示例#1
0
        //------------------------------------------------------------------------------
        public void Create(ref int currDepth, ref int NodeCount)
        {
            currDepth++;
            if (currDepth > _CUROCTDEPTH)
            {
                _CUROCTDEPTH++;
            }

            int         i    = 0;
            double      r    = R / 2.0d;                    // Depth;
            List <bool> used = new List <bool>(_pts.Count); // avoid testing points

            for (int k = 0; k < used.Capacity; k++)
            {
                used.Add(false);
            }
            OctreeLeaf l = null;

            //create the first cells for this branch
            for (i = 0; i < (OctreeNode._OCT); i++)
            {
                Vectors lmin, lmax;
                CalculateNewBBCoord(i, out lmin, out lmax);
                OctreeNode n = null;
                try
                {
                    l = new OctreeLeaf(NodeCount, currDepth, lmin, lmax, ref used, r, this, (eOctPos)i);
                    n = l;
                    NodeCount++;
                    if (l.Split())
                    {
                        OctreeBranch b = new OctreeBranch(l.R, l, this, l.ePos);
                        b.Create(ref currDepth, ref NodeCount);
                        n = b;
                    }
                }

                catch (Exception s)
                {
                    n = null;
                    Debug.WriteLine(s.Message.ToString());
                }
                AddChild(n, i);
            }

            currDepth--;
        }