From cd084a33c6492d477c3b5499ff68c25136209c03 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 14 Sep 2017 13:15:32 +0200 Subject: Fixed a regression bug, which was made during the porting of discover_horizontal_shells() fron Perl to C++, where the already calculated bridge direction was being lost. Improved constness of the debug methods void export_region_slices_to_svg(const char *path) const; void export_region_fill_surfaces_to_svg(const char *path) const; --- xs/src/libslic3r/Layer.cpp | 8 ++++---- xs/src/libslic3r/Layer.hpp | 16 ++++++++-------- xs/src/libslic3r/LayerRegion.cpp | 15 +++++++-------- xs/src/libslic3r/PrintObject.cpp | 13 +++++++------ xs/xsp/Layer.xsp | 8 ++++---- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/xs/src/libslic3r/Layer.cpp b/xs/src/libslic3r/Layer.cpp index ccd01c5f9..652bcdaa0 100644 --- a/xs/src/libslic3r/Layer.cpp +++ b/xs/src/libslic3r/Layer.cpp @@ -161,7 +161,7 @@ void Layer::make_fills() } } -void Layer::export_region_slices_to_svg(const char *path) +void Layer::export_region_slices_to_svg(const char *path) const { BoundingBox bbox; for (LayerRegionPtrs::const_iterator region = this->regions.begin(); region != this->regions.end(); ++region) @@ -181,13 +181,13 @@ void Layer::export_region_slices_to_svg(const char *path) } // Export to "out/LayerRegion-name-%d.svg" with an increasing index with every export. -void Layer::export_region_slices_to_svg_debug(const char *name) +void Layer::export_region_slices_to_svg_debug(const char *name) const { static size_t idx = 0; this->export_region_slices_to_svg(debug_out_path("Layer-slices-%s-%d.svg", name, idx ++).c_str()); } -void Layer::export_region_fill_surfaces_to_svg(const char *path) +void Layer::export_region_fill_surfaces_to_svg(const char *path) const { BoundingBox bbox; for (LayerRegionPtrs::const_iterator region = this->regions.begin(); region != this->regions.end(); ++region) @@ -207,7 +207,7 @@ void Layer::export_region_fill_surfaces_to_svg(const char *path) } // Export to "out/LayerRegion-name-%d.svg" with an increasing index with every export. -void Layer::export_region_fill_surfaces_to_svg_debug(const char *name) +void Layer::export_region_fill_surfaces_to_svg_debug(const char *name) const { static size_t idx = 0; this->export_region_fill_surfaces_to_svg(debug_out_path("Layer-fill_surfaces-%s-%d.svg", name, idx ++).c_str()); diff --git a/xs/src/libslic3r/Layer.hpp b/xs/src/libslic3r/Layer.hpp index 333b02831..f8fdcdd4d 100644 --- a/xs/src/libslic3r/Layer.hpp +++ b/xs/src/libslic3r/Layer.hpp @@ -68,11 +68,11 @@ public: void process_external_surfaces(const Layer* lower_layer); double infill_area_threshold() const; - void export_region_slices_to_svg(const char *path); - void export_region_fill_surfaces_to_svg(const char *path); + void export_region_slices_to_svg(const char *path) const; + void export_region_fill_surfaces_to_svg(const char *path) const; // Export to "out/LayerRegion-name-%d.svg" with an increasing index with every export. - void export_region_slices_to_svg_debug(const char *name); - void export_region_fill_surfaces_to_svg_debug(const char *name); + void export_region_slices_to_svg_debug(const char *name) const; + void export_region_fill_surfaces_to_svg_debug(const char *name) const; // Is there any valid extrusion assigned to this LayerRegion? bool has_extrusions() const { return ! this->perimeters.entities.empty() || ! this->fills.entities.empty(); } @@ -129,11 +129,11 @@ public: void make_perimeters(); void make_fills(); - void export_region_slices_to_svg(const char *path); - void export_region_fill_surfaces_to_svg(const char *path); + void export_region_slices_to_svg(const char *path) const; + void export_region_fill_surfaces_to_svg(const char *path) const; // Export to "out/LayerRegion-name-%d.svg" with an increasing index with every export. - void export_region_slices_to_svg_debug(const char *name); - void export_region_fill_surfaces_to_svg_debug(const char *name); + void export_region_slices_to_svg_debug(const char *name) const; + void export_region_fill_surfaces_to_svg_debug(const char *name) const; // Is there any valid extrusion assigned to this LayerRegion? virtual bool has_extrusions() const { for (auto layerm : this->regions) if (layerm->has_extrusions()) return true; return false; } diff --git a/xs/src/libslic3r/LayerRegion.cpp b/xs/src/libslic3r/LayerRegion.cpp index 16d27ab6f..eb14c19ec 100644 --- a/xs/src/libslic3r/LayerRegion.cpp +++ b/xs/src/libslic3r/LayerRegion.cpp @@ -389,8 +389,7 @@ LayerRegion::infill_area_threshold() const return ss*ss; } - -void LayerRegion::export_region_slices_to_svg(const char *path) +void LayerRegion::export_region_slices_to_svg(const char *path) const { BoundingBox bbox; for (Surfaces::const_iterator surface = this->slices.surfaces.begin(); surface != this->slices.surfaces.end(); ++surface) @@ -410,14 +409,14 @@ void LayerRegion::export_region_slices_to_svg(const char *path) } // Export to "out/LayerRegion-name-%d.svg" with an increasing index with every export. -void LayerRegion::export_region_slices_to_svg_debug(const char *name) +void LayerRegion::export_region_slices_to_svg_debug(const char *name) const { static std::map idx_map; size_t &idx = idx_map[name]; this->export_region_slices_to_svg(debug_out_path("LayerRegion-slices-%s-%d.svg", name, idx ++).c_str()); } -void LayerRegion::export_region_fill_surfaces_to_svg(const char *path) +void LayerRegion::export_region_fill_surfaces_to_svg(const char *path) const { BoundingBox bbox; for (Surfaces::const_iterator surface = this->fill_surfaces.surfaces.begin(); surface != this->fill_surfaces.surfaces.end(); ++surface) @@ -428,16 +427,16 @@ void LayerRegion::export_region_fill_surfaces_to_svg(const char *path) SVG svg(path, bbox); const float transparency = 0.5f; - for (Surfaces::const_iterator surface = this->fill_surfaces.surfaces.begin(); surface != this->fill_surfaces.surfaces.end(); ++surface) { - svg.draw(surface->expolygon, surface_type_to_color_name(surface->surface_type), transparency); - svg.draw_outline(surface->expolygon, "black", "blue", scale_(0.05)); + for (const Surface &surface : this->fill_surfaces.surfaces) { + svg.draw(surface.expolygon, surface_type_to_color_name(surface.surface_type), transparency); + svg.draw_outline(surface.expolygon, "black", "blue", scale_(0.05)); } export_surface_type_legend_to_svg(svg, legend_pos); svg.Close(); } // Export to "out/LayerRegion-name-%d.svg" with an increasing index with every export. -void LayerRegion::export_region_fill_surfaces_to_svg_debug(const char *name) +void LayerRegion::export_region_fill_surfaces_to_svg_debug(const char *name) const { static std::map idx_map; size_t &idx = idx_map[name]; diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp index 475a320bf..fc2979c20 100644 --- a/xs/src/libslic3r/PrintObject.cpp +++ b/xs/src/libslic3r/PrintObject.cpp @@ -314,7 +314,7 @@ void PrintObject::_prepare_infill() // Debugging output. #ifdef SLIC3R_DEBUG_SLICE_PROCESSING - for (size_t region_id = 0; region_id < this->print()->regions.size(); ++ region_id) + for (size_t region_id = 0; region_id < this->print()->regions.size(); ++ region_id) { for (const Layer *layer : this->layers) { LayerRegion *layerm = layer->regions[region_id]; layerm->export_region_slices_to_svg_debug("6_discover_vertical_shells-final"); @@ -332,7 +332,7 @@ void PrintObject::_prepare_infill() this->discover_horizontal_shells(); #ifdef SLIC3R_DEBUG_SLICE_PROCESSING - for (size_t region_id = 0; region_id < this->print()->regions.size(); ++ region_id) + for (size_t region_id = 0; region_id < this->print()->regions.size(); ++ region_id) { for (const Layer *layer : this->layers) { LayerRegion *layerm = layer->regions[region_id]; layerm->export_region_slices_to_svg_debug("7_discover_horizontal_shells-final"); @@ -350,7 +350,7 @@ void PrintObject::_prepare_infill() this->clip_fill_surfaces(); #ifdef SLIC3R_DEBUG_SLICE_PROCESSING - for (size_t region_id = 0; region_id < this->print()->regions.size(); ++ region_id) + for (size_t region_id = 0; region_id < this->print()->regions.size(); ++ region_id) { for (const Layer *layer : this->layers) { LayerRegion *layerm = layer->regions[region_id]; layerm->export_region_slices_to_svg_debug("8_clip_surfaces-final"); @@ -367,7 +367,7 @@ void PrintObject::_prepare_infill() this->combine_infill(); #ifdef SLIC3R_DEBUG_SLICE_PROCESSING - for (size_t region_id = 0; region_id < this->print()->regions.size(); ++ region_id) + for (size_t region_id = 0; region_id < this->print()->regions.size(); ++ region_id) { for (const Layer *layer : this->layers) { LayerRegion *layerm = layer->regions[region_id]; layerm->export_region_slices_to_svg_debug("9_prepare_infill-final"); @@ -1816,7 +1816,8 @@ void PrintObject::discover_horizontal_shells() for (SurfacesPtr &group : top_bottom_groups) neighbor_layerm->fill_surfaces.append( diff_ex(to_polygons(group), polygons_internal), - group.front()->surface_type); + // Use an existing surface as a template, it carries the bridge angle etc. + *group.front()); } EXTERNAL:; } // foreach type (stTop, stBottom, stBottomBridge) @@ -1824,7 +1825,7 @@ void PrintObject::discover_horizontal_shells() } // for each region #ifdef SLIC3R_DEBUG_SLICE_PROCESSING - for (size_t region_id = 0; region_id < this->print()->regions.size(); ++ region_id) + for (size_t region_id = 0; region_id < this->print()->regions.size(); ++ region_id) { for (const Layer *layer : this->layers) { const LayerRegion *layerm = layer->regions[region_id]; layerm->export_region_slices_to_svg_debug("5_discover_horizontal_shells"); diff --git a/xs/xsp/Layer.xsp b/xs/xsp/Layer.xsp index 896712ffc..71fc540dc 100644 --- a/xs/xsp/Layer.xsp +++ b/xs/xsp/Layer.xsp @@ -35,10 +35,10 @@ %code%{ THIS->make_perimeters(*slices, fill_surfaces); %}; double infill_area_threshold(); - void export_region_slices_to_svg(const char *path); - void export_region_fill_surfaces_to_svg(const char *path); - void export_region_slices_to_svg_debug(const char *name); - void export_region_fill_surfaces_to_svg_debug(const char *name); + void export_region_slices_to_svg(const char *path) const; + void export_region_fill_surfaces_to_svg(const char *path) const; + void export_region_slices_to_svg_debug(const char *name) const; + void export_region_fill_surfaces_to_svg_debug(const char *name) const; }; %name{Slic3r::Layer} class Layer { -- cgit v1.2.3