GEOS 3.14.0dev
geomgraph/PlanarGraph.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2005-2006 Refractions Research Inc.
7 * Copyright (C) 2001-2002 Vivid Solutions 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 * Last port: geomgraph/PlanarGraph.java r428 (JTS-1.12+)
17 *
18 **********************************************************************/
19
20
21#pragma once
22
23#include <geos/export.h>
24#include <map>
25#include <vector>
26#include <memory>
27
28#include <geos/geom/Coordinate.h>
29#include <geos/geomgraph/PlanarGraph.h>
30#include <geos/geomgraph/NodeMap.h> // for typedefs
31#include <geos/geomgraph/DirectedEdgeStar.h> // for inlines
32
33// Forward declarations
34namespace geos {
35namespace geom {
36class Coordinate;
37}
38namespace geomgraph {
39class Edge;
40class Node;
41class EdgeEnd;
42class NodeFactory;
43}
44}
45
46namespace geos {
47namespace geomgraph { // geos.geomgraph
48
72class GEOS_DLL PlanarGraph /* non-final */ {
73public:
74
83 template <typename It>
84 static void
85 linkResultDirectedEdges(It first, It last)
86 // throw(TopologyException);
87 {
88 for(; first != last; ++first) {
89 Node* node = *first;
90 assert(node);
91
92 EdgeEndStar* ees = node->getEdges();
93 assert(ees);
94 DirectedEdgeStar* des = dynamic_cast<DirectedEdgeStar*>(ees);
95 assert(des);
96
97 // this might throw an exception
99 }
100 }
101
102 PlanarGraph(const NodeFactory& nodeFact);
103
104 PlanarGraph();
105
106 virtual ~PlanarGraph();
107
108 std::vector<Edge*>::iterator getEdgeIterator();
109
110 std::vector<EdgeEnd*>* getEdgeEnds();
111
112 bool isBoundaryNode(uint8_t geomIndex, const geom::Coordinate& coord);
113
114 void add(EdgeEnd* e);
115
116 NodeMap::iterator getNodeIterator();
117
118 void getNodes(std::vector<Node*>&);
119
120 Node* addNode(Node* node);
121
122 Node* addNode(const geom::Coordinate& coord);
123
128
133 void addEdges(const std::vector<Edge*>& edgesToAdd);
134
135 void linkResultDirectedEdges();
136
137 void linkAllDirectedEdges();
138
147
155 const geom::Coordinate& p1);
156
165 const geom::Coordinate& p1);
166
167 std::string printEdges();
168
169 NodeMap* getNodeMap();
170
171protected:
172
173 std::vector<Edge*>* edges;
174
175 NodeMap* nodes;
176
177 std::vector<EdgeEnd*>* edgeEndList;
178
179 void insertEdge(Edge* e);
180
181private:
182
190 bool matchInSameDirection(const geom::Coordinate& p0,
191 const geom::Coordinate& p1,
192 const geom::Coordinate& ep0,
193 const geom::Coordinate& ep1);
194
195 PlanarGraph(const PlanarGraph&) = delete;
196 PlanarGraph& operator=(const PlanarGraph&) = delete;
197};
198
199
200
201} // namespace geos.geomgraph
202} // namespace geos
203
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
A DirectedEdgeStar is an ordered list of outgoing DirectedEdges around a node.
Definition geomgraph/DirectedEdgeStar.h:54
void linkResultDirectedEdges()
Traverse the star of DirectedEdges, linking the included edges together.
A EdgeEndStar is an ordered list of EdgeEnds around a node.
Definition EdgeEndStar.h:63
Models the end of an edge incident on a node.
Definition EdgeEnd.h:54
Definition geomgraph/Edge.h:63
The node component of a geometry graph.
Definition geomgraph/Node.h:59
Represents a directed graph which is embeddable in a planar surface.
Definition geomgraph/PlanarGraph.h:72
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.
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 ...
Node * find(geom::Coordinate &coord)
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...
Edge * findEdge(const geom::Coordinate &p0, const geom::Coordinate &p1)
Returns the edge whose first two coordinates are p0 and p1.
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
Basic namespace for all GEOS functionalities.
Definition geos.h:39