89 Commits

Author SHA1 Message Date
Seth Hillbrand
8e97855557 Fix Clipper2 handling of Inflate/Deflate
For unknown reasons, Clipper2 only returns Paths structures from the
ClipperOffset::Execute routine.  Further, the Paths are not properly
ordered (outline->hole in outline, outline2->hole in outline2).
To get proper hierarchy, we need to run an additional pass of the
solution with the paths as Subject in a null union.  This is effectively
a Simplify() call but we keep the data in Clipper format to reduce the
churn/calc time
2022-10-28 17:01:36 -07:00
Seth Hillbrand
546e16a002 Add multi-level fallback in tesselation
Some clipper cases do not get resolved with the `FAST` mode, so in those
cases, do a second pass in the `SIMPLE` mode.  If both fail, return a
broken polygon instead of an infinite loop

Fixes https://gitlab.com/kicad/code/kicad/issues/12761
2022-10-28 10:17:58 -07:00
Seth Hillbrand
4cdf0bd6c9 Clipper2: Handle nested poly/hole/poly returns
In Clipper1, we had a flat tree structure on returns.  Clipper2 nests
these, so we need to properly handle the nesting structure when
importing the polygons
2022-10-21 16:14:34 -07:00
Seth Hillbrand
27add591ec Add Clipper2
Currently this lives behind the advanced config flag `UseClipper2`.
Enabling this flag will route all Clipper-based calls through the
Clipper2 library instead of the older Clipper.  The changes should be
mostly transparent.

Of note, Clipper2 does not utilize the `STRICTLY_SIMPLE` flag because
clipper1 did not actually guarantee a strictly simple polygon.
Currently we ignore this flag but we may decide to run strictly-simple
operations through a second NULL union to simplify the results as much
as possible.

Additionally, the inflation options are slightly different.  We cannot
choose the fallback miter.  The fallback miter is always square.  This
only affects the CHAMFER_ACUTE_CORNERS option in inflate, which does not
appear to be used.

Lastly, we currently utilize the 64-bit integer coordinates for
calculations.  This appears to still be faster than 32-bit calculations
in Clipper1 on a modern x86 system.  This may not be the case for older
systems, particularly 32-bit systems.
2022-10-19 16:25:45 -07:00
Seth Hillbrand
df8b7a8fef Fix RemoveNullSegments 2022-08-29 17:08:01 -07:00
Seth Hillbrand
a7f978daf6 Fix typo 2022-08-26 16:58:21 -07:00
Seth Hillbrand
5a37211fdb Handle cases where Simplify removes all outlines
This could theoretically happen for a fully degenerate polygon

Fixes https://gitlab.com/kicad/code/kicad/issues/12120
2022-08-26 16:41:57 -07:00
Seth Hillbrand
146495672e Utilize our combine_hash routine for multiple hash
We should be using the one routine every time we want to build a hash
from indepedent values rather than rebuilding it differently in multiple
places
2022-08-26 08:45:13 -07:00
Seth Hillbrand
16e3d40552 ADDED: Display calculated clearance in status bar
In addition to showing resolved clearance, we also show the calculated
clearance in the same method as is used for DRC.  This will allow users
to better examine their system while working.

Fixes https://gitlab.com/kicad/code/kicad/issues/7934
2022-07-21 15:44:48 -07:00
Jeff Young
b727bfc16d Performance: avoid sqrt at all costs. 2022-07-16 18:42:32 +01:00
Seth Hillbrand
2a9d7314ca Initialize area check
Ensure that the max_poly set is zero before using
2022-05-26 08:19:16 -07:00
Seth Hillbrand
7dd0c67afd Handle hand-drawn holes in unfracture
We can't know that all holes will be ccw when entering unfracture.
Instead, we set the largest polyline to be the outline and the others to
be the holes.

(cherry picked from commit 1fe956c06961ad7e1364f8e9ea6d6c55218570e1)
2022-05-25 13:21:04 -07:00
Jeff Young
65185f53a1 Rotate fp zones before comparing with library versions.
Also includes some performance fixes to not copy around triangulation
data when it's not needed.

Fixes https://gitlab.com/kicad/code/kicad/issues/10143
2022-03-14 15:53:24 +00:00
Seth Hillbrand
e278e77314 Rework of a24cdcb3f0
Inflate with linked holes needs to account for fractured polygons,
otherwise inflating with positive value will create rounded divots where
overlapping fracture lines meet and inflating with negative value will
create spaces between fracture lines.

Calling Simplify before Inflate takes an inordinate amount of time as
the Clipper healing routine is rather slow.  Our own Unfracture is meant
to heal the results of our Fracture routine and works much more quickly.
After healing, we still call the Simplify routine

(cherry picked from commit 9ca35cbcee47ec844d491b4d4a9047b518e8aced)
2022-03-10 09:15:50 -08:00
Seth Hillbrand
e8d6d03247 Always return simplified polygons
Clipper can handle complex input polygons but we will sometimes struggle
dealing with outputs from the inflate routine that have degenerate or
overlapping points.  Calling Simplify after the inflate keeps our
polygons easier to handle

Fixes https://gitlab.com/kicad/code/kicad/issues/11036

(cherry picked from commit a24cdcb3f0f22c7b0a24fc452658f1dcb57c9870)
2022-03-09 16:19:44 -08:00
Jeff Young
e4b56ab7f1 Performance fixes for the board from hell.... 2022-03-08 23:54:34 +00:00
Jeff Young
b1bd8421e0 Performance: remove associated triangle sets when removing outline.
This saves us having to re-triangulate at the end of zone filling.
2022-02-16 17:00:54 +00:00
Jeff Young
d8c4f2cb09 Performance improvements for zone filler. 2022-02-15 19:19:02 +00:00
Jeff Young
5c9e718407 Performance enhancements for connectivity.
1) Generate SHAPE_POLY_SET triangulation by outline so they can be
shared between connectivity system and other clients.
2) Don't add items to connectivity when reading board; we're going
to do a total rebuild anyway.
3) Use multithreading when caching triangulation.
2022-02-15 12:20:34 +00:00
Jeff Young
98b9c6e2a1 Better progress reporting and a slight performance boost on commit. 2022-02-15 12:20:34 +00:00
Jeff Young
90f6edad61 Move connectivity algo to collision-based routines.
Fixes https://gitlab.com/kicad/code/kicad/issues/1800

Fixes https://gitlab.com/kicad/code/kicad/issues/1769
2022-02-13 00:35:11 +00:00
Wayne Stambaugh
e93b7b05ec Wide characterize libs and bitmap2component source.
(cherry picked from commit 54f91a022120a01861853714d3fd530c7f50de88)
2022-02-09 11:49:58 -05:00
Jeff Young
4eac8d7c66 Remove unit-less angles from geometry lib APIs. 2022-01-20 21:10:04 +00:00
Jeff Young
07013d00e1 More EDA_ANGLE. 2022-01-14 16:08:19 +00:00
Tomasz Wlostowski
78968f75c0 SHAPE_POLY_SET: polysets can now be built from a bunch of arbitraily ordered oriented outlines. Used by the SVG hole support 2021-12-31 17:04:16 +01:00
jean-pierre charras
29c3601061 SHAPE_POLY_SET: add FullPointCount(), mainly for statistics and debug. 2021-10-24 15:06:24 +02:00
Roberto Fernandez Bautista
4b8ca18bf7 Remove unfinished code for handling arcs in SHAPE_POLY_SET::booleanOp
Boolean Ops on polygons with arcs are not supported (the only exception
is Simplify)

Also fix a bug in SHAPE_LINE_CHAIN::splitArc that resulted in an
exception

Partially fixes https://gitlab.com/kicad/code/kicad/-/issues/9380
2021-10-13 18:29:32 +01:00
Seth Hillbrand
c1e6fdfb47 Polygon triangulation: Check for broken remainders
If the last three points of a tesselation are concave, we will never be
able to triangulate them.  They were likely formed from a bad polygon,
so we will drop the triangle and return completed

Fixes https://gitlab.com/kicad/code/kicad/issues/9380
2021-10-12 12:14:42 -07:00
Jon Evans
e2368b733c Allow selection of NPTH pads with zero copper size
Fixes https://gitlab.com/kicad/code/kicad/-/issues/9249
2021-09-26 18:17:50 -04:00
Jeff Young
46949abe4a Don't scroll to highlight an object already visible. 2021-09-25 15:31:52 +01:00
Seth Hillbrand
28bd734313 Prevent invalid paths in fracture
We are not always sure of the path validity in fracture.  Nominally, the
Clipper Simplify routine should remove invalid parts but in the case
where it doesn't, we need to recover gracefully, even if the output
polygon is not valid.

Fixes https://gitlab.com/kicad/code/kicad/issues/9199
2021-09-21 10:49:39 -07:00
Jeff Young
f64abcba36 Restore BBoxCache usage for zone fill performance. 2021-09-09 16:43:47 +01:00
Jeff Young
c00f4ed5d2 Add regression tests for track cleaner. 2021-08-03 16:17:18 +01:00
Wayne Stambaugh
78e5e98ea0 Pass VECTOR2I objects by reference instead of on the stack. 2021-07-27 08:41:27 -04:00
Wayne Stambaugh
4c457b5ed3 More NULL expunging. 2021-07-18 14:31:55 -04:00
Jon Evans
3103ff9aa3 Fix display of filled polygons with arcs in the outline 2021-07-04 12:10:59 -04:00
Jon Evans
ddc20dadc0 Formatting and spelling tweaks 2021-07-03 15:43:40 -04:00
Roberto Fernandez Bautista
cee5920d5c Remove dead code (SHAPE_LINE_CHAIN::DetectArcs) 2021-07-03 19:37:50 +00:00
Roberto Fernandez Bautista
778c64de88 Implement ClearArcs() and check curved polys don't get a booleanOp
We cannot (yet) support passing several curved outlines through clipper.
In these cases, the caller should ClearArcs() before processing.
2021-07-03 19:37:50 +00:00
Roberto Fernandez Bautista
260a9d0540 Use ZFillFunction to modify arcs post clipper (does not fully work yet)
Added a unit test to verify union and intersection of polygons result
in desired results: subject + clip - intersect == union
2021-07-03 19:37:50 +00:00
Roberto Fernandez Bautista
437e2783fb Use Clipper Z value to detect arcs post clipper 2021-07-03 19:37:50 +00:00
Roberto Fernandez Bautista
c1361ae173 SHAPE_POLY_SET: Detect arcs after boolean operations 2021-07-03 19:37:50 +00:00
Seth Hillbrand
8521deb38d De-scope ClipperLib namespace 2021-07-03 19:37:50 +00:00
Seth Hillbrand
4f4deece6d ADDED support for reading/writing arcs in polys
This adds support for reading and writing arc elements in polygons.
2021-07-03 19:37:50 +00:00
luz paz
f968fc8719 Fix source comment / documentation typos 2021-06-09 19:32:58 +00:00
Jeff Young
976e756b02 Formatting. 2021-06-03 18:33:59 +01:00
Jon Evans
2c05d99d9f SHAPE_POLY_SET: Fix segment collision testing
It appears as though there was an optimization to skip testing segments if
one of their endpoints (and only the A point) was inside.  Unclear the reason
for this, but I'm going to assume that it was intended to optimize the case
where both points are inside (like the point case above it).
2021-04-04 20:12:45 -04:00
Jon Evans
bd6539885b Fix SHAPE_POLY_SET::SquaredDistanceToPolygon ignoring aNearest if unlucky 2021-04-04 19:38:54 -04:00
Dominik Wernberger
e2aa7be4b3 Added a lot of consts and refactored a few lines 2021-03-08 12:49:48 -08:00
Jeff Young
e89f9db438 Footprint disallow layer checking needs to be based on courtyards.
Fixes https://gitlab.com/kicad/code/kicad/issues/7620
2021-02-20 14:13:36 +00:00