Performance improvement in G-code export for support material

in suppression of retracts when traveling over support regions.
This commit is contained in:
Vojtech Bubnik 2022-08-18 10:45:18 +02:00
parent 01031779b7
commit c03085a1f6
3 changed files with 29 additions and 11 deletions

View file

@ -3134,15 +3134,26 @@ bool GCode::needs_retraction(const Polyline &travel, ExtrusionRole role)
return false; return false;
} }
if (role == erSupportMaterial) { if (role == erSupportMaterial)
const SupportLayer* support_layer = dynamic_cast<const SupportLayer*>(m_layer); if (const SupportLayer *support_layer = dynamic_cast<const SupportLayer*>(m_layer);
//FIXME support_layer->support_islands.contains should use some search structure! support_layer != nullptr && ! support_layer->support_islands_bboxes.empty()) {
if (support_layer != NULL && ! intersection_pl(travel, support_layer->support_islands).empty()) BoundingBox bbox_travel = get_extents(travel);
// skip retraction if this is a travel move inside a support material island Polylines trimmed;
//FIXME not retracting over a long path may cause oozing, which in turn may result in missing material bool trimmed_initialized = false;
// at the end of the extrusion path! for (const BoundingBox &bbox : support_layer->support_islands_bboxes)
return false; if (bbox.overlap(bbox_travel)) {
} const auto &island = support_layer->support_islands[&bbox - support_layer->support_islands_bboxes.data()];
trimmed = trimmed_initialized ? diff_pl(trimmed, island) : diff_pl(travel, island);
trimmed_initialized = true;
if (trimmed.empty())
// skip retraction if this is a travel move inside a support material island
//FIXME not retracting over a long path may cause oozing, which in turn may result in missing material
// at the end of the extrusion path!
return false;
// Not sure whether updating the boudning box isn't too expensive.
//bbox_travel = get_extents(trimmed);
}
}
if (m_config.only_retract_when_crossing_perimeters && m_layer != nullptr && if (m_config.only_retract_when_crossing_perimeters && m_layer != nullptr &&
m_config.fill_density.value > 0 && m_layer->any_internal_region_slice_contains(travel)) m_config.fill_density.value > 0 && m_layer->any_internal_region_slice_contains(travel))

View file

@ -197,6 +197,8 @@ public:
// Polygons covered by the supports: base, interface and contact areas. // Polygons covered by the supports: base, interface and contact areas.
// Used to suppress retraction if moving for a support extrusion over these support_islands. // Used to suppress retraction if moving for a support extrusion over these support_islands.
ExPolygons support_islands; ExPolygons support_islands;
// Slightly inflated bounding boxes of the above, for faster intersection query.
std::vector<BoundingBox> support_islands_bboxes;
// Extrusion paths for the support base and for the support interface and contacts. // Extrusion paths for the support base and for the support interface and contacts.
ExtrusionEntityCollection support_fills; ExtrusionEntityCollection support_fills;

View file

@ -4312,8 +4312,13 @@ void generate_support_toolpaths(
// Order the layers by lexicographically by an increasing print_z and a decreasing layer height. // Order the layers by lexicographically by an increasing print_z and a decreasing layer height.
std::stable_sort(layer_cache_item.overlapping.begin(), layer_cache_item.overlapping.end(), [](auto *l1, auto *l2) { return *l1 < *l2; }); std::stable_sort(layer_cache_item.overlapping.begin(), layer_cache_item.overlapping.end(), [](auto *l1, auto *l2) { return *l1 < *l2; });
} }
if (! polys.empty()) assert(support_layer.support_islands.empty());
expolygons_append(support_layer.support_islands, union_ex(polys)); if (! polys.empty()) {
support_layer.support_islands = union_ex(polys);
support_layer.support_islands_bboxes.reserve(support_layer.support_islands.size());
for (const ExPolygon &expoly : support_layer.support_islands)
support_layer.support_islands_bboxes.emplace_back(get_extents(expoly).inflated(SCALED_EPSILON));
}
} // for each support_layer_id } // for each support_layer_id
}); });