planargraph/Node.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2001-2002 Vivid Solutions Inc.
* Copyright (C) 2005-2006 Refractions Research Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/planargraph/GraphComponent.h> // for inheritance
#include <geos/planargraph/DirectedEdgeStar.h> // for inlines
#include <geos/geom/Coordinate.h> // for composition
// Forward declarations
namespace geos {
namespace planargraph {
//class DirectedEdgeStar;
class DirectedEdge;
}
}
namespace geos {
namespace planargraph { // geos.planargraph
class GEOS_DLL Node: public GraphComponent {
protected:
geom::Coordinate pt;
DirectedEdgeStar* deStar;
public:
friend std::ostream& operator << (std::ostream& os, const Node&);
static std::vector<Edge*>* getEdgesBetween(Node* node0,
Node* node1);
Node(const geom::Coordinate& newPt)
:
pt(newPt)
{
deStar = new DirectedEdgeStar();
}
~Node() override
{
delete deStar;
}
Node(geom::Coordinate& newPt, DirectedEdgeStar* newDeStar)
:
pt(newPt),
deStar(newDeStar)
{}
geom::Coordinate&
getCoordinate()
{
return pt;
}
void
addOutEdge(DirectedEdge* de)
{
deStar->add(de);
}
DirectedEdgeStar*
getOutEdges()
{
return deStar;
}
const DirectedEdgeStar*
getOutEdges() const
{
return deStar;
}
size_t
getDegree() const
{
return deStar->getDegree();
}
int
getIndex(Edge* edge)
{
return deStar->getIndex(edge);
}
private:
Node(const Node&) = delete;
Node& operator=(const Node&) = delete;
};
std::ostream& operator<<(std::ostream& os, const Node& n);
} // namespace geos::planargraph
} // namespace geos
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::planargraph::DirectedEdgeStar
A sorted collection of DirectedEdge which leave a Node in a PlanarGraph.
Definition planargraph/DirectedEdgeStar.h:42
geos::planargraph::DirectedEdge
Represents a directed edge in a PlanarGraph.
Definition planargraph/DirectedEdge.h:45
geos::planargraph::Edge
Represents an undirected edge of a PlanarGraph.
Definition planargraph/Edge.h:54
geos::planargraph::Node
A node in a PlanarGraph is a location where 0 or more Edge meet.
Definition planargraph/Node.h:44
geos::planargraph::Node::getEdgesBetween
static std::vector< Edge * > * getEdgesBetween(Node *node0, Node *node1)
Returns all Edges that connect the two nodes (which are assumed to be different).
geos::planargraph::Node::getCoordinate
geom::Coordinate & getCoordinate()
Returns the location of this Node.
Definition planargraph/Node.h:96
geos::planargraph::Node::Node
Node(geom::Coordinate &newPt, DirectedEdgeStar *newDeStar)
Constructs a Node with the given location and collection of outgoing DirectedEdges....
Definition planargraph/Node.h:86
geos::planargraph::Node::getDegree
size_t getDegree() const
Returns the number of edges around this Node.
Definition planargraph/Node.h:129
geos::planargraph::Node::getOutEdges
DirectedEdgeStar * getOutEdges()
Returns the collection of DirectedEdges that leave this Node.
Definition planargraph/Node.h:115
geos::planargraph::Node::addOutEdge
void addOutEdge(DirectedEdge *de)
Adds an outgoing DirectedEdge to this Node.
Definition planargraph/Node.h:105
geos::planargraph::Node::deStar
DirectedEdgeStar * deStar
The collection of DirectedEdges that leave this Node.
Definition planargraph/Node.h:51
geos::planargraph::Node::pt
geom::Coordinate pt
The location of this Node.
Definition planargraph/Node.h:48
geos::planargraph::Node::getIndex
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
geos::planargraph::Node::Node
Node(const geom::Coordinate &newPt)
Constructs a Node with the given location.
Definition planargraph/Node.h:68
geos::planargraph
Contains classes to implement a planar graph data structure.
Definition namespaces.h:293
geos::planargraph::operator<<
std::ostream & operator<<(std::ostream &, const DirectedEdge &)
Output operator.
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38