Hi Sean, On Fri, 2013-03-29 at 16:51 -0400, Christopher Sean Morrison wrote: > > * more analysis tools directly built in to the primitives, and ways to > > get them via GUI and scripting (e.g. key points and curves usable in > > constraints applied to the primitives); > > Related to that idea, our GCI students this past winter implemented a ton of > new primitive analysis functions for surface area, volume, and centroid > calculations. They are still awaiting review, validation, and integration. > They're along the same line though, supporting analysis information.
I had a look at the GCI 2012 completed tasks, pipe was not in the list - so I assume it was not done for this primitive. I'll provide pipe volume/surface/centroid + length functions. Already started working on it, and there are a few things I noted: 1) most pipe tasks need to iterate through the pipe segments - the loop code is repeating and should be abstracted out; In Java I would solved that via an iterator, my limited C experience misses this aspect. I looked up "ansi C iterator" and got this nice link: http://pine.cs.yale.edu/pinewiki/C/Iterators After reading that, I can think of 3 different ways to solve this: * creating a macro which takes as parameter the code blocks for processing each segment (in fact 2 code blocks, one for linear and one for bent segment); * separate iterator object holding the iteration state + first/done/next functions, and a for loop around that; * iterator function taking a function pointer (or 2 in our case, for linear and bent) for processing the segments found; My personal preference would be the one with iterator object, but if brl-cad has some other standard way to handle it, please point me to it... 2) all of these operations need to calculate the same geometrical elements of the pipe segments, and the current code has no provisions to share these intermediate results; The iterator object approach could solve that, if that object would be shared between these functions, and would cache the intermediate calculations for the pipe segments. The iterator object needs then to be passed to the info calculation functions, and would calculate the pipe segments only on the first iteration, then just serve them on further iterations. This iterator will then be created by the "analyze" function and given to each of the sub-functions which calculate volume/surface/centroid/length/etc. I will code a proof of concept to have it clear what I mean... 3) analyze has a switch on idb_type, and calls multiple individual functions for each primitive type - not very good for abstracting the analyze capabilities; I'm sure you agree the switch must be replaced by a new rt_..._analyze function in the function table. I will not touch this for now however, as you mentioned there are some patches to this area you need to apply first (the GCI volume/surface/centroid additions) - once that is done, I could go for that too. While writing this mail I actually made my mind which approach I prefer (the iterator object one), so I can now go and write that - but please stop me right now if I to off vs. brl-cad conventions... One more thing: among the GCI tasks I've seen some "Create Solid Model and Diagram" ones for visualizing the parameters of primitive types. I wonder what if those parameters would be implemented directly in the primitive code as functions which return vertexes/curves representing those params, matching the primitive object they are called on ? Then it would be trivial to also draw those together with the object for visualization purposes. They could additionally be used for programmatically positioning other objects in relation to the reference primitive. This presumes BRL-CAD supports non-solid vertex + curve object types, used as helpers in constructing the solid objects - is that so ? Those kind of helper objects are also useful e.g. in animation as trajectory, or placing repeated objects on a path, etc. Let me know what you think about all this... Cheers, Csaba ------------------------------------------------------------------------------ Own the Future-Intel(R) Level Up Game Demo Contest 2013 Rise to greatness in Intel's independent game demo contest. Compete for recognition, cash, and the chance to get your game on Steam. $5K grand prize plus 10 genre and skill prizes. Submit your demo by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2 _______________________________________________ BRL-CAD Developer mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/brlcad-devel
