Rhinomergecurves


#1
[merge.rar][1]  has many curves ,and I want merge these curves to one curve.

using rhinomergecurves function.
the biggest gap between curves is less tham 30.but I set the tol to 50,the result curves are also not just one ,but two .
I have to using rhinomergecurves function again to merge the two result curves to one .

why I can’t merge the curves to one curve just one time.


(Menno Deij - van Rijswijk) #2

My “solution” in this case is to increase the tolerance a few times until the curves are joined:

double originalTolerance = 1e-12;
double tol = originalTolerance;
Curve[] curvesToJoin; // this is the collection of curves to join;
Curve[] joined = curvesToJoin;
int n = 0;
while(joined.Length > 1 && n < 6)
{

joined = Curve.JoinCurves(curves, tol);
tol = originalTolerance*Math.Pow(10, n++);

}

if (joined.Length > 1) // uh-oh, the curves are still not joined.

Ok, I know this is C#-like pseudocode, but I hope you understand what I mean. Basically, you increase the tolerance with a factor of 10 in each iteration of the while loop until either the curves are joined or the tolerance has become too large.

I have edited some stuff - it should be OK now.


#3

thanks for you help ,my codes are just like your.
and these can solve the problem.
but i think maybe this is a bug of rhinomergecurves.
and i want to know why this happens?


(Menno Deij - van Rijswijk) #4

I’m not sure, it may have to do with rounding errors and the fact that curves may need to be reversed when joining into a single curve.


(Dale Fugier) #5

Does Rhino’s Join command work to join your curves?

Here are no known issues with the RhinoMergeCurves() SDK function.

Can you post a 3dm file that contains the curves can you cannot join?


#6

dale ,the first article has this 3dm file


(Dale Fugier) #7

I don’t see it on this thread. What am I missing?


#8

dale:
I am sorry,I upload his file before,but I aslo can’t open this link now.

I upload this file again,please help me to see why I can’t merge these curves one time
merge.rar(1010.5 KB)


(Dale Fugier) #9

Clearly, you cannot join all of the curve segments together because not all of the curve segments match end point to end point. The curve segments that do match end-to-end join using the Join command. They also join using the RhinoMergeCurves() SDK function. When using RhinoMergeCurves(), use a joining tolerance of 2.1 * the document’s absolute tolerance.