Jump to content

Create Polyline From Source To Destination


Recommended Posts

Hello ,

I try to create polyline between "source" points to "destination" points.I created a point group and gave 
selected points a color attribute value @Cd.x= 1.Then unselected points @Cd.x = 0 .I created a poly line and add
 vertex to the points whose srcID = 1.
But I can't specify "destination" vertex to create polyline.Here is vex code I tried to put together.I appreciate if someone
point me to the right direction.I couldn't figure out where I messed up.
Thank in advance
 

int ingroup = inpointgroup(0, "group1", @ptnum);
if(ingroup == 1) 
{@Cd = set(1,0,0);} 
else 
{@Cd = set(0,0,0);}
i@srcID = @Cd.x > 0.5;
i@destID= @Cd.x < 0.5;
i@id = @ptnum;

//int dest_array[] = array(@destID < 1);

int line = addprim(0,"polyline");
if (@srcID == 1){
    addvertex(0,line,@id);
    // addvertex(0,line,0);
} 

 

GeometryCreateTest_02.hiplc

Link to comment
Share on other sites

There is 4 source and 6 destination points. Is it correct? If yes, how do you want to connect them? Each source to all destinations? Source to nearest destination? Source to it's unique destination? The posted snippet can be stripped down and in terms of geometry creation it will be equivalent to:

@id = @ptnum;

int line = addprim(0, "polyline");
if (@group_group1)
{
    addvertex(0, line, @id);
}

At this moment, it creates degenerate primitives only.

Edited by f1480187
Link to comment
Share on other sites

float srchrad = ch("searchradius");
int maxpts = chi("maxpoints");
int points[];

points = pcfind(1, "P", @P, srchrad, maxpts);

foreach(int ptsphere; points)
{
    int prim = addprim(geoself(), "polyline");
    vector newpos = point(1, "P", ptsphere);
    int newpt = addpoint(geoself(), newpos);
    addvertex(geoself(), prim, @ptnum);
    addvertex(geoself(), prim, newpt);
}

Hi,thanks again man.I have worked on these settings and recreated the scene with the help of some entegma tutorial.Now I can create polyline between source and destination points. And now

I am trying to filter the distance.Like if they are too close I don`t want a polyline.

I guess I need to edit this line  ///   int newpt = addpoint(geoself(), newpos);

I want to add point if the distance is more then some number which is controlled by a number on a  slider.I guess I need to use pcfind again .That`s me talking to myself sorry.I stuck in this part

 

GeometryCreateTest_05.hiplc

Link to comment
Share on other sites

You can check if the distance between @P and new position it's large enough.

// Point wrangle.
foreach(int pt; nearpoints(1, @P, ch("max_distance"), chi("max_points")))
{
    vector pos = point(1, "P", pt);
    if (distance(@P, pos) > ch("min_distance"))
    {
        int prim = addprim(0, "polyline");
        addvertex(0, prim, @ptnum);
        addvertex(0, prim, addpoint(0, pos));
    }
}

connect_point_sets.png.398713d20dbe692adad983984fd71298.png

connect_point_sets.hipnc

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