How to update 2 seperate geometries within one foreach loop

   2694   3   1
User Avatar
Member
4 posts
Joined: Feb. 2023
Offline
Hello,

I've been trying to solve it for a few days now and I am totally stuck. In naturall programming I would simply create a variable to update over each loop, but I can't seem to figure it out on Houdini.

I have 2 pieces of geometries - the point cloud with thousands of points and the fractured box with pieces joined by connectivity. What I need to do is to take each piece of the box and translate it into the location of given point from pointcloud. Sounds simple enough if you want to do just it.
However, I cannot just take any point from the point cloud - as what I am trying to create is actually the tool that procedurally finds a "spare space" to place each piece without overlapping with eaochother, without changing the piece scale or rotation. Copy to points with attribute from piece doesn't do the trick for me.

The way I try to do it - and possibly this is just wrong approach, so feel free to push me in the right direction - is to iterate every piece in for-each-loop, and in each iteration (e.g. iteration 2 for piece ID 2) I take the smallest available point from point cloud and check, if tranforming pieceID=2 to this locations is safe or not. If new location overlap with any of the already moved pieces - it's not safe and I need to search for the next point. I do this check within compile block actually and it's not to difficult. BUT after I find the safe target point I want to remove all of the points that have ID smaller than our safe target point. This means I need to update not only the fracture box geometry, but also the point cloud, and I have no clue how to approach it.

The only alternative way I see for this is to create a detail array attribute withing box geometry with list of all the "already used" points IDs and then just start seach in every other loop based on this detail attribute.

I've already tried to do it all solely in VEX and with for each loops nested in each other. I also tried to update the point cloud after each loop with compile block. I would share screenshots, but NONE of my solution works and maybe it is just better to hear your fresh ideas. I am totally stuck

Thank you in advance, I hope you can understand what I am trying to do.

Attachments:
ToDo.png (25.8 KB)

User Avatar
Member
9376 posts
Joined: July 2007
Offline
I don't completely understand why you'd want to remove all points with smaller id, since another piece may fit in those, therefore I'd assume you want to remove points that overlap the already placed pieces or something like that


but regardless,
as you suggested keeping the list of "used" points as a detail array attribute may be very straightforward way, as you can join them in a string and use as a group to delete from original points within each iteration prior to checking them, so I'd assume that should work

alternatively you can pass as many different geos as you want to next iteration by packing them first and merging into one
and at the beginning splitting and unpacking
this may have some overhead, but you will get clean separate geos with no attribute cross-contamination as it would be the case when keping them unpacked and just using groups
Edited by tamte - Feb. 16, 2023 14:33:37
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
4 posts
Joined: Feb. 2023
Offline
Hello Tomas, thank you so much for your answer.
My post is a much simplified version of what I actually need to do, and the updates I need to make to the points cloud are much more complicated - there would be so many changes in the point cloud that the detail array would by thousands long, that is why I wanted to avoid this solution. And since I need to use the pointcloud after the for loop - hence the quesions.

However, I didn't know about option to pack the objects, I believe this is what I was looking for precisely. I will look into it, thank you so so much

BTW, is there in Houdini some more elegant option to look for available space in target geometry, in order to pack all small objects inside this target geometry as tight as possible? I am thinking of gravity simulation, but when I tried it it didn't give me the result I was going for - but possibly I just don't know how to control it well. Anyhow, is there any other option (like a node or sth) or am I correct to create it on my own?
Edited by gosiaS - Feb. 17, 2023 04:00:19
User Avatar
Member
73 posts
Joined: July 2011
Offline
Don't know if it would be faster than what taste said but another way can be with 2 groups created just before the output and splitting them right a the very top.

But I suggested the following RFE in the following thread that would allow to do this much cleaner and with less overhead.
https://www.sidefx.com/forum/topic/88657/?page=2 [www.sidefx.com]


andreuparri
Multiple geometry streams in sops for loops.

Right now for loops can only accumulate or iterate through a single geometry stream but it would be nice if we could create parallel outputs to work with different elements that need to iterate with same rules.

For every new output in the loop a new input would be created as well that accumulates whatever geo is feed to the corresponding output number.
Edited by andreuparri - Feb. 20, 2023 08:14:41
  • Quick Links