Commit Graph

30 Commits

Author SHA1 Message Date
Jeff Young e2bc7557cc Clean up arc/circle polygonization.
1) For a while now we've been using a calculated seg count from a given
maxError, and a correction factor to push the radius out so that all
the error is outside the arc/circle.  However, the second calculation
(which pre-dates the first) is pretty much just the inverse of the first
(and yields nothing more than maxError back). This is particularly
sub-optimal given the cost of trig functions.

2) There are a lot of old optimizations to reduce segcounts in certain
situations, someting that our error-based calculation compensates for
 anyway.  (Smaller radii need fewer segments to meet the maxError
condition.) But perhaps more importantly we now surface maxError in the
UI and we don't really want to call it "Max deviation except when it's
not".

3) We were also clamping the segCount twice: once in the calculation
routine and once in most of it's callers.  Furthermore, the caller
clamping was inconsistent (both in being done and in the clamping
value). We now clamp only in the calculation routine.

4) There's no reason to use the correction factors in the 3Dviewer;
it's just a visualization and whether the polygonization error is
inside or outside the shape isn't really material.

5) The arc-correction-disabling stuff (used for solder mask layer) was
somewhat fragile in that it depended on the caller to turn it back on
afterwards.  It's now only exposed as a RAII object which  automatically
cleans up when it goes out of scope.

6) There were also bugs in a couple of the polygonization routines where
we'd accumulate round-off error in adding up the segments and end up with
an overly long last segment (which of course would voilate the error
max). This was the cause of the linked bug and also some issues with vias
that we had fudged in the past with extra clearance.

Fixes https://gitlab.com/kicad/code/kicad/issues/5567
2020-09-11 11:23:49 +01:00
qu1ck 636285311e Make DRAWSEGMENT::GetRectCorners return vector
... instead of modifying the argument.
This will make the method usable in python API and will not incur
permormance penalty because named return value optimization (NRVO)
is a thing since C++11.
But even if copy is not elided vector is moved instead of copied.
https://en.cppreference.com/w/cpp/language/copy_elision
2020-09-07 05:33:10 +00:00
Seth Hillbrand cd51785173 Fix crash with missing board outline 2020-08-21 05:55:22 -07:00
Jeff Young 66ff16dd3d Better board-edge error reporting.
Fixes https://gitlab.com/kicad/code/kicad/issues/4950
2020-08-17 23:55:31 +01:00
Jeff Young 6c74658a98 Finish arc implementation of m_ThirdPoint for EDGE_MODULEs.
Fixes https://gitlab.com/kicad/code/kicad/issues/5191
2020-08-15 17:32:13 +01:00
Jeff Young aeed8e6e2c Finish implementation of DRAWSEGMENT::C_RECT.
It's currently only supported in the Footprint Editor.  It could be
easily added to the board editor (all the code is there), but the board
editor is a little short on room in the drawing tools toolbar.
2020-06-15 20:51:31 +01:00
Jeff Young d046f165de Fix board outline issues.
1) Don't try and do board-edge clearance checking against a
synthetic polygon constructed because we didn't find any edges.

2) Check pads against board edge.

3) Don't report vias as "Track too close to board edge".
2020-05-18 21:11:01 +01:00
Mark Roszko 11ff16be4e Switch to scoped enums 2019-12-20 14:11:39 +00:00
Seth Hillbrand ac435ecd68 Moving further arc approximations down
This corrects an issue with fill segments-per-circle and moves the error
to segmetns calculation down in a number of functions to expose the
single value for approximation
2019-05-22 14:35:17 -07:00
jean-pierre charras abc605fcfa fix a compil warning.
Fix a few comments.
2019-04-02 09:05:42 +02:00
Seth Hillbrand 5eb2a33498 pcbnew: Ensure DRC circles have at least 4 points
This prevents invalid outline errors for small circles.

Fixes: lp:1822641
* https://bugs.launchpad.net/kicad/+bug/1822641
2019-04-01 11:47:58 -07:00
Seth Hillbrand 40309a17ef pcbnew: Check exact overlapping polygons
Checks for polygon collisions in the outline when the polygon contains
two or more segments that exactly overlap.  This also places the DRC
marker at the location where the collision happens.

Fixes: lp:1818163
* https://bugs.launchpad.net/kicad/+bug/1818163

Fixes: lp:1818218
* https://bugs.launchpad.net/kicad/+bug/1818218
2019-03-01 09:38:33 -08:00
Seth Hillbrand 2e0887d49f pcbnew: correctly display edgecut polygons in modules
Commit 1858b7dca corrected the handling of polygons on the edge cut
layer for board items.  This adjusts for the possibility of polygons
in modules on the edge cut layer by applying the module offset/rotation
to the polygon elements.
2018-12-04 15:08:04 -08:00
Seth Hillbrand 1858b7dca7 pcbnew: Allow closed polygons as board edges
Like circles, polygons are self-closed elements that define an outline.
This allows them to be used as such for board outlines and cutouts.

Fixes: lp:1795563
* https://bugs.launchpad.net/kicad/+bug/1795563
2018-12-04 12:32:47 -08:00
Seth Hillbrand 26765161c1 drc: Add board outline and edge crossing
This adds a check for contiguous board outlines to the DRC.  It also
uses the calculated outline to ensure that traces are not crossing the
outlines.

Fixes: lp:1648055
* https://bugs.launchpad.net/kicad/+bug/1648055
2018-12-02 07:54:52 -08:00
jean-pierre charras 0d3637c2ee Fix a few minor I18n issues.
Avoid translation of debug messages.
2018-11-11 10:46:26 +01:00
Jeff Young d9bf1550e4 Improve slightly confusing error message. 2018-10-11 18:53:00 +01:00
jean-pierre charras 1510c2c56f Fix incorrect arc calculation when building the board outline (internal holes only)
Fixes: lp:1783181
https://bugs.launchpad.net/kicad/+bug/1783181
2018-07-24 09:17:20 +02:00
jean-pierre charras 3c6e8c4a40 More support of DRW_SEGMENT Bezier curve (support in 3D viewer, and PnS router). 2018-07-22 18:39:48 +02:00
Maciej Suminski f0b3cf8077 STEP export: Stricter contiguity check
Stricter contiguity check points the user to gaps in the outline.

Fixes: lp:1774351
* https://bugs.launchpad.net/kicad/+bug/1774351
2018-06-19 10:36:21 +02:00
Jeff Young fbf10e941b Switch zone fillets to absolute-error algorithm.
And some general cleanup to related constants, etc.
2018-03-23 12:46:17 +00:00
jean-pierre charras 52ab6216c0 Refinement in circle to segment approximation for clearance area of DRAWSEGMENTS 2018-03-09 15:56:00 +01:00
jean-pierre charras 51fe063524 Circle to polygon conversion: a few enhancements:
* Remove duplicate code
* fix incorrect formulas is some places
* add comments
2018-03-09 13:28:47 +01:00
Jeff Young 8a35e58987 Calculate number of segments based on radius.
Fixes: lp:1754252
* https://bugs.launchpad.net/kicad/+bug/1754252
2018-03-08 18:04:26 +00:00
jean-pierre charras cf5bae7fbf Fix a few doxygen warnings 2017-06-17 10:40:38 +02:00
jean-pierre charras 0f7e898caa Allow selection of number of segments to approximate a circle in convert_drawsegment_list_to_polygon. 2017-03-22 11:47:03 +01:00
jean-pierre charras 05220a86f1 BOARD::GetBoardPolygonOutlines(): do not generate a separate SHAPE_POLY_SET for holes.
They are already managed by SHAPE_POLY_SET board outline.
2017-03-22 11:47:03 +01:00
jean-pierre charras 45b10f0f09 Pcbnew: fix a Regression in fallback to bounding box for board render in 3d-viewer
Fixes: lp: 1674844
https://bugs.launchpad.net/kicad/+bug/1674844
2017-03-22 08:40:48 +01:00
jean-pierre charras ecdfa404cb More work courtyard overlap detection: better code. 2017-03-20 13:06:00 +01:00
jean-pierre charras 2637835a1e First version of courtyard overlap detection 2017-03-19 20:27:45 +01:00