# Node.h

    00001 /**********************************************************************
    00002  * $Id: Node.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) 2001-2002 Vivid Solutions Inc.
    00008  * Copyright (C) 2005-2006 Refractions Research 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 #ifndef GEOS_PLANARGRAPH_NODE_H
    00018 #define GEOS_PLANARGRAPH_NODE_H
    00019
    00020 #include <geos/planargraph/GraphComponent.h> // for inheritance
    00021 #include <geos/planargraph/DirectedEdgeStar.h> // for inlines
    00022 #include <geos/geom/Coordinate.h> // for composition
    00023
    00024 // Forward declarations
    00025 namespace geos {
    00026         namespace planargraph {
    00027                 //class DirectedEdgeStar;
    00028                 class DirectedEdge;
    00029         }
    00030 }
    00031
    00032 namespace geos {
    00033 namespace planargraph { // geos.planargraph
    00034
    00044 class Node: public GraphComponent {
    00045 protected:
    00046
    00048         geom::Coordinate pt;
    00049
    00051         DirectedEdgeStar *deStar;
    00052
    00053 public:
    00054
    00055         friend std::ostream& operator << (std::ostream& os, const Node&);
    00056
    00064         static std::vector<Edge*>* getEdgesBetween(Node *node0,
    00065                         Node *node1);
    00066
    00068         Node(const geom::Coordinate& newPt)
    00069                 :
    00070                 pt(newPt)
    00071                 { deStar=new DirectedEdgeStar(); }
    00072
    00073         virtual ~Node() {
    00074                 delete deStar;
    00075         }
    00076
    00083         Node(geom::Coordinate& newPt, DirectedEdgeStar *newDeStar)
    00084                 :
    00085                 pt(newPt),
    00086                 deStar(newDeStar)
    00087                 {}
    00088
    00092         geom::Coordinate& getCoordinate() {
    00093                 return pt;
    00094         }
    00095
    00099         void addOutEdge(DirectedEdge *de) {
    00100                 deStar->add(de);
    00101         }
    00102
    00107         DirectedEdgeStar* getOutEdges() { return deStar; }
    00108         const DirectedEdgeStar* getOutEdges() const { return deStar; }
    00109
    00113         size_t getDegree() const {
    00114                 return deStar->getDegree();
    00115         }
    00116
    00122         int getIndex(Edge *edge) {
    00123                 return deStar->getIndex(edge);
    00124         }
    00125
    00126 };
    00127
    00129 std::ostream& operator<<(std::ostream& os, const Node& n);
    00130
    00131
    00133 //typedef Node planarNode;
    00134
    00135 } // namespace geos::planargraph
    00136 } // namespace geos
    00137
    00138 #endif // GEOS_PLANARGRAPH_NODE_H
    00139
    00140 /**********************************************************************
    00141  * $Log$
    00142  * Revision 1.3  2006/06/12 16:57:26  strk
    00143  * Added note about ownership of return from getEdgesBetween()
    00144  *
    00145  * Revision 1.2  2006/06/12 10:49:43  strk
    00146  * unsigned int => size_t
    00147  *
    00148  * Revision 1.1  2006/03/21 21:42:54  strk
    00149  * planargraph.h header split, planargraph:: classes renamed to match JTS symbols
    00150  *
    00151  **********************************************************************/
    00152