diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 999e450bb..1579d85db 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -149,6 +149,7 @@ sub thread_cleanup { *Slic3r::Geometry::BoundingBoxf3::DESTROY = sub {}; *Slic3r::Line::DESTROY = sub {}; *Slic3r::Point::DESTROY = sub {}; + *Slic3r::Pointf::DESTROY = sub {}; *Slic3r::Pointf3::DESTROY = sub {}; *Slic3r::Polygon::DESTROY = sub {}; *Slic3r::Polyline::DESTROY = sub {}; diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 37eed4797..8adfd2126 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -343,8 +343,8 @@ sub extrude_path { my $path_length = unscale $path->length; { $gcode .= $path->gcode($self->extruder, $e, $F, - $self->shift_x - $self->extruder->extruder_offset->[X], - $self->shift_y - $self->extruder->extruder_offset->[Y], + $self->shift_x - $self->extruder->extruder_offset->x, + $self->shift_y - $self->extruder->extruder_offset->y, #,, $self->_extrusion_axis, $self->print_config->gcode_comments ? " ; $description" : ""); @@ -587,8 +587,8 @@ sub _G0_G1 { if ($point) { $gcode .= sprintf " X%.3f Y%.3f", - ($point->x * &Slic3r::SCALING_FACTOR) + $self->shift_x - $self->extruder->extruder_offset->[X], - ($point->y * &Slic3r::SCALING_FACTOR) + $self->shift_y - $self->extruder->extruder_offset->[Y]; #** + ($point->x * &Slic3r::SCALING_FACTOR) + $self->shift_x - $self->extruder->extruder_offset->x, + ($point->y * &Slic3r::SCALING_FACTOR) + $self->shift_y - $self->extruder->extruder_offset->y; #** $self->last_pos($point->clone); } if (defined $z && (!defined $self->z || $z != $self->z)) { diff --git a/xs/lib/Slic3r/XS.pm b/xs/lib/Slic3r/XS.pm index d30f84299..42821b816 100644 --- a/xs/lib/Slic3r/XS.pm +++ b/xs/lib/Slic3r/XS.pm @@ -33,6 +33,11 @@ use overload '@{}' => sub { [ $_[0]->x, $_[0]->y ] }, #, 'fallback' => 1; +package Slic3r::Pointf::Ref; +our @ISA = 'Slic3r::Pointf'; + +sub DESTROY {} + package Slic3r::Pointf3; use overload '@{}' => sub { [ $_[0]->x, $_[0]->y, $_[0]->z ] }, #, @@ -226,9 +231,4 @@ use overload '@{}' => sub { $_[0]->arrayref }, 'fallback' => 1; -package Slic3r::Config::Print::Ref; -our @ISA = 'Slic3r::Config::Print'; - -sub DESTROY {} - 1; diff --git a/xs/src/Extruder.cpp b/xs/src/Extruder.cpp index c7a04941f..590855cc3 100644 --- a/xs/src/Extruder.cpp +++ b/xs/src/Extruder.cpp @@ -24,7 +24,7 @@ Extruder::reset() double Extruder::extrude(double dE) { - if (this->use_relative_e_distances()) { + if (this->config->use_relative_e_distances) { this->E = 0; } @@ -33,116 +33,94 @@ Extruder::extrude(double dE) return this->E; } -template Val -Extruder::get_config(const char *name) const -{ - // TODO: figure out way to avoid static_cast to access hidden const method - const ConfigOption *opt = static_cast(this->config) - ->option(name); - return dynamic_cast(opt)->get_at(this->id); -} - -bool -Extruder::use_relative_e_distances() const -{ - // not using get_config because use_relative_e_distances is global - // for all extruders - - // TODO: figure out way to avoid static_cast to access hidden const method - const ConfigOption *opt = static_cast(this->config) - ->option("use_relative_e_distances"); - return *static_cast(opt); -} - Pointf Extruder::extruder_offset() const { - return get_config("extruder_offset"); + return this->config->extruder_offset.get_at(this->id); } double Extruder::nozzle_diameter() const { - return get_config("nozzle_diameter"); + return this->config->nozzle_diameter.get_at(this->id); } double Extruder::filament_diameter() const { - return get_config("filament_diameter"); + return this->config->filament_diameter.get_at(this->id); } double Extruder::extrusion_multiplier() const { - return get_config("extrusion_multiplier"); + return this->config->extrusion_multiplier.get_at(this->id); } int Extruder::temperature() const { - return get_config("temperature"); + return this->config->temperature.get_at(this->id); } int Extruder::first_layer_temperature() const { - return get_config("first_layer_temperature"); + return this->config->first_layer_temperature.get_at(this->id); } double Extruder::retract_length() const { - return get_config("retract_length"); + return this->config->retract_length.get_at(this->id); } double Extruder::retract_lift() const { - return get_config("retract_lift"); + return this->config->retract_lift.get_at(this->id); } int Extruder::retract_speed() const { - return get_config("retract_speed"); + return this->config->retract_speed.get_at(this->id); } double Extruder::retract_restart_extra() const { - return get_config("retract_restart_extra"); + return this->config->retract_restart_extra.get_at(this->id); } double Extruder::retract_before_travel() const { - return get_config("retract_before_travel"); + return this->config->retract_before_travel.get_at(this->id); } bool Extruder::retract_layer_change() const { - return get_config("retract_layer_change"); + return this->config->retract_layer_change.get_at(this->id); } double Extruder::retract_length_toolchange() const { - return get_config("retract_length_toolchange"); + return this->config->retract_length_toolchange.get_at(this->id); } double Extruder::retract_restart_extra_toolchange() const { - return get_config( - "retract_restart_extra_toolchange"); + return this->config->retract_restart_extra_toolchange.get_at(this->id); } bool Extruder::wipe() const { - return get_config("wipe"); + return this->config->wipe.get_at(this->id); } diff --git a/xs/src/Extruder.hpp b/xs/src/Extruder.hpp index 7302e42a3..9caa38c89 100644 --- a/xs/src/Extruder.hpp +++ b/xs/src/Extruder.hpp @@ -14,9 +14,8 @@ class Extruder virtual ~Extruder() {} void reset(); double extrude(double dE); - - - bool use_relative_e_distances() const; + + Pointf extruder_offset() const; double nozzle_diameter() const; double filament_diameter() const; @@ -32,21 +31,14 @@ class Extruder double retract_length_toolchange() const; double retract_restart_extra_toolchange() const; bool wipe() const; - + int id; double E; double absolute_E; double retracted; double restart_extra; - + PrintConfig *config; - - - private: - - // get value from a ConfigOptionVector subtype, indexed by extruder id - template - Val get_config(const char *name) const; }; } diff --git a/xs/xsp/Extruder.xsp b/xs/xsp/Extruder.xsp index 47b5c0fa2..d80b34d62 100644 --- a/xs/xsp/Extruder.xsp +++ b/xs/xsp/Extruder.xsp @@ -7,15 +7,13 @@ %name{Slic3r::Extruder} class Extruder { Extruder(int id, PrintConfig *config); - ~Extruder(); void reset(); double extrude(double dE); - + int id() const %code%{ RETVAL = THIS->id; %}; - - + double E() const %code%{ RETVAL = THIS->E; %}; double set_E(double val) const @@ -32,7 +30,7 @@ %code%{ RETVAL = THIS->restart_extra; %}; double set_restart_extra(double val) const %code%{ RETVAL = THIS->restart_extra = val; %}; - + Clone extruder_offset() const; double nozzle_diameter() const; double filament_diameter() const;