43 std::map<std::string, SHAPE_POLY_SET> polysToTest =
52 for( std::pair<std::string, SHAPE_POLY_SET> testCase : polysToTest )
54 BOOST_TEST_CONTEXT( testCase.first )
58 double originalArea = testPoly.
Area();
60 std::vector<SHAPE_ARC> originalArcs;
61 testPoly.
GetArcs( originalArcs );
63 for(
int i = 1; i <= 3; i++ )
65 BOOST_TEST_CONTEXT(
"Simplify Iteration " << i )
69 std::vector<SHAPE_ARC> foundArcs;
73 BOOST_CHECK_EQUAL( testPoly.
Area(), originalArea );
74 BOOST_CHECK_EQUAL( originalArcs.size(), foundArcs.size() );
79 return aA == aB || aA.
Reversed() == aB;
96 std::map<std::string, SHAPE_POLY_SET> polysToTest = {
103 for( std::pair<std::string, SHAPE_POLY_SET> testCase : polysToTest )
105 BOOST_TEST_CONTEXT( testCase.first )
118 double testPolyArea = testPoly.
Area();
119 double opPolyArea = opPoly.
Area();
123 double intersectArea = intersectionPoly.
Area();
130 double unionArea = unionPoly.
Area();
135 BOOST_CHECK_CLOSE( testPolyArea + opPolyArea - intersectArea, unionArea, 0.01 );
148 std::map<std::string, SHAPE_POLY_SET> polysToTest = {
154 for( std::pair<std::string, SHAPE_POLY_SET> testCase : polysToTest )
156 BOOST_TEST_CONTEXT( testCase.first )
159 double originalArea = testPoly.
Area();
163 BOOST_CHECK_EQUAL( testPoly.
Area(), originalArea );
165 std::vector<SHAPE_ARC> arcBuffer;
168 BOOST_CHECK_EQUAL( arcBuffer.size(), 0 );
SHAPE_ARC Reversed() const
Represent a set of closed polygons.
void BooleanAdd(const SHAPE_POLY_SET &b)
Perform boolean polyset union.
void ClearArcs()
Removes all arc references from all the outlines and holes in the polyset.
double Area()
Return the area of this poly set.
void GetArcs(std::vector< SHAPE_ARC > &aArcBuffer) const
Appends all the arcs in this polyset to aArcBuffer.
void Simplify()
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections)
void BooleanIntersection(const SHAPE_POLY_SET &b)
Perform boolean polyset intersection.
bool IsPolySetValid(const SHAPE_POLY_SET &aSet)
Verify that a SHAPE_POLY_SET has been assembled correctly by verifying each of the outlines and holes...
void CheckUnorderedMatches(const EXP_CONT &aExpected, const FOUND_CONT &aFound, MATCH_PRED aMatchPredicate)
Check that a container of "found" objects matches a container of "expected" objects.
Common data for some of the SHAPE_POLY_SET tests:
SHAPE_POLY_SET holeyCurvedPolySingle
Polygon with a single outline + multiple holes.
SHAPE_POLY_SET holeyCurvedPolyInter
Polygon with a single outlines + multiple holes.
SHAPE_POLY_SET curvedPolyWrapRound
Causes arc wraparound when reloading from Clipper see https://gitlab.com/kicad/code/kicad/-/issues/96...
SHAPE_POLY_SET holeyCurvedPolyMulti
Polygon with a multiple outlines + multiple holes.
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(TestSimplify)
Simplify the polygon a large number of times and check that the area does not change and also that th...