GEOS  3.3.3
planargraph/Node.h
1 /**********************************************************************
2  * $Id: Node.h 2556 2009-06-06 22:22:28Z strk $
3  *
4  * GEOS - Geometry Engine Open Source
5  * http://geos.refractions.net
6  *
7  * Copyright (C) 2001-2002 Vivid Solutions Inc.
8  * Copyright (C) 2005-2006 Refractions Research Inc.
9  *
10  * This is free software; you can redistribute and/or modify it under
11  * the terms of the GNU Lesser General Public Licence as published
12  * by the Free Software Foundation.
13  * See the COPYING file for more information.
14  *
15  **********************************************************************/
16 
17 #ifndef GEOS_PLANARGRAPH_NODE_H
18 #define GEOS_PLANARGRAPH_NODE_H
19 
20 #include <geos/export.h>
21 
22 #include <geos/planargraph/GraphComponent.h> // for inheritance
23 #include <geos/planargraph/DirectedEdgeStar.h> // for inlines
24 #include <geos/geom/Coordinate.h> // for composition
25 
26 // Forward declarations
27 namespace geos {
28  namespace planargraph {
29  //class DirectedEdgeStar;
30  class DirectedEdge;
31  }
32 }
33 
34 namespace geos {
35 namespace planargraph { // geos.planargraph
36 
46 class GEOS_DLL Node: public GraphComponent {
47 protected:
48 
51 
54 
55 public:
56 
57  friend std::ostream& operator << (std::ostream& os, const Node&);
58 
66  static std::vector<Edge*>* getEdgesBetween(Node *node0,
67  Node *node1);
68 
70  Node(const geom::Coordinate& newPt)
71  :
72  pt(newPt)
73  { deStar=new DirectedEdgeStar(); }
74 
75  virtual ~Node() {
76  delete deStar;
77  }
78 
86  :
87  pt(newPt),
88  deStar(newDeStar)
89  {}
90 
95  return pt;
96  }
97 
102  deStar->add(de);
103  }
104 
109  DirectedEdgeStar* getOutEdges() { return deStar; }
110  const DirectedEdgeStar* getOutEdges() const { return deStar; }
111 
115  size_t getDegree() const {
116  return deStar->getDegree();
117  }
118 
124  int getIndex(Edge *edge) {
125  return deStar->getIndex(edge);
126  }
127 
128 };
129 
131 std::ostream& operator<<(std::ostream& os, const Node& n);
132 
133 
135 //typedef Node planarNode;
136 
137 } // namespace geos::planargraph
138 } // namespace geos
139 
140 #endif // GEOS_PLANARGRAPH_NODE_H
141 
142 /**********************************************************************
143  * $Log$
144  * Revision 1.3 2006/06/12 16:57:26 strk
145  * Added note about ownership of return from getEdgesBetween()
146  *
147  * Revision 1.2 2006/06/12 10:49:43 strk
148  * unsigned int => size_t
149  *
150  * Revision 1.1 2006/03/21 21:42:54 strk
151  * planargraph.h header split, planargraph:: classes renamed to match JTS symbols
152  *
153  **********************************************************************/
154 
geom::Coordinate & getCoordinate()
Returns the location of this Node.
Definition: planargraph/Node.h:94
int getIndex(Edge *edge)
Returns the zero-based index of the given Edge, after sorting in ascending order by angle with the po...
Definition: planargraph/Node.h:124
DirectedEdgeStar * deStar
The collection of DirectedEdges that leave this Node.
Definition: planargraph/Node.h:53
A sorted collection of DirectedEdge which leave a Node in a PlanarGraph.
Definition: planargraph/DirectedEdgeStar.h:47
Node(const geom::Coordinate &newPt)
Constructs a Node with the given location.
Definition: planargraph/Node.h:70
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:61
Represents a directed edge in a PlanarGraph.
Definition: planargraph/DirectedEdge.h:47
size_t getDegree() const
Returns the number of edges around this Node.
Definition: planargraph/Node.h:115
Node(geom::Coordinate &newPt, DirectedEdgeStar *newDeStar)
Constructs a Node with the given location and collection of outgoing DirectedEdges. Takes ownership of the given DirectedEdgeStar!!
Definition: planargraph/Node.h:85
DirectedEdgeStar * getOutEdges()
Returns the collection of DirectedEdges that leave this Node.
Definition: planargraph/Node.h:109
std::ostream & operator<<(std::ostream &os, const Edge &n)
Print a Edge.
Represents an undirected edge of a PlanarGraph.
Definition: planargraph/Edge.h:55
void addOutEdge(DirectedEdge *de)
Adds an outgoing DirectedEdge to this Node.
Definition: planargraph/Node.h:101
geom::Coordinate pt
The location of this Node.
Definition: planargraph/Node.h:50
The base class for all graph component classes.
Definition: planargraph/GraphComponent.h:47
A node in a PlanarGraph is a location where 0 or more Edge meet.
Definition: planargraph/Node.h:46