Distance & Clearance#
Compute distances between geometric faces and detect interferences between assembly components. This module provides tools for clearance verification and collision detection.
Note
Prerequisites: Basic understanding of CAD assemblies and meshes
Overview#
The distance module provides two main classes:
Clearance: Calculate the maximum distance between two geometric faces
InterferenceAnalyzer: Detect and measure interferences between meshes
Clearance Analysis#
The Clearance class computes the maximum clearance (distance) between two faces:
from volmdlr.shapes import Face
from volmdlr_tools.distance.clearance import Clearance
# Given two faces
face1, face2 = ... # TopoDS_Face objects
# Compute clearance for multiple face pairs
clearances = Clearance.from_faces(
faces=[face1, face2, face3, face4],
face_indices=[(0, 1), (2, 3)], # Pairs to compare
n_points=10000 # Sampling precision
)
for c in clearances:
print(f"Distance: {c.distance}")
print(f"Point: {c.point}")
print(f"Projection: {c.projection}")
Key Features#
Samples points from mesh surfaces using Poisson disk sampling
Computes normals for accurate distance measurement
Returns the point and projection for maximum distance
Interference Detection#
The InterferenceAnalyzer class detects interferences between meshes and curves:
from volmdlr.display import Mesh3D
from volmdlr_tools.distance.interference import InterferenceAnalyzer
# Create analyzer with environment mesh
environment = Mesh3D(...) # The reference mesh
analyzer = InterferenceAnalyzer(environment)
# Optional: simplify for faster computation
analyzer.set_simplification(
voxel_size_ratio=128,
projection_ratio=0.35
)
# Check interpenetration of multiple meshes
meshes = [mesh1, mesh2, mesh3]
distances = analyzer.interpenetration_distances(
meshes=meshes,
n_sampling_points=2000,
simplification=True
)
for mesh, dist in zip(meshes, distances):
if dist < 0:
print(f"Interpenetration detected: {abs(dist)} mm")
Interpenetration Distances#
Returns signed distances:
Negative: Interpenetration (collision)
Positive: Clearance (no collision)
Magnitude: Severity of interpenetration or clearance
Curvilinear Intersection#
For curve/mesh intersections:
from volmdlr.edges import Edge
# Check how much of a curve intersects the environment
curve = ... # volmdlr Edge
intersecting_distance = analyzer.curvilinear_intersecting_distance(
curve=curve,
n_samples=50
)
print(f"Curve intersects for {intersecting_distance} mm")
See Also#
Kinematics & Determinacy - Kinematic analysis of assemblies
GraphAssembly - Assembly graph structure