123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- package Slic3r::XS;
- use warnings;
- use strict;
- our $VERSION = '0.01';
- # We have to load these modules in order to have Wx.pm find the correct paths
- # for wxWidgets dlls on MSW.
- # We avoid loading these on OS X because Wx::Load() initializes a Wx App
- # automatically and it steals focus even when we're not running Slic3r in GUI mode.
- # TODO: only load these when compiling with GUI support
- BEGIN {
- if ($^O eq 'MSWin32') {
- eval "use Wx";
- eval "use Wx::GLCanvas";
- eval "use Wx::GLContext";
- eval "use Wx::Html";
- eval "use Wx::Print"; # because of some Wx bug, thread creation fails if we don't have this (looks like Wx::Printout is hard-coded in some thread cleanup code)
- }
- }
- use Carp qw();
- use XSLoader;
- XSLoader::load(__PACKAGE__, $VERSION);
- package Slic3r::Line;
- use overload
- '@{}' => sub { $_[0]->arrayref },
- 'fallback' => 1;
- package Slic3r::Point;
- use overload
- '@{}' => sub { $_[0]->arrayref },
- 'fallback' => 1;
- package Slic3r::Pointf;
- use overload
- '@{}' => sub { $_[0]->arrayref },
- 'fallback' => 1;
- package Slic3r::Pointf3;
- use overload
- '@{}' => sub { [ $_[0]->x, $_[0]->y, $_[0]->z ] }, #,
- 'fallback' => 1;
- sub pp {
- my ($self) = @_;
- return [ @$self ];
- }
- package Slic3r::ExPolygon;
- use overload
- '@{}' => sub { $_[0]->arrayref },
- 'fallback' => 1;
- package Slic3r::Polyline;
- use overload
- '@{}' => sub { $_[0]->arrayref },
- 'fallback' => 1;
- package Slic3r::Polyline::Collection;
- use overload
- '@{}' => sub { $_[0]->arrayref },
- 'fallback' => 1;
- package Slic3r::Polygon;
- use overload
- '@{}' => sub { $_[0]->arrayref },
- 'fallback' => 1;
- package Slic3r::ExPolygon::Collection;
- 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::ExtrusionMultiPath;
- use overload
- '@{}' => sub { $_[0]->arrayref },
- 'fallback' => 1;
- 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::ExtrusionSimulator;
- sub new {
- my ($class, %args) = @_;
- return $class->_new();
- }
- package Slic3r::Filler;
- sub fill_surface {
- my ($self, $surface, %args) = @_;
- $self->set_density($args{density}) if defined($args{density});
- $self->set_dont_adjust($args{dont_adjust}) if defined($args{dont_adjust});
- $self->set_complete($args{complete}) if defined($args{complete});
- return $self->_fill_surface($surface);
- }
- package Slic3r::Flow;
- sub new {
- my ($class, %args) = @_;
-
- my $self = $class->_new(
- @args{qw(width height nozzle_diameter)},
- );
- return $self;
- }
- sub new_from_width {
- my ($class, %args) = @_;
-
- return $class->_new_from_width(
- @args{qw(role width nozzle_diameter layer_height)},
- );
- }
- 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(
- $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,
- );
- }
- sub clone {
- my ($self, %args) = @_;
-
- return (ref $self)->_new(
- delete $args{expolygon} // $self->expolygon,
- 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,
- );
- }
- package Slic3r::Surface::Collection;
- use overload
- '@{}' => sub { $_[0]->arrayref },
- 'fallback' => 1;
- sub new {
- my ($class, @surfaces) = @_;
-
- my $self = $class->_new;
- $self->append($_) for @surfaces;
- return $self;
- }
- package Slic3r::Print::SupportMaterial2;
- sub new {
- my ($class, %args) = @_;
-
- return $class->_new(
- $args{print_config}, # required
- $args{object_config}, # required
- $args{first_layer_flow}, # required
- $args{flow}, # required
- $args{interface_flow}, # required
- $args{soluble_interface} // 0
- );
- }
- package Slic3r::GUI::_3DScene::GLVolume::Collection;
- use overload
- '@{}' => sub { $_[0]->arrayref },
- 'fallback' => 1;
- package Slic3r::GUI::PresetCollection;
- use overload
- '@{}' => sub { $_[0]->arrayref },
- 'fallback' => 1;
- package main;
- for my $class (qw(
- Slic3r::BridgeDetector
- Slic3r::Config
- Slic3r::Config::Full
- Slic3r::Config::GCode
- Slic3r::Config::Print
- Slic3r::Config::PrintObject
- Slic3r::Config::PrintRegion
- Slic3r::Config::Static
- Slic3r::ExPolygon
- Slic3r::ExPolygon::Collection
- Slic3r::ExtrusionLoop
- Slic3r::ExtrusionMultiPath
- Slic3r::ExtrusionPath
- Slic3r::ExtrusionPath::Collection
- Slic3r::ExtrusionSimulator
- Slic3r::Filler
- Slic3r::Flow
- Slic3r::GCode
- Slic3r::GCode::PlaceholderParser
- Slic3r::Geometry::BoundingBox
- Slic3r::Geometry::BoundingBoxf
- Slic3r::Geometry::BoundingBoxf3
- Slic3r::GUI::_3DScene::GLShader
- Slic3r::GUI::_3DScene::GLVolume
- Slic3r::GUI::Preset
- Slic3r::GUI::PresetCollection
- Slic3r::GUI::Tab
- Slic3r::Layer
- Slic3r::Layer::Region
- Slic3r::Layer::Support
- Slic3r::Line
- Slic3r::Linef3
- Slic3r::Model
- Slic3r::Model::Instance
- Slic3r::Model::Material
- Slic3r::Model::Object
- Slic3r::Model::Volume
- Slic3r::Point
- Slic3r::Point3
- Slic3r::Pointf
- Slic3r::Pointf3
- Slic3r::Polygon
- Slic3r::Polyline
- Slic3r::Polyline::Collection
- Slic3r::Print
- Slic3r::Print::Object
- Slic3r::Print::Region
- Slic3r::Print::State
- Slic3r::Surface
- Slic3r::Surface::Collection
- Slic3r::Print::SupportMaterial2
- Slic3r::TriangleMesh
- ))
- {
- no strict 'refs';
- my $ref_class = $class . "::Ref";
- eval "package $ref_class; our \@ISA = '$class'; sub DESTROY {};";
- }
- 1;
|