7 #include "Primitive.hxx"
9 //! Interface for tree nodes
13 virtual ~kDTreeNode(){;};
14 // interface for the traversal. [t0,t1] code the active ray interval.
15 virtual bool Traverse(Ray &ray, float& t0, float& t1) = 0;
18 //! An inner node of the kD-tree
19 class kDTreeInnerNode : public kDTreeNode
22 kDTreeInnerNode(float split, int axis);
23 virtual ~kDTreeInnerNode();
25 virtual bool Traverse(Ray& ray, float& t0, float& t1);
27 void setChildren(kDTreeNode* left, kDTreeNode* right);
30 kDTreeInnerNode(const kDTreeInnerNode& );
31 kDTreeInnerNode& operator=(const kDTreeInnerNode& );
33 // pointer to the children
34 kDTreeNode* m_children[2];
35 // encodes the position of the splitting plane on the splitting axis
37 // encodes the splitting axis
41 //! A leaf node of the kD-tree
42 class kDTreeLeafNode : public kDTreeNode
45 kDTreeLeafNode(const std::vector<Primitive*>& prim);
46 virtual ~kDTreeLeafNode();
48 virtual bool Traverse(Ray& ray, float& t0, float& t1);
52 kDTreeLeafNode(const kDTreeLeafNode& );
53 kDTreeLeafNode& operator=(const kDTreeLeafNode& );
55 std::vector<Primitive *> m_primitives;
58 //! The actual kDTree interface
62 kDTree(const Box& bounds, const std::vector<Primitive*>& prim);
65 kDTreeNode* BuildTree(const Box& bounds,
66 const std::vector<Primitive *>& prim,
69 bool Intersect(Ray &ray);
73 kDTree(const kDTree& );
74 kDTree& operator=(const kDTree& );
78 // bounding box of the entire tree
80 // maximal recursion depth
82 // minimal number of triangles per node