capytaine.new_meshes.clean module

capytaine.new_meshes.clean.clean_mesh(vertices: ndarray, faces: List[List[int]], max_iter: int = 5, tol: float = 1e-08) Tuple[ndarray, List[List[int]]][source]

Iteratively clean a mesh by applying geometric simplifications.

Parameters:
  • vertices (numpy.ndarray) – Vertex coordinates of the input mesh.

  • faces (list of list of int) – Face connectivity describing the mesh panels.

  • max_iter (int, default=5) – Maximum number of cleaning iterations to perform.

  • tol (float, default=1e-8) – Tolerance used when merging near-duplicate vertices.

Returns:

The cleaned vertex array and associated face connectivity.

Return type:

tuple[numpy.ndarray, list of list of int]

capytaine.new_meshes.clean.clean_mesh_once(vertices: ndarray, faces: List[List[int]], tol: float = 1e-10) Tuple[ndarray, List[List[int]]][source]

Run a single cleaning pass on the mesh data.

Parameters:
  • vertices (numpy.ndarray) – Vertex coordinates describing the mesh geometry.

  • faces (list of list of int) – Face connectivity with indices referencing vertices.

  • tol (float, default=1e-10) – Tolerance for considering vertices as duplicates.

Returns:

Updated vertices and faces after the cleaning step.

Return type:

tuple[numpy.ndarray, list of list of int]

Raises:

ValueError – If an unsupported face configuration is encountered.

capytaine.new_meshes.clean.merge_near_duplicate_vertices(vertices: ndarray, faces: List[List[int]], tol: float = 1e-08) Tuple[ndarray, List[List[int]]][source]

Merge vertices that are closer than a tolerance.

Parameters:
  • vertices (numpy.ndarray) – Vertex coordinates of shape (n, 3).

  • faces (list of list of int) – Face connectivity referencing the vertices array.

  • tol (float, default=1e-8) – Distance threshold below which vertices are considered duplicates.

Returns:

Deduplicated vertices and remapped faces.

Return type:

tuple[numpy.ndarray, list of list of int]

capytaine.new_meshes.clean.remove_duplicate_faces(faces: List[List[int]]) List[List[int]][source]

Eliminate duplicate faces while preserving order.

Parameters:

faces (list of list of int) – Face connectivity to deduplicate.

Returns:

Face connectivity with duplicates removed.

Return type:

list of list of int

capytaine.new_meshes.clean.remove_duplicate_vertices(vertices: ndarray, faces: List[List[int]]) Tuple[ndarray, List[List[int]]][source]

Remove exactly repeated vertices and remap faces accordingly.

Parameters:
  • vertices (numpy.ndarray) – Vertex coordinates of shape (n, 3).

  • faces (list of list of int) – Face connectivity using indices into vertices.

Returns:

Unique vertices and faces with updated indices.

Return type:

tuple[numpy.ndarray, list of list of int]

capytaine.new_meshes.clean.remove_small_faces(vertices: ndarray, faces: List[int], tol: float = 1e-08) List[int][source]

Remove faces whose area falls below a tolerance.

Parameters:
  • vertices (numpy.ndarray) – Vertex coordinates used to evaluate surface area.

  • faces (list of int) – Face connectivity referencing vertices.

  • tol (float, default=1e-8) – Minimum allowable face area.

Returns:

Faces that exceed the area threshold.

Return type:

list of int

capytaine.new_meshes.clean.remove_unused_vertices(vertices: ndarray, faces: List[List[int]]) Tuple[ndarray, List[List[int]]][source]

Remove vertices that are not referenced by any face.

Parameters:
  • vertices (numpy.ndarray) – Vertex coordinates of shape (n, 3).

  • faces (list of list of int) – Face connectivity using indices into vertices.

Returns:

Reduced vertex array and corresponding face connectivity.

Return type:

tuple[numpy.ndarray, list of list of int]