mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-31 20:51:12 -06:00
Refactoring to Model API for making it stricter and safer
This commit is contained in:
parent
bc023c2d51
commit
7ba08c90cf
17 changed files with 316 additions and 317 deletions
|
|
@ -57,7 +57,7 @@ use Slic3r::Test;
|
|||
$config->set('start_gcode', "TRAVEL:[travel_speed] HEIGHT:[layer_height]\n");
|
||||
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
||||
|
||||
my $output_file = $print->expanded_output_filepath;
|
||||
my $output_file = $print->print->expanded_output_filepath;
|
||||
ok $output_file !~ /\[travel_speed\]/, 'print config options are replaced in output filename';
|
||||
ok $output_file !~ /\[layer_height\]/, 'region config options are replaced in output filename';
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ use Slic3r::Test;
|
|||
|
||||
|
||||
});
|
||||
ok $print->total_used_filament > 0, 'final retraction is not considered in total used filament';
|
||||
ok $print->print->total_used_filament > 0, 'final retraction is not considered in total used filament';
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ sub stacked_cubes {
|
|||
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]);
|
||||
$object->add_instance(offset => Slic3r::Pointf->new(0,0));
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
18
t/print.t
18
t/print.t
|
|
@ -38,21 +38,21 @@ use Slic3r::Test;
|
|||
my $print = Slic3r::Test::init_print(my $model = Slic3r::Test::model('20mm_cube'), config => $config);
|
||||
|
||||
# user sets a per-region option
|
||||
$print->objects->[0]->model_object->config->set('fill_density', 100);
|
||||
$print->reload_object(0);
|
||||
$print->print->objects->[0]->model_object->config->set('fill_density', 100);
|
||||
$print->print->reload_object(0);
|
||||
|
||||
# user exports G-code, thus the default config is reapplied
|
||||
$print->apply_config($config);
|
||||
$print->print->apply_config($config);
|
||||
|
||||
is $print->regions->[0]->config->fill_density, 100, 'apply_config() does not override per-object settings';
|
||||
is $print->print->regions->[0]->config->fill_density, 100, 'apply_config() does not override per-object settings';
|
||||
|
||||
# user assigns object extruders
|
||||
$print->objects->[0]->model_object->config->set('extruder', 3);
|
||||
$print->objects->[0]->model_object->config->set('perimeter_extruder', 2);
|
||||
$print->reload_object(0);
|
||||
$print->print->objects->[0]->model_object->config->set('extruder', 3);
|
||||
$print->print->objects->[0]->model_object->config->set('perimeter_extruder', 2);
|
||||
$print->print->reload_object(0);
|
||||
|
||||
is $print->regions->[0]->config->infill_extruder, 3, 'extruder setting is correctly expanded';
|
||||
is $print->regions->[0]->config->perimeter_extruder, 2, 'extruder setting does not override explicitely specified extruders';
|
||||
is $print->print->regions->[0]->config->infill_extruder, 3, 'extruder setting is correctly expanded';
|
||||
is $print->print->regions->[0]->config->perimeter_extruder, 2, 'extruder setting does not override explicitely specified extruders';
|
||||
}
|
||||
|
||||
__END__
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ use Slic3r::Test qw(_eq);
|
|||
|
||||
if ($info->{dist_Z}) {
|
||||
# lift move or lift + change layer
|
||||
if (_eq($info->{dist_Z}, $print->config->get_at('retract_lift', $tool))
|
||||
|| (_eq($info->{dist_Z}, $conf->layer_height + $print->config->get_at('retract_lift', $tool)) && $print->config->get_at('retract_lift', $tool) > 0)) {
|
||||
if (_eq($info->{dist_Z}, $print->print->config->get_at('retract_lift', $tool))
|
||||
|| (_eq($info->{dist_Z}, $conf->layer_height + $print->print->config->get_at('retract_lift', $tool)) && $print->print->config->get_at('retract_lift', $tool) > 0)) {
|
||||
fail 'only lifting while retracted' if !$retracted[$tool] && !($conf->g0 && $info->{retracting});
|
||||
fail 'double lift' if $lifted;
|
||||
$lifted = 1;
|
||||
|
|
@ -51,8 +51,8 @@ use Slic3r::Test qw(_eq);
|
|||
if ($info->{dist_Z} < 0) {
|
||||
fail 'going down only after lifting' if !$lifted;
|
||||
fail 'going down by the same amount of the lift or by the amount needed to get to next layer'
|
||||
if !_eq($info->{dist_Z}, -$print->config->get_at('retract_lift', $tool))
|
||||
&& !_eq($info->{dist_Z}, -$print->config->get_at('retract_lift', $tool) + $conf->layer_height);
|
||||
if !_eq($info->{dist_Z}, -$print->print->config->get_at('retract_lift', $tool))
|
||||
&& !_eq($info->{dist_Z}, -$print->print->config->get_at('retract_lift', $tool) + $conf->layer_height);
|
||||
$lifted = 0;
|
||||
}
|
||||
fail 'move Z at travel speed' if ($args->{F} // $self->F) != $conf->travel_speed * 60;
|
||||
|
|
@ -60,9 +60,9 @@ use Slic3r::Test qw(_eq);
|
|||
if ($info->{retracting}) {
|
||||
$retracted[$tool] = 1;
|
||||
$retracted_length[$tool] += -$info->{dist_E};
|
||||
if (_eq($retracted_length[$tool], $print->config->get_at('retract_length', $tool))) {
|
||||
if (_eq($retracted_length[$tool], $print->print->config->get_at('retract_length', $tool))) {
|
||||
# okay
|
||||
} elsif (_eq($retracted_length[$tool], $print->config->get_at('retract_length_toolchange', $tool))) {
|
||||
} elsif (_eq($retracted_length[$tool], $print->print->config->get_at('retract_length_toolchange', $tool))) {
|
||||
$wait_for_toolchange = 1;
|
||||
} else {
|
||||
fail 'retracted by the correct amount';
|
||||
|
|
@ -73,9 +73,9 @@ use Slic3r::Test qw(_eq);
|
|||
if ($info->{extruding}) {
|
||||
fail 'only extruding while not lifted' if $lifted;
|
||||
if ($retracted[$tool]) {
|
||||
my $expected_amount = $retracted_length[$tool] + $print->config->get_at('retract_restart_extra', $tool);
|
||||
my $expected_amount = $retracted_length[$tool] + $print->print->config->get_at('retract_restart_extra', $tool);
|
||||
if ($changed_tool && $toolchange_count[$tool] > 1) {
|
||||
$expected_amount = $print->config->get_at('retract_length_toolchange', $tool) + $print->config->get_at('retract_restart_extra_toolchange', $tool);
|
||||
$expected_amount = $print->print->config->get_at('retract_length_toolchange', $tool) + $print->print->config->get_at('retract_restart_extra_toolchange', $tool);
|
||||
$changed_tool = 0;
|
||||
}
|
||||
fail 'unretracted by the correct amount'
|
||||
|
|
@ -84,7 +84,7 @@ use Slic3r::Test qw(_eq);
|
|||
$retracted_length[$tool] = 0;
|
||||
}
|
||||
}
|
||||
if ($info->{travel} && $info->{dist_XY} >= $print->config->get_at('retract_before_travel', $tool)) {
|
||||
if ($info->{travel} && $info->{dist_XY} >= $print->print->config->get_at('retract_before_travel', $tool)) {
|
||||
fail 'retracted before long travel move' if !$retracted[$tool];
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ use Slic3r::Test;
|
|||
|
||||
my $test = sub {
|
||||
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
||||
$print->init_extruders;
|
||||
my $flow = $print->objects->[0]->support_material_flow;
|
||||
$print->print->init_extruders;
|
||||
my $flow = $print->print->objects->[0]->support_material_flow;
|
||||
my $support_z = Slic3r::Print::SupportMaterial
|
||||
->new(
|
||||
object_config => $print->objects->[0]->config,
|
||||
print_config => $print->config,
|
||||
object_config => $print->print->objects->[0]->config,
|
||||
print_config => $print->print->config,
|
||||
flow => $flow,
|
||||
interface_flow => $flow,
|
||||
first_layer_flow => $flow,
|
||||
|
|
|
|||
2
t/svg.t
2
t/svg.t
|
|
@ -14,7 +14,7 @@ use Slic3r::Test;
|
|||
my $print = Slic3r::Test::init_print('20mm_cube');
|
||||
eval {
|
||||
my $fh = IO::Scalar->new(\my $gcode);
|
||||
$print->export_svg(output_fh => $fh, quiet => 1);
|
||||
$print->print->export_svg(output_fh => $fh, quiet => 1);
|
||||
$fh->close;
|
||||
};
|
||||
ok !$@, 'successful SVG export';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue