diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp index 8b9a46f8a..7ecb180df 100644 --- a/xs/src/libslic3r/GCode.cpp +++ b/xs/src/libslic3r/GCode.cpp @@ -1718,7 +1718,8 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou } // extrude all loops ccw - bool was_clockwise = loop.make_counter_clockwise(); + //no! this was decided in perimeter_generator + bool was_clockwise = false;// loop.make_counter_clockwise(); SeamPosition seam_position = m_config.seam_position; if (loop.loop_role() == elrSkirt) diff --git a/xs/src/libslic3r/PerimeterGenerator.cpp b/xs/src/libslic3r/PerimeterGenerator.cpp index e33a39592..f9a7652bf 100644 --- a/xs/src/libslic3r/PerimeterGenerator.cpp +++ b/xs/src/libslic3r/PerimeterGenerator.cpp @@ -158,8 +158,8 @@ void PerimeterGenerator::process() // We can add more perimeters if there are uncovered overhangs // improvement for future: find a way to add perimeters only where it's needed. // It's hard to do, so here is a simple version. - bool may_add_more_perimeters = false; - if (this->config->extra_perimeters && i > loop_number && !last.empty() + bool has_overhang = false; + if (this->config->extra_perimeters /*&& i > loop_number*/ && !last.empty() && this->lower_slices != NULL && !this->lower_slices->expolygons.empty()){ //split the polygons with bottom/notbottom ExPolygons unsupported = diff_ex(last, this->lower_slices->expolygons, true); @@ -199,7 +199,7 @@ void PerimeterGenerator::process() } if (!unsupported.empty()) { //add fake perimeters here - may_add_more_perimeters = true; + has_overhang = true; } } } @@ -279,7 +279,7 @@ void PerimeterGenerator::process() last.clear(); break; } else if (i > loop_number) { - if (may_add_more_perimeters) { + if (has_overhang) { loop_number++; contours.emplace_back(); holes.emplace_back(); @@ -290,11 +290,11 @@ void PerimeterGenerator::process() } for (const ExPolygon &expolygon : next_onion) { - contours[i].emplace_back(PerimeterGeneratorLoop(expolygon.contour, i, true)); + contours[i].emplace_back(PerimeterGeneratorLoop(expolygon.contour, i, true, has_overhang)); if (! expolygon.holes.empty()) { holes[i].reserve(holes[i].size() + expolygon.holes.size()); for (const Polygon &hole : expolygon.holes) - holes[i].emplace_back(PerimeterGeneratorLoop(hole, i, false)); + holes[i].emplace_back(PerimeterGeneratorLoop(hole, i, false, has_overhang)); } } last = std::move(next_onion); @@ -536,7 +536,10 @@ ExtrusionEntityCollection PerimeterGenerator::_traverse_loops( ExtrusionEntityCollection children = this->_traverse_loops(loop.children, thin_walls); if (loop.is_contour) { - eloop.make_counter_clockwise(); + if (loop.is_overhang && this->layer_id % 2 == 1) + eloop.make_clockwise(); + else + eloop.make_counter_clockwise(); entities.append(children.entities); entities.append(eloop); } else { diff --git a/xs/src/libslic3r/PerimeterGenerator.hpp b/xs/src/libslic3r/PerimeterGenerator.hpp index 1a9bb7c2c..3c2288b0a 100644 --- a/xs/src/libslic3r/PerimeterGenerator.hpp +++ b/xs/src/libslic3r/PerimeterGenerator.hpp @@ -19,13 +19,18 @@ public: // Is it a contour or a hole? // Contours are CCW oriented, holes are CW oriented. bool is_contour; + //overhang may need to be reversed + bool is_overhang; // Depth in the hierarchy. External perimeter has depth = 0. An external perimeter could be both a contour and a hole. unsigned short depth; // Children contour, may be both CCW and CW oriented (outer contours or holes). std::vector children; - - PerimeterGeneratorLoop(Polygon polygon, unsigned short depth, bool is_contour) : - polygon(polygon), is_contour(is_contour), depth(depth) {} + + + PerimeterGeneratorLoop(Polygon polygon, unsigned short depth, bool is_contour) : + polygon(polygon), is_contour(is_contour), depth(depth), is_overhang(false) {} + PerimeterGeneratorLoop(Polygon polygon, unsigned short depth, bool is_contour, bool is_overhang) : + polygon(polygon), is_contour(is_contour), depth(depth), is_overhang(is_overhang) {} // External perimeter. It may be CCW or CW oriented (outer contour or hole contour). bool is_external() const { return this->depth == 0; } // An island, which may have holes, but it does not have another internal island.