Fade_2D is a class that contains a Delaunay triangulation. More...
#include <Fade_2D.h>
Public Member Functions | |
Fade_2D (Fade_2D &other, std::vector< Zone2 * > vZoneIn=std::vector< Zone2 * >(), std::vector< Zone2 * > vZoneOut=std::vector< Zone2 * >()) | |
Copy constructor. More... | |
Fade_2D (unsigned numExpectedVertices=3) | |
Constructor of the triangulation class. More... | |
~Fade_2D () | |
Destructor. | |
void | applyConstraintsAndZones () |
Apply conforming constraints and zones (deprecated!) More... | |
bool | checkValidity (bool bCheckEmptyCircleProperty, const char *msg) const |
Checks the validity of the triangulation. More... | |
Bbox2 | computeBoundingBox () const |
Computes the axis-aligned bounding box of the triangulation. More... | |
ConstraintGraph2 * | createConstraint (std::vector< Segment2 > &vSegments, ConstraintInsertionStrategy cis, bool bOrientedSegments=false) |
Insert constraint edges (edges, polyline or polygon) . More... | |
Zone2 * | createZone (const std::vector< ConstraintGraph2 * > &vConstraintGraphs, ZoneLocation zoneLoc, const Point2 &startPoint, bool bVerbose=true) |
Create a Zone2 bounded by multiple ConstraintGraph2 objects by growing from a seed point. More... | |
Zone2 * | createZone (ConstraintGraph2 *pConstraintGraph, ZoneLocation zoneLoc, bool bVerbose=true) |
Create a Zone2 . More... | |
Zone2 * | createZone (ConstraintGraph2 *pConstraintGraph, ZoneLocation zoneLoc, const Point2 &startPoint, bool bVerbose=true) |
Create a Zone2 bounded by a ConstraintGraph2 object by growing from a seed point. More... | |
Zone2 * | createZone (std::vector< Triangle2 * > &vTriangles, bool bVerbose=true) |
Create a Zone2 defined by a vector of triangles. More... | |
Zone2 * | createZone_cookieCutter (std::vector< Segment2 > &vSegments, bool bProtectEdges) |
Cookie Cutter (deprecated) More... | |
Zone2 * | createZone_cookieCutter (std::vector< Segment2 > &vSegments, bool bProtectEdges, ConstraintGraph2 *&pProtectedEdgesCG, ConstraintGraph2 *&pBoundaryCG) |
Cookie Cutter (deprecated) More... | |
Zone2 * | createZone_cookieCutter2 (std::vector< Segment2 > &vSegments, bool bProtectEdges) |
Cookie Cutter2. More... | |
Zone2 * | createZone_cookieCutter2 (std::vector< Segment2 > &vSegments, bool bProtectEdges, ConstraintGraph2 *&pProtectedEdgesCG, ConstraintGraph2 *&pBoundaryCG) |
Cookie Cutter2. More... | |
void | cutTriangles (const Point2 &knifeStart, const Point2 &knifeEnd, bool bTurnEdgesIntoConstraints) |
Cut through a triangulation. More... | |
void | cutTriangles (std::vector< Segment2 > &vSegments, bool bTurnEdgesIntoConstraints) |
Cut through a triangulation. More... | |
void | deleteConstraintsAndZones () |
Deletes all constraints and zones. More... | |
void | deleteZone (Zone2 *pZone) |
Delete a Zone2 object. More... | |
bool | drape (std::vector< Segment2 > &vSegmentsIn, std::vector< Segment2 > &vSegmentsOut, double offTolerance=0.0, bool bKeepOffSegments=false) const |
Drape segments onto a surface. More... | |
void | exportTriangulation (FadeExport &fadeExport, bool bWithCustomIndices, bool bClear) |
Export triangulation data. More... | |
Triangle2 * | getAdjacentTriangle (Point2 *p0, Point2 *p1) const |
Get the adjacent triangle of an oriented edge. More... | |
void | getAliveAndDeadConstraintSegments (std::vector< ConstraintSegment2 * > &vAllConstraintSegments) const |
Get all (alive and dead) constraint segments. | |
void | getAliveConstraintSegments (std::vector< ConstraintSegment2 * > &vAliveConstraintSegments) const |
Get active (alive) constraint segments. More... | |
ConstraintSegment2 * | getConstraintSegment (Point2 *p0, Point2 *p1) const |
Retrieve a ConstraintSegment2. More... | |
void | getConvexHull (bool bAllVertices, std::vector< Point2 * > &vConvexHullPointsOut) |
Compute the convex hull. More... | |
void | getDirectedEdges (std::vector< Edge2 > &vDirectedEdgesOut) const |
Get directed edges Edges are counterclockwise oriented around their triangle. The present method returns directed edges. That means each edge(a,b) is returend twice, as edge(a,b) and as edge(b,a). | |
void | getIncidentTriangles (Point2 *pVtx, std::vector< Triangle2 * > &vIncidentT) const |
Get incident triangles. More... | |
void | getIncidentVertices (Point2 *pVtx, std::vector< Point2 * > &vAdjVtx) const |
Get adjacent vertices. More... | |
double | getMedianEdgeLength2D () |
Get the median 2D edge length. More... | |
Point2 * | getNearestNeighbor (const Point2 &p) |
Get nearest neighbor. More... | |
Orientation2 | getOrientation (const Point2 &p0, const Point2 &p1, const Point2 &p2) |
Compute the orientation of 3 points. More... | |
void | getTrianglePointers (std::vector< Triangle2 * > &vAllTriangles) const |
Get pointers to all triangles. More... | |
void | getUndirectedEdges (std::vector< Edge2 > &vUndirectedEdgesOut) const |
Get undirected edges. More... | |
Point2 * | getVertexPointer (const Point2 &p) |
Get vertex pointer. More... | |
void | getVertexPointers (std::vector< Point2 * > &vAllPoints) const |
Get pointers to all vertices. More... | |
Voronoi2 * | getVoronoiDiagram () |
Get the Voronoi diagram of the triangulation. More... | |
void | getZones (std::vector< Zone2 * > &vZones) const |
Retrieves all zones of the triangulation. More... | |
bool | hasArea () const |
Check if the triangulation contains any triangles. More... | |
Zone2 * | importTriangles (std::vector< Point2 > &vPoints, bool bReorientIfNeeded, bool bCreateExtendedBoundingBox) |
Import Triangles (deprecated in favor of the robust version) More... | |
Zone2 * | importTriangles_robust (std::vector< Point2 > &vPoints) |
Import Triangles - Robust (Error-tolerant version) More... | |
Point2 * | insert (const Point2 &p) |
Insert a single point. More... | |
void | insert (const std::vector< Point2 > &vInputPoints) |
Insert a vector of points. More... | |
void | insert (const std::vector< Point2 > &vInputPoints, std::vector< Point2 * > &vHandles) |
Insert points from a std::vector<Point2> and store pointers in vHandles . More... | |
void | insert (int numPoints, double *aCoordinates, Point2 **aHandles) |
Insert points from an array. More... | |
bool | isConstraint (Point2 *p0, Point2 *p1) const |
Check if an edge is a constraint edge. More... | |
bool | isConstraint (Point2 *pVtx) const |
Check if a vertex is a constraint vertex. More... | |
bool | isConstraint (Triangle2 *pT, int ith) const |
Check if an edge is a constraint edge. More... | |
bool | load (const char *filename, std::vector< Zone2 * > &vZones) |
Load a triangulation from a binary file. More... | |
bool | load (std::istream &stream, std::vector< Zone2 * > &vZones) |
Load a triangulation from a binary file. More... | |
Triangle2 * | locate (const Point2 &p) |
Locate a triangle that contains p. More... | |
double | measureTriangulationTime (const std::vector< Point2 > &vPoints) |
Measure the Delaunay triangulation time. More... | |
size_t | numberOfPoints () const |
Number of points. More... | |
size_t | numberOfTriangles () const |
Number of triangles. More... | |
void | printLicense () const |
Prints license information. | |
void | refine (Zone2 *pZone, double minAngleDegree, double minEdgeLength, double maxEdgeLength, bool bAllowConstraintSplitting) |
Delaunay refinement. More... | |
void | refineAdvanced (MeshGenParams *pParameters) |
Delaunay refinement and grid meshing. More... | |
void | remove (Point2 *pVertex) |
Remove a single vertex. More... | |
void | remove (std::vector< Point2 * > &vPoints) |
Remove vertices. More... | |
Zone2 * | replicateZoneBoundary (Zone2 *pZoneIn) |
Replicate the boundaries of a zone in the current Fade_2D instance. More... | |
void | reset () |
Reset the triangulation. More... | |
bool | saveTriangulation (const char *filename, std::vector< Zone2 * > &vSaveZones) |
Save a triangulation to a binary file. More... | |
bool | saveTriangulation (std::ostream &stream, std::vector< Zone2 * > &vSaveZones) |
Save a triangulation to a binary file. More... | |
bool | saveZones (const char *filename, std::vector< Zone2 * > &vSaveZones) |
Save zones to a binary file. More... | |
bool | saveZones (std::ostream &stream, std::vector< Zone2 * > &vSaveZones) |
Save zones to a binary file. More... | |
void | setFastMode (bool bFast) |
Set fast mode. More... | |
int | setNumCPU (int numCPU) |
Set the number of CPU cores for multithreading (deprecated) More... | |
void | show (const char *filename, bool bWithConstraints=true) const |
Draws the triangulation as a PostScript or PDF file. More... | |
void | show (Visualizer2 *pVis, bool bWithConstraints=true) const |
Draws the triangulation as a PostScript or PDF file. More... | |
void | showVtk (const char *filename, VtkColor color, VtkColor constraintColor=VTK_TRANSPARENT) const |
Draws the triangulation using the VTK file format. More... | |
void | showVtk (VtkWriter *pVtkWriter, VtkColor color, VtkColor constraintColor=VTK_TRANSPARENT) const |
Draws the triangulation using the VTK file format. More... | |
void | statistics (const char *s) const |
Statistics. More... | |
void | subscribe (MsgType msgType, MsgBase *pMsg) |
Registers a message receiver. More... | |
void | unsubscribe (MsgType msgType, MsgBase *pMsg) |
Unregisters a message receiver. More... | |
void | writeObj (const char *filename) const |
Write the current triangulation to an .obj file. More... | |
void | writeObj (const char *filename, Zone2 *pZone) const |
Write a Zone2 an .obj file. More... | |
void | writeWebScene (const char *path) const |
Create a scene of a triangulation that can be viewed in a web browser. More... | |
void | writeWebScene (const char *path, Zone2 *pZone) const |
Create a scene of a Zone2 that can be viewed in a web browser. More... | |
The library comes in two versions: 2D and 2.5D. The 2D version computes classic Delaunay triangulations in the xy-plane, while the 2.5D version includes a z-coordinate and provides additional algorithms for lifted triangulations.
You are currently viewing the 2D documentation. If you are interested in lifted triangulations, you can switch to the 2.5D documentation.
|
explicit |
numExpectedVertices | The number of points that will be inserted. This is an optional parameter. |
GEOM_FADE2D::Fade_2D::Fade_2D | ( | Fade_2D & | other, |
std::vector< Zone2 * > | vZoneIn = std::vector< Zone2 * >() , |
||
std::vector< Zone2 * > | vZoneOut = std::vector< Zone2 * >() |
||
) |
This constructor creates a copy of the provided Fade_2D
instance, including the option to specify zones to copy into the new instance.
[in] | other | The Fade_2D instance to copy from. |
[in] | vZoneIn | A vector of Zone2* objects to copy. |
[out] | vZoneOut | Used to return pointers of the copied Zone2* objects in the new triangulation. |
void GEOM_FADE2D::Fade_2D::applyConstraintsAndZones | ( | ) |
This method establishes conforming constraint segments and zones which depend on them. For technical reasons conforming constraint segments are not immediately established but inserted at the end of the triangulation process. This step must be triggered manually i.e., it is up to the user to call applyConstraintsAndZones() before the resulting triangulation is used. If afterwards the triangulation is changed in any way, applyConstraintsAndZones() must be called again.
bool GEOM_FADE2D::Fade_2D::checkValidity | ( | bool | bCheckEmptyCircleProperty, |
const char * | msg | ||
) | const |
This method checks the validity of the triangulation's data structure. It verifies various properties, and can optionally recheck the empty circle property using slow multiprecision arithmetic for higher accuracy.
[in] | bCheckEmptyCircleProperty | A boolean flag that specifies whether multiprecision arithmetic should be used to recheck the empty circle property. Enabling this option will slow down the check. |
[in] | msg | A debug message that will be displayed in the terminal output to indicate which call to checkValidity is currently running. |
Bbox2 GEOM_FADE2D::Fade_2D::computeBoundingBox | ( | ) | const |
This method calculates the smallest axis-aligned bounding box (AABB) that encloses all points currently present in the triangulation.
ConstraintGraph2* GEOM_FADE2D::Fade_2D::createConstraint | ( | std::vector< Segment2 > & | vSegments, |
ConstraintInsertionStrategy | cis, | ||
bool | bOrientedSegments = false |
||
) |
vSegments | Segments to be inserted as enforced edges of the triangulation. |
cis | Use CIS_CONSTRAINED_DELAUNAY, the supported constraint-insertion-strategy. |
bOrientedSegments | Specifies whether the input segments in vSegments are oriented with a counterclockwise direction around an enclosed area. This property is required if the returned ConstraintGraph2 object shall be used for later Zone2 creation. If bOrientedSegments is false and vSegments represents a simple polygon, the edges are automatically reoriented to establish this property. For complex or uncertain polygon orientations, use the PolygonClipper to repair and orient vSegments upfront. |
The present method subdivides the segments only if required, which is the case if existing vertices or constraint edges are crossed. If you want to subdivide the created constraint edges subsequently to achieve better triangle shapes (see the third image), use ConstraintGraph2::makeDelaunay() on the returned ConstraintGraph2.
Zone2* GEOM_FADE2D::Fade_2D::createZone | ( | const std::vector< ConstraintGraph2 * > & | vConstraintGraphs, |
ZoneLocation | zoneLoc, | ||
const Point2 & | startPoint, | ||
bool | bVerbose = true |
||
) |
Creates a Zone2
object bounded by multiple ConstraintGraph2
objects, grown from a seed point.
vConstraintGraphs | A vector of ConstraintGraph2 objects. |
zoneLoc | The ZoneLocation must be ZL_GROW . |
startPoint | The point from which the area grows until the borders defined in vConstraintGraphs are reached. |
bVerbose | Is true by default and triggers a warning if NULL is returned. |
Zone2
object, or NULL
if zoneLoc != ZL_GROW
or no triangles exist. Zone2* GEOM_FADE2D::Fade_2D::createZone | ( | ConstraintGraph2 * | pConstraintGraph, |
ZoneLocation | zoneLoc, | ||
bool | bVerbose = true |
||
) |
Creates a Zone2 object which represents an area of a triangulation.
[in] | zoneLoc | can be ZL_INSIDE, ZL_OUTSIDE or ZL_GLOBAL. |
[in] | pConstraintGraph | points to an existing ConstraintGraph2 object (which must be oriented) or is NULL if zoneLoc is ZL_GLOBAL. |
[in] | bVerbose | is true by default and causes a warning if NULL is returned. |
Zone2
object, or NULL
if no triangles exist, or if pConstraintGraph->isOriented()
returns false
. Make sure to check for NULL
before proceeding. Zone2* GEOM_FADE2D::Fade_2D::createZone | ( | ConstraintGraph2 * | pConstraintGraph, |
ZoneLocation | zoneLoc, | ||
const Point2 & | startPoint, | ||
bool | bVerbose = true |
||
) |
Creates a Zone2
object bounded by a ConstraintGraph2
object, grown from a seed point.
pConstraintGraph | A pointer to the ConstraintGraph2 that defines the boundary. |
zoneLoc | The ZoneLocation must be ZL_GROW . |
startPoint | The point from which the area grows until the borders defined in pConstraintGraph are reached. |
bVerbose | Is true by default and triggers a warning if NULL is returned. |
Zone2
object, or NULL
if zoneLoc != ZL_GROW
or no triangles exist. Zone2* GEOM_FADE2D::Fade_2D::createZone | ( | std::vector< Triangle2 * > & | vTriangles, |
bool | bVerbose = true |
||
) |
This method creates a Zone2
defined by the triangles in @p vTriangles
.
vTriangles | A vector of Triangle2* pointers defining the area. |
bVerbose | Triggers a warning if NULL is returned. Default: true . |
Zone2
object, or NULL
if vTriangles
is empty.Zone2* GEOM_FADE2D::Fade_2D::createZone_cookieCutter | ( | std::vector< Segment2 > & | vSegments, |
bool | bProtectEdges | ||
) |
Zone2* GEOM_FADE2D::Fade_2D::createZone_cookieCutter | ( | std::vector< Segment2 > & | vSegments, |
bool | bProtectEdges, | ||
ConstraintGraph2 *& | pProtectedEdgesCG, | ||
ConstraintGraph2 *& | pBoundaryCG | ||
) |
Zone2* GEOM_FADE2D::Fade_2D::createZone_cookieCutter2 | ( | std::vector< Segment2 > & | vSegments, |
bool | bProtectEdges | ||
) |
The Cookie Cutter cuts out a part of a 2D or 2.5D triangulation and returns it as a Zone2 object.
vSegments
) defining the shape.[in] | vSegments | specifies the input polygon. |
[in] | bProtectEdges | specifies if existing edges shall be locked by turning them into constraint segments |
Zone2* GEOM_FADE2D::Fade_2D::createZone_cookieCutter2 | ( | std::vector< Segment2 > & | vSegments, |
bool | bProtectEdges, | ||
ConstraintGraph2 *& | pProtectedEdgesCG, | ||
ConstraintGraph2 *& | pBoundaryCG | ||
) |
The Cookie Cutter cuts out a part of a triangulation and returns it as a Zone2 object.
vSegments
) defining the shape.[in] | vSegments | specifies the input polygon. |
[in] | bProtectEdges | specifies if existing edges shall be locked by turning them into constraint segments |
[out] | pProtectedEdgesCG | is used to return the ConstraintGraph2* of edges that have been protected |
[out] | pBoundaryCG | is used to return the ConstraintGraph2* of the boundary |
void GEOM_FADE2D::Fade_2D::cutTriangles | ( | const Point2 & | knifeStart, |
const Point2 & | knifeEnd, | ||
bool | bTurnEdgesIntoConstraints | ||
) |
knifeStart | is one point of the knife segment |
knifeEnd | is the second point of the knife segment |
bTurnEdgesIntoConstraints | turns all 3 edges of each intersected triangle into constraint segments. |
This method inserts a constraint edge knife(knifeStart,knifeEnd). If existing edges E are intersected by knife, then knife is subdivided at the intersection points P.
In any case knife will exist (in a possibly subdivided form) in the result. But a consequence of the insertion of the points P is that the edges E and even edges which are not intersected by knife may be flipped. Use bTurnEdgesIntoConstraints=true to avoid that.
void GEOM_FADE2D::Fade_2D::cutTriangles | ( | std::vector< Segment2 > & | vSegments, |
bool | bTurnEdgesIntoConstraints | ||
) |
vSegments | are the knife segments |
bTurnEdgesIntoConstraints | specifies if intersected edges shall automatically be turned into constraints |
Same method as void cutTriangles(const Point2& knifeStart,const Point2& knifeEnd,bool bTurnEdgesIntoConstraints) but it takes a vector of segments instead of a single segment. This is the recommended method to cut through a triangulation when more than one knife segment exists.
void GEOM_FADE2D::Fade_2D::deleteConstraintsAndZones | ( | ) |
This method deletes all ConstraintGraph2
objects, all ConstraintSegment2
objects, and all Zone2
objects. It does not modify existing triangles; existing edges that have been created as constraint segments before are not flipped back to satisfy the 'empty circle property' of a Delaunay triangulation. However, these edges become unprotected, and any subsequent modifications to the triangulation may cause them to be flipped.
void GEOM_FADE2D::Fade_2D::deleteZone | ( | Zone2 * | pZone | ) |
Zone2 objects are automatically destroyed with their Fade_2D objects. In addition this method provides the possibility to eliminate Zone2 objects earlier.
bool GEOM_FADE2D::Fade_2D::drape | ( | std::vector< Segment2 > & | vSegmentsIn, |
std::vector< Segment2 > & | vSegmentsOut, | ||
double | offTolerance = 0.0 , |
||
bool | bKeepOffSegments = false |
||
) | const |
Projects the segments from vSegmentsIn
onto the triangulation. Degenerate input segments are ignored. Segments are subdivided at intersections with triangulation edges.
[in] | vSegmentsIn | Input segments. |
[out] | vSegmentsOut | Output segments. |
[in] | offTolerance | Used to prevent truncation of segments that are slightly outside the convex hull due to tiny rounding errors. If this value is greater than 0, segment endpoints slightly outside the convex hull of the triangulation will be inserted into the triangulation. |
[in] | bKeepOffSegments | Specifies whether segments outside the triangulation should be kept. Default: false . |
true
if all input segments are inside the convex hull of the triangulation. Otherwise, false
is returned, and the result is still valid but only contains the segment parts inside the convex hull unless bKeepOffSegments
is true
.
void GEOM_FADE2D::Fade_2D::exportTriangulation | ( | FadeExport & | fadeExport, |
bool | bWithCustomIndices, | ||
bool | bClear | ||
) |
This method exports triangulation data from the current Fade instance to a simple FadeExport
structure, which is defined in a header and consists solely of arrays containing basic data types. The method also offers the option to clear the Fade object during the export to prevent memory usage peaks.
[out] | fadeExport | A FadeExport structure that will hold the requested triangulation data after the export operation. |
[in] | bWithCustomIndices | A boolean flag that determines whether custom indices for the points should be included in the export. |
[in] | bClear | A boolean flag that specifies whether the Fade instance should be cleared during the export to free memory. If true , all memory associated with the Fade instance is released, and all existing pointers to its objects will become invalid. |
A method to retrieve the counterclockwise adjacent triangle of an oriented edge of the triangulation.
[in] | p0,p1 | Pointers to the vertices of the triangulation that form the endpoints of the oriented edge. |
Triangle2
containing the oriented edge (p0, p1), or NULL if no such triangle is present.Triangle2
: While an unoriented edge (p0, p1) can have two adjacent triangles, only one of them contains the oriented edge (p0, p1), while the other contains the oriented edge (p1, p0). void GEOM_FADE2D::Fade_2D::getAliveConstraintSegments | ( | std::vector< ConstraintSegment2 * > & | vAliveConstraintSegments | ) | const |
This method retrieves the active (alive) constraint segments and stores them in the provided vector.
vAliveConstraintSegments | A reference to a vector that will be populated with pointers to the active constraint segments. |
ConstraintSegment2* GEOM_FADE2D::Fade_2D::getConstraintSegment | ( | Point2 * | p0, |
Point2 * | p1 | ||
) | const |
[in] | p0,p1 | The endpoints of the ConstraintSegment2 |
ConstraintSegment2
between p0 and p1, or NULL if the segment is not a constraint edge of the triangulation (or is dead because it has been split). void GEOM_FADE2D::Fade_2D::getConvexHull | ( | bool | bAllVertices, |
std::vector< Point2 * > & | vConvexHullPointsOut | ||
) |
Computes the convex hull of the triangulation.
[in] | bAllVertices | A boolean that determines whether all convex hull points are returned or if collinear ones should be removed. |
[out] | vConvexHullPointsOut | A vector used to return the convex hull vertices in counterclockwise order. |
void GEOM_FADE2D::Fade_2D::getIncidentTriangles | ( | Point2 * | pVtx, |
std::vector< Triangle2 * > & | vIncidentT | ||
) | const |
Stores pointers to all triangles around the vertex pVtx
into the vector vIncidentT
.
[in] | pVtx | A pointer to a vertex of the triangulation. |
[out] | vIncidentT | A vector used to return pointers to the incident triangles of pVtx . |
void GEOM_FADE2D::Fade_2D::getIncidentVertices | ( | Point2 * | pVtx, |
std::vector< Point2 * > & | vAdjVtx | ||
) | const |
Stores pointers to all vertices around the vertex pVtx
into the vector vAdjVtx
[in] | pVtx | A pointer to a vertex of the triangulation. |
[out] | vAdjVtx | A vector used to return pointers to all vertices adjacent to pVtx . |
double GEOM_FADE2D::Fade_2D::getMedianEdgeLength2D | ( | ) |
Computes the median edge length of all edges in the triangulation in 2D.
This method returns the closest vertex to the point p
.
[in] | p | A pointer to the query point. |
p
. Orientation2 GEOM_FADE2D::Fade_2D::getOrientation | ( | const Point2 & | p0, |
const Point2 & | p1, | ||
const Point2 & | p2 | ||
) |
Determines if the ordered points p0
, p1
, and p2
are collinear, clockwise, or counterclockwise.
[in] | p0,p1,p2 | The points whose orientation is computed. |
ORIENTATION2_COLLINEAR
, ORIENTATION2_CW
, or ORIENTATION2_CCW
. void GEOM_FADE2D::Fade_2D::getTrianglePointers | ( | std::vector< Triangle2 * > & | vAllTriangles | ) | const |
This method retrieves pointers to all existing triangles in the triangulation.
[out] | vAllTriangles | A vector used to return the pointers to all triangles. |
void GEOM_FADE2D::Fade_2D::getUndirectedEdges | ( | std::vector< Edge2 > & | vUndirectedEdgesOut | ) | const |
Retrieves all undirected edges from the triangulation.
[out] | vUndirectedEdgesOut | A vector used to return a unique set of undirected edges. |
Checks if the given point is
a vertex of the triangulation. If is
a vertex, the function returns a pointer to that vertex. Otherwise, it returns NULL.
[in] | p | The query point. |
is
a vertex of the triangulation, or NULL if is
not a vertex. void GEOM_FADE2D::Fade_2D::getVertexPointers | ( | std::vector< Point2 * > & | vAllPoints | ) | const |
Returns all vertex pointers of the triangulation. The order in which the points are returned is arbitrary.
[out] | vAllPoints | A vector to return the vertex pointers. |
Voronoi2* GEOM_FADE2D::Fade_2D::getVoronoiDiagram | ( | ) |
This method returns the Voronoi diagram of the existing vertices, which is the dual diagram of their Delaunay triangulation.
Voronoi2
instance, representing the dual diagram of the triangulation.void GEOM_FADE2D::Fade_2D::getZones | ( | std::vector< Zone2 * > & | vZones | ) | const |
This method retrieves all the zones in the triangulation and stores their pointers in the provided vector.
[out] | vZones | A vector used to return pointers to all existing Zone2 objects. |
bool GEOM_FADE2D::Fade_2D::hasArea | ( | ) | const |
A triangulation only contains triangles if at least three non-collinear points exist. If all inserted points are collinear, no triangles can be formed, regardless of how many points have been inserted. This method checks whether the triangulation currently contains any triangles, i.e., if an area exists.
Zone2* GEOM_FADE2D::Fade_2D::importTriangles | ( | std::vector< Point2 > & | vPoints, |
bool | bReorientIfNeeded, | ||
bool | bCreateExtendedBoundingBox | ||
) |
This method imports triangles into an empty triangulation.
vPoints | A vector containing the input triangulation, with 3 subsequent points per triangle. |
bReorientIfNeeded | Specifies whether the orientations of the point triples should be checked and corrected. If you are confident that the point triples are already oriented in counterclockwise order, you can skip the orientation test. |
bCreateExtendedBoundingBox | If true, the four corners of an extended bounding box will be inserted as dummy points. This can be useful in some cases. If unsure, set this to false. |
This method imports triangles into an empty Fade object. Unlike the classic importTriangles()
method, this robust version handles errors in the input data and automatically corrects overlapping triangles. This robust version is very fast, and due to the additional checks, it is also very safe. Thus, it is highly recommended to use it always rather than the classic importTriangles() method.
vPoints | A vector containing the input triangulation, with 3 subsequent points per triangle. |
This method inserts a single point into the triangulation.
p | The point to be inserted. |
The triangulation keeps a copy of p
, and the return value is a pointer to this copy. If duplicate points are inserted, the triangulation does not create new copies but instead returns a pointer to the copy of the first insertion.
void GEOM_FADE2D::Fade_2D::insert | ( | const std::vector< Point2 > & | vInputPoints | ) |
This method inserts a vector of points into the triangulation.
vInputPoints | A vector containing the points to be inserted. |
setGlobalNumCPU()
before using this method. void GEOM_FADE2D::Fade_2D::insert | ( | const std::vector< Point2 > & | vInputPoints, |
std::vector< Point2 * > & | vHandles | ||
) |
This method inserts points from vInputPoints
and stores the corresponding pointers to the inserted points in vHandles
.
vInputPoints | A vector containing the points to be inserted. |
vHandles | An empty vector that will be populated with Point2 pointers. |
Internally, the triangulation keeps copies of the inserted points, and these copies are returned in vHandles
(in the same order as in vInputPoints
). If duplicate points are found in vInputPoints
, only one copy will be created, and a pointer to this unique copy will be stored in vHandles
for each occurrence of that point.
setGlobalNumCPU()
before using this method. void GEOM_FADE2D::Fade_2D::insert | ( | int | numPoints, |
double * | aCoordinates, | ||
Point2 ** | aHandles | ||
) |
This method inserts points from an array of coordinates and stores the corresponding pointers to the inserted points in aHandles
.
numPoints | The number of points to be inserted. |
aCoordinates | An array of 2n double values, representing the coordinates of the points in the format: {x0, y0, x1, y1, ..., xn, yn}. |
aHandles | An empty array of size n where pointers to the inserted points will be stored by Fade. |
Fade_2D::setNumCPU()
before using this method. This method checks whether the edge formed by the points p0
and p1
is a constraint edge.
p0,p1 | Pointers to endpoints of the edge |
bool GEOM_FADE2D::Fade_2D::isConstraint | ( | Point2 * | pVtx | ) | const |
This method checks whether the vertex pVtx
belongs to a constraint edge.
pVtx | Pointer to the vertex to check. |
pVtx
belongs to a constraint edge (true) or not (false). bool GEOM_FADE2D::Fade_2D::isConstraint | ( | Triangle2 * | pT, |
int | ith | ||
) | const |
This method checks whether the edge opposite to the ith
vertex in the triangle pT
is a constraint edge.
pT | The triangle to check. |
ith | The index of the vertex in the triangle. |
ith
vertex is a constraint edge (true) or not (false). bool GEOM_FADE2D::Fade_2D::load | ( | const char * | filename, |
std::vector< Zone2 * > & | vZones | ||
) |
This method loads a triangulation from a binary file, including any custom indices, constraint edges, and zones. The file must have been saved using the saveTriangulation()
, saveZones()
, or Zone2::save()
methods.
[in] | filename | The name of the input file. |
[out] | vZones | A vector of Zone2* that will be populated with pointers to the zones (if any) stored in the file. The order of the pointers will match the order at the time of storage. |
true
if the operation was successful, false
otherwise. bool GEOM_FADE2D::Fade_2D::load | ( | std::istream & | stream, |
std::vector< Zone2 * > & | vZones | ||
) |
This method loads a triangulation from a binary file, including any custom indices, constraint edges, and zones. The file must have been saved using the saveTriangulation()
, saveZones()
, or Zone2::save()
methods.
[in] | stream | is an input stream |
[out] | vZones | A vector of Zone2* that will be populated with pointers to the zones (if any) stored in the file. The order of the pointers will match the order at the time of storage. |
true
if the operation was successful, false
otherwise. double GEOM_FADE2D::Fade_2D::measureTriangulationTime | ( | const std::vector< Point2 > & | vPoints | ) |
This method measures the time taken to create a Delaunay triangulation from a given set of points.
[in] | vPoints | A vector of points to be inserted into the triangulation. |
setGlobalNumCPU()
. size_t GEOM_FADE2D::Fade_2D::numberOfPoints | ( | ) | const |
Computes the number of points in the triangulation.
size_t GEOM_FADE2D::Fade_2D::numberOfTriangles | ( | ) | const |
Computes the number of points in the triangulation
void GEOM_FADE2D::Fade_2D::refine | ( | Zone2 * | pZone, |
double | minAngleDegree, | ||
double | minEdgeLength, | ||
double | maxEdgeLength, | ||
bool | bAllowConstraintSplitting | ||
) |
Creates a mesh inside the area given by a Zone2 object.
pZone | is the zone whose triangles are refined. Allowed zoneLocation values are ZL_INSIDE and ZL_BOUNDED. |
minAngleDegree | (up to 30) is the minimum interior triangle angle |
minEdgeLength | is a lower threshold on the edge length. Triangles with smaller edges are not refined. |
maxEdgeLength | is an upper threshold on the edge length. Triangles with larger edges are always refined. |
bAllowConstraintSplitting | specifies if constraint edges may be splitted |
void GEOM_FADE2D::Fade_2D::refineAdvanced | ( | MeshGenParams * | pParameters | ) |
This method calls an advanced Delaunay mesh generator and grid mesher. The parameters are encapsulated in the MeshGenParams
class, which provides default parameters that can be used as is. Alternatively, client code can derive from MeshGenParams
and override the methods and parameters to gain full control over the mesh generation process.
void GEOM_FADE2D::Fade_2D::remove | ( | Point2 * | pVertex | ) |
pVertex | The vertex to be removed. |
pVertex
must not belong to a constraint edge. Otherwise the vertex will not be removed, and a warning will be issued. void GEOM_FADE2D::Fade_2D::remove | ( | std::vector< Point2 * > & | vPoints | ) |
vPoints | are the points to be removed |
vPoints
must not be vertices of any constraint edge. Otherwise they will not be removed. This method replicates only the boundaries of the given Zone2
pZoneIn
in the current Fade_2D
instance. It is primarily intended to facilitate boolean operations with zones, as these operations require the zones to belong to the same Fade_2D instance.
pZoneIn | The input zone whose boundaries are to be replicated. |
void GEOM_FADE2D::Fade_2D::reset | ( | ) |
Resets the triangulation, making it reusable.
bool GEOM_FADE2D::Fade_2D::saveTriangulation | ( | const char * | filename, |
std::vector< Zone2 * > & | vSaveZones | ||
) |
The saveTriangulation()
method saves all triangles of the current triangulation to a binary file. It retains constraint edges and custom vertex indices, if available. If Zone2
pointers are provided, these zones will also be saved, and their order will be preserved.
[in] | filename | The name of the output file. |
[in] | vSaveZones | A vector of Zone2 pointers representing zones to be saved. |
Zone2::save()
or Fade_2D::saveZones()
. To reload data from saved files, use Fade_2D::load()
.true
if the operation was successful, false
otherwise. bool GEOM_FADE2D::Fade_2D::saveTriangulation | ( | std::ostream & | stream, |
std::vector< Zone2 * > & | vSaveZones | ||
) |
The saveTriangulation()
method saves all triangles of the current triangulation to a binary file. It retains constraint edges and custom vertex indices, if available. If Zone2*
pointers are provided, these zones will also be saved, and their order will be preserved.
stream | is the output stream | |
[in] | vSaveZones | A vector of Zone2 pointers representing zones to be saved. |
Zone2::save()
or Fade_2D::saveZones()
. To reload data from saved files, use Fade_2D::load()
.true
if the operation was successful, false
otherwise. bool GEOM_FADE2D::Fade_2D::saveZones | ( | const char * | filename, |
std::vector< Zone2 * > & | vSaveZones | ||
) |
The saveZones()
method saves the triangles of the zones in vSaveZones
to a binary file. It retains the order of the zones, and maintains the constraint edges and custom vertex indices within the domain.
Fade_2D
instance, when reloaded, but will not be associated with any reloaded Zone2
.[in] | filename | The name of the output file |
[in] | vSaveZones | A non-empty vector of Zone2 pointers specifying the zones to be saved. |
true
if the operation was successful, false
otherwise.saveTriangulation()
method to store all triangles of a triangulation along with any specified zones. The Zone2::save()
method can be used to save a single zone. To reload data from a saved file, use Fade_2D::load()
. bool GEOM_FADE2D::Fade_2D::saveZones | ( | std::ostream & | stream, |
std::vector< Zone2 * > & | vSaveZones | ||
) |
The saveZones()
method saves the triangles of the zones in vSaveZones
to a binary file. It retains the order of the zones, and maintains the constraint edges and custom vertex indices within the domain.
Fade_2D
instance, when reloaded, but will not be associated with any reloaded Zone2
.[in] | stream | is the name of output stream |
[in] | vSaveZones | A non-empty vector of Zone2 pointers specifying the zones to be saved. |
true
if the operation was successful, false
otherwise.saveTriangulation()
method to store all triangles of a triangulation along with any specified zones. The Zone2::save()
method can be used to save a single zone. To reload data from a saved file, use Fade_2D::load()
. void GEOM_FADE2D::Fade_2D::setFastMode | ( | bool | bFast | ) |
By default, multiple-precision arithmetic may be used (if required) to compute a 100% perfect Delaunay triangulation. However, the quality difference compared to using double precision arithmetic is hardly noticeable. Use this method to skip computationally expensive calculations and improve performance.
bFast | Set to true to avoid using computationally expensive multiple-precision arithmetic in favor of better performance. |
Depending on the position of the input points, enabling setFastMode(true)
may have no effect if multiple-precision arithmetic wouldn't be used anyway, or provide considerable acceleration if it would otherwise be needed.
int GEOM_FADE2D::Fade_2D::setNumCPU | ( | int | numCPU | ) |
setGlobalNumCPU()
instead. This method is kept for backward compatibility. It internally forwards the call to setGlobalNumCPU()
.[in] | numCPU | The number of CPU cores to use for multithreading. |
void GEOM_FADE2D::Fade_2D::show | ( | const char * | filename, |
bool | bWithConstraints = true |
||
) | const |
show()
is a convenience function for quickly generating outputs with a default appearance. It is also possible to use the Visualizer2 class directly to draw arbitrary circles, line segments, vertices, and labels with custom colors.
filename | The output file name, e.g., "file.ps" for PostScript or "file.pdf" for PDF. |
bWithConstraints | Specifies whether constraint segments should be shown (default: true). |
void GEOM_FADE2D::Fade_2D::show | ( | Visualizer2 * | pVis, |
bool | bWithConstraints = true |
||
) | const |
show()
is a convenience function for quickly generating outputs with a default appearance. It is also possible to use the Visualizer2 class directly to draw arbitrary circles, line segments, vertices, and labels with custom colors.
pVis | A pointer to a Visualizer2 object, which may already contain geometric elements or may later be used to draw additional elements. |
bWithConstraints | Specifies whether constraint segments should be shown (default: true). |
pVis->writeFile()
.void GEOM_FADE2D::Fade_2D::showVtk | ( | const char * | filename, |
VtkColor | color, | ||
VtkColor | constraintColor = VTK_TRANSPARENT |
||
) | const |
This method generates a .VTK file representing the triangulation, which can be viewed with tools like Paraview.
filename | The output filename, e.g., "file.vtk". |
color | The color for the triangles |
constraintColor | The color for the constraint edges. VTK_TRANSPARENT hides them. |
VtkWriter
class directly to visualize custom points, line segments, and triangles. void GEOM_FADE2D::Fade_2D::showVtk | ( | VtkWriter * | pVtkWriter, |
VtkColor | color, | ||
VtkColor | constraintColor = VTK_TRANSPARENT |
||
) | const |
This method generates a .VTK file representing the triangulation, which can be viewed with tools like Paraview.
pVtkWriter | A pointer to a VtkWriter object, which may already contain geometric elements or can be used to add further elements. |
color | The color for the triangles. |
constraintColor | The color for the constraint edges. Use VTK_TRANSPARENT to hide them. |
pVtkWriter->writeFile()
to save the file.VtkWriter
class directly to visualize custom points, line segments, and triangles. void GEOM_FADE2D::Fade_2D::statistics | ( | const char * | s | ) | const |
Prints mesh quality statistics.
This method registers a subscriber to receive messages of a specified type.
msgType | The type of message the subscriber will receive, e.g., MSG_PROGRESS or MSG_WARNING . |
pMsg | A pointer to a custom class derived from MsgBase that will handle the messages. |
This method removes a subscriber from receiving messages of a specified type.
msgType | The type of message that the subscriber will no longer receive. |
pMsg | A pointer to a custom class derived from MsgBase representing the subscriber to be removed. |
void GEOM_FADE2D::Fade_2D::writeObj | ( | const char * | filename | ) | const |
This method writes the current triangulation data to an .obj file, which can be used for visualization and further processing in tools like Meshlab.
filename | The output filename, e.g., "triangulation.obj". |
void GEOM_FADE2D::Fade_2D::writeObj | ( | const char * | filename, |
Zone2 * | pZone | ||
) | const |
This method writes a Zone2 to an .obj file, which can be used for visualization and further processing in tools like Meshlab.
filename | The output filename, e.g., "triangulation.obj". |
pZone | A pointer to the pZone to be written. |
void GEOM_FADE2D::Fade_2D::writeWebScene | ( | const char * | path | ) | const |
This method generates a scene of the triangulation, which can be viewed in a web browser.
path | The output filename or file path where the scene will be saved. |
void GEOM_FADE2D::Fade_2D::writeWebScene | ( | const char * | path, |
Zone2 * | pZone | ||
) | const |