A manufacturing quality analysis (QA) tool that quantifies the geometric deviation between a designed CAD part and its physical scan, enabling automated tolerance verification using statistical analysis. Source code: https://github.com/rebcervasio/scan2cad-deviation


What It Does

Upload a reference CAD mesh (STL/OBJ) and the tool:

No scan available? A built-in simulator generates realistic manufacturing noise on top of the CAD geometry so the demo works by itself.

Why This Matters

Every manufactured part deviates from its CAD geometry due to machining tolerances, material deformation, and assembly stresses. Quantifying this deviation (directly from point cloud data) is fundamental to automated QA pipelines, and catching systematic drift (for exemple tool wear) before it produces out-of-spec parts .

Architecture

scan2cad-deviation/
├── app.py                  # Gradio web app (2 tabs)
├── core/
│   ├── simulation.py       # Synthetic scan generator (noise + rigid offset)
│   ├── registration.py     # ICP alignment: custom SVD implementation
│   ├── deviation.py        # Point-to-mesh distance + heatmap
│   └── batch_analysis.py   # Production-run simulation + Hotelling's T² SPC
├── assets/sample_bracket.stl
├── generate_sample.py
└── requirements.txt

Key Technical Highlights

1. ICP Registration (custom SVD implementation)

Each iteration does nearest-neighbor correspondence matching against a sampled mesh surface (scipy cKDTree), computes the optimal rigid transform via SVD (the Kabsch algorithm), applies it, and filters outlier correspondences (>3× median distance) before the next iteration.

2. Point-to-Surface Deviation

Unsigned distance from each scan point to the nearest CAD surface via trimesh's proximity query, then interpolates onto mesh vertices with inverse-distance weighting (k=5 nearest scan points) and exported as a colored GLB for the 3D viewer app.

3. Production-Run Monitoring (Hotelling's T² (multivariate SPC))