GEOS 3.9.1
geomgraph/EdgeRing.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
7 * Copyright (C) 2005-2006 Refractions Research Inc.
8 * Copyright (C) 2001-2002 Vivid Solutions Inc.
9 *
10 * This is free software; you can redistribute and/or modify it under
11 * the terms of the GNU Lesser General Public Licence as published
12 * by the Free Software Foundation.
13 * See the COPYING file for more information.
14 *
15 **********************************************************************
16 *
17 * Last port: geomgraph/EdgeRing.java r428 (JTS-1.12+)
18 *
19 **********************************************************************/
20
21
22#ifndef GEOS_GEOMGRAPH_EDGERING_H
23#define GEOS_GEOMGRAPH_EDGERING_H
24
25#include <geos/export.h>
26#include <geos/geomgraph/Label.h> // for composition
27#include <geos/geom/CoordinateArraySequence.h>
28#include <geos/geom/LinearRing.h>
29
30#include <geos/inline.h>
31
32#include <cassert> // for testInvariant
33#include <iosfwd> // for operator<<
34#include <memory>
35#include <vector>
36
37#ifdef _MSC_VER
38#pragma warning(push)
39#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
40#endif
41
42// Forward declarations
43namespace geos {
44namespace geom {
45class GeometryFactory;
46class Polygon;
47class Coordinate;
48}
49namespace geomgraph {
50class DirectedEdge;
51//class Label;
52class Edge;
53}
54}
55
56namespace geos {
57namespace geomgraph { // geos.geomgraph
58
60class GEOS_DLL EdgeRing {
61
62public:
63 friend std::ostream& operator<< (std::ostream& os, const EdgeRing& er);
64
65 EdgeRing(DirectedEdge* newStart,
66 const geom::GeometryFactory* newGeometryFactory);
67
68 virtual ~EdgeRing() = default;
69
70 bool isIsolated();
71
72 bool isHole();
73
80
81 Label& getLabel();
82
83 bool isShell();
84
85 EdgeRing* getShell();
86
87 void setShell(EdgeRing* newShell);
88
89 void addHole(EdgeRing* edgeRing);
90
95 std::unique_ptr<geom::Polygon> toPolygon(const geom::GeometryFactory* geometryFactory);
96
103
104 virtual DirectedEdge* getNext(DirectedEdge* de) = 0;
105
106 virtual void setEdgeRing(DirectedEdge* de, EdgeRing* er) = 0;
107
111 std::vector<DirectedEdge*>& getEdges();
112
113 int getMaxNodeDegree();
114
115 void setInResult();
116
122
123 void
124 testInvariant() const
125 {
126 // pts are never NULL
127 // assert(pts);
128
129#ifndef NDEBUG
130 // If this is not an hole, check that
131 // each hole is not null and
132 // has 'this' as it's shell
133 if(! shell) {
134 for(const auto& hole : holes) {
135 assert(hole);
136 assert(hole->getShell() == this);
137 }
138 }
139#endif // ndef NDEBUG
140 }
141
142protected:
143
144 DirectedEdge* startDe; // the directed edge which starts the list of edges for this EdgeRing
145
146 const geom::GeometryFactory* geometryFactory;
147
150
151 void mergeLabel(const Label& deLabel);
152
165 void mergeLabel(const Label& deLabel, int geomIndex);
166
167 void addPoints(Edge* edge, bool isForward, bool isFirstEdge);
168
170 std::vector<std::unique_ptr<EdgeRing>> holes;
171
172private:
173
174 int maxNodeDegree;
175
177 std::vector<DirectedEdge*> edges;
178
179 std::vector<geom::Coordinate> pts;
180
181 // label stores the locations of each geometry on the
182 // face surrounded by this ring
183 Label label;
184
185 std::unique_ptr<geom::LinearRing> ring; // the ring created for this EdgeRing
186
187 bool isHoleVar;
188
190 EdgeRing* shell;
191
192 void computeMaxNodeDegree();
193
194};
195
196std::ostream& operator<< (std::ostream& os, const EdgeRing& er);
197
198} // namespace geos.geomgraph
199} // namespace geos
200
201#ifdef _MSC_VER
202#pragma warning(pop)
203#endif
204
205#endif // ifndef GEOS_GEOMGRAPH_EDGERING_H
206
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:60
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:68
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition LinearRing.h:54
A directed EdgeEnd.
Definition geomgraph/DirectedEdge.h:45
Definition geomgraph/EdgeRing.h:60
std::unique_ptr< geom::Polygon > toPolygon(const geom::GeometryFactory *geometryFactory)
bool containsPoint(const geom::Coordinate &p)
std::vector< std::unique_ptr< EdgeRing > > holes
a list of EdgeRings which are holes in this EdgeRing
Definition geomgraph/EdgeRing.h:170
std::vector< DirectedEdge * > & getEdges()
void computePoints(DirectedEdge *newStart)
geom::LinearRing * getLinearRing()
void mergeLabel(const Label &deLabel, int geomIndex)
Merge the RHS label from a DirectedEdge into the label for this EdgeRing.
Definition geomgraph/Edge.h:66
A Label indicates the topological relationship of a component of a topology graph to a given Geometry...
Definition Label.h:59
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:26