Implement new API function to reduce duplication #3BRL-CAD
Status: ClosedTime to complete: 72 hrs Mentors: SeanTags: implement, code, C, API

This is a follow-on to a new API design task.

This task involves implementing a new function that will measurably help reduce code duplication. You'll need to have already identified a piece of duplicated code that needs to be refactored and/or modified.

This task involves implementing the function per the header doxygen comment specification.  Make sure your implementation is clean, fits well with our existing conventions, and is an efficient implementation that will help reduce code.  Be meticulous.

Submit a patch file with your implementation.

 

Uploaded Work
File name/URLFile sizeDate submitted
bn_polygon_convert.patch10.0 KBJanuary 02 2014 14:25 UTC
bn_polygon_convert.patch9.7 KBJanuary 02 2014 17:02 UTC
Comments
Johannes Schulteon January 2 2014 11:16 UTCTask Claimed

I would like to work on this task.

Gauravjeet Singh on January 2 2014 13:27 UTCTask Assigned

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

Johannes Schulteon January 2 2014 14:25 UTCReady for review

The work on this task is ready to be reviewed.

Daniel Rossberg on January 2 2014 15:06 UTCSome issues

You included a change in the comment for the function bn_polygon_centroid() in your patch.  This doesn't belong here.


Furthermore "declaration = initialization" is a good coding paradigma.  You should use it whenever it's possible (it isn't always the case).  E.g.: point_t **tmp_pts = (point_t **)bu_calloc( ...

Daniel Rossberg on January 2 2014 15:06 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 January 2 2014 17:02 UTCReady for review

The work on this task is ready to be reviewed.

Johannes Schulteon January 2 2014 17:19 UTCFurther notes


  • At the moment, we have the same helper function to sort points ccw 4 times duplicated, spread across librt and libged. While it only has 3 lines (iirc), at least for me it looks like some complicated logic, which isn't obvious, when you want to sort points. As ccw sorted points are required by the other polygon functions, I designed and implemented, I'm not sure, if we can expect that from another caller. So, on the one hand, its just 3 lines, on the other hand, one could loose much time having to work out these 3 lines, just because he wants to know the area of a polygon. What do you think. Is this worth a public function?

  • While looking through table.c, I saw, that a surface area function for bot and a volume function for arbn are still missing. These should be possible to implement, so I would appreciate GCI tasks for those.

Sean on January 2 2014 17:30 UTCTask Closed

Congratulations, this task has been completed successfully.

Johannes Schulteon January 2 2014 21:40 UTC

committed in r59263

Sean on January 3 2014 02:16 UTCduplication

Number of lines is irrelevant.  Any code duplication warrants refactoring.  What's not clear to me (and will need to be addressed in the API doxygen comment at a minimum) is what implications sorting has on a given input data set.


If I gave you N random coplanar points, they could describe a number of valid polygons (that do not self-intersect).  Reordering the points could change not just the orientation, but also the shape of a polygon.


That said, if you literally refactor N identical lines from M places throughout the code, put the N into a function that does exactly the same thing and update the M places, there shouldn't be a problem and the API can state the assumptions implied in those M places where it's used. 


You're welcome to get started on surface area and volume functions for any primitives that still lack them and we'll be sure to create and accept those tasks before the deadline.

Sean on January 3 2014 02:18 UTCBoT task

Note that there is a BoT bounding box function that is still open.  Basically we have two implementations including a new one that doesn't work quite right.  You could investigate or re-implement, whatever is easier.  The task is basically create a bounding box around a mesh (which in theory is just the min/max sum of all vertices):


http://www.google-melange.com/gci/task/view/google/gci2013/5780674933948416


 

Sean on January 3 2014 02:28 UTCbot surface area

There's not a BoT surface area task because you already implemented it last year.  The patch could not be applied because it needed some careful review and testing.  We had other priorities take up all our time, but now that you have commit, you can make it all current.  Last year's work:


http://www.google-melange.com/gci/task/view/google/gci2012/7968224


http://www.google-melange.com/gci/task/view/google/gci2012/8088204


Really glad to see you complete more than three tasks this year.  ;-)


 

Sean on January 3 2014 02:45 UTCfollow-on

A task for BoT mesh surface areas has been added:


http://www.google-melange.com/gci/task/view/google/gci2013/5836041357361152