Turn ExtrusionLoop into a collection of polylines. Includes some changes to the Polygon API to avoid returning newly allocatd objects

This commit is contained in:
Alessandro Ranellucci 2014-05-07 12:02:09 +02:00
parent c72dc13d7e
commit d2d885fc53
11 changed files with 107 additions and 72 deletions

View file

@ -9,13 +9,14 @@
%name{Slic3r::ExtrusionLoop} class ExtrusionLoop {
~ExtrusionLoop();
SV* arrayref()
%code{% RETVAL = THIS->polygon.to_AV(); %};
%code{% Polygon polygon; THIS->polygon(&polygon); RETVAL = polygon.to_AV(); %};
SV* pp()
%code{% RETVAL = THIS->polygon.to_SV_pureperl(); %};
void reverse()
%code{% THIS->polygon.reverse(); %};
ExtrusionPath* split_at_index(int index);
ExtrusionPath* split_at_first_point();
%code{% Polygon polygon; THIS->polygon(&polygon); RETVAL = polygon.to_SV_pureperl(); %};
void reverse();
ExtrusionPath* split_at_index(int index)
%code{% RETVAL = new ExtrusionPath (); THIS->split_at_index(index, RETVAL); %};
ExtrusionPath* split_at_first_point()
%code{% RETVAL = new ExtrusionPath (); THIS->split_at_first_point(RETVAL); %};
bool make_counter_clockwise();
Clone<Point> first_point();
Clone<Point> last_point();
@ -33,22 +34,25 @@ _new(CLASS, polygon_sv, role, mm3_per_mm, width, height)
float width;
float height;
CODE:
RETVAL = new ExtrusionLoop ();
RETVAL->polygon.from_SV_check(polygon_sv);
RETVAL->role = role;
Polygon polygon;
polygon.from_SV_check(polygon_sv);
RETVAL = new ExtrusionLoop (polygon, role);
RETVAL->mm3_per_mm = mm3_per_mm;
RETVAL->width = width;
RETVAL->height = height;
OUTPUT:
RETVAL
Ref<Polygon>
Polygon*
ExtrusionLoop::polygon(...)
CODE:
if (items > 1) {
THIS->polygon.from_SV_check( ST(1) );
Polygon polygon;
polygon.from_SV_check( ST(1) );
THIS->set_polygon(polygon);
}
RETVAL = &(THIS->polygon);
RETVAL = new Polygon ();
THIS->polygon(RETVAL);
OUTPUT:
RETVAL

View file

@ -19,12 +19,13 @@
void reverse();
Lines lines();
Polyline* split_at(Point* point)
%code{% RETVAL = THIS->split_at(*point); %};
%code{% RETVAL = new Polyline(); THIS->split_at(*point, RETVAL); %};
Polyline* split_at_index(int index)
%code{% RETVAL = THIS->split_at_index(index); %};
%code{% RETVAL = new Polyline(); THIS->split_at_index(index, RETVAL); %};
Polyline* split_at_first_point()
%code{% RETVAL = THIS->split_at_first_point(); %};
Points equally_spaced_points(double distance);
%code{% RETVAL = new Polyline(); THIS->split_at_first_point(RETVAL); %};
Points equally_spaced_points(double distance)
%code{% THIS->equally_spaced_points(distance, &RETVAL); %};
double length();
double area();
bool is_counter_clockwise();

View file

@ -23,7 +23,8 @@
Lines lines();
Clone<Point> first_point();
Clone<Point> last_point();
Points equally_spaced_points(double distance);
Points equally_spaced_points(double distance)
%code{% THIS->equally_spaced_points(distance, &RETVAL); %};
double length();
bool is_valid();
void clip_end(double distance);