Skip to content

FOSSILFOrtran Stereo Litography parser

A pure Fortran 2003+ OOP library for reading, writing, and manipulating STL mesh files.

Advanced features

FOSSIL ships a focused subset of the libigl / CGAL geometry-processing toolkit, drawn directly from the standard references in the field:

  • Boolean operations — union, intersection, difference, symmetric difference. Zhou et al. 2016.
  • Self-intersection detection / resolution — Möller tri-tri broad-and-narrow phase, with one-line resolution via the boolean engine.
  • Mesh decimation — quadric edge collapse with normal-flip / non-manifold safety. Garland & Heckbert 1997.
  • Generalized winding number — robust inside/outside on dirty STL, hierarchical Barnes-Hut traversal. Jacobson 2013 + Barill 2018.
  • Marching cubes — isosurface extraction from a regular scalar field, with the SDF→STL roundtrip TBP. Lorensen-Cline 1987 + Bourke tables.
  • Alpha wrapping — guaranteed watertight 2-manifold surrogate from any triangle soup. Portaneri et al. 2022.
  • Isotropic remeshing — uniform-edge re-tessellation with optional sharp-feature preservation. Botsch & Kobbelt 2004.
  • SDF segmentation — per-facet semantic labels via Shape Diameter Function + Gaussian-mixture clustering. Shapira, Shamir & Cohen-Or 2008.
  • Ray-mesh intersection queries — closest hit, all hits, any-hit early-exit. Möller-Trumbore + AABB tree.
  • Cotangent Laplacian + barycentric mass — sparse SPD operator over the surface; foundation for curvature, smoothing, and (when a sparse solver lands) heat-method geodesics. Pinkall & Polthier 1993; Meyer et al. 2003.
  • Per-vertex Gaussian + mean curvature — angle-defect Gaussian and signed mean curvature from H n = (1/2) M⁻¹ L V. Meyer et al. 2003.
  • Mesh smoothing (explicit + Taubin λ|μ) — the right production-grade denoiser for CFD-grade STL. Taubin 1995.

Each algorithm has a dedicated page with a CFD-relevant motivation, a worked Fortran example, and an honest list of known limitations.

Quick start

Load an STL file, print its statistics, and translate it:

fortran
use fossil
use penf, only: R8P
use vecfor, only: ex_R8P

type(surface_stl_object) :: surface
real(R8P)                :: d

! Load (ASCII or binary, auto-detected) and run the full repair pipeline.
call surface%load_from_file(file_name='cube.stl', guess_format=.true.)
call surface%sanitize
print '(A)', surface%statistics()

! Signed distance — SAH BVH + pseudo-normal sign by default.
d = surface%distance(point=2.0_R8P * ex_R8P, is_signed=.true., is_square_root=.true.)
print '(A,ES12.5)', 'signed distance = ', d

! Translate and save.
call surface%translate(x=1.0_R8P, y=2.0_R8P, z=0.5_R8P)
call surface%save_into_file(file_name='cube-moved.stl')

Authors

Stefano Zaghi · stefano.zaghi@cnr.it

Chief Yak Shaver, Accidental Research Scientist, and HPC Farmer — CFD researcher who decided that one more day debugging Fortran build systems was one day too many, opened a Python REPL "just to prototype," and now finds himself maintaining a meshing library, a chimera assembler, an MPI load balancer, and the seven blog tabs he keeps meaning to read.

Claude (Anthropic)

Omniscient Code Oracle & Tireless Rubber Duck — AI pair programmer, responsible for writing the boring parts so humans don't have to.

Contributions are welcome — see the Contributing page.

Copyrights

FOSSIL is distributed under a multi-licensing system:

Use caseLicense
FOSS projectsGPL v3
Closed source / commercialBSD 2-Clause
Closed source / commercialBSD 3-Clause
Closed source / commercialMIT

Anyone interested in using, developing, or contributing to FOSSIL is welcome — pick the license that best fits your needs.