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-09-02 18:22:20 +00:00
|
|
|
package Slic3r::Line::Ref;
|
|
|
|
our @ISA = 'Slic3r::Line';
|
|
|
|
|
|
|
|
sub DESTROY {}
|
|
|
|
|
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
|
|
|
|
2013-09-02 18:22:20 +00:00
|
|
|
package Slic3r::Point::Ref;
|
|
|
|
our @ISA = 'Slic3r::Point';
|
|
|
|
|
|
|
|
sub DESTROY {}
|
|
|
|
|
2014-04-27 22:13:50 +00:00
|
|
|
package Slic3r::Pointf;
|
|
|
|
use overload
|
|
|
|
'@{}' => sub { [ $_[0]->x, $_[0]->y ] }, #,
|
|
|
|
'fallback' => 1;
|
|
|
|
|
2014-04-28 20:02:34 +00:00
|
|
|
package Slic3r::Pointf::Ref;
|
|
|
|
our @ISA = 'Slic3r::Pointf';
|
|
|
|
|
|
|
|
sub DESTROY {}
|
|
|
|
|
2014-01-07 18:08:37 +00:00
|
|
|
package Slic3r::Pointf3;
|
|
|
|
use overload
|
|
|
|
'@{}' => sub { [ $_[0]->x, $_[0]->y, $_[0]->z ] }, #,
|
|
|
|
'fallback' => 1;
|
|
|
|
|
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-08-30 22:28:24 +00:00
|
|
|
package Slic3r::ExPolygon::Ref;
|
|
|
|
our @ISA = 'Slic3r::ExPolygon';
|
|
|
|
|
|
|
|
sub DESTROY {}
|
|
|
|
|
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-08-30 22:50:03 +00:00
|
|
|
package Slic3r::Polyline::Ref;
|
|
|
|
our @ISA = 'Slic3r::Polyline';
|
|
|
|
|
|
|
|
sub DESTROY {}
|
|
|
|
|
2013-08-29 22:06:10 +00:00
|
|
|
package Slic3r::Polyline::Collection;
|
|
|
|
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-08-30 22:50:03 +00:00
|
|
|
package Slic3r::Polygon::Ref;
|
|
|
|
our @ISA = 'Slic3r::Polygon';
|
|
|
|
|
|
|
|
sub DESTROY {}
|
|
|
|
|
2013-07-13 22:38:01 +00:00
|
|
|
package Slic3r::ExPolygon::Collection;
|
|
|
|
use overload
|
2013-07-16 15:13:01 +00:00
|
|
|
'@{}' => sub { $_[0]->arrayref },
|
|
|
|
'fallback' => 1;
|
2013-07-13 22:38:01 +00:00
|
|
|
|
2013-07-18 17:09:07 +00:00
|
|
|
package Slic3r::ExtrusionPath::Collection;
|
|
|
|
use overload
|
|
|
|
'@{}' => sub { $_[0]->arrayref },
|
|
|
|
'fallback' => 1;
|
|
|
|
|
2013-07-18 20:29:12 +00:00
|
|
|
sub new {
|
|
|
|
my ($class, @paths) = @_;
|
|
|
|
|
|
|
|
my $self = $class->_new;
|
|
|
|
$self->append(@paths);
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
2013-08-30 22:37:17 +00:00
|
|
|
package Slic3r::ExtrusionPath::Collection::Ref;
|
|
|
|
our @ISA = 'Slic3r::ExtrusionPath::Collection';
|
|
|
|
|
|
|
|
sub DESTROY {}
|
|
|
|
|
2013-07-15 10:14:22 +00:00
|
|
|
package Slic3r::ExtrusionLoop;
|
2013-07-15 14:21:09 +00:00
|
|
|
use overload
|
|
|
|
'@{}' => sub { $_[0]->arrayref },
|
|
|
|
'fallback' => 1;
|
2013-07-15 10:14:22 +00:00
|
|
|
|
|
|
|
sub new {
|
|
|
|
my ($class, %args) = @_;
|
|
|
|
|
|
|
|
return $class->_new(
|
2013-07-15 14:21:09 +00:00
|
|
|
$args{polygon}, # required
|
2013-07-15 10:14:22 +00:00
|
|
|
$args{role}, # required
|
2014-04-29 21:15:36 +00:00
|
|
|
$args{mm3_per_mm} // die("Missing required mm3_per_mm in ExtrusionLoop constructor"),
|
|
|
|
$args{width} // -1,
|
|
|
|
$args{height} // -1,
|
2013-07-15 10:14:22 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub clone {
|
|
|
|
my ($self, %args) = @_;
|
|
|
|
|
2014-03-09 19:19:30 +00:00
|
|
|
return __PACKAGE__->_new(
|
2013-07-16 07:49:34 +00:00
|
|
|
$args{polygon} // $self->polygon,
|
2013-07-15 10:14:22 +00:00
|
|
|
$args{role} // $self->role,
|
2014-01-03 17:27:46 +00:00
|
|
|
$args{mm3_per_mm} // $self->mm3_per_mm,
|
2014-04-29 21:15:36 +00:00
|
|
|
$args{width} // $self->width,
|
|
|
|
$args{height} // $self->height,
|
2013-07-15 10:14:22 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-08-30 22:37:17 +00:00
|
|
|
package Slic3r::ExtrusionLoop::Ref;
|
|
|
|
our @ISA = 'Slic3r::ExtrusionLoop';
|
|
|
|
|
|
|
|
sub DESTROY {}
|
|
|
|
|
2013-07-15 10:14:22 +00:00
|
|
|
package Slic3r::ExtrusionPath;
|
|
|
|
use overload
|
|
|
|
'@{}' => sub { $_[0]->arrayref },
|
|
|
|
'fallback' => 1;
|
|
|
|
|
|
|
|
sub new {
|
|
|
|
my ($class, %args) = @_;
|
|
|
|
|
|
|
|
return $class->_new(
|
2013-07-15 14:21:09 +00:00
|
|
|
$args{polyline}, # required
|
2013-07-15 10:14:22 +00:00
|
|
|
$args{role}, # required
|
2014-04-29 21:15:36 +00:00
|
|
|
$args{mm3_per_mm} // die("Missing required mm3_per_mm in ExtrusionPath constructor"),
|
|
|
|
$args{width} // -1,
|
|
|
|
$args{height} // -1,
|
2013-07-15 10:14:22 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub clone {
|
|
|
|
my ($self, %args) = @_;
|
|
|
|
|
2014-03-09 19:19:30 +00:00
|
|
|
return __PACKAGE__->_new(
|
2013-07-16 07:49:34 +00:00
|
|
|
$args{polyline} // $self->polyline,
|
2013-07-15 10:14:22 +00:00
|
|
|
$args{role} // $self->role,
|
2014-01-03 17:27:46 +00:00
|
|
|
$args{mm3_per_mm} // $self->mm3_per_mm,
|
2014-04-29 21:15:36 +00:00
|
|
|
$args{width} // $self->width,
|
|
|
|
$args{height} // $self->height,
|
2013-07-15 10:14:22 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-08-30 22:37:17 +00:00
|
|
|
package Slic3r::ExtrusionPath::Ref;
|
|
|
|
our @ISA = 'Slic3r::ExtrusionPath';
|
|
|
|
|
|
|
|
sub DESTROY {}
|
|
|
|
|
2014-01-05 12:16:13 +00:00
|
|
|
package Slic3r::Flow;
|
|
|
|
|
|
|
|
sub new {
|
|
|
|
my ($class, %args) = @_;
|
|
|
|
|
|
|
|
my $self = $class->_new(
|
|
|
|
@args{qw(width spacing nozzle_diameter)},
|
|
|
|
);
|
|
|
|
$self->set_bridge($args{bridge} // 0);
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub new_from_width {
|
|
|
|
my ($class, %args) = @_;
|
|
|
|
|
|
|
|
return $class->_new_from_width(
|
|
|
|
@args{qw(role width nozzle_diameter layer_height bridge_flow_ratio)},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub new_from_spacing {
|
|
|
|
my ($class, %args) = @_;
|
|
|
|
|
|
|
|
return $class->_new_from_spacing(
|
|
|
|
@args{qw(spacing nozzle_diameter layer_height bridge)},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
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-09-06 16:36:38 +00:00
|
|
|
package Slic3r::Surface::Ref;
|
|
|
|
our @ISA = 'Slic3r::Surface';
|
|
|
|
|
|
|
|
sub DESTROY {}
|
|
|
|
|
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
|
|
|
|
2013-06-22 15:16:45 +00:00
|
|
|
1;
|