GEOS  3.8.0dev
Polygonizer.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2010 Sandro Santilli <strk@kbt.io>
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/Polygonizer.java rev. 1.6 (JTS-1.10)
18  *
19  **********************************************************************/
20 
21 #ifndef GEOS_OP_POLYGONIZE_POLYGONIZER_H
22 #define GEOS_OP_POLYGONIZE_POLYGONIZER_H
23 
24 #include <geos/export.h>
25 #include <geos/geom/GeometryComponentFilter.h> // for LineStringAdder 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 Geometry;
38 class LineString;
39 class Polygon;
40 }
41 namespace operation {
42 namespace polygonize {
43 class EdgeRing;
44 class PolygonizeGraph;
45 }
46 }
47 }
48 
49 namespace geos {
50 namespace operation { // geos::operation
51 namespace polygonize { // geos::operation::polygonize
52 
73 class GEOS_DLL Polygonizer {
74 private:
78  class GEOS_DLL LineStringAdder: public geom::GeometryComponentFilter {
79  public:
80  Polygonizer* pol;
81  LineStringAdder(Polygonizer* p);
82  //void filter_rw(geom::Geometry *g);
83  void filter_ro(const geom::Geometry* g) override;
84  };
85 
86  // default factory
87  LineStringAdder lineStringAdder;
88 
94  void add(const geom::LineString* line);
95 
99  void polygonize();
100 
101  void findValidRings(const std::vector<EdgeRing*>& edgeRingList,
102  std::vector<EdgeRing*>& validEdgeRingList,
103  std::vector<geom::LineString*>& invalidRingList);
104 
105  void findShellsAndHoles(const std::vector<EdgeRing*>& edgeRingList);
106 
107  static void assignHolesToShells(const std::vector<EdgeRing*>& holeList,
108  std::vector<EdgeRing*>& shellList);
109 
110  static void assignHoleToShell(EdgeRing* holeER,
111  std::vector<EdgeRing*>& shellList);
112 
113 protected:
114 
115  PolygonizeGraph* graph;
116 
117  // initialize with empty collections, in case nothing is computed
118  std::vector<const geom::LineString*> dangles;
119  std::vector<const geom::LineString*> cutEdges;
120  std::vector<geom::LineString*> invalidRingLines;
121 
122  std::vector<EdgeRing*> holeList;
123  std::vector<EdgeRing*> shellList;
124  std::vector<geom::Polygon*>* polyList;
125 
126 public:
127 
132  Polygonizer();
133 
134  ~Polygonizer();
135 
144  void add(std::vector<geom::Geometry*>* geomList);
145 
154  void add(std::vector<const geom::Geometry*>* geomList);
155 
164  void add(geom::Geometry* g);
165 
174  void add(const geom::Geometry* g);
175 
183  std::vector<geom::Polygon*>* getPolygons();
184 
192  const std::vector<const geom::LineString*>& getDangles();
193 
194 
202  const std::vector<const geom::LineString*>& getCutEdges();
203 
212  const std::vector<geom::LineString*>& getInvalidRingLines();
213 
214 // This seems to be needed by GCC 2.95.4
215  friend class Polygonizer::LineStringAdder;
216 };
217 
218 } // namespace geos::operation::polygonize
219 } // namespace geos::operation
220 } // namespace geos
221 
222 #ifdef _MSC_VER
223 #pragma warning(pop)
224 #endif
225 
226 #endif // GEOS_OP_POLYGONIZE_POLYGONIZER_H
Polygonizes a set of Geometrys which contain linework that represents the edges of a planar graph...
Definition: Polygonizer.h:73
Represents a planar graph of edges that can be used to compute a polygonization, and implements the a...
Definition: PolygonizeGraph.h:69
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:187
Definition: LineString.h:69
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
Definition: GeometryComponentFilter.h:43