示例#1
0
        static void CalledWhenFoundAmount(object sender, RTreeEventArgs e)
        {
            var data = e.Tag as AmountSearchData;

            if (data == null)
            {
                return;
            }

            Point3d found       = data.Points[e.Id];
            double  sq_distance = data.Needle.DistanceToSquared(found);

            if (data.Count < data.AmountTarget || data.Max.Value > sq_distance)
            {
                if (data.Count == data.AmountTarget)
                {
                    data.Remove(data.Max);
                    data.Add(new IndexDistance(e.Id, sq_distance));
                    // shrink the sphere to help improve the test
                    e.SearchSphere = new Sphere(data.Needle, Math.Sqrt(data.Max.Value) + RhinoMath.SqrtEpsilon);
                }
                else
                {
                    data.Add(new IndexDistance(e.Id, sq_distance));
                }
            }
        }
示例#2
0
        private static int CustomSearchCallback(int serial_number, IntPtr idA, IntPtr idB, IntPtr pContext)
        {
            Callbackholder cbh = null;

            for (int i = 0; i < m_callbacks.Count; i++)
            {
                Callbackholder holder = m_callbacks[i];
                if (holder.SerialNumber == serial_number)
                {
                    cbh = holder;
                    break;
                }
            }
            int rc = 1;

            if (cbh != null)
            {
                RTreeEventArgs e = new RTreeEventArgs(idA, idB, pContext);
                e.Tag = cbh.Tag;
                cbh.Callback(cbh.Sender, e);
                if (e.Cancel)
                {
                    rc = 0;
                }
                cbh.Tag = e.Tag;
            }
            return(rc);
        }
示例#3
0
        static void CalledWhenFoundDistance(object sender, RTreeEventArgs e)
        {
            var data = e.Tag as List <int>;

            if (data == null)
            {
                return;
            }

            data.Add(e.Id);
        }
示例#4
0
 void SearchCallback(object sender, RTreeEventArgs e)
 {
   SearchData data = e.Tag as SearchData;
   data.HitCount = data.HitCount + 1;
   Point3f vertex = data.Mesh.Vertices[e.Id];
   double distance = data.Point.DistanceTo(vertex);
   if (data.Index == -1 || data.Distance > distance)
   {
     // shrink the sphere to help improve the test
     e.SearchSphere = new Sphere(data.Point, distance);
     data.Index = e.Id;
     data.Distance = distance;
   }
 }
 private static int CustomSearchCallback(int serial_number, IntPtr idA, IntPtr idB, IntPtr pContext)
 {
   Callbackholder cbh = null;
   for (int i = 0; i < m_callbacks.Count; i++)
   {
     Callbackholder holder = m_callbacks[i];
     if (holder.SerialNumber == serial_number)
     {
       cbh = holder;
       break;
     }
   }
   int rc = 1;
   if (cbh != null)
   {
     RTreeEventArgs e = new RTreeEventArgs(idA, idB, pContext);
     e.Tag = cbh.Tag;
     cbh.Callback(cbh.Sender, e);
     if (e.Cancel)
       rc = 0;
     cbh.Tag = e.Tag;
   }
   return rc;
 }