Strange points order of Intersection.CurveLine

Hello guys,
Here is my problem:I use “Rhino.Geometry.Intersect.Intersection.CurveLine(Crv,Line,tolerance,overlapTolerance)” to find the intersected points between a curve and a line.if the input line is a single one,the point order is normal.But if a list of lines,the order is abnormal.I do not know how to figure it out.Please help me to get the surposed points order.
Best Regards.
My codes and screenshots are below:
input parameters:Line Line0, Line Line1, Polyline BasePolyline

List<Line> Lines = new List<Line>(){Line0,Line1};
NurbsCurve CrvBP = BasePolyline.ToNurbsCurve();
List < Point3d > LptsA = new List<Point3d>(){};
for(int i = 0;i < Lines.Count;i++)
{
  Line iLine = Lines[i];
  var events = Rhino.Geometry.Intersect.Intersection.CurveLine(CrvBP, iLine, 0.01, 0.01);
  for(int j = 0;j < events.Count;j++)
  {
    var ccx_ets = events[j];
    LptsA.Add(ccx_ets.PointA);
  }
}
A = LptsA;


The fact confused me is that the points order is normal in some cases like below:

Where do you have the Curve Seam on that polygon?

I don’t know this, but my guess is that the “hits” are counted along the curve starting from the seam and ending at the seam. So if the Seam is between 7 and 4 (in the first picture), then pt 4 is closest to the start and then comes 5, 6, 7 which are closer to the end of the curve. Just a wild guess…

In any case, all the numbers are increasing while going in the same direction along the curve.

// Rolf

Hi RIL,
Thank you very much.I test the seam you suggested and the output meets your guess.It is absolutely true that all the numbers are increasing while going in the same direction along the curve.And I use “System.Linq” to sort out the problem.My solutions is below:

List<Line> Lines = new List<Line>(){Line0,Line1};
NurbsCurve CrvBP = BasePolyline.ToNurbsCurve();
List < Point3d > Lpts = new List<Point3d>(){};
for(int i = 0;i < Lines.Count;i++)
{
  List < Point3d > LptsA = new List<Point3d>(){};
  Line iLine = Lines[i];
  var events = Rhino.Geometry.Intersect.Intersection.CurveLine(CrvBP, iLine, 0.01, 0.01);
  for(int j = 0;j < events.Count;j++)
  {
    var ccx_ets = events[j];
    LptsA.Add(ccx_ets.PointA);
    var SortList = LptsA.OrderBy(p => p.Y).ThenBy(p => p.X).ToList();//using System.Linq;
    LptsA = SortList;
  }
  Lpts.AddRange(LptsA);
}
A = Lpts;
1 Like

After defining the slave (in inner Loop)/master (in outer Loop) order … is just a simple matter of sync sorting ccx pts and params (the classic ArraySort thingy, that is). See attached.

Curve_Ccx_SortPtsParams_EntryLevel_V1.gh (133.7 KB)

1 Like

Hi Peter,
I really appreciate your precious advice.Your method is a general solution and totally settles the matter.Thank you very much.

BTW: For BIG N of slave/master curves there’s faster ways to cut the mustard than the ArraySort … but for “reasonable” collections is more or less OK.

BTW: By the book (and common sense) one needs to split the C# in 2 parts: the first does the ccx job(s) and the second does the visualization part: is rather stupid to re-solve everything just for inspecting a slave/master combo. So as an exercise do the right thing.