GEOS  3.8.1
planargraph/Node.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2001-2002 Vivid Solutions Inc.
7  * Copyright (C) 2005-2006 Refractions Research Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Public Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  **********************************************************************/
15 
16 #ifndef GEOS_PLANARGRAPH_NODE_H
17 #define GEOS_PLANARGRAPH_NODE_H
18 
19 #include <geos/export.h>
20 
21 #include <geos/planargraph/GraphComponent.h> // for inheritance
22 #include <geos/planargraph/DirectedEdgeStar.h> // for inlines
23 #include <geos/geom/Coordinate.h> // for composition
24 
25 // Forward declarations
26 namespace geos {
27 namespace planargraph {
28 //class DirectedEdgeStar;
29 class DirectedEdge;
30 }
31 }
32 
33 namespace geos {
34 namespace planargraph { // geos.planargraph
35 
45 class GEOS_DLL Node: public GraphComponent {
46 protected:
47 
49  geom::Coordinate pt;
50 
52  DirectedEdgeStar* deStar;
53 
54 public:
55 
56  friend std::ostream& operator << (std::ostream& os, const Node&);
57 
65  static std::vector<Edge*>* getEdgesBetween(Node* node0,
66  Node* node1);
67 
69  Node(const geom::Coordinate& newPt)
70  :
71  pt(newPt)
72  {
73  deStar = new DirectedEdgeStar();
74  }
75 
76  ~Node() override
77  {
78  delete deStar;
79  }
80 
87  Node(geom::Coordinate& newPt, DirectedEdgeStar* newDeStar)
88  :
89  pt(newPt),
90  deStar(newDeStar)
91  {}
92 
97  getCoordinate()
98  {
99  return pt;
100  }
101 
105  void
106  addOutEdge(DirectedEdge* de)
107  {
108  deStar->add(de);
109  }
110 
116  getOutEdges()
117  {
118  return deStar;
119  }
120  const DirectedEdgeStar*
121  getOutEdges() const
122  {
123  return deStar;
124  }
125 
129  size_t
130  getDegree() const
131  {
132  return deStar->getDegree();
133  }
134 
140  int
141  getIndex(Edge* edge)
142  {
143  return deStar->getIndex(edge);
144  }
145 
146 };
147 
149 std::ostream& operator<<(std::ostream& os, const Node& n);
150 
151 
153 //typedef Node planarNode;
154 
155 } // namespace geos::planargraph
156 } // namespace geos
157 
158 #endif // GEOS_PLANARGRAPH_NODE_H
geos::planargraph::DirectedEdge
Represents a directed edge in a PlanarGraph.
Definition: planargraph/DirectedEdge.h:45
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:24
geos::planargraph::DirectedEdgeStar::getDegree
std::size_t getDegree() const
Returns the number of edges around the Node associated with this DirectedEdgeStar.
Definition: planargraph/DirectedEdgeStar.h:98
geos::planargraph::DirectedEdgeStar
A sorted collection of DirectedEdge which leave a Node in a PlanarGraph.
Definition: planargraph/DirectedEdgeStar.h:42
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:81
geos::planargraph::operator<<
std::ostream & operator<<(std::ostream &, const DirectedEdge &)
Output operator.
geos::planargraph::Edge
Represents an undirected edge of a PlanarGraph.
Definition: planargraph/Edge.h:53