Skip to content

Commit

Permalink
Cleanup and bug fixes
Browse files Browse the repository at this point in the history
Moved needs_bridge_over_infill() to LayerRegion and fixed two bugs I introduced when I extracted it from my local tree.
  • Loading branch information
jschuh committed Oct 17, 2020
1 parent 304850a commit 25a4a8c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/libslic3r/Layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class LayerRegion
void make_perimeters(const SurfaceCollection &slices, SurfaceCollection* fill_surfaces);
void process_external_surfaces(const Layer *lower_layer, const Polygons *lower_layer_covered);
double infill_area_threshold() const;
// True if infill voids (computed from infill_density) are larger than bridge_infill_threshold.
bool needs_bridge_over_infill() const;
// Trim surfaces by trimming polygons. Used by the elephant foot compensation at the 1st layer.
void trim_surfaces(const Polygons &trimming_polygons);
// Single elephant foot compensation step, used by the elephant foor compensation at the 1st layer.
Expand Down
11 changes: 11 additions & 0 deletions src/libslic3r/LayerRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,17 @@ double LayerRegion::infill_area_threshold() const
return ss*ss;
}

bool LayerRegion::needs_bridge_over_infill() const
{
auto region_config = region()->config();
if (region_config.fill_density <= 0)
return true;
const double infill_extrusion_width = flow(frInfill).width;
// Compute the unsupported area assuming a grid, which is pragmatically good enough for all infill types.
const double bridging_area = pow<double>(2.0 * 100.0 * infill_extrusion_width / region_config.fill_density - infill_extrusion_width, 2);
return bridging_area > region_config.bridge_infill_threshold;
}

void LayerRegion::trim_surfaces(const Polygons &trimming_polygons)
{
#ifndef NDEBUG
Expand Down
2 changes: 0 additions & 2 deletions src/libslic3r/Print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ class PrintRegion
coordf_t nozzle_dmr_avg(const PrintConfig &print_config) const;
// Average diameter of nozzles participating on extruding this region.
coordf_t bridging_height_avg(const PrintConfig &print_config) const;
// True if infill voids (computed from infill_density) are larger than bridge_infill_threshold.
bool needs_bridge_over_infill() const;

// Collect 0-based extruder indices used to print this region's object.
void collect_object_printing_extruders(std::vector<unsigned int> &object_extruders) const;
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/PrintObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@ void PrintObject::bridge_over_infill()
for (LayerRegion* lower_layerm : lower_layer->m_regions) {
auto surfaces = lower_layerm->fill_surfaces.surfaces;
for (Surfaces::iterator surface = surfaces.begin(); surface != surfaces.end(); ++surface) {
if (surface->surface_type == stInternal && layerm->region()->needs_bridge_over_infill()) {
if (surface->surface_type == stInternal && layerm->needs_bridge_over_infill()) {
Polygons pp = surface->expolygon;
lower_internal.insert(lower_internal.end(), pp.begin(), pp.end());
}
Expand Down
11 changes: 0 additions & 11 deletions src/libslic3r/PrintRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,6 @@ coordf_t PrintRegion::bridging_height_avg(const PrintConfig &print_config) const
return this->nozzle_dmr_avg(print_config) * sqrt(m_config.bridge_flow_ratio.value);
}

bool PrintRegion::needs_bridge_over_infill() const
{
if (config().fill_density <= 0)
return false;
const double infill_extrusion_width = Flow::new_from_config_width(frInfill, m_config.infill_extrusion_width,
m_print->config().nozzle_diameter.get_at(extruder(frInfill) - 1), 0.2f, 0.f).width;
// Compute the unsupported area assuming a grid, which is pragmatically good enough for all infill types.
const double bridging_area = pow<double>(2.0 * 100.0 * infill_extrusion_width / config().fill_density - infill_extrusion_width, 2);
return bridging_area > config().bridge_infill_threshold;
}

void PrintRegion::collect_object_printing_extruders(const PrintConfig &print_config, const PrintRegionConfig &region_config, std::vector<unsigned int> &object_extruders)
{
// These checks reflect the same logic used in the GUI for enabling/disabling extruder selection fields.
Expand Down

0 comments on commit 25a4a8c

Please sign in to comment.