Subversion Repositories gelsvn

Rev

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

Rev Author Line No. Line
290 jrf 1
#include "BoundingNode.h"
2
#include "BoundingINode.h"
3
#include "BoundingLNode.h"
4
 
5
 
6
using namespace std;
7
using namespace CGLA;
8
 
291 jrf 9
namespace Geometry
10
{
11
 
290 jrf 12
template<class BoxType>
13
void BoundingNode<BoxType>::sq_distance(const Vec3f& p, 
291 jrf 14
										float& dmin, float& dmax,
15
										float& s) const
290 jrf 16
{
321 jab 17
  BoxType::minmax_sq_dist(p, dmin, dmax);
290 jrf 18
	s = 0;
19
}
20
 
21
template<class BoxType>
22
BoundingNode<BoxType>* 
23
BoundingNode<BoxType>::build(std::vector<Triangle>& triangles)
24
{
25
	int N = triangles.size();
26
	if(N==1)
27
		{
28
			const Triangle& t = triangles[0];
29
#if USE_LEAF_BOXES
30
			return new BoundingLNode<BoxType>(BoxType::box_triangle(t), t);
31
#else
32
			return new BoundingLNode<BoxType>(t);
33
#endif
34
 
35
		}
36
	else
37
		{
38
			std::vector<Triangle> triangles_left;
39
			std::vector<Triangle> triangles_right;
40
 
41
			BoxType box = 
42
				BoxType::box_and_split(triangles, triangles_left, triangles_right);
43
 
44
			BoundingNode* left  = build(triangles_left);
45
			BoundingNode* right = build(triangles_right);
46
 
47
			BoundingNode<BoxType>* bn = new BoundingINode<BoxType>(box, left, right);
48
			return bn;
49
		}
50
}
51
 
321 jab 52
template class BoundingNode<AABox>;
53
/*
290 jrf 54
template BoundingNode<AABox>* 
55
BoundingNode<AABox>::build(std::vector<Triangle>& triangles);
321 jab 56
*/
57
template class BoundingNode<OBox>;
58
/*template BoundingNode<OBox>* 
290 jrf 59
BoundingNode<OBox>::build(std::vector<Triangle>& triangles);
321 jab 60
*/
309 jab 61
}