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 <vector>
31 #include <cassert> // for testInvariant
32 #include <iosfwd> // for operator<<
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
40 namespace geos {
41 namespace geom {
42 class GeometryFactory;
43 class LinearRing;
44 class Polygon;
45 class Coordinate;
46 class CoordinateSequence;
47 }
48 namespace geomgraph {
49 class DirectedEdge;
50 //class Label;
51 class Edge;
52 }
53 }
54 
55 namespace geos {
56 namespace geomgraph { // geos.geomgraph
57 
59 class GEOS_DLL EdgeRing {
60 
61 public:
62  friend std::ostream& operator<< (std::ostream& os, const EdgeRing& er);
63 
64  EdgeRing(DirectedEdge* newStart,
65  const geom::GeometryFactory* newGeometryFactory);
66 
67  virtual ~EdgeRing();
68 
69  bool isIsolated();
70 
71  bool isHole();
72 
73  /*
74  * Return a pointer to the LinearRing owned by
75  * this object. Make a copy if you need it beyond
76  * this objects's lifetime.
77  */
78  geom::LinearRing* getLinearRing();
79 
80  Label& getLabel();
81 
82  bool isShell();
83 
84  EdgeRing* getShell();
85 
86  void setShell(EdgeRing* newShell);
87 
88  void addHole(EdgeRing* edgeRing);
89 
95  geom::Polygon* toPolygon(const geom::GeometryFactory* geometryFactory);
96 
102  void computeRing();
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 
121  bool containsPoint(const geom::Coordinate& p);
122 
123  void
124  testInvariant()
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(std::vector<EdgeRing*>::const_iterator
135  it = holes.begin(), itEnd = holes.end();
136  it != itEnd;
137  ++it) {
138  EdgeRing* hole = *it;
139  assert(hole);
140  assert(hole->getShell() == this);
141  }
142  }
143 #endif // ndef NDEBUG
144  }
145 
146 protected:
147 
148  DirectedEdge* startDe; // the directed edge which starts the list of edges for this EdgeRing
149 
150  const geom::GeometryFactory* geometryFactory;
151 
153  void computePoints(DirectedEdge* newStart);
154 
155  void mergeLabel(const Label& deLabel);
156 
169  void mergeLabel(const Label& deLabel, int geomIndex);
170 
171  void addPoints(Edge* edge, bool isForward, bool isFirstEdge);
172 
174  std::vector<EdgeRing*> holes;
175 
176 private:
177 
178  int maxNodeDegree;
179 
181  std::vector<DirectedEdge*> edges;
182 
184 
185  // label stores the locations of each geometry on the
186  // face surrounded by this ring
187  Label label;
188 
189  geom::LinearRing* ring; // the ring created for this EdgeRing
190 
191  bool isHoleVar;
192 
194  EdgeRing* shell;
195 
196  void computeMaxNodeDegree();
197 
198 };
199 
200 std::ostream& operator<< (std::ostream& os, const EdgeRing& er);
201 
202 } // namespace geos.geomgraph
203 } // namespace geos
204 
205 #ifdef _MSC_VER
206 #pragma warning(pop)
207 #endif
208 
209 #endif // ifndef GEOS_GEOMGRAPH_EDGERING_H
210 
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
A directed EdgeEnd.
Definition: geomgraph/DirectedEdge.h:44
Represents a linear polygon, which may include holes.
Definition: Polygon.h:65
Definition: geomgraph/EdgeRing.h:59
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:67
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: IndexedNestedRingTester.h:25
Models an OGC SFS LinearRing.
Definition: LinearRing.h:56
std::vector< EdgeRing * > holes
a list of EdgeRings which are holes in this EdgeRing
Definition: geomgraph/EdgeRing.h:174
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
Definition: geomgraph/Edge.h:66