volmdlr_tools.distance package#
Distance computation tools for clearance and interference detection between geometric entities.
Submodules#
volmdlr_tools.distance.clearance module#
This module defines the Clearance class.
- class volmdlr_tools.distance.clearance.Clearance(faces: tuple[Face], distance: float, point: ndarray, projection: ndarray, name: str = '')#
Bases:
DessiaObjectRepresents the clearance (maximum distance) between two geometric faces in 3D space.
This class provides methods for calculating the maximum clearance between faces and working with geometric data like vertices, normals, and meshes.
- classmethod from_faces(faces: list[Face], face_indices: list[tuple[int, int]], n_points: int = 10000) list[Clearance]#
Create Clearance instances for multiple pairs of faces.
- Parameters:
faces – List of all faces
face_indices – Pairs of indices of the faces to compare
n_points – Precision for sampling points
- Returns:
List of Clearance instances for each pair of faces with calculated distances and points
volmdlr_tools.distance.interference module#
Optimized interference detection for meshes and curves.
- class volmdlr_tools.distance.interference.InterferenceAnalyzer(environment: Mesh3D, name: str = '')#
Bases:
DessiaObjectDetect interferences between meshes and curves with optimized spatial algorithms.
- curvilinear_intersecting_distance(curve: Edge, n_samples: int = 50, bbox_margin: float = 1e-06) float#
Measure curvilinear distance of curve intersecting the environment.
Computes (last_intersection - first_intersection) to quantify the intersection extent. Returns 0.0 if no intersections found. Environment mesh is automatically cropped to sampled curve points for performance.
Optimized with early exit: searches for first intersection from start and last from end, avoiding unnecessary middle segment checks.
- Parameters:
curve – Curve to check for intersections
n_samples – Number of discretization samples
bbox_margin – Margin around segment bbox for mesh cropping
- Returns:
Curvilinear distance of intersection
- interpenetration_distances(meshes: list[Mesh3D], n_sampling_points: int = 2000, simplification: bool = True, return_points: bool = False) list[float] | tuple[list[float], list[Point3D | None]]#
Measure interpenetration severity as minimum signed distance between meshes and environment.
Returns negative values for interpenetration, positive for clearance. The more negative, the deeper the interpenetration. Batch-optimized with optional simplification.
- Parameters:
meshes – List of meshes to measure interpenetration for
n_sampling_points – Number of points sampled per mesh for distance computation
simplification – Use simplified environment mesh (cached) for faster computation
return_points – If True, also return the Point3D locations with minimum distances
- Returns:
List of minimum signed distances, or tuple (distances, points) if return_points is True
- set_simplification(voxel_size_ratio: int = 128, projection_ratio: float = 0.35, projection_method: Literal['Approximate', 'Exact'] = 'Approximate') None#
Compute and cache simplified environment mesh with custom parameters.
- Parameters:
voxel_size_ratio – Determines the voxel resolution by dividing the model’s bounding box size. A higher value means coarser voxelization.
projection_ratio – Maximum distance allowed when projecting vertices back onto the original mesh, expressed as a fraction of the voxel size. 0.0 means no projection.
projection_method – Chooses between ‘Approximate’ (faster) and ‘Exact’ (more accurate) vertex projection methods.
Module contents#
Distance related modules.