GEOS: PlanarGraph.h Source File

GEOS 3.5.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

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
33 namespace geos {
34 namespace geom {
35 class Coordinate;
36 }
37 namespace planargraph {
38 class DirectedEdge;
39 class Edge;
40 class Node;
41 }
42 }
43
44 namespace geos {
45 namespace planargraph { // geos.planargraph
46
60 class GEOS_DLL PlanarGraph {
61
62 protected:
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
103 public:
104
105 typedef std::vector<Edge *> EdgeContainer;
106 typedef EdgeContainer::iterator EdgeIterator;
107
108
113 PlanarGraph() {}
114
115 virtual ~PlanarGraph() {}
116
122 Node* findNode(const geom::Coordinate& pt) {
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
222 void remove(DirectedEdge *de);
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
geos::planargraph::PlanarGraph::getNodes
void getNodes(std::vector< Node * > &nodes)
Returns the Nodes in this PlanarGraph.
Definition: planargraph/PlanarGraph.h:156
geos::planargraph::PlanarGraph::dirEdgeIterator
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
geos::planargraph::PlanarGraph::edgeEnd
std::vector< Edge * >::iterator edgeEnd()
Returns an iterator to one-past last Edge in this graph.
Definition: planargraph/PlanarGraph.h:189
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
geos::planargraph::DirectedEdge
Represents a directed edge in a PlanarGraph.
Definition: planargraph/DirectedEdge.h:46
geos::planargraph::PlanarGraph::add
void add(Node *node)
Adds a node to the std::map, replacing any that is already at that location.
Definition: planargraph/PlanarGraph.h:77
geos::planargraph::PlanarGraph::getEdges
std::vector< Edge * > * getEdges()
Returns the Edges that have been added to this PlanarGraph.
Definition: planargraph/PlanarGraph.h:198
geos::planargraph::PlanarGraph::add
void add(DirectedEdge *dirEdge)
Adds the Edge to this PlanarGraph.
Definition: planargraph/PlanarGraph.h:99
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
geos::planargraph::Edge
Represents an undirected edge of a PlanarGraph.
Definition: planargraph/Edge.h:54
geos::planargraph::PlanarGraph::edgeIterator
std::vector< Edge * >::iterator edgeIterator()
Alias for edgeBegin()
Definition: planargraph/PlanarGraph.h:171
geos::planargraph::PlanarGraph::edgeBegin
std::vector< Edge * >::iterator edgeBegin()
Returns an iterator to first Edge in this graph.
Definition: planargraph/PlanarGraph.h:180
geos::planargraph::NodeMap::getNodes
void getNodes(std::vector< Node * > &nodes)
Returns the Nodes in this NodeMap, sorted in ascending order by angle with the positive x-axis...
geos::planargraph::NodeMap::add
Node * add(Node *n)
Adds a node to the std::map, replacing any that is already at that location.
geos::planargraph::Node
A node in a PlanarGraph is a location where 0 or more Edge meet.
Definition: planargraph/Node.h:45
geos::planargraph::PlanarGraph::nodeIterator
NodeMap::container::iterator nodeIterator()
Returns an Iterator over the Nodes in this PlanarGraph.
Definition: planargraph/PlanarGraph.h:130
geos::planargraph::PlanarGraph::findNode
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
geos::planargraph::NodeMap::find
Node * find(const geom::Coordinate &coord)
Returns the Node at the given location, or null if no Node was there.
geos::planargraph::NodeMap
A map of Node, indexed by the coordinate of the node.
Definition: planargraph/NodeMap.h:48
geos::planargraph::PlanarGraph::PlanarGraph
PlanarGraph()
Constructs a PlanarGraph without any Edges, DirectedEdges, or Nodes.
Definition: planargraph/PlanarGraph.h:113
geos::planargraph::PlanarGraph
Represents a directed graph which is embeddable in a planar surface.
Definition: planargraph/PlanarGraph.h:60