GEOS  3.8.0dev
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:
61  static std::unique_ptr<QuadEdge> makeEdge(const Vertex& o, const Vertex& d);
62 
73  static std::unique_ptr<QuadEdge> connect(QuadEdge& a, QuadEdge& b);
74 
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 
122  virtual void free();
123 
133  const QuadEdge& getPrimary() const;
134 
140  virtual void setData(void* data);
141 
147  virtual void* getData();
148 
160  void remove();
161 
167  inline bool
169  {
170  return isAlive;
171  }
172 
173 
179  inline void
180  setNext(QuadEdge* p_next)
181  {
182  this->next = p_next;
183  }
184 
185  /***************************************************************************
186  * QuadEdge Algebra
187  ***************************************************************************
188  */
189 
195  inline QuadEdge&
196  rot() const
197  {
198  return *_rot;
199  }
200 
206  inline QuadEdge&
207  invRot() const
208  {
209  return rot().sym();
210  }
211 
217  inline QuadEdge&
218  sym() const
219  {
220  return rot().rot();
221  }
222 
228  inline QuadEdge&
229  oNext() const
230  {
231  return *next;
232  }
233 
239  inline QuadEdge&
240  oPrev() const
241  {
242  return rot().oNext().rot();
243  }
244 
250  inline QuadEdge&
251  dNext() const
252  {
253  return sym().oNext().sym();
254  }
255 
261  inline QuadEdge&
262  dPrev() const
263  {
264  return invRot().oNext().invRot();
265  }
266 
272  inline QuadEdge&
273  lNext() const
274  {
275  return invRot().oNext().rot();
276  }
277 
283  inline QuadEdge&
284  lPrev() const
285  {
286  return oNext().sym();
287  }
288 
294  inline QuadEdge&
296  {
297  return rot().oNext().invRot();
298  }
299 
305  inline QuadEdge&
307  {
308  return sym().oNext();
309  }
310 
311  /***********************************************************************************************
312  * Data Access
313  **********************************************************************************************/
319  inline void
320  setOrig(const Vertex& o)
321  {
322  vertex = o;
323  }
324 
330  inline void
331  setDest(const Vertex& d)
332  {
333  sym().setOrig(d);
334  }
335 
341  const Vertex&
342  orig() const
343  {
344  return vertex;
345  }
346 
352  const Vertex&
353  dest() const
354  {
355  return sym().orig();
356  }
357 
363  inline double
364  getLength() const
365  {
366  return orig().getCoordinate().distance(dest().getCoordinate());
367  }
368 
376  bool equalsNonOriented(const QuadEdge& qe) const;
377 
385  bool equalsOriented(const QuadEdge& qe) const;
386 
393  std::unique_ptr<geom::LineSegment> toLineSegment() const;
394 };
395 
396 } //namespace geos.triangulate.quadedge
397 } //namespace geos.triangulate
398 } //namespace goes
399 
400 #endif //GEOS_TRIANGULATE_QUADEDGE_QUADEDGE_H
401 
QuadEdge & sym() const
Gets the edge from the destination to the origin of this edge.
Definition: QuadEdge.h:218
QuadEdge & invRot() const
Gets the dual of this edge, directed from its left to its right.
Definition: QuadEdge.h:207
void setNext(QuadEdge *p_next)
Sets the connected edge.
Definition: QuadEdge.h:180
void setOrig(const Vertex &o)
Sets the vertex for this edge's origin.
Definition: QuadEdge.h:320
QuadEdge & dNext() const
Gets the next CCW edge around (into) the destination of this edge.
Definition: QuadEdge.h:251
Models a site (node) in a QuadEdgeSubdivision.
Definition: Vertex.h:59
QuadEdge & rNext()
Gets the edge around the right face ccw following this edge.
Definition: QuadEdge.h:295
QuadEdge & oNext() const
Gets the next CCW edge around the origin of this edge.
Definition: QuadEdge.h:229
QuadEdge & lNext() const
Gets the CCW edge around the left face following this edge.
Definition: QuadEdge.h:273
const Vertex & orig() const
Gets the vertex for the edge's origin.
Definition: QuadEdge.h:342
bool isLive()
Tests whether this edge has been deleted.
Definition: QuadEdge.h:168
QuadEdge & lPrev() const
Gets the CCW edge around the left face before this edge.
Definition: QuadEdge.h:284
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
void setDest(const Vertex &d)
Sets the vertex for this edge's destination.
Definition: QuadEdge.h:331
QuadEdge & rot() const
Gets the dual of this edge, directed from its right to its left.
Definition: QuadEdge.h:196
QuadEdge & dPrev() const
Gets the next CW edge around (into) the destination of this edge.
Definition: QuadEdge.h:262
QuadEdge & rPrev()
Gets the edge around the right face ccw before this edge.
Definition: QuadEdge.h:306
double getLength() const
Gets the length of the geometry of this quadedge.
Definition: QuadEdge.h:364
const Vertex & dest() const
Gets the vertex for the edge's destination.
Definition: QuadEdge.h:353
A class that represents the edge data structure which implements the quadedge algebra.
Definition: QuadEdge.h:51
QuadEdge & oPrev() const
Gets the next CW edge around (from) the origin of this edge.
Definition: QuadEdge.h:240