private static void AddingWellGridIntersectionCellIndices(IPillarGridIntersectionService pgiservice, Grid gridInContext, IPolyline3 pline, List<Index3> ListOfIntersectingGridCells) { IEnumerable<SegmentCellIntersection> intersectionSegments; intersectionSegments = pgiservice.GetPillarGridPolylineIntersections(gridInContext, pline); if (intersectionSegments != null) { foreach (SegmentCellIntersection sci in intersectionSegments) { Index3 indx3 = sci.EnteringCell; if (indx3 != null) { ListOfIntersectingGridCells.Add(indx3); } else { indx3 = sci.LeavingCell; ListOfIntersectingGridCells.Add(indx3); } } } else { IEnumerator<Point3> Point3Enumerator = pline.GetEnumerator(); while (Point3Enumerator.MoveNext()) { Index3 indx3 = gridInContext.GetCellAtPoint(Point3Enumerator.Current); break; } } }