Added cancellation to Lightning infill.
This commit is contained in:
parent
78f62bfddc
commit
11004b4bbd
7 changed files with 25 additions and 18 deletions
|
@ -25,7 +25,7 @@
|
|||
|
||||
namespace Slic3r::FillLightning {
|
||||
|
||||
Generator::Generator(const PrintObject &print_object)
|
||||
Generator::Generator(const PrintObject &print_object, const std::function<void()> &throw_on_cancel_callback)
|
||||
{
|
||||
const PrintConfig &print_config = print_object.print()->config();
|
||||
const PrintObjectConfig &object_config = print_object.config();
|
||||
|
@ -47,11 +47,11 @@ Generator::Generator(const PrintObject &print_object)
|
|||
m_prune_length = coord_t(layer_thickness * std::tan(lightning_infill_prune_angle));
|
||||
m_straightening_max_distance = coord_t(layer_thickness * std::tan(lightning_infill_straightening_angle));
|
||||
|
||||
generateInitialInternalOverhangs(print_object);
|
||||
generateTrees(print_object);
|
||||
generateInitialInternalOverhangs(print_object, throw_on_cancel_callback);
|
||||
generateTrees(print_object, throw_on_cancel_callback);
|
||||
}
|
||||
|
||||
void Generator::generateInitialInternalOverhangs(const PrintObject &print_object)
|
||||
void Generator::generateInitialInternalOverhangs(const PrintObject &print_object, const std::function<void()> &throw_on_cancel_callback)
|
||||
{
|
||||
m_overhang_per_layer.resize(print_object.layers().size());
|
||||
// FIXME: It can be adjusted to improve bonding between infill and perimeters.
|
||||
|
@ -59,7 +59,8 @@ void Generator::generateInitialInternalOverhangs(const PrintObject &print_object
|
|||
|
||||
Polygons infill_area_above;
|
||||
//Iterate from top to bottom, to subtract the overhang areas above from the overhang areas on the layer below, to get only overhang in the top layer where it is overhanging.
|
||||
for (int layer_nr = int(print_object.layers().size()) - 1; layer_nr >= 0; layer_nr--) {
|
||||
for (int layer_nr = int(print_object.layers().size()) - 1; layer_nr >= 0; --layer_nr) {
|
||||
throw_on_cancel_callback();
|
||||
Polygons infill_area_here;
|
||||
for (const LayerRegion* layerm : print_object.get_layer(layer_nr)->regions())
|
||||
for (const Surface& surface : layerm->fill_surfaces.surfaces)
|
||||
|
@ -80,7 +81,7 @@ const Layer& Generator::getTreesForLayer(const size_t& layer_id) const
|
|||
return m_lightning_layers[layer_id];
|
||||
}
|
||||
|
||||
void Generator::generateTrees(const PrintObject &print_object)
|
||||
void Generator::generateTrees(const PrintObject &print_object, const std::function<void()> &throw_on_cancel_callback)
|
||||
{
|
||||
m_lightning_layers.resize(print_object.layers().size());
|
||||
// FIXME: It can be adjusted to improve bonding between infill and perimeters.
|
||||
|
@ -89,11 +90,13 @@ void Generator::generateTrees(const PrintObject &print_object)
|
|||
std::vector<Polygons> infill_outlines(print_object.layers().size(), Polygons());
|
||||
|
||||
// For-each layer from top to bottom:
|
||||
for (int layer_id = int(print_object.layers().size()) - 1; layer_id >= 0; layer_id--)
|
||||
for (int layer_id = int(print_object.layers().size()) - 1; layer_id >= 0; layer_id--) {
|
||||
throw_on_cancel_callback();
|
||||
for (const LayerRegion *layerm : print_object.get_layer(layer_id)->regions())
|
||||
for (const Surface &surface : layerm->fill_surfaces.surfaces)
|
||||
if (surface.surface_type == stInternal || surface.surface_type == stInternalVoid)
|
||||
append(infill_outlines[layer_id], infill_wall_offset == 0 ? surface.expolygon : offset(surface.expolygon, infill_wall_offset));
|
||||
}
|
||||
|
||||
// For various operations its beneficial to quickly locate nearby features on the polygon:
|
||||
const size_t top_layer_id = print_object.layers().size() - 1;
|
||||
|
@ -102,6 +105,7 @@ void Generator::generateTrees(const PrintObject &print_object)
|
|||
|
||||
// For-each layer from top to bottom:
|
||||
for (int layer_id = int(top_layer_id); layer_id >= 0; layer_id--) {
|
||||
throw_on_cancel_callback();
|
||||
Layer ¤t_lightning_layer = m_lightning_layers[layer_id];
|
||||
const Polygons ¤t_outlines = infill_outlines[layer_id];
|
||||
const BoundingBox ¤t_outlines_bbox = get_extents(current_outlines);
|
||||
|
@ -109,7 +113,7 @@ void Generator::generateTrees(const PrintObject &print_object)
|
|||
// register all trees propagated from the previous layer as to-be-reconnected
|
||||
std::vector<NodeSPtr> to_be_reconnected_tree_roots = current_lightning_layer.tree_roots;
|
||||
|
||||
current_lightning_layer.generateNewTrees(m_overhang_per_layer[layer_id], current_outlines, current_outlines_bbox, outlines_locator, m_supporting_radius, m_wall_supporting_radius);
|
||||
current_lightning_layer.generateNewTrees(m_overhang_per_layer[layer_id], current_outlines, current_outlines_bbox, outlines_locator, m_supporting_radius, m_wall_supporting_radius, throw_on_cancel_callback);
|
||||
current_lightning_layer.reconnectRoots(to_be_reconnected_tree_roots, current_outlines, current_outlines_bbox, outlines_locator, m_supporting_radius, m_wall_supporting_radius);
|
||||
|
||||
// Initialize trees for next lower layer from the current one.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue