GEOS  3.9.1dev
HalfEdge.h
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2020 Paul Ramsey <pramsey@cleverelephant.ca>
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU Lesser General Public Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  **********************************************************************/
14 
15 
16 #pragma once
17 
18 #include <geos/export.h>
19 #include <string>
20 #include <cassert>
21 #include <geos/geom/Coordinate.h>
22 
23 // Forward declarations
24 namespace geos {
25 namespace geom {
26 class Coordinate;
27 }
28 }
29 
30 namespace geos {
31 namespace edgegraph { // geos.edgegraph
32 
64 
65 private:
66 
67  /* members */
71 
72 
78  void setSym(HalfEdge* e) { m_sym = e; };
79 
89  HalfEdge* insertionEdge(HalfEdge* eAdd);
90 
98  void insertAfter(HalfEdge* e);
99 
106  const HalfEdge* findLowest() const;
107 
108 protected:
109 
119  virtual const geom::Coordinate& directionPt() const { return dest(); };
120 
121 
122 public:
123 
129  HalfEdge(const geom::Coordinate& p_orig) :
130  m_orig(p_orig)
131  {};
132 
133  virtual ~HalfEdge() {};
134 
143  static HalfEdge* create(const geom::Coordinate& p0, const geom::Coordinate& p1);
144 
151  void link(HalfEdge* p_sym);
152 
158  const geom::Coordinate& orig() const { return m_orig; };
159 
165  const geom::Coordinate& dest() const { return m_sym->m_orig; }
166 
172  double directionX() const { return directionPt().x - m_orig.x; }
173 
179  double directionY() const { return directionPt().y - m_orig.y; }
180 
186  HalfEdge* sym() const { return m_sym; };
187 
196  HalfEdge* next() const { return m_next; };
197 
204  HalfEdge* prev() const { return m_sym->next()->m_sym; };
205 
212  HalfEdge* oNext() const { return m_sym->m_next; };
213 
219  void setNext(HalfEdge* e) { m_next = e; };
220 
230  HalfEdge* find(const geom::Coordinate& dest);
231 
239  bool equals(const geom::Coordinate& p0, const geom::Coordinate& p1) const;
240 
249  void insert(HalfEdge* eAdd);
250 
259  bool isEdgesSorted() const;
260 
283  int compareAngularDirection(const HalfEdge* e) const;
284  int compareTo(const HalfEdge* e) const { return compareAngularDirection(e); };
285 
293  int degree();
294 
303  HalfEdge* prevNode();
304 
305  friend std::ostream& operator<< (std::ostream& os, const HalfEdge& el);
306  static void toStringNode(const HalfEdge* he, std::ostream& os);
307 
308 };
309 
310 
311 } // namespace geos.edgegraph
312 } // namespace geos
313 
314 
315 
HalfEdge * oNext() const
Definition: HalfEdge.h:212
HalfEdge * next() const
Definition: HalfEdge.h:196
#define GEOS_DLL
Definition: export.h:28
double y
y-coordinate
Definition: Coordinate.h:83
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
virtual const geom::Coordinate & directionPt() const
Definition: HalfEdge.h:119
HalfEdge * sym() const
Definition: HalfEdge.h:186
geom::Coordinate m_orig
Definition: HalfEdge.h:68
double directionX() const
Definition: HalfEdge.h:172
const geom::Coordinate & dest() const
Definition: HalfEdge.h:165
void setNext(HalfEdge *e)
Definition: HalfEdge.h:219
std::ostream & operator<<(std::ostream &os, const Coordinate &c)
Output function.
double directionY() const
Definition: HalfEdge.h:179
HalfEdge * prev() const
Definition: HalfEdge.h:204
int compareTo(const HalfEdge *e) const
Definition: HalfEdge.h:284
Basic namespace for all GEOS functionalities.
HalfEdge(const geom::Coordinate &p_orig)
Definition: HalfEdge.h:129
void setSym(HalfEdge *e)
Definition: HalfEdge.h:78
double x
x-coordinate
Definition: Coordinate.h:80
const geom::Coordinate & orig() const
Definition: HalfEdge.h:158