src/KDTree.h

Go to the documentation of this file.
00001 #ifndef KDTREE_H
00002 #define KDTREE_H
00003 
00004 
00005 #include <vector>
00006 #include <cassert>
00007 
00008 #include "Box.h"
00009 #include "Axis.h"
00010 
00011 
00012 class Node;
00013 class Primitive;
00014 class Ray;
00015 
00016 
00021 class KDTree
00022 {
00023 public:
00025     typedef std::vector<Primitive *> PrimitiveList;
00026 
00027 
00033     KDTree( unsigned int min_primitives,
00034             unsigned int max_depth )
00035         : mBoundingBox(),
00036             mRootNode(NULL),
00037             mMinPrimitives(min_primitives),
00038             mMaxDepth(max_depth)
00039     {
00040     }
00041 
00044     virtual ~KDTree();
00045 
00052     virtual bool intersect(Ray & ray) const;
00053 
00059     virtual void buildTree( const PrimitiveList &   list,
00060                             const Box &             bbox );
00061 
00068     void setConstraints(    unsigned int min_primitives,
00069                             unsigned int max_depth )
00070     {
00071         mMinPrimitives  = min_primitives;
00072         mMaxDepth       = max_depth;
00073     }
00074 
00077     unsigned int minPrimitives() const
00078     {
00079         return mMinPrimitives;
00080     }
00081 
00084     unsigned int maxDepth() const
00085     {
00086         return mMaxDepth;
00087     }
00088 
00089 protected:
00091     Box             mBoundingBox;
00092 
00094     Node *          mRootNode;
00095 
00097     unsigned int    mMinPrimitives;
00098 
00100     unsigned int    mMaxDepth;
00101 
00102 
00111     virtual bool intersect( const Node *    node,
00112                             Ray &           ray,
00113                             float           min,
00114                             float           max ) const;
00115 
00125     virtual bool terminate( const Node *    current,
00126                             float           dummy,
00127                             unsigned int    depth ) const;
00128 };
00129 
00130 
00131 #endif
00132 

Generated on Fri Feb 1 00:01:42 2008 for Grayfall by  doxygen 1.5.1