Removed Surface and SurfaceCollection from Perl bindings.
This commit is contained in:
parent
d041fa6c0c
commit
57db091612
@ -53,8 +53,6 @@ set(XS_XSP_FILES
|
||||
${XSP_DIR}/Polygon.xsp
|
||||
${XSP_DIR}/Polyline.xsp
|
||||
${XSP_DIR}/Print.xsp
|
||||
${XSP_DIR}/Surface.xsp
|
||||
${XSP_DIR}/SurfaceCollection.xsp
|
||||
${XSP_DIR}/TriangleMesh.xsp
|
||||
${XSP_DIR}/XS.xsp
|
||||
)
|
||||
|
@ -48,61 +48,6 @@ use overload
|
||||
'@{}' => sub { $_[0]->arrayref },
|
||||
'fallback' => 1;
|
||||
|
||||
package Slic3r::ExtrusionPath::Collection;
|
||||
use overload
|
||||
'@{}' => sub { $_[0]->arrayref },
|
||||
'fallback' => 1;
|
||||
|
||||
sub new {
|
||||
my ($class, @paths) = @_;
|
||||
|
||||
my $self = $class->_new;
|
||||
$self->append(@paths);
|
||||
return $self;
|
||||
}
|
||||
|
||||
package Slic3r::ExtrusionLoop;
|
||||
use overload
|
||||
'@{}' => sub { $_[0]->arrayref },
|
||||
'fallback' => 1;
|
||||
|
||||
sub new_from_paths {
|
||||
my ($class, @paths) = @_;
|
||||
|
||||
my $loop = $class->new;
|
||||
$loop->append($_) for @paths;
|
||||
return $loop;
|
||||
}
|
||||
|
||||
package Slic3r::ExtrusionPath;
|
||||
use overload
|
||||
'@{}' => sub { $_[0]->arrayref },
|
||||
'fallback' => 1;
|
||||
|
||||
sub new {
|
||||
my ($class, %args) = @_;
|
||||
|
||||
return $class->_new(
|
||||
$args{polyline}, # required
|
||||
$args{role}, # required
|
||||
$args{mm3_per_mm} // die("Missing required mm3_per_mm in ExtrusionPath constructor"),
|
||||
$args{width} // -1,
|
||||
$args{height} // -1,
|
||||
);
|
||||
}
|
||||
|
||||
sub clone {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
return __PACKAGE__->_new(
|
||||
$args{polyline} // $self->polyline,
|
||||
$args{role} // $self->role,
|
||||
$args{mm3_per_mm} // $self->mm3_per_mm,
|
||||
$args{width} // $self->width,
|
||||
$args{height} // $self->height,
|
||||
);
|
||||
}
|
||||
|
||||
package Slic3r::Surface;
|
||||
|
||||
sub new {
|
||||
@ -155,9 +100,6 @@ for my $class (qw(
|
||||
Slic3r::Config::Print
|
||||
Slic3r::Config::Static
|
||||
Slic3r::ExPolygon
|
||||
Slic3r::ExtrusionLoop
|
||||
Slic3r::ExtrusionPath
|
||||
Slic3r::ExtrusionPath::Collection
|
||||
Slic3r::Geometry::BoundingBox
|
||||
Slic3r::Line
|
||||
Slic3r::Model
|
||||
|
@ -4,9 +4,6 @@
|
||||
namespace Slic3r {
|
||||
|
||||
REGISTER_CLASS(ExPolygon, "ExPolygon");
|
||||
REGISTER_CLASS(ExtrusionPath, "ExtrusionPath");
|
||||
REGISTER_CLASS(ExtrusionLoop, "ExtrusionLoop");
|
||||
REGISTER_CLASS(ExtrusionEntityCollection, "ExtrusionPath::Collection");
|
||||
REGISTER_CLASS(GCode, "GCode");
|
||||
REGISTER_CLASS(Line, "Line");
|
||||
REGISTER_CLASS(Polygon, "Polygon");
|
||||
|
@ -1,71 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Slic3r::XS;
|
||||
use Test::More tests => 11;
|
||||
|
||||
my $square = [ # ccw
|
||||
[100, 100],
|
||||
[200, 100],
|
||||
[200, 200],
|
||||
[100, 200],
|
||||
];
|
||||
my $hole_in_square = [ # cw
|
||||
[140, 140],
|
||||
[140, 160],
|
||||
[160, 160],
|
||||
[160, 140],
|
||||
];
|
||||
|
||||
my $expolygon = Slic3r::ExPolygon->new($square, $hole_in_square);
|
||||
my $surface = Slic3r::Surface->new(
|
||||
expolygon => $expolygon,
|
||||
surface_type => Slic3r::Surface::S_TYPE_INTERNAL,
|
||||
);
|
||||
|
||||
$surface = $surface->clone;
|
||||
|
||||
is $surface->surface_type, Slic3r::Surface::S_TYPE_INTERNAL, 'surface_type';
|
||||
$surface->surface_type(Slic3r::Surface::S_TYPE_BOTTOM);
|
||||
is $surface->surface_type, Slic3r::Surface::S_TYPE_BOTTOM, 'modify surface_type';
|
||||
|
||||
$surface->bridge_angle(30);
|
||||
is $surface->bridge_angle, 30, 'bridge_angle';
|
||||
|
||||
$surface->extra_perimeters(2);
|
||||
is $surface->extra_perimeters, 2, 'extra_perimeters';
|
||||
|
||||
{
|
||||
my $surface2 = $surface->clone;
|
||||
$surface2->expolygon->scale(2);
|
||||
isnt $surface2->expolygon->area, $expolygon->area, 'expolygon is returned by reference';
|
||||
}
|
||||
|
||||
{
|
||||
my $collection = Slic3r::Surface::Collection->new;
|
||||
$collection->append($_) for $surface, $surface->clone;
|
||||
is scalar(@$collection), 2, 'collection has the right number of items';
|
||||
is_deeply $collection->[0]->expolygon->pp, [$square, $hole_in_square],
|
||||
'collection returns a correct surface expolygon';
|
||||
$collection->clear;
|
||||
is scalar(@$collection), 0, 'clear collection';
|
||||
$collection->append($surface);
|
||||
is scalar(@$collection), 1, 'append to collection';
|
||||
|
||||
my $item = $collection->[0];
|
||||
$item->surface_type(Slic3r::Surface::S_TYPE_INTERNAL);
|
||||
is $item->surface_type, $collection->[0]->surface_type, 'collection returns items by reference';
|
||||
}
|
||||
|
||||
{
|
||||
my $collection = Slic3r::Surface::Collection->new;
|
||||
$collection->append($_) for
|
||||
Slic3r::Surface->new(expolygon => $expolygon, surface_type => Slic3r::Surface::S_TYPE_BOTTOM),
|
||||
Slic3r::Surface->new(expolygon => $expolygon, surface_type => Slic3r::Surface::S_TYPE_BOTTOM),
|
||||
Slic3r::Surface->new(expolygon => $expolygon, surface_type => Slic3r::Surface::S_TYPE_TOP);
|
||||
is scalar(@{$collection->group}), 2, 'group() returns correct number of groups';
|
||||
}
|
||||
|
||||
__END__
|
@ -1,107 +0,0 @@
|
||||
%module{Slic3r::XS};
|
||||
|
||||
%{
|
||||
#include <xsinit.h>
|
||||
#include "libslic3r/Surface.hpp"
|
||||
%}
|
||||
|
||||
%name{Slic3r::Surface} class Surface {
|
||||
~Surface();
|
||||
Ref<ExPolygon> expolygon()
|
||||
%code{% RETVAL = &(THIS->expolygon); %};
|
||||
double thickness()
|
||||
%code{% RETVAL = THIS->thickness; %};
|
||||
unsigned short thickness_layers()
|
||||
%code{% RETVAL = THIS->thickness_layers; %};
|
||||
double area();
|
||||
bool is_solid() const;
|
||||
bool is_external() const;
|
||||
bool is_internal() const;
|
||||
bool is_bottom() const;
|
||||
bool is_bridge() const;
|
||||
%{
|
||||
|
||||
Surface*
|
||||
_new(CLASS, expolygon, surface_type, thickness, thickness_layers, bridge_angle, extra_perimeters)
|
||||
char* CLASS;
|
||||
ExPolygon* expolygon;
|
||||
SurfaceType surface_type;
|
||||
double thickness;
|
||||
unsigned short thickness_layers;
|
||||
double bridge_angle;
|
||||
unsigned short extra_perimeters;
|
||||
CODE:
|
||||
RETVAL = new Surface (surface_type, *expolygon);
|
||||
RETVAL->thickness = thickness;
|
||||
RETVAL->thickness_layers = thickness_layers;
|
||||
RETVAL->bridge_angle = bridge_angle;
|
||||
RETVAL->extra_perimeters = extra_perimeters;
|
||||
// we don't delete expolygon here because it's referenced by a Perl SV
|
||||
// whose DESTROY will take care of destruction
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
SurfaceType
|
||||
Surface::surface_type(...)
|
||||
CODE:
|
||||
if (items > 1) {
|
||||
THIS->surface_type = (SurfaceType)SvUV(ST(1));
|
||||
}
|
||||
RETVAL = THIS->surface_type;
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
double
|
||||
Surface::bridge_angle(...)
|
||||
CODE:
|
||||
if (items > 1) {
|
||||
THIS->bridge_angle = (double)SvNV(ST(1));
|
||||
}
|
||||
RETVAL = THIS->bridge_angle;
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
unsigned short
|
||||
Surface::extra_perimeters(...)
|
||||
CODE:
|
||||
if (items > 1) {
|
||||
THIS->extra_perimeters = (double)SvUV(ST(1));
|
||||
}
|
||||
RETVAL = THIS->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
|
||||
|
||||
%}
|
||||
};
|
||||
|
||||
%package{Slic3r::Surface};
|
||||
%{
|
||||
|
||||
IV
|
||||
_constant()
|
||||
ALIAS:
|
||||
S_TYPE_TOP = stTop
|
||||
S_TYPE_BOTTOM = stBottom
|
||||
S_TYPE_BOTTOMBRIDGE = stBottomBridge
|
||||
S_TYPE_INTERNAL = stInternal
|
||||
S_TYPE_INTERNALSOLID = stInternalSolid
|
||||
S_TYPE_INTERNALBRIDGE = stInternalBridge
|
||||
S_TYPE_INTERNALVOID = stInternalVoid
|
||||
S_TYPW_PERIMETER = stPerimeter
|
||||
PROTOTYPE:
|
||||
CODE:
|
||||
RETVAL = ix;
|
||||
OUTPUT: RETVAL
|
||||
|
||||
%}
|
||||
|
@ -1,70 +0,0 @@
|
||||
%module{Slic3r::XS};
|
||||
|
||||
%{
|
||||
#include <xsinit.h>
|
||||
#include "libslic3r/SurfaceCollection.hpp"
|
||||
%}
|
||||
|
||||
%name{Slic3r::Surface::Collection} class SurfaceCollection {
|
||||
%name{_new} SurfaceCollection();
|
||||
~SurfaceCollection();
|
||||
void clear()
|
||||
%code{% THIS->surfaces.clear(); %};
|
||||
void append(Surface* surface)
|
||||
%code{% THIS->surfaces.push_back(*surface); %};
|
||||
int count()
|
||||
%code{% RETVAL = THIS->surfaces.size(); %};
|
||||
void simplify(double tolerance);
|
||||
%{
|
||||
|
||||
SV*
|
||||
SurfaceCollection::arrayref()
|
||||
CODE:
|
||||
AV* av = newAV();
|
||||
av_fill(av, THIS->surfaces.size()-1);
|
||||
int i = 0;
|
||||
for (Surfaces::iterator it = THIS->surfaces.begin(); it != THIS->surfaces.end(); ++it) {
|
||||
av_store(av, i++, perl_to_SV_ref(*it));
|
||||
}
|
||||
RETVAL = newRV_noinc((SV*)av);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
SV*
|
||||
SurfaceCollection::filter_by_type(surface_type)
|
||||
SurfaceType surface_type;
|
||||
CODE:
|
||||
AV* av = newAV();
|
||||
for (Surfaces::iterator it = THIS->surfaces.begin(); it != THIS->surfaces.end(); ++it) {
|
||||
if ((*it).surface_type == surface_type) av_push(av, perl_to_SV_ref(*it));
|
||||
}
|
||||
RETVAL = newRV_noinc((SV*)av);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
SV*
|
||||
SurfaceCollection::group()
|
||||
CODE:
|
||||
// perform grouping
|
||||
std::vector<SurfacesPtr> groups;
|
||||
THIS->group(&groups);
|
||||
|
||||
// build return arrayref
|
||||
AV* av = newAV();
|
||||
av_fill(av, groups.size()-1);
|
||||
size_t i = 0;
|
||||
for (std::vector<SurfacesPtr>::iterator it = groups.begin(); it != groups.end(); ++it) {
|
||||
AV* innerav = newAV();
|
||||
av_fill(innerav, it->size()-1);
|
||||
size_t j = 0;
|
||||
for (SurfacesPtr::iterator it_s = it->begin(); it_s != it->end(); ++it_s) {
|
||||
av_store(innerav, j++, perl_to_SV_clone_ref(**it_s));
|
||||
}
|
||||
av_store(av, i++, newRV_noinc((SV*)innerav));
|
||||
}
|
||||
RETVAL = newRV_noinc((SV*)av);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
%}
|
||||
};
|
@ -70,13 +70,6 @@ ExPolygon* O_OBJECT_SLIC3R
|
||||
Ref<ExPolygon> O_OBJECT_SLIC3R_T
|
||||
Clone<ExPolygon> O_OBJECT_SLIC3R_T
|
||||
|
||||
Surface* O_OBJECT_SLIC3R
|
||||
Ref<Surface> O_OBJECT_SLIC3R_T
|
||||
Clone<Surface> O_OBJECT_SLIC3R_T
|
||||
|
||||
SurfaceCollection* O_OBJECT_SLIC3R
|
||||
Ref<SurfaceCollection> O_OBJECT_SLIC3R_T
|
||||
|
||||
Model* O_OBJECT_SLIC3R
|
||||
Ref<Model> O_OBJECT_SLIC3R_T
|
||||
Clone<Model> O_OBJECT_SLIC3R_T
|
||||
@ -119,7 +112,6 @@ Lines T_ARRAYREF
|
||||
Polygons T_ARRAYREF
|
||||
Polylines T_ARRAYREF
|
||||
ExPolygons T_ARRAYREF
|
||||
Surfaces T_ARRAYREF
|
||||
|
||||
# we return these types whenever we want the items to be returned
|
||||
# by reference and marked ::Ref because they're contained in another
|
||||
|
@ -56,13 +56,6 @@
|
||||
%typemap{TriangleMesh*};
|
||||
%typemap{Ref<TriangleMesh>}{simple};
|
||||
%typemap{Clone<TriangleMesh>}{simple};
|
||||
%typemap{SurfaceCollection*};
|
||||
%typemap{Ref<SurfaceCollection>}{simple};
|
||||
%typemap{Clone<SurfaceCollection>}{simple};
|
||||
|
||||
%typemap{Surface*};
|
||||
%typemap{Ref<Surface>}{simple};
|
||||
%typemap{Clone<Surface>}{simple};
|
||||
|
||||
%typemap{PrintState*};
|
||||
%typemap{Ref<PrintState>}{simple};
|
||||
@ -83,7 +76,6 @@
|
||||
%typemap{Polygons};
|
||||
%typemap{Polylines};
|
||||
%typemap{ExPolygons};
|
||||
%typemap{Surfaces};
|
||||
%typemap{Polygons*};
|
||||
%typemap{TriangleMesh*};
|
||||
%typemap{Model*};
|
||||
|
Loading…
Reference in New Issue
Block a user