GEOS 3.15.0dev
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
48 geom::CoordinateXY pt;
49
52
53public:
54
55 friend std::ostream& operator << (std::ostream& os, const Node&);
56
61 static std::vector<Edge*> getEdgesBetween(const Node* node0,
62 const Node* node1);
63
65 explicit Node(const geom::CoordinateXY& newPt)
66 :
67 pt(newPt)
68 {}
69
70 ~Node() override = default;
71
75 const geom::CoordinateXY&
77 {
78 return pt;
79 }
80
84 void
86 {
87 deStar.add(de);
88 }
89
96 {
97 return &deStar;
98 }
99
100 const DirectedEdgeStar*
101 getOutEdges() const
102 {
103 return &deStar;
104 }
105
109 size_t
110 getDegree() const
111 {
112 return deStar.getDegree();
113 }
114
120 int
122 {
123 return deStar.getIndex(edge);
124 }
125
126private:
127
128 Node(const Node&) = delete;
129 Node& operator=(const Node&) = delete;
130
131};
132
134std::ostream& operator<<(std::ostream& os, const Node& n);
135
136
137} // namespace geos::planargraph
138} // namespace geos
139
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.
std::size_t getDegree() const
Returns the number of edges around the Node associated with this DirectedEdgeStar.
Definition planargraph/DirectedEdgeStar.h:98
int getIndex(const Edge *edge) const
Returns the zero-based index of the given Edge, after sorting in ascending order by angle with the po...
Represents a directed edge in a PlanarGraph.
Definition planargraph/DirectedEdge.h:45
Represents an undirected edge of a PlanarGraph.
Definition planargraph/Edge.h:55
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(const Node *node0, const Node *node1)
Returns all Edges that connect the two nodes (which are assumed to be different).
Node(const geom::CoordinateXY &newPt)
Constructs a Node with the given location.
Definition planargraph/Node.h:65
DirectedEdgeStar deStar
The collection of DirectedEdges that leave this Node.
Definition planargraph/Node.h:51
size_t getDegree() const
Returns the number of edges around this Node.
Definition planargraph/Node.h:110
geom::CoordinateXY pt
The location of this Node.
Definition planargraph/Node.h:48
const geom::CoordinateXY & getCoordinate() const
Returns the location of this Node.
Definition planargraph/Node.h:76
DirectedEdgeStar * getOutEdges()
Returns the collection of DirectedEdges that leave this Node.
Definition planargraph/Node.h:95
void addOutEdge(DirectedEdge *de)
Adds an outgoing DirectedEdge to this Node.
Definition planargraph/Node.h:85
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:121
std::ostream & operator<<(std::ostream &, const DirectedEdge &)
Output operator.
Basic namespace for all GEOS functionalities.
Definition geos.h:38