Implement a volume function for triangle meshes (BOT)BRL-CAD
Status: ClosedTime to complete: 72 hrs Mentors: SeanTags:

BRL-CAD provides more than two dozen types of geometry ''primitives'' such as ellipsoids, boxes, and cones. Every primitive is described by a collection of callback functions, for example rt_ell_bbox() returns the bounding box dimensions for an ellipsoid. Wikipedia, Wolfram Mathworld, and various other math sites (and research papers) around the web include the equations for most of our basic primitives while others are a little more difficult to compute.


  • include/raytrace.h: See ft_volume callback defined in rt_functab structure


  • src/librt/primitives/bot/bot.c (implement your function here)
  • src/librt/primitives/table.c (add a reference to your function here)

This task involves writing a new callback function that takes an rt_db_internal object and calculates the volume (units are mm^3). There are numerous examples in our code where we compute volume for other primitives. Submit a patch file the may be applied cleanly.

If you succeed, a follow-on task may be created to enable and validate your function.

Uploaded Work
File name/URLFile sizeDate submitted
tmp_bot_vol-602668554.patch3.4 KBNovember 21 2013 05:29 UTC
bot_vol_2.patch3.3 KBNovember 23 2013 19:42 UTC
Johannes Schulteon November 20 2013 22:51 UTCTask Claimed

I would like to work on this task.

Daniel Rossberg on November 20 2013 23:41 UTCTask Assigned

This task has been assigned to Johannes Schulte. You have 72 hours to complete this task, good luck!

Johannes Schulteon November 21 2013 05:30 UTCReady for review

The work on this task is ready to be reviewed.

Daniel Rossberg on November 21 2013 23:29 UTCinitialize volume

Wouldn't it be a good idea to initialize volume first to 0?  I know other primitives don't initialize it either.

Daniel Rossberg on November 21 2013 23:30 UTCTask Needs More Work

One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.

Johannes Schulteon November 23 2013 19:42 UTCReady for review

The work on this task is ready to be reviewed.

Melange on November 23 2013 23:41 UTCNo more Work can be submitted

Melange has detected that the deadline has passed and no more work can be submitted. The submitted work should be reviewed.

Sean on November 24 2013 04:31 UTCvolume or surface area?


Upon quick inspection, it looks like you calculate total surface area, not volume?  Or is this based on the tetrahedron method where you use the surface normal to add/subtract tetrahedron areas?

I kind of see the latter in your calculations, but that implies we'll need some protections in place for non-closed meshes.  Basically, it just amounts to adding a check that tests whether a mesh is in volume mode (closed) or surface mode with a thickness.

Sean on November 24 2013 04:31 UTCTask Closed

Congratulations, this task has been completed successfully.

Sean on November 24 2013 05:23 UTCauthorship

You've been credited in our authorship documentation that is shipped and installed with every copy of BRL-CAD.  Feel free to join our brlcad-news mailing list to see announcements related to your participation in GCI or to stay involved in BRL-CAD development (feel free to join brlcad-devel too):


Johannes Schulteon November 24 2013 15:49 UTC

The calculation for the volume is based on the surface area of each face :