Fade2.5D Documentation pages v1.97
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 
178 {
179  bool operator()(const Edge2& e0,const Edge2& e1) const
180  {
181  if(e0.getLength2D()<e1.getLength2D()) return true;
182  else return false;
183  }
184 };
188 {
189  bool operator()(const Edge2& e0,const Edge2& e1) const
190  {
191  if(e0.getLength2D()>e1.getLength2D()) return true;
192  else return false;
193  }
194 };
195 
196 
197 #if GEOM_PSEUDO3D==GEOM_TRUE
201 {
202  bool operator()(const Edge2& e0,const Edge2& e1) const
203  {
204  if(e0.getLength25D()<e1.getLength25D()) return true;
205  else return false;
206  }
207 };
208 #endif
209 
210 
211 
212 
213 } // (namespace)
std::ostream & operator<<(std::ostream &stream, const Bbox2 &pC)
Print the box.
Definition: Bbox2.h:450
Edge2 is a directed edge.
Definition: Edge2.h:34
bool operator==(const Edge2 &e) const
operator==()
Definition: Edge2.h:74
Point2 * getSrc() const
Get the source point.
void getPoints(Point2 *&p1, Point2 *&p2) const
Get the endpoints.
void getTriangles(Triangle2 *&pT0, Triangle2 *&pT1, int &idx0, int &idx1) const
bool operator<(const Edge2 &e) const
operator<()
Definition: Edge2.h:59
double getLength2D() const
Edge2(Triangle2 *pT, int oppIdx_)
Constructor.
double getLength25D() const
bool operator!=(const Edge2 &e) const
operator!=()
Definition: Edge2.h:85
int getIndex() const
Triangle2 * getTriangle() const
Point2 * getTrg() const
Get the target point.
Point.
Definition: Point2.h:43
Triangle.
Definition: Triangle2.h:59
Functor to sort edges by 2d length (descending)
Definition: Edge2.h:188
Functor to sort edges by 2.5d length (ascending)
Definition: Edge2.h:201
Functor to sort edges by 2d length (ascending)
Definition: Edge2.h:178