00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef GEOS_GEOMGRAPH_PLANARGRAPH_H
00023 #define GEOS_GEOMGRAPH_PLANARGRAPH_H
00024
00025 #include <geos/export.h>
00026 #include <map>
00027 #include <vector>
00028 #include <memory>
00029
00030 #include <geos/geom/Coordinate.h>
00031 #include <geos/geomgraph/PlanarGraph.h>
00032 #include <geos/geomgraph/NodeMap.h>
00033 #include <geos/geomgraph/DirectedEdgeStar.h>
00034
00035 #include <geos/inline.h>
00036
00037
00038 namespace geos {
00039 namespace geom {
00040 class Coordinate;
00041 }
00042 namespace geomgraph {
00043 class Edge;
00044 class Node;
00045 class EdgeEnd;
00046 class NodeFactory;
00047 }
00048 }
00049
00050 namespace geos {
00051 namespace geomgraph {
00052
00076 class GEOS_DLL PlanarGraph {
00077 public:
00078
00087 template <typename It>
00088 static void linkResultDirectedEdges(It first, It last)
00089
00090 {
00091 for ( ; first!=last; ++first )
00092 {
00093 Node *node=*first;
00094 assert(node);
00095
00096 EdgeEndStar* ees = node->getEdges();
00097 assert(ees);
00098 DirectedEdgeStar* des = dynamic_cast<DirectedEdgeStar*>(ees);
00099 assert(des);
00100
00101
00102 des->linkResultDirectedEdges();
00103 }
00104 }
00105
00106 PlanarGraph(const NodeFactory &nodeFact);
00107
00108 PlanarGraph();
00109
00110 virtual ~PlanarGraph();
00111
00112 virtual std::vector<Edge*>::iterator getEdgeIterator();
00113
00114 virtual std::vector<EdgeEnd*>* getEdgeEnds();
00115
00116 virtual bool isBoundaryNode(int geomIndex, const geom::Coordinate& coord);
00117
00118 virtual void add(EdgeEnd *e);
00119
00120 virtual NodeMap::iterator getNodeIterator();
00121
00122 virtual void getNodes(std::vector<Node*>&);
00123
00124 virtual Node* addNode(Node *node);
00125
00126 virtual Node* addNode(const geom::Coordinate& coord);
00127
00131 virtual Node* find(geom::Coordinate& coord);
00132
00137 virtual void addEdges(const std::vector<Edge*> &edgesToAdd);
00138
00139 virtual void linkResultDirectedEdges();
00140
00141 virtual void linkAllDirectedEdges();
00142
00150 virtual EdgeEnd* findEdgeEnd(Edge *e);
00151
00158 virtual Edge* findEdge(const geom::Coordinate& p0,
00159 const geom::Coordinate& p1);
00160
00168 virtual Edge* findEdgeInSameDirection(const geom::Coordinate& p0,
00169 const geom::Coordinate& p1);
00170
00171 virtual std::string printEdges();
00172
00173 virtual NodeMap* getNodeMap();
00174
00175 protected:
00176
00177 std::vector<Edge*> *edges;
00178
00179 NodeMap *nodes;
00180
00181 std::vector<EdgeEnd*> *edgeEndList;
00182
00183 virtual void insertEdge(Edge *e);
00184
00185 private:
00186
00194 bool matchInSameDirection(const geom::Coordinate& p0,
00195 const geom::Coordinate& p1,
00196 const geom::Coordinate& ep0,
00197 const geom::Coordinate& ep1);
00198 };
00199
00200
00201
00202 }
00203 }
00204
00205
00206
00207
00208
00209 #endif // ifndef GEOS_GEOMGRAPH_PLANARGRAPH_H
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229