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  *
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: planargraph/PlanarGraph.java rev. 107/138 (JTS-1.10)
00016  *
00017  **********************************************************************/
00018 
00019 #ifndef GEOS_PLANARGRAPH_PLANARGRAPH_H
00020 #define GEOS_PLANARGRAPH_PLANARGRAPH_H
00021 
00022 #include <geos/export.h>
00023 #include <geos/planargraph/NodeMap.h> // for composition
00024 
00025 #include <vector> // for typedefs
00026 
00027 #ifdef _MSC_VER
00028 #pragma warning(push)
00029 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00030 #endif
00031 
00032 // Forward declarations
00033 namespace geos {
00034         namespace geom { 
00035                 class Coordinate;
00036         }
00037         namespace planargraph { 
00038                 class DirectedEdge;
00039                 class Edge;
00040                 class Node;
00041         }
00042 }
00043 
00044 namespace geos {
00045 namespace planargraph { // geos.planargraph
00046 
00060 class GEOS_DLL PlanarGraph {
00061 
00062 protected:
00063 
00064         std::vector<Edge*> edges;
00065         std::vector<DirectedEdge*> dirEdges;
00066         NodeMap nodeMap;
00067 
00077         void add(Node *node) {
00078                 nodeMap.add(node);
00079         }
00080 
00090         void add(Edge *edge);
00091 
00099         void add(DirectedEdge *dirEdge) {
00100                 dirEdges.push_back(dirEdge);
00101         }
00102 
00103 public:
00104 
00105         typedef std::vector<Edge *> EdgeContainer;
00106         typedef EdgeContainer::iterator EdgeIterator;
00107 
00108 
00113         PlanarGraph() {}
00114 
00115         virtual ~PlanarGraph() {}
00116 
00122         Node* findNode(const geom::Coordinate& pt) {
00123                 return nodeMap.find(pt);
00124         }
00125 
00130         NodeMap::container::iterator nodeIterator() {
00131                 return nodeMap.begin();
00132         }
00133 
00134         NodeMap::container::iterator nodeBegin() {
00135                 return nodeMap.begin();
00136         }
00137 
00138         NodeMap::container::const_iterator nodeBegin() const {
00139                 return nodeMap.begin();
00140         }
00141 
00142         NodeMap::container::iterator nodeEnd() {
00143                 return nodeMap.end();
00144         }
00145 
00146         NodeMap::container::const_iterator nodeEnd() const {
00147                 return nodeMap.end();
00148         }
00149 
00156         void getNodes(std::vector<Node*>& nodes) { nodeMap.getNodes(nodes); }
00157 
00166         std::vector<DirectedEdge*>::iterator dirEdgeIterator() {
00167                 return dirEdges.begin();
00168         }
00169 
00171         std::vector<Edge*>::iterator edgeIterator() {
00172                 return edges.begin();
00173         }
00174 
00176         //
00180         std::vector<Edge*>::iterator edgeBegin() {
00181                 return edges.begin();
00182         }
00183 
00185         //
00189         std::vector<Edge*>::iterator edgeEnd() {
00190                 return edges.end();
00191         }
00192 
00198         std::vector<Edge*>* getEdges() {
00199                 return &edges;
00200         }
00201 
00211         void remove(Edge *edge);
00212 
00222         void remove(DirectedEdge *de);
00223 
00229         void remove(Node *node);
00230 
00236         std::vector<Node*>* findNodesOfDegree(std::size_t degree);
00237 
00244         void findNodesOfDegree(std::size_t degree, std::vector<Node*>& to);
00245 };
00246 
00247 } // namespace geos::planargraph
00248 } // namespace geos
00249 
00250 #ifdef _MSC_VER
00251 #pragma warning(pop)
00252 #endif
00253 
00254 #endif // GEOS_PLANARGRAPH_PLANARGRAPH_H

Generated on 23 Sep 2013 for GEOS by  doxygen 1.4.7