The PolygonTree class represents nested polygon layers as a hierarchical structure. More...
#include <PolygonTree.h>
Public Member Functions | |
PolygonTree (int layer_) | |
Constructs a PolygonTree object. More... | |
~PolygonTree () | |
Destructor for the PolygonTree class. | |
std::vector< PolygonTree * > & | getChildren () |
Retrieves the child nodes of this PolygonTree node. More... | |
void | getChildrenRecursive (std::vector< PolygonTree * > &vChildNodesRec) |
Retrieves all child nodes recursively. More... | |
int | getLayer () const |
Retrieves the layer number of this PolygonTree node. More... | |
void | getSegments_CCW (std::vector< Segment2 > &vSegments) const |
Retrieves counter-clockwise ordered and oriented segments. More... | |
void | getSegments_CW (std::vector< Segment2 > &vSegments) const |
Retrieves clockwise ordered and oriented segments. More... | |
void | getSegments_regionOriented (std::vector< Segment2 > &vSegments) const |
Retrieves region-oriented segments. More... | |
The PolygonTree class represents nested polygon layers as a hierarchical structure.
This class organizes nested polygons in a tree-like format, where each layer of the tree corresponds to a polygon layer, progressing from the outermost to the innermost. The direct children of the root node represent layer 0, which corresponds to the outermost polygons (potentially multiple in case of disjoint components). The leaf nodes of the tree correspond to the innermost polygons.
|
explicit |
Constructs a PolygonTree object.
layer_ | The layer number this tree node represents. |
std::vector<PolygonTree*>& GEOM_FADE2D::PolygonTree::getChildren | ( | ) |
Retrieves the child nodes of this PolygonTree node.
void GEOM_FADE2D::PolygonTree::getChildrenRecursive | ( | std::vector< PolygonTree * > & | vChildNodesRec | ) |
Retrieves all child nodes recursively.
This method populates the provided vector with all child nodes of this PolygonTree node, traversing the tree recursively.
vChildNodesRec | A vector to be filled with the recursive child nodes. |
int GEOM_FADE2D::PolygonTree::getLayer | ( | ) | const |
Retrieves the layer number of this PolygonTree node.
The root node of the tree has a layer number of -1 and does not contain any segments. Its direct children, which have a layer number of 0, represent the outermost segments. There can be multiple layer-0 nodes for disjoint components of the polygon. The child nodes of the layer-0 nodes correspond to layer 1, representing the next inner layer, and so on.
void GEOM_FADE2D::PolygonTree::getSegments_CCW | ( | std::vector< Segment2 > & | vSegments | ) | const |
Retrieves counter-clockwise ordered and oriented segments.
This method populates the provided vector with segments ordered and oriented in a counter-clockwise direction.
vSegments | A vector to be filled with CCW-oriented segments. |
void GEOM_FADE2D::PolygonTree::getSegments_CW | ( | std::vector< Segment2 > & | vSegments | ) | const |
Retrieves clockwise ordered and oriented segments.
This method fills the provided vector with segments ordered and oriented in a clockwise direction.
vSegments | A vector to be filled with CW-oriented segments. |
void GEOM_FADE2D::PolygonTree::getSegments_regionOriented | ( | std::vector< Segment2 > & | vSegments | ) | const |
Retrieves region-oriented segments.
The boundary layer (layer 0) of a polygon defines a transition from empty space to filled area (or from 'air' to 'material'). If a polygon contains a nested polygon, it defines a hole; the hole polygons of layer 1 indicate a transition from material back to air. More generally, considering multiple nested polygon layers from outside to inside signifies alternating transitions between air and material. Even layers represent borders from air to material, while odd layers represent borders to holes ('air') within that material.
This method returns the segments of the current layer, ordered and oriented counter-clockwise around the adjacent 'material' region. Consequently, segments from even polygon layers are oriented counter-clockwise, while those from odd layers are oriented clockwise.
vSegments | A vector to be filled with the region-oriented segments. |