planargraph/PlanarGraph.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* 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.
*
**********************************************************************
*
* Last port: planargraph/PlanarGraph.java rev. 107/138 (JTS-1.10)
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/planargraph/NodeMap.h> // for composition
#include <vector> // for typedefs
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
#endif
// Forward declarations
namespace geos {
namespace geom {
class Coordinate;
}
namespace planargraph {
class DirectedEdge;
class Edge;
class Node;
}
}
namespace geos {
namespace planargraph { // geos.planargraph
class GEOS_DLL PlanarGraph {
protected:
std::vector<Edge*> edges;
std::vector<DirectedEdge*> dirEdges;
NodeMap nodeMap;
void
add(Node* node)
{
nodeMap.add(node);
}
void add(Edge* edge);
void
add(DirectedEdge* dirEdge)
{
dirEdges.push_back(dirEdge);
}
public:
typedef std::vector<Edge*> EdgeContainer;
typedef EdgeContainer::iterator EdgeIterator;
PlanarGraph() {}
virtual
~PlanarGraph() {}
Node*
findNode(const geom::Coordinate& pt)
{
return nodeMap.find(pt);
}
NodeMap::container::iterator
nodeIterator()
{
return nodeMap.begin();
}
NodeMap::container::iterator
nodeBegin()
{
return nodeMap.begin();
}
NodeMap::container::const_iterator
nodeBegin() const
{
return nodeMap.begin();
}
NodeMap::container::iterator
nodeEnd()
{
return nodeMap.end();
}
NodeMap::container::const_iterator
nodeEnd() const
{
return nodeMap.end();
}
void
getNodes(std::vector<Node*>& nodes)
{
nodeMap.getNodes(nodes);
}
std::vector<DirectedEdge*>::iterator
dirEdgeIterator()
{
return dirEdges.begin();
}
std::vector<DirectedEdge*>::iterator
dirEdgeBegin()
{
return dirEdges.begin();
}
std::vector<DirectedEdge*>::iterator
dirEdgeEnd()
{
return dirEdges.end();
}
std::vector<Edge*>::iterator
edgeIterator()
{
return edges.begin();
}
//
std::vector<Edge*>::iterator
edgeBegin()
{
return edges.begin();
}
//
std::vector<Edge*>::iterator
edgeEnd()
{
return edges.end();
}
std::vector<Edge*>*
getEdges()
{
return &edges;
}
void remove(Edge* edge);
void remove(DirectedEdge* de);
void remove(Node* node);
std::vector<Node*>* findNodesOfDegree(std::size_t degree);
void findNodesOfDegree(std::size_t degree, std::vector<Node*>& to);
};
} // namespace geos::planargraph
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
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::NodeMap
A map of Node, indexed by the coordinate of the node.
Definition planargraph/NodeMap.h:47
geos::planargraph::Node
A node in a PlanarGraph is a location where 0 or more Edge meet.
Definition planargraph/Node.h:44
geos::planargraph::PlanarGraph
Represents a directed graph which is embeddable in a planar surface.
Definition planargraph/PlanarGraph.h:59
geos::planargraph::PlanarGraph::PlanarGraph
PlanarGraph()
Constructs a PlanarGraph without any Edges, DirectedEdges, or Nodes.
Definition planargraph/PlanarGraph.h:115
geos::planargraph::PlanarGraph::edgeIterator
std::vector< Edge * >::iterator edgeIterator()
Alias for edgeBegin().
Definition planargraph/PlanarGraph.h:205
geos::planargraph::PlanarGraph::dirEdgeIterator
std::vector< DirectedEdge * >::iterator dirEdgeIterator()
Returns an Iterator over the DirectedEdges in this PlanarGraph, in the order in which they were added...
Definition planargraph/PlanarGraph.h:186
geos::planargraph::PlanarGraph::remove
void remove(DirectedEdge *de)
Removes DirectedEdge from its from-Node and from this PlanarGraph.
geos::planargraph::PlanarGraph::add
void add(Edge *edge)
Adds the Edge and its DirectedEdges with this PlanarGraph.
geos::planargraph::PlanarGraph::findNode
Node * findNode(const geom::Coordinate &pt)
Returns the Node at the given location, or null if no Node was there.
Definition planargraph/PlanarGraph.h:126
geos::planargraph::PlanarGraph::nodeIterator
NodeMap::container::iterator nodeIterator()
Returns an Iterator over the Nodes in this PlanarGraph.
Definition planargraph/PlanarGraph.h:136
geos::planargraph::PlanarGraph::findNodesOfDegree
std::vector< Node * > * findNodesOfDegree(std::size_t degree)
Returns all Nodes with the given number of Edges around it. The return value is a newly allocated vec...
geos::planargraph::PlanarGraph::getEdges
std::vector< Edge * > * getEdges()
Definition planargraph/PlanarGraph.h:237
geos::planargraph::PlanarGraph::edgeBegin
std::vector< Edge * >::iterator edgeBegin()
Returns an iterator to first Edge in this graph.
Definition planargraph/PlanarGraph.h:216
geos::planargraph::PlanarGraph::add
void add(DirectedEdge *dirEdge)
Adds the Edge to this PlanarGraph.
Definition planargraph/PlanarGraph.h:100
geos::planargraph::PlanarGraph::add
void add(Node *node)
Adds a node to the std::map, replacing any that is already at that location.
Definition planargraph/PlanarGraph.h:76
geos::planargraph::PlanarGraph::remove
void remove(Edge *edge)
Removes an Edge and its associated DirectedEdges from their from-Nodes and from this PlanarGraph.
geos::planargraph::PlanarGraph::remove
void remove(Node *node)
Removes a node from the graph, along with any associated DirectedEdges and Edges.
geos::planargraph::PlanarGraph::findNodesOfDegree
void findNodesOfDegree(std::size_t degree, std::vector< Node * > &to)
Get all Nodes with the given number of Edges around it.
geos::planargraph::PlanarGraph::getNodes
void getNodes(std::vector< Node * > &nodes)
Returns the Nodes in this PlanarGraph.
Definition planargraph/PlanarGraph.h:172
geos::planargraph::PlanarGraph::edgeEnd
std::vector< Edge * >::iterator edgeEnd()
Returns an iterator to one-past last Edge in this graph.
Definition planargraph/PlanarGraph.h:227
geos::geom
Definition Angle.h:26
geos::planargraph
Contains classes to implement a planar graph data structure.
Definition namespaces.h:293
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38