From 1904b7b904597d9e9a8a77deeb1a9d9cab604b03 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 19 Feb 2021 10:57:18 +0100 Subject: [PATCH] Bugfix: custom seam did not work for triangles that were exactly vertical The projection algorithm was originally made for custom supports, so vertical triangles were not interesting. They are for seam. Instead of rewriting the algorithm and risking more bugs, the edge case is detected and the triangle is tilted slightly. --- src/libslic3r/GCode/SeamPlacer.cpp | 53 +++++++++++++++--------------- src/libslic3r/PrintObject.cpp | 5 +++ 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/libslic3r/GCode/SeamPlacer.cpp b/src/libslic3r/GCode/SeamPlacer.cpp index 9738a0016..44b1fcff1 100644 --- a/src/libslic3r/GCode/SeamPlacer.cpp +++ b/src/libslic3r/GCode/SeamPlacer.cpp @@ -750,35 +750,36 @@ void SeamPlacer::apply_custom_seam(const Polygon& polygon, size_t po_idx, } } -//////////////////////// -// std::ostringstream os; -// os << std::setw(3) << std::setfill('0') << layer_id; -// int a = scale_(30.); -// SVG svg("custom_seam" + os.str() + ".svg", BoundingBox(Point(-a, -a), Point(a, a))); -// //if (! m_enforcers[po_idx].empty()) -// // svg.draw(m_enforcers[po_idx][layer_id].polys, "blue"); -// //if (! m_blockers[po_idx].empty()) -// // svg.draw(m_blockers[po_idx][layer_id].polys, "red"); +#if 0 + std::ostringstream os; + os << std::setw(3) << std::setfill('0') << layer_id; + int a = scale_(30.); + SVG svg("custom_seam" + os.str() + ".svg", BoundingBox(Point(-a, -a), Point(a, a))); + if (! m_enforcers[po_idx].empty()) + svg.draw(m_enforcers[po_idx][layer_id].polys, "blue"); + if (! m_blockers[po_idx].empty()) + svg.draw(m_blockers[po_idx][layer_id].polys, "red"); + + if (! blockers_idxs.empty()) { + ; + } + size_t min_idx = std::min_element(penalties.begin(), penalties.end()) - penalties.begin(); -// size_t min_idx = std::min_element(penalties.begin(), penalties.end()) - penalties.begin(); - -// //svg.draw(polygon.points[idx_min], "red", 6e5); -// for (size_t i=0; i 0.) continue; + // The algorithm does not process vertical triangles, but it should for seam. + // In that case, tilt the triangle a bit so the projection does not degenerate. + if (seam && z_comp == 0.f) + facet[0].x() += float(EPSILON); + // Sort the three vertices according to z-coordinate. std::sort(facet.begin(), facet.end(), [](const Vec3f& pt1, const Vec3f&pt2) {