/** * Recursively builds a binary tree with leaf triangle nodes. */ private void buildTree(int[] ijk, float[] xyz, float[] uvw, float[] rgb) { float[] c = computeCenters(ijk,xyz); BoundingBoxTree bbt = new BoundingBoxTree(MIN_TRI_PER_NODE,c); buildTree(this,bbt.getRoot(),ijk,xyz,uvw,rgb); } private void buildTree(Group parent, BoundingBoxTree.Node bbtNode,
/** * Constructs a bounding box tree for points with specified coordinates. * The (x,y,z) coordinates are packed into the specified array such * that (xyz[0],xyz[1],xyz[2]) are the (x,y,z) coordinates of the * 1st point, (xyz[3],xyz[4],xyz[5]) are the (x,y,z) coordinates of * the 2nd point, and so on. * @param minSize the minimum number of points in a child node. * @param xyz array of packed (x,y,z) coordinates. */ public BoundingBoxTree(int minSize, float[] xyz) { Check.argument(minSize>0,"minSize>0"); _n = xyz.length/3; _i = rampint(0,1,_n); _x = copy(_n,0,3,xyz); _y = copy(_n,1,3,xyz); _z = copy(_n,2,3,xyz); _root = new Node(); _root._bb = new BoundingBox(_x,_y,_z); _root._kmin = 0; _root._kmax = _n-1; split(minSize,_root); _x = _y = _z = null; }
/** * Recursively builds a binary tree with leaf quad nodes. */ private void buildTree(int[] ijkl, float[] xyz, float[] uvw, float[] rgb) { float[] c = computeCenters(ijkl,xyz); BoundingBoxTree bbt = new BoundingBoxTree(MIN_QUAD_PER_NODE,c); buildTree(this,bbt.getRoot(),ijkl,xyz,uvw,rgb); } private void buildTree(Group parent, BoundingBoxTree.Node bbtNode,
/** * Constructs a bounding box tree for points with specified coordinates. * @param minSize the minimum number of points in a child node. * @param x array of x coordinates. * @param y array of y coordinates. * @param z array of z coordinates. */ public BoundingBoxTree(int minSize, float[] x, float[] y, float[] z) { Check.argument(minSize>0,"minSize>0"); Check.argument(x.length==y.length,"x.length==y.length"); Check.argument(x.length==z.length,"x.length==z.length"); _n = x.length; _i = rampint(0,1,_n); _x = copy(x); _y = copy(y); _z = copy(z); _root = new Node(); _root._bb = new BoundingBox(_x,_y,_z); _root._kmin = 0; _root._kmax = _n-1; split(minSize,_root); _x = _y = _z = null; }
public void testRandom() { int minSize = 10; int n = 10000; float[] x = randfloat(n); float[] y = randfloat(n); float[] z = randfloat(n); BoundingBoxTree bbt = new BoundingBoxTree(minSize,x,y,z); BoundingBoxTree.Node root = bbt.getRoot(); test(root,minSize,x,y,z); }
private void buildTree( Group parent, BoundingBoxTree.Node bbtNode, float[] xyz, float[] rgb) { if (bbtNode.isLeaf()) { PointNode pn; if (_size>0.0f) { pn = new PointNode(bbtNode,_size,xyz,rgb); } else { pn = new PointNode(bbtNode,xyz,rgb); } parent.addChild(pn); } else { Group group = new Group(); parent.addChild(group); buildTree(group,bbtNode.getLeft(),xyz,rgb); buildTree(group,bbtNode.getRight(),xyz,rgb); } }