GEOS  3.3.7
PlanarGraph.h
00001 /**********************************************************************
00002  * $Id: PlanarGraph.h 3078 2010-07-01 21:44:33Z strk $
00003  *
00004  * GEOS - Geometry Engine Open Source
00005  * http://geos.refractions.net
00006  *
00007  * Copyright (C) 2005-2006 Refractions Research 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: planargraph/PlanarGraph.java rev. 107/138 (JTS-1.10)
00017  *
00018  **********************************************************************/
00019 
00020 #ifndef GEOS_PLANARGRAPH_PLANARGRAPH_H
00021 #define GEOS_PLANARGRAPH_PLANARGRAPH_H
00022 
00023 #include <geos/export.h>
00024 #include <geos/planargraph/NodeMap.h> // for composition
00025 
00026 #include <vector> // for typedefs
00027 
00028 #ifdef _MSC_VER
00029 #pragma warning(push)
00030 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00031 #endif
00032 
00033 // Forward declarations
00034 namespace geos {
00035         namespace geom { 
00036                 class Coordinate;
00037         }
00038         namespace planargraph { 
00039                 class DirectedEdge;
00040                 class Edge;
00041                 class Node;
00042         }
00043 }
00044 
00045 namespace geos {
00046 namespace planargraph { // geos.planargraph
00047 
00061 class GEOS_DLL PlanarGraph {
00062 
00063 protected:
00064 
00065         std::vector<Edge*> edges;
00066         std::vector<DirectedEdge*> dirEdges;
00067         NodeMap nodeMap;
00068 
00078         void add(Node *node) {
00079                 nodeMap.add(node);
00080         }
00081 
00091         void add(Edge *edge);
00092 
00100         void add(DirectedEdge *dirEdge) {
00101                 dirEdges.push_back(dirEdge);
00102         }
00103 
00104 public:
00105 
00106         typedef std::vector<Edge *> EdgeContainer;
00107         typedef EdgeContainer::iterator EdgeIterator;
00108 
00109 
00114         PlanarGraph() {}
00115 
00116         virtual ~PlanarGraph() {}
00117 
00123         Node* findNode(const geom::Coordinate& pt) {
00124                 return nodeMap.find(pt);
00125         }
00126 
00131         NodeMap::container::iterator nodeIterator() {
00132                 return nodeMap.begin();
00133         }
00134 
00135         NodeMap::container::iterator nodeBegin() {
00136                 return nodeMap.begin();
00137         }
00138 
00139         NodeMap::container::const_iterator nodeBegin() const {
00140                 return nodeMap.begin();
00141         }
00142 
00143         NodeMap::container::iterator nodeEnd() {
00144                 return nodeMap.end();
00145         }
00146 
00147         NodeMap::container::const_iterator nodeEnd() const {
00148                 return nodeMap.end();
00149         }
00150 
00157         void getNodes(std::vector<Node*>& nodes) { nodeMap.getNodes(nodes); }
00158 
00167         std::vector<DirectedEdge*>::iterator dirEdgeIterator() {
00168                 return dirEdges.begin();
00169         }
00170 
00172         std::vector<Edge*>::iterator edgeIterator() {
00173                 return edges.begin();
00174         }
00175 
00177         //
00181         std::vector<Edge*>::iterator edgeBegin() {
00182                 return edges.begin();
00183         }
00184 
00186         //
00190         std::vector<Edge*>::iterator edgeEnd() {
00191                 return edges.end();
00192         }
00193 
00199         std::vector<Edge*>* getEdges() {
00200                 return &edges;
00201         }
00202 
00212         void remove(Edge *edge);
00213 
00223         void remove(DirectedEdge *de);
00224 
00230         void remove(Node *node);
00231 
00237         std::vector<Node*>* findNodesOfDegree(std::size_t degree);
00238 
00245         void findNodesOfDegree(std::size_t degree, std::vector<Node*>& to);
00246 };
00247 
00248 } // namespace geos::planargraph
00249 } // namespace geos
00250 
00251 #ifdef _MSC_VER
00252 #pragma warning(pop)
00253 #endif
00254 
00255 #endif // GEOS_PLANARGRAPH_PLANARGRAPH_H
00256 
00257 /**********************************************************************
00258  * $Log$
00259  * Revision 1.2  2006/06/12 10:49:43  strk
00260  * unsigned int => size_t
00261  *
00262  * Revision 1.1  2006/03/21 21:42:54  strk
00263  * planargraph.h header split, planargraph:: classes renamed to match JTS symbols
00264  *
00265  **********************************************************************/
00266