-
Notifications
You must be signed in to change notification settings - Fork 347
/
OverlayGraph.h
143 lines (112 loc) · 3.8 KB
/
OverlayGraph.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2020 Paul Ramsey <pramsey@cleverelephant.ca>
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/geom/Coordinate.h>
#include <geos/operation/overlayng/OverlayEdge.h>
#include <geos/operation/overlayng/OverlayLabel.h>
#include <geos/geom/CoordinateSequence.h>
#include <unordered_map>
#include <vector>
#include <deque>
// Forward declarations
namespace geos {
namespace geom {
}
namespace operation {
namespace overlayng {
class Edge;
}
}
}
namespace geos { // geos.
namespace operation { // geos.operation
namespace overlayng { // geos.operation.overlayng
using namespace geos::geom;
/**
* A planar graph of {@link OverlayEdge}, representing
* the topology resulting from an overlay operation.
* Each source {@link Edge} is represented
* by two OverlayEdges, with opposite orientation.
* A single {@link OverlayLabel} is created for each symmetric pair of OverlayEdges.
*
* @author mdavis
*
*/
class GEOS_DLL OverlayGraph {
private:
// Members
std::unordered_map<Coordinate, OverlayEdge*, geom::Coordinate::HashCode> nodeMap;
std::vector<OverlayEdge*> edges;
// Locally store the OverlayEdge and OverlayLabel
std::deque<OverlayEdge> ovEdgeQue;
std::deque<OverlayLabel> ovLabelQue;
std::vector<std::unique_ptr<const geom::CoordinateSequence>> csQue;
// Methods
/**
* Create and add HalfEdge pairs to map and vector containers,
* using local std::deque storage for objects.
*/
OverlayEdge* createEdgePair(const CoordinateSequence* pts, OverlayLabel* lbl);
/**
* Create a single OverlayEdge in local std::deque storage, and return the
* pointer.
*/
OverlayEdge* createOverlayEdge(const CoordinateSequence* pts, OverlayLabel* lbl, bool direction);
void insert(OverlayEdge* e);
public:
/**
* Creates a new graph for a set of noded, labelled {@link Edge}s.
*/
OverlayGraph();
OverlayGraph(const OverlayGraph& g) = delete;
OverlayGraph& operator=(const OverlayGraph& g) = delete;
/**
* Adds an edge between the coordinates orig and dest
* to this graph.
* Only valid edges can be added (in particular, zero-length segments cannot be added)
*
*/
OverlayEdge* addEdge(Edge* edge);
/**
* Gets the set of edges in this graph.
* Only one of each symmetric pair of OverlayEdges is included.
* The opposing edge can be found by using {@link OverlayEdge#sym()}.
*/
std::vector<OverlayEdge*>& getEdges();
/**
* Gets the collection of edges representing the nodes in this graph.
* For each star of edges originating at a node
* a single representative edge is included.
* The other edges around the node can be found by following the next and prev links.
*/
std::vector<OverlayEdge*> getNodeEdges();
/**
* Gets an edge originating at the given node point.
*/
OverlayEdge* getNodeEdge(const Coordinate& nodePt) const;
/**
* Gets the representative edges marked as being in the result area.
*/
std::vector<OverlayEdge*> getResultAreaEdges();
/**
* Create a single OverlayLabel in local std::deque storage
* and return a pointer to the stored object.
*/
OverlayLabel* createOverlayLabel(const Edge* edge);
friend std::ostream& operator<<(std::ostream& os, const OverlayGraph& og);
};
} // namespace geos.operation.overlayng
} // namespace geos.operation
} // namespace geos