GEOS 3.9.1
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#ifndef GEOS_GEOMGRAPH_PLANARGRAPH_H
22#define GEOS_GEOMGRAPH_PLANARGRAPH_H
23
24#include <geos/export.h>
25#include <map>
26#include <vector>
27#include <memory>
28
29#include <geos/geom/Coordinate.h>
30#include <geos/geomgraph/PlanarGraph.h>
31#include <geos/geomgraph/NodeMap.h> // for typedefs
32#include <geos/geomgraph/DirectedEdgeStar.h> // for inlines
33
34#include <geos/inline.h>
35
36// Forward declarations
37namespace geos {
38namespace geom {
39class Coordinate;
40}
41namespace geomgraph {
42class Edge;
43class Node;
44class EdgeEnd;
45class NodeFactory;
46}
47}
48
49namespace geos {
50namespace geomgraph { // geos.geomgraph
51
75class GEOS_DLL PlanarGraph {
76public:
77
86 template <typename It>
87 static void
88 linkResultDirectedEdges(It first, It last)
89 // throw(TopologyException);
90 {
91 for(; first != last; ++first) {
92 Node* node = *first;
93 assert(node);
94
95 EdgeEndStar* ees = node->getEdges();
96 assert(ees);
97 DirectedEdgeStar* des = dynamic_cast<DirectedEdgeStar*>(ees);
98 assert(des);
99
100 // this might throw an exception
102 }
103 }
104
105 PlanarGraph(const NodeFactory& nodeFact);
106
107 PlanarGraph();
108
109 virtual ~PlanarGraph();
110
111 virtual std::vector<Edge*>::iterator getEdgeIterator();
112
113 virtual std::vector<EdgeEnd*>* getEdgeEnds();
114
115 virtual bool isBoundaryNode(int geomIndex, const geom::Coordinate& coord);
116
117 virtual void add(EdgeEnd* e);
118
119 virtual NodeMap::iterator getNodeIterator();
120
121 virtual void getNodes(std::vector<Node*>&);
122
123 virtual Node* addNode(Node* node);
124
125 virtual Node* addNode(const geom::Coordinate& coord);
126
130 virtual Node* find(geom::Coordinate& coord);
131
136 virtual void addEdges(const std::vector<Edge*>& edgesToAdd);
137
138 virtual void linkResultDirectedEdges();
139
140 virtual void linkAllDirectedEdges();
141
150
157 virtual Edge* findEdge(const geom::Coordinate& p0,
158 const geom::Coordinate& p1);
159
168 const geom::Coordinate& p1);
169
170 virtual std::string printEdges();
171
172 virtual NodeMap* getNodeMap();
173
174protected:
175
176 std::vector<Edge*>* edges;
177
178 NodeMap* nodes;
179
180 std::vector<EdgeEnd*>* edgeEndList;
181
182 virtual void insertEdge(Edge* e);
183
184private:
185
193 bool matchInSameDirection(const geom::Coordinate& p0,
194 const geom::Coordinate& p1,
195 const geom::Coordinate& ep0,
196 const geom::Coordinate& ep1);
197
198 PlanarGraph(const PlanarGraph&) = delete;
199 PlanarGraph& operator=(const PlanarGraph&) = delete;
200};
201
202
203
204} // namespace geos.geomgraph
205} // namespace geos
206
207//#ifdef GEOS_INLINE
208//# include "geos/geomgraph/PlanarGraph.inl"
209//#endif
210
211#endif // ifndef GEOS_GEOMGRAPH_PLANARGRAPH_H
212
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:60
A DirectedEdgeStar is an ordered list of outgoing DirectedEdges around a node.
Definition geomgraph/DirectedEdgeStar.h:55
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:65
Models the end of an edge incident on a node.
Definition EdgeEnd.h:56
Definition geomgraph/Edge.h:66
The node component of a geometry graph.
Definition geomgraph/Node.h:62
Represents a directed graph which is embeddable in a planar surface.
Definition geomgraph/PlanarGraph.h:75
virtual 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.
virtual 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 ...
virtual Node * find(geom::Coordinate &coord)
virtual 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...
virtual 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:88
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:26