/********************************************************************** * * GEOS - Geometry Engine Open Source * http://geos.osgeo.org * * Copyright (C) 2020 Paul Ramsey * * 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 #include // Forward declarations namespace geos { namespace geom { class Geometry; class GeometryFactory; class Polygon; } } using geos::geom::Geometry; using geos::geom::GeometryFactory; using geos::geom::Polygon; using geos::triangulate::tri::TriList; using geos::triangulate::tri::Tri; namespace geos { namespace triangulate { namespace polygon { /** * Computes the Constrained Delaunay Triangulation of polygons. * The Constrained Delaunay Triangulation of a polygon is a set of triangles * covering the polygon, with the maximum total interior angle over all * possible triangulations. It provides the "best quality" triangulation * of the polygon. *

* Holes are supported. */ class GEOS_DLL ConstrainedDelaunayTriangulator { private: // Members const Geometry* inputGeom; const GeometryFactory* geomFact; std::unique_ptr compute(); static std::unique_ptr toGeometry( const geom::GeometryFactory* geomFact, const std::vector>>& allTriLists); public: /** * Constructs a new triangulator. * * @param p_inputGeom the input geometry */ ConstrainedDelaunayTriangulator(const Geometry* p_inputGeom) : inputGeom(p_inputGeom) , geomFact(p_inputGeom->getFactory()) {} /** * Computes the Constrained Delaunay Triangulation of each polygon element in a geometry. * * @param geom the input geometry * @return a GeometryCollection of the computed triangle polygons */ static std::unique_ptr triangulate(const Geometry* geom); /** * Computes the triangulation of a single polygon * and returns it as a list of {@link geos::triangulate::tri::Tri}s. * * @param poly the input polygon * @param triList the list to store the triangulation in */ static void triangulatePolygon(const Polygon* poly, TriList& triList); }; } // namespace geos.triangulate.polygon } // namespace geos.triangulate } // namespace geos