GEOS  3.6.1
QuadEdge.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2012 Excensus LLC.
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU Lesser General Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  **********************************************************************
14  *
15  * Last port: triangulate/quadedge/QuadEdge.java r524
16  *
17  **********************************************************************/
18 
19 #ifndef GEOS_TRIANGULATE_QUADEDGE_QUADEDGE_H
20 #define GEOS_TRIANGULATE_QUADEDGE_QUADEDGE_H
21 
22 #include <memory>
23 
24 #include <geos/triangulate/quadedge/Vertex.h>
25 #include <geos/geom/LineSegment.h>
26 
27 namespace geos {
28 namespace triangulate { //geos.triangulate
29 namespace quadedge { //geos.triangulate.quadedge
30 
51 class GEOS_DLL QuadEdge {
52 public:
63  static std::auto_ptr<QuadEdge> makeEdge(const Vertex &o, const Vertex &d);
64 
74  static std::auto_ptr<QuadEdge> connect(QuadEdge &a, QuadEdge &b);
75 
89  static void splice(QuadEdge &a, QuadEdge &b);
90 
96  static void swap(QuadEdge &e);
97 
98 private:
100  QuadEdge *_rot;
101  Vertex vertex; // The vertex that this edge represents
102  QuadEdge *next; // A reference to a connected edge
103  void* data;
104  bool isAlive;
105 
110  QuadEdge();
111 
112 public:
113  virtual ~QuadEdge();
114 
121  virtual void free();
122 
131  const QuadEdge& getPrimary() const;
132 
138  virtual void setData(void* data);
139 
145  virtual void* getData();
146 
157  void remove();
158 
164  inline bool isLive() {
165  return isAlive;
166  }
167 
168 
174  inline void setNext(QuadEdge *next) {
175  this->next = next;
176  }
177 
178  /***************************************************************************
179  * QuadEdge Algebra
180  ***************************************************************************
181  */
182 
188  inline QuadEdge& rot() const {
189  return *_rot;
190  }
191 
197  inline QuadEdge& invRot() const {
198  return rot().sym();
199  }
200 
206  inline QuadEdge& sym() const {
207  return rot().rot();
208  }
209 
215  inline QuadEdge& oNext() const {
216  return *next;
217  }
218 
224  inline QuadEdge& oPrev() const {
225  return rot().oNext().rot();
226  }
227 
233  inline QuadEdge& dNext() const {
234  return sym().oNext().sym();
235  }
236 
242  inline QuadEdge& dPrev() const {
243  return invRot().oNext().invRot();
244  }
245 
251  inline QuadEdge& lNext() const {
252  return invRot().oNext().rot();
253  }
254 
260  inline QuadEdge& lPrev() const {
261  return oNext().sym();
262  }
263 
269  inline QuadEdge& rNext() {
270  return rot().oNext().invRot();
271  }
272 
278  inline QuadEdge& rPrev() {
279  return sym().oNext();
280  }
281 
282  /***********************************************************************************************
283  * Data Access
284  **********************************************************************************************/
290  inline void setOrig(const Vertex &o) {
291  vertex = o;
292  }
293 
299  inline void setDest(const Vertex &d) {
300  sym().setOrig(d);
301  }
302 
308  const Vertex& orig() const {
309  return vertex;
310  }
311 
317  const Vertex& dest() const {
318  return sym().orig();
319  }
320 
326  inline double getLength() const {
327  return orig().getCoordinate().distance(dest().getCoordinate());
328  }
329 
337  bool equalsNonOriented(const QuadEdge &qe) const;
338 
346  bool equalsOriented(const QuadEdge &qe) const;
347 
354  std::auto_ptr<geom::LineSegment> toLineSegment() const;
355 };
356 
357 } //namespace geos.triangulate.quadedge
358 } //namespace geos.triangulate
359 } //namespace goes
360 
361 #endif //GEOS_TRIANGULATE_QUADEDGE_QUADEDGE_H
362 
QuadEdge & dPrev() const
Definition: QuadEdge.h:242
void setOrig(const Vertex &o)
Definition: QuadEdge.h:290
QuadEdge & lNext() const
Definition: QuadEdge.h:251
const Vertex & orig() const
Definition: QuadEdge.h:308
QuadEdge & rNext()
Definition: QuadEdge.h:269
QuadEdge & oNext() const
Definition: QuadEdge.h:215
QuadEdge & invRot() const
Definition: QuadEdge.h:197
bool isLive()
Definition: QuadEdge.h:164
QuadEdge & dNext() const
Definition: QuadEdge.h:233
QuadEdge & rot() const
Definition: QuadEdge.h:188
void setNext(QuadEdge *next)
Definition: QuadEdge.h:174
QuadEdge & sym() const
Definition: QuadEdge.h:206
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
void setDest(const Vertex &d)
Definition: QuadEdge.h:299
QuadEdge & rPrev()
Definition: QuadEdge.h:278
QuadEdge & oPrev() const
Definition: QuadEdge.h:224
Definition: QuadEdge.h:51
double getLength() const
Definition: QuadEdge.h:326
QuadEdge & lPrev() const
Definition: QuadEdge.h:260
const Vertex & dest() const
Definition: QuadEdge.h:317