GEOS  3.6.1
PolygonizeGraph.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2006 Refractions Research Inc.
7  * Copyright (C) 2001-2002 Vivid Solutions Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Public Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  **********************************************************************
15  *
16  * Last port: operation/polygonize/PolygonizeGraph.java rev. 6/138 (JTS-1.10)
17  *
18  **********************************************************************/
19 
20 #ifndef GEOS_OP_POLYGONIZE_POLYGONIZEGRAPH_H
21 #define GEOS_OP_POLYGONIZE_POLYGONIZEGRAPH_H
22 
23 #include <geos/export.h>
24 
25 #include <geos/planargraph/PlanarGraph.h> // for inheritance
26 
27 #include <vector>
28 
29 #ifdef _MSC_VER
30 #pragma warning(push)
31 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
32 #endif
33 
34 // Forward declarations
35 namespace geos {
36  namespace geom {
37  class LineString;
38  class GeometryFactory;
39  class Coordinate;
40  class CoordinateSequence;
41  }
42  namespace planargraph {
43  class Node;
44  class Edge;
45  class DirectedEdge;
46  }
47  namespace operation {
48  namespace polygonize {
49  class EdgeRing;
50  class PolygonizeDirectedEdge;
51  }
52  }
53 }
54 
55 namespace geos {
56 namespace operation { // geos::operation
57 namespace polygonize { // geos::operation::polygonize
58 
59 
69 class GEOS_DLL PolygonizeGraph: public planargraph::PlanarGraph {
70 
71 public:
72 
77  static void deleteAllEdges(planargraph::Node *node);
78 
83  PolygonizeGraph(const geom::GeometryFactory *newFactory);
84 
89  ~PolygonizeGraph();
90 
96  void addEdge(const geom::LineString *line);
97 
106  void getEdgeRings(std::vector<EdgeRing*>& edgeRingList);
107 
117  void deleteCutEdges(std::vector<const geom::LineString*> &cutLines);
118 
131  void deleteDangles(std::vector<const geom::LineString*> &dangleLines);
132 
133 private:
134 
135  static int getDegreeNonDeleted(planargraph::Node *node);
136 
137  static int getDegree(planargraph::Node *node, long label);
138 
139  const geom::GeometryFactory *factory;
140 
141  planargraph::Node* getNode(const geom::Coordinate& pt);
142 
143  void computeNextCWEdges();
144 
154  void convertMaximalToMinimalEdgeRings(
155  std::vector<PolygonizeDirectedEdge*> &ringEdges);
156 
167  static void findIntersectionNodes( PolygonizeDirectedEdge *startDE,
168  long label, std::vector<planargraph::Node*>& intNodes
169 );
170 
180  static void findLabeledEdgeRings(
181  std::vector<planargraph::DirectedEdge*> &dirEdgesIn,
182  std::vector<PolygonizeDirectedEdge*> &dirEdgesOut);
183 
184  static void label(std::vector<planargraph::DirectedEdge*> &dirEdges, long label);
185 
186  static void computeNextCWEdges(planargraph::Node *node);
187 
195  static void computeNextCCWEdges(planargraph::Node *node, long label);
196 
207  static void findDirEdgesInRing(PolygonizeDirectedEdge *startDE,
208  std::vector<planargraph::DirectedEdge*>& edgesInRing);
209 
210  EdgeRing* findEdgeRing(PolygonizeDirectedEdge *startDE);
211 
212  /* Tese are for memory management */
213  std::vector<planargraph::Edge *> newEdges;
214  std::vector<planargraph::DirectedEdge *> newDirEdges;
215  std::vector<planargraph::Node *> newNodes;
216  std::vector<EdgeRing *> newEdgeRings;
217  std::vector<geom::CoordinateSequence *> newCoords;
218 };
219 
220 } // namespace geos::operation::polygonize
221 } // namespace geos::operation
222 } // namespace geos
223 
224 #ifdef _MSC_VER
225 #pragma warning(pop)
226 #endif
227 
228 #endif // GEOS_OP_POLYGONIZE_POLYGONIZEGRAPH_H
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Represents a planar graph of edges that can be used to compute a polygonization, and implements the a...
Definition: PolygonizeGraph.h:69
Definition: LineString.h:70
A DirectedEdge of a PolygonizeGraph, which represents an edge of a polygon formed by the graph...
Definition: PolygonizeDirectedEdge.h:54
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:67
Represents a ring of PolygonizeDirectedEdge which form a ring of a polygon. The ring may be either an...
Definition: operation/polygonize/EdgeRing.h:57
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
A node in a PlanarGraph is a location where 0 or more Edge meet.
Definition: planargraph/Node.h:45
Represents a directed graph which is embeddable in a planar surface.
Definition: planargraph/PlanarGraph.h:60