Subversion Repositories gelsvn

Rev

Rev 443 | Go to most recent revision | 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
 
7
/**
8
 * @file BoundingTree.h
9
 * @brief Template representing a bounding hierarchy.
10
 */
11
 
443 jab 12
#ifndef __GEOMETRY_BOUNDINGTREE_H
13
#define __GEOMETRY_BOUNDINGTREE_H
290 jrf 14
 
15
#include "BoundingNode.h"
16
#include "BoundingLNode.h"
17
#include "BoundingINode.h"
309 jab 18
#include "Ray.h"
290 jrf 19
 
291 jrf 20
namespace Geometry
21
{
22
 
595 jab 23
/** Template representing a bounding hierarchy. The argument should be the bounding box type - 
24
    either ABox or OOBox */
290 jrf 25
template<class BoxType>
26
class BoundingTree
27
{
28
 public:
29
 
30
	typedef BoundingNode<BoxType> Node;
31
	typedef BoundingLNode<BoxType> LeafNode;
32
	typedef BoundingINode<BoxType> IntNode;
33
 
34
	Node* root;
35
 
36
 public:
37
 
38
	BoundingTree(): root(0) {}
39
 
40
	~BoundingTree() {delete root;}
41
 
42
	void build(std::vector<Triangle>& triangles);
309 jab 43
 
290 jrf 44
	bool intersect(const CGLA::Vec3f&,const CGLA::Vec3f&,float&) const;
309 jab 45
 
46
	void intersect(Ray& r) const;
47
 
290 jrf 48
	int intersect_cnt(const CGLA::Vec3f&,const CGLA::Vec3f&) const;
49
 
50
	float compute_signed_distance(const CGLA::Vec3f& p,	float=FLT_MAX) const;
51
};
52
 
291 jrf 53
}
290 jrf 54
 
55
#endif