Subversion Repositories gelsvn

Rev

Rev 595 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 595 Rev 601
1
/* ----------------------------------------------------------------------- *
1
/* ----------------------------------------------------------------------- *
2
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
2
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
3
 * Copyright (C) the authors and DTU Informatics
3
 * Copyright (C) the authors and DTU Informatics
4
 * For license and list of authors, see ../../doc/intro.pdf
4
 * For license and list of authors, see ../../doc/intro.pdf
5
 * ----------------------------------------------------------------------- */
5
 * ----------------------------------------------------------------------- */
6
 
6
 
7
/**
7
/**
8
 * @file BoundingNode.h
8
 * @file BoundingNode.h
9
 * @brief Abstract ancestor of the nodes of a bounding hierarchy.
9
 * @brief Abstract ancestor of the nodes of a bounding hierarchy.
10
 */
10
 */
11
 
11
 
12
#ifndef __GEOMETRY_BOUNDINGNODE_H
12
#ifndef __GEOMETRY_BOUNDINGNODE_H
13
#define __GEOMETRY_BOUNDINGNODE_H
13
#define __GEOMETRY_BOUNDINGNODE_H
14
 
14
 
15
#include <vector>
15
#include <vector>
16
#include "CGLA/Vec3f.h"
16
#include "../CGLA/Vec3f.h"
17
#include "Ray.h"
17
#include "Ray.h"
18
#include "Triangle.h"
18
#include "Triangle.h"
19
#include "AABox.h"
19
#include "AABox.h"
20
#include "OBox.h"
20
#include "OBox.h"
21
 
21
 
22
namespace Geometry
22
namespace Geometry
23
{
23
{
24
 
24
 
25
/// Abstract BOUNDINGNODE node.
25
/// Abstract BOUNDINGNODE node.
26
template<class BoxType>
26
template<class BoxType>
27
class BoundingNode: public BoxType
27
class BoundingNode: public BoxType
28
{
28
{
29
 public:
29
 public:
30
	
30
	
31
	BoundingNode(const BoxType& box): BoxType(box) {}
31
	BoundingNode(const BoxType& box): BoxType(box) {}
32
	virtual ~BoundingNode() {}
32
	virtual ~BoundingNode() {}
33
 
33
 
34
	/// Count number of intersections from a point in a given direction
34
	/// Count number of intersections from a point in a given direction
35
	virtual int intersect_cnt(const CGLA::Vec3f&,const CGLA::Vec3f&) const=0;
35
	virtual int intersect_cnt(const CGLA::Vec3f&,const CGLA::Vec3f&) const=0;
36
 
36
 
37
	/// Find the surface intersection point
37
	/// Find the surface intersection point
38
	virtual bool intersect(const CGLA::Vec3f&,const CGLA::Vec3f&,float&) const=0;
38
	virtual bool intersect(const CGLA::Vec3f&,const CGLA::Vec3f&,float&) const=0;
39
 
39
 
40
	virtual void intersect(Ray& r) const = 0;
40
	virtual void intersect(Ray& r) const = 0;
41
 
41
 
42
	/** For a given point, return the min and max square distance and the
42
	/** For a given point, return the min and max square distance and the
43
			sign. Non-leafs return zero for the sign. Leaves
43
			sign. Non-leafs return zero for the sign. Leaves
44
			return the square of the true distance as both min and max. */
44
			return the square of the true distance as both min and max. */
45
	virtual void sq_distance(const CGLA::Vec3f&, float&, float&, float&) const;
45
	virtual void sq_distance(const CGLA::Vec3f&, float&, float&, float&) const;
46
	
46
	
47
	static BoundingNode* build(std::vector<Triangle>& triangles);
47
	static BoundingNode* build(std::vector<Triangle>& triangles);
48
};
48
};
49
 
49
 
50
}
50
}
51
#endif
51
#endif
52
 
52