# Geometry calculations with STL file?

**URL:** <https://discourse.julialang.org/t/geometry-calculations-with-stl-file/48126>\
**Category:** General Usage\
**Tags:** 3d\
**Created:** [October 10, 2020, 8:29pm UTC](https://discourse.julialang.org/t/geometry-calculations-with-stl-file/48126 "2020-10-10T20:29:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [October 10, 2020, 8:29pm UTC](https://discourse.julialang.org/t/geometry-calculations-with-stl-file/48126/1 "2020-10-10T20:29:19Z")

</div>

I have a friend who wants to calculate some things based on geometry described by STL files (basically he’s got an OpenSCAD model, and he wants to do things like calculate the volumes of different things, and then based on assumed density of material calculate weights, or find the center of mass of an assembly, or the distances between various points … etc)

Is there some Julia package that would make reading the STL file and doing various calculations relatively easy?

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [October 10, 2020, 9:54pm UTC](https://discourse.julialang.org/t/geometry-calculations-with-stl-file/48126/2 "2020-10-10T21:54:17Z")

</div>

I believe that tetgen would do the job.

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [October 10, 2020, 10:10pm UTC](https://discourse.julialang.org/t/geometry-calculations-with-stl-file/48126/3 "2020-10-10T22:10:26Z")

</div>

How would that work? I’m not clear on what tetgen enables.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [October 10, 2020, 10:11pm UTC](https://discourse.julialang.org/t/geometry-calculations-with-stl-file/48126/4 "2020-10-10T22:11:53Z")

</div>

Tetgen is supposed to be able to read stl. Then it can generate a tet mesh, which enables the volume calculations your friend was calling for.

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [October 10, 2020, 10:14pm UTC](https://discourse.julialang.org/t/geometry-calculations-with-stl-file/48126/5 "2020-10-10T22:14:40Z")

</div>

> [@PetrKryslUCSD](#):
>
> which enables the volume calculations your friend was calling for.

Is tetgen itself going to be able to do calculations involving volumes and centers of mass etc, or are you suggesting that the output of tetgen is something I can easily read into Julia and perform calculations on? If so, what packages would be useful for that?

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [October 10, 2020, 10:24pm UTC](https://discourse.julialang.org/t/geometry-calculations-with-stl-file/48126/6 "2020-10-10T22:24:42Z")

</div>

FinEtools can perform the moments-of-volume calculations. [https://github.com/PetrKryslUCSD/FinEtoolsAcoustics.jl/blob/9fed81300d79c31553fef828fba46922c943d814/examples/transient/water\_hemis\_td\_struc.jl#L73](https://github.com/PetrKryslUCSD/FinEtoolsAcoustics.jl/blob/9fed81300d79c31553fef828fba46922c943d814/examples/transient/water_hemis_td_struc.jl#L73)
