From 7df7c64d9dadc861b449bda6792d934a75589002 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Thu, 29 Feb 2024 11:47:26 +0100 Subject: [PATCH] Code cleaning --- include/utils/SVG.h | 4 ++-- include/utils/polygon.h | 15 --------------- src/TreeModelVolumes.cpp | 3 ++- src/utils/SVG.cpp | 18 +++++++++++++----- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/include/utils/SVG.h b/include/utils/SVG.h index 058bacc414..a67b1d5944 100644 --- a/include/utils/SVG.h +++ b/include/utils/SVG.h @@ -144,9 +144,9 @@ class SVG : NoCopy void writeText(const Point2LL& p, const std::string& txt, const ColorObject color = Color::BLACK, const double font_size = 10.0) const; - void writePolygons(const Polygons& polys, const ColorObject color = Color::BLACK, const double stroke_width = 1.0) const; + void writePolygons(const Polygons& polys, const ColorObject color = Color::BLACK, const double stroke_width = 1.0, const bool flush = true) const; - void writePolygon(ConstPolygonRef poly, const ColorObject color = Color::BLACK, const double stroke_width = 1.0) const; + void writePolygon(ConstPolygonRef poly, const ColorObject color = Color::BLACK, const double stroke_width = 1.0, const bool flush = true) const; void writePolylines(const Polygons& polys, const ColorObject color = Color::BLACK, const double stroke_width = 1.0) const; diff --git a/include/utils/polygon.h b/include/utils/polygon.h index 527e0a3472..e9eb6c2fcb 100644 --- a/include/utils/polygon.h +++ b/include/utils/polygon.h @@ -1194,11 +1194,6 @@ class Polygons */ double area() const; - void reverse() - { - ClipperLib::ReversePaths(paths); - } - /*! * Smooth out small perpendicular segments * Smoothing is performed by removing the inner most vertex of a line segment smaller than \p remove_length @@ -1559,16 +1554,6 @@ class PolygonsPart : public Polygons return paths[0]; } - Polygons innerPolygons() const - { - Polygons ret; - if (size() > 1) - { - ret.paths = ClipperLib::Paths(std::next(paths.begin()), paths.end()); - } - return ret; - } - /*! * Tests whether the given point is inside this polygon part. * \param p The point to test whether it is inside. diff --git a/src/TreeModelVolumes.cpp b/src/TreeModelVolumes.cpp index c2a610b4c7..fa8fe4bedf 100644 --- a/src/TreeModelVolumes.cpp +++ b/src/TreeModelVolumes.cpp @@ -572,6 +572,7 @@ Polygons TreeModelVolumes::extractOutlineFromMesh(const SliceMeshStorage& mesh, { // Similar to SliceDataStorage.getLayerOutlines but only for one mesh instead of for all of them. + constexpr bool external_polys_only = false; Polygons total; if (mesh.settings.get("infill_mesh") || mesh.settings.get("anti_overhang_mesh")) @@ -580,7 +581,7 @@ Polygons TreeModelVolumes::extractOutlineFromMesh(const SliceMeshStorage& mesh, } const SliceLayer& layer = mesh.layers[layer_idx]; - layer.getOutlines(total); + layer.getOutlines(total, external_polys_only); if (mesh.settings.get("magic_mesh_surface_mode") != ESurfaceMode::NORMAL) { total = total.unionPolygons(layer.openPolyLines.offsetPolyLine(FUDGE_LENGTH * 2)); diff --git a/src/utils/SVG.cpp b/src/utils/SVG.cpp index 88d820b123..4da036996a 100644 --- a/src/utils/SVG.cpp +++ b/src/utils/SVG.cpp @@ -334,16 +334,20 @@ void SVG::writeText(const Point2LL& p, const std::string& txt, const ColorObject txt.c_str()); } -void SVG::writePolygons(const Polygons& polys, const ColorObject color, const double stroke_width) const +void SVG::writePolygons(const Polygons& polys, const ColorObject color, const double stroke_width, const bool flush) const { for (ConstPolygonRef poly : polys) { - writePolygon(poly, color, stroke_width); + writePolygon(poly, color, stroke_width, false); + } + + if (flush) + { + fflush(out_); } - fflush(out_); } -void SVG::writePolygon(ConstPolygonRef poly, const ColorObject color, const double stroke_width) const +void SVG::writePolygon(ConstPolygonRef poly, const ColorObject color, const double stroke_width, const bool flush) const { if (poly.size() == 0) { @@ -375,7 +379,11 @@ void SVG::writePolygon(ConstPolygonRef poly, const ColorObject color, const doub p0 = p1; i++; } - fflush(out_); + + if (flush) + { + fflush(out_); + } }