GEOS 3.11.1
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
34namespace geos {
35namespace geom {
36class Coordinate;
37class Envelope;
38}
39namespace algorithm {
40class CGAlgorithms;
41}
42namespace geomgraph {
43class DirectedEdge;
44class Node;
45}
46}
47
48namespace geos {
49namespace operation { // geos.operation
50namespace buffer { // geos.operation.buffer
51
60class GEOS_DLL BufferSubgraph {
61private:
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
105public:
106
107 friend std::ostream& operator<< (std::ostream& os, const BufferSubgraph& bs);
108
110
112
113 std::vector<geomgraph::DirectedEdge*>* getDirectedEdges();
114
115 std::vector<geomgraph::Node*>* getNodes();
116
120 geom::Coordinate* getRightmostCoordinate();
121
131
132 void computeDepth(int outsideDepth);
133
146
162
170};
171
172std::ostream& operator<< (std::ostream& os, const BufferSubgraph& bs);
173
174// INLINES
175inline geom::Coordinate*
177{
178 return rightMostCoord;
179}
180
181inline std::vector<geomgraph::Node*>*
182BufferSubgraph::getNodes()
183{
184 return &nodes;
185}
186
187inline std::vector<geomgraph::DirectedEdge*>*
188BufferSubgraph::getDirectedEdges()
189{
190 return &dirEdgeList;
191}
192
193bool 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:58
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
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
geom::Envelope * getEnvelope()
Computes the envelope of the edges in the subgraph. The envelope is cached after being computed.
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::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: geos.h:39