GEOS: PlanarGraph.h Source File

GEOS 3.3.8

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

- File List

planargraph/PlanarGraph.h
1 /**********************************************************************
2 * $Id: PlanarGraph.h 3078 2010-07-01 21:44:33Z strk $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
7 * Copyright (C) 2005-2006 Refractions Research 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: planargraph/PlanarGraph.java rev. 107/138 (JTS-1.10)
17 *
18 **********************************************************************/
19
20 #ifndef GEOS_PLANARGRAPH_PLANARGRAPH_H
21 #define GEOS_PLANARGRAPH_PLANARGRAPH_H
22
23 #include <geos/export.h>
24 #include <geos/planargraph/NodeMap.h> // for composition
25
26 #include <vector> // for typedefs
27
28 #ifdef _MSC_VER
29 #pragma warning(push)
30 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
31 #endif
32
33 // Forward declarations
34 namespace geos {
35 namespace geom {
36 class Coordinate;
37 }
38 namespace planargraph {
39 class DirectedEdge;
40 class Edge;
41 class Node;
42 }
43 }
44
45 namespace geos {
46 namespace planargraph { // geos.planargraph
47
61 class GEOS_DLL PlanarGraph {
62
63 protected:
64
65 std::vector<Edge*> edges;
66 std::vector<DirectedEdge*> dirEdges;
67 NodeMap nodeMap;
68
78 void add(Node *node) {
79 nodeMap.add(node);
80 }
81
91 void add(Edge *edge);
92
100 void add(DirectedEdge *dirEdge) {
101 dirEdges.push_back(dirEdge);
102 }
103
104 public:
105
106 typedef std::vector<Edge *> EdgeContainer;
107 typedef EdgeContainer::iterator EdgeIterator;
108
109
114 PlanarGraph() {}
115
116 virtual ~PlanarGraph() {}
117
123 Node* findNode(const geom::Coordinate& pt) {
124 return nodeMap.find(pt);
125 }
126
131 NodeMap::container::iterator nodeIterator() {
132 return nodeMap.begin();
133 }
134
135 NodeMap::container::iterator nodeBegin() {
136 return nodeMap.begin();
137 }
138
139 NodeMap::container::const_iterator nodeBegin() const {
140 return nodeMap.begin();
141 }
142
143 NodeMap::container::iterator nodeEnd() {
144 return nodeMap.end();
145 }
146
147 NodeMap::container::const_iterator nodeEnd() const {
148 return nodeMap.end();
149 }
150
157 void getNodes(std::vector<Node*>& nodes) { nodeMap.getNodes(nodes); }
158
167 std::vector<DirectedEdge*>::iterator dirEdgeIterator() {
168 return dirEdges.begin();
169 }
170
172 std::vector<Edge*>::iterator edgeIterator() {
173 return edges.begin();
174 }
175
177 //
181 std::vector<Edge*>::iterator edgeBegin() {
182 return edges.begin();
183 }
184
186 //
190 std::vector<Edge*>::iterator edgeEnd() {
191 return edges.end();
192 }
193
199 std::vector<Edge*>* getEdges() {
200 return &edges;
201 }
202
212 void remove(Edge *edge);
213
223 void remove(DirectedEdge *de);
224
230 void remove(Node *node);
231
237 std::vector<Node*>* findNodesOfDegree(std::size_t degree);
238
245 void findNodesOfDegree(std::size_t degree, std::vector<Node*>& to);
246 };
247
248 } // namespace geos::planargraph
249 } // namespace geos
250
251 #ifdef _MSC_VER
252 #pragma warning(pop)
253 #endif
254
255 #endif // GEOS_PLANARGRAPH_PLANARGRAPH_H
256
257 /**********************************************************************
258 * $Log$
259 * Revision 1.2 2006/06/12 10:49:43 strk
260 * unsigned int => size_t
261 *
262 * Revision 1.1 2006/03/21 21:42:54 strk
263 * planargraph.h header split, planargraph:: classes renamed to match JTS symbols
264 *
265 **********************************************************************/
266