Fade2.5D Documentation pages v1.90
Delaunay Features
Fade_2D.h
Go to the documentation of this file.
1 // Copyright (C) Geom Software e.U, Bernhard Kornberger, Graz/Austria
2 //
3 // This file is part of the Fade2D library. The student license is free
4 // of charge and covers personal non-commercial research. Licensees
5 // holding a commercial license may use this file in accordance with
6 // the Commercial License Agreement.
7 //
8 // This software is provided AS IS with NO WARRANTY OF ANY KIND,
9 // INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS
10 // FOR A PARTICULAR PURPOSE.
11 //
12 // Please contact the author if any conditions of this licensing are
13 // not clear to you.
14 //
15 // Author: Bernhard Kornberger, bkorn (at) geom.at
16 // http://www.geom.at
17 
18 
24 #pragma once
25 
26 #include "common.h"
27 #include "Point2.h"
28 #include "Triangle2.h"
30 #include "Visualizer2.h"
31 #include "Zone2.h"
32 #include "ConstraintGraph2.h"
33 #include "Performance.h"
34 #include "MeshGenParams.h"
35 #include "MsgBase.h"
36 #include "SegmentChecker.h"
37 #include "testDataGenerators.h"
38 #include "freeFunctions.h"
39 #include "FadeExport.h"
40 #include "Voronoi2.h"
41 
42 
43 #if GEOM_PSEUDO3D==GEOM_TRUE
44  #include "IsoContours.h"
45  #include "EfficientModel.h"
46  #include "CutAndFill.h"
47  #include "CloudPrepare.h"
48 
49 #endif
50 
51 
52 
53 #if GEOM_PSEUDO3D==GEOM_TRUE
54  namespace GEOM_FADE25D {
55 #elif GEOM_PSEUDO3D==GEOM_FALSE
56  namespace GEOM_FADE2D {
57 #else
58  #error GEOM_PSEUDO3D is not defined
59 #endif
60 
61 
62 class Dt2; // Forward
63 class Visualizer3; // Forward
64 
65 
70 class CLASS_DECLSPEC Fade_2D
71 {
72 public:
79  explicit Fade_2D(unsigned numExpectedVertices=3)
80  {
81  initFade(numExpectedVertices);
82  }
85 
86 
87 
88 
106  bool saveTriangulation(const char* filename,std::vector<Zone2*>& vSaveZones);
107 
125  bool saveTriangulation(std::ostream& stream,std::vector<Zone2*>& vSaveZones);
126 
127 
150  bool saveZones(const char* filename,std::vector<Zone2*>& vSaveZones);
151 
152 
175  bool saveZones(std::ostream& stream,std::vector<Zone2*>& vSaveZones);
176 
177 
189  bool load(const char* filename,std::vector<Zone2*>& vZones);
190 
191 
203  bool load(std::istream& stream,std::vector<Zone2*>& vZones);
204 
205 
215  void exportTriangulation(FadeExport& fadeExport,bool bWithCustomIndices,bool bClear);
216 
217 
230  bool checkValidity(bool bCheckEmptyCircleProperty,const char* msg) const;
231 
253  int setNumCPU(int numCPU);
254 
260  Voronoi2* getVoronoiDiagram();
261 
276  void setFastMode(bool bFast);
277 
278 
283  void statistics(const char* s) const;
284 
295  void show(const char* postscriptFilename,bool bWithConstraints=true) const;
296 
297 
310  void show(Visualizer2* pVis,bool bWithConstraints=true) const;
311 
312 #if GEOM_PSEUDO3D==GEOM_TRUE
320  void showGeomview(const char* filename, const char* color="1 1 1 0.5") const;
321 
329  void showGeomview(Visualizer3* pVis, const char* color="1 1 1 0.5") const;
330 
331 
332 #endif
333 
343  void remove(Point2* pVertex);
344 
345 
358  void getConvexHull(bool bAllVertices,std::vector<Point2*>& vConvexHullPointsOut);
359 
360 #if GEOM_PSEUDO3D==GEOM_TRUE
378  void insert(CloudPrepare* pCloudPrepare,bool bClear=true);
379 #endif
380 
394  Point2* insert(const Point2& p);
395 
404  void insert(const std::vector<Point2>& vInputPoints);
405 
420  void insert(const std::vector<Point2>& vInputPoints,std::vector<Point2*>& vHandles);
421 
422 #if GEOM_PSEUDO3D==GEOM_TRUE
431 #else
440 #endif
441  void insert(int numPoints,double * aCoordinates,Point2 ** aHandles);
442 
443 
460  double measureTriangulationTime(std::vector<Point2>& vPoints);
461 
462 
463 
478  Triangle2* locate(const Point2& p);
479 
480 
481 #if GEOM_PSEUDO3D==GEOM_TRUE
507  bool getHeight(double x,double y,double& heightOut,Triangle2* pApproxT=NULL,double tolerance=0) const;
508 #endif
509 
525  void refine( Zone2* pZone,
526  double minAngleDegree,
527  double minEdgeLength,
528  double maxEdgeLength,
529  bool bAllowConstraintSplitting
530  );
531 
567  void refineAdvanced(MeshGenParams* pParameters);
568 
569 
570 
571 
572 
573 
583  size_t numberOfPoints() const;
584 
591  size_t numberOfTriangles() const;
592 
593 
605  void getTrianglePointers(std::vector<Triangle2*>& vAllTriangles) const;
606 
620  void getVertexPointers(std::vector<Point2*>& vAllPoints) const;
621 
622 
623 
634 
651  bool hasArea() const;
652 
658  bool is2D() const;
659 
660 
716 #if GEOM_PSEUDO3D==GEOM_TRUE
718  std::vector<Segment2>& vSegments,
720  bool bOrientedSegments=false,
721  bool bUseHeightOfLatest=false
722  );
723 #else
724  ConstraintGraph2* createConstraint(
725  std::vector<Segment2>& vSegments,
727  bool bOrientedSegments=false
728  );
729 #endif
730 
731 
732 
733 
734 
757  Zone2* createZone(ConstraintGraph2* pConstraintGraph,ZoneLocation zoneLoc,bool bVerbose=true);
758 
759 
771  Zone2* createZone(const std::vector<ConstraintGraph2*>& vConstraintGraphs,ZoneLocation zoneLoc,const Point2& startPoint,bool bVerbose=true);
772 
785  Zone2* createZone(ConstraintGraph2* pConstraintGraph,ZoneLocation zoneLoc,const Point2& startPoint,bool bVerbose=true);
786 
797  Zone2* createZone( std::vector<Triangle2*>& vTriangles,bool bVerbose=true );
798 
799 
800 
813  void deleteZone(Zone2* pZone);
814 
815 
836 
837 
845 
853  bool isConstraint(Triangle2* pT,int ith) const;
854 
857  void getAliveConstraintSegments(std::vector<ConstraintSegment2*>& vAliveConstraintSegments) const;
858 
861  void getAliveAndDeadConstraintSegments(std::vector<ConstraintSegment2*>& vAllConstraintSegments) const;
862 
871 
872 
877  void getIncidentTriangles(Point2* pVtx,std::vector<Triangle2*>& vIncidentT) const;
878 
883  void getIncidentVertices(Point2* pVtx,std::vector<Point2*>& vIncidentVertices) const;
884 
885 
893  void writeObj(const char* filename) const;
894 
901  void writeObj(const char* filename,Zone2* pZone) const;
902 
903 
909  void writeWebScene(const char* path) const;
910 
916  void writeWebScene(const char* path,Zone2* pZone) const;
917 
923 void subscribe(MsgType msgType,MsgBase* pMsg);
924 
930 void unsubscribe(MsgType msgType,MsgBase* pMsg);
931 
932 
939  bool isConstraint(Point2* p0,Point2* p1) const;
940 
946  bool isConstraint(Point2* pVtx) const;
947 
949  void printLicense() const;
950 
952  bool checkZoneQuality(Zone2* pZone,double minAngle,const char* name,const AcceptExperimentalFeature& accept);
954  void setName(const char* s);
956  const char* getName() const;
957 
958 
980  Zone2* importTriangles( std::vector<Point2>& vPoints,
981  bool bReorientIfNeeded,
982  bool bCreateExtendedBoundingBox
983  );
984 
989  Orientation2 getOrientation(const Point2& p0,const Point2& p1,const Point2& p2);
990 
1021  void cutTriangles( const Point2& knifeStart,
1022  const Point2& knifeEnd,
1023  bool bTurnEdgesIntoConstraints);
1024 
1037  void cutTriangles( std::vector<Segment2>& vSegments,
1038  bool bTurnEdgesIntoConstraints);
1039 
1040 
1060  Zone2* createZone_cookieCutter(std::vector<Segment2>& vSegments,bool bProtectEdges);
1061 
1062 
1108 #if GEOM_PSEUDO3D==GEOM_TRUE
1109  bool drape( std::vector<Segment2>& vSegmentsIn,
1110  std::vector<Segment2>& vSegmentsOut,
1111  double zTolerance) const;
1112 #else
1113  bool drape( std::vector<Segment2>& vSegmentsIn,
1114  std::vector<Segment2>& vSegmentsOut) const;
1115 #endif
1116 
1118  /* Deprecated: Use setNumCPU() instead. This method is kept for
1119  * compatibility with existing applications. Internally it calls
1120  * setNumCPU(0) to automatically determine and use the number of
1121  * available CPU cores.
1122  */
1123  void enableMultithreading();
1124  // Development functions, not for public use
1126  void internal(int au,int fu,const char* s="");
1128  Dt2* getImpl();
1130  void setDev(const char* s,int ival,double dval);
1131 
1132 protected:
1134  void initFade(unsigned numExpectedVertices);
1136  Fade_2D(const Fade_2D&); // No copy constructor
1138  Fade_2D& operator=(const Fade_2D&); // No assignment allowed
1140  Dt2* pImpl;
1141 }; // end of class
1142 
1143 
1144 
1145 #ifndef FADE2D_EXPORT
1146  #include "License.h"
1147 #endif
1148 
1149 
1150 } // (namespace)
1151 
ConstraintInsertionStrategy
Constraint Insertion Strategy determines how a constraint edge shall be inserted:
Definition: ConstraintSegment2.h:52
Bbox2 is an axis aligned 2D bounding box.
Definition: Bbox2.h:37
CloudPrepare simplifies overdense point clouds and helps to avoid memory-usage-peaks during data tran...
Definition: CloudPrepare.h:87
ConstraintGraph2 is a set of Constraint Edges (ConstraintSegment2)
Definition: ConstraintGraph2.h:52
A ConstraintSegment2 represents a Constraint Edge.
Definition: ConstraintSegment2.h:69
Fade_2D is the Delaunay triangulation main class.
Definition: Fade_2D.h:71
void getTrianglePointers(std::vector< Triangle2 * > &vAllTriangles) const
Get pointers to all triangles.
void writeWebScene(const char *path, Zone2 *pZone) const
Write a zone to an *.obj file.
bool getHeight(double x, double y, double &heightOut, Triangle2 *pApproxT=NULL, double tolerance=0) const
Compute the height of a certain point.
bool load(const char *filename, std::vector< Zone2 * > &vZones)
Load a triangulation.
void getVertexPointers(std::vector< Point2 * > &vAllPoints) const
Get pointers to all vertices.
void statistics(const char *s) const
Statistics.
void cutTriangles(const Point2 &knifeStart, const Point2 &knifeEnd, bool bTurnEdgesIntoConstraints)
Cut through a triangulation.
void getConvexHull(bool bAllVertices, std::vector< Point2 * > &vConvexHullPointsOut)
Compute the convex hull.
void getAliveConstraintSegments(std::vector< ConstraintSegment2 * > &vAliveConstraintSegments) const
Get active (alive) constraint segments.
bool drape(std::vector< Segment2 > &vSegmentsIn, std::vector< Segment2 > &vSegmentsOut, double zTolerance) const
Drape segments along a surface.
void insert(const std::vector< Point2 > &vInputPoints)
Insert a vector of points.
void showGeomview(Visualizer3 *pVis, const char *color="1 1 1 0.5") const
Draws the triangulation in 3D.
void writeWebScene(const char *path) const
Write the current triangulation to an *.obj file.
Voronoi2 * getVoronoiDiagram()
Get the Voronoi diagram.
void unsubscribe(MsgType msgType, MsgBase *pMsg)
Unregister a message receiver.
void setFastMode(bool bFast)
Set fast mode.
void insert(CloudPrepare *pCloudPrepare, bool bClear=true)
Insert points from a CloudPrepare object.
void insert(int numPoints, double *aCoordinates, Point2 **aHandles)
Insert points from an array.
void refineAdvanced(MeshGenParams *pParameters)
Delaunay refinement and grid meshing.
size_t numberOfTriangles() const
Number of triangles.
void writeObj(const char *filename, Zone2 *pZone) const
Write a zone to an *.obj file.
void insert(const std::vector< Point2 > &vInputPoints, std::vector< Point2 * > &vHandles)
Insert points from a std::vector and store pointers in vHandles.
ConstraintGraph2 * createConstraint(std::vector< Segment2 > &vSegments, ConstraintInsertionStrategy cis, bool bOrientedSegments=false, bool bUseHeightOfLatest=false)
Add constraint edges (edges, polyline, polygon) .
ConstraintSegment2 * getConstraintSegment(Point2 *p0, Point2 *p1) const
Retrieve a ConstraintSegment2.
bool saveZones(std::ostream &stream, std::vector< Zone2 * > &vSaveZones)
Save zones.
bool isConstraint(Point2 *p0, Point2 *p1) const
Check if an edge is a constraint edge.
Point2 * insert(const Point2 &p)
Insert a single point.
void applyConstraintsAndZones()
Apply conforming constraints and zones (deprecated!)
bool hasArea() const
Check if the triangulation contains triangles (which is the case if at least 3 non-collinear points e...
void refine(Zone2 *pZone, double minAngleDegree, double minEdgeLength, double maxEdgeLength, bool bAllowConstraintSplitting)
Delaunay refinement.
void remove(Point2 *pVertex)
Remove a single vertex.
Zone2 * createZone(ConstraintGraph2 *pConstraintGraph, ZoneLocation zoneLoc, bool bVerbose=true)
Create a zone.
void show(const char *postscriptFilename, bool bWithConstraints=true) const
Draws the triangulation as postscript file.
bool saveTriangulation(const char *filename, std::vector< Zone2 * > &vSaveZones)
Save a triangulation.
void showGeomview(const char *filename, const char *color="1 1 1 0.5") const
Draws the triangulation in 3D.
void deleteZone(Zone2 *pZone)
Delete a Zone2 object.
size_t numberOfPoints() const
Number of points.
bool saveZones(const char *filename, std::vector< Zone2 * > &vSaveZones)
Save zones.
void getIncidentTriangles(Point2 *pVtx, std::vector< Triangle2 * > &vIncidentT) const
Get incident triangles.
Zone2 * createZone(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.
void show(Visualizer2 *pVis, bool bWithConstraints=true) const
Draws the triangulation as postscript file using an existing Visualizer2 object.
Zone2 * importTriangles(std::vector< Point2 > &vPoints, bool bReorientIfNeeded, bool bCreateExtendedBoundingBox)
Import triangles.
Triangle2 * getAdjacentTriangle(Point2 *p0, Point2 *p1) const
Get adjacent triangle.
Triangle2 * locate(const Point2 &p)
Locate a triangle which contains p.
bool isConstraint(Point2 *pVtx) const
Check if a vertex is a constraint vertex.
void exportTriangulation(FadeExport &fadeExport, bool bWithCustomIndices, bool bClear)
Export triangulation data from Fade.
Fade_2D(unsigned numExpectedVertices=3)
Constructor of the main triangulation class.
Definition: Fade_2D.h:79
Zone2 * createZone(std::vector< Triangle2 * > &vTriangles, bool bVerbose=true)
Create a zone defined by a vector of triangles.
bool checkValidity(bool bCheckEmptyCircleProperty, const char *msg) const
Checks if a triangulation is valid.
bool isConstraint(Triangle2 *pT, int ith) const
Check if an edge is a constraint edge.
void printLicense() const
Prints license information.
int setNumCPU(int numCPU)
Set the number CPU cores for multithreading.
void subscribe(MsgType msgType, MsgBase *pMsg)
Register a message receiver.
void writeObj(const char *filename) const
Write the current triangulation to an *.obj file.
bool saveTriangulation(std::ostream &stream, std::vector< Zone2 * > &vSaveZones)
Save a triangulation.
void cutTriangles(std::vector< Segment2 > &vSegments, bool bTurnEdgesIntoConstraints)
Cut through a triangulation.
Zone2 * createZone(ConstraintGraph2 *pConstraintGraph, ZoneLocation zoneLoc, const Point2 &startPoint, bool bVerbose=true)
Create a zone limited by a ConstraintGraph by growing from a start point.
bool load(std::istream &stream, std::vector< Zone2 * > &vZones)
Load a triangulation.
Zone2 * createZone_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.
Orientation2 getOrientation(const Point2 &p0, const Point2 &p1, const Point2 &p2)
Compute the orientation of 3 points.
void getIncidentVertices(Point2 *pVtx, std::vector< Point2 * > &vIncidentVertices) const
Get incident vertices.
~Fade_2D()
Destructor.
void getAliveAndDeadConstraintSegments(std::vector< ConstraintSegment2 * > &vAllConstraintSegments) const
Get all (alive and dead) constraint segments.
double measureTriangulationTime(std::vector< Point2 > &vPoints)
Measure the Delaunay triangulation time.
Bbox2 computeBoundingBox() const
Compute the axis-aligned bounding box of the points.
Parameters for the mesh generator.
Definition: MeshGenParams.h:56
MsgBase, a base class for message subscriber classes.
Definition: MsgBase.h:47
Point.
Definition: Point2.h:43
Triangle.
Definition: Triangle2.h:59
Visualizer2 is a general Postscript writer. It draws the objects Point2, Segment2,...
Definition: Visualizer2.h:56
Visualizer3 is a 3D scene writer for the Geomview viewer.
Definition: Visualizer3.h:37
Zone2 is a certain defined area of a triangulation.
Definition: Zone2.h:91
FadeExport is a simple struct to export triangulation data.
Definition: FadeExport.h:43