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