compas_cgal.isolines
¤
Isoline extraction from vertex scalar fields using CGAL.
Functions¤
isolines
¤
isolines(
mesh: Mesh,
scalars: str,
isovalues: list[float] | None = None,
n: int | None = None,
resample: int | bool = True,
smoothing: int = 0,
) -> PolylinesNumpy
Extract isoline polylines from vertex scalar field.
Uses CGAL's refine_mesh_at_isolevel to extract isolines from a scalar field defined at mesh vertices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
:class:`compas.datastructures.Mesh`
|
A triangulated mesh. |
required |
scalars
|
str
|
Name of the vertex attribute containing scalar values. |
required |
isovalues
|
list[float]
|
Explicit isovalue thresholds for isoline extraction. |
None
|
n
|
int
|
Number of evenly spaced isovalues between scalar min and max. The isovalues will exclude the endpoints. |
None
|
resample
|
int or bool
|
Polyline resampling mode. If True (default), adaptively resample segments longer than 2x median length. If int > 1, uniformly subdivide each segment into that many parts. If False or 1, disable. |
True
|
smoothing
|
int
|
Number of Laplacian smoothing iterations to apply to polylines. Default is 0 (no smoothing). |
0
|
Returns:
| Type | Description |
|---|---|
attr:`compas_cgal.types.PolylinesNumpy`
|
List of polyline segments as Nx3 arrays of points. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither or both of |
Examples:
>>> from compas.datastructures import Mesh
>>> from compas.geometry import Sphere
>>> from compas_cgal.geodesics import heat_geodesic_distances
>>> from compas_cgal.isolines import isolines
>>> sphere = Sphere(1.0)
>>> mesh = Mesh.from_shape(sphere, u=32, v=32)
>>> mesh.quads_to_triangles()
>>> vf = mesh.to_vertices_and_faces()
>>> distances = heat_geodesic_distances(vf, [0])
>>> for key, d in zip(mesh.vertices(), distances):
... mesh.vertex_attribute(key, "distance", d)
>>> polylines = isolines(mesh, "distance", n=5)