Hi. I’m running into an issue when I try to split the curves with multiple intersections
Option 1 using parameters from the closest point method in the split method.
List<Curve> curveLines = new List<Curve>();
for (int i = 0; i < inCurves.Count; i++)
{
List<Double> paramList = new List<Double>();
for (int j = 0; j < eventPoints.Count; j++)
{
//Find number of points on the curve and run loops to split based on the number of points
if (inCurves[i].ClosestPoint(eventPoints[j], out double param) == true)
{
paramList.Add(param);
}
}
var splitC1 = inCurves[i].Split(paramList);
paramList.Clear();
if (splitC1 != null)
{
var splitLines = splitC1.ToList();
for (int k = 0; k < splitLines.Count; k++)
{
var ccx_event = splitLines[k];
curveLines.Add(ccx_event);
}
}
}
inCurves the list of all curves for the intersection.
The left is 4 curves which i used for testing. The right is splits created after doing the above. you can see that the first curve breaks well but the rest breaks into smaller segments as the first. I am clearing the paramsList each time before the next split. Even then it retains the information I think.
Option 2 using parameters from curveIntersection method
for (int i=0;i<inCurves.Count-1;i++)
{
List<Double> eventParams = new List<Double>();
for (int j = i + 1; j < inCurves.Count; j++)
{
var eventsMultC = Rhino.Geometry.Intersect.Intersection.CurveCurve(inCurves[i], inCurves[j], doc.ModelAbsoluteTolerance, doc.ModelAbsoluteTolerance);
//var selfIntersect = Rhino.Geometry.Intersect.Intersection.CurveSelf(inCurves[i], doc.ModelAbsoluteTolerance);
if (eventsMultC != null)
{
for(int k = 0; k < eventsMultC.Count; k++)
{
var ccx_event = eventsMultC[k];
//eventPoints.Add(ccx_event.PointA);
if (ccx_event.PointA.DistanceTo(ccx_event.PointB) > double.Epsilon || ccx_event.PointA.DistanceTo(ccx_event.PointB) < double.Epsilon)
{
eventParams.Add(ccx_event.ParameterA);
}
}
}
}
curveLines.AddRange(inCurves[i].Split(eventParams));
}
the first curve has split but the rest did not split at all in the second option.
Not sure which is the best approach forward and how to get the curve split to work well.