Fade2D Documentation pages v2.16.7
Delaunay Features
VertexPair2.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 #pragma once
18 
19 #include "common.h"
20 #include "Point2.h"
21 #include <ostream>
22 
23 #if GEOM_PSEUDO3D==GEOM_TRUE
24  namespace GEOM_FADE25D {
25 #elif GEOM_PSEUDO3D==GEOM_FALSE
26  namespace GEOM_FADE2D {
27 #else
28  #error GEOM_PSEUDO3D is not defined
29 #endif
30 
31 
41 struct CLASS_DECLSPEC VertexPair2
42 {
43 public:
55  VertexPair2(Point2* pSource,Point2* pTarget):p0(pSource),p1(pTarget)
56  {
57  if(p0==p1)
58  {
59  GCOUT<<std::endl;
60  GCOUT<<"VertexPair2::VertexPair2(),pSource==pTarget"<<std::endl;
61  GCOUT<<"p0="<<p0<<", p1="<<p1<<std::endl;
62  GCOUT<<"*p0="<<*p0<<", *p1="<<*p1<<std::endl;
63  assert(p0!=p1);
64  }
65  if(p0>p1)
66  {
67  bReverse=true;
68  std::swap(p0, p1);
69  }
70  else
71  {
72  bReverse=false;
73  }
74  }
76  VertexPair2():p0(NULL),p1(NULL),bReverse(false)
77  {
78  }
79 
87  double getSqLen2D() const
88  {
89  return sqDistance2D(*p0,*p1);
90  }
91 #if GEOM_PSEUDO3D==GEOM_TRUE
99  double getSqLen25D() const
100  {
101  return sqDistance25D(*p0,*p1);
102  }
103 #endif
104 
112  bool operator==(const VertexPair2& other) const
113  {
114  return (p0==other.p0 && p1==other.p1);
115  }
116 
125  bool operator<(const VertexPair2& other) const
126  {
127  if(p0<other.p0) return true;
128  if(p0>other.p0) return false;
129  return (p1<other.p1);
130  }
131 
132 
142  CLASS_DECLSPEC
143  friend std::ostream &operator<<(std::ostream &stream, const VertexPair2& pr);
144 
152  Point2* getSrc() const
153  {
154  if(bReverse) return p1;
155  else return p0;
156  }
157 
165  Point2* getTrg() const
166  {
167  if(bReverse) return p0;
168  else return p1;
169  }
170  // Data
173  bool bReverse;
174 };
175 
176 
177 inline std::ostream &operator<<(std::ostream &stream, const VertexPair2& pr)
178 {
179  stream << "("<<pr.p0<<","<<pr.p1<<"), "<<*pr.getSrc()<<" -> "<<*pr.getTrg();
180  return stream;
181 }
182 
183 } // (namespace)
std::ostream & operator<<(std::ostream &stream, const Bbox2 &pC)
Prints the bounding box to a stream.
Definition: Bbox2.h:605
double sqDistance2D(const Point2 &p0, const Point2 &p1)
Get the squared 2D distance between two points.
Definition: Point2.h:667
Represents a 2D point.
Definition: Point2.h:61
An edge consisting of two vertex pointers.
Definition: VertexPair2.h:42
Point2 * p0
The smaller vertex pointer.
Definition: VertexPair2.h:171
VertexPair2()
Default constructor.
Definition: VertexPair2.h:76
bool operator==(const VertexPair2 &other) const
Equality operator.
Definition: VertexPair2.h:112
bool bReverse
Flag indicating if the pointers were reversed.
Definition: VertexPair2.h:173
Point2 * p1
The larger vertex pointer.
Definition: VertexPair2.h:172
bool operator<(const VertexPair2 &other) const
Less-than operator.
Definition: VertexPair2.h:125
Point2 * getTrg() const
Get the oriented target vertex pointer.
Definition: VertexPair2.h:165
Point2 * getSrc() const
Get the oriented source vertex pointer.
Definition: VertexPair2.h:152
double getSqLen2D() const
Get the squared 2D length of the edge.
Definition: VertexPair2.h:87
VertexPair2(Point2 *pSource, Point2 *pTarget)
Constructor that initializes the vertex pair with two different vertex pointers.
Definition: VertexPair2.h:55