Fade2D Documentation pages v2.16.8
Delaunay Features
GEOM_FADE2D::PolygonTree Class Reference

Represents the possibly nested layers of a polygon as a hierarchical structure. More...

#include <PolygonTree.h>

Public Member Functions

std::vector< PolygonTree * > & getChildren ()
 Retrieves the direct 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 globally 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...
 

Detailed Description

The PolygonTree organizes nested polygon layers as a hierarchical, tree-like structure.

A nested polygon on the left, and the corresponding PolygonTree on the right

Details

  • Hierarchical structure: Nested polygons are represented in a tree format, where each layer corresponds to a level in the hierarchy, progressing from the outermost to the innermost regions.
  • Layers: 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.

Member Function Documentation

◆ getChildren()

std::vector<PolygonTree*>& GEOM_FADE2D::PolygonTree::getChildren ( )

Returns the direct children of the current PolygonTree node as a vector of pointers.

Returns
A vector of pointers to the direct child PolygonTree nodes.

◆ getChildrenRecursive()

void GEOM_FADE2D::PolygonTree::getChildrenRecursive ( std::vector< PolygonTree * > &  vChildNodesRec)

Populates the provided vector with all descendant nodes of this PolygonTree node, traversing the hierarchy recursively.

Parameters
vChildNodesRecA vector to be filled with pointers to all descendant nodes.

◆ getLayer()

int GEOM_FADE2D::PolygonTree::getLayer ( ) const

Returns the layer number associated with the current PolygonTree node.

Returns
The layer number of this node.

Details

  • The root node has a layer number of -1 and does not contain any segments.
  • Direct children of the root (layer 0) represent the outermost segments. Multiple layer-0 nodes can exist for disjoint components of the polygon.
  • Child nodes of layer-0 nodes correspond to layer 1, representing the next inner layer, continuing inward for subsequent layers.

◆ getSegments_CCW()

void GEOM_FADE2D::PolygonTree::getSegments_CCW ( std::vector< Segment2 > &  vSegments) const

This method fills the provided vector with segments that are ordered and oriented in a globally counter-clockwise (CCW) direction.

Parameters
vSegmentsA vector to be filled with CCW-oriented segments.
Note
For hole-layers, globally counter-clockwise oriented segments differ from segments that are counter-clockwise oriented around inside-regions. Double-check your requirements: If you need segments oriented counter-clockwise around the inside-regions, call getSegments_regionOriented() instead.

◆ getSegments_CW()

void GEOM_FADE2D::PolygonTree::getSegments_CW ( std::vector< Segment2 > &  vSegments) const

This method fills the provided vector with segments ordered and oriented in a globally clockwise direction.

Parameters
vSegmentsA vector to be filled with CW-oriented segments.

◆ getSegments_regionOriented()

void GEOM_FADE2D::PolygonTree::getSegments_regionOriented ( std::vector< Segment2 > &  vSegments) const

Retrieves the segments of this node, oriented counter-clockwise around the inside regions of the polygon.

Polygon with hole: Layer 0 (outer hull) returns a counterclockwise polygon, while Layer 1 (hole) returns a globally clockwise oriented polygon.

Observe:

  • If the layer number is even, the layer represents a transition from 'air' to 'material', and its segments are returned in a globally counter-clockwise orientation.
  • If the layer number is odd, the layer represents a hole (a transition from 'material' back to 'air'). Consequently, its segments are globally clockwise oriented (to be counter-clockwise around the inside region).
Parameters
vSegmentsA vector to be filled with the region-oriented segments.

The documentation for this class was generated from the following file: