Merge branch 'master' into xsdata

Conflicts:
	xs/xsp/ExPolygon.xsp
This commit is contained in:
Alessandro Ranellucci 2013-07-07 16:53:58 +02:00
commit 21816acbd7
4 changed files with 12 additions and 9 deletions

View file

@ -16,12 +16,13 @@ use Time::HiRes qw(gettimeofday tv_interval);
my $t0 = [gettimeofday]; my $t0 = [gettimeofday];
my $print = Slic3r::Test::init_print('20mm_cube', scale => 2); my $print = Slic3r::Test::init_print('20mm_cube', scale => 2);
my $gcode = Slic3r::Test::gcode($print); my $gcode = Slic3r::Test::gcode($print);
diag sprintf 'Slicing took %s seconds', tv_interval($t0); ###diag sprintf 'Slicing took %s seconds', tv_interval($t0);
my $t1 = [gettimeofday]; my $t1 = [gettimeofday];
nstore $print, 'print.dat'; nstore $print, 'print.dat';
$print = retrieve 'print.dat'; $print = retrieve 'print.dat';
diag sprintf 'Freezing and retrieving took %s seconds', tv_interval($t1); unlink 'print.dat';
###diag sprintf 'Freezing and retrieving took %s seconds', tv_interval($t1);
isa_ok $print, 'Slic3r::Print', 'restored Print object'; isa_ok $print, 'Slic3r::Print', 'restored Print object';
} }

View file

@ -21,21 +21,20 @@ class ExPolygon
SV* arrayref(); SV* arrayref();
}; };
Polygon* void
perl2polygon(SV* poly_sv) perl2polygon(SV* poly_sv, Polygon& poly)
{ {
AV* poly_av = (AV*)SvRV(poly_sv); AV* poly_av = (AV*)SvRV(poly_sv);
const unsigned int num_points = av_len(poly_av)+1; const unsigned int num_points = av_len(poly_av)+1;
Polygon* retval = new Polygon(num_points); poly.resize(num_points);
for (unsigned int i = 0; i < num_points; i++) { for (unsigned int i = 0; i < num_points; i++) {
SV** point_sv = av_fetch(poly_av, i, 0); SV** point_sv = av_fetch(poly_av, i, 0);
AV* point_av = (AV*)SvRV(*point_sv); AV* point_av = (AV*)SvRV(*point_sv);
Point& p = (*retval)[i]; Point& p = poly[i];
p.x = (unsigned long)SvIV(*av_fetch(point_av, 0, 0)); p.x = (unsigned long)SvIV(*av_fetch(point_av, 0, 0));
p.y = (unsigned long)SvIV(*av_fetch(point_av, 1, 0)); p.y = (unsigned long)SvIV(*av_fetch(point_av, 1, 0));
} }
return retval;
} }
SV* SV*

View file

@ -7,6 +7,7 @@
%name{Slic3r::ExPolygon::XS} class ExPolygon { %name{Slic3r::ExPolygon::XS} class ExPolygon {
%name{_clone} ExPolygon(ExPolygon& self); %name{_clone} ExPolygon(ExPolygon& self);
~ExPolygon();
%{ %{
ExPolygon* ExPolygon*
@ -14,9 +15,10 @@ ExPolygon::new(...)
CODE: CODE:
RETVAL = new ExPolygon (); RETVAL = new ExPolygon ();
// ST(0) is class name, ST(1) is contour and others are holes // ST(0) is class name, ST(1) is contour and others are holes
RETVAL->contour = *perl2polygon(ST(1)); perl2polygon(ST(1), RETVAL->contour);
RETVAL->holes.resize(items-2);
for (unsigned int i = 2; i < items; i++) { for (unsigned int i = 2; i < items; i++) {
RETVAL->holes.push_back(*perl2polygon(ST(i))); perl2polygon(ST(i), RETVAL->holes[i-2]);
} }
OUTPUT: OUTPUT:
RETVAL RETVAL

View file

@ -7,6 +7,7 @@
%name{Slic3r::Point::XS} class Point { %name{Slic3r::Point::XS} class Point {
Point(unsigned long _x = 0, unsigned long _y = 0); Point(unsigned long _x = 0, unsigned long _y = 0);
~Point();
%{ %{
SV* SV*