2013-07-16 19:04:14 +00:00
|
|
|
#include "ExtrusionEntity.hpp"
|
2013-11-21 16:53:50 +00:00
|
|
|
#include "ExtrusionEntityCollection.hpp"
|
|
|
|
#include "ExPolygonCollection.hpp"
|
|
|
|
#include "ClipperUtils.hpp"
|
2013-07-16 19:04:14 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
2013-11-21 17:03:40 +00:00
|
|
|
bool
|
|
|
|
ExtrusionEntity::is_perimeter() const
|
|
|
|
{
|
|
|
|
return this->role == erPerimeter
|
|
|
|
|| this->role == erExternalPerimeter
|
|
|
|
|| this->role == erOverhangPerimeter
|
|
|
|
|| this->role == erContourInternalPerimeter;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ExtrusionEntity::is_fill() const
|
|
|
|
{
|
|
|
|
return this->role == erFill
|
|
|
|
|| this->role == erSolidFill
|
|
|
|
|| this->role == erTopSolidFill;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ExtrusionEntity::is_bridge() const
|
|
|
|
{
|
|
|
|
return this->role == erBrige
|
|
|
|
|| this->role == erInternalBridge
|
|
|
|
|| this->role == erOverhangPerimeter;
|
|
|
|
}
|
|
|
|
|
2013-08-29 09:47:59 +00:00
|
|
|
ExtrusionPath*
|
|
|
|
ExtrusionPath::clone() const
|
|
|
|
{
|
|
|
|
return new ExtrusionPath (*this);
|
|
|
|
}
|
|
|
|
|
2013-07-16 19:04:14 +00:00
|
|
|
void
|
|
|
|
ExtrusionPath::reverse()
|
|
|
|
{
|
|
|
|
this->polyline.reverse();
|
|
|
|
}
|
|
|
|
|
2013-08-29 09:47:59 +00:00
|
|
|
Point*
|
2013-09-02 20:33:03 +00:00
|
|
|
ExtrusionPath::first_point() const
|
2013-08-26 21:42:00 +00:00
|
|
|
{
|
2013-09-02 20:33:03 +00:00
|
|
|
return new Point(this->polyline.points.front());
|
2013-08-26 21:42:00 +00:00
|
|
|
}
|
|
|
|
|
2013-08-29 09:47:59 +00:00
|
|
|
Point*
|
2013-09-02 20:33:03 +00:00
|
|
|
ExtrusionPath::last_point() const
|
2013-08-28 23:36:42 +00:00
|
|
|
{
|
2013-09-02 20:33:03 +00:00
|
|
|
return new Point(this->polyline.points.back());
|
2013-08-28 23:36:42 +00:00
|
|
|
}
|
|
|
|
|
2013-11-21 16:53:50 +00:00
|
|
|
ExtrusionEntityCollection*
|
|
|
|
ExtrusionPath::intersect_expolygons(ExPolygonCollection* collection) const
|
|
|
|
{
|
|
|
|
// perform clipping
|
|
|
|
Polylines clipped;
|
|
|
|
intersection(this->polyline, *collection, clipped);
|
|
|
|
return this->_inflate_collection(clipped);
|
|
|
|
}
|
|
|
|
|
|
|
|
ExtrusionEntityCollection*
|
|
|
|
ExtrusionPath::subtract_expolygons(ExPolygonCollection* collection) const
|
|
|
|
{
|
|
|
|
// perform clipping
|
|
|
|
Polylines clipped;
|
|
|
|
diff(this->polyline, *collection, clipped);
|
|
|
|
return this->_inflate_collection(clipped);
|
|
|
|
}
|
|
|
|
|
2013-11-21 17:03:40 +00:00
|
|
|
void
|
|
|
|
ExtrusionPath::clip_end(double distance)
|
|
|
|
{
|
|
|
|
this->polyline.clip_end(distance);
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
ExtrusionPath::length() const
|
|
|
|
{
|
|
|
|
return this->polyline.length();
|
|
|
|
}
|
|
|
|
|
2013-11-21 16:53:50 +00:00
|
|
|
ExtrusionEntityCollection*
|
|
|
|
ExtrusionPath::_inflate_collection(const Polylines &polylines) const
|
|
|
|
{
|
|
|
|
ExtrusionEntityCollection* retval = new ExtrusionEntityCollection();
|
|
|
|
for (Polylines::const_iterator it = polylines.begin(); it != polylines.end(); ++it) {
|
|
|
|
ExtrusionPath* path = this->clone();
|
|
|
|
path->polyline = *it;
|
|
|
|
retval->entities.push_back(path);
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2013-08-29 09:47:59 +00:00
|
|
|
ExtrusionLoop*
|
|
|
|
ExtrusionLoop::clone() const
|
|
|
|
{
|
|
|
|
return new ExtrusionLoop (*this);
|
|
|
|
}
|
|
|
|
|
2013-07-16 19:04:14 +00:00
|
|
|
ExtrusionPath*
|
2013-09-13 13:19:15 +00:00
|
|
|
ExtrusionLoop::split_at_index(int index) const
|
2013-07-16 19:04:14 +00:00
|
|
|
{
|
|
|
|
Polyline* poly = this->polygon.split_at_index(index);
|
|
|
|
|
|
|
|
ExtrusionPath* path = new ExtrusionPath();
|
|
|
|
path->polyline = *poly;
|
|
|
|
path->role = this->role;
|
|
|
|
path->height = this->height;
|
|
|
|
path->flow_spacing = this->flow_spacing;
|
|
|
|
|
|
|
|
delete poly;
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
ExtrusionPath*
|
2013-09-13 13:19:15 +00:00
|
|
|
ExtrusionLoop::split_at_first_point() const
|
2013-07-16 19:04:14 +00:00
|
|
|
{
|
|
|
|
return this->split_at_index(0);
|
|
|
|
}
|
|
|
|
|
2013-08-28 23:40:42 +00:00
|
|
|
bool
|
|
|
|
ExtrusionLoop::make_counter_clockwise()
|
|
|
|
{
|
|
|
|
return this->polygon.make_counter_clockwise();
|
|
|
|
}
|
|
|
|
|
2013-08-29 09:47:59 +00:00
|
|
|
void
|
|
|
|
ExtrusionLoop::reverse()
|
|
|
|
{
|
|
|
|
// no-op
|
|
|
|
}
|
|
|
|
|
|
|
|
Point*
|
2013-09-02 20:33:03 +00:00
|
|
|
ExtrusionLoop::first_point() const
|
2013-08-29 09:47:59 +00:00
|
|
|
{
|
2013-09-02 20:33:03 +00:00
|
|
|
return new Point(this->polygon.points.front());
|
2013-08-29 09:47:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Point*
|
2013-09-02 20:33:03 +00:00
|
|
|
ExtrusionLoop::last_point() const
|
2013-08-29 09:47:59 +00:00
|
|
|
{
|
2013-09-02 20:33:03 +00:00
|
|
|
return new Point(this->polygon.points.front()); // in polygons, first == last
|
2013-08-29 09:47:59 +00:00
|
|
|
}
|
|
|
|
|
2013-07-16 19:04:14 +00:00
|
|
|
}
|