This small Python project generates 3D helical vessel meshes and can produce "spiral artery" variants where the helix radius changes along revolutions.
spiral.py: Main module. Contains theVesselMeshclass with methods to generate, visualize, and export meshes (OBJ, ASCII STL).helical_vessel.obj/helical_vessel.stl: Example outputs produced by running the script.spiral_artery.obj/spiral_artery.stl: Example outputs produced by running the script.
- Python 3.8+
- numpy
- matplotlib
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install numpy matplotlibpython3 spiral.pyThis writes helical_vessel.obj, helical_vessel.stl, spiral_artery.obj, and spiral_artery.stl to the script's current working directory.
If you run on a headless machine or want to avoid opening GUI windows and related macOS IMK log lines, set the matplotlib backend to Agg or use the environment variable:
MPLBACKEND=Agg python3 spiral.pyOr edit spiral.py near the top and add:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as pltfrom spiral import VesselMesh
# helical (constant radius)
v = VesselMesh(mode='helical')
v.generate_mesh()
v.visualize()
# spiral artery (radius varies along the helix; taper optionally reduces cross-section)
s = VesselMesh(mode='spiral', radius_variation= -2.0, taper_ratio=0.2)
s.generate_mesh()
s.visualize()- Outputs are written to the current working directory by default. Use absolute paths or create an
output/folder for organization. - The
modeparameter acceptshelical(constant radius) orspiral(radius changes along revolutions).radius_variationis the total radial change across the full helix;taper_ratiooptionally reduces the cross-section radius along the helix.
- This project is licensed under the MIT License — see the
LICENSEfile for full terms. If you use this code in research, please cite the project (CITATION.cff) and contact the authors: Leo Liu et al. leo.liu@eng.famu.fsu.edu.