Implement split_at_index() and split_at_first_point() in ExtrusionLoop too
This commit is contained in:
parent
0d07a2e4e6
commit
339ba9e5c3
@ -47,6 +47,8 @@ class ExtrusionLoop : public ExtrusionEntity
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Polygon polygon;
|
Polygon polygon;
|
||||||
|
ExtrusionPath* split_at_index(int index);
|
||||||
|
ExtrusionPath* split_at_first_point();
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -55,6 +57,27 @@ ExtrusionPath::reverse()
|
|||||||
this->polyline.reverse();
|
this->polyline.reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExtrusionPath*
|
||||||
|
ExtrusionLoop::split_at_index(int index)
|
||||||
|
{
|
||||||
|
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*
|
||||||
|
ExtrusionLoop::split_at_first_point()
|
||||||
|
{
|
||||||
|
return this->split_at_index(0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,7 +4,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Slic3r::XS;
|
use Slic3r::XS;
|
||||||
use Test::More tests => 4;
|
use Test::More tests => 7;
|
||||||
|
|
||||||
my $square = [
|
my $square = [
|
||||||
[100, 100],
|
[100, 100],
|
||||||
@ -26,4 +26,12 @@ is $loop->role, Slic3r::ExtrusionPath::EXTR_ROLE_EXTERNAL_PERIMETER, 'role';
|
|||||||
$loop->role(Slic3r::ExtrusionPath::EXTR_ROLE_FILL);
|
$loop->role(Slic3r::ExtrusionPath::EXTR_ROLE_FILL);
|
||||||
is $loop->role, Slic3r::ExtrusionPath::EXTR_ROLE_FILL, 'modify role';
|
is $loop->role, Slic3r::ExtrusionPath::EXTR_ROLE_FILL, 'modify role';
|
||||||
|
|
||||||
|
{
|
||||||
|
my $path = $loop->split_at_first_point;
|
||||||
|
is_deeply $path->as_polyline->pp, $square, 'split_at_first_point';
|
||||||
|
is $path->role, $loop->role, 'role preserved after split';
|
||||||
|
|
||||||
|
is_deeply $loop->split_at_index(2)->as_polyline->pp, [ @$square[2,3,0,1] ], 'split_at_index';
|
||||||
|
}
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
%code{% const char* CLASS = "Slic3r::Polygon"; RETVAL = new Polygon(THIS->polygon); %};
|
%code{% const char* CLASS = "Slic3r::Polygon"; RETVAL = new Polygon(THIS->polygon); %};
|
||||||
void set_polygon(SV* polygon_sv)
|
void set_polygon(SV* polygon_sv)
|
||||||
%code{% THIS->polygon.from_SV_check(polygon_sv); %};
|
%code{% THIS->polygon.from_SV_check(polygon_sv); %};
|
||||||
|
ExtrusionPath* split_at_index(int index)
|
||||||
|
%code{% const char* CLASS = "Slic3r::ExtrusionPath"; RETVAL = THIS->split_at_index(index); %};
|
||||||
|
ExtrusionPath* split_at_first_point()
|
||||||
|
%code{% const char* CLASS = "Slic3r::ExtrusionPath"; RETVAL = THIS->split_at_first_point(); %};
|
||||||
%{
|
%{
|
||||||
|
|
||||||
ExtrusionLoop*
|
ExtrusionLoop*
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
%typemap{ExPolygon*};
|
%typemap{ExPolygon*};
|
||||||
%typemap{Polyline*};
|
%typemap{Polyline*};
|
||||||
%typemap{Polygon*};
|
%typemap{Polygon*};
|
||||||
|
%typemap{ExtrusionPath*};
|
||||||
|
%typemap{ExtrusionLoop*};
|
||||||
%typemap{Lines};
|
%typemap{Lines};
|
||||||
|
|
||||||
%typemap{SurfaceType}{parsed}{
|
%typemap{SurfaceType}{parsed}{
|
||||||
|
Loading…
Reference in New Issue
Block a user