Subversion Repositories gelsvn

Rev

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

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