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 
23 namespace geos {
24 namespace edgegraph { // geos.edgegraph
25 
56 class GEOS_DLL HalfEdge {
57 
58 private:
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 
101 protected:
102 
112  virtual const geom::CoordinateXYZM& directionPt() const { return dest(); };
113 
114 
115 public:
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 
282  int compareAngularDirection(const HalfEdge* e) const;
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 * next() const
Definition: HalfEdge.h:188
bool equals(const geom::CoordinateXY &p0, const geom::CoordinateXY &p1) const
static HalfEdge * create(const geom::CoordinateXYZM &p0, const geom::CoordinateXYZM &p1)
const geom::CoordinateXYZM & dest() const
Definition: HalfEdge.h:157
double directionX() const
Definition: HalfEdge.h:164
HalfEdge(const geom::CoordinateXYZM &p_orig)
Definition: HalfEdge.h:122
int compareAngularDirection(const HalfEdge *e) const
HalfEdge * sym() const
Definition: HalfEdge.h:178
HalfEdge * find(const geom::CoordinateXY &dest)
void setNext(HalfEdge *e)
Definition: HalfEdge.h:218
void insert(HalfEdge *eAdd)
virtual const geom::CoordinateXYZM & directionPt() const
Definition: HalfEdge.h:112
HalfEdge * prev() const
void link(HalfEdge *p_sym)
double directionY() const
Definition: HalfEdge.h:171
const geom::CoordinateXYZM & orig() const
Definition: HalfEdge.h:150
HalfEdge * oNext() const
Definition: HalfEdge.h:211
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25