Пример #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);
        }