Optimization of LayerRegion::slices_to_fill_surfaces_clipped()

Added some run time tracing through boost::log.
This commit is contained in:
bubnikv 2017-03-02 16:41:16 +01:00
parent 73f603d90e
commit 83a80a9b7d

View file

@ -10,6 +10,8 @@
#include <string> #include <string>
#include <map> #include <map>
#include <boost/log/trivial.hpp>
namespace Slic3r { namespace Slic3r {
LayerRegion::LayerRegion(Layer *layer, PrintRegion *region) LayerRegion::LayerRegion(Layer *layer, PrintRegion *region)
@ -50,11 +52,18 @@ void LayerRegion::slices_to_fill_surfaces_clipped()
// that combine_infill() turns some fill_surface into VOID surfaces. // that combine_infill() turns some fill_surface into VOID surfaces.
// Polygons fill_boundaries = to_polygons(STDMOVE(this->fill_surfaces)); // Polygons fill_boundaries = to_polygons(STDMOVE(this->fill_surfaces));
Polygons fill_boundaries = to_polygons(this->fill_expolygons); Polygons fill_boundaries = to_polygons(this->fill_expolygons);
// Collect polygons per surface type.
std::vector<Polygons> polygons_by_surface;
polygons_by_surface.assign(size_t(stCount), Polygons());
for (Surface &surface : this->slices.surfaces)
polygons_append(polygons_by_surface[(size_t)surface.surface_type], surface.expolygon);
// Trim surfaces by the fill_boundaries.
this->fill_surfaces.surfaces.clear(); this->fill_surfaces.surfaces.clear();
for (Surfaces::const_iterator surface = this->slices.surfaces.begin(); surface != this->slices.surfaces.end(); ++ surface) for (size_t surface_type = 0; surface_type < size_t(stCount); ++ surface_type) {
this->fill_surfaces.append( const Polygons &polygons = polygons_by_surface[surface_type];
intersection_ex(to_polygons(surface->expolygon), fill_boundaries), if (! polygons.empty())
surface->surface_type); this->fill_surfaces.append(intersection_ex(polygons, fill_boundaries), SurfaceType(surface_type));
}
} }
void void
@ -233,6 +242,7 @@ LayerRegion::process_external_surfaces(const Layer* lower_layer)
// 3) Merge the groups with the same group id, detect bridges. // 3) Merge the groups with the same group id, detect bridges.
{ {
BOOST_LOG_TRIVIAL(trace) << "Processing external surface, detecting bridges. layer" << this->layer()->print_z << ", bridge groups: " << n_groups;
for (size_t group_id = 0; group_id < n_groups; ++ group_id) { for (size_t group_id = 0; group_id < n_groups; ++ group_id) {
size_t n_bridges_merged = 0; size_t n_bridges_merged = 0;
size_t idx_last = (size_t)-1; size_t idx_last = (size_t)-1;
@ -278,7 +288,8 @@ LayerRegion::process_external_surfaces(const Layer* lower_layer)
} }
fill_boundaries = STDMOVE(to_polygons(fill_boundaries_ex)); fill_boundaries = STDMOVE(to_polygons(fill_boundaries_ex));
} BOOST_LOG_TRIVIAL(trace) << "Processing external surface, detecting bridges - done";
}
#if 0 #if 0
{ {