GEOS  3.3.3
PolygonizeGraph.h
1 /**********************************************************************
2  * $Id: PolygonizeGraph.h 3255 2011-03-01 17:56:10Z mloskot $
3  *
4  * GEOS - Geometry Engine Open Source
5  * http://geos.refractions.net
6  *
7  * Copyright (C) 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: operation/polygonize/PolygonizeGraph.java rev. 6/138 (JTS-1.10)
18  *
19  **********************************************************************/
20 
21 #ifndef GEOS_OP_POLYGONIZE_POLYGONIZEGRAPH_H
22 #define GEOS_OP_POLYGONIZE_POLYGONIZEGRAPH_H
23 
24 #include <geos/export.h>
25 
26 #include <geos/planargraph/PlanarGraph.h> // for inheritance
27 
28 #include <vector>
29 
30 #ifdef _MSC_VER
31 #pragma warning(push)
32 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
33 #endif
34 
35 // Forward declarations
36 namespace geos {
37  namespace geom {
38  class LineString;
39  class GeometryFactory;
40  class Coordinate;
41  class CoordinateSequence;
42  }
43  namespace planargraph {
44  class Node;
45  class Edge;
46  class DirectedEdge;
47  }
48  namespace operation {
49  namespace polygonize {
50  class EdgeRing;
51  class PolygonizeDirectedEdge;
52  }
53  }
54 }
55 
56 namespace geos {
57 namespace operation { // geos::operation
58 namespace polygonize { // geos::operation::polygonize
59 
60 
70 class GEOS_DLL PolygonizeGraph: public planargraph::PlanarGraph {
71 
72 public:
73 
78  static void deleteAllEdges(planargraph::Node *node);
79 
84  PolygonizeGraph(const geom::GeometryFactory *newFactory);
85 
90  ~PolygonizeGraph();
91 
97  void addEdge(const geom::LineString *line);
98 
107  void getEdgeRings(std::vector<EdgeRing*>& edgeRingList);
108 
118  void deleteCutEdges(std::vector<const geom::LineString*> &cutLines);
119 
132  void deleteDangles(std::vector<const geom::LineString*> &dangleLines);
133 
134 private:
135 
136  static int getDegreeNonDeleted(planargraph::Node *node);
137 
138  static int getDegree(planargraph::Node *node, long label);
139 
140  const geom::GeometryFactory *factory;
141 
142  planargraph::Node* getNode(const geom::Coordinate& pt);
143 
144  void computeNextCWEdges();
145 
155  void convertMaximalToMinimalEdgeRings(
156  std::vector<PolygonizeDirectedEdge*> &ringEdges);
157 
168  static void findIntersectionNodes( PolygonizeDirectedEdge *startDE,
169  long label, std::vector<planargraph::Node*>& intNodes
170 );
171 
181  static void findLabeledEdgeRings(
182  std::vector<planargraph::DirectedEdge*> &dirEdgesIn,
183  std::vector<PolygonizeDirectedEdge*> &dirEdgesOut);
184 
185  static void label(std::vector<planargraph::DirectedEdge*> &dirEdges, long label);
186 
187  static void computeNextCWEdges(planargraph::Node *node);
188 
196  static void computeNextCCWEdges(planargraph::Node *node, long label);
197 
208  static void findDirEdgesInRing(PolygonizeDirectedEdge *startDE,
209  std::vector<planargraph::DirectedEdge*>& edgesInRing);
210 
211  EdgeRing* findEdgeRing(PolygonizeDirectedEdge *startDE);
212 
213  /* Tese are for memory management */
214  std::vector<planargraph::Edge *> newEdges;
215  std::vector<planargraph::DirectedEdge *> newDirEdges;
216  std::vector<planargraph::Node *> newNodes;
217  std::vector<EdgeRing *> newEdgeRings;
218  std::vector<geom::CoordinateSequence *> newCoords;
219 };
220 
221 } // namespace geos::operation::polygonize
222 } // namespace geos::operation
223 } // namespace geos
224 
225 #ifdef _MSC_VER
226 #pragma warning(pop)
227 #endif
228 
229 #endif // GEOS_OP_POLYGONIZE_POLYGONIZEGRAPH_H
230 
231 /**********************************************************************
232  * $Log$
233  * Revision 1.1 2006/03/22 11:19:06 strk
234  * opPolygonize.h headers split.
235  *
236  **********************************************************************/