geomgraph/PlanarGraph.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2005-2006 Refractions Research Inc.
* Copyright (C) 2001-2002 Vivid Solutions 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: geomgraph/PlanarGraph.java r428 (JTS-1.12+)
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <map>
#include <vector>
#include <memory>
#include <geos/geom/Coordinate.h>
#include <geos/geomgraph/PlanarGraph.h>
#include <geos/geomgraph/NodeMap.h> // for typedefs
#include <geos/geomgraph/DirectedEdgeStar.h> // for inlines
// Forward declarations
namespace geos {
namespace geom {
class Coordinate;
}
namespace geomgraph {
class Edge;
class Node;
class EdgeEnd;
class NodeFactory;
}
}
namespace geos {
namespace geomgraph { // geos.geomgraph
class GEOS_DLL PlanarGraph /* non-final */ {
public:
template <typename It>
static void
linkResultDirectedEdges(It first, It last)
// throw(TopologyException);
{
for(; first != last; ++first) {
Node* node = *first;
assert(node);
EdgeEndStar* ees = node->getEdges();
assert(ees);
DirectedEdgeStar* des = dynamic_cast<DirectedEdgeStar*>(ees);
assert(des);
// this might throw an exception
des->linkResultDirectedEdges();
}
}
PlanarGraph(const NodeFactory& nodeFact);
PlanarGraph();
virtual ~PlanarGraph();
std::vector<Edge*>::iterator getEdgeIterator();
std::vector<EdgeEnd*>* getEdgeEnds();
bool isBoundaryNode(uint8_t geomIndex, const geom::Coordinate& coord);
void add(EdgeEnd* e);
NodeMap::iterator getNodeIterator();
void getNodes(std::vector<Node*>&);
Node* addNode(Node* node);
Node* addNode(const geom::Coordinate& coord);
Node* find(geom::Coordinate& coord);
void addEdges(const std::vector<Edge*>& edgesToAdd);
void linkResultDirectedEdges();
void linkAllDirectedEdges();
EdgeEnd* findEdgeEnd(Edge* e);
Edge* findEdge(const geom::Coordinate& p0,
const geom::Coordinate& p1);
Edge* findEdgeInSameDirection(const geom::Coordinate& p0,
const geom::Coordinate& p1);
std::string printEdges();
NodeMap* getNodeMap();
protected:
std::vector<Edge*>* edges;
NodeMap* nodes;
std::vector<EdgeEnd*>* edgeEndList;
void insertEdge(Edge* e);
private:
bool matchInSameDirection(const geom::Coordinate& p0,
const geom::Coordinate& p1,
const geom::Coordinate& ep0,
const geom::Coordinate& ep1);
PlanarGraph(const PlanarGraph&) = delete;
PlanarGraph& operator=(const PlanarGraph&) = delete;
};
} // namespace geos.geomgraph
} // namespace geos
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::geomgraph::DirectedEdgeStar
A DirectedEdgeStar is an ordered list of outgoing DirectedEdges around a node.
Definition geomgraph/DirectedEdgeStar.h:54
geos::geomgraph::DirectedEdgeStar::linkResultDirectedEdges
void linkResultDirectedEdges()
Traverse the star of DirectedEdges, linking the included edges together.
geos::geomgraph::EdgeEndStar
A EdgeEndStar is an ordered list of EdgeEnds around a node.
Definition EdgeEndStar.h:63
geos::geomgraph::EdgeEnd
Models the end of an edge incident on a node.
Definition EdgeEnd.h:54
geos::geomgraph::Edge
Definition geomgraph/Edge.h:63
geos::geomgraph::Node
The node component of a geometry graph.
Definition geomgraph/Node.h:59
geos::geomgraph::PlanarGraph
Represents a directed graph which is embeddable in a planar surface.
Definition geomgraph/PlanarGraph.h:72
geos::geomgraph::PlanarGraph::findEdgeInSameDirection
Edge * findEdgeInSameDirection(const geom::Coordinate &p0, const geom::Coordinate &p1)
Returns the edge which starts at p0 and whose first segment is parallel to p1.
geos::geomgraph::PlanarGraph::findEdgeEnd
EdgeEnd * findEdgeEnd(Edge *e)
Returns the EdgeEnd which has edge e as its base edge (MD 18 Feb 2002 - this should return a pair of ...
geos::geomgraph::PlanarGraph::find
Node * find(geom::Coordinate &coord)
geos::geomgraph::PlanarGraph::addEdges
void addEdges(const std::vector< Edge * > &edgesToAdd)
Add a set of edges to the graph. For each edge two DirectedEdges will be created. DirectedEdges are N...
geos::geomgraph::PlanarGraph::findEdge
Edge * findEdge(const geom::Coordinate &p0, const geom::Coordinate &p1)
Returns the edge whose first two coordinates are p0 and p1.
geos::geomgraph::PlanarGraph::linkResultDirectedEdges
static void linkResultDirectedEdges(It first, It last)
For nodes in the collection (first..last), link the DirectedEdges at the node that are in the result.
Definition geomgraph/PlanarGraph.h:85
geos::geom
Definition Angle.h:26
geos::geomgraph
Contains classes that implement topology graphs.
Definition Depth.h:31
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38