Subversion Repositories gelsvn

Rev

Rev 291 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#ifndef __BOUNDINGNODE_H
#define __BOUNDINGNODE_H

#include <vector>
#include "CGLA/Vec3f.h"
#include "Triangle.h"
#include "AABox.h"
#include "OBox.h"

/// Abstract BOUNDINGNODE node.
template<class BoxType>
class BoundingNode: public BoxType
{
 public:
        
        BoundingNode(const BoxType& box): BoxType(box) {}

        /// Count number of intersections from a point in a given direction
        virtual int intersect_cnt(const CGLA::Vec3f&,const CGLA::Vec3f&) const=0;

        /** Draw the tree. The first argument is the level counter, the second
                        argument is the level at which to draw. */
        virtual void draw(int l, int lmax) const =0;

        /// Find the surface intersection point
        virtual bool intersect(const CGLA::Vec3f&,const CGLA::Vec3f&,float&) const=0;

        /** For a given point, return the min and max square distance and the
                        sign. Non-leafs return zero for the sign. Leaves
                        return the square of the true distance as both min and max. */
        virtual void sq_distance(const CGLA::Vec3f&, float&, float&, float&) const;
        
        static BoundingNode* build(std::vector<Triangle>& triangles);
};

#endif