Fade2D Documentation pages v2.16.10
Delaunay Features
ConstraintSegment2.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 // unclear to you.
14 //
15 // Support: https://www.geom.at/contact/
16 // Project: https://www.geom.at/fade2d/html/
17 
19 #pragma once
20 #include <set>
21 
22 #include "common.h"
23 #if GEOM_PSEUDO3D==GEOM_TRUE
24  namespace GEOM_FADE25D {
25 #elif GEOM_PSEUDO3D==GEOM_FALSE
26  namespace GEOM_FADE2D {
27 #else
28  #error GEOM_PSEUDO3D is not defined
29 #endif
30 
31 class Point2; // FWD
32 class ConstraintGraph2; // FWD
33 class ConstraintMgr; // FWD
34 
44 {
47 #if GEOM_PSEUDO3D==GEOM_TRUE
48  CIS_CONFORMING_DELAUNAY_SEGMENT_LEVEL=2,
49 #endif
52 };
53 
54 
71 {
72 private:
73  // ConstraintSegment2 objects are only made by ConstraintMgr/ConstraintGraph2
75  friend class ConstraintMgr;
76  friend class ConstraintGraph2;
77 public:
79 
80  const std::vector<ConstraintSegment2*>& getParents() const;
81 
87  CLASS_DECLSPEC
88  Point2* getSrc() const;
89 
95  CLASS_DECLSPEC
96  Point2* getTrg() const;
97 
99 
100  void kill() // Only for internal use!
101  {
102  bAlive=false;
103  }
104 
106 
107  bool dbg_hasDirection();
108 
109 
111 
112  void unkill() // Only for internal use!
113  {
114  bAlive=true;
115  }
116 
124  CLASS_DECLSPEC
125  bool isAlive() const;
126 
127 
138 
139 
140 
151  inline bool operator<(const ConstraintSegment2& pOther) const
152  {
153  if(p0<pOther.p0) return true;
154  if(p0>pOther.p0) return false;
155  return p1<pOther.p1;
156  }
157 
177  CLASS_DECLSPEC
178  Point2* insertAndSplit(const Point2& splitPoint);
179 
181  CLASS_DECLSPEC
182  bool split_combinatorialOnly(Point2* pSplit);
183 
185  CLASS_DECLSPEC
186  bool splitAndRemovePrev(const Point2& split);
187 
188 
189  //Sets a specific ConstraintGraph2 as owner of the current ConstraintSegment2.
191  void addOwnerRecursive(ConstraintGraph2* pOwner);
192 
193  // Removes a specific ConstraintGraph2 as owner of the current ConstraintSegment2.
195  void removeOwner(ConstraintGraph2* pOwner);
196 
206  CLASS_DECLSPEC
207  void getChildrenRec(std::vector<ConstraintSegment2*>& vChildConstraintSegments);
208 
217  CLASS_DECLSPEC
218  void getDirectChildren(std::vector<ConstraintSegment2*>& vChildConstraintSegments) const;
219 
231  CLASS_DECLSPEC
233 
234 
235  CLASS_DECLSPEC
236  friend std::ostream &operator<<(std::ostream &stream, const ConstraintSegment2& cSeg);
237 
238 
240  CLASS_DECLSPEC
241  size_t getNumberOfOwners() const;
242 
243  // Not thought for public use. If the current constraint segment is a border segment, then
244  // the area of the thought, non-existing outside triangle can manually be deposited here.
245  // This value is used by the extended meshing method when a grow factor is given or ignored
246  // if not set.
248  CLASS_DECLSPEC
249  void setAdjacentArea(double adjacentArea_);
250 
252  CLASS_DECLSPEC
253  int getLabel() const;
254 
256  CLASS_DECLSPEC
257  std::string getLabelString() const;
258 
259  // Not thought for public use: Returns a previously via setAdjacentArea(double adjacentArea_) deposited value. If not explicitly set, DBL_MAX is returned.
261  CLASS_DECLSPEC
262  double getAdjacentArea() const;
263 
264  static int runningLabel;
265  int label;
266 protected:
268  std::set<ConstraintGraph2*> sOwners;
269  Point2 *p0,*p1;
271  bool bAlive;
272  std::vector<ConstraintSegment2*> vChildren;
273  std::vector<ConstraintSegment2*> vParents;
275  double adjacentArea;
276 };
277 
278 } // NAMESPACE
std::ostream & operator<<(std::ostream &stream, const Bbox2 &pC)
Prints the bounding box to a stream.
Definition: Bbox2.h:605
ConstraintInsertionStrategy
Enum defining the available strategies for inserting constraints.
Definition: ConstraintSegment2.h:44
@ CIS_KEEP_DELAUNAY
Definition: ConstraintSegment2.h:50
@ CIS_CONSTRAINED_DELAUNAY
The only recommended insertion strategy.
Definition: ConstraintSegment2.h:46
@ CIS_CONFORMING_DELAUNAY
Definition: ConstraintSegment2.h:45
@ CIS_IGNORE_DELAUNAY
Definition: ConstraintSegment2.h:51
A constraint graph is a collection of constraint edges (ConstraintSegment2).
Definition: ConstraintGraph2.h:56
A ConstraintSegment2 represents a constraint edge between two vertices of a Delaunay triangulation.
Definition: ConstraintSegment2.h:71
bool operator<(const ConstraintSegment2 &pOther) const
Comparison operator for sorting segments.
Definition: ConstraintSegment2.h:151
CLASS_DECLSPEC void getDirectChildren(std::vector< ConstraintSegment2 * > &vChildConstraintSegments) const
Retrieves the direct children of this constraint segment.
CLASS_DECLSPEC Point2 * getSrc() const
Get the first endpoint of the constraint segment.
CLASS_DECLSPEC Point2 * getTrg() const
Get the second endpoint of the constraint segment.
CLASS_DECLSPEC bool isAlive() const
Checks if the segment is alive.
CLASS_DECLSPEC Point2 * insertAndSplit(const Point2 &splitPoint)
Splits a constraint segment at a specified point.
ConstraintInsertionStrategy getCIS() const
Retrieves the constraint insertion strategy (CIS) of this segment.
CLASS_DECLSPEC void getChildrenAndSplitPoint(ConstraintSegment2 *&pCSeg0, ConstraintSegment2 *&pCSeg1, Point2 *&pSplitPoint)
Retrieves the two direct children and the split point.
CLASS_DECLSPEC void getChildrenRec(std::vector< ConstraintSegment2 * > &vChildConstraintSegments)
Retrieves all children of this constraint segment recursively.
Represents a 2D point.
Definition: Point2.h:76