GEOS  3.14.0dev
overlay/PolygonBuilder.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/overlay/PolygonBuilder.java rev. 1.20 (JTS-1.10)
16  *
17  **********************************************************************/
18 
19 #pragma once
20 
21 #include <geos/export.h>
22 #include <geos/algorithm/locate/IndexedPointInAreaLocator.h>
23 
24 #include <vector>
25 
26 #ifdef _MSC_VER
27 #pragma warning(push)
28 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
29 #endif
30 
31 // Forward declarations
32 namespace geos {
33 namespace geom {
34 class Geometry;
35 class Coordinate;
36 class GeometryFactory;
37 }
38 namespace geomgraph {
39 class EdgeRing;
40 class Node;
41 class PlanarGraph;
42 class DirectedEdge;
43 }
44 namespace operation {
45 namespace overlay {
46 class MaximalEdgeRing;
47 class MinimalEdgeRing;
48 }
49 }
50 }
51 
52 namespace geos {
53 namespace operation { // geos::operation
54 namespace overlay { // geos::operation::overlay
55 
61 class GEOS_DLL PolygonBuilder {
62 public:
63 
64  PolygonBuilder(const geom::GeometryFactory* newGeometryFactory);
65 
66  ~PolygonBuilder();
67 
74  // throw(const TopologyException &)
75 
81  void add(const std::vector<geomgraph::DirectedEdge*>* dirEdges,
82  const std::vector<geomgraph::Node*>* nodes);
83  // throw(const TopologyException &)
84 
85  std::vector<std::unique_ptr<geom::Geometry>> getPolygons();
86 
87 private:
88 
89  const geom::GeometryFactory* geometryFactory;
90 
91  std::vector<geomgraph::EdgeRing*> shellList;
92 
100  void buildMaximalEdgeRings(
101  const std::vector<geomgraph::DirectedEdge*>* dirEdges,
102  std::vector<MaximalEdgeRing*>& maxEdgeRings);
103  // throw(const TopologyException &)
104 
105  void buildMinimalEdgeRings(
106  std::vector<MaximalEdgeRing*>& maxEdgeRings,
107  std::vector<geomgraph::EdgeRing*>& newShellList,
108  std::vector<geomgraph::EdgeRing*>& freeHoleList,
109  std::vector<MaximalEdgeRing*>& edgeRings);
110 
122  geomgraph::EdgeRing* findShell(std::vector<MinimalEdgeRing*>* minEdgeRings);
123 
135  void placePolygonHoles(geomgraph::EdgeRing* shell,
136  std::vector<MinimalEdgeRing*>* minEdgeRings);
137 
145  void sortShellsAndHoles(std::vector<MaximalEdgeRing*>& edgeRings,
146  std::vector<geomgraph::EdgeRing*>& newShellList,
147  std::vector<geomgraph::EdgeRing*>& freeHoleList);
148 
149  struct FastPIPRing {
150  geomgraph::EdgeRing* edgeRing;
152  };
153 
168  void placeFreeHoles(std::vector<FastPIPRing>& newShellList,
169  std::vector<geomgraph::EdgeRing*>& freeHoleList);
170  // throw(const TopologyException&)
171 
190  geomgraph::EdgeRing* findEdgeRingContaining(geomgraph::EdgeRing* testEr,
191  std::vector<FastPIPRing>& newShellList);
192 
193  std::vector<std::unique_ptr<geom::Geometry>> computePolygons(
194  std::vector<geomgraph::EdgeRing*>& newShellList);
195 
201 };
202 
203 } // namespace geos::operation::overlay
204 } // namespace geos::operation
205 } // namespace geos
206 
207 #ifdef _MSC_VER
208 #pragma warning(pop)
209 #endif
210 
Determines the location of Coordinates relative to an areal geometry, using indexing for efficiency.
Definition: IndexedPointInAreaLocator.h:54
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:70
Definition: geomgraph/EdgeRing.h:57
Represents a directed graph which is embeddable in a planar surface.
Definition: geomgraph/PlanarGraph.h:72
Forms Polygon out of a graph of geomgraph::DirectedEdge.
Definition: overlay/PolygonBuilder.h:61
void add(const std::vector< geomgraph::DirectedEdge * > *dirEdges, const std::vector< geomgraph::Node * > *nodes)
void add(geomgraph::PlanarGraph *graph)
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25