Subversion Repositories gelsvn

Rev

Details | Last modification | View Log | RSS feed

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