Fade2D Documentation pages v2.12
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
33 class CLASS_DECLSPEC Edge2
34 {
35 public:
36  Edge2();
37  Edge2(const Edge2& e_);
48  Edge2(Triangle2* pT,int oppIdx_);
49  Edge2& operator=(const Edge2& other);
50 
51  ~Edge2();
52 
59  bool operator<(const Edge2& e) const
60  {
61  if(pT<e.pT) return true;
62  if(pT>e.pT) return false;
63  if(oppIdx<e.oppIdx) return true;
64  return false;
65  }
66 
74  bool operator==(const Edge2& e) const
75  {
76  return(pT==e.pT && oppIdx==e.oppIdx);
77  }
85  bool operator!=(const Edge2& e) const
86  {
87  return((pT!=e.pT || oppIdx!=e.oppIdx));
88  }
89 
94  Point2* getSrc() const;
99  Point2* getTrg() const;
100 
105  void getPoints(Point2*& p1,Point2*& p2) const;
106 #if GEOM_PSEUDO3D==GEOM_TRUE
111 #else
116 #endif
117  double getLength2D() const;
118 
119 #if GEOM_PSEUDO3D==GEOM_TRUE
124  double getLength25D() const;
125 #endif
126 
132 
137  int getIndex() const;
138 
150  void getTriangles(Triangle2*& pT0,Triangle2*& pT1,int& idx0,int& idx1) const;
151  friend std::ostream &operator<<(std::ostream &stream, const Edge2& e);
152 
153 protected:
154  Triangle2* pT;
155  int oppIdx;
156 };
157 
159 struct Func_ltUndirected
160 {
161  bool operator()(const Edge2& eA,const Edge2& eB) const
162  {
163  Point2 *pA1,*pA2,*pB1,*pB2;
164  eA.getPoints(pA1,pA2);
165  eB.getPoints(pB1,pB2);
166  if(pA1>pA2) std::swap(pA1,pA2);
167  if(pB1>pB2) std::swap(pB1,pB2);
168 
169  if(pA1<pB1) return true;
170  if(pA1>pB1) return false;
171  return pA2<pB2;
172  }
173 };
174 
175 inline bool sameEdge(const Edge2& eA,const Edge2& eB)
176 {
177  return ( (eA.getSrc()==eB.getSrc() && eA.getTrg()==eB.getTrg()) ||
178  (eA.getSrc()==eB.getTrg() && eA.getTrg()==eB.getSrc()) );
179 }
180 
184 {
185  bool operator()(const Edge2& e0,const Edge2& e1) const
186  {
187  if(e0.getLength2D()<e1.getLength2D()) return true;
188  else return false;
189  }
190 };
194 {
195  bool operator()(const Edge2& e0,const Edge2& e1) const
196  {
197  if(e0.getLength2D()>e1.getLength2D()) return true;
198  else return false;
199  }
200 };
201 
202 
203 #if GEOM_PSEUDO3D==GEOM_TRUE
206 struct Func_ltEdge25D
207 {
208  bool operator()(const Edge2& e0,const Edge2& e1) const
209  {
210  if(e0.getLength25D()<e1.getLength25D()) return true;
211  else return false;
212  }
213 };
214 #endif
215 
216 
217 
218 
219 } // (namespace)
std::ostream & operator<<(std::ostream &stream, const Bbox2 &pC)
Print the box.
Definition: Bbox2.h:492
Edge2 is a directed edge.
Definition: Edge2.h:34
bool operator!=(const Edge2 &e) const
operator!=()
Definition: Edge2.h:85
Triangle2 * getTriangle() const
Edge2(Triangle2 *pT, int oppIdx_)
Constructor.
Point2 * getSrc() const
Get the source point.
bool operator<(const Edge2 &e) const
operator<()
Definition: Edge2.h:59
void getPoints(Point2 *&p1, Point2 *&p2) const
Get the endpoints.
Point2 * getTrg() const
Get the target point.
void getTriangles(Triangle2 *&pT0, Triangle2 *&pT1, int &idx0, int &idx1) const
double getLength2D() const
int getIndex() const
bool operator==(const Edge2 &e) const
operator==()
Definition: Edge2.h:74
Point.
Definition: Point2.h:52
Triangle.
Definition: Triangle2.h:60
Functor to sort edges by 2d length (descending)
Definition: Edge2.h:194
Functor to sort edges by 2d length (ascending)
Definition: Edge2.h:184