VoronoiDiagramBuilder.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2012 Excensus LLC.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: triangulate/VoronoiDiagramBuilder.java r524
*
**********************************************************************/
#pragma once
#include <geos/triangulate/quadedge/QuadEdgeSubdivision.h>
#include <geos/geom/Envelope.h> // for composition
#include <memory>
#include <iostream>
#include <unordered_map>
namespace geos {
namespace geom {
class Geometry;
class CoordinateSequence;
class GeometryCollection;
class GeometryFactory;
}
namespace triangulate { //geos.triangulate
class GEOS_DLL VoronoiDiagramBuilder {
public:
VoronoiDiagramBuilder();
~VoronoiDiagramBuilder() = default;
void setSites(const geom::Geometry& geom);
void setSites(const geom::CoordinateSequence& coords);
void setOrdered(bool isOrdered);
void setClipEnvelope(const geom::Envelope* clipEnv);
void setTolerance(double tolerance);
std::unique_ptr<quadedge::QuadEdgeSubdivision> getSubdivision();
std::unique_ptr<geom::GeometryCollection> getDiagram(const geom::GeometryFactory& geomFact);
std::unique_ptr<geom::MultiLineString> getDiagramEdges(const geom::GeometryFactory& geomFact);
void reorderCellsToInput(std::vector<std::unique_ptr<geom::Geometry>> & polys) const;
private:
using CoordinateCellMap = std::unordered_map<geom::CoordinateXY, std::unique_ptr<geom::Geometry>, geom::Coordinate::HashCode>;
std::unique_ptr<geom::CoordinateSequence> siteCoords;
double tolerance;
std::unique_ptr<quadedge::QuadEdgeSubdivision> subdiv;
const geom::Envelope* clipEnv; // externally owned
const geom::Geometry* inputGeom;
const geom::CoordinateSequence* inputSeq;
geom::Envelope diagramEnv;
bool isOrdered;
void create();
std::size_t getNumInputPoints() const;
static std::unique_ptr<geom::GeometryCollection>
clipGeometryCollection(std::vector<std::unique_ptr<geom::Geometry>> & geoms, const geom::Envelope& clipEnv);
static void addCellsForCoordinates(CoordinateCellMap& cellMap, const geom::Geometry& g, std::vector<std::unique_ptr<geom::Geometry>> & polys);
static void addCellsForCoordinates(CoordinateCellMap& cellMap, const geom::CoordinateSequence& g, std::vector<std::unique_ptr<geom::Geometry>> & polys);
};
} //namespace geos.triangulate
} //namespace geos
geos::geom::CoordinateSequence
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
geos::geom::GeometryCollection
Represents a collection of heterogeneous Geometry objects.
Definition GeometryCollection.h:51
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::triangulate::VoronoiDiagramBuilder::setClipEnvelope
void setClipEnvelope(const geom::Envelope *clipEnv)
Sets the envelope to clip the diagram to.
geos::triangulate::VoronoiDiagramBuilder::getDiagramEdges
std::unique_ptr< geom::MultiLineString > getDiagramEdges(const geom::GeometryFactory &geomFact)
Gets the edges of the computed diagram as a geom::MultiLineString, clipped as specified.
geos::triangulate::VoronoiDiagramBuilder::setOrdered
void setOrdered(bool isOrdered)
Specify whether the geometries in the generated diagram should reflect the order of coordinates in th...
geos::triangulate::VoronoiDiagramBuilder::setSites
void setSites(const geom::CoordinateSequence &coords)
Sets the sites (point or vertices) which will be diagrammed from a collection of geom::Coordinates.
geos::triangulate::VoronoiDiagramBuilder::setSites
void setSites(const geom::Geometry &geom)
Sets the sites (point or vertices) which will be diagrammed. All vertices of the given geometry will ...
geos::triangulate::VoronoiDiagramBuilder::getSubdivision
std::unique_ptr< quadedge::QuadEdgeSubdivision > getSubdivision()
Gets the quadedge::QuadEdgeSubdivision which models the computed diagram.
geos::triangulate::VoronoiDiagramBuilder::setTolerance
void setTolerance(double tolerance)
Sets the snapping tolerance which will be used to improved the robustness of the triangulation comput...
geos::triangulate::VoronoiDiagramBuilder::VoronoiDiagramBuilder
VoronoiDiagramBuilder()
Creates a new Voronoi diagram builder.
geos::triangulate::VoronoiDiagramBuilder::getDiagram
std::unique_ptr< geom::GeometryCollection > getDiagram(const geom::GeometryFactory &geomFact)
Gets the faces of the computed diagram as a geom::GeometryCollection of geom::Polygons,...
geos::geom
Definition Angle.h:26
geos::triangulate
Classes to compute Delaunay triangulations.
Definition ConcaveHull.h:32
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38