Adds the option to simplify the output of Clipper ops that remove minor
detours from the output lines. These detours are not substantive, so
removing them speeds up the rest of the system by removing unimportant
vertices. This also prevents the introduction of inadvertant concave
points when unioning two, closely-sized rounded shapes
Rounded line ends when deflating leads to microscopic jags in the
outline that are not visible but add substantial computation time and
minor error when computing polygon offsets.
Instead, the chamfer deflate method prevents these jagged lines by
clipping angles < 90° by the error level. This does not impact deflate
calls where we explicitly require the angles to be maintained
(cherry picked from commit af10878954)
acos(1) returns 0, so this implies infinite segements to get to 0 error.
This is not reasonable but might be encountered in bad arcs or circles
that have 0 radius. Instead of returning infinite or std::max segments,
we limit the error to be at least 1 IU
(cherry picked from commit 1fda68099f)
Nominally, the zcode of a vertex is unique. This is not 100% true,
however, as we must interlace two 32-bit numbers into a single 32-bit
number. Sorting needs to account for the possibility that the zcode
will be the same while other elements of the vertex are different. This
commit fixes the broken boolean logic to more clearly handle these cases
Fixes https://gitlab.com/kicad/code/kicad/issues/13867
(cherry picked from commit e7fe69b97f)
Just testing a single point to find copper that is outside the board works
until the arc->segment conversion moves the board outline just enough to
have the filled copper slightly (few IU) outside of the converted outline.
Instead, we do an expensive check of comparing the size of the
intersection between the island and the island's intersection with the
board. If the intersection is at least half as large as the original
island, we can say with certainty that the island is inside. The margin
could be much smaller than half but this preserves the intent without
picking an arbitrary number that might be violated
Fixes https://gitlab.com/kicad/code/kicad/issues/13717
The segment iterator creates segments when needed, so using it in a dual
loop creates NlgN more copies than we need. This shifts to a single
copy algorithm that then uses a sorting to preemptively abort the search
once the segments are outside of the search bounding box
Fixes https://gitlab.com/kicad/code/kicad/issues/13191
If the poly set is self-intersecting, the triangulation may be
problematic and the full set needs simplification before. We don't do
this uniformly because the simplification can be a slowdown if it is not
needed
Fixes https://gitlab.com/kicad/code/kicad/issues/12806
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
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
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