From 85011dfef3685f53cbe8b36e1d4a27d5c92d0f43 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 26 Aug 2013 23:03:00 +0200 Subject: [PATCH] Ported Surface->p --- lib/Slic3r/Surface.pm | 2 +- xs/t/05_surface.t | 3 ++- xs/xsp/Surface.xsp | 10 ++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/Surface.pm b/lib/Slic3r/Surface.pm index a1f4e1466..d0b9ec778 100644 --- a/lib/Slic3r/Surface.pm +++ b/lib/Slic3r/Surface.pm @@ -45,7 +45,7 @@ sub simplify { sub p { my $self = shift; - return @{$self->expolygon->pp}; + return @{$self->polygons}; } sub is_solid { diff --git a/xs/t/05_surface.t b/xs/t/05_surface.t index a8797d25c..c9d28c43d 100644 --- a/xs/t/05_surface.t +++ b/xs/t/05_surface.t @@ -4,7 +4,7 @@ use strict; use warnings; use Slic3r::XS; -use Test::More tests => 11; +use Test::More tests => 12; my $square = [ # ccw [100, 100], @@ -29,6 +29,7 @@ $surface = $surface->clone; isa_ok $surface->expolygon, 'Slic3r::ExPolygon', 'expolygon'; is_deeply [ @{$surface->expolygon->pp} ], [$square, $hole_in_square], 'expolygon roundtrip'; +is scalar(@{$surface->polygons}), 2, 'polygons roundtrip'; is $surface->surface_type, Slic3r::Surface::S_TYPE_INTERNAL, 'surface_type'; $surface->surface_type(Slic3r::Surface::S_TYPE_BOTTOM); diff --git a/xs/xsp/Surface.xsp b/xs/xsp/Surface.xsp index e0123aa8e..d2a8e0f3f 100644 --- a/xs/xsp/Surface.xsp +++ b/xs/xsp/Surface.xsp @@ -67,6 +67,16 @@ Surface::extra_perimeters(...) OUTPUT: RETVAL +Polygons +Surface::polygons() + CODE: + RETVAL.push_back(THIS->expolygon.contour); + for (Polygons::iterator it = THIS->expolygon.holes.begin(); it != THIS->expolygon.holes.end(); ++it) { + RETVAL.push_back((*it)); + } + OUTPUT: + RETVAL + %} };