Subversion Repositories gelsvn

Rev

Rev 443 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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