Parallelize PrintObject::process_external_surfaces()
This commit is contained in:
parent
109013bed7
commit
65c024f7cf
3 changed files with 29 additions and 40 deletions
|
@ -22,7 +22,8 @@ class LayerRegion
|
|||
friend class Layer;
|
||||
|
||||
public:
|
||||
Layer* layer();
|
||||
Layer* layer() { return this->_layer; }
|
||||
const Layer* layer() const { return this->_layer; }
|
||||
PrintRegion* region() { return this->_region; }
|
||||
const PrintRegion* region() const { return this->_region; }
|
||||
|
||||
|
@ -76,8 +77,8 @@ class LayerRegion
|
|||
Layer *_layer;
|
||||
PrintRegion *_region;
|
||||
|
||||
LayerRegion(Layer *layer, PrintRegion *region);
|
||||
~LayerRegion();
|
||||
LayerRegion(Layer *layer, PrintRegion *region) : _layer(layer), _region(region) {}
|
||||
~LayerRegion() {}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -14,22 +14,6 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
LayerRegion::LayerRegion(Layer *layer, PrintRegion *region)
|
||||
: _layer(layer),
|
||||
_region(region)
|
||||
{
|
||||
}
|
||||
|
||||
LayerRegion::~LayerRegion()
|
||||
{
|
||||
}
|
||||
|
||||
Layer*
|
||||
LayerRegion::layer()
|
||||
{
|
||||
return this->_layer;
|
||||
}
|
||||
|
||||
Flow
|
||||
LayerRegion::flow(FlowRole role, bool bridge, double width) const
|
||||
{
|
||||
|
@ -134,26 +118,26 @@ LayerRegion::process_external_surfaces(const Layer* lower_layer)
|
|||
// bottom_polygons are used to trim inflated top surfaces.
|
||||
fill_boundaries.reserve(number_polygons(surfaces));
|
||||
bool has_infill = this->region()->config.fill_density.value > 0.;
|
||||
for (Surfaces::iterator surface = this->fill_surfaces.surfaces.begin(); surface != this->fill_surfaces.surfaces.end(); ++surface) {
|
||||
if (surface->surface_type == stTop) {
|
||||
for (const Surface &surface : this->fill_surfaces.surfaces) {
|
||||
if (surface.surface_type == stTop) {
|
||||
// Collect the top surfaces, inflate them and trim them by the bottom surfaces.
|
||||
// This gives the priority to bottom surfaces.
|
||||
surfaces_append(top, offset_ex(surface->expolygon, float(margin), EXTERNAL_SURFACES_OFFSET_PARAMETERS), *surface);
|
||||
} else if (surface->surface_type == stBottom || (surface->surface_type == stBottomBridge && lower_layer == NULL)) {
|
||||
surfaces_append(top, offset_ex(surface.expolygon, float(margin), EXTERNAL_SURFACES_OFFSET_PARAMETERS), surface);
|
||||
} else if (surface.surface_type == stBottom || (surface.surface_type == stBottomBridge && lower_layer == NULL)) {
|
||||
// Grown by 3mm.
|
||||
surfaces_append(bottom, offset_ex(surface->expolygon, float(margin), EXTERNAL_SURFACES_OFFSET_PARAMETERS), *surface);
|
||||
} else if (surface->surface_type == stBottomBridge) {
|
||||
if (! surface->empty())
|
||||
bridges.push_back(*surface);
|
||||
surfaces_append(bottom, offset_ex(surface.expolygon, float(margin), EXTERNAL_SURFACES_OFFSET_PARAMETERS), surface);
|
||||
} else if (surface.surface_type == stBottomBridge) {
|
||||
if (! surface.empty())
|
||||
bridges.push_back(surface);
|
||||
}
|
||||
bool internal_surface = surface->surface_type != stTop && ! surface->is_bottom();
|
||||
if (has_infill || surface->surface_type != stInternal) {
|
||||
bool internal_surface = surface.surface_type != stTop && ! surface.is_bottom();
|
||||
if (has_infill || surface.surface_type != stInternal) {
|
||||
if (internal_surface)
|
||||
// Make a copy as the following line uses the move semantics.
|
||||
internal.push_back(*surface);
|
||||
polygons_append(fill_boundaries, STDMOVE(surface->expolygon));
|
||||
internal.push_back(surface);
|
||||
polygons_append(fill_boundaries, STDMOVE(surface.expolygon));
|
||||
} else if (internal_surface)
|
||||
internal.push_back(STDMOVE(*surface));
|
||||
internal.push_back(STDMOVE(surface));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -526,15 +526,19 @@ PrintObject::process_external_surfaces()
|
|||
BOOST_LOG_TRIVIAL(info) << "Processing external surfaces...";
|
||||
|
||||
FOREACH_REGION(this->_print, region) {
|
||||
size_t region_id = region - this->_print->regions.begin();
|
||||
int region_id = int(region - this->_print->regions.begin());
|
||||
|
||||
FOREACH_LAYER(this, layer_it) {
|
||||
const Layer* lower_layer = (layer_it == this->layers.begin())
|
||||
? NULL
|
||||
: *(layer_it-1);
|
||||
BOOST_LOG_TRIVIAL(trace) << "Processing external surface, layer" << (*layer_it)->print_z;
|
||||
(*layer_it)->get_region(region_id)->process_external_surfaces(lower_layer);
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(debug) << "Processing external surfaces for region " << region_id << " in parallel - start";
|
||||
tbb::parallel_for(
|
||||
tbb::blocked_range<size_t>(0, this->layers.size()),
|
||||
[this, region_id](const tbb::blocked_range<size_t>& range) {
|
||||
for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++ layer_idx) {
|
||||
// BOOST_LOG_TRIVIAL(trace) << "Processing external surface, layer" << this->layers[layer_idx]->print_z;
|
||||
this->layers[layer_idx]->get_region(region_id)->process_external_surfaces((layer_idx == 0) ? NULL : this->layers[layer_idx - 1]);
|
||||
}
|
||||
}
|
||||
);
|
||||
BOOST_LOG_TRIVIAL(debug) << "Processing external surfaces for region " << region_id << " in parallel - end";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue