GEOS  3.4.2
PlanarGraph.h
00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2005-2006 Refractions Research Inc.
00007  * Copyright (C) 2001-2002 Vivid Solutions Inc.
00008  *
00009  * This is free software; you can redistribute and/or modify it under
00010  * the terms of the GNU Lesser General Public Licence as published
00011  * by the Free Software Foundation. 
00012  * See the COPYING file for more information.
00013  *
00014  **********************************************************************
00015  *
00016  * Last port: geomgraph/PlanarGraph.java r428 (JTS-1.12+)
00017  *
00018  **********************************************************************/
00019 
00020 
00021 #ifndef GEOS_GEOMGRAPH_PLANARGRAPH_H
00022 #define GEOS_GEOMGRAPH_PLANARGRAPH_H
00023 
00024 #include <geos/export.h>
00025 #include <map>
00026 #include <vector>
00027 #include <memory>
00028 
00029 #include <geos/geom/Coordinate.h>
00030 #include <geos/geomgraph/PlanarGraph.h>
00031 #include <geos/geomgraph/NodeMap.h> // for typedefs
00032 #include <geos/geomgraph/DirectedEdgeStar.h> // for inlines
00033 
00034 #include <geos/inline.h>
00035 
00036 // Forward declarations
00037 namespace geos {
00038         namespace geom {
00039                 class Coordinate;
00040         }
00041         namespace geomgraph {
00042                 class Edge;
00043                 class Node;
00044                 class EdgeEnd;
00045                 class NodeFactory;
00046         }
00047 }
00048 
00049 namespace geos {
00050 namespace geomgraph { // geos.geomgraph
00051 
00075 class GEOS_DLL PlanarGraph {
00076 public:
00077 
00086   template <typename It>
00087   static void linkResultDirectedEdges(It first, It last)
00088     // throw(TopologyException);
00089   {
00090     for ( ; first!=last; ++first )
00091     {
00092       Node *node=*first;
00093       assert(node);
00094 
00095       EdgeEndStar* ees = node->getEdges();
00096       assert(ees);
00097       DirectedEdgeStar* des = dynamic_cast<DirectedEdgeStar*>(ees);
00098       assert(des);
00099 
00100       // this might throw an exception
00101       des->linkResultDirectedEdges();
00102     }
00103   }
00104 
00105         PlanarGraph(const NodeFactory &nodeFact);
00106 
00107         PlanarGraph();
00108 
00109         virtual ~PlanarGraph();
00110 
00111         virtual std::vector<Edge*>::iterator getEdgeIterator();
00112 
00113         virtual std::vector<EdgeEnd*>* getEdgeEnds();
00114 
00115         virtual bool isBoundaryNode(int geomIndex, const geom::Coordinate& coord);
00116 
00117         virtual void add(EdgeEnd *e);
00118 
00119         virtual NodeMap::iterator getNodeIterator();
00120 
00121         virtual void getNodes(std::vector<Node*>&);
00122 
00123         virtual Node* addNode(Node *node);
00124 
00125         virtual Node* addNode(const geom::Coordinate& coord);
00126 
00130         virtual Node* find(geom::Coordinate& coord);
00131 
00136         virtual void addEdges(const std::vector<Edge*> &edgesToAdd);
00137 
00138         virtual void linkResultDirectedEdges();
00139 
00140         virtual void linkAllDirectedEdges();
00141 
00149         virtual EdgeEnd* findEdgeEnd(Edge *e);
00150 
00157         virtual Edge* findEdge(const geom::Coordinate& p0,
00158                         const geom::Coordinate& p1);
00159 
00167         virtual Edge* findEdgeInSameDirection(const geom::Coordinate& p0,
00168                         const geom::Coordinate& p1);
00169 
00170         virtual std::string printEdges();
00171 
00172         virtual NodeMap* getNodeMap();
00173 
00174 protected:
00175 
00176         std::vector<Edge*> *edges;
00177 
00178         NodeMap *nodes;
00179 
00180         std::vector<EdgeEnd*> *edgeEndList;
00181 
00182         virtual void insertEdge(Edge *e);
00183 
00184 private:
00185 
00193         bool matchInSameDirection(const geom::Coordinate& p0,
00194                         const geom::Coordinate& p1,
00195                         const geom::Coordinate& ep0,
00196                         const geom::Coordinate& ep1);
00197 };
00198 
00199 
00200 
00201 } // namespace geos.geomgraph
00202 } // namespace geos
00203 
00204 //#ifdef GEOS_INLINE
00205 //# include "geos/geomgraph/PlanarGraph.inl"
00206 //#endif
00207 
00208 #endif // ifndef GEOS_GEOMGRAPH_PLANARGRAPH_H
00209