include/kdtree.h
branchpyrit
changeset 24 d0d76e8a5203
parent 22 76b7bd51d64a
child 34 28f6e8b9d5d1
equal deleted inserted replaced
23:7e258561a690 24:d0d76e8a5203
     1 #ifndef KDTREE_H
     1 #ifndef KDTREE_H
     2 #define KDTREE_H
     2 #define KDTREE_H
     3 
     3 
     4 #include <vector>
       
     5 #include <iostream>
     4 #include <iostream>
     6 #include <fstream>
     5 #include <fstream>
     7 
     6 
       
     7 #include "container.h"
       
     8 #include "vector.h"
     8 #include "scene.h"
     9 #include "scene.h"
     9 
    10 
    10 using namespace std;
    11 using namespace std;
    11 
       
    12 class ShapeList: public vector<Shape*>
       
    13 {
       
    14 };
       
    15 
       
    16 class Container
       
    17 {
       
    18 protected:
       
    19 	BBox bbox;
       
    20 public:
       
    21 	ShapeList shapes;
       
    22 	Container(): bbox(), shapes() {};
       
    23 	virtual ~Container() {};
       
    24 	virtual void addShape(Shape* aShape);
       
    25 	//void addShapeNoExtend(Shape* aShape) { shapes.push_back(aShape); };
       
    26 	virtual Shape *nearest_intersection(const Shape *origin_shape, const Ray &ray,
       
    27 		Float &nearest_distance);
       
    28 	virtual void optimize() {};
       
    29 };
       
    30 
    12 
    31 class KdNode
    13 class KdNode
    32 {
    14 {
    33 	Float split;
    15 	Float split;
    34 	short axis; /* 0,1,2 => x,y,z; 3 => leaf */
    16 	short axis; /* 0,1,2 => x,y,z; 3 => leaf */