GEOS  3.9.0dev
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2012 Excensus LLC.
7  * Copyright (C) 2019 Daniel Baston
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Licence as published
11  * by the Free Software Foundation.
13  *
14  **********************************************************************
15  *
17  *
18  **********************************************************************/
19
22
23 #include <memory>
24
26 #include <geos/geom/LineSegment.h>
27
28 namespace geos {
29 namespace triangulate { //geos.triangulate
31
32
34
56 public:
65  static QuadEdge* makeEdge(const Vertex& o, const Vertex & d, std::deque<QuadEdgeQuartet> & edges);
66
77
93
100
101 private:
103  Vertex vertex; // The vertex that this edge represents
104  QuadEdge* next; // A reference to a connected edge
105
106  int8_t num; // the position of the QuadEdge in the quartet (0-3)
107
108  bool isAlive;
109  bool visited;
110
116  next(nullptr),
117  num(_num),
118  isAlive(true),
119  visited(false) {
120  }
121
122 public:
133
145  void remove();
146
152  inline bool
153  isLive() const
154  {
155  return isAlive;
156  }
157
158  inline bool
159  isVisited() const
160  {
161  return visited;
162  }
163
164  inline void
165  setVisited(bool v) {
166  visited = v;
167  }
168
174  inline void
176  {
177  this->next = p_next;
178  }
179
180  /***************************************************************************
182  ***************************************************************************
183  */
184
191  rot() const
192  {
193  return (num < 3) ? *(this + 1) : *(this - 3);
194  }
195
197  rot()
198  {
199  return (num < 3) ? *(this + 1) : *(this - 3);
200  }
201
208  invRot() const
209  {
210  return (num > 0) ? *(this - 1) : *(this + 3);
211  }
212
214  invRot()
215  {
216  return (num > 0) ? *(this - 1) : *(this + 3);
217  }
218
225  sym() const
226  {
227  return (num < 2) ? *(this + 2) : *(this - 2);
228  }
229
231  sym()
232  {
233  return (num < 2) ? *(this + 2) : *(this - 2);
234  }
235
242  oNext() const
243  {
244  return *next;
245  }
246
248  oNext()
249  {
250  return *next;
251  }
252
259  oPrev() const
260  {
261  return rot().oNext().rot();
262  }
263
265  oPrev()
266  {
267  return rot().oNext().rot();
268  }
269
276  dNext() const
277  {
278  return sym().oNext().sym();
279  }
280
287  dPrev() const
288  {
289  return invRot().oNext().invRot();
290  }
291
293  dPrev()
294  {
295  return invRot().oNext().invRot();
296  }
297
304  lNext() const
305  {
306  return invRot().oNext().rot();
307  }
308
310  lNext()
311  {
312  return invRot().oNext().rot();
313  }
314
321  lPrev() const
322  {
323  return oNext().sym();
324  }
325
327  lPrev()
328  {
329  return oNext().sym();
330  }
331
338  rNext() const
339  {
340  return rot().oNext().invRot();
341  }
342
349  rPrev() const
350  {
351  return sym().oNext();
352  }
353
354  /***********************************************************************************************
355  * Data Access
356  **********************************************************************************************/
362  inline void
363  setOrig(const Vertex& o)
364  {
365  vertex = o;
366  }
367
373  inline void
374  setDest(const Vertex& d)
375  {
376  sym().setOrig(d);
377  }
378
384  const Vertex&
385  orig() const
386  {
387  return vertex;
388  }
389
395  const Vertex&
396  dest() const
397  {
398  return sym().orig();
399  }
400
406  inline double
407  getLength() const
408  {
409  return orig().getCoordinate().distance(dest().getCoordinate());
410  }
411
419  bool equalsNonOriented(const QuadEdge& qe) const;
420
428  bool equalsOriented(const QuadEdge& qe) const;
429
436  std::unique_ptr<geom::LineSegment> toLineSegment() const;
437 };
438
439
441 } //namespace geos.triangulate
442 } //namespace geos
443
445
Sets the connected edge.
void setOrig(const Vertex &o)
Sets the vertex for this edge's origin.
Models a site (node) in a QuadEdgeSubdivision.
Definition: Vertex.h:60
Gets the next CW edge around (into) the destination of this edge.
Gets the edge from the destination to the origin of this edge.
const Vertex & orig() const
Gets the vertex for the edge's origin.
Gets the dual of this edge, directed from its right to its left.
Gets the edge around the right face ccw following this edge.
Gets the CCW edge around the left face following this edge.
Gets the next CCW edge around the origin of this edge.
bool isLive() const
Tests whether this edge has been deleted.
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26
Gets the dual of this edge, directed from its left to its right.
void setDest(const Vertex &d)
Sets the vertex for this edge's destination.
Gets the next CW edge around (from) the origin of this edge.
double getLength() const
Gets the length of the geometry of this quadedge.
const Vertex & dest() const
Gets the vertex for the edge's destination.