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 |
/**
|
|
|
8 |
* @file BoundingTree.h
|
|
|
9 |
* @brief Template representing a bounding hierarchy.
|
|
|
10 |
*/
|
|
|
11 |
|
|
|
12 |
#ifndef __GEOMETRY_BOUNDINGTREE_H
|
|
|
13 |
#define __GEOMETRY_BOUNDINGTREE_H
|
|
|
14 |
|
|
|
15 |
#include "BoundingNode.h"
|
|
|
16 |
#include "BoundingLNode.h"
|
|
|
17 |
#include "BoundingINode.h"
|
|
|
18 |
#include "Ray.h"
|
|
|
19 |
|
|
|
20 |
namespace Geometry
|
|
|
21 |
{
|
|
|
22 |
|
|
|
23 |
/** Template representing a bounding hierarchy. The argument should be the bounding box type -
|
|
|
24 |
either ABox or OOBox */
|
|
|
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);
|
|
|
43 |
|
|
|
44 |
bool intersect(const CGLA::Vec3f&,const CGLA::Vec3f&,float&) const;
|
|
|
45 |
|
|
|
46 |
void intersect(Ray& r) const;
|
|
|
47 |
|
|
|
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 |
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
#endif
|