GEOS 3.4.2

- 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