GEOS  3.3.3
BufferSubgraph.h
1 /**********************************************************************
2  * $Id: BufferSubgraph.h 3301 2011-04-27 09:42:31Z strk $
3  *
4  * GEOS - Geometry Engine Open Source
5  * http://geos.refractions.net
6  *
7  * Copyright (C) 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: operation/buffer/BufferSubgraph.java r378 (JTS-1.12)
17  *
18  **********************************************************************/
19 
20 #ifndef GEOS_OP_BUFFER_BUFFERSUBGRAPH_H
21 #define GEOS_OP_BUFFER_BUFFERSUBGRAPH_H
22 
23 #include <geos/export.h>
24 
25 #include <geos/operation/buffer/RightmostEdgeFinder.h> // for composition
26 
27 #include <vector>
28 #include <set>
29 
30 #ifdef _MSC_VER
31 #pragma warning(push)
32 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
33 #endif
34 
35 // Forward declarations
36 namespace geos {
37  namespace geom {
38  class Coordinate;
39  class Envelope;
40  }
41  namespace algorithm {
42  class CGAlgorithms;
43  }
44  namespace geomgraph {
45  class DirectedEdge;
46  class Node;
47  }
48 }
49 
50 namespace geos {
51 namespace operation { // geos.operation
52 namespace buffer { // geos.operation.buffer
53 
62 class GEOS_DLL BufferSubgraph {
63 private:
64  RightmostEdgeFinder finder;
65 
66  std::vector<geomgraph::DirectedEdge*> dirEdgeList;
67 
68  std::vector<geomgraph::Node*> nodes;
69 
70  geom::Coordinate *rightMostCoord;
71 
72  geom::Envelope *env;
73 
81  void addReachable(geomgraph::Node *startNode);
82 
84  //
88  void add(geomgraph::Node* node, std::vector<geomgraph::Node*>* nodeStack);
89 
90  void clearVisitedEdges();
91 
98  // <FIX> MD - use iteration & queue rather than recursion, for speed and robustness
99  void computeDepths(geomgraph::DirectedEdge *startEdge);
100 
101  void computeNodeDepth(geomgraph::Node *n);
102 
103  void copySymDepths(geomgraph::DirectedEdge *de);
104 
105  bool contains(std::set<geomgraph::Node*>& nodes, geomgraph::Node *node);
106 
107 public:
108 
109  friend std::ostream& operator<< (std::ostream& os, const BufferSubgraph& bs);
110 
111  BufferSubgraph();
112 
113  ~BufferSubgraph();
114 
115  std::vector<geomgraph::DirectedEdge*>* getDirectedEdges();
116 
117  std::vector<geomgraph::Node*>* getNodes();
118 
122  geom::Coordinate* getRightmostCoordinate();
123 
132  void create(geomgraph::Node *node);
133 
134  void computeDepth(int outsideDepth);
135 
147  void findResultEdges();
148 
163  int compareTo(BufferSubgraph *);
164 
171  geom::Envelope *getEnvelope();
172 };
173 
174 std::ostream& operator<< (std::ostream& os, const BufferSubgraph& bs);
175 
176 // INLINES
177 inline geom::Coordinate*
178 BufferSubgraph::getRightmostCoordinate() {return rightMostCoord;}
179 
180 inline std::vector<geomgraph::Node*>*
181 BufferSubgraph::getNodes() { return &nodes; }
182 
183 inline std::vector<geomgraph::DirectedEdge*>*
184 BufferSubgraph::getDirectedEdges() {
185  return &dirEdgeList;
186 }
187 
188 bool BufferSubgraphGT(BufferSubgraph *first, BufferSubgraph *second);
189 
190 } // namespace geos::operation::buffer
191 } // namespace geos::operation
192 } // namespace geos
193 
194 #ifdef _MSC_VER
195 #pragma warning(pop)
196 #endif
197 
198 #endif // ndef GEOS_OP_BUFFER_BUFFERSUBGRAPH_H
199 
200 /**********************************************************************
201  * $Log$
202  * Revision 1.3 2006/03/15 11:45:06 strk
203  * doxygen comments
204  *
205  * Revision 1.2 2006/03/14 14:16:52 strk
206  * operator<< for BufferSubgraph, more debugging calls
207  *
208  * Revision 1.1 2006/03/14 00:19:40 strk
209  * opBuffer.h split, streamlined headers in some (not all) files in operation/buffer/
210  *
211  **********************************************************************/
212