Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/CuraEngine.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/slicer.cpp3
-rw-r--r--src/utils/polygon.cpp11
-rw-r--r--src/utils/polygon.h24
3 files changed, 34 insertions, 4 deletions
diff --git a/src/slicer.cpp b/src/slicer.cpp
index 5bfc94a27..4f9501869 100644
--- a/src/slicer.cpp
+++ b/src/slicer.cpp
@@ -789,8 +789,7 @@ void SlicerLayer::makePolygons(const Mesh* mesh)
it = std::remove_if(openPolylines.begin(), openPolylines.end(), [snap_distance](PolygonRef poly) { return poly.shorterThan(snap_distance); });
openPolylines.erase(it, openPolylines.end());
- constexpr bool for_polylines = true;
- openPolylines.removeDegenerateVerts(for_polylines);
+ openPolylines.removeDegenerateVertsPolyline();
}
Slicer::Slicer(Mesh* i_mesh, const coord_t thickness, const size_t slice_layer_count,
diff --git a/src/utils/polygon.cpp b/src/utils/polygon.cpp
index e9445e1f2..bb6797cb7 100644
--- a/src/utils/polygon.cpp
+++ b/src/utils/polygon.cpp
@@ -585,8 +585,17 @@ void Polygons::removeSmallAreas(const double min_area_size, const bool remove_ho
paths.resize(new_end-paths.begin());
}
+void Polygons::removeDegenerateVerts()
+{
+ _removeDegenerateVerts(false);
+}
+
+void Polygons::removeDegenerateVertsPolyline()
+{
+ _removeDegenerateVerts(true);
+}
-void Polygons::removeDegenerateVerts(const bool for_polyline)
+void Polygons::_removeDegenerateVerts(const bool for_polyline)
{
Polygons& thiss = *this;
for(size_t poly_idx = 0; poly_idx < size(); poly_idx++)
diff --git a/src/utils/polygon.h b/src/utils/polygon.h
index ec5a09ba4..7496637b1 100644
--- a/src/utils/polygon.h
+++ b/src/utils/polygon.h
@@ -1025,13 +1025,35 @@ public:
/*!
* Removes overlapping consecutive line segments which don't delimit a
* positive area.
+ *
+ * This function is meant to work on polygons, not polylines. When misused
+ * on polylines, it may cause too many vertices to be removed.
+ * See \ref removeDegenerateVertsPolyline for a version that works on
+ * polylines.
+ */
+ void removeDegenerateVerts();
+
+ /*!
+ * Removes overlapping consecutive line segments which don't delimit a
+ * positive area.
+ *
+ * This version is meant to work on polylines, not polygons. It leaves the
+ * endpoints of the polyline untouched. When misused on polygons, it may
+ * leave some degenerate vertices in.
+ * See \ref removeDegenerateVerts for a version that works on polygons.
+ */
+ void removeDegenerateVertsPolyline();
+
+ /*!
+ * Removes overlapping consecutive line segments which don't delimit a
+ * positive area.
* \param for_polyline Indicate that we're removing degenerate vertices from
* a polyline, causing the endpoints of the polyline to be left untouched.
* When removing vertices from a polygon, the start and end can be
* considered for removal too, but when processing a polyline, removing
* those would cause the polyline to become shorter.
*/
- void removeDegenerateVerts(const bool for_polyline = false);
+ void _removeDegenerateVerts(const bool for_polyline = false);
/*!
* Removes the same polygons from this set (and also empty polygons).