GEOS  3.4.2
PolygonBuilder.h
00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2006 Refractions Research Inc.
00007  *
00008  * This is free software; you can redistribute and/or modify it under
00009  * the terms of the GNU Lesser General Public Licence as published
00010  * by the Free Software Foundation. 
00011  * See the COPYING file for more information.
00012  *
00013  **********************************************************************
00014  *
00015  * Last port: operation/overlay/PolygonBuilder.java rev. 1.20 (JTS-1.10)
00016  *
00017  **********************************************************************/
00018 
00019 #ifndef GEOS_OP_OVERLAY_POLYGONBUILDER_H
00020 #define GEOS_OP_OVERLAY_POLYGONBUILDER_H
00021 
00022 #include <geos/export.h>
00023 
00024 #include <vector>
00025 
00026 #ifdef _MSC_VER
00027 #pragma warning(push)
00028 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00029 #endif
00030 
00031 // Forward declarations
00032 namespace geos {
00033         namespace geom {
00034                 class Geometry;
00035                 class Coordinate;
00036                 class GeometryFactory;
00037         }
00038         namespace geomgraph {
00039                 class EdgeRing;
00040                 class Node;
00041                 class PlanarGraph;
00042                 class DirectedEdge;
00043         }
00044         namespace operation {
00045                 namespace overlay {
00046                         class MaximalEdgeRing;
00047                         class MinimalEdgeRing;
00048                 }
00049         }
00050 }
00051 
00052 namespace geos {
00053 namespace operation { // geos::operation
00054 namespace overlay { // geos::operation::overlay
00055 
00061 class GEOS_DLL PolygonBuilder {
00062 public:
00063 
00064         PolygonBuilder(const geom::GeometryFactory *newGeometryFactory);
00065 
00066         ~PolygonBuilder();
00067 
00073         void add(geomgraph::PlanarGraph *graph);
00074             // throw(const TopologyException &)
00075 
00081         void add(const std::vector<geomgraph::DirectedEdge*> *dirEdges,
00082                         const std::vector<geomgraph::Node*> *nodes);
00083                         // throw(const TopologyException &)
00084 
00085         std::vector<geom::Geometry*>* getPolygons();
00086 
00091         bool containsPoint(const geom::Coordinate& p);
00092 
00093 private:
00094 
00095         const geom::GeometryFactory *geometryFactory;
00096 
00097         std::vector<geomgraph::EdgeRing*> shellList;
00098 
00106         void buildMaximalEdgeRings(
00107                 const std::vector<geomgraph::DirectedEdge*> *dirEdges,
00108                 std::vector<MaximalEdgeRing*> &maxEdgeRings);
00109                         // throw(const TopologyException &)
00110 
00111         void buildMinimalEdgeRings(
00112                 std::vector<MaximalEdgeRing*> &maxEdgeRings,
00113                 std::vector<geomgraph::EdgeRing*> &newShellList,
00114                 std::vector<geomgraph::EdgeRing*> &freeHoleList,
00115                 std::vector<MaximalEdgeRing*> &edgeRings);
00116 
00128         geomgraph::EdgeRing* findShell(std::vector<MinimalEdgeRing*>* minEdgeRings);
00129 
00141         void placePolygonHoles(geomgraph::EdgeRing *shell,
00142                 std::vector<MinimalEdgeRing*> *minEdgeRings);
00143 
00151         void sortShellsAndHoles(std::vector<MaximalEdgeRing*> &edgeRings,
00152                 std::vector<geomgraph::EdgeRing*> &newShellList,
00153                 std::vector<geomgraph::EdgeRing*> &freeHoleList);
00154 
00169         void placeFreeHoles(std::vector<geomgraph::EdgeRing*>& newShellList,
00170                 std::vector<geomgraph::EdgeRing*>& freeHoleList);
00171                 // throw(const TopologyException&)
00172 
00191         geomgraph::EdgeRing* findEdgeRingContaining(geomgraph::EdgeRing *testEr,
00192                 std::vector<geomgraph::EdgeRing*>& newShellList);
00193 
00194         std::vector<geom::Geometry*>* computePolygons(
00195                         std::vector<geomgraph::EdgeRing*>& newShellList);
00196 
00202 };
00203 
00204 } // namespace geos::operation::overlay
00205 } // namespace geos::operation
00206 } // namespace geos
00207 
00208 #ifdef _MSC_VER
00209 #pragma warning(pop)
00210 #endif
00211 
00212 #endif // ndef GEOS_OP_OVERLAY_POLYGONBUILDER_H