Skip to content

SemiQuant/ThinSkin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ThinSkin

PyPI version Python versions License: MIT

ThinSkin analyses an STL mesh and identifies regions where the local geometry is thinner than a specified diameter threshold — handy for checking 3D-print wall thickness, minimum feature sizes, and structurally fragile areas before manufacturing.

How it works

For every vertex in the mesh, ThinSkin estimates the local inscribed diameter using two complementary approaches and takes the minimum of the two as the effective local diameter:

  1. Ray-cast thickness — casts a ray inward along the inverted vertex normal and measures the distance to the nearest opposing surface.
  2. Local curvature radius — derived from the mean curvature at each vertex via the cotangent-weighted Laplacian.

Vertices whose effective diameter falls below the threshold are flagged as narrow.

Installation

pip install thinskin

ThinSkin uses trimesh for ray casting, which relies on rtree (bundled libspatialindex). If you hit native-library issues, install via conda/mamba:

micromamba install -c conda-forge rtree
pip install thinskin

From source

git clone https://github.com/SemiQuant/ThinSkin.git
cd ThinSkin
pip install -e ".[dev]"

Usage

Command line

thinskin model.stl --diameter 2.0

Options:

Option Alias Default Description
--diameter -d 2.0 Minimum diameter threshold (mm).
--output -o <input>_narrow.stl Output STL path.
--version -V Print version and exit.
--help -h Show help and exit.

You can also run it as a module:

python -m thinskin model.stl -d 1.5

Outputs

For an input model.stl, ThinSkin writes (when narrow regions are found):

File Description
model_narrow.stl Mesh containing only the flagged (narrow) faces — overlay in MeshLab.
model_narrow_coloured.obj Full mesh with per-vertex colours (red = narrow, green = OK).
model_narrow_annotated_views.png CAD-style 2×2 multi-view annotated report.

The console also prints mesh stats, a results summary, and a diameter distribution histogram as tables.

Python API

import thinskin

mesh = thinskin.load_mesh("model.stl")
eff_diam, thickness, curv_radius = thinskin.compute_effective_diameter(mesh)

threshold = 2.0
narrow = eff_diam < threshold
print(f"{int(narrow.sum())} narrow vertices below {threshold} mm")

# Render the annotated report
thinskin.generate_annotated_report(mesh, eff_diam, threshold, "model_narrow.stl")

Requirements

  • Python ≥ 3.9
  • click, numpy, scipy, trimesh, rtree, matplotlib

License

MIT © SemiQuant (Jason Limberis)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages