GEOS 3.4.2

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

- File List

geomgraph/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 * Copyright (C) 2001-2002 Vivid Solutions 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: geomgraph/PlanarGraph.java r428 (JTS-1.12+)
17 *
18 **********************************************************************/
19
20
21 #ifndef GEOS_GEOMGRAPH_PLANARGRAPH_H
22 #define GEOS_GEOMGRAPH_PLANARGRAPH_H
23
24 #include <geos/export.h>
25 #include <map>
26 #include <vector>
27 #include <memory>
28
29 #include <geos/geom/Coordinate.h>
30 #include <geos/geomgraph/PlanarGraph.h>
31 #include <geos/geomgraph/NodeMap.h> // for typedefs
32 #include <geos/geomgraph/DirectedEdgeStar.h> // for inlines
33
34 #include <geos/inline.h>
35
36 // Forward declarations
37 namespace geos {
38 namespace geom {
39 class Coordinate;
40 }
41 namespace geomgraph {
42 class Edge;
43 class Node;
44 class EdgeEnd;
45 class NodeFactory;
46 }
47 }
48
49 namespace geos {
50 namespace geomgraph { // geos.geomgraph
51
75 class GEOS_DLL PlanarGraph {
76 public:
77
86 template <typename It>
87 static void linkResultDirectedEdges(It first, It last)
88 // throw(TopologyException);
89 {
90 for ( ; first!=last; ++first )
91 {
92 Node *node=*first;
93 assert(node);
94
95 EdgeEndStar* ees = node->getEdges();
96 assert(ees);
97 DirectedEdgeStar* des = dynamic_cast<DirectedEdgeStar*>(ees);
98 assert(des);
99
100 // this might throw an exception
101 des->linkResultDirectedEdges();
102 }
103 }
104
105 PlanarGraph(const NodeFactory &nodeFact);
106
107 PlanarGraph();
108
109 virtual ~PlanarGraph();
110
111 virtual std::vector<Edge*>::iterator getEdgeIterator();
112
113 virtual std::vector<EdgeEnd*>* getEdgeEnds();
114
115 virtual bool isBoundaryNode(int geomIndex, const geom::Coordinate& coord);
116
117 virtual void add(EdgeEnd *e);
118
119 virtual NodeMap::iterator getNodeIterator();
120
121 virtual void getNodes(std::vector<Node*>&);
122
123 virtual Node* addNode(Node *node);
124
125 virtual Node* addNode(const geom::Coordinate& coord);
126
130 virtual Node* find(geom::Coordinate& coord);
131
136 virtual void addEdges(const std::vector<Edge*> &edgesToAdd);
137
138 virtual void linkResultDirectedEdges();
139
140 virtual void linkAllDirectedEdges();
141
149 virtual EdgeEnd* findEdgeEnd(Edge *e);
150
157 virtual Edge* findEdge(const geom::Coordinate& p0,
158 const geom::Coordinate& p1);
159
167 virtual Edge* findEdgeInSameDirection(const geom::Coordinate& p0,
168 const geom::Coordinate& p1);
169
170 virtual std::string printEdges();
171
172 virtual NodeMap* getNodeMap();
173
174 protected:
175
176 std::vector<Edge*> *edges;
177
178 NodeMap *nodes;
179
180 std::vector<EdgeEnd*> *edgeEndList;
181
182 virtual void insertEdge(Edge *e);
183
184 private:
185
193 bool matchInSameDirection(const geom::Coordinate& p0,
194 const geom::Coordinate& p1,
195 const geom::Coordinate& ep0,
196 const geom::Coordinate& ep1);
197 };
198
199
200
201 } // namespace geos.geomgraph
202 } // namespace geos
203
204 //#ifdef GEOS_INLINE
205 //# include "geos/geomgraph/PlanarGraph.inl"
206 //#endif
207
208 #endif // ifndef GEOS_GEOMGRAPH_PLANARGRAPH_H
209