Hi all, While working on the surface/volume/centroid/length calculation for pipe primitives, I noticed that the calculation of the elements of a pipe based on the control points is repeated ~3 times in the code, and each of the info functions would also need it.
The functions repeating it currently are: * rt_pipe_bbox * rt_pipe_prep * rt_pipe_tess It is likely a good idea to factor that calculation out in a separate function (rt_pipe_tess already has a slight variation of the algorithm, which is likely not a good sign). I first though a kind of iterator object would be the best, which keeps state and returns the elements in order - but there's quite some state and the algorithm for iterating would be a mess (there can be a variable number of pipe elements per control point, and an iterator algorithm which keeps a few states per control point would not be that easy to follow). So I decided to use a function which uses the algorithm in the form as it is currently in the code, and return a list with the calculated elements. I uploaded a first attempt to it, which I discovered to be buggy (the curves have the outer diameter for the next point wrong). After more code-reading, I see that there are already some structures to accommodate linear/bent elements in one list: * id_pipe -> as a common header; * lin_pipe; * bend_pipe; They are prepared by the rt_pipe_prep function and used in ray tracing I suppose (not checked that). So a valid solution would be to re-purpose the rt_pipe_prep function to also generate that structure for all the rest of the pipe element consumers. On further thinking that makes more and more sense - I just wanted to say that some of the pipe element processors don't need all what the lin/bend_pipe structures offer, and by reordering those structures so that the essential fields are in the beginning and the not so much used ones further down, I could define smaller structs to match them (same idea as id_pipe matches the beginning of lin_pipe/bend_pipe). Then a single function could init both kind of lists, fully calculated or simple - but now I think this is overkill and the fully resolved structure can always be calculated. OK, this turned out to be more like a self-talk, but if you have any comments I would be glad to hear them ! Cheers, Csaba ------------------------------------------------------------------------------ Minimize network downtime and maximize team effectiveness. Reduce network management and security costs.Learn how to hire the most talented Cisco Certified professionals. Visit the Employer Resources Portal http://www.cisco.com/web/learning/employer_resources/index.html _______________________________________________ BRL-CAD Developer mailing list brlcad-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/brlcad-devel