• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List

PlanarGraph.h

00001 /**********************************************************************
00002  * $Id: PlanarGraph.h 2733 2009-11-20 19:58: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 #ifndef GEOS_PLANARGRAPH_PLANARGRAPH_H
00017 #define GEOS_PLANARGRAPH_PLANARGRAPH_H
00018 
00019 #include <geos/export.h>
00020 #include <geos/planargraph/NodeMap.h> // for composition
00021 
00022 #include <vector> // for typedefs
00023 
00024 // Forward declarations
00025 namespace geos {
00026         namespace geom { 
00027                 class Coordinate;
00028         }
00029         namespace planargraph { 
00030                 class DirectedEdge;
00031                 class Edge;
00032                 class Node;
00033         }
00034 }
00035 
00036 namespace geos {
00037 namespace planargraph { // geos.planargraph
00038 
00052 class GEOS_DLL PlanarGraph {
00053 
00054 protected:
00055 
00056         std::vector<Edge*> edges;
00057         std::vector<DirectedEdge*> dirEdges;
00058         NodeMap nodeMap;
00059 
00069         void add(Node *node) {
00070                 nodeMap.add(node);
00071         }
00072 
00082         void add(Edge *edge);
00083 
00091         void add(DirectedEdge *dirEdge) {
00092                 dirEdges.push_back(dirEdge);
00093         }
00094 
00095 public:
00096 
00097         typedef std::vector<Edge *> EdgeContainer;
00098         typedef EdgeContainer::iterator EdgeIterator;
00099 
00100 
00105         PlanarGraph() {}
00106 
00107         virtual ~PlanarGraph() {}
00108 
00114         Node* findNode(const geom::Coordinate& pt) {
00115                 return nodeMap.find(pt);
00116         }
00117 
00122         NodeMap::container::iterator nodeIterator() {
00123                 return nodeMap.begin();
00124         }
00125 
00126         NodeMap::container::iterator nodeBegin() {
00127                 return nodeMap.begin();
00128         }
00129 
00130         NodeMap::container::const_iterator nodeBegin() const {
00131                 return nodeMap.begin();
00132         }
00133 
00134         NodeMap::container::iterator nodeEnd() {
00135                 return nodeMap.end();
00136         }
00137 
00138         NodeMap::container::const_iterator nodeEnd() const {
00139                 return nodeMap.end();
00140         }
00141 
00148         void getNodes(std::vector<Node*>& nodes) { nodeMap.getNodes(nodes); }
00149 
00158         std::vector<DirectedEdge*>::iterator dirEdgeIterator() {
00159                 return dirEdges.begin();
00160         }
00161 
00163         std::vector<Edge*>::iterator edgeIterator() {
00164                 return edges.begin();
00165         }
00166 
00168         //
00172         std::vector<Edge*>::iterator edgeBegin() {
00173                 return edges.begin();
00174         }
00175 
00177         //
00181         std::vector<Edge*>::iterator edgeEnd() {
00182                 return edges.end();
00183         }
00184 
00190         std::vector<Edge*>* getEdges() {
00191                 return &edges;
00192         }
00193 
00203         void remove(Edge *edge);
00204 
00214         void remove(DirectedEdge *de);
00215 
00221         void remove(Node *node);
00222 
00228         std::vector<Node*>* findNodesOfDegree(size_t degree);
00229 };
00230 
00231 } // namespace geos::planargraph
00232 } // namespace geos
00233 
00234 #endif // GEOS_PLANARGRAPH_PLANARGRAPH_H
00235 
00236 /**********************************************************************
00237  * $Log$
00238  * Revision 1.2  2006/06/12 10:49:43  strk
00239  * unsigned int => size_t
00240  *
00241  * Revision 1.1  2006/03/21 21:42:54  strk
00242  * planargraph.h header split, planargraph:: classes renamed to match JTS symbols
00243  *
00244  **********************************************************************/
00245 

Generated on Thu Jul 22 2010 for GEOS by  doxygen 1.7.1