Fade2D Documentation pages v2.16.8
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 
85  CLASS_DECLSPEC
86  Point2* getSrc() const;
87 
93  CLASS_DECLSPEC
94  Point2* getTrg() const;
95 
97 
98  void kill() // Only for internal use!
99  {
100  bAlive=false;
101  }
102 
104 
105  bool dbg_hasDirection();
106 
107 
109 
110  void unkill() // Only for internal use!
111  {
112  bAlive=true;
113  }
114 
122  CLASS_DECLSPEC
123  bool isAlive() const;
124 
125 
136 
137 
138 
149  inline bool operator<(const ConstraintSegment2& pOther) const
150  {
151  if(p0<pOther.p0) return true;
152  if(p0>pOther.p0) return false;
153  return p1<pOther.p1;
154  }
155 
175  CLASS_DECLSPEC
176  Point2* insertAndSplit(const Point2& splitPoint);
177 
179  CLASS_DECLSPEC
180  bool split_combinatorialOnly(Point2* pSplit);
181 
183  CLASS_DECLSPEC
184  bool splitAndRemovePrev(const Point2& split);
185 
186 
187  //Sets a specific ConstraintGraph2 as owner of the current ConstraintSegment2.
189  void addOwnerRecursive(ConstraintGraph2* pOwner);
190 
191  // Removes a specific ConstraintGraph2 as owner of the current ConstraintSegment2.
193  void removeOwner(ConstraintGraph2* pOwner);
194 
204  CLASS_DECLSPEC
205  void getChildrenRec(std::vector<ConstraintSegment2*>& vChildConstraintSegments);
206 
218  CLASS_DECLSPEC
220 
221 
222  CLASS_DECLSPEC
223  friend std::ostream &operator<<(std::ostream &stream, const ConstraintSegment2& cSeg);
224 
225 
227  CLASS_DECLSPEC
228  size_t getNumberOfOwners() const;
229 
230  // Not thought for public use. If the current constraint segment is a border segment, then
231  // the area of the thought, non-existing outside triangle can manually be deposited here.
232  // This value is used by the extended meshing method when a grow factor is given or ignored
233  // if not set.
235  CLASS_DECLSPEC
236  void setAdjacentArea(double adjacentArea_);
237 
239  CLASS_DECLSPEC
240  int getLabel() const;
241 
243  CLASS_DECLSPEC
244  std::string getLabelString() const;
245 
246  // Not thought for public use: Returns a previously via setAdjacentArea(double adjacentArea_) deposited value. If not explicitly set, DBL_MAX is returned.
248  CLASS_DECLSPEC
249  double getAdjacentArea() const;
250 
251  static int runningLabel;
252  int label;
253 protected:
255  std::set<ConstraintGraph2*> sOwners;
256  Point2 *p0,*p1;
258  bool bAlive;
259  std::vector<ConstraintSegment2*> vChildren;
260  std::vector<ConstraintSegment2*> vParents;
262  double adjacentArea;
263 };
264 
265 } // 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:149
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