GEOS  3.11.0
VoronoiDiagramBuilder.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2012 Excensus LLC.
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU Lesser General Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  **********************************************************************
14  *
15  * Last port: triangulate/VoronoiDiagramBuilder.java r524
16  *
17  **********************************************************************/
18 
19 #pragma once
20 
21 #include <geos/triangulate/quadedge/QuadEdgeSubdivision.h>
22 #include <geos/geom/Envelope.h> // for composition
23 #include <memory>
24 #include <iostream>
25 
26 namespace geos {
27 namespace geom {
28 class Geometry;
29 class CoordinateSequence;
30 class GeometryCollection;
31 class GeometryFactory;
32 }
33 namespace triangulate { //geos.triangulate
34 
45 class GEOS_DLL VoronoiDiagramBuilder {
46 public:
52 
53  ~VoronoiDiagramBuilder() = default;
54 
61  void setSites(const geom::Geometry& geom);
62 
69  void setSites(const geom::CoordinateSequence& coords);
70 
81  void setClipEnvelope(const geom::Envelope* clipEnv);
82 
91  void setTolerance(double tolerance);
92 
98  std::unique_ptr<quadedge::QuadEdgeSubdivision> getSubdivision();
99 
107  std::unique_ptr<geom::GeometryCollection> getDiagram(const geom::GeometryFactory& geomFact);
108 
116  std::unique_ptr<geom::Geometry> getDiagramEdges(const geom::GeometryFactory& geomFact);
117 
118 private:
119 
120  std::unique_ptr<geom::CoordinateSequence> siteCoords;
121  double tolerance;
122  std::unique_ptr<quadedge::QuadEdgeSubdivision> subdiv;
123  const geom::Envelope* clipEnv; // externally owned
124  geom::Envelope diagramEnv;
125 
126  void create();
127 
128  static std::unique_ptr<geom::GeometryCollection>
129  clipGeometryCollection(std::vector<std::unique_ptr<geom::Geometry>> & geoms, const geom::Envelope& clipEnv);
130 
131 };
132 
133 } //namespace geos.triangulate
134 } //namespace geos
135 
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:44
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:66
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
A utility class which creates Voronoi Diagrams from collections of points.
Definition: VoronoiDiagramBuilder.h:45
std::unique_ptr< geom::Geometry > getDiagramEdges(const geom::GeometryFactory &geomFact)
Gets the faces of the computed diagram as a geom::GeometryCollection of geom::LineStrings,...
void setClipEnvelope(const geom::Envelope *clipEnv)
Sets the envelope to clip the diagram to.
void setSites(const geom::CoordinateSequence &coords)
Sets the sites (point or vertices) which will be diagrammed from a collection of geom::Coordinates.
void setSites(const geom::Geometry &geom)
Sets the sites (point or vertices) which will be diagrammed. All vertices of the given geometry will ...
std::unique_ptr< quadedge::QuadEdgeSubdivision > getSubdivision()
Gets the quadedge::QuadEdgeSubdivision which models the computed diagram.
void setTolerance(double tolerance)
Sets the snapping tolerance which will be used to improved the robustness of the triangulation comput...
VoronoiDiagramBuilder()
Creates a new Voronoi diagram builder.
std::unique_ptr< geom::GeometryCollection > getDiagram(const geom::GeometryFactory &geomFact)
Gets the faces of the computed diagram as a geom::GeometryCollection of geom::Polygons,...
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25