Ported clip_end(), length(), is_perimeter(), is_fill(), is_bridge() to XS
This commit is contained in:
parent
761f261a68
commit
ac88fbcbb0
5 changed files with 50 additions and 36 deletions
|
@ -10,8 +10,6 @@ our @EXPORT_OK = qw(EXTR_ROLE_PERIMETER EXTR_ROLE_EXTERNAL_PERIMETER
|
|||
EXTR_ROLE_INTERNALBRIDGE EXTR_ROLE_SKIRT EXTR_ROLE_SUPPORTMATERIAL EXTR_ROLE_GAPFILL);
|
||||
our %EXPORT_TAGS = (roles => \@EXPORT_OK);
|
||||
|
||||
use Slic3r::Geometry qw(PI X Y epsilon deg2rad rotate_points);
|
||||
|
||||
sub clip_with_polygon {
|
||||
my $self = shift;
|
||||
my ($polygon) = @_;
|
||||
|
@ -32,43 +30,9 @@ sub simplify {
|
|||
$self->polyline($self->polyline->simplify(@_));
|
||||
}
|
||||
|
||||
sub clip_end {
|
||||
my $self = shift;
|
||||
my $polyline = $self->polyline;
|
||||
$polyline->clip_end(@_);
|
||||
$self->polyline($polyline);
|
||||
}
|
||||
|
||||
sub length {
|
||||
my $self = shift;
|
||||
return $self->polyline->length;
|
||||
}
|
||||
|
||||
sub points {
|
||||
my $self = shift;
|
||||
return $self->polyline;
|
||||
}
|
||||
|
||||
sub is_perimeter {
|
||||
my $self = shift;
|
||||
return $self->role == EXTR_ROLE_PERIMETER
|
||||
|| $self->role == EXTR_ROLE_EXTERNAL_PERIMETER
|
||||
|| $self->role == EXTR_ROLE_OVERHANG_PERIMETER
|
||||
|| $self->role == EXTR_ROLE_CONTOUR_INTERNAL_PERIMETER;
|
||||
}
|
||||
|
||||
sub is_fill {
|
||||
my $self = shift;
|
||||
return $self->role == EXTR_ROLE_FILL
|
||||
|| $self->role == EXTR_ROLE_SOLIDFILL
|
||||
|| $self->role == EXTR_ROLE_TOPSOLIDFILL;
|
||||
}
|
||||
|
||||
sub is_bridge {
|
||||
my $self = shift;
|
||||
return $self->role == EXTR_ROLE_BRIDGE
|
||||
|| $self->role == EXTR_ROLE_INTERNALBRIDGE
|
||||
|| $self->role == EXTR_ROLE_OVERHANG_PERIMETER;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -5,6 +5,31 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
ExtrusionPath*
|
||||
ExtrusionPath::clone() const
|
||||
{
|
||||
|
@ -47,6 +72,18 @@ ExtrusionPath::subtract_expolygons(ExPolygonCollection* collection) const
|
|||
return this->_inflate_collection(clipped);
|
||||
}
|
||||
|
||||
void
|
||||
ExtrusionPath::clip_end(double distance)
|
||||
{
|
||||
this->polyline.clip_end(distance);
|
||||
}
|
||||
|
||||
double
|
||||
ExtrusionPath::length() const
|
||||
{
|
||||
return this->polyline.length();
|
||||
}
|
||||
|
||||
ExtrusionEntityCollection*
|
||||
ExtrusionPath::_inflate_collection(const Polylines &polylines) const
|
||||
{
|
||||
|
|
|
@ -36,6 +36,9 @@ class ExtrusionEntity
|
|||
virtual void reverse() = 0;
|
||||
virtual Point* first_point() const = 0;
|
||||
virtual Point* last_point() const = 0;
|
||||
bool is_perimeter() const;
|
||||
bool is_fill() const;
|
||||
bool is_bridge() const;
|
||||
};
|
||||
|
||||
typedef std::vector<ExtrusionEntity*> ExtrusionEntitiesPtr;
|
||||
|
@ -50,6 +53,8 @@ class ExtrusionPath : public ExtrusionEntity
|
|||
Point* last_point() const;
|
||||
ExtrusionEntityCollection* intersect_expolygons(ExPolygonCollection* collection) const;
|
||||
ExtrusionEntityCollection* subtract_expolygons(ExPolygonCollection* collection) const;
|
||||
void clip_end(double distance);
|
||||
double length() const;
|
||||
private:
|
||||
ExtrusionEntityCollection* _inflate_collection(const Polylines &polylines) const;
|
||||
};
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->first_point(); %};
|
||||
Point* last_point()
|
||||
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->last_point(); %};
|
||||
bool is_perimeter();
|
||||
bool is_fill();
|
||||
bool is_bridge();
|
||||
%{
|
||||
|
||||
ExtrusionLoop*
|
||||
|
|
|
@ -24,6 +24,11 @@
|
|||
%code{% const char* CLASS = "Slic3r::ExtrusionPath::Collection"; RETVAL = THIS->intersect_expolygons(collection); %};
|
||||
ExtrusionEntityCollection* subtract_expolygons(ExPolygonCollection* collection)
|
||||
%code{% const char* CLASS = "Slic3r::ExtrusionPath::Collection"; RETVAL = THIS->subtract_expolygons(collection); %};
|
||||
void clip_end(double distance);
|
||||
double length();
|
||||
bool is_perimeter();
|
||||
bool is_fill();
|
||||
bool is_bridge();
|
||||
%{
|
||||
|
||||
ExtrusionPath*
|
||||
|
|
Loading…
Reference in a new issue