diff options
author | bubnikv <bubnikv@gmail.com> | 2016-11-03 12:24:32 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2016-11-03 12:24:32 +0300 |
commit | 7b6b609df146da7a829cdad935029f162a817839 (patch) | |
tree | 0ef159e9bba879b913b2ccc1148016e4ebc719f0 /xs/src/libslic3r/ExtrusionEntity.cpp | |
parent | 12b7818caa436d6c84f8be0e5ec6273ff37ec128 (diff) |
ExtrusionEntity and derived classes: Documented, short methods made
inline for efficiency and readability, grow() renamed to polygons_covered().
Diffstat (limited to 'xs/src/libslic3r/ExtrusionEntity.cpp')
-rw-r--r-- | xs/src/libslic3r/ExtrusionEntity.cpp | 121 |
1 files changed, 8 insertions, 113 deletions
diff --git a/xs/src/libslic3r/ExtrusionEntity.cpp b/xs/src/libslic3r/ExtrusionEntity.cpp index ab462eb03..0fed22490 100644 --- a/xs/src/libslic3r/ExtrusionEntity.cpp +++ b/xs/src/libslic3r/ExtrusionEntity.cpp @@ -4,35 +4,12 @@ #include "ClipperUtils.hpp" #include "Extruder.hpp" #include <cmath> +#include <limits> #include <sstream> namespace Slic3r { - -ExtrusionPath* -ExtrusionPath::clone() const -{ - return new ExtrusionPath (*this); -} void -ExtrusionPath::reverse() -{ - this->polyline.reverse(); -} - -Point -ExtrusionPath::first_point() const -{ - return this->polyline.points.front(); -} - -Point -ExtrusionPath::last_point() const -{ - return this->polyline.points.back(); -} - -void ExtrusionPath::intersect_expolygons(const ExPolygonCollection &collection, ExtrusionEntityCollection* retval) const { // perform clipping @@ -68,38 +45,6 @@ ExtrusionPath::length() const return this->polyline.length(); } -bool -ExtrusionPath::is_perimeter() const -{ - return this->role == erPerimeter - || this->role == erExternalPerimeter - || this->role == erOverhangPerimeter; -} - -bool -ExtrusionPath::is_infill() const -{ - return this->role == erBridgeInfill - || this->role == erInternalInfill - || this->role == erSolidInfill - || this->role == erTopSolidInfill; -} - -bool -ExtrusionPath::is_solid_infill() const -{ - return this->role == erBridgeInfill - || this->role == erSolidInfill - || this->role == erTopSolidInfill; -} - -bool -ExtrusionPath::is_bridge() const -{ - return this->role == erBridgeInfill - || this->role == erOverhangPerimeter; -} - void ExtrusionPath::_inflate_collection(const Polylines &polylines, ExtrusionEntityCollection* collection) const { @@ -111,19 +56,13 @@ ExtrusionPath::_inflate_collection(const Polylines &polylines, ExtrusionEntityCo } Polygons -ExtrusionPath::grow() const +ExtrusionPath::polygons_covered() const { Polygons pp; offset(this->polyline, &pp, +scale_(this->width/2)); return pp; } -ExtrusionLoop* -ExtrusionLoop::clone() const -{ - return new ExtrusionLoop (*this); -} - bool ExtrusionLoop::make_clockwise() { @@ -148,18 +87,6 @@ ExtrusionLoop::reverse() std::reverse(this->paths.begin(), this->paths.end()); } -Point -ExtrusionLoop::first_point() const -{ - return this->paths.front().polyline.points.front(); -} - -Point -ExtrusionLoop::last_point() const -{ - return this->paths.back().polyline.points.back(); // which coincides with first_point(), by the way -} - Polygon ExtrusionLoop::polygon() const { @@ -296,53 +223,21 @@ ExtrusionLoop::has_overhang_point(const Point &point) const return false; } -bool -ExtrusionLoop::is_perimeter() const -{ - return this->paths.front().role == erPerimeter - || this->paths.front().role == erExternalPerimeter - || this->paths.front().role == erOverhangPerimeter; -} - -bool -ExtrusionLoop::is_infill() const -{ - return this->paths.front().role == erBridgeInfill - || this->paths.front().role == erInternalInfill - || this->paths.front().role == erSolidInfill - || this->paths.front().role == erTopSolidInfill; -} - -bool -ExtrusionLoop::is_solid_infill() const -{ - return this->paths.front().role == erBridgeInfill - || this->paths.front().role == erSolidInfill - || this->paths.front().role == erTopSolidInfill; -} - Polygons -ExtrusionLoop::grow() const +ExtrusionLoop::polygons_covered() const { Polygons pp; - for (ExtrusionPaths::const_iterator path = this->paths.begin(); path != this->paths.end(); ++path) { - Polygons path_pp = path->grow(); - pp.insert(pp.end(), path_pp.begin(), path_pp.end()); - } + for (ExtrusionPaths::const_iterator path = this->paths.begin(); path != this->paths.end(); ++path) + polygons_append(pp, path->polygons_covered()); return pp; } double ExtrusionLoop::min_mm3_per_mm() const { - double min_mm3_per_mm = 0; - for (ExtrusionPaths::const_iterator path = this->paths.begin(); path != this->paths.end(); ++path) { - if (min_mm3_per_mm == 0) { - min_mm3_per_mm = path->mm3_per_mm; - } else { - min_mm3_per_mm = fmin(min_mm3_per_mm, path->mm3_per_mm); - } - } + double min_mm3_per_mm = std::numeric_limits<double>::max(); + for (ExtrusionPaths::const_iterator path = this->paths.begin(); path != this->paths.end(); ++path) + min_mm3_per_mm = std::min(min_mm3_per_mm, path->mm3_per_mm); return min_mm3_per_mm; } |