mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 18:27:58 -06:00
ExtrusionEntity and derived classes: Documented, short methods made
inline for efficiency and readability, grow() renamed to polygons_covered().
This commit is contained in:
parent
12b7818caa
commit
7b6b609df1
8 changed files with 92 additions and 167 deletions
|
@ -4,34 +4,11 @@
|
|||
#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
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue