-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port locationtech/jts#775, a constrained
delaunay triangulation algorithm. Adds PolygonTriangulator::triangulate() for a naive ear-clipped triangulation, and ConstrainedDelaunayTriangulator::triangulate() for a more aesthetically pleasing polygon triangulation. Access for the CAPI is via GEOSConstrainedDelaunayTriangulation()
- Loading branch information
Showing
42 changed files
with
4,194 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
include/geos/triangulate/polygon/ConstrainedDelaunayTriangulator.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| /********************************************************************** | ||
| * | ||
| * 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 | ||
|
|
||
|
|
||
| // Forward declarations | ||
| namespace geos { | ||
| namespace geom { | ||
| class Geometry; | ||
| class GeometryFactory; | ||
| class Polygon; | ||
| } | ||
| namespace triangulate { | ||
| namespace tri { | ||
| class TriList; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| using geos::geom::Geometry; | ||
| using geos::geom::GeometryFactory; | ||
| using geos::geom::Polygon; | ||
| using geos::triangulate::tri::TriList; | ||
|
|
||
|
|
||
| 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. | ||
| * <p> | ||
| * Holes are supported. | ||
| */ | ||
| class GEOS_DLL ConstrainedDelaunayTriangulator { | ||
|
|
||
| private: | ||
|
|
||
| // Members | ||
| const Geometry* inputGeom; | ||
| const GeometryFactory* geomFact; | ||
|
|
||
| /** | ||
| * Computes the triangulation of a single polygon | ||
| * and returns it as a list of {@link Tri}s. | ||
| * | ||
| * @param poly the input polygon | ||
| * @return list of Tris forming the triangulation | ||
| */ | ||
| void triangulatePolygon(const Polygon* poly, TriList& triList); | ||
|
|
||
| std::unique_ptr<Geometry> compute(); | ||
|
|
||
|
|
||
| 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<Geometry> triangulate(const Geometry* geom); | ||
|
|
||
|
|
||
|
|
||
|
|
||
| }; | ||
|
|
||
|
|
||
|
|
||
| } // namespace geos.triangulate.polygon | ||
| } // namespace geos.triangulate | ||
| } // namespace geos | ||
|
|
Oops, something went wrong.