GEOS 3.8.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
27namespace geos {
28namespace triangulate { //geos.triangulate
29namespace quadedge { //geos.triangulate.quadedge
30
51class GEOS_DLL QuadEdge {
52public:
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
98private:
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 bool visited;
106
111 QuadEdge();
112
113public:
114 virtual ~QuadEdge();
115
123 virtual void free();
124
134 const QuadEdge& getPrimary() const;
135
141 virtual void setData(void* data);
142
148 virtual void* getData();
149
161 void remove();
162
168 inline bool
169 isLive() const
170 {
171 return isAlive;
172 }
173
174 inline bool
175 isVisited() const
176 {
177 return visited;
178 }
179
180 inline void
181 setVisited(bool v) {
182 visited = v;
183 }
184
190 inline void
192 {
193 this->next = p_next;
194 }
195
196 /***************************************************************************
197 * QuadEdge Algebra
198 ***************************************************************************
199 */
200
206 inline QuadEdge&
207 rot() const
208 {
209 return *_rot;
210 }
211
217 inline QuadEdge&
218 invRot() const
219 {
220 return rot().sym();
221 }
222
228 inline QuadEdge&
229 sym() const
230 {
231 return rot().rot();
232 }
233
239 inline QuadEdge&
240 oNext() const
241 {
242 return *next;
243 }
244
250 inline QuadEdge&
251 oPrev() const
252 {
253 return rot().oNext().rot();
254 }
255
261 inline QuadEdge&
262 dNext() const
263 {
264 return sym().oNext().sym();
265 }
266
272 inline QuadEdge&
273 dPrev() const
274 {
275 return invRot().oNext().invRot();
276 }
277
283 inline QuadEdge&
284 lNext() const
285 {
286 return invRot().oNext().rot();
287 }
288
294 inline QuadEdge&
295 lPrev() const
296 {
297 return oNext().sym();
298 }
299
305 inline QuadEdge&
307 {
308 return rot().oNext().invRot();
309 }
310
316 inline QuadEdge&
318 {
319 return sym().oNext();
320 }
321
322 /***********************************************************************************************
323 * Data Access
324 **********************************************************************************************/
330 inline void
331 setOrig(const Vertex& o)
332 {
333 vertex = o;
334 }
335
341 inline void
342 setDest(const Vertex& d)
343 {
344 sym().setOrig(d);
345 }
346
352 const Vertex&
353 orig() const
354 {
355 return vertex;
356 }
357
363 const Vertex&
364 dest() const
365 {
366 return sym().orig();
367 }
368
374 inline double
375 getLength() const
376 {
377 return orig().getCoordinate().distance(dest().getCoordinate());
378 }
379
387 bool equalsNonOriented(const QuadEdge& qe) const;
388
396 bool equalsOriented(const QuadEdge& qe) const;
397
404 std::unique_ptr<geom::LineSegment> toLineSegment() const;
405};
406
407} //namespace geos.triangulate.quadedge
408} //namespace geos.triangulate
409} //namespace goes
410
411#endif //GEOS_TRIANGULATE_QUADEDGE_QUADEDGE_H
412
A class that represents the edge data structure which implements the quadedge algebra.
Definition: QuadEdge.h:51
std::unique_ptr< geom::LineSegment > toLineSegment() const
Creates a geom::LineSegment representing the geometry of this edge.
QuadEdge & sym() const
Gets the edge from the destination to the origin of this edge.
Definition: QuadEdge.h:229
void setOrig(const Vertex &o)
Sets the vertex for this edge's origin.
Definition: QuadEdge.h:331
bool equalsOriented(const QuadEdge &qe) const
Tests if this quadedge and another have the same line segment geometry with the same orientation.
QuadEdge & oNext() const
Gets the next CCW edge around the origin of this edge.
Definition: QuadEdge.h:240
void setDest(const Vertex &d)
Sets the vertex for this edge's destination.
Definition: QuadEdge.h:342
QuadEdge & dPrev() const
Gets the next CW edge around (into) the destination of this edge.
Definition: QuadEdge.h:273
QuadEdge & rPrev()
Gets the edge around the right face ccw before this edge.
Definition: QuadEdge.h:317
QuadEdge & dNext() const
Gets the next CCW edge around (into) the destination of this edge.
Definition: QuadEdge.h:262
static std::unique_ptr< QuadEdge > makeEdge(const Vertex &o, const Vertex &d)
Creates a new QuadEdge quartet from Vertex o to Vertex d.
QuadEdge & lNext() const
Gets the CCW edge around the left face following this edge.
Definition: QuadEdge.h:284
virtual void setData(void *data)
Sets the external data value for this edge.
static void swap(QuadEdge &e)
Turns an edge counterclockwise inside its enclosing quadrilateral.
QuadEdge & oPrev() const
Gets the next CW edge around (from) the origin of this edge.
Definition: QuadEdge.h:251
QuadEdge & lPrev() const
Gets the CCW edge around the left face before this edge.
Definition: QuadEdge.h:295
virtual void free()
Free the QuadEdge quartet associated with this QuadEdge by a connect() or makeEdge() call.
void remove()
Marks this quadedge as being deleted.
QuadEdge & rot() const
Gets the dual of this edge, directed from its right to its left.
Definition: QuadEdge.h:207
const QuadEdge & getPrimary() const
Gets the primary edge of this quadedge and its sym.
bool isLive() const
Tests whether this edge has been deleted.
Definition: QuadEdge.h:169
QuadEdge & rNext()
Gets the edge around the right face ccw following this edge.
Definition: QuadEdge.h:306
const Vertex & orig() const
Gets the vertex for the edge's origin.
Definition: QuadEdge.h:353
static void splice(QuadEdge &a, QuadEdge &b)
Splices two edges together or apart.
double getLength() const
Gets the length of the geometry of this quadedge.
Definition: QuadEdge.h:375
QuadEdge & invRot() const
Gets the dual of this edge, directed from its left to its right.
Definition: QuadEdge.h:218
bool equalsNonOriented(const QuadEdge &qe) const
Tests if this quadedge and another have the same line segment geometry, regardless of orientation.
const Vertex & dest() const
Gets the vertex for the edge's destination.
Definition: QuadEdge.h:364
void setNext(QuadEdge *p_next)
Sets the connected edge.
Definition: QuadEdge.h:191
static std::unique_ptr< QuadEdge > connect(QuadEdge &a, QuadEdge &b)
Creates a new QuadEdge connecting the destination of a to the origin of b, in such a way that all thr...
virtual void * getData()
Gets the external data value for this edge.
Models a site (node) in a QuadEdgeSubdivision.
Definition: Vertex.h:59
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25