Grasshopper

algorithmic modeling for Rhino

Hi everyone,

I have a bunch of curves. Some of them share start or end point and some don't. 
I would like to join them and get as an output a list that shows for each new generated curve the indices of the input curves before joining. Hope this is clear enough? (see attached image for clarity)

Both the methods in rhinoscriptsyntax and rhinocommon don't offer access to this information. I was wondering if you had to solve the same issue and if you could give any hints on how to proceed.

Of course it is possible to analyze the resulted joined curves against the input curves by taking the midpoint of the latter and running the "IsPointOnCurve" method (or similar approaches). But this is quite slow, inefficient and cumbersome if one compares it to the simple joincurves method that seems to be very fast and from which the information I need could be (I guess) accessed easily.

Any help would be appreciated!

Paul

Views: 1531

Attachments:

Replies to This Discussion

I have exactly this as training material for my people in the practice (the training scope is to find another way faster way (not included in the attached def) to do that by NOT using the Join Curves approach against the Curve List).

BTW: If the Curves are solely lines after joining them try:

Line[] segments = polyline.GetSegments () ...

... in order to find the pieces and then find their indices within the OEM cList (Note: IndexOf may not work if the segment is reversed by the Curve.Join opp, meaning that if returns -1 flip the line in question).

Attachments:

We may be able to add this functionality to the Rhino SDK join function (I think it makes a lot of sense to add it), but in general I'd like some more control over joining operations. For example different ways to resolve conflicts where more than two curves terminate at the same point. Pick the closest ones (assuming tolerances are in effect), join the most tangentially aligned ones, join the most curvature-aligned ones, join the curves that are closest in length, etc. etc. etc.

I suspect I may need to write my own join algorithm for this, which will undoubtedly be somewhat slower than the hyper-optimised C++ one.

@Peter: thanks a lot for your script! that is exactly what I needed. In my case I actually don't have any node with a valency > 2 but that's great to have this option.


@David: thanks for your answer. yes, would be great if at least the index functionality could be added to the SDK. Should I post this as well on Serengeti or is this aspect already considered? The other functionalities that you mentioned seem already very specific, but the more the better :)

Well ... valence > 2 indicates the known fact the the Curve.JoinCurves Method is a bit temperamental. 

See attached V1A  (using shuffle = true > change fate).

Attachments:

BTW: As an exercise add a 2nd option for finding the joined pieces (rather the orthodox one):

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service