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;
This commit is contained in:
bubnikv 2017-09-14 13:15:32 +02:00
parent 630b746cab
commit cd084a33c6
5 changed files with 30 additions and 30 deletions

View File

@ -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());

View File

@ -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; }

View File

@ -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<std::string, size_t> 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<std::string, size_t> idx_map;
size_t &idx = idx_map[name];

View File

@ -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");

View File

@ -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 {