public static Face GetNearestFace(Point p1, Point p2, RTree tree) { List <Face> faceList = new(); FindFaces(p1, p2, tree, ref faceList); List <Face> IntersectedFaceList = new(); foreach (Face face in faceList) { if (CheckForIntersections.Intersection(p1, p2, face)) { IntersectedFaceList.Add(face); } } Face nearest = GetNearestFromList(p1, IntersectedFaceList); return(nearest); }
private static void FindFaces(Point p1, Point p2, RTree tree, ref List <Face> faceList) { if (!CheckForIntersections.Intersection(p1, p2, tree)) { return; } if (!tree.IsParent) { foreach (Face f in tree.Faces) { faceList.Add(f); } } else { FindFaces(p1, p2, tree.Child1, ref faceList); FindFaces(p1, p2, tree.Child2, ref faceList); } }