diff --git a/qa/libs/kimath/geometry/fixtures_geometry.h b/qa/libs/kimath/geometry/fixtures_geometry.h index 9d66f6bbc2..93a3352b49 100644 --- a/qa/libs/kimath/geometry/fixtures_geometry.h +++ b/qa/libs/kimath/geometry/fixtures_geometry.h @@ -46,6 +46,8 @@ struct CommonTestData SHAPE_POLY_SET uniqueVertexPolySet; SHAPE_POLY_SET solidPolySet; SHAPE_POLY_SET holeyPolySet; + SHAPE_POLY_SET curvedPolyWrapRound; ///< Causes arc wraparound when reloading from Clipper + ///< see https://gitlab.com/kicad/code/kicad/-/issues/9670 SHAPE_POLY_SET holeyCurvedPolySingle; ///< Polygon with a single outline + multiple holes. ///< Holes and outline contain arcs SHAPE_POLY_SET holeyCurvedPolyMulti; ///< Polygon with a multiple outlines + multiple holes. @@ -146,6 +148,12 @@ struct CommonTestData hole.SetClosed( true ); holeyPolySet.AddHole( hole ); + //GENERATE CURVED POLYGON THAT CAUSES WRAPAROUND + SHAPE_LINE_CHAIN wrapLine; + wrapLine.Append( SHAPE_ARC( { -4300000, -6950000 }, { 2000000, 0 }, { -4300000, 6950000 }, 0 ) ); + wrapLine.Append( SHAPE_ARC( { -4300000, 2200000 }, { -2700000, 0 }, { -4300000, -2200000 }, 0 ) ); + wrapLine.SetClosed( true ); + curvedPolyWrapRound.AddOutline( wrapLine ); // GENERATE CURVED POLYGON WITH HOLES // For visualisation, launch test_pns with the arguments "viewcurvedpoly -[single|multi]" diff --git a/qa/libs/kimath/geometry/test_shape_poly_set_arcs.cpp b/qa/libs/kimath/geometry/test_shape_poly_set_arcs.cpp index 13cc59ac4d..b5a6fc356e 100644 --- a/qa/libs/kimath/geometry/test_shape_poly_set_arcs.cpp +++ b/qa/libs/kimath/geometry/test_shape_poly_set_arcs.cpp @@ -43,7 +43,8 @@ BOOST_AUTO_TEST_CASE( TestSimplify ) std::map polysToTest = { { "Case 1: Single polygon", testData.holeyCurvedPolySingle }, - //{ "Case 2: Multi polygon", testData.holeyCurvedPolyMulti } // This test fails right now: + { "Case 2: Wraparound polygon", testData.curvedPolyWrapRound }, + //{ "Case 3: Multi polygon", testData.holeyCurvedPolyMulti } // This test fails right now: // clipper seems to not handle // multiple outlines correctly }; @@ -68,6 +69,7 @@ BOOST_AUTO_TEST_CASE( TestSimplify ) std::vector foundArcs; testPoly.GetArcs( foundArcs ); + BOOST_CHECK( GEOM_TEST::IsPolySetValid( testPoly ) ); BOOST_CHECK_EQUAL( testPoly.Area(), originalArea ); BOOST_CHECK_EQUAL( originalArcs.size(), foundArcs.size() ); KI_TEST::CheckUnorderedMatches( originalArcs, foundArcs,