Fade2D Documentation pages v1.86
Delaunay Features
Edge2.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 #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 
73  bool operator==(const Edge2& e) const
74  {
75  return(pT==e.pT && oppIdx==e.oppIdx);
76  }
84  bool operator!=(const Edge2& e) const
85  {
86  return((pT!=e.pT || oppIdx!=e.oppIdx));
87  }
88 
93  Point2* getSrc() const;
98  Point2* getTrg() const;
99 
104  void getPoints(Point2*& p1,Point2*& p2) const;
105 #if GEOM_PSEUDO3D==GEOM_TRUE
106 
110 #else
111 
115 #endif
116  double getLength2D() const;
117 
118 #if GEOM_PSEUDO3D==GEOM_TRUE
119 
123  double getLength25D() const;
124 #endif
125 
130  Triangle2* getTriangle() const;
131 
136  int getIndex() const;
137 
149  void getTriangles(Triangle2*& pT0,Triangle2*& pT1,int& idx0,int& idx1) const;
150  friend std::ostream &operator<<(std::ostream &stream, const Edge2& e);
151 
152 protected:
153  Triangle2* pT;
154  int oppIdx;
155 };
156 
158 struct Func_ltUndirected
159 {
160  bool operator()(const Edge2& eA,const Edge2& eB) const
161  {
162  Point2 *pA1,*pA2,*pB1,*pB2;
163  eA.getPoints(pA1,pA2);
164  eB.getPoints(pB1,pB2);
165  if(pA1>pA2) std::swap(pA1,pA2);
166  if(pB1>pB2) std::swap(pB1,pB2);
167 
168  if(pA1<pB1) return true;
169  if(pA1>pB1) return false;
170  return pA2<pB2;
171  }
172 };
173 
177 {
178  bool operator()(const Edge2& e0,const Edge2& e1) const
179  {
180  if(e0.getLength2D()<e1.getLength2D()) return true;
181  else return false;
182  }
183 };
187 {
188  bool operator()(const Edge2& e0,const Edge2& e1) const
189  {
190  if(e0.getLength2D()>e1.getLength2D()) return true;
191  else return false;
192  }
193 };
194 
195 
196 #if GEOM_PSEUDO3D==GEOM_TRUE
197 
199 struct Func_ltEdge25D
200 {
201  bool operator()(const Edge2& e0,const Edge2& e1) const
202  {
203  if(e0.getLength25D()<e1.getLength25D()) return true;
204  else return false;
205  }
206 };
207 #endif
208 
209 
210 
211 
212 } // (namespace)
GEOM_FADE2D::Triangle2
Triangle.
Definition: Triangle2.h:48
GEOM_FADE2D::Func_gtEdge2D
Functor to sort edges by 2d length (descending)
Definition: Edge2.h:186
GEOM_FADE2D::Point2
Point.
Definition: Point2.h:40
GEOM_FADE2D::Edge2::operator<
bool operator<(const Edge2 &e) const
operator<()
Definition: Edge2.h:59
GEOM_FADE2D::Edge2::operator!=
bool operator!=(const Edge2 &e) const
operator!=()
Definition: Edge2.h:84
GEOM_FADE2D::Edge2::getLength2D
double getLength2D() const
GEOM_FADE2D::Func_ltEdge2D
Functor to sort edges by 2d length (ascending)
Definition: Edge2.h:176
GEOM_FADE2D::Edge2::operator==
bool operator==(const Edge2 &e) const
operator==()
Definition: Edge2.h:73
GEOM_FADE2D::Edge2
Edge2 is a directed edge.
Definition: Edge2.h:33