00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GEOS_OP_POLYGONIZE_POLYGONIZEGRAPH_H
00021 #define GEOS_OP_POLYGONIZE_POLYGONIZEGRAPH_H
00022
00023 #include <geos/export.h>
00024
00025 #include <geos/planargraph/PlanarGraph.h>
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
00035 namespace geos {
00036 namespace geom {
00037 class LineString;
00038 class GeometryFactory;
00039 class Coordinate;
00040 class CoordinateSequence;
00041 }
00042 namespace planargraph {
00043 class Node;
00044 class Edge;
00045 class DirectedEdge;
00046 }
00047 namespace operation {
00048 namespace polygonize {
00049 class EdgeRing;
00050 class PolygonizeDirectedEdge;
00051 }
00052 }
00053 }
00054
00055 namespace geos {
00056 namespace operation {
00057 namespace polygonize {
00058
00059
00069 class GEOS_DLL PolygonizeGraph: public planargraph::PlanarGraph {
00070
00071 public:
00072
00077 static void deleteAllEdges(planargraph::Node *node);
00078
00083 PolygonizeGraph(const geom::GeometryFactory *newFactory);
00084
00089 ~PolygonizeGraph();
00090
00096 void addEdge(const geom::LineString *line);
00097
00106 void getEdgeRings(std::vector<EdgeRing*>& edgeRingList);
00107
00117 void deleteCutEdges(std::vector<const geom::LineString*> &cutLines);
00118
00131 void deleteDangles(std::vector<const geom::LineString*> &dangleLines);
00132
00133 private:
00134
00135 static int getDegreeNonDeleted(planargraph::Node *node);
00136
00137 static int getDegree(planargraph::Node *node, long label);
00138
00139 const geom::GeometryFactory *factory;
00140
00141 planargraph::Node* getNode(const geom::Coordinate& pt);
00142
00143 void computeNextCWEdges();
00144
00154 void convertMaximalToMinimalEdgeRings(
00155 std::vector<PolygonizeDirectedEdge*> &ringEdges);
00156
00167 static void findIntersectionNodes( PolygonizeDirectedEdge *startDE,
00168 long label, std::vector<planargraph::Node*>& intNodes
00169 );
00170
00180 static void findLabeledEdgeRings(
00181 std::vector<planargraph::DirectedEdge*> &dirEdgesIn,
00182 std::vector<PolygonizeDirectedEdge*> &dirEdgesOut);
00183
00184 static void label(std::vector<planargraph::DirectedEdge*> &dirEdges, long label);
00185
00186 static void computeNextCWEdges(planargraph::Node *node);
00187
00195 static void computeNextCCWEdges(planargraph::Node *node, long label);
00196
00207 static void findDirEdgesInRing(PolygonizeDirectedEdge *startDE,
00208 std::vector<planargraph::DirectedEdge*>& edgesInRing);
00209
00210 EdgeRing* findEdgeRing(PolygonizeDirectedEdge *startDE);
00211
00212
00213 std::vector<planargraph::Edge *> newEdges;
00214 std::vector<planargraph::DirectedEdge *> newDirEdges;
00215 std::vector<planargraph::Node *> newNodes;
00216 std::vector<EdgeRing *> newEdgeRings;
00217 std::vector<geom::CoordinateSequence *> newCoords;
00218 };
00219
00220 }
00221 }
00222 }
00223
00224 #ifdef _MSC_VER
00225 #pragma warning(pop)
00226 #endif
00227
00228 #endif // GEOS_OP_POLYGONIZE_POLYGONIZEGRAPH_H