Geom Software - C++ Programming and Geometry Libraries
Fade2D Documentation pages v1.63
Fade_2D.h
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 #pragma once
19 
20 #include "common.h"
21 #include "Point2.h"
22 #include "Triangle2.h"
23 #include "TriangleAroundVertexIterator.h"
24 #include "Visualizer2.h"
25 #include "Zone2.h"
26 #include "ConstraintGraph2.h"
27 #include "Performance.h"
28 #include "MeshGenParams.h"
29 #include "MsgBase.h"
30 #include "SegmentChecker.h"
31 #include "testDataGenerators.h"
32 #include "freeFunctions.h"
33 
34 
35 
36 
37 #if GEOM_PSEUDO3D==GEOM_TRUE
38  #include "IsoContours.h"
39  #include "EfficientModel.h"
40  #include "CutAndFill.h"
41 #endif
42 
43 
44 
45 #if GEOM_PSEUDO3D==GEOM_TRUE
46  namespace GEOM_FADE25D {
47 #elif GEOM_PSEUDO3D==GEOM_FALSE
48  namespace GEOM_FADE2D {
49 #else
50  #error GEOM_PSEUDO3D is not defined
51 #endif
52 
53 
54 
55 class Dt2; // Forward
56 class Visualizer3; // Forward
57 
58 
63 class CLASS_DECLSPEC Fade_2D
64 {
65 public:
75  explicit Fade_2D(unsigned numExpectedVertices=3)
76  {
77  initFade(numExpectedVertices);
78  }
79 
80 
81  ~Fade_2D();
82 
83 
84 
97  bool checkValidity(bool bCheckEmptyCircleProperty,const std::string& msg) const;
98 
121  int setNumCPU(int numCPU);
122 
123 
128  void statistics(const std::string& s) const;
129 
140  void show(const std::string& postscriptFilename,bool bWithConstraints=true) const;
141 
142 
155  void show(Visualizer2* pVis,bool bWithConstraints=true) const;
156 
157 #if GEOM_PSEUDO3D==GEOM_TRUE
158 
163  void showGeomview(const std::string& filename);
164 
169  void showGeomview(Visualizer3* pVis);
170 
172  // Experimental, will change
173  bool save(const char* filenameOut);
175  // Experimental, will change
176  bool load(const char* filenameIn);
177 
178 #endif
179 
189  void remove(Point2* pVertex);
190 
191 
204  void getConvexHull(bool bAllVertices,std::vector<Point2*>& vConvexHullPointsOut);
205 
206 
207 
221  Point2* insert(const Point2& p);
222 
231  void insert(const std::vector<Point2>& vInputPoints);
232 
247  void insert(const std::vector<Point2>& vInputPoints,std::vector<Point2*>& vHandles);
248 
249 #if GEOM_PSEUDO3D==GEOM_TRUE
250 
258 #else
259 
267 #endif
268  void insert(int numPoints,double * aCoordinates,Point2 ** aHandles);
269 
270 
287  double measureTrianguluationTime(std::vector<Point2>& vPoints);
288 
289 
290 
305  Triangle2* locate(const Point2& p);
306 
307 
308 #if GEOM_PSEUDO3D==GEOM_TRUE
309 
334  bool getHeight(double x,double y,double& heightOut,Triangle2* pApproxT=NULL,double tolerance=0) const;
335 #endif
336 
352  void refine( Zone2* pZone,
353  double minAngleDegree,
354  double minEdgeLength,
355  double maxEdgeLength,
356  bool bAllowConstraintSplitting
357  );
358 
394  void refineAdvanced(MeshGenParams* pParameters);
395 
396 
397 
398 
399 
400 
410  size_t numberOfPoints() const;
411 
418  size_t numberOfTriangles() const;
419 
420 
431  void getTrianglePointers(std::vector<Triangle2*>& vAllTriangles) const;
432 
444  void getVertexPointers(std::vector<Point2*>& vAllPoints) const;
445 
446 
447 
457 Triangle2* getAdjacentTriangle(Point2* p0,Point2* p1) const;
458 
476  bool is2D() const;
477 
478 
548  ConstraintGraph2* createConstraint(
549  std::vector<Segment2>& vSegments,
550  ConstraintInsertionStrategy cis,
551  bool bOrientedSegments=false
552  );
553 
554 
555 
556 
557 
558 
582  Zone2* createZone(ConstraintGraph2* pConstraintGraph,ZoneLocation zoneLoc,bool bVerbose=true);
583 
584 
596  Zone2* createZone(const std::vector<ConstraintGraph2*>& vConstraintGraphs,ZoneLocation zoneLoc,const Point2& startPoint,bool bVerbose=true);
597 
610  Zone2* createZone(ConstraintGraph2* pConstraintGraph,ZoneLocation zoneLoc,const Point2& startPoint,bool bVerbose=true);
611 
622  Zone2* createZone( std::vector<Triangle2*>& vTriangles,bool bVerbose=true );
623 
624 
625 
638  void deleteZone(Zone2* pZone);
639 
640 
652  void applyConstraintsAndZones();
653 
654 
661  Bbox2 computeBoundingBox() const;
662 
670  bool isConstraint(Triangle2* pT,int ith) const;
671 
680  ConstraintSegment2* getConstraintSegment(Point2* p0,Point2* p1) const;
681 
682 
687  void getIncidentTriangles(Point2* pVtx,std::vector<Triangle2*>& vIncidentT) const;
688 
689 
698  void writeObj(const std::string& filename) const;
699 
706  void writeObj(const std::string& filename,Zone2* pZone) const;
707 
708 
714  void writeWebScene(const char* path) const;
715 
721  void writeWebScene(const char* path,Zone2* pZone) const;
722 
728 void subscribe(MsgType msgType,MsgBase* pMsg);
729 
735 void unsubscribe(MsgType msgType,MsgBase* pMsg);
736 
737 
744  bool isConstraint(Point2* p0,Point2* p1) const;
745 
751  bool isConstraint(Point2* pVtx) const;
752 
758  void printLicense() const;
759 
763  bool checkZoneQuality(Zone2* pZone,double minAngle,const std::string& name,const AcceptExperimentalFeature& accept);
764 
767  void setName(const std::string& s);
768 
771  std::string getName() const;
772 
773 
796  Zone2* importTriangles( std::vector<Point2>& vPoints,
797  bool bReorientIfNeeded,
798  bool bCreateExtendedBoundingBox
799  );
800 
805  Orientation2 getOrientation(const Point2& p0,const Point2& p1,const Point2& p2);
806 
837  void cutTriangles( const Point2& knifeStart,
838  const Point2& knifeEnd,
839  bool bTurnEdgesIntoConstraints);
840 
853  void cutTriangles( std::vector<Segment2>& vSegments,
854  bool bTurnEdgesIntoConstraints);
855 
856 
875 Zone2* createZone_cookieCutter(std::vector<Segment2>& vSegments,bool bProtectEdges);
876 
884  void enableMultithreading();
885 
886  // Development functions, not for public use
888  void internal(int au,int fu,std::string s="");
890  Dt2* getImpl();
892  void setDev(const std::string& s,int ival,double dval);
893 
894 protected:
896  void initFade(unsigned numExpectedVertices);
898  Fade_2D(const Fade_2D&); // No copy constructor
900  Fade_2D& operator=(const Fade_2D&); // No assignment allowed
902  Dt2* pImpl;
903 };
904 
905 #if GEOM_PSEUDO3D==GEOM_TRUE
906 
911 CLASS_DECLSPEC
912 bool reconstruct(const std::string& inFile,std::vector<Point2>& vCornersOut);
913 
918 CLASS_DECLSPEC
919 bool reconstruct(const std::string& inFile,const std::string& outFile);
920 
921 
927 CLASS_DECLSPEC
928 bool reconstruct(std::vector<Point2>& vInPoints, std::vector<Point2>& vCornersOut);
929 
930 #endif
931 
932 } // (namespace)
933 
934 
935 
936 
937 #ifndef FADE2D_EXPORT
938  #include "License.h"
939 #endif
940 
Delaunay triangulation - the main class.
Definition: Fade_2D.h:63
Point.
Definition: Point2.h:39
Visualizer2 is a general Postscript writer. It draws the objects Point2, Segment2, Triangle2, Circle2 and Label.
Definition: Visualizer2.h:51
Zone2 is an exactly defined area of a triangulation.
Definition: Zone2.h:49
Fade_2D(unsigned numExpectedVertices=3)
Constructor of the main triangulation class.
Definition: Fade_2D.h:75
Parameters for the mesh generator.
Definition: MeshGenParams.h:50
MsgBase
Definition: MsgBase.h:46
ConstraintGraph2 is a set of Constraint Edges to be enforced. These are ConstraintSegment2 objects...
Definition: ConstraintGraph2.h:49
A ConstraintSegment2 represents a Constraint Edge.
Definition: ConstraintSegment2.h:74
Bbox2 is an axis aligned bounding box.
Definition: Bbox2.h:36
Triangle.
Definition: Triangle2.h:48
Definition: Bbox2.h:25