Browse Source

fix 2 points on same spot (2.5.60)
supermerill/SuperSlicer#4436

supermerill 5 months ago
parent
commit
d128ea95f1
1 changed files with 16 additions and 2 deletions
  1. 16 2
      src/libslic3r/GCode.cpp

+ 16 - 2
src/libslic3r/GCode.cpp

@@ -3982,7 +3982,7 @@ std::string GCode::extrude_loop_vase(const ExtrusionLoop &original_loop, const s
     //get extrusion length
     coordf_t length = 0;
     for (ExtrusionPaths::iterator path = paths.begin(); path != paths.end(); ++path) {
-        //path->simplify(SCALED_RESOLUTION); //not useful, this should have been done before.
+        path->simplify(std::max(coord_t(SCALED_EPSILON), scale_t(m_config.resolution.value)), false, 0); //not useful, this should have been done before.
         length += path->length() * SCALING_FACTOR;
     }
 
@@ -4729,7 +4729,21 @@ std::string GCode::extrude_loop(const ExtrusionLoop &original_loop, const std::s
         }
     }
     if (building_paths.empty()) return "";
-
+    
+    //simplify paths
+    for (size_t i=0 ; i< building_paths.size(); ++i){
+        ExtrusionPath &path = building_paths[i];
+        path.simplify(std::max(coord_t(SCALED_EPSILON), scale_t(m_config.resolution.value)), false, 0);
+        if (path.length() < std::max(coord_t(SCALED_EPSILON), scale_t(m_config.resolution.value))) {
+            if (i + 1 < building_paths.size()) {
+                building_paths[i+1].polyline.set_points().front() = path.polyline.front();
+                building_paths.erase(building_paths.begin() + i);
+                --i;
+            } else {
+                building_paths.pop_back();
+            }
+        }
+    }
     const ExtrusionPaths& wipe_paths = building_paths;
     for (const ExtrusionPath &path : wipe_paths)
         for (int i = 1; i < path.polyline.get_points().size(); ++i)