GEOS: PlanarGraph.h Source File

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

# PlanarGraph.h

    00001 /**********************************************************************
    00002  * $Id: PlanarGraph.h 1820 2006-09-06 16:54:23Z mloskot $
    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/planargraph/NodeMap.h> // for composition
    00020
    00021 #include <vector> // for typedefs
    00022
    00023 // Forward declarations
    00024 namespace geos {
    00025         namespace geom {
    00026                 class Coordinate;
    00027         }
    00028         namespace planargraph {
    00029                 class DirectedEdge;
    00030                 class Edge;
    00031                 class Node;
    00032         }
    00033 }
    00034
    00035 namespace geos {
    00036 namespace planargraph { // geos.planargraph
    00037
    00051 class PlanarGraph {
    00052
    00053 protected:
    00054
    00055         std::vector<Edge*> edges;
    00056         std::vector<DirectedEdge*> dirEdges;
    00057         NodeMap nodeMap;
    00058
    00068         void add(Node *node) {
    00069                 nodeMap.add(node);
    00070         }
    00071
    00081         void add(Edge *edge);
    00082
    00090         void add(DirectedEdge *dirEdge) {
    00091                 dirEdges.push_back(dirEdge);
    00092         }
    00093
    00094 public:
    00095
    00096         typedef std::vector<Edge *> EdgeContainer;
    00097         typedef EdgeContainer::iterator EdgeIterator;
    00098
    00099
    00104         PlanarGraph() {}
    00105
    00106         virtual ~PlanarGraph() {}
    00107
    00113         Node* findNode(const geom::Coordinate& pt) {
    00114                 return nodeMap.find(pt);
    00115         }
    00116
    00121         NodeMap::container::iterator nodeIterator() {
    00122                 return nodeMap.begin();
    00123         }
    00124
    00125         NodeMap::container::iterator nodeBegin() {
    00126                 return nodeMap.begin();
    00127         }
    00128
    00129         NodeMap::container::const_iterator nodeBegin() const {
    00130                 return nodeMap.begin();
    00131         }
    00132
    00133         NodeMap::container::iterator nodeEnd() {
    00134                 return nodeMap.end();
    00135         }
    00136
    00137         NodeMap::container::const_iterator nodeEnd() const {
    00138                 return nodeMap.end();
    00139         }
    00140
    00145         std::vector<Node*>* getNodes() { return nodeMap.getNodes(); }
    00146
    00155         std::vector<DirectedEdge*>::iterator dirEdgeIterator() {
    00156                 return dirEdges.begin();
    00157         }
    00158
    00160         std::vector<Edge*>::iterator edgeIterator() {
    00161                 return edges.begin();
    00162         }
    00163
    00165         //
    00169         std::vector<Edge*>::iterator edgeBegin() {
    00170                 return edges.begin();
    00171         }
    00172
    00174         //
    00178         std::vector<Edge*>::iterator edgeEnd() {
    00179                 return edges.end();
    00180         }
    00181
    00187         std::vector<Edge*>* getEdges() {
    00188                 return &edges;
    00189         }
    00190
    00200         void remove(Edge *edge);
    00201
    00211         void remove(DirectedEdge *de);
    00212
    00218         void remove(Node *node);
    00219
    00225         std::vector<Node*>* findNodesOfDegree(size_t degree);
    00226 };
    00227
    00228 } // namespace geos::planargraph
    00229 } // namespace geos
    00230
    00231 #endif // GEOS_PLANARGRAPH_PLANARGRAPH_H
    00232
    00233 /**********************************************************************
    00234  * $Log$
    00235  * Revision 1.2  2006/06/12 10:49:43  strk
    00236  * unsigned int => size_t
    00237  *
    00238  * Revision 1.1  2006/03/21 21:42:54  strk
    00239  * planargraph.h header split, planargraph:: classes renamed to match JTS symbols
    00240  *
    00241  **********************************************************************/
    00242