a pure Fortran 2003+ OOP library for reading, writing, and manipulating STL mesh files.
| 📂 ASCII & binary STL Auto-detect format with guess_format=.true. — no manual selection needed |
🔧 Surface manipulation Translate, rotate, mirror, resize, clip, and merge STL surfaces |
📐 Geometry analysis Volume, centroid, bounding box, connectivity, and disconnected edges |
🔨 Mesh repair Sanitize and reverse facet normals; reconnect nearby vertices automatically |
|---|---|---|---|
| 📏 Distance & inside queries Signed distance and point-in-polyhedron via solid angle or ray intersection |
⚡ AABB octree Up to 7× faster distance queries over brute force using an 8-child octree |
🏗️ OOP/TDD designed Three types ( file_stl_object, surface_stl_object, facet_object), all functionality as type-bound procedures |
🖥️ fossilizer CLI Companion command-line app for interactive STL analysis and manipulation |
For full documentation (guide, API reference, examples, etc...) see the FOSSIL website.
- Stefano Zaghi — @szaghi
Contributions are welcome — see the Contributing page.
This project is distributed under a multi-licensing system:
- FOSS projects: GPL v3
- Closed source / commercial: BSD 2-Clause, BSD 3-Clause, or MIT
Anyone interested in using, developing, or contributing to this project is welcome — pick the license that best fits your needs.
use fossil
use penf, only: R8P
implicit none
type(file_stl_object) :: file_stl
type(surface_stl_object) :: surface
call file_stl%load_from_file(facet=surface%facet, file_name='cube.stl', guess_format=.true.)
call surface%analize
print '(A)', surface%statistics()
call surface%sanitize_normals
call surface%translate(x=1.0_R8P, y=2.0_R8P, z=0.5_R8P)
call file_stl%save_into_file(facet=surface%facet, file_name='cube-moved.stl')See src/tests/ for more examples including clipping, distance queries, and point-in-polyhedron tests.
Standalone — clone with submodules and build:
git clone https://github.com/szaghi/FOSSIL --recursive && cd FOSSIL
FoBiS.py build -mode static-gnu # build static library
FoBiS.py build -mode tests-gnu && ./scripts/run_tests.sh # build and run testsAs a project dependency — declare FOSSIL in your fobos and run fetch:
[dependencies]
deps_dir = src/third_party
FOSSIL = https://github.com/szaghi/FOSSILFoBiS.py fetch # fetch and build
FoBiS.py fetch --update # re-fetch and rebuildgit clone https://github.com/szaghi/FOSSIL --recursive && cd FOSSIL
cmake -B build && cmake --build build && ctest --test-dir buildAs a CMake subdirectory:
add_subdirectory(FOSSIL)
target_link_libraries(your_target FOSSIL::FOSSIL)
