> On Aug 18, 2017, at 3:44 PM, Mario Meissner <mr.rash....@gmail.com> wrote:
>
> I found a flaw in my current code.
> I considered all points to be valid and projected them to calculate the final
> density. However, not always do we need all points to be projected.
What did you use to calculate the voronoi boundaries? Whatever you used,
that’s essentially what the code needs to do. Instead of projecting points,
you could use the density points to define a voronoi mesh. Then directly
evaluate the ray against the mesh edges. Then you can march through the mesh,
adding up the density contributions for each cell.
In your diagram, that would be akin to deriving the yellow/black/magenta
polygons from the three density points, then doing a line-line intersection
test for the ray against each polygon edge. You would calculate the density at
each start/end segment and add them up accordingly.
> When I BU_LIST_PUSH to the tail of the list, and then BU_LIST_FOR through
> them, why do I get the last element first? I expected PUSH to put the element
> behind all other elements, and then FOR to roll through them from front to
> back, showing me the elements in the order I pushed them.
You’re probably seeing the “list head”. Every bu list is supposed to have a
list head, which is really just a dedicated list element that marks the
end/beginning of the list. That’s because lists can be queues, dequeues,
doubly linked lists, simple arrays, stacks, lists, etc.
You can look around the code for examples (as there are many), but I wouldn’t
worry too much about it. If a simple "struct my_struct *mydata[123]; size_t
mydata_count = 0;” is easier to understand or if you have experience with STL
containers, either would be fine.
> Do I need to use APPEND and keep a pointer to my last added element to get
> the behaviour I need? Why?
If you’re going to use a bu_list, then you do need to keep track of the head
pointer and start with “the next” one whenever iterating forward or iterating
until you reach the head pointer when going backwards, or something to that
effect. It depends on how bu_list is being used. That said, a simple
BU_LIST_PUSH sounds like the prior case, and you just need to start with the
next entry and stop when you get back to the head..
Cheers!
Sean
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel