Cad Simplification#
volmdlr cad simplification module.
- class volmdlr.cad_simplification.AlphaShapeSimplify(volume_model: VolumeModel, name: str = '')#
Bases:
SimplifyCAD simplification using ‘alpha shape’ method.
- simplify(concavity: Literal['Tight', 'Precise', 'Balanced', 'Convex'] = 'Precise', n_sample_points: int = 10000, alpha_multiplier: float | None = None) VolumeModel#
Simplify the mesh using the Alpha Shape algorithm.
https://www.open3d.org/docs/latest/tutorial/Advanced/surface_reconstruction.html
- Parameters:
concavity – Desired fidelity level of the simplified shape. Options: - “Tight”: Very close to original, high detail (alpha × 3.0) - “Precise”: Preserves most features (alpha × 5.0) - “Balanced”: Tradeoff between detail and smoothness (alpha × 11.0) - “Convex”: Simplifies to convex hull (no alpha shape)
n_sample_points – Number of points to sample using Poisson disk sampling. Default is 10000.
alpha_multiplier – Custom alpha multiplier to override preset values. If None, the multiplier is selected based on concavity.
- Returns:
A VolumeModel containing the simplified mesh.
- class volmdlr.cad_simplification.DisplaySimplify(volume_model: VolumeModel, name: str = '')#
Bases:
SimplifyCAD simplification for display purposes. Suitable for CAD with millions of triangles.
The simplification pipeline involves: voxelization, marching cubes, smoothing, projection on the original mesh, second smoothing, and decimation.
- simplify(voxel_size_ratio: int = 128, projection_ratio: float = 0.35, projection_method: Literal['Approximate', 'Exact'] = 'Approximate', smoothing_iterations_1: int = 20, smoothing_iterations_2: int = 20, decimation_ratio: float = 0.3, debug: bool = False) VolumeModel#
Simplify the volume model for display purposes.
- 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.
smoothing_iterations_1 – Number of iterations for the first smoothing step using Taubin smoothing, applied before the projection.
smoothing_iterations_2 – Number of iterations for the second smoothing step using Taubin smoothing, applied after the projection.
decimation_ratio – Proportion of triangles to keep during mesh simplification. Lower values produce coarser meshes.
debug – If True, enables display of intermediate steps for debugging purposes.
- class volmdlr.cad_simplification.Simplify(volume_model: VolumeModel, name: str = '')#
Bases:
DessiaObjectCAD simplification abstract class.
- class volmdlr.cad_simplification.TriangleDecimationSimplify(volume_model: VolumeModel, name: str = '')#
Bases:
SimplifyCAD simplification based on ‘triangle decimation’ method.
- simplify(target_ratio: float, update_rate: int = 5, aggressiveness: float = 7.0, max_iterations: int = 100, verbose: bool = False, lossless: bool = False, threshold_lossless: float = 0.001, alpha: float = 1e-09, k: int = 3, preserve_border: bool = True, preserve_shells: bool = True)#
Simplify the VolumeModel using the ‘triangle decimation’ method, and return it.
To do so, it triangulates each shell of the given volume model and then decimates it at the given target ratio.
Note: threshold = alpha * pow(iteration + k, aggressiveness)
- Parameters:
target_ratio (float) – Target ratio on the number of triangles (between 0 and 1).
update_rate (int) – Number of iterations between each update. If lossless flag is set to True, rate is 1.
aggressiveness (float) – Parameter controlling the growth rate of the threshold at each iteration when lossless is False.
max_iterations (int) – Maximal number of iterations.
verbose (bool) – Control verbosity.
lossless (bool) – Flag for using the lossless simplification method. Sets the update rate to 1.
threshold_lossless (float) – Maximal error after which a vertex is not deleted. Only for lossless method.
alpha (float) – Parameter for controlling the threshold growth.
k (int) – Parameter for controlling the threshold growth.
preserve_border (bool) – Flag for preserving vertices on open border.
preserve_shells (bool) – Argument to chose if you want to keep the shell structures (same number of shells in the returned volume model), or if you want a volume model with only one shell including the entire input geometry.
- Returns:
The decimated VolumeModel.
- Return type:
- class volmdlr.cad_simplification.TripleExtrusionSimplify(volume_model: VolumeModel, name: str = '')#
Bases:
SimplifyCAD simplification based on ‘triple extrusion’ method.
- static extrusion_union_cloud_simplifier(point_cloud3d: PointCloud3D) Solid#
Simplify a point cloud using extrusion and union operations.
- Parameters:
point_cloud3d (PointCloud3D) – The 3D point cloud to simplify.
- Returns:
The simplified shell.
- Return type:
ExtrudedProfile
- simplify() VolumeModel#
Simplify the volume model using the ‘triple extrusion’ method, and return it.
- Returns:
The simplified volume model.
- Return type:
- class volmdlr.cad_simplification.VoxelizationSimplify(volume_model: VolumeModel, name: str = '')#
Bases:
SimplifyCAD simplification using ‘voxelization’ method.
- simplify(voxel_size: float, fill: bool = True) VolumeModel#
Simplify the volume model using the ‘voxelization’ method, and return it.
- Parameters:
voxel_size (float) – The size of the voxels used for simplification.
fill (bool) – Control the filling of the voxelization, default is True.
- Returns:
The simplified volume model.
- Return type: