GEOS 3.15.0dev
OverlayEdge.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#pragma once
16
17#include <geos/edgegraph/HalfEdge.h>
18#include <geos/geom/CoordinateSequence.h>
19#include <geos/geom/Location.h>
20#include <geos/operation/overlayng/OverlayEdge.h>
21#include <geos/operation/overlayng/OverlayLabel.h>
22#include <geos/export.h>
23
24#include <memory>
25
26// Forward declarations
27namespace geos {
28namespace geom {
29class Coordinate;
30class CoordinateSequence;
31}
32namespace operation {
33namespace overlayng {
34class OverlayEdgeRing;
35class MaximalEdgeRing;
36}
37}
38}
39
40namespace geos { // geos.
41namespace operation { // geos.operation
42namespace overlayng { // geos.operation.overlayng
43
47class GEOS_DLL OverlayEdge : public edgegraph::HalfEdge {
49 using CoordinateXY = geos::geom::CoordinateXY;
50 using CoordinateXYZM = geos::geom::CoordinateXYZM;
53
54private:
55
56 // Members
57 std::shared_ptr<const CoordinateSequence> pts;
63 bool direction;
64 bool m_isCurved;
65 CoordinateXY dirPt;
66 OverlayLabel* label;
67 bool m_isInResultArea;
68 bool m_isInResultLine;
69 bool m_isVisited;
70 OverlayEdge* nextResultEdge;
71 const OverlayEdgeRing* edgeRing;
72 const MaximalEdgeRing* maxEdgeRing;
73 OverlayEdge* nextResultMaxEdge;
74
75 void markVisited()
76 {
77 m_isVisited = true;
78 };
79
80
81public:
82
83 OverlayEdge(const CoordinateXYZM& p_orig, const CoordinateXY& p_dirPt,
84 bool p_direction, OverlayLabel* p_label,
85 const std::shared_ptr<const CoordinateSequence>& p_pts,
86 bool isCurved)
87 : HalfEdge(p_orig)
88 , pts(p_pts)
89 , direction(p_direction)
90 , m_isCurved(isCurved)
91 , dirPt(p_dirPt)
92 , label(p_label)
93 , m_isInResultArea(false)
94 , m_isInResultLine(false)
95 , m_isVisited(false)
96 , nextResultEdge(nullptr)
97 , edgeRing(nullptr)
98 , maxEdgeRing(nullptr)
99 , nextResultMaxEdge(nullptr)
100 {}
101
102 ~OverlayEdge() override {};
103
104 bool isForward() const
105 {
106 return direction;
107 };
108
109 bool isCurved() const
110 {
111 return m_isCurved;
112 }
113
114 const CoordinateXY& directionPt() const override
115 {
116 return dirPt;
117 };
118
119 OverlayLabel* getLabel() const
120 {
121 return label;
122 };
123
124 Location getLocation(uint8_t index, int position) const
125 {
126 return label->getLocation(index, position, direction);
127 };
128
129 const CoordinateXYZM& getCoordinate() const
130 {
131 return orig();
132 };
133
134 const CoordinateSequence* getCoordinatesRO() const
135 {
136 return pts.get();
137 };
138
139 std::shared_ptr<const CoordinateSequence> getCoordinatesOriented() const;
140
151
152 OverlayEdge* symOE() const
153 {
154 return static_cast<OverlayEdge*>(sym());
155 };
156
157 OverlayEdge* oNextOE() const
158 {
159 return static_cast<OverlayEdge*>(oNext());
160 };
161
162 bool isInResultArea() const
163 {
164 return m_isInResultArea;
165 };
166
167 bool isInResultAreaBoth() const
168 {
169 return m_isInResultArea && symOE()->m_isInResultArea;
170 };
171
172 bool isInResultEither() const
173 {
174 return isInResult() || symOE()->isInResult();
175 };
176
177 void unmarkFromResultAreaBoth()
178 {
179 m_isInResultArea = false;
180 symOE()->m_isInResultArea = false;
181 };
182
183 void markInResultArea()
184 {
185 m_isInResultArea = true;
186 };
187
188 void markInResultAreaBoth()
189 {
190 m_isInResultArea = true;
191 symOE()->m_isInResultArea = true;
192 };
193
194 bool isInResultLine() const
195 {
196 return m_isInResultLine;
197 };
198
199 void markInResultLine()
200 {
201 m_isInResultLine = true;
202 symOE()->m_isInResultLine = true;
203 };
204
205 bool isInResult() const
206 {
207 return m_isInResultArea || m_isInResultLine;
208 };
209
210 void setNextResult(OverlayEdge* e)
211 {
212 // Assert: e.orig() == this.dest();
213 nextResultEdge = e;
214 };
215
216 OverlayEdge* nextResult() const
217 {
218 return nextResultEdge;
219 };
220
221 bool isResultLinked() const
222 {
223 return nextResultEdge != nullptr;
224 };
225
226 void setNextResultMax(OverlayEdge* e)
227 {
228 // Assert: e.orig() == this.dest();
229 nextResultMaxEdge = e;
230 };
231
232 OverlayEdge* nextResultMax() const
233 {
234 return nextResultMaxEdge;
235 };
236
237 bool isResultMaxLinked() const
238 {
239 return nextResultMaxEdge != nullptr;
240 };
241
242 bool isVisited() const
243 {
244 return m_isVisited;
245 };
246
247 void markVisitedBoth()
248 {
249 markVisited();
250 symOE()->markVisited();
251 };
252
253 void setEdgeRing(const OverlayEdgeRing* p_edgeRing)
254 {
255 edgeRing = p_edgeRing;
256 };
257
258 const OverlayEdgeRing* getEdgeRing() const
259 {
260 return edgeRing;
261 };
262
263 const MaximalEdgeRing* getEdgeRingMax() const
264 {
265 return maxEdgeRing;
266 };
267
268 void setEdgeRingMax(const MaximalEdgeRing* p_maximalEdgeRing)
269 {
270 maxEdgeRing = p_maximalEdgeRing;
271 };
272
273 friend std::ostream& operator<<(std::ostream& os, const OverlayEdge& oe);
274 std::string resultSymbol() const;
275
276};
277
278
279} // namespace geos.operation.overlayng
280} // namespace geos.operation
281} // namespace geos
Definition HalfEdge.h:56
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:220
Definition OverlayEdge.h:47
void addCoordinates(CoordinateSequence *coords) const
const CoordinateXY & directionPt() const override
Definition OverlayEdge.h:114
Definition OverlayLabel.h:86
Location getLocation(uint8_t index) const
Definition OverlayLabel.h:370
Location
Constants representing the location of a point relative to a geometry.
Definition Location.h:32
Basic namespace for all GEOS functionalities.
Definition geos.h:38