2013-07-15 10:14:22 +00:00
|
|
|
#ifndef slic3r_ExtrusionEntity_hpp_
|
|
|
|
#define slic3r_ExtrusionEntity_hpp_
|
|
|
|
|
2015-12-07 23:39:54 +00:00
|
|
|
#include "libslic3r.h"
|
2013-07-15 10:14:22 +00:00
|
|
|
#include "Polygon.hpp"
|
|
|
|
#include "Polyline.hpp"
|
|
|
|
|
2019-09-26 14:39:50 +00:00
|
|
|
#include <assert.h>
|
2020-10-29 09:51:28 +00:00
|
|
|
#include <string_view>
|
2019-09-26 14:39:50 +00:00
|
|
|
|
2013-07-15 10:14:22 +00:00
|
|
|
namespace Slic3r {
|
|
|
|
|
2013-11-21 16:53:50 +00:00
|
|
|
class ExPolygonCollection;
|
|
|
|
class ExtrusionEntityCollection;
|
2014-04-07 23:43:02 +00:00
|
|
|
class Extruder;
|
2013-11-21 16:53:50 +00:00
|
|
|
|
2019-09-06 12:58:04 +00:00
|
|
|
// Each ExtrusionRole value identifies a distinct set of { extruder, speed }
|
2019-09-30 14:25:26 +00:00
|
|
|
enum ExtrusionRole : uint8_t {
|
2015-07-02 12:29:20 +00:00
|
|
|
erNone,
|
2013-07-15 10:14:22 +00:00
|
|
|
erPerimeter,
|
|
|
|
erExternalPerimeter,
|
|
|
|
erOverhangPerimeter,
|
2014-05-12 19:49:17 +00:00
|
|
|
erInternalInfill,
|
|
|
|
erSolidInfill,
|
|
|
|
erTopSolidInfill,
|
2020-04-14 09:53:28 +00:00
|
|
|
erIroning,
|
2014-05-12 19:49:17 +00:00
|
|
|
erBridgeInfill,
|
|
|
|
erGapFill,
|
2013-07-15 10:14:22 +00:00
|
|
|
erSkirt,
|
|
|
|
erSupportMaterial,
|
2014-05-12 20:59:49 +00:00
|
|
|
erSupportMaterialInterface,
|
2018-02-05 12:16:08 +00:00
|
|
|
erWipeTower,
|
2018-02-22 07:59:47 +00:00
|
|
|
erCustom,
|
2017-04-07 15:37:30 +00:00
|
|
|
// Extrusion role for a collection with multiple extrusion roles.
|
|
|
|
erMixed,
|
2019-09-06 12:58:04 +00:00
|
|
|
erCount
|
2014-05-12 19:49:17 +00:00
|
|
|
};
|
|
|
|
|
2019-09-06 12:58:04 +00:00
|
|
|
// Special flags describing loop
|
|
|
|
enum ExtrusionLoopRole {
|
|
|
|
elrDefault,
|
|
|
|
elrContourInternalPerimeter,
|
|
|
|
elrSkirt,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-05-03 16:28:22 +00:00
|
|
|
inline bool is_perimeter(ExtrusionRole role)
|
|
|
|
{
|
|
|
|
return role == erPerimeter
|
|
|
|
|| role == erExternalPerimeter
|
|
|
|
|| role == erOverhangPerimeter;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool is_infill(ExtrusionRole role)
|
|
|
|
{
|
|
|
|
return role == erBridgeInfill
|
|
|
|
|| role == erInternalInfill
|
|
|
|
|| role == erSolidInfill
|
2020-04-14 09:53:28 +00:00
|
|
|
|| role == erTopSolidInfill
|
|
|
|
|| role == erIroning;
|
2017-05-03 16:28:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool is_solid_infill(ExtrusionRole role)
|
|
|
|
{
|
|
|
|
return role == erBridgeInfill
|
|
|
|
|| role == erSolidInfill
|
2020-04-14 09:53:28 +00:00
|
|
|
|| role == erTopSolidInfill
|
|
|
|
|| role == erIroning;
|
2017-05-03 16:28:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool is_bridge(ExtrusionRole role) {
|
|
|
|
return role == erBridgeInfill
|
|
|
|
|| role == erOverhangPerimeter;
|
|
|
|
}
|
|
|
|
|
2013-07-15 10:14:22 +00:00
|
|
|
class ExtrusionEntity
|
|
|
|
{
|
2016-11-03 09:24:32 +00:00
|
|
|
public:
|
2017-04-07 15:37:30 +00:00
|
|
|
virtual ExtrusionRole role() const = 0;
|
2016-11-03 09:24:32 +00:00
|
|
|
virtual bool is_collection() const { return false; }
|
|
|
|
virtual bool is_loop() const { return false; }
|
|
|
|
virtual bool can_reverse() const { return true; }
|
2013-08-29 09:47:59 +00:00
|
|
|
virtual ExtrusionEntity* clone() const = 0;
|
2019-09-11 11:25:50 +00:00
|
|
|
// Create a new object, initialize it with this object using the move semantics.
|
|
|
|
virtual ExtrusionEntity* clone_move() = 0;
|
2019-09-06 12:58:04 +00:00
|
|
|
virtual ~ExtrusionEntity() {}
|
2013-08-29 09:47:59 +00:00
|
|
|
virtual void reverse() = 0;
|
2019-09-27 16:17:21 +00:00
|
|
|
virtual const Point& first_point() const = 0;
|
|
|
|
virtual const Point& last_point() const = 0;
|
2016-11-03 23:10:35 +00:00
|
|
|
// Produce a list of 2D polygons covered by the extruded paths, offsetted by the extrusion width.
|
|
|
|
// Increase the offset by scaled_epsilon to achieve an overlap, so a union will produce no gaps.
|
|
|
|
virtual void polygons_covered_by_width(Polygons &out, const float scaled_epsilon) const = 0;
|
|
|
|
// Produce a list of 2D polygons covered by the extruded paths, offsetted by the extrusion spacing.
|
|
|
|
// Increase the offset by scaled_epsilon to achieve an overlap, so a union will produce no gaps.
|
|
|
|
// Useful to calculate area of an infill, which has been really filled in by a 100% rectilinear infill.
|
|
|
|
virtual void polygons_covered_by_spacing(Polygons &out, const float scaled_epsilon) const = 0;
|
|
|
|
Polygons polygons_covered_by_width(const float scaled_epsilon = 0.f) const
|
|
|
|
{ Polygons out; this->polygons_covered_by_width(out, scaled_epsilon); return out; }
|
|
|
|
Polygons polygons_covered_by_spacing(const float scaled_epsilon = 0.f) const
|
|
|
|
{ Polygons out; this->polygons_covered_by_spacing(out, scaled_epsilon); return out; }
|
2016-11-03 09:24:32 +00:00
|
|
|
// Minimum volumetric velocity of this extrusion entity. Used by the constant nozzle pressure algorithm.
|
2015-05-31 20:04:32 +00:00
|
|
|
virtual double min_mm3_per_mm() const = 0;
|
2015-07-06 23:17:31 +00:00
|
|
|
virtual Polyline as_polyline() const = 0;
|
2018-09-17 13:12:13 +00:00
|
|
|
virtual void collect_polylines(Polylines &dst) const = 0;
|
|
|
|
virtual Polylines as_polylines() const { Polylines dst; this->collect_polylines(dst); return dst; }
|
2016-11-03 23:10:35 +00:00
|
|
|
virtual double length() const = 0;
|
2018-05-24 12:05:51 +00:00
|
|
|
virtual double total_volume() const = 0;
|
2019-09-06 12:58:04 +00:00
|
|
|
|
|
|
|
static std::string role_to_string(ExtrusionRole role);
|
2020-10-29 09:51:28 +00:00
|
|
|
static ExtrusionRole string_to_role(const std::string_view role);
|
2013-07-15 10:14:22 +00:00
|
|
|
};
|
|
|
|
|
2013-07-18 17:09:07 +00:00
|
|
|
typedef std::vector<ExtrusionEntity*> ExtrusionEntitiesPtr;
|
|
|
|
|
2013-07-15 10:14:22 +00:00
|
|
|
class ExtrusionPath : public ExtrusionEntity
|
|
|
|
{
|
2016-11-03 09:24:32 +00:00
|
|
|
public:
|
2013-07-15 10:14:22 +00:00
|
|
|
Polyline polyline;
|
2016-11-23 14:51:47 +00:00
|
|
|
// Volumetric velocity. mm^3 of plastic per mm of linear head motion. Used by the G-code generator.
|
2016-11-03 09:24:32 +00:00
|
|
|
double mm3_per_mm;
|
2016-11-23 14:51:47 +00:00
|
|
|
// Width of the extrusion, used for visualization purposes.
|
2014-05-08 09:07:37 +00:00
|
|
|
float width;
|
2019-09-11 09:38:17 +00:00
|
|
|
// Height of the extrusion, used for visualization purposes.
|
2014-05-08 09:07:37 +00:00
|
|
|
float height;
|
2019-09-30 14:25:26 +00:00
|
|
|
|
2020-08-12 10:58:23 +00:00
|
|
|
ExtrusionPath(ExtrusionRole role) : mm3_per_mm(-1), width(-1), height(-1), m_role(role) {}
|
|
|
|
ExtrusionPath(ExtrusionRole role, double mm3_per_mm, float width, float height) : mm3_per_mm(mm3_per_mm), width(width), height(height), m_role(role) {}
|
2019-09-30 14:25:26 +00:00
|
|
|
ExtrusionPath(const ExtrusionPath& rhs) : polyline(rhs.polyline), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), m_role(rhs.m_role) {}
|
|
|
|
ExtrusionPath(ExtrusionPath&& rhs) : polyline(std::move(rhs.polyline)), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), m_role(rhs.m_role) {}
|
|
|
|
ExtrusionPath(const Polyline &polyline, const ExtrusionPath &rhs) : polyline(polyline), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), m_role(rhs.m_role) {}
|
|
|
|
ExtrusionPath(Polyline &&polyline, const ExtrusionPath &rhs) : polyline(std::move(polyline)), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), m_role(rhs.m_role) {}
|
|
|
|
|
|
|
|
ExtrusionPath& operator=(const ExtrusionPath& rhs) { m_role = rhs.m_role; this->mm3_per_mm = rhs.mm3_per_mm; this->width = rhs.width; this->height = rhs.height; this->polyline = rhs.polyline; return *this; }
|
|
|
|
ExtrusionPath& operator=(ExtrusionPath&& rhs) { m_role = rhs.m_role; this->mm3_per_mm = rhs.mm3_per_mm; this->width = rhs.width; this->height = rhs.height; this->polyline = std::move(rhs.polyline); return *this; }
|
2017-01-20 13:39:44 +00:00
|
|
|
|
2019-09-11 11:25:50 +00:00
|
|
|
ExtrusionEntity* clone() const override { return new ExtrusionPath(*this); }
|
|
|
|
// Create a new object, initialize it with this object using the move semantics.
|
|
|
|
ExtrusionEntity* clone_move() override { return new ExtrusionPath(std::move(*this)); }
|
2019-09-06 12:58:04 +00:00
|
|
|
void reverse() override { this->polyline.reverse(); }
|
2019-09-27 16:17:21 +00:00
|
|
|
const Point& first_point() const override { return this->polyline.points.front(); }
|
|
|
|
const Point& last_point() const override { return this->polyline.points.back(); }
|
2018-09-17 13:12:13 +00:00
|
|
|
size_t size() const { return this->polyline.size(); }
|
|
|
|
bool empty() const { return this->polyline.empty(); }
|
|
|
|
bool is_closed() const { return ! this->empty() && this->polyline.points.front() == this->polyline.points.back(); }
|
2016-11-03 09:24:32 +00:00
|
|
|
// Produce a list of extrusion paths into retval by clipping this path by ExPolygonCollection.
|
|
|
|
// Currently not used.
|
2014-03-09 19:19:30 +00:00
|
|
|
void intersect_expolygons(const ExPolygonCollection &collection, ExtrusionEntityCollection* retval) const;
|
2016-11-03 09:24:32 +00:00
|
|
|
// Produce a list of extrusion paths into retval by removing parts of this path by ExPolygonCollection.
|
|
|
|
// Currently not used.
|
2014-03-09 19:19:30 +00:00
|
|
|
void subtract_expolygons(const ExPolygonCollection &collection, ExtrusionEntityCollection* retval) const;
|
2013-11-21 17:03:40 +00:00
|
|
|
void clip_end(double distance);
|
2013-11-21 19:25:24 +00:00
|
|
|
void simplify(double tolerance);
|
2018-09-17 13:12:13 +00:00
|
|
|
double length() const override;
|
|
|
|
ExtrusionRole role() const override { return m_role; }
|
2016-11-03 23:10:35 +00:00
|
|
|
// Produce a list of 2D polygons covered by the extruded paths, offsetted by the extrusion width.
|
|
|
|
// Increase the offset by scaled_epsilon to achieve an overlap, so a union will produce no gaps.
|
2019-09-06 12:58:04 +00:00
|
|
|
void polygons_covered_by_width(Polygons &out, const float scaled_epsilon) const override;
|
2016-11-03 23:10:35 +00:00
|
|
|
// Produce a list of 2D polygons covered by the extruded paths, offsetted by the extrusion spacing.
|
|
|
|
// Increase the offset by scaled_epsilon to achieve an overlap, so a union will produce no gaps.
|
|
|
|
// Useful to calculate area of an infill, which has been really filled in by a 100% rectilinear infill.
|
2019-09-06 12:58:04 +00:00
|
|
|
void polygons_covered_by_spacing(Polygons &out, const float scaled_epsilon) const override;
|
2016-11-03 23:10:35 +00:00
|
|
|
Polygons polygons_covered_by_width(const float scaled_epsilon = 0.f) const
|
|
|
|
{ Polygons out; this->polygons_covered_by_width(out, scaled_epsilon); return out; }
|
|
|
|
Polygons polygons_covered_by_spacing(const float scaled_epsilon = 0.f) const
|
|
|
|
{ Polygons out; this->polygons_covered_by_spacing(out, scaled_epsilon); return out; }
|
2016-11-03 09:24:32 +00:00
|
|
|
// Minimum volumetric velocity of this extrusion entity. Used by the constant nozzle pressure algorithm.
|
2019-09-06 12:58:04 +00:00
|
|
|
double min_mm3_per_mm() const override { return this->mm3_per_mm; }
|
|
|
|
Polyline as_polyline() const override { return this->polyline; }
|
2018-09-17 13:12:13 +00:00
|
|
|
void collect_polylines(Polylines &dst) const override { if (! this->polyline.empty()) dst.emplace_back(this->polyline); }
|
|
|
|
double total_volume() const override { return mm3_per_mm * unscale<double>(length()); }
|
2014-05-08 09:07:37 +00:00
|
|
|
|
2017-04-07 15:37:30 +00:00
|
|
|
private:
|
2014-03-09 19:19:30 +00:00
|
|
|
void _inflate_collection(const Polylines &polylines, ExtrusionEntityCollection* collection) const;
|
2017-04-07 15:37:30 +00:00
|
|
|
|
|
|
|
ExtrusionRole m_role;
|
2013-07-15 10:14:22 +00:00
|
|
|
};
|
|
|
|
|
2014-05-08 09:07:37 +00:00
|
|
|
typedef std::vector<ExtrusionPath> ExtrusionPaths;
|
|
|
|
|
2017-01-19 12:35:55 +00:00
|
|
|
// Single continuous extrusion path, possibly with varying extrusion thickness, extrusion height or bridging / non bridging.
|
|
|
|
class ExtrusionMultiPath : public ExtrusionEntity
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ExtrusionPaths paths;
|
|
|
|
|
2019-09-06 12:58:04 +00:00
|
|
|
ExtrusionMultiPath() {}
|
2017-01-20 13:39:44 +00:00
|
|
|
ExtrusionMultiPath(const ExtrusionMultiPath &rhs) : paths(rhs.paths) {}
|
|
|
|
ExtrusionMultiPath(ExtrusionMultiPath &&rhs) : paths(std::move(rhs.paths)) {}
|
2019-09-06 12:58:04 +00:00
|
|
|
ExtrusionMultiPath(const ExtrusionPaths &paths) : paths(paths) {}
|
2017-01-19 12:35:55 +00:00
|
|
|
ExtrusionMultiPath(const ExtrusionPath &path) { this->paths.push_back(path); }
|
2017-01-20 13:39:44 +00:00
|
|
|
|
|
|
|
ExtrusionMultiPath& operator=(const ExtrusionMultiPath &rhs) { this->paths = rhs.paths; return *this; }
|
|
|
|
ExtrusionMultiPath& operator=(ExtrusionMultiPath &&rhs) { this->paths = std::move(rhs.paths); return *this; }
|
|
|
|
|
2019-09-06 12:58:04 +00:00
|
|
|
bool is_loop() const override { return false; }
|
|
|
|
bool can_reverse() const override { return true; }
|
2019-09-11 11:25:50 +00:00
|
|
|
ExtrusionEntity* clone() const override { return new ExtrusionMultiPath(*this); }
|
|
|
|
// Create a new object, initialize it with this object using the move semantics.
|
|
|
|
ExtrusionEntity* clone_move() override { return new ExtrusionMultiPath(std::move(*this)); }
|
2019-09-06 12:58:04 +00:00
|
|
|
void reverse() override;
|
2019-09-27 16:17:21 +00:00
|
|
|
const Point& first_point() const override { return this->paths.front().polyline.points.front(); }
|
|
|
|
const Point& last_point() const override { return this->paths.back().polyline.points.back(); }
|
2018-09-17 13:12:13 +00:00
|
|
|
double length() const override;
|
|
|
|
ExtrusionRole role() const override { return this->paths.empty() ? erNone : this->paths.front().role(); }
|
2017-01-19 12:35:55 +00:00
|
|
|
// Produce a list of 2D polygons covered by the extruded paths, offsetted by the extrusion width.
|
|
|
|
// Increase the offset by scaled_epsilon to achieve an overlap, so a union will produce no gaps.
|
2019-09-06 12:58:04 +00:00
|
|
|
void polygons_covered_by_width(Polygons &out, const float scaled_epsilon) const override;
|
2017-01-19 12:35:55 +00:00
|
|
|
// Produce a list of 2D polygons covered by the extruded paths, offsetted by the extrusion spacing.
|
|
|
|
// Increase the offset by scaled_epsilon to achieve an overlap, so a union will produce no gaps.
|
|
|
|
// Useful to calculate area of an infill, which has been really filled in by a 100% rectilinear infill.
|
2019-09-06 12:58:04 +00:00
|
|
|
void polygons_covered_by_spacing(Polygons &out, const float scaled_epsilon) const override;
|
2017-01-19 12:35:55 +00:00
|
|
|
Polygons polygons_covered_by_width(const float scaled_epsilon = 0.f) const
|
|
|
|
{ Polygons out; this->polygons_covered_by_width(out, scaled_epsilon); return out; }
|
|
|
|
Polygons polygons_covered_by_spacing(const float scaled_epsilon = 0.f) const
|
|
|
|
{ Polygons out; this->polygons_covered_by_spacing(out, scaled_epsilon); return out; }
|
|
|
|
// Minimum volumetric velocity of this extrusion entity. Used by the constant nozzle pressure algorithm.
|
2019-09-06 12:58:04 +00:00
|
|
|
double min_mm3_per_mm() const override;
|
|
|
|
Polyline as_polyline() const override;
|
2018-09-17 13:12:13 +00:00
|
|
|
void collect_polylines(Polylines &dst) const override { Polyline pl = this->as_polyline(); if (! pl.empty()) dst.emplace_back(std::move(pl)); }
|
|
|
|
double total_volume() const override { double volume =0.; for (const auto& path : paths) volume += path.total_volume(); return volume; }
|
2017-01-19 12:35:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Single continuous extrusion loop, possibly with varying extrusion thickness, extrusion height or bridging / non bridging.
|
2013-07-15 10:14:22 +00:00
|
|
|
class ExtrusionLoop : public ExtrusionEntity
|
|
|
|
{
|
2017-04-07 15:37:30 +00:00
|
|
|
public:
|
2014-05-08 09:07:37 +00:00
|
|
|
ExtrusionPaths paths;
|
2014-05-07 10:02:09 +00:00
|
|
|
|
2019-09-06 12:58:04 +00:00
|
|
|
ExtrusionLoop(ExtrusionLoopRole role = elrDefault) : m_loop_role(role) {}
|
|
|
|
ExtrusionLoop(const ExtrusionPaths &paths, ExtrusionLoopRole role = elrDefault) : paths(paths), m_loop_role(role) {}
|
|
|
|
ExtrusionLoop(ExtrusionPaths &&paths, ExtrusionLoopRole role = elrDefault) : paths(std::move(paths)), m_loop_role(role) {}
|
2017-07-07 14:40:23 +00:00
|
|
|
ExtrusionLoop(const ExtrusionPath &path, ExtrusionLoopRole role = elrDefault) : m_loop_role(role)
|
2019-09-06 12:58:04 +00:00
|
|
|
{ this->paths.push_back(path); }
|
2017-07-07 14:40:23 +00:00
|
|
|
ExtrusionLoop(const ExtrusionPath &&path, ExtrusionLoopRole role = elrDefault) : m_loop_role(role)
|
2019-09-06 12:58:04 +00:00
|
|
|
{ this->paths.emplace_back(std::move(path)); }
|
|
|
|
bool is_loop() const override{ return true; }
|
|
|
|
bool can_reverse() const override { return false; }
|
2019-09-11 11:25:50 +00:00
|
|
|
ExtrusionEntity* clone() const override{ return new ExtrusionLoop (*this); }
|
|
|
|
// Create a new object, initialize it with this object using the move semantics.
|
|
|
|
ExtrusionEntity* clone_move() override { return new ExtrusionLoop(std::move(*this)); }
|
2014-05-08 09:07:37 +00:00
|
|
|
bool make_clockwise();
|
2013-08-28 23:40:42 +00:00
|
|
|
bool make_counter_clockwise();
|
2019-09-06 12:58:04 +00:00
|
|
|
void reverse() override;
|
2019-09-27 16:17:21 +00:00
|
|
|
const Point& first_point() const override { return this->paths.front().polyline.points.front(); }
|
|
|
|
const Point& last_point() const override { assert(this->first_point() == this->paths.back().polyline.points.back()); return this->first_point(); }
|
2015-01-25 14:21:45 +00:00
|
|
|
Polygon polygon() const;
|
2018-09-17 13:12:13 +00:00
|
|
|
double length() const override;
|
2014-11-08 11:56:14 +00:00
|
|
|
bool split_at_vertex(const Point &point);
|
2017-02-02 17:49:33 +00:00
|
|
|
void split_at(const Point &point, bool prefer_non_overhang);
|
2014-05-08 09:07:37 +00:00
|
|
|
void clip_end(double distance, ExtrusionPaths* paths) const;
|
2016-11-03 09:24:32 +00:00
|
|
|
// Test, whether the point is extruded by a bridging flow.
|
|
|
|
// This used to be used to avoid placing seams on overhangs, but now the EdgeGrid is used instead.
|
2014-05-08 09:07:37 +00:00
|
|
|
bool has_overhang_point(const Point &point) const;
|
2018-09-17 13:12:13 +00:00
|
|
|
ExtrusionRole role() const override { return this->paths.empty() ? erNone : this->paths.front().role(); }
|
|
|
|
ExtrusionLoopRole loop_role() const { return m_loop_role; }
|
2016-11-03 23:10:35 +00:00
|
|
|
// Produce a list of 2D polygons covered by the extruded paths, offsetted by the extrusion width.
|
|
|
|
// Increase the offset by scaled_epsilon to achieve an overlap, so a union will produce no gaps.
|
2019-09-06 12:58:04 +00:00
|
|
|
void polygons_covered_by_width(Polygons &out, const float scaled_epsilon) const override;
|
2016-11-03 23:10:35 +00:00
|
|
|
// Produce a list of 2D polygons covered by the extruded paths, offsetted by the extrusion spacing.
|
|
|
|
// Increase the offset by scaled_epsilon to achieve an overlap, so a union will produce no gaps.
|
|
|
|
// Useful to calculate area of an infill, which has been really filled in by a 100% rectilinear infill.
|
2019-09-06 12:58:04 +00:00
|
|
|
void polygons_covered_by_spacing(Polygons &out, const float scaled_epsilon) const override;
|
2016-11-03 23:10:35 +00:00
|
|
|
Polygons polygons_covered_by_width(const float scaled_epsilon = 0.f) const
|
|
|
|
{ Polygons out; this->polygons_covered_by_width(out, scaled_epsilon); return out; }
|
|
|
|
Polygons polygons_covered_by_spacing(const float scaled_epsilon = 0.f) const
|
|
|
|
{ Polygons out; this->polygons_covered_by_spacing(out, scaled_epsilon); return out; }
|
2016-11-03 09:24:32 +00:00
|
|
|
// Minimum volumetric velocity of this extrusion entity. Used by the constant nozzle pressure algorithm.
|
2019-09-06 12:58:04 +00:00
|
|
|
double min_mm3_per_mm() const override;
|
|
|
|
Polyline as_polyline() const override { return this->polygon().split_at_first_point(); }
|
2018-09-17 13:12:13 +00:00
|
|
|
void collect_polylines(Polylines &dst) const override { Polyline pl = this->as_polyline(); if (! pl.empty()) dst.emplace_back(std::move(pl)); }
|
|
|
|
double total_volume() const override { double volume =0.; for (const auto& path : paths) volume += path.total_volume(); return volume; }
|
2017-04-07 15:37:30 +00:00
|
|
|
|
2019-09-06 12:58:04 +00:00
|
|
|
//static inline std::string role_to_string(ExtrusionLoopRole role);
|
|
|
|
|
2019-11-14 16:02:32 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
bool validate() const {
|
|
|
|
assert(this->first_point() == this->paths.back().polyline.points.back());
|
|
|
|
for (size_t i = 1; i < paths.size(); ++ i)
|
|
|
|
assert(this->paths[i - 1].polyline.points.back() == this->paths[i].polyline.points.front());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif /* NDEBUG */
|
|
|
|
|
2017-04-07 15:37:30 +00:00
|
|
|
private:
|
|
|
|
ExtrusionLoopRole m_loop_role;
|
2013-07-15 10:14:22 +00:00
|
|
|
};
|
|
|
|
|
2016-12-13 18:22:23 +00:00
|
|
|
inline void extrusion_paths_append(ExtrusionPaths &dst, Polylines &polylines, ExtrusionRole role, double mm3_per_mm, float width, float height)
|
|
|
|
{
|
|
|
|
dst.reserve(dst.size() + polylines.size());
|
2017-07-07 14:40:23 +00:00
|
|
|
for (Polyline &polyline : polylines)
|
|
|
|
if (polyline.is_valid()) {
|
2017-01-25 17:25:14 +00:00
|
|
|
dst.push_back(ExtrusionPath(role, mm3_per_mm, width, height));
|
2017-07-07 14:40:23 +00:00
|
|
|
dst.back().polyline = polyline;
|
2017-01-25 17:25:14 +00:00
|
|
|
}
|
2016-12-13 18:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void extrusion_paths_append(ExtrusionPaths &dst, Polylines &&polylines, ExtrusionRole role, double mm3_per_mm, float width, float height)
|
|
|
|
{
|
|
|
|
dst.reserve(dst.size() + polylines.size());
|
2017-07-07 14:40:23 +00:00
|
|
|
for (Polyline &polyline : polylines)
|
|
|
|
if (polyline.is_valid()) {
|
2017-01-25 17:25:14 +00:00
|
|
|
dst.push_back(ExtrusionPath(role, mm3_per_mm, width, height));
|
2017-07-07 14:40:23 +00:00
|
|
|
dst.back().polyline = std::move(polyline);
|
2017-01-25 17:25:14 +00:00
|
|
|
}
|
|
|
|
polylines.clear();
|
2016-12-13 18:22:23 +00:00
|
|
|
}
|
|
|
|
|
2016-11-23 14:51:47 +00:00
|
|
|
inline void extrusion_entities_append_paths(ExtrusionEntitiesPtr &dst, Polylines &polylines, ExtrusionRole role, double mm3_per_mm, float width, float height)
|
|
|
|
{
|
|
|
|
dst.reserve(dst.size() + polylines.size());
|
2017-07-07 14:40:23 +00:00
|
|
|
for (Polyline &polyline : polylines)
|
|
|
|
if (polyline.is_valid()) {
|
2017-01-25 17:25:14 +00:00
|
|
|
ExtrusionPath *extrusion_path = new ExtrusionPath(role, mm3_per_mm, width, height);
|
|
|
|
dst.push_back(extrusion_path);
|
2017-07-07 14:40:23 +00:00
|
|
|
extrusion_path->polyline = polyline;
|
2017-01-25 17:25:14 +00:00
|
|
|
}
|
2016-11-23 14:51:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void extrusion_entities_append_paths(ExtrusionEntitiesPtr &dst, Polylines &&polylines, ExtrusionRole role, double mm3_per_mm, float width, float height)
|
|
|
|
{
|
|
|
|
dst.reserve(dst.size() + polylines.size());
|
2017-07-07 14:40:23 +00:00
|
|
|
for (Polyline &polyline : polylines)
|
|
|
|
if (polyline.is_valid()) {
|
2017-01-25 17:25:14 +00:00
|
|
|
ExtrusionPath *extrusion_path = new ExtrusionPath(role, mm3_per_mm, width, height);
|
|
|
|
dst.push_back(extrusion_path);
|
2017-07-07 14:40:23 +00:00
|
|
|
extrusion_path->polyline = std::move(polyline);
|
2017-01-25 17:25:14 +00:00
|
|
|
}
|
|
|
|
polylines.clear();
|
2016-11-23 14:51:47 +00:00
|
|
|
}
|
|
|
|
|
2017-07-07 14:40:23 +00:00
|
|
|
inline void extrusion_entities_append_loops(ExtrusionEntitiesPtr &dst, Polygons &&loops, ExtrusionRole role, double mm3_per_mm, float width, float height)
|
|
|
|
{
|
|
|
|
dst.reserve(dst.size() + loops.size());
|
|
|
|
for (Polygon &poly : loops) {
|
|
|
|
if (poly.is_valid()) {
|
|
|
|
ExtrusionPath path(role, mm3_per_mm, width, height);
|
|
|
|
path.polyline.points = std::move(poly.points);
|
|
|
|
path.polyline.points.push_back(path.polyline.points.front());
|
|
|
|
dst.emplace_back(new ExtrusionLoop(std::move(path)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
loops.clear();
|
|
|
|
}
|
|
|
|
|
2021-02-03 14:12:53 +00:00
|
|
|
inline void extrusion_entities_append_loops_and_paths(ExtrusionEntitiesPtr &dst, Polylines &&polylines, ExtrusionRole role, double mm3_per_mm, float width, float height)
|
|
|
|
{
|
|
|
|
dst.reserve(dst.size() + polylines.size());
|
|
|
|
for (Polyline &polyline : polylines) {
|
|
|
|
if (polyline.is_valid()) {
|
|
|
|
if (polyline.is_closed()) {
|
|
|
|
ExtrusionPath extrusion_path(role, mm3_per_mm, width, height);
|
|
|
|
extrusion_path.polyline = std::move(polyline);
|
|
|
|
dst.emplace_back(new ExtrusionLoop(std::move(extrusion_path)));
|
|
|
|
} else {
|
|
|
|
ExtrusionPath *extrusion_path = new ExtrusionPath(role, mm3_per_mm, width, height);
|
|
|
|
extrusion_path->polyline = std::move(polyline);
|
|
|
|
dst.emplace_back(extrusion_path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
polylines.clear();
|
|
|
|
}
|
|
|
|
|
2013-07-15 10:14:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|