GEOS 3.9.1
PolygonizeGraph.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2006 Refractions Research Inc.
7 * Copyright (C) 2001-2002 Vivid Solutions Inc.
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************
15 *
16 * Last port: operation/polygonize/PolygonizeGraph.java rev. 974
17 *
18 **********************************************************************/
19
20#ifndef GEOS_OP_POLYGONIZE_POLYGONIZEGRAPH_H
21#define GEOS_OP_POLYGONIZE_POLYGONIZEGRAPH_H
22
23#include <geos/export.h>
24
25#include <geos/planargraph/PlanarGraph.h> // for inheritance
26
27#include <vector>
28
29#ifdef _MSC_VER
30#pragma warning(push)
31#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
32#endif
33
34// Forward declarations
35namespace geos {
36namespace geom {
37class LineString;
38class GeometryFactory;
39class Coordinate;
40class CoordinateSequence;
41}
42namespace planargraph {
43class Node;
44class Edge;
45class DirectedEdge;
46}
47namespace operation {
48namespace polygonize {
49class EdgeRing;
50class PolygonizeDirectedEdge;
51}
52}
53}
54
55namespace geos {
56namespace operation { // geos::operation
57namespace polygonize { // geos::operation::polygonize
58
59
70
71public:
72
78
83 explicit PolygonizeGraph(const geom::GeometryFactory* newFactory);
84
89 ~PolygonizeGraph() override;
90
96 void addEdge(const geom::LineString* line);
97
106 void getEdgeRings(std::vector<EdgeRing*>& edgeRingList);
107
117 void deleteCutEdges(std::vector<const geom::LineString*>& cutLines);
118
131 void deleteDangles(std::vector<const geom::LineString*>& dangleLines);
132
133private:
134
135 static int getDegreeNonDeleted(planargraph::Node* node);
136
137 static int getDegree(planargraph::Node* node, long label);
138
139 const geom::GeometryFactory* factory;
140
141 planargraph::Node* getNode(const geom::Coordinate& pt);
142
143 void computeNextCWEdges();
144
154 void convertMaximalToMinimalEdgeRings(
155 std::vector<PolygonizeDirectedEdge*>& ringEdges);
156
167 static void findIntersectionNodes(PolygonizeDirectedEdge* startDE,
168 long label, std::vector<planargraph::Node*>& intNodes
169 );
170
180 static void findLabeledEdgeRings(
181 std::vector<planargraph::DirectedEdge*>& dirEdgesIn,
182 std::vector<PolygonizeDirectedEdge*>& dirEdgesOut);
183
184 static void label(std::vector<PolygonizeDirectedEdge*>& dirEdges, long label);
185 static void label(std::vector<planargraph::DirectedEdge*>& dirEdges, long label);
186
187 static void computeNextCWEdges(planargraph::Node* node);
188
196 static void computeNextCCWEdges(planargraph::Node* node, long label);
197
198 EdgeRing* findEdgeRing(PolygonizeDirectedEdge* startDE);
199
200 /* Tese are for memory management */
201 std::vector<planargraph::Edge*> newEdges;
202 std::vector<planargraph::DirectedEdge*> newDirEdges;
203 std::vector<planargraph::Node*> newNodes;
204 std::vector<EdgeRing*> newEdgeRings;
205 std::vector<geom::CoordinateSequence*> newCoords;
206};
207
208} // namespace geos::operation::polygonize
209} // namespace geos::operation
210} // namespace geos
211
212#ifdef _MSC_VER
213#pragma warning(pop)
214#endif
215
216#endif // GEOS_OP_POLYGONIZE_POLYGONIZEGRAPH_H
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:68
Definition: LineString.h:68
Represents a ring of PolygonizeDirectedEdge which form a ring of a polygon. The ring may be either an...
Definition: operation/polygonize/EdgeRing.h:66
A DirectedEdge of a PolygonizeGraph, which represents an edge of a polygon formed by the graph.
Definition: PolygonizeDirectedEdge.h:54
Represents a planar graph of edges that can be used to compute a polygonization, and implements the a...
Definition: PolygonizeGraph.h:69
void getEdgeRings(std::vector< EdgeRing * > &edgeRingList)
Computes the EdgeRings formed by the edges in this graph.
static void deleteAllEdges(planargraph::Node *node)
Deletes all edges at a node.
void deleteCutEdges(std::vector< const geom::LineString * > &cutLines)
Finds and removes all cut edges from the graph.
void addEdge(const geom::LineString *line)
Add a LineString forming an edge of the polygon graph.
~PolygonizeGraph() override
Destroy a polygonization graph.
PolygonizeGraph(const geom::GeometryFactory *newFactory)
Create a new polygonization graph.
void deleteDangles(std::vector< const geom::LineString * > &dangleLines)
Marks all edges from the graph which are "dangles".
A node in a PlanarGraph is a location where 0 or more Edge meet.
Definition: planargraph/Node.h:45
Represents a directed graph which is embeddable in a planar surface.
Definition: planargraph/PlanarGraph.h:60
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26