Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/crashing when generating walls #6325

Merged
merged 2 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/libslic3r/Geometry/MedialAxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,19 @@ MedialAxis::MedialAxis(double min_width, double max_width, const ExPolygon &expo
void MedialAxis::build(ThickPolylines* polylines)
{
m_vd.construct_voronoi(m_lines.begin(), m_lines.end());

// For several ExPolygons in SPE-1729, an invalid Voronoi diagram was produced that wasn't fixable by rotating input data.
// Those ExPolygons contain very thin lines and holes formed by very close (1-5nm) vertices that are on the edge of our resolution.
// Those thin lines and holes are both unprintable and cause the Voronoi diagram to be invalid.
// So we filter out such thin lines and holes and try to compute the Voronoi diagram again.
if (!m_vd.is_valid()) {
m_lines = to_lines(closing_ex({m_expolygon}, float(2. * SCALED_EPSILON)));
m_vd.construct_voronoi(m_lines.begin(), m_lines.end());

if (!m_vd.is_valid())
BOOST_LOG_TRIVIAL(error) << "MedialAxis - Invalid Voronoi diagram even after morphological closing.";
}

Slic3r::Voronoi::annotate_inside_outside(m_vd, m_lines);
// static constexpr double threshold_alpha = M_PI / 12.; // 30 degrees
// std::vector<Vec2d> skeleton_edges = Slic3r::Voronoi::skeleton_edges_rough(vd, lines, threshold_alpha);
Expand Down
6 changes: 3 additions & 3 deletions src/libslic3r/Geometry/Voronoi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ void VoronoiDiagram::copy_to_local(voronoi_diagram_type &voronoi_diagram) {
new_edge.prev(&m_edges[prev_edge_idx]);
}
}

m_voronoi_diagram.clear();
m_is_modified = true;
}

template<typename SegmentIterator>
Expand Down Expand Up @@ -346,9 +349,6 @@ VoronoiDiagram::try_to_repair_degenerated_voronoi_diagram_by_rotation(const Segm
for (vertex_type &vertex : m_vertices)
vertex.color(0);

m_voronoi_diagram.clear();
m_is_modified = true;

return issue_type;
}

Expand Down