GEOS  3.8.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 #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 
28 #include <geos/inline.h>
29 
30 #include <cassert> // for testInvariant
31 #include <iosfwd> // for operator<<
32 #include <memory>
33 #include <vector>
34 
35 #ifdef _MSC_VER
36 #pragma warning(push)
37 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
38 #endif
39 
40 // Forward declarations
41 namespace geos {
42 namespace geom {
43 class GeometryFactory;
44 class LinearRing;
45 class Polygon;
46 class Coordinate;
47 class CoordinateArraySequence;
48 }
49 namespace geomgraph {
50 class DirectedEdge;
51 //class Label;
52 class Edge;
53 }
54 }
55 
56 namespace geos {
57 namespace geomgraph { // geos.geomgraph
58 
60 class GEOS_DLL EdgeRing {
61 
62 public:
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();
69 
70  bool isIsolated();
71 
72  bool isHole();
73 
74  /*
75  * Return a pointer to the LinearRing owned by
76  * this object. Make a copy if you need it beyond
77  * this objects's lifetime.
78  */
79  geom::LinearRing* getLinearRing();
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 
96  geom::Polygon* toPolygon(const geom::GeometryFactory* geometryFactory);
97 
103  void computeRing();
104 
105  virtual DirectedEdge* getNext(DirectedEdge* de) = 0;
106 
107  virtual void setEdgeRing(DirectedEdge* de, EdgeRing* er) = 0;
108 
112  std::vector<DirectedEdge*>& getEdges();
113 
114  int getMaxNodeDegree();
115 
116  void setInResult();
117 
122  bool containsPoint(const geom::Coordinate& p);
123 
124  void
125  testInvariant()
126  {
127  // pts are never NULL
128  assert(pts);
129 
130 #ifndef NDEBUG
131  // If this is not an hole, check that
132  // each hole is not null and
133  // has 'this' as it's shell
134  if(! shell) {
135  for(std::vector<EdgeRing*>::const_iterator
136  it = holes.begin(), itEnd = holes.end();
137  it != itEnd;
138  ++it) {
139  EdgeRing* hole = *it;
140  assert(hole);
141  assert(hole->getShell() == this);
142  }
143  }
144 #endif // ndef NDEBUG
145  }
146 
147 protected:
148 
149  DirectedEdge* startDe; // the directed edge which starts the list of edges for this EdgeRing
150 
151  const geom::GeometryFactory* geometryFactory;
152 
154  void computePoints(DirectedEdge* newStart);
155 
156  void mergeLabel(const Label& deLabel);
157 
170  void mergeLabel(const Label& deLabel, int geomIndex);
171 
172  void addPoints(Edge* edge, bool isForward, bool isFirstEdge);
173 
175  std::vector<EdgeRing*> holes;
176 
177 private:
178 
179  int maxNodeDegree;
180 
182  std::vector<DirectedEdge*> edges;
183 
185 
186  // label stores the locations of each geometry on the
187  // face surrounded by this ring
188  Label label;
189 
190  geom::LinearRing* ring; // the ring created for this EdgeRing
191 
192  bool isHoleVar;
193 
195  EdgeRing* shell;
196 
197  void computeMaxNodeDegree();
198 
199 };
200 
201 std::ostream& operator<< (std::ostream& os, const EdgeRing& er);
202 
203 } // namespace geos.geomgraph
204 } // namespace geos
205 
206 #ifdef _MSC_VER
207 #pragma warning(pop)
208 #endif
209 
210 #endif // ifndef GEOS_GEOMGRAPH_EDGERING_H
211 
The default implementation of CoordinateSequence.
Definition: CoordinateArraySequence.h:37
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
A directed EdgeEnd.
Definition: geomgraph/DirectedEdge.h:45
Represents a linear polygon, which may include holes.
Definition: Polygon.h:64
Definition: geomgraph/EdgeRing.h:60
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:66
A Label indicates the topological relationship of a component of a topology graph to a given Geometry...
Definition: Label.h:58
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple...
Definition: LinearRing.h:54
std::vector< EdgeRing * > holes
a list of EdgeRings which are holes in this EdgeRing
Definition: geomgraph/EdgeRing.h:175
Definition: geomgraph/Edge.h:66