Parallelized the slow discover_vertical_shells()
This commit is contained in:
parent
f200781436
commit
798bca561b
1 changed files with 215 additions and 206 deletions
|
@ -579,8 +579,6 @@ PrintObject::discover_vertical_shells()
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "Discovering vertical shells...";
|
BOOST_LOG_TRIVIAL(info) << "Discovering vertical shells...";
|
||||||
|
|
||||||
const SurfaceType surfaces_bottom[2] = { stBottom, stBottomBridge };
|
|
||||||
|
|
||||||
for (size_t idx_region = 0; idx_region < this->_print->regions.size(); ++ idx_region) {
|
for (size_t idx_region = 0; idx_region < this->_print->regions.size(); ++ idx_region) {
|
||||||
PROFILE_BLOCK(discover_vertical_shells_region);
|
PROFILE_BLOCK(discover_vertical_shells_region);
|
||||||
|
|
||||||
|
@ -593,11 +591,20 @@ PrintObject::discover_vertical_shells()
|
||||||
if (n_extra_top_layers + n_extra_bottom_layers == 0)
|
if (n_extra_top_layers + n_extra_bottom_layers == 0)
|
||||||
// Zero or 1 layer, there is no additional vertical wall thickness enforced.
|
// Zero or 1 layer, there is no additional vertical wall thickness enforced.
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(debug) << "Discovering vertical shells for region " << idx_region << " in parallel - start";
|
||||||
|
//FIXME Improve the heuristics for a grain size.
|
||||||
|
size_t grain_size = std::max(this->layers.size() / 16, size_t(1));
|
||||||
|
tbb::parallel_for(
|
||||||
|
tbb::blocked_range<size_t>(0, this->layers.size(), grain_size),
|
||||||
|
[this, idx_region, n_extra_top_layers, n_extra_bottom_layers](const tbb::blocked_range<size_t>& range) {
|
||||||
|
// printf("discover_vertical_shells from %d to %d\n", range.begin(), range.end());
|
||||||
// Cyclic buffers of pre-calculated offsetted top/bottom surfaces.
|
// Cyclic buffers of pre-calculated offsetted top/bottom surfaces.
|
||||||
|
//FIXME these caches could be maintained per thread of the thread loop.
|
||||||
std::vector<DiscoverVerticalShellsCacheEntry> cache_top_regions(n_extra_top_layers, DiscoverVerticalShellsCacheEntry());
|
std::vector<DiscoverVerticalShellsCacheEntry> cache_top_regions(n_extra_top_layers, DiscoverVerticalShellsCacheEntry());
|
||||||
std::vector<DiscoverVerticalShellsCacheEntry> cache_bottom_regions(n_extra_bottom_layers, DiscoverVerticalShellsCacheEntry());
|
std::vector<DiscoverVerticalShellsCacheEntry> cache_bottom_regions(n_extra_bottom_layers, DiscoverVerticalShellsCacheEntry());
|
||||||
for (size_t idx_layer = 0; idx_layer < this->layers.size(); ++ idx_layer)
|
const SurfaceType surfaces_bottom[2] = { stBottom, stBottomBridge };
|
||||||
{
|
for (size_t idx_layer = range.begin(); idx_layer < range.end(); ++ idx_layer) {
|
||||||
PROFILE_BLOCK(discover_vertical_shells_region_layer);
|
PROFILE_BLOCK(discover_vertical_shells_region_layer);
|
||||||
|
|
||||||
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
||||||
|
@ -606,7 +613,7 @@ PrintObject::discover_vertical_shells()
|
||||||
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */
|
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */
|
||||||
|
|
||||||
Layer *layer = this->layers[idx_layer];
|
Layer *layer = this->layers[idx_layer];
|
||||||
LayerRegion *layerm = layer->get_region(idx_region);
|
LayerRegion *layerm = layer->regions[idx_region];
|
||||||
|
|
||||||
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
||||||
layerm->export_region_slices_to_svg_debug("4_discover_vertical_shells-initial");
|
layerm->export_region_slices_to_svg_debug("4_discover_vertical_shells-initial");
|
||||||
|
@ -711,7 +718,7 @@ PrintObject::discover_vertical_shells()
|
||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
PROFILE_BLOCK(discover_vertical_shells_region_layer_shell_);
|
PROFILE_BLOCK(discover_vertical_shells_region_layer_shell_);
|
||||||
// shell = union_(shell, true);
|
// shell = union_(shell, true);
|
||||||
shell = union_(shell, false);
|
shell = union_(shell, false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -784,7 +791,7 @@ PrintObject::discover_vertical_shells()
|
||||||
continue;
|
continue;
|
||||||
#else
|
#else
|
||||||
// Ensure each region is at least 3x infill line width wide, so it could be filled in.
|
// Ensure each region is at least 3x infill line width wide, so it could be filled in.
|
||||||
// float margin = float(infill_line_spacing) * 3.f;
|
// float margin = float(infill_line_spacing) * 3.f;
|
||||||
float margin = float(infill_line_spacing) * 1.5f;
|
float margin = float(infill_line_spacing) * 1.5f;
|
||||||
// we use a higher miterLimit here to handle areas with acute angles
|
// we use a higher miterLimit here to handle areas with acute angles
|
||||||
// in those cases, the default miterLimit would cut the corner and we'd
|
// in those cases, the default miterLimit would cut the corner and we'd
|
||||||
|
@ -841,6 +848,8 @@ PrintObject::discover_vertical_shells()
|
||||||
layerm->fill_surfaces.append(new_internal_void, stInternalVoid);
|
layerm->fill_surfaces.append(new_internal_void, stInternalVoid);
|
||||||
layerm->fill_surfaces.append(new_internal_solid, stInternalSolid);
|
layerm->fill_surfaces.append(new_internal_solid, stInternalSolid);
|
||||||
} // for each layer
|
} // for each layer
|
||||||
|
});
|
||||||
|
BOOST_LOG_TRIVIAL(debug) << "Discovering vertical shells for region " << idx_region << " in parallel - end";
|
||||||
|
|
||||||
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
||||||
for (size_t idx_layer = 0; idx_layer < this->layers.size(); ++idx_layer) {
|
for (size_t idx_layer = 0; idx_layer < this->layers.size(); ++idx_layer) {
|
||||||
|
|
Loading…
Reference in a new issue