Exemplo n.º 1
0
        /**
         * Descend Tree and insert particle.  We're at a cell so
         * we need to move down the tree.
         *
         * @param p    the body to insert into the tree
         * @param xpic
         * @param l
         * @param tree the root of the tree
         * @return the subtree with the new body inserted
         */
        public override Cell loadTree(Body p, MathVector xpic, int l, BTree tree)
        {
            // move down one level
            int  si = Node.oldSubindex(xpic, l);
            Node rt = subp [si];

            if (rt != null)
            {
                subp [si] = rt.loadTree(p, xpic, l >> 1, tree);
            }
            else
            {
                subp [si] = p;
            }

            return(this);
        }
Exemplo n.º 2
0
        /**
         * Descend Tree and insert particle.  We're at a body so we need to
         * create a cell and attach this body to the cell.
         *
         * @param p    the body to insert
         * @param xpic
         * @param l
         * @param tree the root of the data structure
         * @return the subtree with the new body inserted
         */
        public override Cell loadTree(Body p, MathVector xpic, int l, BTree tree)
        {
            // create a Cell
            Cell retval = Cell.makeCell();
            int  si     = subindex(tree, l);

            // attach this Body node to the cell
            retval.subp [si] = this;

            // move down one level
            si = Node.oldSubindex(xpic, l);
            Node rt = retval.subp [si];

            if (rt != null)
            {
                retval.subp [si] = rt.loadTree(p, xpic, l >> 1, tree);
            }
            else
            {
                retval.subp [si] = p;
            }

            return(retval);
        }