From 10d576a301cb6681d1bf64fcfb36daba0cf000ce Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Tue, 22 Oct 2024 19:41:35 +0800 Subject: [PATCH] FIX: crash when slicing(15%, generate perimeter) github: 5037 and jira: 8182 Change-Id: I6719dc0cb4e5de808da14f9911cec19d4db9be3f --- src/libslic3r/Geometry/VoronoiOffset.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/libslic3r/Geometry/VoronoiOffset.cpp b/src/libslic3r/Geometry/VoronoiOffset.cpp index 46105220a..e772b1599 100644 --- a/src/libslic3r/Geometry/VoronoiOffset.cpp +++ b/src/libslic3r/Geometry/VoronoiOffset.cpp @@ -117,7 +117,7 @@ namespace detail { // Return maximum two points, that are at distance "d" from both the line and point. Intersections line_point_equal_distance_points(const Line &line, const Point &ipt, const double d) - { + { assert(line.a != ipt && line.b != ipt); // Calculating two points of distance "d" to a ray and a point. // Point. @@ -667,10 +667,12 @@ void annotate_inside_outside(VD &vd, const Lines &lines) // Set a VertexCategory, verify validity of the operation. auto annotate_vertex = [](const VD::vertex_type *vertex, VertexCategory new_vertex_category) { + if (vertex == nullptr) + return; #ifndef NDEBUG VertexCategory vc = vertex_category(vertex); assert(vc == VertexCategory::Unknown || vc == new_vertex_category); - assert(new_vertex_category == VertexCategory::Inside || + assert(new_vertex_category == VertexCategory::Inside || new_vertex_category == VertexCategory::Outside || new_vertex_category == VertexCategory::OnContour); #endif // NDEBUG @@ -1509,9 +1511,9 @@ Polygons offset( } Polygons offset( - const VD &vd, - const Lines &lines, - double offset_distance, + const VD &vd, + const Lines &lines, + double offset_distance, double discretization_error) { annotate_inside_outside(const_cast(vd), lines); @@ -1528,7 +1530,7 @@ Polygons offset( // An infinite Voronoi Edge-Point (parabola) or Point-Point (line) bisector is split into // a center part close to the Voronoi sites (not skeleton) and the ends (skeleton), // though either part could be clipped by the Voronoi segment. -// +// // Further filtering of the skeleton may be necessary. std::vector skeleton_edges_rough( const VD &vd, @@ -1583,7 +1585,7 @@ std::vector skeleton_edges_rough( } } else { // An infinite Voronoi Edge-Point (parabola) or Point-Point (line) bisector, clipped to a finite Voronoi segment. - // The infinite bisector has a distance (skeleton radius) minimum, which is also a minimum + // The infinite bisector has a distance (skeleton radius) minimum, which is also a minimum // of the skeleton function dr / dt. assert(cell->contains_point() || cell2->contains_point()); if (cell->contains_point() != cell2->contains_point()) {