Parallelized process_external_surfaces

This commit is contained in:
Alessandro Ranellucci 2017-03-09 20:40:06 +01:00
parent db8396a290
commit afacf0c99d
4 changed files with 19 additions and 15 deletions

View File

@ -419,4 +419,11 @@ Layer::detect_surfaces_type()
} }
} }
void
Layer::process_external_surfaces()
{
for (LayerRegion* &layerm : this->regions)
layerm->process_external_surfaces();
}
} }

View File

@ -61,7 +61,7 @@ class LayerRegion
void prepare_fill_surfaces(); void prepare_fill_surfaces();
void make_perimeters(const SurfaceCollection &slices, SurfaceCollection* fill_surfaces); void make_perimeters(const SurfaceCollection &slices, SurfaceCollection* fill_surfaces);
void make_fill(); void make_fill();
void process_external_surfaces(const Layer* lower_layer); void process_external_surfaces();
double infill_area_threshold() const; double infill_area_threshold() const;
private: private:
@ -111,6 +111,7 @@ class Layer {
void make_perimeters(); void make_perimeters();
void make_fills(); void make_fills();
void detect_surfaces_type(); void detect_surfaces_type();
void process_external_surfaces();
protected: protected:
size_t _id; // sequential number of layer, 0-based size_t _id; // sequential number of layer, 0-based

View File

@ -65,8 +65,10 @@ LayerRegion::make_perimeters(const SurfaceCollection &slices, SurfaceCollection*
g.process(); g.process();
} }
// This function reads lower_layer->slices and writes this->bridged and this->fill_surfaces,
// so it's thread-safe.
void void
LayerRegion::process_external_surfaces(const Layer* lower_layer) LayerRegion::process_external_surfaces()
{ {
const Surfaces &surfaces = this->fill_surfaces.surfaces; const Surfaces &surfaces = this->fill_surfaces.surfaces;
const double margin = scale_(EXTERNAL_INFILL_MARGIN); const double margin = scale_(EXTERNAL_INFILL_MARGIN);
@ -82,10 +84,10 @@ LayerRegion::process_external_surfaces(const Layer* lower_layer)
also, supply the original expolygon instead of the grown one, because in case also, supply the original expolygon instead of the grown one, because in case
of very thin (but still working) anchors, the grown expolygon would go beyond them */ of very thin (but still working) anchors, the grown expolygon would go beyond them */
double angle = -1; double angle = -1;
if (lower_layer != NULL && surface->is_bridge()) { if (this->layer()->lower_layer != NULL && surface->is_bridge()) {
BridgeDetector bd( BridgeDetector bd(
surface->expolygon, surface->expolygon,
lower_layer->slices, this->layer()->lower_layer->slices,
this->flow(frInfill, true).scaled_width() this->flow(frInfill, true).scaled_width()
); );

View File

@ -371,17 +371,11 @@ PrintObject::detect_surfaces_type()
void void
PrintObject::process_external_surfaces() PrintObject::process_external_surfaces()
{ {
FOREACH_REGION(this->_print, region) { parallelize<Layer*>(
size_t region_id = region - this->_print->regions.begin(); std::queue<Layer*>(std::deque<Layer*>(this->layers.begin(), this->layers.end())), // cast LayerPtrs to std::queue<Layer*>
boost::bind(&Slic3r::Layer::process_external_surfaces, _1),
FOREACH_LAYER(this, layer_it) { this->_print->config.threads.value
const Layer* lower_layer = (layer_it == this->layers.begin()) );
? NULL
: *(layer_it-1);
(*layer_it)->get_region(region_id)->process_external_surfaces(lower_layer);
}
}
} }
/* This method applies bridge flow to the first internal solid layer above /* This method applies bridge flow to the first internal solid layer above