GEOS 3.11.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
142 static HalfEdge* create(const geom::Coordinate& p0, const geom::Coordinate& p1);
143
150 void link(HalfEdge* p_sym);
151
157 const geom::Coordinate& orig() const { return m_orig; };
158
164 const geom::Coordinate& dest() const { return m_sym->m_orig; }
165
171 double directionX() const { return directionPt().x - m_orig.x; }
172
178 double directionY() const { return directionPt().y - m_orig.y; }
179
185 HalfEdge* sym() const { return m_sym; };
186
195 HalfEdge* next() const { return m_next; };
196
208 HalfEdge* prev() const;
209
218 HalfEdge* oNext() const { return m_sym->m_next; };
219
225 void setNext(HalfEdge* e) { m_next = e; };
226
237
245 bool equals(const geom::Coordinate& p0, const geom::Coordinate& p1) const;
246
255 void insert(HalfEdge* eAdd);
256
265 bool isEdgesSorted() const;
266
290 int compareTo(const HalfEdge* e) const { return compareAngularDirection(e); };
291
299 int degree();
300
311
312 friend std::ostream& operator<< (std::ostream& os, const HalfEdge& el);
313 static void toStringNode(const HalfEdge* he, std::ostream& os);
314
315};
316
317
318} // namespace geos.edgegraph
319} // namespace geos
320
321
322
Definition: HalfEdge.h:63
HalfEdge * oNext() const
Definition: HalfEdge.h:218
HalfEdge(const geom::Coordinate &p_orig)
Definition: HalfEdge.h:129
const geom::Coordinate & orig() const
Definition: HalfEdge.h:157
double directionX() const
Definition: HalfEdge.h:171
int compareAngularDirection(const HalfEdge *e) const
const geom::Coordinate & dest() const
Definition: HalfEdge.h:164
virtual const geom::Coordinate & directionPt() const
Definition: HalfEdge.h:119
HalfEdge * sym() const
Definition: HalfEdge.h:185
void setNext(HalfEdge *e)
Definition: HalfEdge.h:225
HalfEdge * prev() const
void insert(HalfEdge *eAdd)
bool equals(const geom::Coordinate &p0, const geom::Coordinate &p1) const
HalfEdge * next() const
Definition: HalfEdge.h:195
void link(HalfEdge *p_sym)
double directionY() const
Definition: HalfEdge.h:178
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:58
double y
y-coordinate
Definition: Coordinate.h:81
double x
x-coordinate
Definition: Coordinate.h:78
Basic namespace for all GEOS functionalities.
Definition: geos.h:39