Jump to content

Call pcopen() on groups of points dynamically?


Recommended Posts

Hey everyone! First time posting :)

I have a variable number of groups of points, and I want each point to find its nearest neighbor in every group that is not its own. I know pcopen() takes in either an Opinput or a filename, so I was wondering if there is a way to somehow dynamically set inputs to take in groups or if there is a way to export groups of points to a file without manually having to delete non-selected on each group and exporting them individually with the file sop.

Link to comment
Share on other sites

If groups don't overlap, convert groups to name attribute using Name node and then use nearpoint function:

// Point wrangle.

i@near = nearpoint(0, "!" + s@pt_group_name, @P);

// Test.
int prim = addprim(0, "polyline");
addvertex(0, prim, @ptnum);
addvertex(0, prim, @near);

 

crusty_pig.jpgexclude_itself_group_grid.png

Effect is pretty nice on clustered geo.

 

exclude_itself_group.hipnc

Link to comment
Share on other sites

Here is pcfind signature accepting a group. I think it is an equivalent of the nearpoints function, which also return an array.

int [] pcfind(int inputnum, string ptgroup, string Pchannel, vector P, float radius, int maxpoints);

If you really meant pure VEX solution, without converting stuff, use something like this:

// Point wrangle.

string groups[] = detailintrinsic(0, "pointgroups");

foreach (string group; groups)
{
    if (inpointgroup(0, group, @ptnum))
    {
        i@near = pcfind(0, "!" + group, "P", @P, 1e10, 1)[0];

        // Test.
        int prim = addprim(0, "polyline");
        addvertex(0, prim, @ptnum);
        addvertex(0, prim, @near);

        // Exit loop.
        break;
    }
}

It will act similar. Just a bit more code.

 

exclude_itself_group_pcloud.hipnc

Edited by f1480187
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...