Skip to content

compas_cgal.meshing ¤

Functions¤

trimesh_dual ¤

trimesh_dual(
    mesh: VerticesFaces,
    length_factor: float = 1.0,
    number_of_iterations: int = 10,
    angle_radians: float = 0.9,
    scale_factor: float = 1.0,
    fixed_vertices: list[int] = [],
) -> tuple[ndarray, list[list[int]]]

Create a dual mesh from a triangular mesh with variable-length faces.

Parameters:

Name Type Description Default
mesh VerticesFaces

The mesh to create a dual from.

required
angle_radians float

Angle limit in radians for boundary vertices to remove.

0.9
length_factor float

Length factor for remeshing.

1.0
number_of_iterations int

Number of remeshing iterations.

10
scale_factor float

Scale factor for inner vertices.

1.0
fixed_vertices list[int]

List of vertex indices to keep fixed during remeshing.

[]

Returns:

Type Description
tuple

A tuple containing:

  • Remeshed mesh vertices as an Nx3 numpy array.
  • Remeshed mesh faces as an Mx3 numpy array.
  • Dual mesh vertices as an Nx3 numpy array.
  • Variable-length faces as a list of lists of vertex indices.
Notes

This dual mesh implementation includes proper boundary handling by: 1. Creating vertices at face centroids of the primal mesh 2. Creating additional vertices at boundary edge midpoints 3. Creating proper connections for boundary edges

trimesh_remesh ¤

trimesh_remesh(
    mesh: VerticesFaces,
    target_edge_length: float,
    number_of_iterations: int = 10,
    do_project: bool = True,
) -> VerticesFacesNumpy

Remeshing of a triangle mesh.

Parameters:

Name Type Description Default
mesh VerticesFaces

The mesh to remesh.

required
target_edge_length float

The target edge length.

required
number_of_iterations int

Number of remeshing iterations.

10
do_project bool

If True, reproject vertices onto the input surface when they are created or displaced.

True

Returns:

Type Description
VerticesFacesNumpy
Notes

This remeshing function only constrains the edges on the boundary of the mesh. Protecting specific features or edges is not implemented yet.

Examples:

>>> from compas.geometry import Sphere, Polyhedron
>>> from compas_cgal.meshing import mesh_remesh
>>> sphere = Sphere(0.5, point=[1, 1, 1])
>>> mesh = sphere.to_vertices_and_faces(u=32, v=32, triangulated=True)
>>> V, F = mesh_remesh(mesh, 1.0)
>>> shape = Polyhedron(V.tolist(), F.tolist())