GEOS 3.14.0dev
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#pragma once
23
24#include <geos/export.h>
25#include <geos/geomgraph/Label.h> // for composition
26#include <geos/geom/CoordinateSequence.h>
27#include <geos/geom/LinearRing.h>
28
29#include <cassert> // for testInvariant
30#include <iosfwd> // for operator<<
31#include <memory>
32#include <vector>
33
34#ifdef _MSC_VER
35#pragma warning(push)
36#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
37#endif
38
39// Forward declarations
40namespace geos {
41namespace geom {
42class GeometryFactory;
43class Polygon;
44class Coordinate;
45}
46namespace geomgraph {
47class DirectedEdge;
48//class Label;
49class Edge;
50}
51}
52
53namespace geos {
54namespace geomgraph { // geos.geomgraph
55
57class GEOS_DLL EdgeRing /* non-final */ {
58
59public:
60 friend std::ostream& operator<< (std::ostream& os, const EdgeRing& er);
61
62 EdgeRing(DirectedEdge* newStart,
63 const geom::GeometryFactory* newGeometryFactory);
64
65 virtual ~EdgeRing() = default;
66
67 bool isIsolated();
68
69 bool isHole();
70
77
78 Label& getLabel();
79
80 bool isShell();
81
82 EdgeRing* getShell();
83
84 void setShell(EdgeRing* newShell);
85
86 void addHole(EdgeRing* edgeRing);
87
92 std::unique_ptr<geom::Polygon> toPolygon(const geom::GeometryFactory* geometryFactory);
93
100
101 virtual DirectedEdge* getNext(DirectedEdge* de) = 0;
102
103 virtual void setEdgeRing(DirectedEdge* de, EdgeRing* er) = 0;
104
108 std::vector<DirectedEdge*>& getEdges();
109
110 int getMaxNodeDegree();
111
112 void setInResult();
113
119
120 void
121 testInvariant() const
122 {
123 // pts are never NULL
124 // assert(pts);
125
126#ifndef NDEBUG
127 // If this is not an hole, check that
128 // each hole is not null and
129 // has 'this' as it's shell
130 if(! shell) {
131 for(const auto& hole : holes) {
132 assert(hole);
133 assert(hole->getShell() == this);
134 }
135 }
136#endif // ndef NDEBUG
137 }
138
139protected:
140
141 DirectedEdge* startDe; // the directed edge which starts the list of edges for this EdgeRing
142
143 const geom::GeometryFactory* geometryFactory;
144
147
148 void mergeLabel(const Label& deLabel);
149
162 void mergeLabel(const Label& deLabel, uint8_t geomIndex);
163
164 void addPoints(Edge* edge, bool isForward, bool isFirstEdge);
165
167 std::vector<std::unique_ptr<EdgeRing>> holes;
168
169private:
170
171 int maxNodeDegree;
172
174 std::vector<DirectedEdge*> edges;
175
177
178 // label stores the locations of each geometry on the
179 // face surrounded by this ring
180 Label label;
181
182 std::unique_ptr<geom::LinearRing> ring; // the ring created for this EdgeRing
183
184 bool isHoleVar;
185
187 EdgeRing* shell;
188
189 void computeMaxNodeDegree();
190
191};
192
193std::ostream& operator<< (std::ostream& os, const EdgeRing& er);
194
195} // namespace geos.geomgraph
196} // namespace geos
197
198#ifdef _MSC_VER
199#pragma warning(pop)
200#endif
201
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:217
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
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:42
Definition geomgraph/EdgeRing.h:57
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:167
void mergeLabel(const Label &deLabel, uint8_t geomIndex)
Merge the RHS label from a DirectedEdge into the label for this EdgeRing.
std::vector< DirectedEdge * > & getEdges()
void computePoints(DirectedEdge *newStart)
geom::LinearRing * getLinearRing()
Definition geomgraph/Edge.h:63
A Label indicates the topological relationship of a component of a topology graph to a given Geometry...
Definition Label.h:57
Basic namespace for all GEOS functionalities.
Definition geos.h:39