Skip to content

Commit

Permalink
Code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Feb 29, 2024
1 parent 4eb7ec7 commit 7df7c64
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
4 changes: 2 additions & 2 deletions include/utils/SVG.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
15 changes: 0 additions & 15 deletions include/utils/polygon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/TreeModelVolumes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>("infill_mesh") || mesh.settings.get<bool>("anti_overhang_mesh"))
Expand All @@ -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<ESurfaceMode>("magic_mesh_surface_mode") != ESurfaceMode::NORMAL)
{
total = total.unionPolygons(layer.openPolyLines.offsetPolyLine(FUDGE_LENGTH * 2));
Expand Down
18 changes: 13 additions & 5 deletions src/utils/SVG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -375,7 +379,11 @@ void SVG::writePolygon(ConstPolygonRef poly, const ColorObject color, const doub
p0 = p1;
i++;
}
fflush(out_);

if (flush)
{
fflush(out_);
}
}


Expand Down

0 comments on commit 7df7c64

Please sign in to comment.