static public List <Fiber> GenerateFibers(List <Pin> pinsA, List <Pin> pinsB, Surface srf, string fiberGenerationType) { List <Fiber> fibers = new List <Fiber>(); List <Curve> fiberCrvs = new List <Curve>(); for (int i = 0; i < pinsA.Count; i++) //A { for (int j = 0; j < pinsB.Count; j++) //B { if (fiberGenerationType == "Intersaction") { // intersection Curve[] IntersactionCrv = IntersectionCrv(srf, pinsA[i].Position, pinsB[j].Position); // out IntersectionCrvResult Curve fiberCrv = null; if (IntersactionCrv == null || IntersactionCrv.Length == 0) { break; } else { fiberCrv = IntersactionCrv.Where(o => o != null).ToList().First(); } if ((fiberCrv.PointAtStart.DistanceTo(pinsA[i].Position) < 0.01 && fiberCrv.PointAtEnd.DistanceTo(pinsB[j].Position) < 0.01)) { fiberCrvs.Add(fiberCrv); Fiber ifiber = new Fiber(fiberCrv, -1, "AB", "MAT"); ifiber.StartPinID = pinsA[i].PinID; ifiber.EndPinID = pinsB[j].PinID; // always starts from A to B ifiber.PinA = pinsA[i]; ifiber.PinB = pinsB[j]; //ifiber.StartPin = pinsA[i]; //ifiber.EndPin = pinsB[i]; pinsA[i].VisibleFibers.Add(ifiber); pinsB[j].VisibleFibers.Add(ifiber); fibers.Add(ifiber); } // (fiberCrv.PointAtStart.DistanceTo(pinsB[j].Position) < 0.01 && fiberCrv.PointAtEnd.DistanceTo(pinsA[i].Position) < 0.01)) //{ // } //else // break; } if (fiberGenerationType == "Geodesic") // geodesic { Curve fiberCrv = GeodesicLine(srf, pinsA[i].Position, pinsB[j].Position); fiberCrvs.Add(fiberCrv); Fiber ifiber = new Fiber(fiberCrv, -1, "AB", "MAT"); ifiber.StartPinID = pinsA[i].PinID; ifiber.EndPinID = pinsB[j].PinID; // always starts from A to B ifiber.PinA = pinsA[i]; ifiber.PinB = pinsB[j]; pinsA[i].VisibleFibers.Add(ifiber); pinsB[j].VisibleFibers.Add(ifiber); fibers.Add(ifiber); } } } return(fibers); }