mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-12-05 11:17:58 -05:00
Speed up internal bridge detection over fully dense layers
This commit is contained in:
1 parent
b797ceb7fa
commit
0ad175c42b
4 files changed
+230
-2
No files matched your search
@@ -3039,6 +3039,32 @@ template<typename T> void debug_draw(std::string name, const T& a, const T& b, c
|
||||
}
|
||||
#endif
|
||||
|
||||
// Whether a fill surface of the layer with the given id prints at full density, by the density Fill.cpp gives its type, once
|
||||
// bridge_over_infill() and combine_infill() have run.
|
||||
static bool prints_dense(const Surface &surface, const PrintRegionConfig ®ion_config, const PrintObjectConfig &object_config, size_t layer_id)
|
||||
{
|
||||
switch (surface.surface_type) {
|
||||
case stInternal: return region_config.sparse_infill_density.value == 100;
|
||||
case stTop: return region_config.top_surface_density.value == 100;
|
||||
case stBottom: return region_config.bottom_surface_density.value == 100;
|
||||
case stBottomBridge: return region_config.bridge_density.value == 100;
|
||||
case stInternalSolid:
|
||||
// Elephant foot compensation thins it on the layers just above the first, and combining infill leaves voids below
|
||||
// the top layer of each group.
|
||||
if (region_config.infill_combination.value ||
|
||||
(object_config.elefant_foot_layers_density.value < 100 && layer_id > 0 &&
|
||||
layer_id <= size_t(object_config.elefant_foot_compensation_layers.value)))
|
||||
return false;
|
||||
// Where it lies over sparse infill, bridge_over_infill() turns it into an internal bridge.
|
||||
[[fallthrough]];
|
||||
case stInternalBridge:
|
||||
case stSecondInternalBridge:
|
||||
case stInternalAfterExternalBridge:
|
||||
return region_config.bridge_density.value == 100 && object_config.internal_bridge_density.value == 100;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
// This method applies bridge flow to the first internal solid layer above sparse infill.
|
||||
void PrintObject::bridge_over_infill()
|
||||
{
|
||||
@@ -3088,6 +3114,9 @@ void PrintObject::bridge_over_infill()
|
||||
// unsupported area will serve as a filter for polygons worth bridging.
|
||||
Polygons unsupported_area;
|
||||
Polygons lower_layer_solids;
|
||||
// Whether every fill surface of the lower layer prints at full density, which the early-out below needs. Kept
|
||||
// apart from the unchanged rule for what counts as a solid to expand.
|
||||
bool dense_below = true;
|
||||
for (const LayerRegion *region : layer->lower_layer->regions()) {
|
||||
Polygons fill_polys = to_polygons(region->fill_expolygons);
|
||||
// initially consider the whole layer unsupported, but also gather solid layers to later cut off supported parts
|
||||
@@ -3097,6 +3126,7 @@ void PrintObject::bridge_over_infill()
|
||||
Polygons p = to_polygons(surface.expolygon);
|
||||
lower_layer_solids.insert(lower_layer_solids.end(), p.begin(), p.end());
|
||||
}
|
||||
dense_below = dense_below && prints_dense(surface, region->region().config(), po->config(), layer->lower_layer->id());
|
||||
}
|
||||
}
|
||||
unsupported_area = closing(unsupported_area, float(SCALED_EPSILON));
|
||||
@@ -3110,10 +3140,15 @@ void PrintObject::bridge_over_infill()
|
||||
// By expanding the lower layer solids, we avoid making bridges from the tiny internal overhangs that are (very likely) supported by previous layer solids
|
||||
// NOTE that we cannot filter out polygons worth bridging by their area, because sometimes there is a very small internal island that will grow into large hole
|
||||
lower_layer_solids = shrink(lower_layer_solids, 1 * spacing); // first remove thin regions that will not support anything
|
||||
lower_layer_solids = expand(lower_layer_solids, (1 + expansion_multiplier) * spacing); // then expand back (opening), and further for parts supported by internal solids
|
||||
// By shrinking the unsupported area, we avoid making bridges from narrow ensuring region along perimeters.
|
||||
unsupported_area = shrink(unsupported_area, expansion_multiplier * spacing);
|
||||
unsupported_area = diff(unsupported_area, lower_layer_solids);
|
||||
// Then expand the solids back (opening), and further for parts supported by internal solids. Over a lower layer
|
||||
// printed at full density the expansion nearly always covers everything, which diff_expanded() proves at a
|
||||
// fraction of the cost. Where Clipper's own offset decimation folds a sliver of solid thinner than about 0.01
|
||||
// of the reach, about 16 µm here, its result may differ from the full expansion's; that is accepted.
|
||||
const float reach = float((1 + expansion_multiplier) * spacing);
|
||||
unsupported_area = dense_below ? diff_expanded(unsupported_area, lower_layer_solids, reach) :
|
||||
diff(unsupported_area, expand(lower_layer_solids, reach));
|
||||
|
||||
for (const LayerRegion *region : layer->regions()) {
|
||||
SurfacesPtr region_internal_solids = region->fill_surfaces.filter_by_type(stInternalSolid);
|
||||
|
||||
Reference in new issue
Block a user