2013-06-22 15:16:45 +00:00
|
|
|
package Slic3r::XS;
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
our $VERSION = '0.01';
|
|
|
|
|
2013-09-09 21:09:56 +00:00
|
|
|
use Carp qw();
|
2013-06-22 15:16:45 +00:00
|
|
|
use XSLoader;
|
|
|
|
XSLoader::load(__PACKAGE__, $VERSION);
|
|
|
|
|
2013-07-16 15:13:01 +00:00
|
|
|
package Slic3r::Line;
|
|
|
|
use overload
|
|
|
|
'@{}' => sub { $_[0]->arrayref },
|
|
|
|
'fallback' => 1;
|
|
|
|
|
2013-07-15 18:31:43 +00:00
|
|
|
package Slic3r::Point;
|
2013-07-06 13:26:32 +00:00
|
|
|
use overload
|
2013-07-16 15:13:01 +00:00
|
|
|
'@{}' => sub { $_[0]->arrayref },
|
|
|
|
'fallback' => 1;
|
2013-06-22 15:16:45 +00:00
|
|
|
|
2014-04-27 22:13:50 +00:00
|
|
|
package Slic3r::Pointf;
|
|
|
|
use overload
|
2014-08-02 22:20:55 +00:00
|
|
|
'@{}' => sub { $_[0]->arrayref },
|
2014-04-27 22:13:50 +00:00
|
|
|
'fallback' => 1;
|
|
|
|
|
2014-01-07 18:08:37 +00:00
|
|
|
package Slic3r::Pointf3;
|
|
|
|
use overload
|
|
|
|
'@{}' => sub { [ $_[0]->x, $_[0]->y, $_[0]->z ] }, #,
|
|
|
|
'fallback' => 1;
|
|
|
|
|
2015-01-15 17:49:07 +00:00
|
|
|
sub pp {
|
|
|
|
my ($self) = @_;
|
|
|
|
return [ @$self ];
|
|
|
|
}
|
|
|
|
|
2013-07-15 20:57:22 +00:00
|
|
|
package Slic3r::ExPolygon;
|
2013-07-06 14:33:49 +00:00
|
|
|
use overload
|
2013-07-16 15:13:01 +00:00
|
|
|
'@{}' => sub { $_[0]->arrayref },
|
|
|
|
'fallback' => 1;
|
2013-07-06 14:33:49 +00:00
|
|
|
|
2013-07-15 20:57:22 +00:00
|
|
|
package Slic3r::Polyline;
|
2013-07-15 10:14:22 +00:00
|
|
|
use overload
|
|
|
|
'@{}' => sub { $_[0]->arrayref },
|
|
|
|
'fallback' => 1;
|
|
|
|
|
2013-07-15 20:57:22 +00:00
|
|
|
package Slic3r::Polygon;
|
2013-07-15 10:14:22 +00:00
|
|
|
use overload
|
2013-07-16 15:13:01 +00:00
|
|
|
'@{}' => sub { $_[0]->arrayref },
|
|
|
|
'fallback' => 1;
|
2013-07-15 10:14:22 +00:00
|
|
|
|
2013-07-14 11:05:55 +00:00
|
|
|
package Slic3r::Surface;
|
|
|
|
|
|
|
|
sub new {
|
|
|
|
my ($class, %args) = @_;
|
|
|
|
|
|
|
|
# defensive programming: make sure no negative bridge_angle is supplied
|
|
|
|
die "Error: invalid negative bridge_angle\n"
|
|
|
|
if defined $args{bridge_angle} && $args{bridge_angle} < 0;
|
|
|
|
|
|
|
|
return $class->_new(
|
2013-07-15 10:14:22 +00:00
|
|
|
$args{expolygon} // (die "Missing required expolygon\n"),
|
|
|
|
$args{surface_type} // (die "Missing required surface_type\n"),
|
|
|
|
$args{thickness} // -1,
|
|
|
|
$args{thickness_layers} // 1,
|
|
|
|
$args{bridge_angle} // -1,
|
|
|
|
$args{extra_perimeters} // 0,
|
2013-07-14 11:05:55 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub clone {
|
|
|
|
my ($self, %args) = @_;
|
|
|
|
|
|
|
|
return (ref $self)->_new(
|
2013-08-08 00:10:34 +00:00
|
|
|
delete $args{expolygon} // $self->expolygon,
|
2013-07-14 11:05:55 +00:00
|
|
|
delete $args{surface_type} // $self->surface_type,
|
|
|
|
delete $args{thickness} // $self->thickness,
|
|
|
|
delete $args{thickness_layers} // $self->thickness_layers,
|
|
|
|
delete $args{bridge_angle} // $self->bridge_angle,
|
|
|
|
delete $args{extra_perimeters} // $self->extra_perimeters,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-07-14 12:56:43 +00:00
|
|
|
package Slic3r::Surface::Collection;
|
|
|
|
use overload
|
2013-07-16 15:13:01 +00:00
|
|
|
'@{}' => sub { $_[0]->arrayref },
|
|
|
|
'fallback' => 1;
|
2013-07-14 12:56:43 +00:00
|
|
|
|
2014-11-09 15:23:50 +00:00
|
|
|
sub new {
|
|
|
|
my ($class, @surfaces) = @_;
|
|
|
|
|
|
|
|
my $self = $class->_new;
|
|
|
|
$self->append($_) for @surfaces;
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
2014-04-29 23:04:49 +00:00
|
|
|
package main;
|
|
|
|
for my $class (qw(
|
|
|
|
Slic3r::Config
|
2014-11-09 18:02:45 +00:00
|
|
|
Slic3r::Config::GCode
|
2014-04-29 23:04:49 +00:00
|
|
|
Slic3r::Config::Print
|
2015-12-16 11:33:19 +00:00
|
|
|
Slic3r::Config::Static
|
2014-04-29 23:04:49 +00:00
|
|
|
Slic3r::ExPolygon
|
|
|
|
Slic3r::Line
|
|
|
|
Slic3r::Model
|
|
|
|
Slic3r::Model::Instance
|
|
|
|
Slic3r::Model::Material
|
|
|
|
Slic3r::Model::Object
|
|
|
|
Slic3r::Model::Volume
|
|
|
|
Slic3r::Point
|
2014-05-06 08:07:18 +00:00
|
|
|
Slic3r::Point3
|
2014-04-29 23:04:49 +00:00
|
|
|
Slic3r::Pointf
|
|
|
|
Slic3r::Pointf3
|
|
|
|
Slic3r::Polygon
|
|
|
|
Slic3r::Polyline
|
2014-05-06 22:38:57 +00:00
|
|
|
Slic3r::Polyline::Collection
|
2014-05-06 08:07:18 +00:00
|
|
|
Slic3r::Print
|
2014-04-29 23:04:49 +00:00
|
|
|
Slic3r::TriangleMesh
|
|
|
|
))
|
|
|
|
{
|
|
|
|
no strict 'refs';
|
|
|
|
my $ref_class = $class . "::Ref";
|
|
|
|
eval "package $ref_class; our \@ISA = '$class'; sub DESTROY {};";
|
|
|
|
}
|
|
|
|
|
2013-06-22 15:16:45 +00:00
|
|
|
1;
|