mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 22:54:08 -06:00
Initial refactoring for supporting multiple extruders. Little speed optimization included
This commit is contained in:
parent
92460ba902
commit
898266fd34
10 changed files with 567 additions and 504 deletions
|
@ -3,48 +3,47 @@ use Moo;
|
|||
|
||||
use Slic3r::Geometry qw(PI);
|
||||
|
||||
has 'width' => (is => 'rw');
|
||||
has 'min_spacing' => (is => 'rw');
|
||||
has 'spacing' => (is => 'rw');
|
||||
has 'layer_height' => (is => 'lazy', builder => 1);
|
||||
has 'nozzle_diameter' => (is => 'rw', required => 1);
|
||||
has 'layer_height' => (is => 'rw', default => sub { $Slic3r::layer_height });
|
||||
|
||||
sub _build_layer_height { $Slic3r::layer_height }
|
||||
has 'width' => (is => 'rw');
|
||||
has 'min_spacing' => (is => 'rw');
|
||||
has 'spacing' => (is => 'rw');
|
||||
|
||||
sub calculate {
|
||||
sub BUILD {
|
||||
my $self = shift;
|
||||
my ($extrusion_width) = @_;
|
||||
|
||||
my ($flow_width, $min_flow_spacing, $flow_spacing);
|
||||
if ($extrusion_width) {
|
||||
$flow_width = $extrusion_width =~ /^(\d+(?:\.\d+)?)%$/
|
||||
if ($self->width) {
|
||||
$flow_width = $self->width =~ /^(\d+(?:\.\d+)?)%$/
|
||||
? ($self->layer_height * $1 / 100)
|
||||
: $extrusion_width;
|
||||
: $self->width;
|
||||
} else {
|
||||
# here we calculate a sane default by matching the flow speed (at the nozzle)
|
||||
# and the feed rate
|
||||
my $volume = ($Slic3r::nozzle_diameter**2) * PI/4;
|
||||
my $shape_threshold = $Slic3r::nozzle_diameter * $self->layer_height
|
||||
my $volume = ($self->nozzle_diameter**2) * PI/4;
|
||||
my $shape_threshold = $self->nozzle_diameter * $self->layer_height
|
||||
+ ($self->layer_height**2) * PI/4;
|
||||
if ($volume >= $shape_threshold) {
|
||||
# rectangle with semicircles at the ends
|
||||
$flow_width = (($Slic3r::nozzle_diameter**2) * PI + ($self->layer_height**2) * (4 - PI)) / (4 * $self->layer_height);
|
||||
$flow_width = (($self->nozzle_diameter**2) * PI + ($self->layer_height**2) * (4 - PI)) / (4 * $self->layer_height);
|
||||
} else {
|
||||
# rectangle with squished semicircles at the ends
|
||||
$flow_width = $Slic3r::nozzle_diameter * ($Slic3r::nozzle_diameter/$self->layer_height - 4/PI + 1);
|
||||
$flow_width = $self->nozzle_diameter * ($self->nozzle_diameter/$self->layer_height - 4/PI + 1);
|
||||
}
|
||||
|
||||
my $min_flow_width = $Slic3r::nozzle_diameter * 1.05;
|
||||
my $max_flow_width = $Slic3r::nozzle_diameter * 1.4;
|
||||
my $min_flow_width = $self->nozzle_diameter * 1.05;
|
||||
my $max_flow_width = $self->nozzle_diameter * 1.4;
|
||||
$flow_width = $max_flow_width if $flow_width > $max_flow_width;
|
||||
$flow_width = $min_flow_width if $flow_width < $min_flow_width;
|
||||
}
|
||||
|
||||
if ($flow_width >= ($Slic3r::nozzle_diameter + $self->layer_height)) {
|
||||
if ($flow_width >= ($self->nozzle_diameter + $self->layer_height)) {
|
||||
# rectangle with semicircles at the ends
|
||||
$min_flow_spacing = $flow_width - $self->layer_height * (1 - PI/4);
|
||||
} else {
|
||||
# rectangle with shrunk semicircles at the ends
|
||||
$min_flow_spacing = $flow_width * (1 - PI/4) + $Slic3r::nozzle_diameter * PI/4;
|
||||
$min_flow_spacing = $flow_width * (1 - PI/4) + $self->nozzle_diameter * PI/4;
|
||||
}
|
||||
$flow_spacing = $flow_width - $Slic3r::overlap_factor * ($flow_width - $min_flow_spacing);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue