Fixed unit tests broken with the previous commit (Spiral Vase fix).

Fixed a crash in the previous commit.
This commit is contained in:
bubnikv 2020-02-09 09:43:15 +01:00
parent 76433da64c
commit e7d2fcf0be
6 changed files with 53 additions and 49 deletions

View File

@ -829,7 +829,7 @@ void PrintObject::detect_surfaces_type()
// Fill in layerm->fill_surfaces by trimming the layerm->slices by the cummulative layerm->fill_surfaces. // Fill in layerm->fill_surfaces by trimming the layerm->slices by the cummulative layerm->fill_surfaces.
tbb::parallel_for( tbb::parallel_for(
tbb::blocked_range<size_t>(0, m_layers.size()), tbb::blocked_range<size_t>(0, m_layers.size()),
[this, idx_region, interface_shells, &surfaces_new](const tbb::blocked_range<size_t>& range) { [this, idx_region, interface_shells](const tbb::blocked_range<size_t>& range) {
for (size_t idx_layer = range.begin(); idx_layer < range.end(); ++ idx_layer) { for (size_t idx_layer = range.begin(); idx_layer < range.end(); ++ idx_layer) {
m_print->throw_if_canceled(); m_print->throw_if_canceled();
LayerRegion *layerm = m_layers[idx_layer]->m_regions[idx_region]; LayerRegion *layerm = m_layers[idx_layer]->m_regions[idx_region];
@ -1145,7 +1145,7 @@ void PrintObject::discover_vertical_shells()
coordf_t print_z = layer->print_z; coordf_t print_z = layer->print_z;
int n_top_layers = region_config.top_solid_layers.value; int n_top_layers = region_config.top_solid_layers.value;
for (int i = int(idx_layer) + 1; for (int i = int(idx_layer) + 1;
i < int(m_layers.size()) && i < int(cache_top_botom_regions.size()) &&
(i < int(idx_layer) + n_top_layers || (i < int(idx_layer) + n_top_layers ||
m_layers[i]->print_z - print_z < region_config.top_solid_min_thickness - EPSILON); m_layers[i]->print_z - print_z < region_config.top_solid_min_thickness - EPSILON);
++ i) { ++ i) {

View File

@ -1,4 +1,4 @@
use Test::More tests => 25; use Test::More tests => 24;
use strict; use strict;
use warnings; use warnings;
@ -199,22 +199,24 @@ use Slic3r::Test;
like $gcode, qr/START:20mm_cube/, '[input_filename] is also available in custom G-code'; like $gcode, qr/START:20mm_cube/, '[input_filename] is also available in custom G-code';
} }
{ # The current Spiral Vase slicing code removes the holes and all but the largest contours from each slice,
my $config = Slic3r::Config::new_from_defaults; # therefore the following test is no more valid.
$config->set('spiral_vase', 1); #{
my $print = Slic3r::Test::init_print('cube_with_hole', config => $config); # my $config = Slic3r::Config::new_from_defaults;
# $config->set('spiral_vase', 1);
my $spiral = 0; # my $print = Slic3r::Test::init_print('cube_with_hole', config => $config);
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { #
my ($self, $cmd, $args, $info) = @_; # my $spiral = 0;
# Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
if ($cmd eq 'G1' && exists $args->{E} && exists $args->{Z}) { # my ($self, $cmd, $args, $info) = @_;
$spiral = 1; #
} # if ($cmd eq 'G1' && exists $args->{E} && exists $args->{Z}) {
}); # $spiral = 1;
# }
ok !$spiral, 'spiral vase is correctly disabled on layers with multiple loops'; # });
} #
# ok !$spiral, 'spiral vase is correctly disabled on layers with multiple loops';
#}
{ {

View File

@ -1,4 +1,4 @@
use Test::More tests => 21; use Test::More tests => 20;
use strict; use strict;
use warnings; use warnings;
@ -293,31 +293,33 @@ use Slic3r::Test;
ok !$horizontal_extrusions, 'no horizontal extrusions'; ok !$horizontal_extrusions, 'no horizontal extrusions';
} }
{ # The current Spiral Vase slicing code removes the holes and all but the largest contours from each slice,
my $config = Slic3r::Config::new_from_defaults; # therefore the following test is no more valid.
$config->set('perimeters', 1); #{
$config->set('fill_density', 0); # my $config = Slic3r::Config::new_from_defaults;
$config->set('top_solid_layers', 0); # $config->set('perimeters', 1);
$config->set('spiral_vase', 1); # $config->set('fill_density', 0);
$config->set('bottom_solid_layers', 0); # $config->set('top_solid_layers', 0);
$config->set('skirts', 0); # $config->set('spiral_vase', 1);
$config->set('first_layer_height', '100%'); # $config->set('bottom_solid_layers', 0);
$config->set('start_gcode', ''); # $config->set('skirts', 0);
# $config->set('first_layer_height', '100%');
my $print = Slic3r::Test::init_print('two_hollow_squares', config => $config); # $config->set('start_gcode', '');
my $diagonal_moves = 0; #
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { # my $print = Slic3r::Test::init_print('two_hollow_squares', config => $config);
my ($self, $cmd, $args, $info) = @_; # my $diagonal_moves = 0;
# Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
if ($cmd eq 'G1') { # my ($self, $cmd, $args, $info) = @_;
if ($info->{extruding} && $info->{dist_XY} > 0) { #
if ($info->{dist_Z} > 0) { # if ($cmd eq 'G1') {
$diagonal_moves++; # if ($info->{extruding} && $info->{dist_XY} > 0) {
} # if ($info->{dist_Z} > 0) {
} # $diagonal_moves++;
} # }
}); # }
is $diagonal_moves, 0, 'no spiral moves on two-island object'; # }
} # });
# is $diagonal_moves, 0, 'no spiral moves on two-island object';
#}
__END__ __END__

View File

@ -54,7 +54,7 @@ TEST_CASE("Support point generator should be deterministic if seeded",
auto slicegrid = grid(float(gnd), float(zmax), layer_h); auto slicegrid = grid(float(gnd), float(zmax), layer_h);
std::vector<ExPolygons> slices; std::vector<ExPolygons> slices;
slicer.slice(slicegrid, CLOSING_RADIUS, &slices, []{}); slicer.slice(slicegrid, SlicingMode::Regular, CLOSING_RADIUS, &slices, []{});
point_gen.seed(0); point_gen.seed(0);
point_gen.execute(slices, slicegrid); point_gen.execute(slices, slicegrid);

View File

@ -98,7 +98,7 @@ void test_supports(const std::string &obj_filename,
auto layer_h = 0.05f; auto layer_h = 0.05f;
out.slicegrid = grid(float(gnd), float(zmax), layer_h); out.slicegrid = grid(float(gnd), float(zmax), layer_h);
slicer.slice(out.slicegrid , CLOSING_RADIUS, &out.model_slices, []{}); slicer.slice(out.slicegrid, SlicingMode::Regular, CLOSING_RADIUS, &out.model_slices, []{});
sla::cut_drainholes(out.model_slices, out.slicegrid, CLOSING_RADIUS, drainholes, []{}); sla::cut_drainholes(out.model_slices, out.slicegrid, CLOSING_RADIUS, drainholes, []{});
// Create the special index-triangle mesh with spatial indexing which // Create the special index-triangle mesh with spatial indexing which

View File

@ -182,7 +182,7 @@ TriangleMesh::slice(z)
std::vector<ExPolygons> layers; std::vector<ExPolygons> layers;
TriangleMeshSlicer mslicer(THIS); TriangleMeshSlicer mslicer(THIS);
mslicer.slice(z_f, 0.049f, &layers, [](){}); mslicer.slice(z_f, SlicingMode::Regular, 0.049f, &layers, [](){});
AV* layers_av = newAV(); AV* layers_av = newAV();
size_t len = layers.size(); size_t len = layers.size();