Jump to content

Find biggest Volume ?


Guest Swann

Recommended Posts

Guest Swann

Hi,

I'm sitting couple hours with this and can't find solution.

Basicaly, I have geometry that I put into a loop. In this loop geometry is changing and I measure volume of each change. Since it's a loop on Output I get vol1, vol2, vol3... vol20 etc.

Now I want to find geometry that has biggest volume.

And here is a catch.

You don't know how many volumes you will get on output. So you can't import to VOPS let say 4 volumes, name it Import1, Import2 etc and compare because next time you may have 100 volume attributes.

Any sugestions ?

Thanks in advance

Link to comment
Share on other sites

Guest Swann

I'm thinking about something like sorted list in Python, so I could then easily choose first o r last value, but I don't know how to pack all values into list while they name change.

Number of volumes is the same like number of points on begining of the loop.

So maybe something like:

for i in range(npoints)

import val

pack it into list

and sort.

But I'm just too tired because I can't get it to work.

Edited by SWANN
Link to comment
Share on other sites

For what purpose you need this data? The easy way to compare volumes is Python. From Python SOP you have an access to all volume's properties, like resolution. You can then create attribute and sort prim based on it or what ever.

Link to comment
Share on other sites

Guest Swann

Hey

Yeah, I know that everybody here like to blowUp things, but there are couple of us that also want to build things. ChillOut guys. Noo, no, no. I'm not talking about volume like smoke etc. I just measure geometry volume with measureSOP Volume option.

Take a look into the file. CopySOP has 8 detail attributes and I want to find biggest from those. It will help me find correct skined geometry. All other will be deleted. I cant use isoOffset like in macha example because it gives me the same volume for every geometry, excludind first one that is also not nedded.

Link to comment
Share on other sites

For a quick and hacky way you could just use a Python SOP after the attribpromote that stored the attribute value into a dictionary in hou.session with the copy number as the key. Then all you need to do is find which element in the dictionary has the largest value. Depending on how you are working and possibly varying your number of copies, you might have to take special considerations to make sure your dictionary doesn't have any extra entries caused by decreasing your copy count.

Link to comment
Share on other sites

Like Graham, I might resort to Python here.

But for a non-Python approach, I usually end up copying the the "per-group" attribute value onto each primitive in the group. So, one AttribPromote before the Copy to sum the volume for the current group, then a second one to copy that value back down to all the group's primitives.

Then after the Copy, another AttribPromote to find the maxvolume for all the primitives, then delete all primitives where their volume attribute is not equal to that. This can obviously fall apart in the rare situation that one or more groups have the exact same volume. In that case you'll probably need a second unique per-group primitive attribute and choose the first one that has the volume == maxvolume. (I can give an example of that part if that's unclear).

test_volume_on_prims.hipnc

Edited by johner
Link to comment
Share on other sites

I thought about johner's idea for a non-scripting method as well. I also thought I'd try and take advantage of the ForEach SOP and it's ability to iterate over the previous iterations geometry every time rather than merging the results.

I reconstructed the stamp relying nodes inside the ForEach and then did the volume calculations there. Since the output geometry is then the input geometry I could compare the current iterations volume with a max_volume attr value and see if it the current is now the max. I also keep track of the iteration number that has the max so I could delete all but that group later. Probably not as clean as using more prim attributes but still the correct result with a different method.

max_volume.hipnc

Edited by graham
Link to comment
Share on other sites

Guest Swann

:lol: Just done the same two minutes ago (but fist I done maximum and then in another branch attribCreate with test "if(point("../copy1", $PT, "volPoint", 0) == detail("../toDetail", "del", 0),1, 0)") and deleteSop.

Now I came here to say it solved and what I see . Anyway thanks

Like Graham, I might resort to Python here.

But for a non-Python approach, I usually end up copying the the "per-group" attribute value onto each primitive in the group. So, one AttribPromote before the Copy to sum the volume for the current group, then a second one to copy that value back down to all the group's primitives.

Then after the Copy, another AttribPromote to find the maxvolume for all the primitives, then delete all primitives where their volume attribute is not equal to that. This can obviously fall apart in the rare situation that one or more groups have the exact same volume. In that case you'll probably need a second unique per-group primitive attribute and choose the first one that has the volume == maxvolume. (I can give an example of that part if that's unclear).

Always good to have more than one trick to do the same. Now I try to make python verion. Thanks Graham.

I thought about johner's idea for a non-scripting method as well. I also thought I'd try and take advantage of the ForEach SOP and it's ability to iterate over the previous iterations geometry every time rather than merging the results.

I reconstructed the stamp relying nodes inside the ForEach and then did the volume calculations there. Since the output geometry is then the input geometry I could compare the current iterations volume with a max_volume attr value and see if it the current is now the max. I also keep track of the iteration number that has the max so I could delete all but that group later. Probably not as clean as using more prim attributes but still the correct result with a different method.

Edited by SWANN
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...