GEOS 3.6.2
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 {
34 namespace geom {
35 class Coordinate;
36 }
37 namespace planargraph {
38 class DirectedEdge;
39 class Edge;
40 class 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
77 void add(Node *node) {
78 nodeMap.add(node);
79 }
80
90 void add(Edge *edge);
91
99 void add(DirectedEdge *dirEdge) {
100 dirEdges.push_back(dirEdge);
101 }
102
103public:
104
105 typedef std::vector<Edge *> EdgeContainer;
106 typedef EdgeContainer::iterator EdgeIterator;
107
108
114
115 virtual ~PlanarGraph() {}
116
123 return nodeMap.find(pt);
124 }
125
130 NodeMap::container::iterator nodeIterator() {
131 return nodeMap.begin();
132 }
133
134 NodeMap::container::iterator nodeBegin() {
135 return nodeMap.begin();
136 }
137
138 NodeMap::container::const_iterator nodeBegin() const {
139 return nodeMap.begin();
140 }
141
142 NodeMap::container::iterator nodeEnd() {
143 return nodeMap.end();
144 }
145
146 NodeMap::container::const_iterator nodeEnd() const {
147 return nodeMap.end();
148 }
149
156 void getNodes(std::vector<Node*>& nodes) { nodeMap.getNodes(nodes); }
157
166 std::vector<DirectedEdge*>::iterator dirEdgeIterator() {
167 return dirEdges.begin();
168 }
169
171 std::vector<Edge*>::iterator edgeIterator() {
172 return edges.begin();
173 }
174
176 //
180 std::vector<Edge*>::iterator edgeBegin() {
181 return edges.begin();
182 }
183
185 //
189 std::vector<Edge*>::iterator edgeEnd() {
190 return edges.end();
191 }
192
198 std::vector<Edge*>* getEdges() {
199 return &edges;
200 }
201
211 void remove(Edge *edge);
212
223
229 void remove(Node *node);
230
236 std::vector<Node*>* findNodesOfDegree(std::size_t degree);
237
244 void findNodesOfDegree(std::size_t degree, std::vector<Node*>& to);
245};
246
247} // namespace geos::planargraph
248} // namespace geos
249
250#ifdef _MSC_VER
251#pragma warning(pop)
252#endif
253
254#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
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:113
std::vector< Edge * >::iterator edgeIterator()
Alias for edgeBegin().
Definition planargraph/PlanarGraph.h:171
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:166
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:122
NodeMap::container::iterator nodeIterator()
Returns an Iterator over the Nodes in this PlanarGraph.
Definition planargraph/PlanarGraph.h:130
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()
Returns the Edges that have been added to this PlanarGraph.
Definition planargraph/PlanarGraph.h:198
std::vector< Edge * >::iterator edgeBegin()
Returns an iterator to first Edge in this graph.
Definition planargraph/PlanarGraph.h:180
void add(DirectedEdge *dirEdge)
Adds the Edge to this PlanarGraph.
Definition planargraph/PlanarGraph.h:99
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:156
std::vector< Edge * >::iterator edgeEnd()
Returns an iterator to one-past last Edge in this graph.
Definition planargraph/PlanarGraph.h:189
Contains the Geometry interface hierarchy and supporting classes.
Definition IndexedNestedRingTester.h:26
Contains classes to implement a planar graph data structure.
Definition LineMergeDirectedEdge.h:32
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:25