2013-06-22 15:16:45 +00:00
|
|
|
package Slic3r::XS;
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
our $VERSION = '0.01';
|
|
|
|
|
|
|
|
use XSLoader;
|
|
|
|
XSLoader::load(__PACKAGE__, $VERSION);
|
|
|
|
|
2013-07-15 18:31:43 +00:00
|
|
|
package Slic3r::Point;
|
2013-07-06 13:26:32 +00:00
|
|
|
use overload
|
2013-07-07 10:41:54 +00:00
|
|
|
'@{}' => sub { $_[0]->arrayref };
|
2013-06-22 15:16:45 +00:00
|
|
|
|
2013-07-15 20:57:22 +00:00
|
|
|
package Slic3r::ExPolygon;
|
2013-07-06 14:33:49 +00:00
|
|
|
use overload
|
2013-07-07 10:41:54 +00:00
|
|
|
'@{}' => sub { $_[0]->arrayref };
|
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
|
|
|
|
'@{}' => sub { $_[0]->arrayref };
|
|
|
|
|
2013-07-13 22:38:01 +00:00
|
|
|
package Slic3r::ExPolygon::Collection;
|
|
|
|
use overload
|
|
|
|
'@{}' => sub { $_[0]->arrayref };
|
|
|
|
|
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
|
|
|
|
$args{height} // -1,
|
|
|
|
$args{flow_spacing} // -1,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub clone {
|
|
|
|
my ($self, %args) = @_;
|
|
|
|
|
|
|
|
return (ref $self)->_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,
|
|
|
|
$args{height} // $self->height,
|
|
|
|
$args{flow_spacing} // $self->flow_spacing,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
$args{height} // -1,
|
|
|
|
$args{flow_spacing} // -1,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub clone {
|
|
|
|
my ($self, %args) = @_;
|
|
|
|
|
|
|
|
return (ref $self)->_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,
|
|
|
|
$args{height} // $self->height,
|
|
|
|
$args{flow_spacing} // $self->flow_spacing,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
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(
|
|
|
|
delete $args{expolygon} // $self->expolygon->clone,
|
|
|
|
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
|
|
|
|
'@{}' => sub { $_[0]->arrayref };
|
|
|
|
|
2013-06-22 15:16:45 +00:00
|
|
|
1;
|