Welcome to od|forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

duveil

Create Polyline From Source To Destination

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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
1 person likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now