mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-16 19:35:54 +08:00
Refactoring of PrintObject::discover_vertical_shells() for readability
and efficiency. Also added an experiment of adding one more "ensuring" layer to support top / bottom surfaces, disabled with one_more_layer_below_top_bottom_surfaces
This commit is contained in:
parent
cc5660ad8c
commit
eec51c67d3
@ -1373,43 +1373,56 @@ void PrintObject::discover_vertical_shells()
|
|||||||
}
|
}
|
||||||
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */
|
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */
|
||||||
polygons_append(holes, cache_top_botom_regions[idx_layer].holes);
|
polygons_append(holes, cache_top_botom_regions[idx_layer].holes);
|
||||||
if (int n_top_layers = region_config.top_solid_layers.value; n_top_layers > 0) {
|
auto combine_holes = [&holes](const Polygons &holes2) {
|
||||||
// Gather top regions projected to this layer.
|
if (holes.empty() || holes2.empty())
|
||||||
coordf_t print_z = layer->print_z;
|
holes.clear();
|
||||||
for (int i = int(idx_layer) + 1;
|
else
|
||||||
i < int(cache_top_botom_regions.size()) &&
|
holes = intersection(holes, holes2);
|
||||||
(i < int(idx_layer) + n_top_layers ||
|
};
|
||||||
m_layers[i]->print_z - print_z < region_config.top_solid_min_thickness - EPSILON);
|
auto combine_shells = [&shell](const Polygons &shells2) {
|
||||||
++ i) {
|
if (shell.empty())
|
||||||
const DiscoverVerticalShellsCacheEntry &cache = cache_top_botom_regions[i];
|
shell = std::move(shells2);
|
||||||
if (! holes.empty())
|
else if (! shells2.empty()) {
|
||||||
holes = intersection(holes, cache.holes);
|
polygons_append(shell, shells2);
|
||||||
if (! cache.top_surfaces.empty()) {
|
|
||||||
polygons_append(shell, cache.top_surfaces);
|
|
||||||
// Running the union_ using the Clipper library piece by piece is cheaper
|
// Running the union_ using the Clipper library piece by piece is cheaper
|
||||||
// than running the union_ all at once.
|
// than running the union_ all at once.
|
||||||
shell = union_(shell);
|
shell = union_(shell);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
static constexpr const bool one_more_layer_below_top_bottom_surfaces = false;
|
||||||
|
if (int n_top_layers = region_config.top_solid_layers.value; n_top_layers > 0) {
|
||||||
|
// Gather top regions projected to this layer.
|
||||||
|
coordf_t print_z = layer->print_z;
|
||||||
|
int i = int(idx_layer) + 1;
|
||||||
|
int itop = int(idx_layer) + n_top_layers;
|
||||||
|
for (; i < int(cache_top_botom_regions.size()) &&
|
||||||
|
(i < itop || m_layers[i]->print_z - print_z < region_config.top_solid_min_thickness - EPSILON);
|
||||||
|
++ i) {
|
||||||
|
const DiscoverVerticalShellsCacheEntry &cache = cache_top_botom_regions[i];
|
||||||
|
combine_holes(cache.holes);
|
||||||
|
combine_shells(cache.top_surfaces);
|
||||||
}
|
}
|
||||||
|
if (one_more_layer_below_top_bottom_surfaces)
|
||||||
|
if (i < int(cache_top_botom_regions.size()) &&
|
||||||
|
(i <= itop || m_layers[i]->bottom_z() - print_z < region_config.top_solid_min_thickness - EPSILON))
|
||||||
|
combine_holes(cache_top_botom_regions[i].holes);
|
||||||
}
|
}
|
||||||
if (int n_bottom_layers = region_config.bottom_solid_layers.value; n_bottom_layers > 0) {
|
if (int n_bottom_layers = region_config.bottom_solid_layers.value; n_bottom_layers > 0) {
|
||||||
// Gather bottom regions projected to this layer.
|
// Gather bottom regions projected to this layer.
|
||||||
coordf_t bottom_z = layer->bottom_z();
|
coordf_t bottom_z = layer->bottom_z();
|
||||||
for (int i = int(idx_layer) - 1;
|
int i = int(idx_layer) - 1;
|
||||||
i >= 0 &&
|
int ibottom = int(idx_layer) - n_bottom_layers;
|
||||||
(i > int(idx_layer) - n_bottom_layers ||
|
for (; i >= 0 &&
|
||||||
bottom_z - m_layers[i]->bottom_z() < region_config.bottom_solid_min_thickness - EPSILON);
|
(i > ibottom || bottom_z - m_layers[i]->bottom_z() < region_config.bottom_solid_min_thickness - EPSILON);
|
||||||
-- i) {
|
-- i) {
|
||||||
const DiscoverVerticalShellsCacheEntry &cache = cache_top_botom_regions[i];
|
const DiscoverVerticalShellsCacheEntry &cache = cache_top_botom_regions[i];
|
||||||
if (! holes.empty())
|
combine_holes(cache.holes);
|
||||||
holes = intersection(holes, cache.holes);
|
combine_shells(cache.bottom_surfaces);
|
||||||
if (! cache.bottom_surfaces.empty()) {
|
|
||||||
polygons_append(shell, cache.bottom_surfaces);
|
|
||||||
// Running the union_ using the Clipper library piece by piece is cheaper
|
|
||||||
// than running the union_ all at once.
|
|
||||||
shell = union_(shell);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (one_more_layer_below_top_bottom_surfaces)
|
||||||
|
if (i >= 0 &&
|
||||||
|
(i > ibottom || bottom_z - m_layers[i]->print_z < region_config.bottom_solid_min_thickness - EPSILON))
|
||||||
|
combine_holes(cache_top_botom_regions[i].holes);
|
||||||
}
|
}
|
||||||
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user