GEOS 3.9.1
HalfEdge.h
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
24namespace geos {
25namespace geom {
26class Coordinate;
27}
28}
29
30namespace geos {
31namespace edgegraph { // geos.edgegraph
32
63class GEOS_DLL HalfEdge {
64
65private:
66
67 /* members */
68 geom::Coordinate m_orig;
69 HalfEdge* m_sym;
70 HalfEdge* m_next;
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
108protected:
109
119 virtual const geom::Coordinate& directionPt() const { return dest(); };
120
121
122public:
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
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
284 int compareTo(const HalfEdge* e) const { return compareAngularDirection(e); };
285
293 int degree();
294
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
Definition: HalfEdge.h:63
HalfEdge * oNext() const
Definition: HalfEdge.h:212
HalfEdge(const geom::Coordinate &p_orig)
Definition: HalfEdge.h:129
const geom::Coordinate & orig() const
Definition: HalfEdge.h:158
double directionX() const
Definition: HalfEdge.h:172
int compareAngularDirection(const HalfEdge *e) const
const geom::Coordinate & dest() const
Definition: HalfEdge.h:165
virtual const geom::Coordinate & directionPt() const
Definition: HalfEdge.h:119
HalfEdge * sym() const
Definition: HalfEdge.h:186
void setNext(HalfEdge *e)
Definition: HalfEdge.h:219
HalfEdge * prev() const
Definition: HalfEdge.h:204
void insert(HalfEdge *eAdd)
bool equals(const geom::Coordinate &p0, const geom::Coordinate &p1) const
HalfEdge * next() const
Definition: HalfEdge.h:196
void link(HalfEdge *p_sym)
double directionY() const
Definition: HalfEdge.h:179
HalfEdge * find(const geom::Coordinate &dest)
static HalfEdge * create(const geom::Coordinate &p0, const geom::Coordinate &p1)
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
double y
y-coordinate
Definition: Coordinate.h:83
double x
x-coordinate
Definition: Coordinate.h:80
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26