GEOS 3.14.0dev
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
23namespace geos {
24namespace edgegraph { // geos.edgegraph
25
56class GEOS_DLL HalfEdge {
57
58private:
59
60 /* members */
61 geom::CoordinateXYZM m_orig;
62 HalfEdge* m_sym;
63 HalfEdge* m_next;
64
65
71 void setSym(HalfEdge* e) { m_sym = e; };
72
82 HalfEdge* insertionEdge(HalfEdge* eAdd);
83
91 void insertAfter(HalfEdge* e);
92
99 const HalfEdge* findLowest() const;
100
101protected:
102
112 virtual const geom::CoordinateXYZM& directionPt() const { return dest(); };
113
114
115public:
116
122 HalfEdge(const geom::CoordinateXYZM& p_orig) :
123 m_orig(p_orig)
124 {};
125
126 virtual ~HalfEdge() {};
127
135 static HalfEdge* create(const geom::CoordinateXYZM& p0, const geom::CoordinateXYZM& p1);
136
143 void link(HalfEdge* p_sym);
144
150 const geom::CoordinateXYZM& orig() const { return m_orig; };
151
157 const geom::CoordinateXYZM& dest() const { return m_sym->m_orig; }
158
164 double directionX() const { return directionPt().x - m_orig.x; }
165
171 double directionY() const { return directionPt().y - m_orig.y; }
172
178 HalfEdge* sym() const { return m_sym; };
179
188 HalfEdge* next() const { return m_next; };
189
201 HalfEdge* prev() const;
202
211 HalfEdge* oNext() const { return m_sym->m_next; };
212
218 void setNext(HalfEdge* e) { m_next = e; };
219
229 HalfEdge* find(const geom::CoordinateXY& dest);
230
238 bool equals(const geom::CoordinateXY& p0, const geom::CoordinateXY& p1) const;
239
248 void insert(HalfEdge* eAdd);
249
258 bool isEdgesSorted() const;
259
283 int compareTo(const HalfEdge* e) const { return compareAngularDirection(e); };
284
292 int degree();
293
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:56
HalfEdge * find(const geom::CoordinateXY &dest)
HalfEdge * oNext() const
Definition HalfEdge.h:211
virtual const geom::CoordinateXYZM & directionPt() const
Definition HalfEdge.h:112
const geom::CoordinateXYZM & orig() const
Definition HalfEdge.h:150
bool equals(const geom::CoordinateXY &p0, const geom::CoordinateXY &p1) const
double directionX() const
Definition HalfEdge.h:164
HalfEdge(const geom::CoordinateXYZM &p_orig)
Definition HalfEdge.h:122
int compareAngularDirection(const HalfEdge *e) const
static HalfEdge * create(const geom::CoordinateXYZM &p0, const geom::CoordinateXYZM &p1)
HalfEdge * sym() const
Definition HalfEdge.h:178
void setNext(HalfEdge *e)
Definition HalfEdge.h:218
HalfEdge * prev() const
void insert(HalfEdge *eAdd)
HalfEdge * next() const
Definition HalfEdge.h:188
void link(HalfEdge *p_sym)
double directionY() const
Definition HalfEdge.h:171
const geom::CoordinateXYZM & dest() const
Definition HalfEdge.h:157
Basic namespace for all GEOS functionalities.
Definition geos.h:39