Triangle#

class pandamesh.triangle_mesher.DelaunayAlgorithm(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
DIVIDE_AND_CONQUER = ''#
INCREMENTAL = 'i'#
SWEEPLINE = 'F'#
class pandamesh.triangle_mesher.TriangleMesher(gdf: GeoDataFrame)[source]#

Wrapper for the python bindings to Triangle. This class must be initialized with a geopandas GeoDataFrame containing at least one polygon, and a column named "cellsize".

Optionally, multiple polygons with different cell sizes can be included in the geodataframe. These can be used to achieve local mesh remfinement.

Linestrings and points may also be included. The segments of linestrings will be directly forced into the triangulation. Points can also be forced into the triangulation. The cell size values associated with these geometries willl not be used.

Triangle cannot automatically resolve overlapping polygons, or points located exactly on segments. During initialization, the geometries of the geodataframe are checked:

  • Polygons should not have any overlap with each other.

  • Linestrings should not intersect each other.

  • Every linestring should be fully contained by a single polygon; a linestring may not intersect two or more polygons.

  • Linestrings and points should not “touch” / be located on polygon borders.

  • Holes in polygons are fully supported, but they must not contain any linestrings or points.

If such cases are detected, the initialization will error.

For more details on Triangle, see: https://www.cs.cmu.edu/~quake/triangle.defs.html

property conforming_delaunay: bool#

use this switch if you want all triangles in the mesh to be Delaunay, and not just constrained Delaunay; or if you want to ensure that all Voronoi vertices lie within the triangulation.

Type:

Conforming Delaunay

property consistency_check: bool#

Check the consistency of the final mesh. Uses exact arithmetic for checking, even if suppress_exact_arithmetic is set to False. Useful if you suspect Triangle is buggy.

property delaunay_algorithm: DelaunayAlgorithm#

Default algorithm.

DelaunayAlgoritm.INCREMENTAL: Uses the incremental algorithm for Delaunay triangulation, rather than the divide-and-conquer algorithm.

DelaunayAlgoritm.SWEEPLINE: Uses Steven Fortune’s sweepline algorithm for Delaunay triangulation, rather than the divide-and-conquer algorithm.

Type:

DelaunayAlgoritm.DIVIDE_AND_CONQUER

generate() Tuple[ndarray, ndarray][source]#

Generate a mesh of triangles.

Returns:

  • vertices (np.ndarray of floats with shape (n_vertex, 2))

  • triangles (np.ndarray of integers with shape (n_triangle, 3))

generate_ugrid() xugrid.Ugrid2d[source]#
property maximum_steiner_points: int#

Specifies the maximum number of added Steiner points

See: https://www.cs.cmu.edu/~quake/triangle.S.html

property minimum_angle: float#

Minimum allowed angle for any triangle in the mesh.

See: https://www.cs.cmu.edu/~quake/triangle.q.html

property suppress_exact_arithmetic: bool#

Suppresses exact arithmetic.

See: https://www.cs.cmu.edu/~quake/triangle.exact.html