r/C_Programming • • 26d ago

Review [Code Review] Wrote a fast binary STL inspector/analyzer in C – looking for feedback on memory management and math logic

Hi everyone,

I've been working on a lightweight CLI tool in C called stl-inspector (GitHub repo).

Why I built it:

I got tired of waiting for heavy slicers (PrusaSlicer, Cura, Bambu Studio) just to check basic parameters like watertightness, mesh volume, overhang areas, and bounding dimensions of 3D models.

What it currently does:

  • Parses binary STL headers and triangle arrays
  • Calculates bounding box, volume (tetrahedron method), and surface area
  • Detects overhang areas (default 45°) for 3D printing feasibility
  • Checks if the mesh is watertight
  • Fast build with zero external dependencies (pure C + Makefile)

Where I'd appreciate feedback:

  • Memory safety & cleanup (handling large meshes)
  • Performance of the watertight check (currently O(N^2), looking into spatial hashing / edge mapping)
  • General C code idiomatic style and CLI argument handling

Note: AI was used to help debug directory creation.

Would love to hear your critique or suggestions for improvement.

1 Upvotes

5 comments sorted by

View all comments

•

u/mikeblas 26d ago

Thank you for disclosing your AI use. I have approved your post.

1

u/wajlem 26d ago

Thanks for approving it.

2

u/mikeblas 26d ago

Just doin' my job.

1

u/wajlem 26d ago

Doesn't mean you don't get a thanks.

1

u/mikeblas 26d ago

You're very kind!