Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Slic3r/Model.pm10
-rw-r--r--t/multi.t52
-rw-r--r--xs/src/PrintConfig.hpp2
3 files changed, 55 insertions, 9 deletions
diff --git a/lib/Slic3r/Model.pm b/lib/Slic3r/Model.pm
index d4faaf508..a39fd165d 100644
--- a/lib/Slic3r/Model.pm
+++ b/lib/Slic3r/Model.pm
@@ -82,6 +82,11 @@ sub set_material {
);
}
+sub get_material {
+ my ($self, $material_id) = @_;
+ return $self->materials->{$material_id};
+}
+
sub duplicate_objects_grid {
my ($self, $grid, $distance) = @_;
@@ -356,6 +361,11 @@ sub add_volume {
);
}
+ if (defined $new_volume->material_id && !defined $self->model->get_material($new_volume->material_id)) {
+ # TODO: this should be a trigger on Volume::material_id
+ $self->model->set_material($new_volume->material_id);
+ }
+
push @{$self->volumes}, $new_volume;
# invalidate cached bounding box
diff --git a/t/multi.t b/t/multi.t
index cc87083d1..b15c261e5 100644
--- a/t/multi.t
+++ b/t/multi.t
@@ -1,4 +1,4 @@
-use Test::More tests => 8;
+use Test::More tests => 12;
use strict;
use warnings;
@@ -86,13 +86,9 @@ use Slic3r::Test;
}
{
- my $model = Slic3r::Model->new;
- my $object = $model->add_object;
- my $lower_config = $model->set_material('lower')->config;
- my $upper_config = $model->set_material('upper')->config;
- $object->add_volume(mesh => Slic3r::Test::mesh('20mm_cube'), material_id => 'lower');
- $object->add_volume(mesh => Slic3r::Test::mesh('20mm_cube', translate => [0,0,20]), material_id => 'upper');
- $object->add_instance(offset => [0,0]);
+ my $model = stacked_cubes();
+ my $lower_config = $model->get_material('lower')->config;
+ my $upper_config = $model->get_material('upper')->config;
$lower_config->set('extruder', 1);
$lower_config->set('bottom_solid_layers', 0);
@@ -142,4 +138,44 @@ use Slic3r::Test;
}
}
+{
+ my $model = stacked_cubes();
+
+ my $config = Slic3r::Config->new_from_defaults;
+ $config->set('skirts', 0);
+ my $print = Slic3r::Test::init_print($model, config => $config);
+
+ is $model->get_material('lower')->config->extruder, 1, 'auto_assign_extruders() assigned correct extruder to first volume';
+ is $model->get_material('upper')->config->extruder, 2, 'auto_assign_extruders() assigned correct extruder to second volume';
+
+ my $tool = undef;
+ my %T0 = my %T1 = (); # Z => 1
+ Slic3r::GCode::Reader->new->parse(my $gcode = Slic3r::Test::gcode($print), sub {
+ my ($self, $cmd, $args, $info) = @_;
+
+ if ($cmd =~ /^T(\d+)/) {
+ $tool = $1;
+ } elsif ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) {
+ if ($tool == 0) {
+ $T0{$self->Z} = 1;
+ } elsif ($tool == 1) {
+ $T1{$self->Z} = 1;
+ }
+ }
+ });
+
+ ok !(defined first { $_ > 20 } keys %T0), 'T0 is never used for upper object';
+ ok !(defined first { $_ < 20 } keys %T1), 'T1 is never used for lower object';
+}
+
+sub stacked_cubes {
+ my $model = Slic3r::Model->new;
+ my $object = $model->add_object;
+ $object->add_volume(mesh => Slic3r::Test::mesh('20mm_cube'), material_id => 'lower');
+ $object->add_volume(mesh => Slic3r::Test::mesh('20mm_cube', translate => [0,0,20]), material_id => 'upper');
+ $object->add_instance(offset => [0,0]);
+
+ return $model;
+}
+
__END__
diff --git a/xs/src/PrintConfig.hpp b/xs/src/PrintConfig.hpp
index 245cd017d..028849b02 100644
--- a/xs/src/PrintConfig.hpp
+++ b/xs/src/PrintConfig.hpp
@@ -944,7 +944,7 @@ class DynamicPrintConfig : public DynamicConfig
if (!this->has("infill_extruder"))
this->option("infill_extruder", true)->setInt(extruder);
if (!this->has("perimeter_extruder"))
- this->option("infill_extruder", true)->setInt(extruder);
+ this->option("perimeter_extruder", true)->setInt(extruder);
if (!this->has("support_material_extruder"))
this->option("support_material_extruder", true)->setInt(extruder);
if (!this->has("support_material_interface_extruder"))