GEOS  3.8.0dev
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
88  linkResultDirectedEdges(It first, It last)
89  // throw(TopologyException);
90  {
91  for(; first != last; ++first) {
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
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 
A EdgeEndStar is an ordered list of EdgeEnds around a node.
Definition: EdgeEndStar.h:65
static void linkResultDirectedEdges(It first, It last)
For nodes in the collection (first..last), link the DirectedEdges at the node that are in the result...
Definition: geomgraph/PlanarGraph.h:88
A DirectedEdgeStar is an ordered list of outgoing DirectedEdges around a node.
Definition: geomgraph/DirectedEdgeStar.h:55
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Represents a directed graph which is embeddable in a planar surface.
Definition: geomgraph/PlanarGraph.h:75
Models the end of an edge incident on a node.
Definition: EdgeEnd.h:56
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Definition: geomgraph/Node.h:62
void linkResultDirectedEdges()
Traverse the star of DirectedEdges, linking the included edges together.
Definition: geomgraph/Edge.h:66