Geom Software - C++ Programming and Geometry Libraries
Fade2.5D Documentation pages v1.63
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;
142  void getTriangles(Triangle2*& pT0,Triangle2*& pT1,int& idx0,int& idx1) const;
143  friend std::ostream &operator<<(std::ostream &stream, const Edge2& e);
144 
145 protected:
146  Triangle2* pT;
147  int oppIdx;
148 };
149 
151 {
152  bool operator()(const Edge2& eA,const Edge2& eB) const
153  {
154  Point2 *pA1,*pA2,*pB1,*pB2;
155  eA.getPoints(pA1,pA2);
156  eB.getPoints(pB1,pB2);
157  if(pA1>pA2) std::swap(pA1,pA2);
158  if(pB1>pB2) std::swap(pB1,pB2);
159 
160  if(pA1<pB1) return true;
161  if(pA1>pB1) return false;
162  if(pA2<pB2) return true;
163  if(pA2>pB2) return false;
164  return false;
165  }
166 };
167 
171 {
172  bool operator()(const Edge2& e0,const Edge2& e1) const
173  {
174  if(e0.getLength2D()<e1.getLength2D()) return true;
175  else return false;
176  }
177 };
181 {
182  bool operator()(const Edge2& e0,const Edge2& e1) const
183  {
184  if(e0.getLength2D()>e1.getLength2D()) return true;
185  else return false;
186  }
187 };
188 
189 
190 #if GEOM_PSEUDO3D==GEOM_TRUE
191 
194 {
195  bool operator()(const Edge2& e0,const Edge2& e1) const
196  {
197  if(e0.getLength25D()<e1.getLength25D()) return true;
198  else return false;
199  }
200 };
201 #endif
202 
203 
204 
205 
206 } // (namespace)
bool operator!=(const Edge2 &e) const
operator!=()
Definition: Edge2.h:84
bool operator<(const Edge2 &e) const
operator<()
Definition: Edge2.h:59
Functor to sort edges by 2d length (ascending)
Definition: Edge2.h:170
void getPoints(Point2 *&p1, Point2 *&p2) const
Get the endpoints.
double getLength2D() const
Triangle.
Definition: Triangle2.h:48
Definition: Edge2.h:150
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:193
bool operator==(const Edge2 &e) const
operator==()
Definition: Edge2.h:73
Point.
Definition: Point2.h:39
Functor to sort edges by 2d length (descending)
Definition: Edge2.h:180