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:
63  static std::unique_ptr<QuadEdge> makeEdge(const Vertex& o, const Vertex& d);
64 
74  static std::unique_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
166  {
167  return isAlive;
168  }
169 
170 
176  inline void
177  setNext(QuadEdge* p_next)
178  {
179  this->next = p_next;
180  }
181 
182  /***************************************************************************
183  * QuadEdge Algebra
184  ***************************************************************************
185  */
186 
192  inline QuadEdge&
193  rot() const
194  {
195  return *_rot;
196  }
197 
203  inline QuadEdge&
204  invRot() const
205  {
206  return rot().sym();
207  }
208 
214  inline QuadEdge&
215  sym() const
216  {
217  return rot().rot();
218  }
219 
225  inline QuadEdge&
226  oNext() const
227  {
228  return *next;
229  }
230 
236  inline QuadEdge&
237  oPrev() const
238  {
239  return rot().oNext().rot();
240  }
241 
247  inline QuadEdge&
248  dNext() const
249  {
250  return sym().oNext().sym();
251  }
252 
258  inline QuadEdge&
259  dPrev() const
260  {
261  return invRot().oNext().invRot();
262  }
263 
269  inline QuadEdge&
270  lNext() const
271  {
272  return invRot().oNext().rot();
273  }
274 
280  inline QuadEdge&
281  lPrev() const
282  {
283  return oNext().sym();
284  }
285 
291  inline QuadEdge&
293  {
294  return rot().oNext().invRot();
295  }
296 
302  inline QuadEdge&
304  {
305  return sym().oNext();
306  }
307 
308  /***********************************************************************************************
309  * Data Access
310  **********************************************************************************************/
316  inline void
317  setOrig(const Vertex& o)
318  {
319  vertex = o;
320  }
321 
327  inline void
328  setDest(const Vertex& d)
329  {
330  sym().setOrig(d);
331  }
332 
338  const Vertex&
339  orig() const
340  {
341  return vertex;
342  }
343 
349  const Vertex&
350  dest() const
351  {
352  return sym().orig();
353  }
354 
360  inline double
361  getLength() const
362  {
363  return orig().getCoordinate().distance(dest().getCoordinate());
364  }
365 
373  bool equalsNonOriented(const QuadEdge& qe) const;
374 
382  bool equalsOriented(const QuadEdge& qe) const;
383 
390  std::unique_ptr<geom::LineSegment> toLineSegment() const;
391 };
392 
393 } //namespace geos.triangulate.quadedge
394 } //namespace geos.triangulate
395 } //namespace goes
396 
397 #endif //GEOS_TRIANGULATE_QUADEDGE_QUADEDGE_H
398 
QuadEdge & sym() const
Definition: QuadEdge.h:215
QuadEdge & invRot() const
Definition: QuadEdge.h:204
void setNext(QuadEdge *p_next)
Definition: QuadEdge.h:177
void setOrig(const Vertex &o)
Definition: QuadEdge.h:317
QuadEdge & dNext() const
Definition: QuadEdge.h:248
QuadEdge & rNext()
Definition: QuadEdge.h:292
QuadEdge & oNext() const
Definition: QuadEdge.h:226
QuadEdge & lNext() const
Definition: QuadEdge.h:270
const Vertex & orig() const
Definition: QuadEdge.h:339
bool isLive()
Definition: QuadEdge.h:165
QuadEdge & lPrev() const
Definition: QuadEdge.h:281
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
void setDest(const Vertex &d)
Definition: QuadEdge.h:328
QuadEdge & rot() const
Definition: QuadEdge.h:193
QuadEdge & dPrev() const
Definition: QuadEdge.h:259
QuadEdge & rPrev()
Definition: QuadEdge.h:303
double getLength() const
Definition: QuadEdge.h:361
const Vertex & dest() const
Definition: QuadEdge.h:350
Definition: QuadEdge.h:51
QuadEdge & oPrev() const
Definition: QuadEdge.h:237