Jump to content

How to connect points to other points by attributes?


GreenAvoy

Recommended Posts

 Good day everyone!
 For now I can introduce you another, I guess, simple thing.
 it's a fully procedural model and I'm trying to connect all "corner points" to all "wall primitives" and get one close shape with same amount and position of points on this shape.
 Below attached pictures of what I have at the current time and how (as example) that expecting to be at the end.
 Does anybody know how to solve that stage? Any possibility to do that with SOP\VOP nodes, or VEX is essential?
 Thank you :)

Q3.jpg

Q3_2.jpg

Link to comment
Share on other sites

33 minutes ago, Aizatulin said:

Hi,

one possible solution can be connecting the points by neighbourcount (attribute). To avoid connecting the wrong points, all possible distances between all point pairs can be sorted to define a maximum distance from the right value of the sorted array.

 

line_add.hipnc

Thanks for reply, Aizatulin!
 With this code in "attribWrangler" node I have that kind of issues:
 

int n = npoints(0);
int zero[];
int one[];
int c;
// zero ~ isolated points
// one ~ end points (with only one neighbour)
for (int i = 0; i < n; i++)
{
    c = point(0, 'n', i);      
    if (c == 0)
    {
        push(zero, i);
    }
    if (c == 1)
    {
        push(one, i);
    }   
}

n = len(zero);
int l = len(one);
float dist[];
vector V,W;
float d;
// calculate all possible distances between zero and one
for (int i = 0; i < n; i++)
{
    V = point(0, 'P', zero);
    for (int k = 0; k < l; k++)
    {
        W = point(0, 'P', one[k]);  
        d = length(W - V);
        push(dist, d);
    }
}
// sort distances
sort(dist);
// the n * 2 - smallest value should be the maximum distance
float maxdist = dist[n * 2 - 1];

int line;
// now connect all points with a smaller distance than maxdist
// zero <-> one[k], if distance is small enough
for (int i = 0; i < n; i++)
{
    line = addprim(0, “polyline”);  
    V = point(0, 'P', zero);
    for (int k = 0; k < l; k++)
    {    
        W = point(0, 'P', one[k]);        
        d = length(W - V);
        if (d <= maxdist)
        {
            addvertex (0, line, zero);
            addvertex (0, line, one[k]);
        }
    }
}
____________________________________________

Issues:
 Error:       The sub-network output operator failed to cook: /obj/curve_object1/by_dist/attribvop1
 Error:       Vex error: /obj/curve_object1/by_dist/attribvop1/snippet1: Syntax error, unexpected end of file. (46,27)
Failed to resolve VEX code op:/obj/curve_object1/by_dist/attribvop1.

...On top of that I could say that I am absolutely zero in scripting... :c
 Maybe that errors cause I use old version of Houdini (v13) cause of my PC.
:)

Link to comment
Share on other sites

one way of doing this would be,

with the a couple of foreach loop nodes every line would have a start which is 0 and the end, number of points -1 , and then you can use the fuse sop to connect between the points , this is the bear bones of achieving this

or 

search closest point and add a line , fuse them , resample points, file below 

 

joinconnect.hiplc

Edited by pxptpw
Link to comment
Share on other sites

On 11/23/2018 at 2:40 PM, pxptpw said:

one way of doing this would be,

with the a couple of foreach loop nodes every line would have a start which is 0 and the end, number of points -1 , and then you can use the fuse sop to connect between the points , this is the bear bones of achieving this

or 

search closest point and add a line , fuse them , resample points, file below 

 

joinconnect.hiplc

Thanks for reply!
 ...My H v13 cannot open this file, sorry >.<

Link to comment
Share on other sites

  • 3 weeks 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...