GEOS 3.11.1
overlayng/PolygonBuilder.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2020 Paul Ramsey <pramsey@cleverelephant.ca>
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#pragma once
16
17#include <geos/export.h>
18
19#include <geos/geom/Polygon.h>
20#include <geos/operation/overlayng/OverlayEdge.h>
21#include <geos/operation/overlayng/OverlayEdgeRing.h>
22#include <geos/operation/overlayng/MaximalEdgeRing.h>
23
24#include <vector>
25
26
27// Forward declarations
28namespace geos {
29namespace geom {
30class GeometryFactory;
31class Geometry;
32class Polygon;
33}
34namespace operation {
35namespace overlayng {
36class Edge;
37}
38}
39}
40
41namespace geos { // geos.
42namespace operation { // geos.operation
43namespace overlayng { // geos.operation.overlayng
44
45class GEOS_DLL PolygonBuilder {
46
47private:
48
49 // Members
50 const geom::GeometryFactory* geometryFactory;
51 std::vector<OverlayEdgeRing*> shellList;
52 std::vector<OverlayEdgeRing*> freeHoleList;
53 bool isEnforcePolygonal;
54
55 // Storage
56 std::vector<std::unique_ptr<OverlayEdgeRing>> vecOER;
57
58 std::vector<std::unique_ptr<geom::Polygon>> computePolygons(const std::vector<OverlayEdgeRing*>& shellList) const;
59
60 void buildRings(const std::vector<OverlayEdge*>& resultAreaEdges);
61
62 static void linkResultAreaEdgesMax(const std::vector<OverlayEdge*>& resultEdges);
63
67 static std::vector<std::unique_ptr<MaximalEdgeRing>>
68 buildMaximalRings(const std::vector<OverlayEdge *> &edges);
69
75 std::vector<OverlayEdgeRing*> storeMinimalRings(std::vector<std::unique_ptr<OverlayEdgeRing>>& minRings);
76
77 void buildMinimalRings(const std::vector<std::unique_ptr<MaximalEdgeRing>>& maxRings);
78
79 void assignShellsAndHoles(const std::vector<OverlayEdgeRing *> &minRings);
80
90 static OverlayEdgeRing* findSingleShell(const std::vector<OverlayEdgeRing *> &edgeRings) ;
91
102 static void assignHoles(OverlayEdgeRing* shell, const std::vector<OverlayEdgeRing *> &edgeRings);
103
104
117 void placeFreeHoles(const std::vector<OverlayEdgeRing*> & shellList, const std::vector<OverlayEdgeRing*>& freeHoleList) const;
118
119
120
121public:
122
123 PolygonBuilder(std::vector<OverlayEdge*>& resultAreaEdges, const geom::GeometryFactory* geomFact)
124 : geometryFactory(geomFact)
125 , isEnforcePolygonal(true)
126 {
127 buildRings(resultAreaEdges);
128 }
129
130 PolygonBuilder(std::vector<OverlayEdge*>& resultAreaEdges, const geom::GeometryFactory* geomFact, bool p_isEnforcePolygonal)
131 : geometryFactory(geomFact)
132 , isEnforcePolygonal(p_isEnforcePolygonal)
133 {
134 buildRings(resultAreaEdges);
135 }
136
137 PolygonBuilder(const PolygonBuilder&) = delete;
138 PolygonBuilder& operator=(const PolygonBuilder&) = delete;
139
140 // Methods
141 std::vector<std::unique_ptr<geom::Polygon>> getPolygons() const;
142 std::vector<OverlayEdgeRing*> getShellRings() const;
143
144
145};
146
147
148} // namespace geos.operation.overlayng
149} // namespace geos.operation
150} // namespace geos
151
Basic namespace for all GEOS functionalities.
Definition: geos.h:39