GEOS  3.6.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@keybit.net>
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 testInvariant()
124  {
125  // pts are never NULL
126  assert(pts);
127 
128 #ifndef NDEBUG
129  // If this is not an hole, check that
130  // each hole is not null and
131  // has 'this' as it's shell
132  if ( ! shell )
133  {
134  for (std::vector<EdgeRing*>::const_iterator
135  it=holes.begin(), itEnd=holes.end();
136  it != itEnd;
137  ++it)
138  {
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 
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:66
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:57
std::vector< EdgeRing * > holes
a list of EdgeRings which are holes in this EdgeRing
Definition: geomgraph/EdgeRing.h:175
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:59
Definition: geomgraph/Edge.h:66