Subversion Repositories gelsvn

Rev

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

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