Fade2D Documentation pages v1.97
Delaunay Features
GEOM_FADE2D::Fade_2D Class Reference

Fade_2D is the Delaunay triangulation main class. More...

#include <Fade_2D.h>

Public Member Functions

 Fade_2D (unsigned numExpectedVertices=3)
 Constructor of the main triangulation class. More...
 
 ~Fade_2D ()
 Destructor.
 
void applyConstraintsAndZones ()
 Apply conforming constraints and zones (deprecated!) More...
 
bool checkValidity (bool bCheckEmptyCircleProperty, const char *msg) const
 Checks if a triangulation is valid. More...
 
Bbox2 computeBoundingBox () const
 Compute the axis-aligned bounding box of the points. More...
 
ConstraintGraph2createConstraint (std::vector< Segment2 > &vSegments, ConstraintInsertionStrategy cis, bool bOrientedSegments=false)
 Add constraint edges (edges, polyline, polygon) . More...
 
Zone2createZone (const std::vector< ConstraintGraph2 * > &vConstraintGraphs, ZoneLocation zoneLoc, const Point2 &startPoint, bool bVerbose=true)
 Create a zone limited by multiple ConstraintGraph2 objects by growing from a start point. More...
 
Zone2createZone (ConstraintGraph2 *pConstraintGraph, ZoneLocation zoneLoc, bool bVerbose=true)
 Create a zone. More...
 
Zone2createZone (ConstraintGraph2 *pConstraintGraph, ZoneLocation zoneLoc, const Point2 &startPoint, bool bVerbose=true)
 Create a zone limited by a ConstraintGraph by growing from a start point. More...
 
Zone2createZone (std::vector< Triangle2 * > &vTriangles, bool bVerbose=true)
 Create a zone defined by a vector of triangles. More...
 
Zone2createZone_cookieCutter (std::vector< Segment2 > &vSegments, bool bProtectEdges)
 Cookie Cutter The Cookie Cutter cuts out a part of a triangulation and returns it as a Zone2 object. 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 deleteZone (Zone2 *pZone)
 Delete a Zone2 object. More...
 
bool drape (std::vector< Segment2 > &vSegmentsIn, std::vector< Segment2 > &vSegmentsOut) const
 Drape segments along a surface. More...
 
void exportTriangulation (FadeExport &fadeExport, bool bWithCustomIndices, bool bClear)
 Export triangulation data from Fade. More...
 
Triangle2getAdjacentTriangle (Point2 *p0, Point2 *p1) const
 Get adjacent triangle. 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.
 
ConstraintSegment2getConstraintSegment (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 * > &vIncidentVertices) const
 Get incident vertices. More...
 
Point2getNearestNeighbor (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...
 
void getVertexPointers (std::vector< Point2 * > &vAllPoints) const
 Get pointers to all vertices. More...
 
Voronoi2getVoronoiDiagram ()
 Get the Voronoi diagram. More...
 
bool hasArea () const
 Check if the triangulation contains triangles (which is the case if at least 3 non-collinear points exist in the triangulation. More...
 
Zone2importTriangles (std::vector< Point2 > &vPoints, bool bReorientIfNeeded, bool bCreateExtendedBoundingBox)
 Import triangles. More...
 
Point2insert (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 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. More...
 
bool load (std::istream &stream, std::vector< Zone2 * > &vZones)
 Load a triangulation. More...
 
Triangle2locate (const Point2 &p)
 Locate a triangle which contains p. More...
 
double measureTriangulationTime (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...
 
bool saveTriangulation (const char *filename, std::vector< Zone2 * > &vSaveZones)
 Save a triangulation. More...
 
bool saveTriangulation (std::ostream &stream, std::vector< Zone2 * > &vSaveZones)
 Save a triangulation. More...
 
bool saveZones (const char *filename, std::vector< Zone2 * > &vSaveZones)
 Save zones. More...
 
bool saveZones (std::ostream &stream, std::vector< Zone2 * > &vSaveZones)
 Save zones. More...
 
void setFastMode (bool bFast)
 Set fast mode. More...
 
int setNumCPU (int numCPU)
 Set the number CPU cores for multithreading. More...
 
void show (const char *postscriptFilename, bool bWithConstraints=true) const
 Draws the triangulation as postscript file. More...
 
void show (Visualizer2 *pVis, bool bWithConstraints=true) const
 Draws the triangulation as postscript file using an existing Visualizer2 object. More...
 
void statistics (const char *s) const
 Statistics. More...
 
void subscribe (MsgType msgType, MsgBase *pMsg)
 Register a message receiver. More...
 
void unsubscribe (MsgType msgType, MsgBase *pMsg)
 Unregister 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 zone to an *.obj file. More...
 
void writeWebScene (const char *path) const
 Write the current triangulation to an *.obj file. More...
 
void writeWebScene (const char *path, Zone2 *pZone) const
 Write a zone to an *.obj file. More...
 

Detailed Description

Fade_2D represents a Delaunay triangulation in 2D or 2.5D (depends on the used namespace)

Constructor & Destructor Documentation

◆ Fade_2D()

GEOM_FADE2D::Fade_2D::Fade_2D ( unsigned  numExpectedVertices = 3)
inlineexplicit
Parameters
numExpectedVerticesspecifies the number of points that will be inserted. This is a default parameter that does not need to be specified.

Member Function Documentation

◆ applyConstraintsAndZones()

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.

Note
The present function applyConstraintsAndZones() as well as the two constraint insertion strategies CIS_CONFORMING_DELAUNAY and CIS_CONFORMING_DELAUNAY_SEGMENT_LEVEL are deprecated. These are only kept for backwards compatibilty. The replacement is CIS_CONSTRAINED_DELAUNAY along with the methods Fade_2D::drape() and/or ConstraintGraph2::makeDelaunay(). See the example code in examples_25D/terrain.cpp

◆ checkValidity()

bool GEOM_FADE2D::Fade_2D::checkValidity ( bool  bCheckEmptyCircleProperty,
const char *  msg 
) const

Checks the validity of the data structure.

Parameters
bCheckEmptyCirclePropertyspecifies if (slow!) multiprecision arithmetic shall be used to recheck the empty circle property
msgis a debug string that will be shown in terminal output so that you know which checkValidity call currently runs.

This method is thought for development purposes. Don't call it method unless you assume that something is wrong with the code.

◆ computeBoundingBox()

Bbox2 GEOM_FADE2D::Fade_2D::computeBoundingBox ( ) const

If no points have been inserted yet, then the returned Bbox2 object is invalid and its member function Bbox2::isValid() returns false.

◆ createConstraint()

ConstraintGraph2* GEOM_FADE2D::Fade_2D::createConstraint ( std::vector< Segment2 > &  vSegments,
ConstraintInsertionStrategy  cis,
bool  bOrientedSegments = false 
)
Parameters
vSegmentsare segments which shall appear as edges of the triangulation. The segments may be automatically reordered and reoriented, see bOrientedSegments below.
cisis the Constraint-Insertion-Strategy. Use always CIS_CONSTRAINED_DELAUNAY. This mode inserts the constraint segments without subdivision unless existing vertices or existing constraint segments are crossed. When subdivision (e.g., to achieve better triangle shapes) is desired then use ConstraintGraph2::makeDelaunay() after insertion.
bOrientedSegmentsspecifies whether the segments in vSegments are oriented (oriented, not ordered!). If later a zone is to be made with the returned ConstraintGraph2 object this is only possible if the value is true (then it is assumed that all segments are counterclockwise oriented) or if the ConstraintGraph2 represents exactly one closed polygon. The value affects also the order of the returned vertices when later ConstraintGraph2::getPolygonVertices() is called. This is a default parameter and it defaults to false.
Returns
a pointer to the new ConstraintGraph2 object

Delaunay triangulation without constraints

Constrained Delaunay triangulation

Conforming Delaunay triangulation through the ConstraintGraph::makeDelaunay() method

◆ createZone() [1/4]

Zone2* GEOM_FADE2D::Fade_2D::createZone ( const std::vector< ConstraintGraph2 * > &  vConstraintGraphs,
ZoneLocation  zoneLoc,
const Point2 startPoint,
bool  bVerbose = true 
)

A Zone2 object is an area of the traingulation, see createZone

Parameters
vConstraintGraphsis a vector of ConstraintGraph objects
zoneLocmust be ZL_GROW
startPointis the point from which the area is grown until the borders specified in vConstraintGraphs are reached
bVerboseis by default true and causes a warning if NULL is returned.
Returns
a pointer to the new Zone2 object (or NULL if zoneLoc!=ZL_GROW or no triangles exist)

◆ createZone() [2/4]

Zone2* GEOM_FADE2D::Fade_2D::createZone ( ConstraintGraph2 pConstraintGraph,
ZoneLocation  zoneLoc,
bool  bVerbose = true 
)

A Zone2 object is an area of a triangulation, possibly bounded by a ConstraintGraph.

Parameters
zoneLocis ZL_INSIDE, ZL_OUTSIDE or ZL_GLOBAL.
pConstraintGraphpoints to a formerly created ConstraintGraph2 object (which must be oriented and contain a simple polygon) or is NULL in case of zoneLoc==ZL_GLOBAL.
bVerboseis by default true and causes a warning if NULL is returned.
Returns
a pointer to the new Zone2 object or NULL if no triangles exist or pConstraintGraph->isOriented() returns false.

Zones in a triangulation

◆ createZone() [3/4]

Zone2* GEOM_FADE2D::Fade_2D::createZone ( ConstraintGraph2 pConstraintGraph,
ZoneLocation  zoneLoc,
const Point2 startPoint,
bool  bVerbose = true 
)

A Zone2 object is an area of the traingulation, see createZone

Parameters
pConstraintGraphis a constraint whose edges specify the area's border
zoneLocmust be ZL_GROW
startPointis the point from which the area is grown until the borders specified in pConstraint are reached
bVerboseis by default true and causes a warning if NULL is returned.
Returns
a pointer to the new Zone2 object (or NULL if zoneLoc!=ZL_GROW or no triangles exist)

◆ createZone() [4/4]

Zone2* GEOM_FADE2D::Fade_2D::createZone ( std::vector< Triangle2 * > &  vTriangles,
bool  bVerbose = true 
)

A Zone2 object is an area of the traingulation, see createZone

Parameters
vTriangles
bVerboseis by default true and causes a warning if NULL is returned.
Returns
a pointer to the new Zone2 object (or NULL if vTriangles is empty)

◆ createZone_cookieCutter()

Zone2* GEOM_FADE2D::Fade_2D::createZone_cookieCutter ( std::vector< Segment2 > &  vSegments,
bool  bProtectEdges 
)
Parameters
[in]vSegmentsspecifies a simple polygon.
[in]bProtectEdgesspecifies if existing triangles shall be protected with constraint segments.
Returns
a Zone2 object consisting of all triangles inside the polygon or NULL when the operation has failed due to wrong preconditions.

Properties: The input polygon ( vSegments) does not need to have certain height values, the z-coordinates are computed automatically. The input polygon is automatically trimmed when it is outside the convex hull of the triangulation. Insertion of intersection points may flip existing edges in the triangulation but this can be avoided using bProtectEdges=true. In this case new constraint edges may be created.

◆ cutTriangles() [1/2]

void GEOM_FADE2D::Fade_2D::cutTriangles ( const Point2 knifeStart,
const Point2 knifeEnd,
bool  bTurnEdgesIntoConstraints 
)
Parameters
knifeStartis one point of the knife segment
knifeEndis the second point of the knife segment
bTurnEdgesIntoConstraintsturns 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.

Note
The intersection point of two line segments may not be exactly representable in double precision floating point arithmetic and thus tiny rounding errors may occur. As a consequence two very close intersection points may be rounded to the same coordinates.
When more than one knife segment is inserted then the method void cutTriangles(std::vector<Segment2>& vSegments,bool bTurnEdgesIntoConstraints) should be used. The reason is that each individual cut operation changes the triangulation and thus iterative calls to the present version of the method can lead to a different result.

◆ cutTriangles() [2/2]

void GEOM_FADE2D::Fade_2D::cutTriangles ( std::vector< Segment2 > &  vSegments,
bool  bTurnEdgesIntoConstraints 
)
Parameters
vSegmentsare the knife segments
bTurnEdgesIntoConstraintsspecifies 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.

◆ deleteZone()

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.

Note
Zones are designed transparently: When two zones Z1 and Z2 are combined to a new one Z3 (for example through a boolean operation) then Z1,Z2,Z3 form a tree such that changes in the leaf nodes Z1 and Z2 can propagate up to the root node Z3. For this reason Z1 and Z2 must be alive as long as Z3 is used.

◆ drape()

bool GEOM_FADE2D::Fade_2D::drape ( std::vector< Segment2 > &  vSegmentsIn,
std::vector< Segment2 > &  vSegmentsOut 
) const

Projects the segments from vSegmentsIn onto the triangulation. Thereby the segments are subdivided where they intersect edges of the triangulation. Segment parts outside the triangulation are cut off and ignored. Degenerate input segments are also ignored.

Parameters
[in]vSegmentsInInput segments
[out]vSegmentsOutOutput segments
Returns
TRUE if all input segments are inside the convex hull of the triangulation. Otherwise FALSE is returned and the result is still valid but it contains only the segment parts inside the convex hull.
Note
The tiny rounding errors that occur when segment intersections are computed are largely theoretical. But be aware that subdivided segments are not always perfectly collinear. This can't be avoided because the exact split point is sometimes not even representable using floating point coordinates.

  • Drape: Input segments are draped (red) onto a TIN. They are subdivided (blue) at intersections with triangulation edges
Note
Draping segments onto a TIN does not insert them. Use Fade_2D::createConstraint() for that purpose.

◆ exportTriangulation()

void GEOM_FADE2D::Fade_2D::exportTriangulation ( FadeExport fadeExport,
bool  bWithCustomIndices,
bool  bClear 
)
Parameters
fadeExportis a struct that will hold the requested triangulation data
bWithCustomIndicesdetermines whether the custom indices of the points are also stored
bCleardetermines whether the Fade instance is cleared during the export operation to save memory
Note
When bClear is true then all memory of the Fade object is deleted i.e., all existing pointers to its objects become invalid.

◆ getAdjacentTriangle()

Triangle2* GEOM_FADE2D::Fade_2D::getAdjacentTriangle ( Point2 p0,
Point2 p1 
) const
Returns
the triangle that has the edge (p0,p1) or NULL if no such edge is present
Note
Recall the counter-clockwise enumeration of vertices in a triangle. If (p0,p1) is used, the unique triangle with the CCW oriented edge (p0,p1) is returned, using (p1,p0) one gets the other adjacent triangle.

◆ getConstraintSegment()

ConstraintSegment2* GEOM_FADE2D::Fade_2D::getConstraintSegment ( Point2 p0,
Point2 p1 
) const
Returns
a pointer to the ConstraintSegment2 between p0 and p1 or NULL if the segment is not a constraint edge (or dead because it has been splitted)

◆ getConvexHull()

void GEOM_FADE2D::Fade_2D::getConvexHull ( bool  bAllVertices,
std::vector< Point2 * > &  vConvexHullPointsOut 
)
Parameters
bAllVerticesdetermines if all convex hull points are returned or if collinear ones shall be removed.
[out]vConvexHullPointsOutis used to return the convex hull vertices in counterclockwise order. The start vertex is the leftmost vertex. If more than one leftmost vertex exists, the bottommost of them is the start vertex.

◆ getIncidentTriangles()

void GEOM_FADE2D::Fade_2D::getIncidentTriangles ( Point2 pVtx,
std::vector< Triangle2 * > &  vIncidentT 
) const

Stores pointers to all triangles around pVtx into vIncidentT

◆ getIncidentVertices()

void GEOM_FADE2D::Fade_2D::getIncidentVertices ( Point2 pVtx,
std::vector< Point2 * > &  vIncidentVertices 
) const

Stores pointers to all vertices around pVtx into vIncidentVertices

◆ getNearestNeighbor()

Point2* GEOM_FADE2D::Fade_2D::getNearestNeighbor ( const Point2 p)

This method returns the closest vertex of p.

Parameters
[in]pis the query point
Returns
a pointer to the closest vertex

◆ getOrientation()

Orientation2 GEOM_FADE2D::Fade_2D::getOrientation ( const Point2 p0,
const Point2 p1,
const Point2 p2 
)
Returns
ORIENTATION2_COLLINEAR, ORIENTATION2_CW (clockwise) or ORENTATION2_CCW (counterclockwise)

◆ getTrianglePointers()

void GEOM_FADE2D::Fade_2D::getTrianglePointers ( std::vector< Triangle2 * > &  vAllTriangles) const

This command fetches the existing triangles

Parameters
[out]vAllTrianglesis used to return the triangles
Note
that the lifetime of data from the Fade2D datastructures does exceed the lifetime of the Fade2D object.

◆ getUndirectedEdges()

void GEOM_FADE2D::Fade_2D::getUndirectedEdges ( std::vector< Edge2 > &  vUndirectedEdgesOut) const
Parameters
vUndirectedEdgesOutis used to return a unique set of undirected edges.

◆ getVertexPointers()

void GEOM_FADE2D::Fade_2D::getVertexPointers ( std::vector< Point2 * > &  vAllPoints) const
Parameters
vAllPointsis an empty vector of Point2 pointers.

Stores pointers to all vertices of the triangulation in vAllPoints. The order in which the points are stored is not necessarily the insertion order. For geometrically identical points which have been inserted multiple times, only one pointer exists. Thus vAllPoints.size() can be smaller than the number of inserted points.

Note
that the lifetime of data from the Fade2D datastructures does exceed the lifetime of the Fade2D object.

◆ getVoronoiDiagram()

Voronoi2* GEOM_FADE2D::Fade_2D::getVoronoiDiagram ( )
Returns
a dual Voronoi diagram that changes dynamically when the triangulation changes.

◆ hasArea()

bool GEOM_FADE2D::Fade_2D::hasArea ( ) const

As long as all inserted points are collinear the triangulation does not contain triangles. This is clearly the case as long as less than three input points are present but it may also be the case when 3 or more points have been inserted when all these points are collinear. These points are then in a pending state, i.e. they will be triangulated as soon as the first non-collinear point is inserted.

Triangles are generated as soon as the first non-collinear point is inserted.
Returns
true if at least one triangle exists
false otherwise

◆ importTriangles()

Zone2* GEOM_FADE2D::Fade_2D::importTriangles ( std::vector< Point2 > &  vPoints,
bool  bReorientIfNeeded,
bool  bCreateExtendedBoundingBox 
)

This method imports triangles into an empty Fade object. The triangles do not need to satisfy the empty circle property.

Parameters
vPointscontains the input vertices (3 subsequent ones per triangle)
bReorientIfNeededspecifies if the orientations of the point triples shall be checked and corrected. If the point triples are certainly oriented in counterclockwise order then the orientation test can be skipped.
bCreateExtendedBoundingBoxcan be used to insert 4 dummy points of an extended bounding box. This is convenient in some cases. Use false if you are unsure.
Returns
a pointer to a Zone2 object or NULL if the input data is invalid
Warning
This method requires 100% correct input. A frequent source of trouble is when client software reads points from an ASCII file. The ASCII format is convenient but it can introduce rounding errors that cause intersections and flipped triangle orientations. Thus it is highly recommended to transfer point coordinates with binary files. See also readPointsBIN() and writePointsBIN().

◆ insert() [1/4]

Point2* GEOM_FADE2D::Fade_2D::insert ( const Point2 p)
Parameters
pis the point to be inserted.
Returns
a pointer to the point in the triangulation

The triangulation keeps a copy of p. The return value is a pointer to this copy. If duplicate points are inserted, the triangulation does not create new copies but returns a pointer to the copy of the very first insertion.

Note
This method offers a very good performance but it is still faster if all points are passed at once, if possible.

◆ insert() [2/4]

void GEOM_FADE2D::Fade_2D::insert ( const std::vector< Point2 > &  vInputPoints)
Parameters
vInputPointscontains the points to be inserted.
Note
Use Fade_2D::setNumCPU() to activate multithreading

◆ insert() [3/4]

void GEOM_FADE2D::Fade_2D::insert ( const std::vector< Point2 > &  vInputPoints,
std::vector< Point2 * > &  vHandles 
)
Parameters
vInputPointscontains the points to be inserted.
vHandles(empty) is used by Fade to return Point2 pointers

Internally, the triangulation keeps copies of the inserted points which are returned in vHandles (in the same order). If duplicate points are contained in vInputPoints then only one copy will be made and a pointer to this unique copy will be stored in vHandles for every occurance.

Note
Use Fade_2D::setNumCPU() to activate multithreading

◆ insert() [4/4]

void GEOM_FADE2D::Fade_2D::insert ( int  numPoints,
double *  aCoordinates,
Point2 **  aHandles 
)
Parameters
numPointsis the number of points to be inserted
aCoordinatesis an array of 2n double values, e.g. {x0,y0,x1,y1,...,xn,yn}
aHandlesis an empty array with size n where pointers to the inserted points will be stored by Fade
Note
Use Fade_2D::setNumCPU() to activate multithreading

◆ isConstraint() [1/3]

bool GEOM_FADE2D::Fade_2D::isConstraint ( Point2 p0,
Point2 p1 
) const

Returns whether the edge (p0,p1) is a constraint edge.

◆ isConstraint() [2/3]

bool GEOM_FADE2D::Fade_2D::isConstraint ( Point2 pVtx) const

Returns whether the vertex pVtx belongs to a constraint edge.

◆ isConstraint() [3/3]

bool GEOM_FADE2D::Fade_2D::isConstraint ( Triangle2 pT,
int  ith 
) const

Returns whether the edge in triangle pT which is opposite to the ith vertex is a constraint edge.

◆ load() [1/2]

bool GEOM_FADE2D::Fade_2D::load ( const char *  filename,
std::vector< Zone2 * > &  vZones 
)

Loads a triangulation together with any custom indices, constraint-edges and zones from a binary file

Parameters
[in]filenameis the name of the input file
[out]vZonesis used to return Zone2* pointers if any. The order of the pointers is the same as at the time of storage
Returns
whether the operation was successful

◆ load() [2/2]

bool GEOM_FADE2D::Fade_2D::load ( std::istream &  stream,
std::vector< Zone2 * > &  vZones 
)

Loads a triangulation together with any custom indices, constraint-edges and zones from a stream

Parameters
streamis an input stream
[out]vZonesis used to return Zone2* pointers if any. The order of the pointers is the same as at the time of storage
Returns
whether the operation was successful

◆ locate()

Triangle2* GEOM_FADE2D::Fade_2D::locate ( const Point2 p)
Point location

The Fade_2D class can be used as a data structure for point location. This method returns a pointer to a triangle which contains p.

Parameters
[in]pis the query point
Returns
a pointer to a Triangle2 object (or NULL if hasArea()==false or if p is outside the triangulation)

◆ measureTriangulationTime()

double GEOM_FADE2D::Fade_2D::measureTriangulationTime ( std::vector< Point2 > &  vPoints)

This method evaluates the performance of single- and multithreaded point insertion into a Delaunay triangulation.

Parameters
[in]vPointsare the points to be inserted
Returns
the total wall-time for point insertion in seconds
Note
The method cleans up the triangulation (objects, memory) on exit. Thus the time measured outside this method may be slightly larger than the returned time that is exactly the time needed to triangulate the input points.
Use Fade_2D::setNumCPU() to activate multithreading

◆ numberOfPoints()

size_t GEOM_FADE2D::Fade_2D::numberOfPoints ( ) const
Returns
the number of points in the triangulation
Note
Due to possibly duplicate input points the number of points is not stored somewhere but freshly computed in O(n) time. This is fast but you are adviced to avoid calling this method over-frequently in a loop. Duplicate point insertions count only once.

◆ numberOfTriangles()

size_t GEOM_FADE2D::Fade_2D::numberOfTriangles ( ) const
Returns
the number of triangles in the triangulation (or 0 as long as hasArea() is false).

◆ refine()

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.

Parameters
pZoneis 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
minEdgeLengthis a lower threshold on the edge length. Triangles with smaller edges are not refined.
maxEdgeLengthis an upper threshold on the edge length. Triangles with larger edges are always refined.
bAllowConstraintSplittingspecifies if constraint edges may be splitted
Note
The behavior of the present method had to be changed in Fade v1.39: Only ZL_INSIDE and ZL_BOUNDED zones are accepted. But you can easily convert other types of zones to ZL_BOUNDED using Zone2::convertToBoundedZone().

◆ refineAdvanced()

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. This class provides default parameters that can be used as is. Alternatively client code can derive from MeshGenParams and overwrite the methods and parameters to gain full control over the mesh generation process.

Control over the local mesh density in a Delaunay Mesh

Control over the local mesh density

Delaunay meshing with maximum edge length

Delaunay meshing with maximum edge length

Axis-aligned grid mesh

Grid mesh, axis-aligned

Grid mesh aligned to a certain direction

Grid mesh, aligned to a certain direction

◆ remove()

void GEOM_FADE2D::Fade_2D::remove ( Point2 pVertex)
Parameters
pVertexshall be removed.
Note
pVertex must not be a vertex of a ConstraintGraph2 or ConstraintSegment2 object. If this is the case, the vertex is not removed and a warning is issued.

◆ saveTriangulation() [1/2]

bool GEOM_FADE2D::Fade_2D::saveTriangulation ( const char *  filename,
std::vector< Zone2 * > &  vSaveZones 
)

The saveTriangulation() command saves all triangles of the present triangulation to a binary file. Thereby it retains constraint edges and custom vertex indices, if any. If Zone2* pointers are specified, these zones will be saved also and their order will be retained.

Parameters
[in]filenameis the name of the output file
[out]vSaveZonesis used specify zones that shall additionally be saved
See also
If you just want to store zones, use Zone2::save() or Fade_2D::saveTriangulation(). Use Fade_2D::load() to reload data from such files.
Returns
whether the operation was successful

◆ saveTriangulation() [2/2]

bool GEOM_FADE2D::Fade_2D::saveTriangulation ( std::ostream &  stream,
std::vector< Zone2 * > &  vSaveZones 
)

The saveTriangulation() command saves all triangles of the present triangulation to a stream. Thereby it retains constraint edges and custom vertex indices, if any. If Zone2* pointers are specified, these zones will be saved also and their order will be retained.

Parameters
streamis the output stream
[out]vSaveZonesis used specify zones that shall additionally be saved
See also
If you just want to store zones, use Zone2::save() or Fade_2D::saveTriangulation(). Use Fade_2D::load() to reload data from such files.
Returns
whether the operation was successful

◆ saveZones() [1/2]

bool GEOM_FADE2D::Fade_2D::saveZones ( const char *  filename,
std::vector< Zone2 * > &  vSaveZones 
)

The saveZones() command saves the triangles of the zones in vSaveZones to a binary file. Thereby it keeps the order of the zones and it retains any constraint edges and custom indices in the domain.

Note
A Delaunay triangulation is convex without holes and this may not hold for the zones to be saved. Thus extra triangles may be saved to fill concavities. These extra-triangles will belong to the Fade_2D instance but not to any Zone2 when reloaded later.
Parameters
[in]filenameis the name of the output file
[out]vSaveZones(non-empty) specifies the zones to be saved
Returns
whether the operation was successful
See also
The saveTriangulation() command can be used to store all triangles of a triangulation plus any specified zones. The Zone2::save() command is used to store just one zone. Use Fade_2D::load() to reload data from such files.

◆ saveZones() [2/2]

bool GEOM_FADE2D::Fade_2D::saveZones ( std::ostream &  stream,
std::vector< Zone2 * > &  vSaveZones 
)

The saveZones() command saves the triangles of the zones in vSaveZones to stream. Thereby it keeps the order of the zones and it retains any constraint edges and custom indices in the domain.

Note
A Delaunay triangulation is convex without holes and this may not hold for the zones to be saved. Thus extra triangles may be saved to fill concavities. These extra-triangles will belong to the Fade_2D instance but not to any Zone2 when reloaded later.
Parameters
streamis the name of output stream
[out]vSaveZones(non-empty) specifies the zones to be saved
Returns
whether the operation was successful
See also
The saveTriangulation() command can be used to store all triangles of a triangulation plus any specified zones. The Zone2::save() command is used to store just one zone. Use Fade_2D::load() to reload data from such files.

◆ setFastMode()

void GEOM_FADE2D::Fade_2D::setFastMode ( bool  bFast)

By default, numerically perfect calculations are performed to compute a 100% perfect Delaunay triangulation. However, the quality difference to using double precision arithmetic is hardly noticeable. It is often rather relevant in scientific applications while practical applications may want to skip the computationally expensive calculations. Depending on the position of the input points, the effect of FastMode can be zero or a quite considerable acceleration.

Parameters
bFastuse true to avoid using multiple precision arithmetic in favor of better performance.

◆ setNumCPU()

int GEOM_FADE2D::Fade_2D::setNumCPU ( int  numCPU)
Parameters
numCPUis the number of CPU cores to be used. The special value numCPU=0 means: auto-detect and use the number of available CPU cores.
Returns
the number of CPU cores that will be used (useful in case of auto-detection)

Characteristics:

  • This setting affects Fade_2D::measureTriangulationTime() and Fade_2D::insert() which is by default single-threaded to avoid undeliberate nested multithreading (an application may run Fade in a thread).
  • For technical reasons points should be inserted before any constraint segments so that the algorithm can fully benefit from multithreading.
  • Fade continues support for very old compilers but multithreading is not available for VS2010 and CentOS6.4 library versions.

◆ show() [1/2]

void GEOM_FADE2D::Fade_2D::show ( const char *  postscriptFilename,
bool  bWithConstraints = true 
) const

show() is a convenience function for quick outputs with a default look. It is also possible to use the Visualizer2 class directly to draw arbitrary circles, line segments, vertices and labels with custom colors.

Parameters
postscriptFilenameis the output name, i.e. "myFile.ps"
bWithConstraintsspecifies if constraint segments shall be shown (default: true)

◆ show() [2/2]

void GEOM_FADE2D::Fade_2D::show ( Visualizer2 pVis,
bool  bWithConstraints = true 
) const

This overload of the show() method allows to add further geometric primitives to the Visualizer2 object before it is finally written.

Parameters
pVisis the pointer of a Visualizer2 object that may already contain geometric primitives or that may later be used to draw further elements
bWithConstraintsspecifies if constraint segments shall be shown (default: true)
Note
The postscript file must be finalized with Visualizer2::writeFile().

◆ statistics()

void GEOM_FADE2D::Fade_2D::statistics ( const char *  s) const

Prints mesh statistics to stdout.

◆ subscribe()

void GEOM_FADE2D::Fade_2D::subscribe ( MsgType  msgType,
MsgBase pMsg 
)
Parameters
msgTypeis the type of message the subscriber shall receive, e.g. MSG_PROGRESS or MSG_WARNING
pMsgis a pointer to a custom class derived from MsgBase

◆ unsubscribe()

void GEOM_FADE2D::Fade_2D::unsubscribe ( MsgType  msgType,
MsgBase pMsg 
)
Parameters
msgTypeis the type of message the subscriber shall not receive anymore
pMsgis a pointer to a custom class derived from MsgBase

◆ writeObj() [1/2]

void GEOM_FADE2D::Fade_2D::writeObj ( const char *  filename) const

Visualizes the current triangulation. The *.obj format represents a 3D scene.

◆ writeObj() [2/2]

void GEOM_FADE2D::Fade_2D::writeObj ( const char *  filename,
Zone2 pZone 
) const

Visualizes a certain Zone2 object of the present triangulation. The *.obj format represents a 3D scene.

◆ writeWebScene() [1/2]

void GEOM_FADE2D::Fade_2D::writeWebScene ( const char *  path) const

Made for terrain visualizations in 2.5D but will work also for 2D.

◆ writeWebScene() [2/2]

void GEOM_FADE2D::Fade_2D::writeWebScene ( const char *  path,
Zone2 pZone 
) const

Made for terrain visualizations in 2.5D but will work also for 2D.


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