GEOS 3.11.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#pragma once
17
18#include <geos/export.h>
19
20#include <geos/planargraph/GraphComponent.h> // for inheritance
21#include <geos/planargraph/DirectedEdgeStar.h> // for inlines
22#include <geos/geom/Coordinate.h> // for composition
23
24// Forward declarations
25namespace geos {
26namespace planargraph {
27//class DirectedEdgeStar;
28class DirectedEdge;
29}
30}
31
32namespace geos {
33namespace planargraph { // geos.planargraph
34
44class GEOS_DLL Node: public GraphComponent {
45protected:
46
49
52
53public:
54
55 friend std::ostream& operator << (std::ostream& os, const Node&);
56
64 static std::vector<Edge*>* getEdgesBetween(Node* node0,
65 Node* node1);
66
68 Node(const geom::Coordinate& newPt)
69 :
70 pt(newPt)
71 {
72 deStar = new DirectedEdgeStar();
73 }
74
75 ~Node() override
76 {
77 delete deStar;
78 }
79
87 :
88 pt(newPt),
89 deStar(newDeStar)
90 {}
91
97 {
98 return pt;
99 }
100
104 void
106 {
107 deStar->add(de);
108 }
109
116 {
117 return deStar;
118 }
119 const DirectedEdgeStar*
120 getOutEdges() const
121 {
122 return deStar;
123 }
124
128 size_t
129 getDegree() const
130 {
131 return deStar->getDegree();
132 }
133
139 int
141 {
142 return deStar->getIndex(edge);
143 }
144
145private:
146
147 Node(const Node&) = delete;
148 Node& operator=(const Node&) = delete;
149
150};
151
153std::ostream& operator<<(std::ostream& os, const Node& n);
154
155
156} // namespace geos::planargraph
157} // namespace geos
158
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
A sorted collection of DirectedEdge which leave a Node in a PlanarGraph.
Definition: planargraph/DirectedEdgeStar.h:42
void add(DirectedEdge *de)
Adds a new member to this DirectedEdgeStar.
int getIndex(const Edge *edge)
Returns the zero-based index of the given Edge, after sorting in ascending order by angle with the po...
std::size_t getDegree() const
Returns the number of edges around the Node associated with this DirectedEdgeStar.
Definition: planargraph/DirectedEdgeStar.h:98
Represents a directed edge in a PlanarGraph.
Definition: planargraph/DirectedEdge.h:45
Represents an undirected edge of a PlanarGraph.
Definition: planargraph/Edge.h:54
The base class for all graph component classes.
Definition: planargraph/GraphComponent.h:45
A node in a PlanarGraph is a location where 0 or more Edge meet.
Definition: planargraph/Node.h:44
static std::vector< Edge * > * getEdgesBetween(Node *node0, Node *node1)
Returns all Edges that connect the two nodes (which are assumed to be different).
geom::Coordinate & getCoordinate()
Returns the location of this Node.
Definition: planargraph/Node.h:96
Node(geom::Coordinate &newPt, DirectedEdgeStar *newDeStar)
Constructs a Node with the given location and collection of outgoing DirectedEdges....
Definition: planargraph/Node.h:86
size_t getDegree() const
Returns the number of edges around this Node.
Definition: planargraph/Node.h:129
DirectedEdgeStar * getOutEdges()
Returns the collection of DirectedEdges that leave this Node.
Definition: planargraph/Node.h:115
void addOutEdge(DirectedEdge *de)
Adds an outgoing DirectedEdge to this Node.
Definition: planargraph/Node.h:105
DirectedEdgeStar * deStar
The collection of DirectedEdges that leave this Node.
Definition: planargraph/Node.h:51
geom::Coordinate pt
The location of this Node.
Definition: planargraph/Node.h:48
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:140
Node(const geom::Coordinate &newPt)
Constructs a Node with the given location.
Definition: planargraph/Node.h:68
std::ostream & operator<<(std::ostream &, const DirectedEdge &)
Output operator.
Basic namespace for all GEOS functionalities.
Definition: geos.h:39