diff --git a/tests/libslic3r/test_voronoi.cpp b/tests/libslic3r/test_voronoi.cpp index db12e2fec..7f25797f5 100644 --- a/tests/libslic3r/test_voronoi.cpp +++ b/tests/libslic3r/test_voronoi.cpp @@ -2055,6 +2055,50 @@ TEST_CASE("Voronoi missing vertex 3", "[VoronoiMissingVertex3]") // REQUIRE(!has_missing_voronoi_vertices(poly, vd)); } +TEST_CASE("Voronoi missing vertex 4", "[VoronoiMissingVertex4]") +{ + // Probably the reason why Voronoi vertex is missing is that 19299999 and 19300000 are very close. + Polygon polygon_1 = { + Point(27000000, -18900000), + Point(27000000, 20000000), + Point(19000000, 20000000), + Point(19000000, 19299999), + Point(26000000, -18000000), + Point(-19000000, -18000000), + Point(-27000000, 19300000), + Point(-19000000, 19300000), + Point(-19000000, 20000000), + Point(-28000000, 20000000), + Point(-20000000, -18900000), + }; + + // Maybe this is the same case as the previous, but the missing Voronoi vertex is different. + Polygon polygon_2 = { + Point(27000000, -18900000), + Point(27000000, 20000000), + Point(19000000, 20000000), + Point(19000000, 19299999), + Point(19000000, -18000000), // Just this point is different other points are the same as previous. + Point(-19000000, -18000000), + Point(-27000000, 19300000), + Point(-19000000, 19300000), + Point(-19000000, 20000000), + Point(-28000000, 20000000), + Point(-20000000, -18900000), + }; + + Geometry::VoronoiDiagram vd_1; + Geometry::VoronoiDiagram vd_2; + Lines lines_1 = to_lines(polygon_1); + Lines lines_2 = to_lines(polygon_2); + construct_voronoi(lines_1.begin(), lines_1.end(), &vd_1); + construct_voronoi(lines_2.begin(), lines_2.end(), &vd_2); +#ifdef VORONOI_DEBUG_OUT + dump_voronoi_to_svg(debug_out_path("voronoi-missing-vertex4-1-out.svg").c_str(), vd_1, Points(), lines_1); + dump_voronoi_to_svg(debug_out_path("voronoi-missing-vertex4-2-out.svg").c_str(), vd_2, Points(), lines_2); +#endif +} + // In this case, the Voronoi vertex (146873, -146873) is included twice. // Also, near to those duplicate Voronoi vertices is another Voronoi vertex (146872, -146872). // Rotating the polygon will help solve this problem, but then there arise three very close Voronoi vertices.