src/kdtree.cc
branchpyrit
changeset 20 f22952603f29
parent 17 5176ba000a67
child 21 79b516a3803d
equal deleted inserted replaced
19:4e0955fca797 20:f22952603f29
     1 #include <algorithm>
     1 #include <algorithm>
     2 #include <stack>
     2 #include <stack>
     3 
     3 
       
     4 #include "common.h"
     4 #include "kdtree.h"
     5 #include "kdtree.h"
     5 
     6 
     6 class SortableShape
     7 class SortableShape
     7 {
     8 {
     8 public:
     9 public:
   298 	children[1].subdivide(rbb, depth+1);
   299 	children[1].subdivide(rbb, depth+1);
   299 }
   300 }
   300 
   301 
   301 void KdTree::build()
   302 void KdTree::build()
   302 {
   303 {
       
   304 	infomsg("* building kd-tree\n");
   303 	root = new KdNode();
   305 	root = new KdNode();
   304 	ShapeList::iterator shape;
   306 	ShapeList::iterator shape;
   305 	for (shape = shapes.begin(); shape != shapes.end(); shape++)
   307 	for (shape = shapes.begin(); shape != shapes.end(); shape++)
   306 		root->addShape(*shape);
   308 		root->addShape(*shape);
   307 	root->subdivide(bbox, 0);
   309 	root->subdivide(bbox, 0);