Polygonizer.h

00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2010 Sandro Santilli <strk@keybit.net>
00007  * Copyright (C) 2006 Refractions Research Inc.
00008  * Copyright (C) 2001-2002 Vivid Solutions Inc.
00009  *
00010  * This is free software; you can redistribute and/or modify it under
00011  * the terms of the GNU Lesser General Public Licence as published
00012  * by the Free Software Foundation. 
00013  * See the COPYING file for more information.
00014  *
00015  **********************************************************************
00016  *
00017  * Last port: operation/polygonize/Polygonizer.java rev. 1.6 (JTS-1.10)
00018  *
00019  **********************************************************************/
00020 
00021 #ifndef GEOS_OP_POLYGONIZE_POLYGONIZER_H
00022 #define GEOS_OP_POLYGONIZE_POLYGONIZER_H
00023 
00024 #include <geos/export.h>
00025 #include <geos/geom/GeometryComponentFilter.h> // for LineStringAdder inheritance
00026 
00027 #include <vector>
00028 
00029 #ifdef _MSC_VER
00030 #pragma warning(push)
00031 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00032 #endif
00033 
00034 // Forward declarations
00035 namespace geos {
00036         namespace geom { 
00037                 class Geometry;
00038                 class LineString;
00039                 class Polygon;
00040         }
00041         namespace operation { 
00042                 namespace polygonize { 
00043                         class EdgeRing;
00044                         class PolygonizeGraph;
00045                 }
00046         }
00047 }
00048 
00049 namespace geos {
00050 namespace operation { // geos::operation
00051 namespace polygonize { // geos::operation::polygonize
00052 
00073 class GEOS_DLL Polygonizer {
00074 private:
00078         class GEOS_DLL LineStringAdder: public geom::GeometryComponentFilter {
00079         public:
00080                 Polygonizer *pol;
00081                 LineStringAdder(Polygonizer *p);
00082                 //void filter_rw(geom::Geometry *g);
00083                 void filter_ro(const geom::Geometry * g);
00084         };
00085 
00086         // default factory
00087         LineStringAdder lineStringAdder;
00088 
00094         void add(const geom::LineString *line);
00095 
00099         void polygonize();
00100 
00101         void findValidRings(const std::vector<EdgeRing*>& edgeRingList,
00102                         std::vector<EdgeRing*>& validEdgeRingList,
00103                         std::vector<geom::LineString*>& invalidRingList);
00104 
00105         void findShellsAndHoles(const std::vector<EdgeRing*>& edgeRingList);
00106 
00107         static void assignHolesToShells(const std::vector<EdgeRing*>& holeList,
00108                         std::vector<EdgeRing*>& shellList);
00109 
00110         static void assignHoleToShell(EdgeRing *holeER,
00111                         std::vector<EdgeRing*>& shellList);
00112 
00113 protected:
00114 
00115         PolygonizeGraph *graph;
00116 
00117         // initialize with empty collections, in case nothing is computed
00118         std::vector<const geom::LineString*> dangles;
00119         std::vector<const geom::LineString*> cutEdges;
00120         std::vector<geom::LineString*> invalidRingLines;
00121 
00122         std::vector<EdgeRing*> holeList;
00123         std::vector<EdgeRing*> shellList;
00124         std::vector<geom::Polygon*> *polyList;
00125 
00126 public:
00127 
00132         Polygonizer();
00133 
00134         ~Polygonizer();
00135 
00144         void add(std::vector<geom::Geometry*> *geomList);
00145 
00154         void add(std::vector<const geom::Geometry*> *geomList);
00155 
00164         void add(geom::Geometry *g);
00165 
00174         void add(const geom::Geometry *g);
00175 
00183         std::vector<geom::Polygon*>* getPolygons();
00184 
00192         const std::vector<const geom::LineString*>& getDangles();
00193 
00194 
00202         const std::vector<const geom::LineString*>& getCutEdges();
00203 
00212         const std::vector<geom::LineString*>& getInvalidRingLines();
00213 
00214 // This seems to be needed by    GCC 2.95.4
00215 friend class Polygonizer::LineStringAdder;
00216 };
00217 
00218 } // namespace geos::operation::polygonize
00219 } // namespace geos::operation
00220 } // namespace geos
00221 
00222 #ifdef _MSC_VER
00223 #pragma warning(pop)
00224 #endif
00225 
00226 #endif // GEOS_OP_POLYGONIZE_POLYGONIZER_H

Generated on 30 Dec 2015 for GEOS by  doxygen 1.4.7