Geom Software - C++ Programming and Geometry Libraries
Fade2.5D Documentation pages v1.58
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();
50 
57  bool operator<(const Edge2& e) const
58  {
59  if(pT<e.pT) return true;
60  if(pT>e.pT) return false;
61  if(oppIdx<e.oppIdx) return true;
62  return false;
63  }
64 
71  bool operator==(const Edge2& e) const
72  {
73  return(pT==e.pT && oppIdx==e.oppIdx);
74  }
82  bool operator!=(const Edge2& e) const
83  {
84  return((pT!=e.pT || oppIdx!=e.oppIdx));
85  }
86 
91  Point2* getSrc() const;
96  Point2* getTrg() const;
97 
102  void getPoints(Point2*& p1,Point2*& p2) const;
103 #if GEOM_PSEUDO3D==GEOM_TRUE
104 
108 #else
109 
113 #endif
114  double getLength2D() const;
115 
116 #if GEOM_PSEUDO3D==GEOM_TRUE
117 
121  double getLength25D() const;
122 #endif
123 
128  Triangle2* getTriangle() const;
140  void getTriangles(Triangle2*& pT0,Triangle2*& pT1,int& idx0,int& idx1) const;
141  friend std::ostream &operator<<(std::ostream &stream, const Edge2& e);
142 
143 protected:
144  Triangle2* pT;
145  int oppIdx;
146 };
147 
149 {
150  bool operator()(const Edge2& eA,const Edge2& eB) const
151  {
152  Point2 *pA1,*pA2,*pB1,*pB2;
153  eA.getPoints(pA1,pA2);
154  eB.getPoints(pB1,pB2);
155  if(pA1>pA2) std::swap(pA1,pA2);
156  if(pB1>pB2) std::swap(pB1,pB2);
157 
158  if(pA1<pB1) return true;
159  if(pA1>pB1) return false;
160  if(pA2<pB2) return true;
161  if(pA2>pB2) return false;
162  return false;
163  }
164 };
165 
169 {
170  bool operator()(const Edge2& e0,const Edge2& e1) const
171  {
172  if(e0.getLength2D()<e1.getLength2D()) return true;
173  else return false;
174  }
175 };
179 {
180  bool operator()(const Edge2& e0,const Edge2& e1) const
181  {
182  if(e0.getLength2D()>e1.getLength2D()) return true;
183  else return false;
184  }
185 };
186 
187 
188 #if GEOM_PSEUDO3D==GEOM_TRUE
189 
192 {
193  bool operator()(const Edge2& e0,const Edge2& e1) const
194  {
195  if(e0.getLength25D()<e1.getLength25D()) return true;
196  else return false;
197  }
198 };
199 #endif
200 
201 
202 
203 
204 } // (namespace)
bool operator!=(const Edge2 &e) const
operator!=()
Definition: Edge2.h:82
bool operator<(const Edge2 &e) const
operator<()
Definition: Edge2.h:57
Functor to sort edges by 2d length (ascending)
Definition: Edge2.h:168
void getPoints(Point2 *&p1, Point2 *&p2) const
Get the endpoints.
double getLength2D() const
Triangle.
Definition: Triangle2.h:48
Definition: Edge2.h:148
double getLength25D() const
Definition: Bbox2.h:23
Directed Edge.
Definition: Edge2.h:33
Functor to sort edges by 2.5d length (ascending)
Definition: Edge2.h:191
bool operator==(const Edge2 &e) const
operator==()
Definition: Edge2.h:71
Point.
Definition: Point2.h:39
Functor to sort edges by 2d length (descending)
Definition: Edge2.h:178