GEOS 3.3.4

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

- File List

geomgraph/PlanarGraph.h
1 /**********************************************************************
2 * $Id: PlanarGraph.h 3281 2011-04-18 15:08:24Z strk $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
7 * Copyright (C) 2005-2006 Refractions Research Inc.
8 * Copyright (C) 2001-2002 Vivid Solutions Inc.
9 *
10 * This is free software; you can redistribute and/or modify it under
11 * the terms of the GNU Lesser General Public Licence as published
12 * by the Free Software Foundation.
13 * See the COPYING file for more information.
14 *
15 **********************************************************************
16 *
17 * Last port: geomgraph/PlanarGraph.java rev. 1.6 (JTS-1.10)
18 *
19 **********************************************************************/
20
21
22 #ifndef GEOS_GEOMGRAPH_PLANARGRAPH_H
23 #define GEOS_GEOMGRAPH_PLANARGRAPH_H
24
25 #include <geos/export.h>
26 #include <map>
27 #include <vector>
28 #include <memory>
29
30 #include <geos/geom/Coordinate.h>
31 #include <geos/geomgraph/PlanarGraph.h>
32 #include <geos/geomgraph/NodeMap.h> // for typedefs
33 #include <geos/geomgraph/DirectedEdgeStar.h> // for inlines
34
35 #include <geos/inline.h>
36
37 // Forward declarations
38 namespace geos {
39 namespace geom {
40 class Coordinate;
41 }
42 namespace geomgraph {
43 class Edge;
44 class Node;
45 class EdgeEnd;
46 class NodeFactory;
47 }
48 }
49
50 namespace geos {
51 namespace geomgraph { // geos.geomgraph
52
76 class GEOS_DLL PlanarGraph {
77 public:
78
87 template <typename It>
88 static void linkResultDirectedEdges(It first, It last)
89 // throw(TopologyException);
90 {
91 for ( ; first!=last; ++first )
92 {
93 Node *node=*first;
94 assert(node);
95
96 EdgeEndStar* ees = node->getEdges();
97 assert(ees);
98 DirectedEdgeStar* des = dynamic_cast<DirectedEdgeStar*>(ees);
99 assert(des);
100
101 // this might throw an exception
102 des->linkResultDirectedEdges();
103 }
104 }
105
106 PlanarGraph(const NodeFactory &nodeFact);
107
108 PlanarGraph();
109
110 virtual ~PlanarGraph();
111
112 virtual std::vector<Edge*>::iterator getEdgeIterator();
113
114 virtual std::vector<EdgeEnd*>* getEdgeEnds();
115
116 virtual bool isBoundaryNode(int geomIndex, const geom::Coordinate& coord);
117
118 virtual void add(EdgeEnd *e);
119
120 virtual NodeMap::iterator getNodeIterator();
121
122 virtual void getNodes(std::vector<Node*>&);
123
124 virtual Node* addNode(Node *node);
125
126 virtual Node* addNode(const geom::Coordinate& coord);
127
131 virtual Node* find(geom::Coordinate& coord);
132
137 virtual void addEdges(const std::vector<Edge*> &edgesToAdd);
138
139 virtual void linkResultDirectedEdges();
140
141 virtual void linkAllDirectedEdges();
142
150 virtual EdgeEnd* findEdgeEnd(Edge *e);
151
158 virtual Edge* findEdge(const geom::Coordinate& p0,
159 const geom::Coordinate& p1);
160
168 virtual Edge* findEdgeInSameDirection(const geom::Coordinate& p0,
169 const geom::Coordinate& p1);
170
171 virtual std::string printEdges();
172
173 virtual NodeMap* getNodeMap();
174
175 protected:
176
177 std::vector<Edge*> *edges;
178
179 NodeMap *nodes;
180
181 std::vector<EdgeEnd*> *edgeEndList;
182
183 virtual void insertEdge(Edge *e);
184
185 private:
186
194 bool matchInSameDirection(const geom::Coordinate& p0,
195 const geom::Coordinate& p1,
196 const geom::Coordinate& ep0,
197 const geom::Coordinate& ep1);
198 };
199
200
201
202 } // namespace geos.geomgraph
203 } // namespace geos
204
205 //#ifdef GEOS_INLINE
206 //# include "geos/geomgraph/PlanarGraph.inl"
207 //#endif
208
209 #endif // ifndef GEOS_GEOMGRAPH_PLANARGRAPH_H
210
211 /**********************************************************************
212 * $Log$
213 * Revision 1.5 2006/06/01 11:49:36 strk
214 * Reduced installed headers form geomgraph namespace
215 *
216 * Revision 1.4 2006/04/07 16:52:20 strk
217 * Port info, doxygen comments, assertion checking
218 *
219 * Revision 1.3 2006/03/24 09:52:41 strk
220 * USE_INLINE => GEOS_INLINE
221 *
222 * Revision 1.2 2006/03/14 15:46:54 strk
223 * Added PlanarGraph::getNodes(vector&) func, to reduce useless heap allocations
224 *
225 * Revision 1.1 2006/03/09 16:46:49 strk
226 * geos::geom namespace definition, first pass at headers split
227 *
228 **********************************************************************/
229