From f4e61ffddd0e941f502b60259fb3a08fc66430a9 Mon Sep 17 00:00:00 2001 From: Filip Sykala - NTB T15p Date: Wed, 12 Feb 2025 15:35:59 +0100 Subject: [PATCH] FIX SPE-2674_symphysis.3mf 2/2 Island which can't create Voronoi Diagram are supported by one point in center of bounding box --- .../SLA/SupportIslands/SupportIslandPoint.hpp | 2 ++ .../SupportIslands/UniformSupportIsland.cpp | 24 ++++++++++++++++--- tests/data/sla_islands/SPE-2674_2.svg | 11 +++++++++ tests/sla_print/sla_supptgen_tests.cpp | 1 + 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 tests/data/sla_islands/SPE-2674_2.svg diff --git a/src/libslic3r/SLA/SupportIslands/SupportIslandPoint.hpp b/src/libslic3r/SLA/SupportIslands/SupportIslandPoint.hpp index f42a1b9a32..5ca2b9393e 100644 --- a/src/libslic3r/SLA/SupportIslands/SupportIslandPoint.hpp +++ b/src/libslic3r/SLA/SupportIslands/SupportIslandPoint.hpp @@ -26,6 +26,8 @@ public: thick_part_outline, // keep position align with island outline thick_part_inner, // point inside wide part, without restriction on move + bad_shape_for_vd, // can't make a Voronoi diagram on the shape + permanent, // permanent support point with static position undefined }; diff --git a/src/libslic3r/SLA/SupportIslands/UniformSupportIsland.cpp b/src/libslic3r/SLA/SupportIslands/UniformSupportIsland.cpp index 26d0e99895..0955197e76 100644 --- a/src/libslic3r/SLA/SupportIslands/UniformSupportIsland.cpp +++ b/src/libslic3r/SLA/SupportIslands/UniformSupportIsland.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "VoronoiGraph.hpp" #include "Parabola.hpp" @@ -2059,7 +2060,7 @@ coord_t get_longest_distance(const IslandPartChanges& changes, Position* center return farest_from_change; const NodeDistance *prev_node_distance = farest_distnace; - const NodeDistance *node_distance = prev_node_distance; + const NodeDistance *node_distance = nullptr; // iterate over longest path to find center(half distance) while (prev_node_distance->shortest_distances[change_index].distance >= half_distance) { node_distance = prev_node_distance; @@ -2402,16 +2403,33 @@ SupportIslandPoints uniform_support_island( #ifdef OPTION_TO_STORE_ISLAND if (!path.empty()){ // add center support point into image SVG svg = draw_island(path, island, simplified_island); + svg.draw_text(Point{0, 0}, "one center support point", "black"); draw(svg, supports, config.head_radius); } #endif // OPTION_TO_STORE_ISLAND return supports; } - Slic3r::Geometry::VoronoiDiagram vd; + Geometry::VoronoiDiagram vd; Lines lines = to_lines(simplified_island); vd.construct_voronoi(lines.begin(), lines.end()); - Slic3r::Voronoi::annotate_inside_outside(vd, lines); + assert(vd.get_issue_type() == Geometry::VoronoiDiagram::IssueType::NO_ISSUE_DETECTED); + if (vd.get_issue_type() != Geometry::VoronoiDiagram::IssueType::NO_ISSUE_DETECTED) { + // error state suppport island by one point + Point center = BoundingBox{island.contour.points}.center(); + SupportIslandPoints supports; + supports.push_back(std::make_unique( + center, SupportIslandInnerPoint::Type::bad_shape_for_vd)); +#ifdef OPTION_TO_STORE_ISLAND + if (!path.empty()) { // add center support point into image + SVG svg = draw_island(path, island, simplified_island); + svg.draw_text(Point{0, 0}, "Can't create Voronoi Diagram for the shape", "red"); + draw(svg, supports, config.head_radius); + } +#endif // OPTION_TO_STORE_ISLAND + return supports; + } + Voronoi::annotate_inside_outside(vd, lines); VoronoiGraph skeleton = VoronoiGraphUtils::create_skeleton(vd, lines); VoronoiGraph::ExPath longest_path; diff --git a/tests/data/sla_islands/SPE-2674_2.svg b/tests/data/sla_islands/SPE-2674_2.svg new file mode 100644 index 0000000000..96c36acaae --- /dev/null +++ b/tests/data/sla_islands/SPE-2674_2.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/tests/sla_print/sla_supptgen_tests.cpp b/tests/sla_print/sla_supptgen_tests.cpp index 4af6375211..1cd1e2be90 100644 --- a/tests/sla_print/sla_supptgen_tests.cpp +++ b/tests/sla_print/sla_supptgen_tests.cpp @@ -390,6 +390,7 @@ ExPolygons createTestIslands(double size) create_cylinder_bottom_slice(), load_svg(dir + "lm_issue.svg"), // change from thick to thin and vice versa on circle load_svg(dir + "SPE-2674.svg"), // center of longest path lay inside of the VD node + load_svg(dir + "SPE-2674_2.svg"), // missing Voronoi vertex even after the rotation of input. // still problem // three support points