Subversion Repositories gelsvn

Rev

Rev 321 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
595 jab 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
 
290 jrf 7
#include "BoundingNode.h"
8
#include "BoundingINode.h"
9
#include "BoundingLNode.h"
10
 
11
 
12
using namespace std;
13
using namespace CGLA;
14
 
291 jrf 15
namespace Geometry
16
{
17
 
290 jrf 18
template<class BoxType>
19
void BoundingNode<BoxType>::sq_distance(const Vec3f& p, 
291 jrf 20
										float& dmin, float& dmax,
21
										float& s) const
290 jrf 22
{
321 jab 23
  BoxType::minmax_sq_dist(p, dmin, dmax);
290 jrf 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
 
321 jab 58
template class BoundingNode<AABox>;
59
/*
290 jrf 60
template BoundingNode<AABox>* 
61
BoundingNode<AABox>::build(std::vector<Triangle>& triangles);
321 jab 62
*/
63
template class BoundingNode<OBox>;
64
/*template BoundingNode<OBox>* 
290 jrf 65
BoundingNode<OBox>::build(std::vector<Triangle>& triangles);
321 jab 66
*/
309 jab 67
}