![]() |
Prusa Slicer 2.6.0
|
#include <src/libslic3r/Fill/Lightning/TreeNode.hpp>
Inheritance diagram for Slic3r::FillLightning::Node:
Collaboration diagram for Slic3r::FillLightning::Node:Classes | |
| struct | RectilinearJunction |
Public Member Functions | |
| const Point & | getLocation () const |
| void | setLocation (const Point &p) |
| NodeSPtr | addChild (const Point &p) |
| NodeSPtr | addChild (NodeSPtr &new_child) |
| void | propagateToNextLayer (std::vector< NodeSPtr > &next_trees, const Polygons &next_outlines, const EdgeGrid::Grid &outline_locator, coord_t prune_distance, coord_t smooth_magnitude, coord_t max_remove_colinear_dist) const |
| void | visitBranches (const std::function< void(const Point &, const Point &)> &visitor) const |
| void | visitNodes (const std::function< void(NodeSPtr)> &visitor) |
| coord_t | getWeightedDistance (const Point &unsupported_location, const coord_t &supporting_radius) const |
| bool | isRoot () const |
| void | reroot (const NodeSPtr &new_parent=nullptr) |
| NodeSPtr | closestNode (const Point &loc) |
| bool | hasOffspring (const NodeSPtr &to_be_checked) const |
| Node ()=delete | |
| void | convertToPolylines (Polylines &output, coord_t line_overlap) const |
| const std::optional< Point > & | getLastGroundingLocation () const |
Static Public Member Functions | |
| template<typename ... Arg> | |
| static NodeSPtr | create (Arg &&...arg) |
Protected Member Functions | |
| Node (const Point &p, const std::optional< Point > &last_grounding_location=std::nullopt) | |
| NodeSPtr | deepCopy () const |
| bool | realign (const Polygons &outlines, const EdgeGrid::Grid &outline_locator, std::vector< NodeSPtr > &rerooted_parts) |
| void | straighten (coord_t magnitude, coord_t max_remove_colinear_dist) |
| RectilinearJunction | straighten (coord_t magnitude, const Point &junction_above, coord_t accumulated_dist, int64_t max_remove_colinear_dist2) |
| coord_t | prune (const coord_t &distance) |
| void | convertToPolylines (size_t long_line_idx, Polylines &output) const |
| void | removeJunctionOverlap (Polylines &polylines, coord_t line_overlap) const |
Protected Attributes | |
| bool | m_is_root |
| Point | m_p |
| std::weak_ptr< Node > | m_parent |
| std::vector< NodeSPtr > | m_children |
| std::optional< Point > | m_last_grounding_location |
Friends | |
| BoundingBox | get_extents (const NodeSPtr &root_node) |
| BoundingBox | get_extents (const std::vector< NodeSPtr > &tree_roots) |
A single vertex of a Lightning Tree, the structure that determines the paths to be printed to form Lightning Infill.
In essence these vertices are just a position linked to other positions in 2D. The nodes have a hierarchical structure of parents and children, forming a tree. The class also has some helper functions specific to Lightning Infill e.g. to straighten the paths around this node.
| struct Slic3r::FillLightning::Node::RectilinearJunction |
|
delete |
|
explicitprotected |
Construct a new node, either for insertion in a tree or as root.
| p | The physical location in the 2D layer that this node represents. Connecting other nodes to this node indicates that a line segment should be drawn between those two physical positions. |
Construct a new Node instance and add it as a child of this node.
| p | The location of the new node. |
References addChild(), create(), and m_p.
Referenced by addChild().
Here is the call graph for this function:
Here is the caller graph for this function:Add an existing Node as a child of this node.
| new_child | The node that must be added as a child. |
new_child. References m_children.
Retrieves the closest node to the specified location.
| loc | The specified location. |
References m_children, and m_p.
| void Slic3r::FillLightning::Node::convertToPolylines | ( | Polylines & | output, |
| coord_t | line_overlap | ||
| ) | const |
Convert the tree into polylines
At each junction one line is chosen at random to continue
The lines start at a leaf and end in a junction
| output | all branches in this tree connected into polylines |
References Slic3r::append().
Referenced by convertToPolylines().
Here is the call graph for this function:
Here is the caller graph for this function:
|
protected |
Convert the tree into polylines
At each junction one line is chosen at random to continue
The lines start at a leaf and end in a junction
| long_line | a reference to a polyline in output which to continue building on in the recursion |
| output | all branches in this tree connected into polylines |
References convertToPolylines().
Here is the call graph for this function:
|
inlinestatic |
References arg().
Referenced by addChild(), and deepCopy().
Here is the call graph for this function:
Here is the caller graph for this function:
|
protected |
Copy this node and its entire sub-tree.
References create(), m_children, m_is_root, m_last_grounding_location, and m_p.
Referenced by propagateToNextLayer().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
If this was ever a direct child of the root, it'll have a previous grounding location.
This needs to be known when roots are reconnected, so that the last (higher) layer is supported by the next one.
References m_last_grounding_location.
Get the position on this layer that this node represents, a vertex of the path to print.
References m_p.
Referenced by getWeightedDistance().
Here is the caller graph for this function:| coord_t Slic3r::FillLightning::Node::getWeightedDistance | ( | const Point & | unsupported_location, |
| const coord_t & | supporting_radius | ||
| ) | const |
Get a weighted distance from an unsupported point to this node (given the current supporting radius).
When attaching a unsupported location to a node, not all nodes have the same priority. (Eucludian) closer nodes are prioritised, but that's not the whole story. For instance, we give some nodes a 'valence boost' depending on the nr. of branches.
| unsupported_location | The (unsuppported) location of which the weighted distance needs to be calculated. |
| supporting_radius | The maximum distance which can be bridged without (infill) supporting it. |
References getLocation(), m_children, and m_is_root.
Here is the call graph for this function:Returns whether the given tree node is a descendant of this node.
If this node itself is given, it is also considered to be a descendant.
| to_be_checked | A node to find out whether it is a descendant of this node. |
true if the given node is a descendant or this node itself, or false if it is not in the sub-tree. References m_children.
|
inline |
| void Slic3r::FillLightning::Node::propagateToNextLayer | ( | std::vector< NodeSPtr > & | next_trees, |
| const Polygons & | next_outlines, | ||
| const EdgeGrid::Grid & | outline_locator, | ||
| coord_t | prune_distance, | ||
| coord_t | smooth_magnitude, | ||
| coord_t | max_remove_colinear_dist | ||
| ) | const |
Propagate this node's sub-tree to the next layer.
Creates a copy of this tree, realign it to the new layer boundaries next_outlines and reduce (i.e. prune and straighten) it. A copy of this node and all of its descendant nodes will be added to the next_trees vector.
| next_trees | A collection of tree nodes to use for the next layer. |
| next_outlines | The shape of the layer below, to make sure that the tree stays within the bounds of the infill area. |
| prune_distance | The maximum distance that a leaf node may be moved such that it still supports the current node. |
| smooth_magnitude | The maximum distance that a line may be shifted to straighten the tree's paths, such that it still supports the current paths. |
| max_remove_colinear_dist | The maximum distance of a line-segment from which straightening may remove a colinear point. |
References deepCopy().
Here is the call graph for this function:Prune the tree from the extremeties (leaf-nodes) until the pruning distance is reached.
distance, then the whole tree was puned away.
|
protected |
Reconnect trees from the layer above to the new outlines of the lower layer.
References Slic3r::contains(), m_children, m_last_grounding_location, and m_p.
Here is the call graph for this function:
|
protected |
References Slic3r::MultiPoint::back(), Slic3r::MultiPoint::points, and Slic3r::MultiPoint::size().
Here is the call graph for this function:Reverse the parent-child relationship all the way to the root, from this node onward. This has the effect of 're-rooting' the tree at the current node if no immediate parent is given as argument. That is, the current node will become the root, it's (former) parent if any, will become one of it's children. This is then recursively bubbled up until it reaches the (former) root, which then will become a leaf.
| new_parent | The (new) parent-node of the root, useful for recursing or immediately attaching the node to another tree. |
References m_children, m_is_root, and m_parent.
|
protected |
Recursive part of straighten(.)
| junction_above | The last seen junction with multiple children above |
| accumulated_dist | The distance along the tree from the last seen junction to this node |
| max_remove_colinear_dist2 | Maximum distance squared of the (compound) line-segment from which a co-linear point may be removed. |
References Slic3r::Line::distance_to_squared(), Slic3r::FillLightning::Node::RectilinearJunction::junction_loc, and Slic3r::FillLightning::Node::RectilinearJunction::total_recti_dist.
Here is the call graph for this function:
|
protected |
Smoothen the tree to make it a bit more printable, while still supporting the trees above.
| magnitude | The maximum allowed distance to move the node. |
| max_remove_colinear_dist | Maximum distance of the (compound) line-segment from which a co-linear point may be removed. |
| void Slic3r::FillLightning::Node::visitBranches | ( | const std::function< void(const Point &, const Point &)> & | visitor | ) | const |
Executes a given function for every line segment in this node's sub-tree.
The function takes two Point arguments. These arguments will be filled in with the higher-order node (closer to the root) first, and the downtree node (closer to the leaves) as the second argument. The segment from this node's parent to this node itself is not included. The order in which the segments are visited is depth-first.
| visitor | A function to execute for every branch in the node's sub- tree. |
References m_children, and m_p.
Execute a given function for every node in this node's sub-tree.
The visitor function takes a node as input. This node is not const, so this can be used to change the tree. Nodes are visited in depth-first order. This node itself is visited as well (pre-order).
| visitor | A function to execute for every node in this node's sub- tree. |
References m_children.
|
friend |
|
friend |
|
protected |
Referenced by addChild(), closestNode(), deepCopy(), getWeightedDistance(), hasOffspring(), realign(), reroot(), visitBranches(), and visitNodes().
|
protected |
Referenced by deepCopy(), getWeightedDistance(), isRoot(), and reroot().
|
protected |
Referenced by deepCopy(), getLastGroundingLocation(), and realign().
|
protected |
Referenced by addChild(), closestNode(), deepCopy(), getLocation(), realign(), setLocation(), and visitBranches().