overlayng/PolygonBuilder.h
/**********************************************************************
*
* 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/Polygon.h>
#include <geos/operation/overlayng/OverlayEdge.h>
#include <geos/operation/overlayng/OverlayEdgeRing.h>
#include <geos/operation/overlayng/MaximalEdgeRing.h>
#include <vector>
// Forward declarations
namespace geos {
namespace geom {
class GeometryFactory;
class Geometry;
class Polygon;
}
namespace operation {
namespace overlayng {
class Edge;
}
}
}
namespace geos { // geos.
namespace operation { // geos.operation
namespace overlayng { // geos.operation.overlayng
class GEOS_DLL PolygonBuilder {
private:
// Members
const geom::GeometryFactory* geometryFactory;
std::vector<OverlayEdgeRing*> shellList;
std::vector<OverlayEdgeRing*> freeHoleList;
bool isEnforcePolygonal;
// Storage
std::vector<std::unique_ptr<OverlayEdgeRing>> vecOER;
std::vector<std::unique_ptr<geom::Polygon>> computePolygons(const std::vector<OverlayEdgeRing*>& shellList) const;
void buildRings(const std::vector<OverlayEdge*>& resultAreaEdges);
static void linkResultAreaEdgesMax(const std::vector<OverlayEdge*>& resultEdges);
static std::vector<std::unique_ptr<MaximalEdgeRing>>
buildMaximalRings(const std::vector<OverlayEdge *> &edges);
std::vector<OverlayEdgeRing*> storeMinimalRings(std::vector<std::unique_ptr<OverlayEdgeRing>>& minRings);
void buildMinimalRings(const std::vector<std::unique_ptr<MaximalEdgeRing>>& maxRings);
void assignShellsAndHoles(const std::vector<OverlayEdgeRing *> &minRings);
static OverlayEdgeRing* findSingleShell(const std::vector<OverlayEdgeRing *> &edgeRings) ;
static void assignHoles(OverlayEdgeRing* shell, const std::vector<OverlayEdgeRing *> &edgeRings);
void placeFreeHoles(const std::vector<OverlayEdgeRing*> & shellList, const std::vector<OverlayEdgeRing*>& freeHoleList) const;
public:
PolygonBuilder(std::vector<OverlayEdge*>& resultAreaEdges, const geom::GeometryFactory* geomFact)
: geometryFactory(geomFact)
, isEnforcePolygonal(true)
{
buildRings(resultAreaEdges);
}
PolygonBuilder(std::vector<OverlayEdge*>& resultAreaEdges, const geom::GeometryFactory* geomFact, bool p_isEnforcePolygonal)
: geometryFactory(geomFact)
, isEnforcePolygonal(p_isEnforcePolygonal)
{
buildRings(resultAreaEdges);
}
PolygonBuilder(const PolygonBuilder&) = delete;
PolygonBuilder& operator=(const PolygonBuilder&) = delete;
// Methods
std::vector<std::unique_ptr<geom::Polygon>> getPolygons() const;
std::vector<OverlayEdgeRing*> getShellRings() const;
};
} // namespace geos.operation.overlayng
} // namespace geos.operation
} // namespace geos
geos::geom::GeometryFactory
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
geos::geom::Polygon
Represents a linear polygon, which may include holes.
Definition Polygon.h:61
geos::operation::overlayng::Edge
Definition operation/overlayng/Edge.h:55
geos::geom
Definition Angle.h:26
geos::operation
Provides classes for implementing operations on geometries.
Definition CleanCoverage.h:34
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38