Пример #1
0
        public int ClosestPointIndex(Point3d searchPoint)
        {
            ClosestPointSearchData closestPointSearchData = new ClosestPointSearchData(Points);

            Tree.Search(new Sphere(searchPoint, searchPoint.DistanceTo(Points[0] * 1.1)), ClosestPointCallback, closestPointSearchData);
            return(closestPointSearchData.Index);
        }
Пример #2
0
        private static void ClosestPointCallback(object sender, RTreeEventArgs e)
        {
            ClosestPointSearchData closestPointSearchData = e.Tag as ClosestPointSearchData;

            if (closestPointSearchData != null)
            {
                Point3d val          = closestPointSearchData.Points[e.Id];
                Sphere  searchSphere = e.SearchSphere;
                double  num          = val.DistanceTo(searchSphere.Center);
                if (closestPointSearchData.Index == -1 || num < closestPointSearchData.Distance)
                {
                    searchSphere   = e.SearchSphere;
                    e.SearchSphere = new Sphere(searchSphere.Center, num);
                    closestPointSearchData.Distance = num;
                    closestPointSearchData.Index    = e.Id;
                }
            }
        }