mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-16 03:16:10 +08:00
Some minor changes to the newly-ported Extruder class
This commit is contained in:
parent
4c330b6c59
commit
24571612c7
@ -149,6 +149,7 @@ sub thread_cleanup {
|
|||||||
*Slic3r::Geometry::BoundingBoxf3::DESTROY = sub {};
|
*Slic3r::Geometry::BoundingBoxf3::DESTROY = sub {};
|
||||||
*Slic3r::Line::DESTROY = sub {};
|
*Slic3r::Line::DESTROY = sub {};
|
||||||
*Slic3r::Point::DESTROY = sub {};
|
*Slic3r::Point::DESTROY = sub {};
|
||||||
|
*Slic3r::Pointf::DESTROY = sub {};
|
||||||
*Slic3r::Pointf3::DESTROY = sub {};
|
*Slic3r::Pointf3::DESTROY = sub {};
|
||||||
*Slic3r::Polygon::DESTROY = sub {};
|
*Slic3r::Polygon::DESTROY = sub {};
|
||||||
*Slic3r::Polyline::DESTROY = sub {};
|
*Slic3r::Polyline::DESTROY = sub {};
|
||||||
|
@ -343,8 +343,8 @@ sub extrude_path {
|
|||||||
my $path_length = unscale $path->length;
|
my $path_length = unscale $path->length;
|
||||||
{
|
{
|
||||||
$gcode .= $path->gcode($self->extruder, $e, $F,
|
$gcode .= $path->gcode($self->extruder, $e, $F,
|
||||||
$self->shift_x - $self->extruder->extruder_offset->[X],
|
$self->shift_x - $self->extruder->extruder_offset->x,
|
||||||
$self->shift_y - $self->extruder->extruder_offset->[Y],
|
$self->shift_y - $self->extruder->extruder_offset->y, #,,
|
||||||
$self->_extrusion_axis,
|
$self->_extrusion_axis,
|
||||||
$self->print_config->gcode_comments ? " ; $description" : "");
|
$self->print_config->gcode_comments ? " ; $description" : "");
|
||||||
|
|
||||||
@ -587,8 +587,8 @@ sub _G0_G1 {
|
|||||||
|
|
||||||
if ($point) {
|
if ($point) {
|
||||||
$gcode .= sprintf " X%.3f Y%.3f",
|
$gcode .= sprintf " X%.3f Y%.3f",
|
||||||
($point->x * &Slic3r::SCALING_FACTOR) + $self->shift_x - $self->extruder->extruder_offset->[X],
|
($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->y * &Slic3r::SCALING_FACTOR) + $self->shift_y - $self->extruder->extruder_offset->y; #**
|
||||||
$self->last_pos($point->clone);
|
$self->last_pos($point->clone);
|
||||||
}
|
}
|
||||||
if (defined $z && (!defined $self->z || $z != $self->z)) {
|
if (defined $z && (!defined $self->z || $z != $self->z)) {
|
||||||
|
@ -33,6 +33,11 @@ use overload
|
|||||||
'@{}' => sub { [ $_[0]->x, $_[0]->y ] }, #,
|
'@{}' => sub { [ $_[0]->x, $_[0]->y ] }, #,
|
||||||
'fallback' => 1;
|
'fallback' => 1;
|
||||||
|
|
||||||
|
package Slic3r::Pointf::Ref;
|
||||||
|
our @ISA = 'Slic3r::Pointf';
|
||||||
|
|
||||||
|
sub DESTROY {}
|
||||||
|
|
||||||
package Slic3r::Pointf3;
|
package Slic3r::Pointf3;
|
||||||
use overload
|
use overload
|
||||||
'@{}' => sub { [ $_[0]->x, $_[0]->y, $_[0]->z ] }, #,
|
'@{}' => sub { [ $_[0]->x, $_[0]->y, $_[0]->z ] }, #,
|
||||||
@ -226,9 +231,4 @@ use overload
|
|||||||
'@{}' => sub { $_[0]->arrayref },
|
'@{}' => sub { $_[0]->arrayref },
|
||||||
'fallback' => 1;
|
'fallback' => 1;
|
||||||
|
|
||||||
package Slic3r::Config::Print::Ref;
|
|
||||||
our @ISA = 'Slic3r::Config::Print';
|
|
||||||
|
|
||||||
sub DESTROY {}
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -24,7 +24,7 @@ Extruder::reset()
|
|||||||
double
|
double
|
||||||
Extruder::extrude(double dE)
|
Extruder::extrude(double dE)
|
||||||
{
|
{
|
||||||
if (this->use_relative_e_distances()) {
|
if (this->config->use_relative_e_distances) {
|
||||||
this->E = 0;
|
this->E = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,116 +33,94 @@ Extruder::extrude(double dE)
|
|||||||
return this->E;
|
return this->E;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Val, class OptType> 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<const ConfigBase*>(this->config)
|
|
||||||
->option(name);
|
|
||||||
return dynamic_cast<const OptType *>(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<const ConfigBase*>(this->config)
|
|
||||||
->option("use_relative_e_distances");
|
|
||||||
return *static_cast<const ConfigOptionBool*>(opt);
|
|
||||||
}
|
|
||||||
|
|
||||||
Pointf
|
Pointf
|
||||||
Extruder::extruder_offset() const
|
Extruder::extruder_offset() const
|
||||||
{
|
{
|
||||||
return get_config<Pointf, ConfigOptionPoints>("extruder_offset");
|
return this->config->extruder_offset.get_at(this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
Extruder::nozzle_diameter() const
|
Extruder::nozzle_diameter() const
|
||||||
{
|
{
|
||||||
return get_config<double, ConfigOptionFloats>("nozzle_diameter");
|
return this->config->nozzle_diameter.get_at(this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
Extruder::filament_diameter() const
|
Extruder::filament_diameter() const
|
||||||
{
|
{
|
||||||
return get_config<double, ConfigOptionFloats>("filament_diameter");
|
return this->config->filament_diameter.get_at(this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
Extruder::extrusion_multiplier() const
|
Extruder::extrusion_multiplier() const
|
||||||
{
|
{
|
||||||
return get_config<double, ConfigOptionFloats>("extrusion_multiplier");
|
return this->config->extrusion_multiplier.get_at(this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Extruder::temperature() const
|
Extruder::temperature() const
|
||||||
{
|
{
|
||||||
return get_config<int, ConfigOptionInts>("temperature");
|
return this->config->temperature.get_at(this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Extruder::first_layer_temperature() const
|
Extruder::first_layer_temperature() const
|
||||||
{
|
{
|
||||||
return get_config<int, ConfigOptionInts>("first_layer_temperature");
|
return this->config->first_layer_temperature.get_at(this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
Extruder::retract_length() const
|
Extruder::retract_length() const
|
||||||
{
|
{
|
||||||
return get_config<double, ConfigOptionFloats>("retract_length");
|
return this->config->retract_length.get_at(this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
Extruder::retract_lift() const
|
Extruder::retract_lift() const
|
||||||
{
|
{
|
||||||
return get_config<double, ConfigOptionFloats>("retract_lift");
|
return this->config->retract_lift.get_at(this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Extruder::retract_speed() const
|
Extruder::retract_speed() const
|
||||||
{
|
{
|
||||||
return get_config<int, ConfigOptionInts>("retract_speed");
|
return this->config->retract_speed.get_at(this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
Extruder::retract_restart_extra() const
|
Extruder::retract_restart_extra() const
|
||||||
{
|
{
|
||||||
return get_config<double, ConfigOptionFloats>("retract_restart_extra");
|
return this->config->retract_restart_extra.get_at(this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
Extruder::retract_before_travel() const
|
Extruder::retract_before_travel() const
|
||||||
{
|
{
|
||||||
return get_config<double, ConfigOptionFloats>("retract_before_travel");
|
return this->config->retract_before_travel.get_at(this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Extruder::retract_layer_change() const
|
Extruder::retract_layer_change() const
|
||||||
{
|
{
|
||||||
return get_config<bool, ConfigOptionBools>("retract_layer_change");
|
return this->config->retract_layer_change.get_at(this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
Extruder::retract_length_toolchange() const
|
Extruder::retract_length_toolchange() const
|
||||||
{
|
{
|
||||||
return get_config<double, ConfigOptionFloats>("retract_length_toolchange");
|
return this->config->retract_length_toolchange.get_at(this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
Extruder::retract_restart_extra_toolchange() const
|
Extruder::retract_restart_extra_toolchange() const
|
||||||
{
|
{
|
||||||
return get_config<double, ConfigOptionFloats>(
|
return this->config->retract_restart_extra_toolchange.get_at(this->id);
|
||||||
"retract_restart_extra_toolchange");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Extruder::wipe() const
|
Extruder::wipe() const
|
||||||
{
|
{
|
||||||
return get_config<bool, ConfigOptionBools>("wipe");
|
return this->config->wipe.get_at(this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,9 +14,8 @@ class Extruder
|
|||||||
virtual ~Extruder() {}
|
virtual ~Extruder() {}
|
||||||
void reset();
|
void reset();
|
||||||
double extrude(double dE);
|
double extrude(double dE);
|
||||||
|
|
||||||
|
|
||||||
bool use_relative_e_distances() const;
|
|
||||||
Pointf extruder_offset() const;
|
Pointf extruder_offset() const;
|
||||||
double nozzle_diameter() const;
|
double nozzle_diameter() const;
|
||||||
double filament_diameter() const;
|
double filament_diameter() const;
|
||||||
@ -32,21 +31,14 @@ class Extruder
|
|||||||
double retract_length_toolchange() const;
|
double retract_length_toolchange() const;
|
||||||
double retract_restart_extra_toolchange() const;
|
double retract_restart_extra_toolchange() const;
|
||||||
bool wipe() const;
|
bool wipe() const;
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
double E;
|
double E;
|
||||||
double absolute_E;
|
double absolute_E;
|
||||||
double retracted;
|
double retracted;
|
||||||
double restart_extra;
|
double restart_extra;
|
||||||
|
|
||||||
PrintConfig *config;
|
PrintConfig *config;
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
// get value from a ConfigOptionVector subtype, indexed by extruder id
|
|
||||||
template <typename Val, class OptType>
|
|
||||||
Val get_config(const char *name) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,15 +7,13 @@
|
|||||||
|
|
||||||
%name{Slic3r::Extruder} class Extruder {
|
%name{Slic3r::Extruder} class Extruder {
|
||||||
Extruder(int id, PrintConfig *config);
|
Extruder(int id, PrintConfig *config);
|
||||||
|
|
||||||
~Extruder();
|
~Extruder();
|
||||||
void reset();
|
void reset();
|
||||||
double extrude(double dE);
|
double extrude(double dE);
|
||||||
|
|
||||||
int id() const
|
int id() const
|
||||||
%code%{ RETVAL = THIS->id; %};
|
%code%{ RETVAL = THIS->id; %};
|
||||||
|
|
||||||
|
|
||||||
double E() const
|
double E() const
|
||||||
%code%{ RETVAL = THIS->E; %};
|
%code%{ RETVAL = THIS->E; %};
|
||||||
double set_E(double val) const
|
double set_E(double val) const
|
||||||
@ -32,7 +30,7 @@
|
|||||||
%code%{ RETVAL = THIS->restart_extra; %};
|
%code%{ RETVAL = THIS->restart_extra; %};
|
||||||
double set_restart_extra(double val) const
|
double set_restart_extra(double val) const
|
||||||
%code%{ RETVAL = THIS->restart_extra = val; %};
|
%code%{ RETVAL = THIS->restart_extra = val; %};
|
||||||
|
|
||||||
Clone<Pointf> extruder_offset() const;
|
Clone<Pointf> extruder_offset() const;
|
||||||
double nozzle_diameter() const;
|
double nozzle_diameter() const;
|
||||||
double filament_diameter() const;
|
double filament_diameter() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user