GEOS: PlanarGraph.h Source File

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

# PlanarGraph.h

    00001 /**********************************************************************
    00002  * $Id: PlanarGraph.h 3281 2011-04-18 15:08:24Z strk $
    00003  *
    00004  * GEOS - Geometry Engine Open Source
    00005  * http://geos.refractions.net
    00006  *
    00007  * Copyright (C) 2005-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: geomgraph/PlanarGraph.java rev. 1.6 (JTS-1.10)
    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> // for typedefs
    00033 #include <geos/geomgraph/DirectedEdgeStar.h> // for inlines
    00034
    00035 #include <geos/inline.h>
    00036
    00037 // Forward declarations
    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 { // geos.geomgraph
    00052
    00076 class GEOS_DLL PlanarGraph {
    00077 public:
    00078
    00087   template <typename It>
    00088   static void linkResultDirectedEdges(It first, It last)
    00089     // throw(TopologyException);
    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       // this might throw an exception
    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 } // namespace geos.geomgraph
    00203 } // namespace geos
    00204
    00205 //#ifdef GEOS_INLINE
    00206 //# include "geos/geomgraph/PlanarGraph.inl"
    00207 //#endif
    00208
    00209 #endif // ifndef GEOS_GEOMGRAPH_PLANARGRAPH_H
    00210
    00211 /**********************************************************************
    00212  * $Log$
    00213  * Revision 1.5  2006/06/01 11:49:36  strk
    00214  * Reduced installed headers form geomgraph namespace
    00215  *
    00216  * Revision 1.4  2006/04/07 16:52:20  strk
    00217  * Port info, doxygen comments, assertion checking
    00218  *
    00219  * Revision 1.3  2006/03/24 09:52:41  strk
    00220  * USE_INLINE => GEOS_INLINE
    00221  *
    00222  * Revision 1.2  2006/03/14 15:46:54  strk
    00223  * Added PlanarGraph::getNodes(vector&) func, to reduce useless heap allocations
    00224  *
    00225  * Revision 1.1  2006/03/09 16:46:49  strk
    00226  * geos::geom namespace definition, first pass at headers split
    00227  *
    00228  **********************************************************************/
    00229