The PolygonClipper class handles polygon repair operations. More...
#include <PolygonClipper.h>
Public Member Functions | |
PolygonClipper (const std::vector< Segment2 > &vSegments, double collapseDist) | |
Constructs a PolygonClipper object. More... | |
~PolygonClipper () | |
Destructor for the PolygonClipper class. | |
void | getOuterSegments_CCW (std::vector< Segment2 > &vOuterSegments_CCW) const |
Retrieves the outermost segments of the polygon in counter-clockwise direction. More... | |
PolygonTree * | getPolygonTree () |
Returnes the PolygonTree structure. More... | |
void | getSegments_regionOriented (std::vector< Segment2 > &vSegments_regionOriented) const |
Retrieves the inner and outer polygon segments oriented by region. More... | |
void | show (const std::string &name, const Color &matColor=Color(CYELLOW, 0, true), const Color airColor=Color(CWHITE, 0, false)) const |
Visualizes the polygon regions as a .PDF or PostScript file. More... | |
void | show (Visualizer2 *pVis, const Color &matColor=Color(CYELLOW, 0, true), const Color airColor=Color(CWHITE, 0, false)) const |
Visualizes the polygon regions as a .PDF or PostScript file. More... | |
The PolygonClipper class handles polygon repair operations.
This class processes a set of polygon segments. After optionally removing ultra-short segments, it resolves self-intersections and provides methods to retrieve the layers of the repaired polygon.
GEOM_FADE25D::PolygonClipper::PolygonClipper | ( | const std::vector< Segment2 > & | vSegments, |
double | collapseDist | ||
) |
Constructor: Initializes the clipper with a set of segments representing polygon edges and a collapse distance used to eliminate near-degenerate edges.
vSegments | A vector containing possibly intersecting polygon edges with no specific order or orientation. |
collapseDist | A threshold distance: Use a positive value to collapse edges shorter than this distance, -1 to automatically determine a tiny value for collapseDist based on the numeric uncertainty of the given coordinates, or 0 to retain all edges. |
void GEOM_FADE25D::PolygonClipper::getOuterSegments_CCW | ( | std::vector< Segment2 > & | vOuterSegments_CCW | ) | const |
This method fills the provided vector with the polygon's outer boundary segments, ordered and oriented in counter-clockwise (CCW) direction around the enclosed area. Segments inside this outer polygon, if any, are ignored.
Details:
vOuterSegments_CCW | A vector to be filled with the CCW-oriented outer boundary segments. |
PolygonTree* GEOM_FADE25D::PolygonClipper::getPolygonTree | ( | ) |
This method returns a pointer to a PolygonTree
object. This object represents the root node of the hierarchical PolygonTree structure for the repaired polygon. The structure can be analyzed layer by layer.
void GEOM_FADE25D::PolygonClipper::getSegments_regionOriented | ( | std::vector< Segment2 > & | vSegments_regionOriented | ) | const |
This method returns all layers of the polygon, oriented in a counter-clockwise direction around their adjacent inside regions. This way, the result is suitable as input for Fade_2D::createConstraint()
and for subsequent creation of a Zone2.
vSegments_regionOriented | A vector to be filled with the region-oriented segments. |
Key details
getPolygonTree()
and query it layer-by-layer. Each layer corresponds to one layer of the polygon, from outside to inside.void GEOM_FADE25D::PolygonClipper::show | ( | const std::string & | name, |
const Color & | matColor = Color(CYELLOW, 0, true) , |
||
const Color | airColor = Color(CWHITE, 0, false) |
||
) | const |
Generates a visualization of the polygon regions and saves it as a .PDF or PostScript file, depending on the file extension provided.
name | The output filename. Use .pdf or .ps as the file extension. |
matColor | The color used for the 'material' regions. Default is yellow. |
airColor | The color used for the 'air' regions. Default is white (transparent). |
void GEOM_FADE25D::PolygonClipper::show | ( | Visualizer2 * | pVis, |
const Color & | matColor = Color(CYELLOW, 0, true) , |
||
const Color | airColor = Color(CWHITE, 0, false) |
||
) | const |
Visualizes the polygon regions using a Visualizer2 object (PDF or PostScript file).
pVis | A pointer to a Visualizer2 object. |
matColor | The color used for the 'material' regions. Default is yellow. |
airColor | The color used for the 'air' regions. Default is white (transparent). |