Fixed a crash with a layer range modifier containing no slicing layer.

This commit is contained in:
bubnikv 2019-10-01 13:41:22 +02:00
parent 93a157e26c
commit 6a07b231e1

View File

@ -1659,25 +1659,26 @@ void PrintObject::_slice(const std::vector<coordf_t> &layer_height_profile)
// Trim volumes in a single layer, one by the other, possibly apply upscaling. // Trim volumes in a single layer, one by the other, possibly apply upscaling.
{ {
Polygons processed; Polygons processed;
for (SlicedVolume &sliced_volume : sliced_volumes) { for (SlicedVolume &sliced_volume : sliced_volumes)
ExPolygons slices = std::move(sliced_volume.expolygons_by_layer[layer_id]); if (! sliced_volume.expolygons_by_layer.empty()) {
if (upscale) ExPolygons slices = std::move(sliced_volume.expolygons_by_layer[layer_id]);
slices = offset_ex(std::move(slices), delta); if (upscale)
if (! processed.empty()) slices = offset_ex(std::move(slices), delta);
// Trim by the slices of already processed regions. if (! processed.empty())
slices = diff_ex(to_polygons(std::move(slices)), processed); // Trim by the slices of already processed regions.
if (size_t(&sliced_volume - &sliced_volumes.front()) + 1 < sliced_volumes.size()) slices = diff_ex(to_polygons(std::move(slices)), processed);
// Collect the already processed regions to trim the to be processed regions. if (size_t(&sliced_volume - &sliced_volumes.front()) + 1 < sliced_volumes.size())
polygons_append(processed, slices); // Collect the already processed regions to trim the to be processed regions.
sliced_volume.expolygons_by_layer[layer_id] = std::move(slices); polygons_append(processed, slices);
} sliced_volume.expolygons_by_layer[layer_id] = std::move(slices);
}
} }
// Collect and union volumes of a single region. // Collect and union volumes of a single region.
for (int region_id = 0; region_id < (int)this->region_volumes.size(); ++ region_id) { for (int region_id = 0; region_id < (int)this->region_volumes.size(); ++ region_id) {
ExPolygons expolygons; ExPolygons expolygons;
size_t num_volumes = 0; size_t num_volumes = 0;
for (SlicedVolume &sliced_volume : sliced_volumes) for (SlicedVolume &sliced_volume : sliced_volumes)
if (sliced_volume.region_id == region_id && ! sliced_volume.expolygons_by_layer[layer_id].empty()) { if (sliced_volume.region_id == region_id && ! sliced_volume.expolygons_by_layer.empty() && ! sliced_volume.expolygons_by_layer[layer_id].empty()) {
++ num_volumes; ++ num_volumes;
append(expolygons, std::move(sliced_volume.expolygons_by_layer[layer_id])); append(expolygons, std::move(sliced_volume.expolygons_by_layer[layer_id]));
} }