Implement a primitive volume function ... for gridded volumes (VOL)BRL-CAD
Status: ClosedTime to complete: 72 hrs Mentors: Sean, Matt S.Tags: C, C++, math, geometry, volume

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.

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. The primitives that do not already have a volume callback are itemized in following.

References:

Code:

  • src/librt/primitives/vol/vol.c
Uploaded Work
File name/URLFile sizeDate submitted
rt_vol_volume.patch1.5 KBDecember 05 2012 07:18 UTC
rt_vol_volume.patch1.5 KBDecember 05 2012 15:14 UTC
rt_vol_volume2.patch1.5 KBDecember 05 2012 18:11 UTC
rt_vol_volume3.patch1.5 KBDecember 06 2012 15:17 UTC
implement_rt_vol_volime.patch1.5 KBDecember 23 2012 07:53 UTC
rt_vol_volume2.patch1.4 KBDecember 25 2012 16:34 UTC
revisedpatch.patch1.4 KBDecember 29 2012 09:45 UTC
fix-null-ptr-behaviour.patch1.5 KBDecember 31 2012 16:21 UTC
change_types.patch1.5 KBJanuary 01 2013 03:03 UTC
Comments
fernozzleon December 5 2012 04:32 UTCTask Claimed

I would like to work on this task.

Sean on December 5 2012 04:50 UTCTask Assigned

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

fernozzleon December 5 2012 07:18 UTCReady for review

The work on this task is ready to be reviewed.

fernozzleon December 5 2012 07:19 UTCMy name

My name is Michael Huang.


Thanks!

Daniel Rossberg on December 5 2012 09:50 UTCThe for-loops should go from 0 to vip-~dim - 1

Values equal to vip-~dim won't crash the program but are unnecessary.

Daniel Rossberg on December 5 2012 09:50 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.

fernozzleon December 5 2012 15:15 UTCReady for review

The work on this task is ready to be reviewed.

fernozzleon December 5 2012 15:16 UTCCorrected

Sorry about that.

Daniel Rossberg on December 5 2012 15:56 UTCRT_ELL_CK_MAGIC

Are you sure?


BTW, do you see any chance to test the function by yourself?

Daniel Rossberg on December 5 2012 15:56 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.

fernozzleon December 5 2012 18:11 UTCReady for review

The work on this task is ready to be reviewed.

fernozzleon December 5 2012 18:16 UTCI have tested it

Sorry about that. This is embarrassing. I've submitted a corrected vesion.


I did manage to test the function, but I later copy/pasted the "boilerplate" vip/CHK_MAGIC lines afterward to better match that of the ellipse volume function, and I forgot to replace "ell" with "vol".

Daniel Rossberg on December 6 2012 08:41 UTCTake the time to check your code again

Now there are again the = in the loop conditions.

Daniel Rossberg on December 6 2012 08:41 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.

fernozzleon December 6 2012 15:17 UTCReady for review

The work on this task is ready to be reviewed.

Daniel Rossberg on December 6 2012 16:08 UTCError during build

[ 27%] Building C object src/librt/CMakeFiles/librt.dir/primitives/vol/vol.c.o


/home/rossberg/Devel/brlcad/src/librt/primitives/vol/vol.c: In function ‘rt_vol_volume’:


/home/rossberg/Devel/brlcad/src/librt/primitives/vol/vol.c:416:5: error: ISO C90 forbids mixed declarations and code [-Werror=edantic]


cc1: all warnings being treated as errors


make[2]: *** [src/librt/CMakeFiles/librt.dir/primitives/vol/vol.c.o] Fehler 1


make[1]: *** [src/librt/CMakeFiles/librt.dir/all] Fehler 2


make: *** [all] Fehler 2

Daniel Rossberg on December 6 2012 16:08 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.

fernozzleon December 7 2012 04:26 UTCClaim Removed

The claim on this task has been removed, someone else can claim it now.

Sean on December 7 2012 04:36 UTCgive up?

It sounds like you were close to compiling cleanly.  The error daniel posted is because you have to only declare variables at the top of a function.


 

Vibhav Panton December 23 2012 03:44 UTCTask Claimed

I would like to work on this task.

Sean on December 23 2012 04:05 UTCTask Assigned

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

Vibhav Panton December 23 2012 07:53 UTCReady for review

The work on this task is ready to be reviewed.

Sean on December 23 2012 14:44 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.

Sean on December 23 2012 14:45 UTCfollow our coding style

Vibhav, it looks like you fixed the warning, but your patch doesn't follow our indentation coding style.  See other places throughout our code for examples or see our HACKING file, but it's 4spc, 1tab, 1tab+4spc, 2tab, etc for indentation levels.


 

Vibhav Panton December 25 2012 16:34 UTCReady for review

The work on this task is ready to be reviewed.

Melange on December 26 2012 04:05 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 December 26 2012 18:32 UTCstill not right..

Vibav, your patch still doesn't follow our indentation coding style.  The latest patch uses all tabs.  If you are familiar with vim or emacs, we provide a local-variables block and modeline at the bottom of every file that will help auto-format the sources.


 

Sean on December 26 2012 18:32 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.

Sean on December 26 2012 18:32 UTCDeadline extended

The deadline of the task has been extended with 2 days and 0 hours.

Vibhav Panton December 28 2012 14:41 UTCCould the deadline be extended

Due to lack of time, I could not work on the patch. Could you please extended the deadline with 2 days?


 

Melange on December 29 2012 05:17 UTCTask Reopened

Melange has detected that the final deadline has passed and it has reopened the task.

Sean on December 29 2012 05:20 UTCyou can reclaim

Vibhav, you (or anyone else) can reclaim the task and get another 72 hours.  The work is basically done, but surprisingly nobody has been able to conform to our simple coding guidelines.  The task is open to anyone again.

Vibhav Panton December 29 2012 09:18 UTCTask Claimed

I would like to work on this task.

Andrei Popescu on December 29 2012 09:21 UTCTask Assigned

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

Vibhav Panton December 29 2012 09:45 UTCReady for review

The work on this task is ready to be reviewed.

Vibhav Panton December 29 2012 09:45 UTCReady for review

I have rewritten the whole implementation using emacs.

Sean on December 29 2012 20:12 UTCusing the right tool

Using the right tool can make all the diference.  The patch formatting looks correct now.


Looking at the code in the patch, have you tried compiling this?  I see a type error on the volume= line that I'd imagine the compiler would have reported.  Also, the function should be well-behaved if the caller passes a NULL pointer.


 

Sean on December 29 2012 20:12 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.

Vibhav Panton December 30 2012 06:11 UTCfunction should be well-behaved if the caller passes a NULL pointer.

Should just a "return" work when a NULL pointer is passed?


 

Sean on December 30 2012 06:14 UTCyep

yep

Vibhav Panton December 30 2012 18:15 UTCReady for review

The work on this task is ready to be reviewed.

Sean on December 31 2012 05:27 UTCdidn't upload

You apparently didn't upload a new version of the patch?

Sean on December 31 2012 05:27 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.

Vibhav Panton December 31 2012 16:21 UTCReady for review

The work on this task is ready to be reviewed.

Daniel Rossberg on December 31 2012 16:58 UTCWhy is the voxel variable a short?

voxel gets its value from an unsigned char and will be casted to a size_t before it will be compared to an uint32_t. There is no short in this pipeline.  How about making it an unsigned char and if necessary casting it to uint32_t for comparing it with an uint32_t?


And how about making voxelcount making a size_t, the type of the sizes and indices of arrays?

Daniel Rossberg on December 31 2012 16:58 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.

Daniel Rossberg on December 31 2012 16:58 UTCDeadline extended

The deadline of the task has been extended with 1 days and 0 hours.

Vibhav Panton January 1 2013 03:03 UTCReady for review

The work on this task is ready to be reviewed.

Sean on January 1 2013 19:14 UTCTask Closed

Congratulations, this task has been completed successfully.

Sean on January 14 2013 14:43 UTCthank you!

As GCI comes to a close, we wanted to take the time to say THANK YOU for all your efforts.  This comment interface closes after GCI is over, so you're encouraged to join our mailing list where we'll be announcing contributions from GCI participants like yourelf over the upcoming months: 


https://lists.sourceforge.net/lists/listinfo/brlcad-news


If you've provided your full name, we'll be sure to credit you in our authorship documentation and you'll see your name in a future announcement.  If you contact us at devs@brlcad.org or via IRC, we'll even let you know when your work is integrated and follow up with updates.  You're welcome and encouraged to contact us any time, especially if you have a question about how to continue participating in Open Source after GCI is over, but even if just to keep in touch.  Take care, be well, and thank you again!