Hello,
I am using curve.Split method(IE t) method to split closed curve into 2 segments… List “t” contains only 2 parameters when i call that method it is giving me 3 splits instead of 2 splits.
It would be a great help if anyone can tell me where I am going wrong.
here is the code. Also find attached Rhino and GH_file
List<double> t = new List<double>();
//Input for this method has to be List for further process.
splitCrvs = SplitBoundaries(bdCrv, paths, out t);
tParams = t;
//////////////////////////////
public List SplitBoundaries(List boundaries, List paths, out List tP)
{
List newBoundary = new List();
List<double> tPara = new List<double>();
for(int i = 0; i < boundaries.Count; i++)
{
Curve cB = boundaries[i];
Curve[] cS = null;
if(cB.IsClosed){
cB.Domain = new Interval(0, 1);
for(int j = 0; j < paths.Count; j++)
{
Curve cP = paths[j];
cP.Domain = new Interval(0, 1);
double t1,t2;
Point3d cP_Start = cP.PointAtStart; Point3d cP_End = cP.PointAtEnd;
cB.ClosestPoint(cP_Start, out t1);
cB.ClosestPoint(cP_End, out t2);
Point3d p1 = cB.PointAt(t1); Point3d p2 = cB.PointAt(t2);
double dist_t1 = cP_Start.DistanceTo(p1);
double dist_t2 = cP_End.DistanceTo(p2);
if(dist_t1 < 0.1 && dist_t2 < 0.1)
{
tPara.Add(t1); tPara.Add(t2);
break;
}
}
cS = cB.Split(tPara);
if(cS != null)
newBoundary.AddRange(cS);
}
}
tP = tPara;
return newBoundary;
}
/////////////////////////////////
SplitMethod.3dm (305.4 KB)
SplitMethod.gh (7.5 KB)