GEOS 3.9.1
planargraph/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 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 **********************************************************************
14 *
15 * Last port: planargraph/PlanarGraph.java rev. 107/138 (JTS-1.10)
16 *
17 **********************************************************************/
18
19#ifndef GEOS_PLANARGRAPH_PLANARGRAPH_H
20#define GEOS_PLANARGRAPH_PLANARGRAPH_H
21
22#include <geos/export.h>
23#include <geos/planargraph/NodeMap.h> // for composition
24
25#include <vector> // for typedefs
26
27#ifdef _MSC_VER
28#pragma warning(push)
29#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
30#endif
31
32// Forward declarations
33namespace geos {
34namespace geom {
35class Coordinate;
36}
37namespace planargraph {
38class DirectedEdge;
39class Edge;
40class Node;
41}
42}
43
44namespace geos {
45namespace planargraph { // geos.planargraph
46
60class GEOS_DLL PlanarGraph {
61
62protected:
63
64 std::vector<Edge*> edges;
65 std::vector<DirectedEdge*> dirEdges;
66 NodeMap nodeMap;
67
76 void
77 add(Node* node)
78 {
79 nodeMap.add(node);
80 }
81
91 void add(Edge* edge);
92
100 void
102 {
103 dirEdges.push_back(dirEdge);
104 }
105
106public:
107
108 typedef std::vector<Edge*> EdgeContainer;
109 typedef EdgeContainer::iterator EdgeIterator;
110
111
117
118 virtual
119 ~PlanarGraph() {}
120
126 Node*
128 {
129 return nodeMap.find(pt);
130 }
131
136 NodeMap::container::iterator
138 {
139 return nodeMap.begin();
140 }
141
142 NodeMap::container::iterator
143 nodeBegin()
144 {
145 return nodeMap.begin();
146 }
147
148 NodeMap::container::const_iterator
149 nodeBegin() const
150 {
151 return nodeMap.begin();
152 }
153
154 NodeMap::container::iterator
155 nodeEnd()
156 {
157 return nodeMap.end();
158 }
159
160 NodeMap::container::const_iterator
161 nodeEnd() const
162 {
163 return nodeMap.end();
164 }
165
172 void
173 getNodes(std::vector<Node*>& nodes)
174 {
175 nodeMap.getNodes(nodes);
176 }
177
186 std::vector<DirectedEdge*>::iterator
188 {
189 return dirEdges.begin();
190 }
191
193 std::vector<Edge*>::iterator
195 {
196 return edges.begin();
197 }
198
200 //
204 std::vector<Edge*>::iterator
206 {
207 return edges.begin();
208 }
209
211 //
215 std::vector<Edge*>::iterator
217 {
218 return edges.end();
219 }
220
225 std::vector<Edge*>*
227 {
228 return &edges;
229 }
230
240 void remove(Edge* edge);
241
252
258 void remove(Node* node);
259
265 std::vector<Node*>* findNodesOfDegree(std::size_t degree);
266
273 void findNodesOfDegree(std::size_t degree, std::vector<Node*>& to);
274};
275
276} // namespace geos::planargraph
277} // namespace geos
278
279#ifdef _MSC_VER
280#pragma warning(pop)
281#endif
282
283#endif // GEOS_PLANARGRAPH_PLANARGRAPH_H
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Represents a directed edge in a PlanarGraph.
Definition: planargraph/DirectedEdge.h:46
Represents an undirected edge of a PlanarGraph.
Definition: planargraph/Edge.h:54
A map of Node, indexed by the coordinate of the node.
Definition: planargraph/NodeMap.h:48
Node * find(const geom::Coordinate &coord)
Returns the Node at the given location, or null if no Node was there.
void getNodes(std::vector< Node * > &nodes)
Returns the Nodes in this NodeMap, sorted in ascending order by angle with the positive x-axis.
Node * add(Node *n)
Adds a node to the std::map, replacing any that is already at that location.
A node in a PlanarGraph is a location where 0 or more Edge meet.
Definition: planargraph/Node.h:45
Represents a directed graph which is embeddable in a planar surface.
Definition: planargraph/PlanarGraph.h:60
PlanarGraph()
Constructs a PlanarGraph without any Edges, DirectedEdges, or Nodes.
Definition: planargraph/PlanarGraph.h:116
std::vector< Edge * >::iterator edgeIterator()
Alias for edgeBegin()
Definition: planargraph/PlanarGraph.h:194
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:187
void remove(DirectedEdge *de)
Removes DirectedEdge from its from-Node and from this PlanarGraph.
void add(Edge *edge)
Adds the Edge and its DirectedEdges with this PlanarGraph.
Node * findNode(const geom::Coordinate &pt)
Returns the Node at the given location, or null if no Node was there.
Definition: planargraph/PlanarGraph.h:127
NodeMap::container::iterator nodeIterator()
Returns an Iterator over the Nodes in this PlanarGraph.
Definition: planargraph/PlanarGraph.h:137
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...
std::vector< Edge * > * getEdges()
Definition: planargraph/PlanarGraph.h:226
std::vector< Edge * >::iterator edgeBegin()
Returns an iterator to first Edge in this graph.
Definition: planargraph/PlanarGraph.h:205
void add(DirectedEdge *dirEdge)
Adds the Edge to this PlanarGraph.
Definition: planargraph/PlanarGraph.h:101
void add(Node *node)
Adds a node to the std::map, replacing any that is already at that location.
Definition: planargraph/PlanarGraph.h:77
void remove(Edge *edge)
Removes an Edge and its associated DirectedEdges from their from-Nodes and from this PlanarGraph.
void remove(Node *node)
Removes a node from the graph, along with any associated DirectedEdges and Edges.
void findNodesOfDegree(std::size_t degree, std::vector< Node * > &to)
Get all Nodes with the given number of Edges around it.
void getNodes(std::vector< Node * > &nodes)
Returns the Nodes in this PlanarGraph.
Definition: planargraph/PlanarGraph.h:173
std::vector< Edge * >::iterator edgeEnd()
Returns an iterator to one-past last Edge in this graph.
Definition: planargraph/PlanarGraph.h:216
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26