GEOS  3.14.0dev
BufferSubgraph.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2006 Refractions Research Inc.
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU Lesser General Public Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  **********************************************************************
14  *
15  * Last port: operation/buffer/BufferSubgraph.java r378 (JTS-1.12)
16  *
17  **********************************************************************/
18 
19 #pragma once
20 
21 #include <geos/export.h>
22 
23 #include <geos/operation/buffer/RightmostEdgeFinder.h> // for composition
24 
25 #include <vector>
26 #include <set>
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 class Envelope;
38 }
39 namespace algorithm {
40 class CGAlgorithms;
41 }
42 namespace geomgraph {
43 class DirectedEdge;
44 class Node;
45 }
46 }
47 
48 namespace geos {
49 namespace operation { // geos.operation
50 namespace buffer { // geos.operation.buffer
51 
60 class GEOS_DLL BufferSubgraph {
61 private:
62  RightmostEdgeFinder finder;
63 
64  std::vector<geomgraph::DirectedEdge*> dirEdgeList;
65 
66  std::vector<geomgraph::Node*> nodes;
67 
68  geom::Coordinate* rightMostCoord;
69 
70  geom::Envelope* env;
71 
79  void addReachable(geomgraph::Node* startNode);
80 
86  void add(geomgraph::Node* node, std::vector<geomgraph::Node*>* nodeStack);
87 
88  void clearVisitedEdges();
89 
96  // <FIX> MD - use iteration & queue rather than recursion, for speed and robustness
97  void computeDepths(geomgraph::DirectedEdge* startEdge);
98 
99  void computeNodeDepth(geomgraph::Node* n);
100 
101  void copySymDepths(geomgraph::DirectedEdge* de);
102 
103  bool contains(std::set<geomgraph::Node*>& nodes, geomgraph::Node* node);
104 
105 public:
106 
107  friend std::ostream& operator<< (std::ostream& os, const BufferSubgraph& bs);
108 
109  BufferSubgraph();
110 
111  ~BufferSubgraph();
112 
113  std::vector<geomgraph::DirectedEdge*>* getDirectedEdges();
114 
115  std::vector<geomgraph::Node*>* getNodes();
116 
120  geom::Coordinate* getRightmostCoordinate();
121 
130  void create(geomgraph::Node* node);
131 
132  void computeDepth(int outsideDepth);
133 
146 
162 
170 };
171 
172 std::ostream& operator<< (std::ostream& os, const BufferSubgraph& bs);
173 
174 // INLINES
175 inline geom::Coordinate*
177 {
178  return rightMostCoord;
179 }
180 
181 inline std::vector<geomgraph::Node*>*
182 BufferSubgraph::getNodes()
183 {
184  return &nodes;
185 }
186 
187 inline std::vector<geomgraph::DirectedEdge*>*
188 BufferSubgraph::getDirectedEdges()
189 {
190  return &dirEdgeList;
191 }
192 
193 bool BufferSubgraphGT(BufferSubgraph* first, BufferSubgraph* second);
194 
195 } // namespace geos::operation::buffer
196 } // namespace geos::operation
197 } // namespace geos
198 
199 #ifdef _MSC_VER
200 #pragma warning(pop)
201 #endif
202 
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:217
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:59
A directed EdgeEnd.
Definition: geomgraph/DirectedEdge.h:42
The node component of a geometry graph.
Definition: geomgraph/Node.h:59
A connected subset of the graph of DirectedEdge and geomgraph::Node.
Definition: BufferSubgraph.h:60
void findResultEdges()
Find all edges whose depths indicates that they are in the result area(s).
int compareTo(BufferSubgraph *)
BufferSubgraphs are compared on the x-value of their rightmost Coordinate.
void create(geomgraph::Node *node)
Creates the subgraph consisting of all edges reachable from this node.
geom::Envelope * getEnvelope()
Computes the envelope of the edges in the subgraph. The envelope is cached after being computed.
geom::Coordinate * getRightmostCoordinate()
Gets the rightmost coordinate in the edges of the subgraph.
Definition: BufferSubgraph.h:176
A RightmostEdgeFinder find the geomgraph::DirectedEdge in a list which has the highest coordinate,...
Definition: RightmostEdgeFinder.h:46
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25