Fade2.5D Documentation pages v2.16.7
Delaunay Features
Edge2.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
18 #pragma once
19 
20 #include "common.h"
21 #if GEOM_PSEUDO3D==GEOM_TRUE
22  namespace GEOM_FADE25D {
23 #elif GEOM_PSEUDO3D==GEOM_FALSE
24  namespace GEOM_FADE2D {
25 #else
26  #error GEOM_PSEUDO3D is not defined
27 #endif
28 
29 class Triangle2; // FWD
30 class Point2; // FWD
31 
45 class CLASS_DECLSPEC Edge2
46 {
47 public:
51  Edge2();
57  Edge2(const Edge2& e);
67  Edge2(Triangle2* pT,int oppIdx_);
68 
77  Edge2& operator=(const Edge2& other);
78 
82  ~Edge2();
92  bool operator<(const Edge2& e) const
93  {
94  if(pT<e.pT) return true;
95  if(pT>e.pT) return false;
96  if(oppIdx<e.oppIdx) return true;
97  return false;
98  }
108  bool operator==(const Edge2& e) const
109  {
110  return(pT==e.pT && oppIdx==e.oppIdx);
111  }
122  bool operator!=(const Edge2& e) const
123  {
124  return((pT!=e.pT || oppIdx!=e.oppIdx));
125  }
126 
132  Point2* getSrc() const;
133 
139  Point2* getTrg() const;
146  void getPoints(Point2*& p1,Point2*& p2) const;
158  double getLength2D() const;
159 
160 #if GEOM_PSEUDO3D==GEOM_TRUE
166  double getLength25D() const;
167 #endif
168 
180  int getIndex() const;
190  void getTriangles(Triangle2*& pT0,Triangle2*& pT1,int& idx0,int& idx1) const;
191 
199  friend std::ostream &operator<<(std::ostream &stream, const Edge2& e);
200 
201 protected:
202  Triangle2* pT;
203  int oppIdx;
204 };
205 
207 struct Func_ltUndirected
208 {
209  bool operator()(const Edge2& eA,const Edge2& eB) const
210  {
211  Point2 *pA1,*pA2,*pB1,*pB2;
212  eA.getPoints(pA1,pA2);
213  eB.getPoints(pB1,pB2);
214  if(pA1>pA2) std::swap(pA1,pA2);
215  if(pB1>pB2) std::swap(pB1,pB2);
216 
217  if(pA1<pB1) return true;
218  if(pA1>pB1) return false;
219  return pA2<pB2;
220  }
221 };
223 inline bool sameEdge(const Edge2& eA,const Edge2& eB)
224 {
225  return ( (eA.getSrc()==eB.getSrc() && eA.getTrg()==eB.getTrg()) ||
226  (eA.getSrc()==eB.getTrg() && eA.getTrg()==eB.getSrc()) );
227 }
228 
231 struct Func_ltEdge2D
232 {
233  bool operator()(const Edge2& e0,const Edge2& e1) const
234  {
235  if(e0.getLength2D()<e1.getLength2D()) return true;
236  else return false;
237  }
238 };
241 struct Func_gtEdge2D
242 {
243  bool operator()(const Edge2& e0,const Edge2& e1) const
244  {
245  if(e0.getLength2D()>e1.getLength2D()) return true;
246  else return false;
247  }
248 };
249 
250 
251 #if GEOM_PSEUDO3D==GEOM_TRUE
254 struct Func_ltEdge25D
255 {
256  bool operator()(const Edge2& e0,const Edge2& e1) const
257  {
258  if(e0.getLength25D()<e1.getLength25D()) return true;
259  else return false;
260  }
261 };
262 #endif
263 
264 
265 
266 
267 } // (namespace)
Represents a directed edge in a triangulation.
Definition: Edge2.h:46
bool operator==(const Edge2 &e) const
Equality operator for edges.
Definition: Edge2.h:108
Point2 * getSrc() const
Get the source point of the edge.
friend std::ostream & operator<<(std::ostream &stream, const Edge2 &e)
Stream output for Edge2.
Edge2 & operator=(const Edge2 &other)
Assignment operator.
~Edge2()
Destructor.
void getPoints(Point2 *&p1, Point2 *&p2) const
Get both endpoints of the edge.
void getTriangles(Triangle2 *&pT0, Triangle2 *&pT1, int &idx0, int &idx1) const
Get the two adjacent triangles of the edge.
bool operator<(const Edge2 &e) const
Comparison operator for ordering edges (does not compare the lengths)
Definition: Edge2.h:92
double getLength2D() const
Get the 2D length of the edge.
Edge2(const Edge2 &e)
Copy constructor.
Edge2(Triangle2 *pT, int oppIdx_)
Constructs an Edge2 from a Triangle2 and an intra-triangle-index.
double getLength25D() const
Get the 2.5D length of the edge.
bool operator!=(const Edge2 &e) const
Inequality operator for edges.
Definition: Edge2.h:122
int getIndex() const
Get the intra-triangle-index of the edge.
Triangle2 * getTriangle() const
Get the Triangle2 associated with the edge.
Edge2()
Default constructor.
Point2 * getTrg() const
Get the target point of the edge.
Represents a 2.5D point.
Definition: Point2.h:61
Represents a triangle in a triangulation.
Definition: Triangle2.h:59