Skeletonization¶
MASCAF supports three ways to obtain a skeleton.
Option 1: Internal CGAL integration¶
MASCAF includes native CGAL operations:
repair(mesh → mesh)simplify(mesh → mesh)skeletonize(mesh → .polylines.txt)
The C++ project lives in cpp/ and the Python interface lives in
mascaf.cgal.
Windows setup¶
Install Visual Studio or Build Tools for Visual Studio with C++ support.
Install CMake and make sure
cmakeis onPATH.Install vcpkg and set the
VCPKG_ROOTenvironment variable.Open a terminal where your compiler environment is available (e.g., Visual Studio Developer Command Prompt).
Configure the native project from the repo root:
cmake -S cpp -B cpp/build -DCMAKE_TOOLCHAIN_FILE="%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake"
Build the executables:
cmake --build cpp/build --config Release
Confirm that
mesh_repair.exe,mesh_simplify.exe, andmesh_skeletonize.exeexist in the build output.
Linux and macOS setup¶
Install a C++17-capable compiler toolchain.
Install CMake.
Install vcpkg and export
VCPKG_ROOT.Configure from the repo root:
cmake -S cpp -B cpp/build -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
Build:
cmake --build cpp/build --config Release
Confirm
mesh_repair,mesh_simplify, andmesh_skeletonizeexist in the build output.
Python build orchestration¶
MASCAF provides helpers to drive the build from Python:
from mascaf import CGALBuilder, CGALConfig
config = CGALConfig(build_dir="cpp/build")
builder = CGALBuilder(config)
builder.run_configure()
builder.run_build(config="Release")
Running CGAL operations from Python¶
from mascaf import CGALConfig, CGALOperator
config = CGALConfig(build_dir="cpp/build")
ops = CGALOperator(config=config)
ops.skeletonize(
"neuron.obj",
"neuron.polylines.txt",
quality_speed_tradeoff=0.5,
medially_centered_speed_tradeoff=5.0,
)
Shell usage¶
The skeletonization executable accepts:
mesh_skeletonize <input.obj> <output.polylines.txt> [w_H] [w_M]
where w_H is quality_speed_tradeoff and w_M is
medially_centered_speed_tradeoff.
Example:
mesh_skeletonize neuron.obj neuron.polylines.txt 0.5 5.0
Option 2: CGAL Lab¶
The CGAL distribution includes a demo application (CGAL Lab) for interactive skeletonization.
Download CGAL Lab 6.1.
Open CGAL Lab and load your mesh.
Run Operations → Triangulated Surface Mesh Skeletonization → Mean Curvature Skeleton (Advanced).
Export the result as a polylines text file.
Option 3: Any compatible tool¶
Any external tool that produces a MASCAF-compatible polylines file works:
N x1 y1 z1 x2 y2 z2 ... xN yN zN
One line per branch, starting with the number of points on that line.
Troubleshooting¶
Executable not found — Build the native
cpp/project first and confirm the configuration (Release/Debug) matches what you built.VCPKG_ROOT is not set — Export the environment variable before invoking CMake or
CGALBuilder.CMake cannot find CGAL or Eigen — Confirm you configured with the vcpkg toolchain file and that
cpp/vcpkg.jsondependencies were resolved.Skeletonization fails on the mesh — The CGAL path expects a closed triangle mesh.
You already have a skeleton — Skip CGAL entirely and load with
from_txt().