Jump to content

Is it possible to fuse points with the same attribute values?


Recommended Posts

Hi,

If you have points with a point attribute called id, is it possible to fuse points with the same ids? I assume this is only possible by using the Foreach SOP?

I thought Fuse SOP had this functionality?

Thanks :)

Edited by magneto
Link to comment
Share on other sites

it is certainly possible with Fuse SOP

however with a little hack

so you have your desired attribute called attrib

1. save your point positions as some attribute (rest sop or something)

2. use attrib values as P, so your geometry will be in this attrib space if you will with similar attrib values actually closer together in terms of point positions

3. Fuse SOP with snap mode to average points based on threshold, and average all other attributes

4. Fuse SOP with fuse option to fuse snapped points

5. transfer geometry back to original space using rest position, which was already averaged and therefore all points with attrib values within threshold are fused together

EDIT: I used attrib instead of id to make it more generic, but essentially the same process

snap_fuse_points_by_attribute_value_threshold.hip

Edited by anim
  • Like 3
Link to comment
Share on other sites

Thanks anim, pretty amazing trick :) It almost does what I want. Because this solution fuses points with the same attribute value completely, regardless of distance. Is it possible to fuse them still using fuse distance?

Basically if you had 10 points with value 0, and all the rest were different values, these 10 points will be fused if they are close to each other using their actual point positions. Imagine 2 of them are close to each other (0.001), then only those will be fused, leaving you with 9 points.

Would this be possible using the same trick?

Link to comment
Share on other sites

Thanks anim, I just looked at your file. What's the use of snap_by_distance's Snap Distance? Basically I set the vop's Snap Threshold to 0.001, but it still fused many points. Normally at this value, if you use Fuse > Consolidate, you should still have 5000 points.

I will try to create a simpler example using your technique.

Link to comment
Share on other sites

Ok I made a simple example, where there are 2 curves and each point in each curve has an attrib value of their point number. After they are merged, only point 0 and 5 should be merged because they are within threshold but also have the same attrib values.

But after I set the vop threshold to 0 because they are integer, and snap distance to 0.001, it still fuses 3 points within threshold.

Am I using it incorrectly?

fuse_points_by_distance_and_attribute_value_threshold.hip

Link to comment
Share on other sites

attrib in vop expects float attrib, so either change insides of the vop_sop or convert your attrib to float prior to snapping

it is better if it's float to avoid rounding when snap is averaging as well

but maybe it is not applicable for every case, since the more points you average the more the value will be out of threshold

so this works the best if the points snapped by position threshold have either similar values or not

if they are mixture of like 2 very similar and 1 completely different, that group will not be fused

but try AttribCast your attribute to float and you will see if it works for your case

(snap_by_distance Snap Distance is initial averaging of points by distances

vop's Snap Threshold will then be used to either geep such averaged cluster together and fuse or move to original positions)

Link to comment
Share on other sites

Thanks anim, I see what you mean. So this technique relies on thresholds to work? Because I know the value groups I use will be distinct from each other, I am basically assigning each group a different integer value, kind of like having different groups and each action only happens for each group, but doesn't go outside the group.

That's why I was thinking of using Foreach to do this:

[points with value 1] -> Fuse 0.001

[points with value 2] -> Fuse 0.001

...

[points with value n] -> Fuse 0.001

I will try the AttribCast.

Link to comment
Share on other sites

what you are describing now is the very first method I posted here

but if you want that to be limited by maximum distance, this was the hack I could think of, basically first snap everything within that distance, then just keep values within threshold, so essentially if the original value is not too far from average of all snapped points within the distance, but obviously it has it's drawbacks

I will think of something distance based which work with exact values later

meanwhile use foreach for this case

EDIT:

but you can keep value threshold at 0 if in your case you nave distance threshold 0.001

and therefore you are more focusing on 2 cases

1. 2 points with exactly the same value

2. 2 points with different values

3. cases with 3 and more mixed values ( similar and different) are questionable

other thing is that fuse at the end is just meant to fuse snapped points (all the points on the same position) so you may want to decrease it's distance to 0.00001, but in case your original points are on the same positions and you just want to fuse them only if they have the same value, then it's not meant to do that, it will fuse all on the same pos

Edited by anim
  • Like 1
Link to comment
Share on other sites

I have put something together with pointcloud lookups

so essentially

1. save your point positions as some attribute (rest)

2. snap by distance averaging P and attrib

.. so far the same as last method ...

3. do pointcloud lookup among all points within very small radius (== all previously snapped point with actual point)

average rest positions among only points with the values within threshold (0.000001 for exact, let leave houdini same space for error :))

if no point with value within threshold found it will use it's own since at least one point will be sampled ant it will be current point

4. fuse points on exactly the same position

so as long as your original points are not on the same positions, this will work 100% for your case

remember to cast int parms to float before usage

fuse_points_by_distance_and_attribute_value_threshold_v2.hip

  • Like 1
Link to comment
Share on other sites

yes, pretty close is fine while it is more that distance threshold on the last Fuse SOP (which can be as low as it gets, just try to avoid 0)

only exactly the same positions are problem since that last fuse doesn't care about values, whatever is on the same position is fused

so if you need to solve it for the case where points with different values are on exactly the same position from the begining there is a possible workaround, but unless you need it, it would just complicate things a bit

essentially it would be:

store rest1

jitter points very little to minimize the possibility of exactly the same positions

store rest2

do the snapping setup with addition that you need to average rest1 and rest2 in that vop and store averaged rest2 as P (that one was jittered so fuse afterward will not fuse points that were at the same positions originally) and store average rest1 as an attribute (this one contains correct positions prior to jittering)

so now just fuse the points with minimal distance imaginable

then just update P from rest1 to correct the positions, so you may get back the points with different values on the same position

no file this time, just guidelines, but if you need it I can make one later

  • Like 1
Link to comment
Share on other sites

  • 6 years later...

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...