2011-09-26 09:42:08 +00:00
|
|
|
package Slic3r::Extruder;
|
|
|
|
use Moo;
|
|
|
|
|
2013-03-17 01:22:50 +00:00
|
|
|
use Slic3r::Geometry qw(PI scale);
|
2011-12-07 18:33:59 +00:00
|
|
|
|
2012-08-07 18:50:54 +00:00
|
|
|
use constant OPTIONS => [qw(
|
2012-08-07 19:39:45 +00:00
|
|
|
extruder_offset
|
2012-08-07 18:50:54 +00:00
|
|
|
nozzle_diameter filament_diameter extrusion_multiplier temperature first_layer_temperature
|
2012-08-07 19:08:56 +00:00
|
|
|
retract_length retract_lift retract_speed retract_restart_extra retract_before_travel
|
2013-03-17 01:22:50 +00:00
|
|
|
retract_layer_change retract_length_toolchange retract_restart_extra_toolchange wipe
|
2012-08-07 18:50:54 +00:00
|
|
|
)];
|
2012-09-23 00:40:25 +00:00
|
|
|
|
|
|
|
has 'id' => (is => 'rw', required => 1);
|
|
|
|
has $_ => (is => 'ro', required => 1) for @{&OPTIONS};
|
2011-09-26 09:42:08 +00:00
|
|
|
|
2013-02-27 09:43:50 +00:00
|
|
|
has 'bridge_flow' => (is => 'lazy');
|
2013-06-03 13:27:58 +00:00
|
|
|
has 'e' => (is => 'rw', default => sub {0} );
|
2012-08-22 16:57:03 +00:00
|
|
|
has 'retracted' => (is => 'rw', default => sub {0} );
|
2012-12-21 14:14:44 +00:00
|
|
|
has 'restart_extra' => (is => 'rw', default => sub {0} );
|
2012-07-03 16:05:31 +00:00
|
|
|
has 'e_per_mm3' => (is => 'lazy');
|
2012-08-07 19:08:56 +00:00
|
|
|
has 'retract_speed_mm_min' => (is => 'lazy');
|
2013-03-17 01:22:50 +00:00
|
|
|
has 'scaled_wipe_distance' => (is => 'lazy'); # scaled mm
|
2012-07-03 16:05:31 +00:00
|
|
|
has '_mm3_per_mm_cache' => (is => 'ro', default => sub {{}});
|
2011-09-26 09:42:08 +00:00
|
|
|
|
2013-02-27 09:43:50 +00:00
|
|
|
sub _build_bridge_flow {
|
|
|
|
my $self = shift;
|
|
|
|
return Slic3r::Flow::Bridge->new(nozzle_diameter => $self->nozzle_diameter);
|
|
|
|
}
|
|
|
|
|
2012-07-03 16:05:31 +00:00
|
|
|
sub _build_e_per_mm3 {
|
2012-05-20 18:07:39 +00:00
|
|
|
my $self = shift;
|
2012-07-03 16:05:31 +00:00
|
|
|
return $self->extrusion_multiplier * (4 / (($self->filament_diameter ** 2) * PI));
|
2012-05-20 18:07:39 +00:00
|
|
|
}
|
|
|
|
|
2012-08-07 19:08:56 +00:00
|
|
|
sub _build_retract_speed_mm_min {
|
|
|
|
my $self = shift;
|
|
|
|
return $self->retract_speed * 60;
|
|
|
|
}
|
|
|
|
|
2013-03-17 01:22:50 +00:00
|
|
|
sub _build_scaled_wipe_distance {
|
|
|
|
my $self = shift;
|
2013-06-03 20:49:47 +00:00
|
|
|
# reduce feedrate a bit; travel speed is often too high to move on existing material
|
|
|
|
# too fast = ripping of existing material; too slow = short wipe path, thus more blob
|
|
|
|
return scale($self->retract_length / $self->retract_speed * $Slic3r::Config->travel_speed * 0.8);
|
2013-03-17 01:22:50 +00:00
|
|
|
}
|
|
|
|
|
2012-06-28 12:44:54 +00:00
|
|
|
sub make_flow {
|
2012-05-20 18:07:39 +00:00
|
|
|
my $self = shift;
|
2012-06-28 12:44:54 +00:00
|
|
|
return Slic3r::Flow->new(nozzle_diameter => $self->nozzle_diameter, @_);
|
2012-05-20 18:07:39 +00:00
|
|
|
}
|
|
|
|
|
2012-07-03 16:05:31 +00:00
|
|
|
sub mm3_per_mm {
|
|
|
|
my $self = shift;
|
|
|
|
my ($s, $h) = @_;
|
|
|
|
|
|
|
|
my $cache_key = "${s}_${h}";
|
|
|
|
if (!exists $self->_mm3_per_mm_cache->{$cache_key}) {
|
|
|
|
my $w_threshold = $h + $self->nozzle_diameter;
|
2012-07-27 19:13:03 +00:00
|
|
|
my $s_threshold = $w_threshold - &Slic3r::OVERLAP_FACTOR * ($w_threshold - ($w_threshold - $h * (1 - PI/4)));
|
2012-07-03 16:05:31 +00:00
|
|
|
|
|
|
|
if ($s >= $s_threshold) {
|
|
|
|
# rectangle with semicircles at the ends
|
2012-07-27 19:13:03 +00:00
|
|
|
my $w = $s + &Slic3r::OVERLAP_FACTOR * $h * (1 - PI/4);
|
2012-07-03 16:05:31 +00:00
|
|
|
$self->_mm3_per_mm_cache->{$cache_key} = $w * $h + ($h**2) / 4 * (PI - 4);
|
|
|
|
} else {
|
|
|
|
# rectangle with shrunk semicircles at the ends
|
2012-07-27 19:13:03 +00:00
|
|
|
my $w = ($s + $self->nozzle_diameter * &Slic3r::OVERLAP_FACTOR * (PI/4 - 1)) / (1 + &Slic3r::OVERLAP_FACTOR * (PI/4 - 1));
|
2012-07-03 16:05:31 +00:00
|
|
|
$self->_mm3_per_mm_cache->{$cache_key} = $self->nozzle_diameter * $h * (1 - PI/4) + $h * $w * PI/4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $self->_mm3_per_mm_cache->{$cache_key};
|
|
|
|
}
|
|
|
|
|
2012-10-29 10:17:57 +00:00
|
|
|
sub e_per_mm {
|
|
|
|
my $self = shift;
|
|
|
|
my ($s, $h) = @_;
|
|
|
|
return $self->mm3_per_mm($s, $h) * $self->e_per_mm3;
|
|
|
|
}
|
|
|
|
|
2011-09-26 09:42:08 +00:00
|
|
|
1;
|