Subversion Repositories gelsvn

Rev

Rev 291 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
290 jrf 1
#ifndef __AABOX__H
2
#define __AABOX__H
3
 
4
#include <iostream>
5
#include <vector>
6
#include "Triangle.h"
7
 
8
const float DIST_THRESH = 5e-4;
9
 
10
 
11
class AABox
12
{
13
	CGLA::Vec3f pmin, pmax, interior_point;
14
public:
15
 
16
	AABox() {}
17
 
18
	AABox(const CGLA::Vec3f& _pmin, const CGLA::Vec3f& _pmax,
19
				const CGLA::Vec3f& _interior_point):
20
		pmin(_pmin), pmax(_pmax), interior_point(_interior_point)
21
		{
22
			for(int i=0;i<3;++i)
23
				if((pmax[i]-pmin[i]) < DIST_THRESH)
24
					{
25
						pmax[i] += DIST_THRESH/2.0f;
26
						pmin[i] -= DIST_THRESH/2.0f;
27
					}
28
			assert(pmin.all_le(interior_point));
29
			assert(pmax.all_ge(interior_point));
30
		}
31
 
32
 
33
	const CGLA::Vec3f& get_pmin() const {return pmin;}
34
 
35
	const CGLA::Vec3f& get_pmax() const {return pmax;}
36
 
37
	bool intersect(const CGLA::Vec3f&, const CGLA::Vec3f&) const;
38
 
39
	void gl_draw() const;
40
 
41
	void minmax_sq_dist(const CGLA::Vec3f& p, float& dmin, float& dmax) const;
42
 
43
	static AABox box_triangle(const Triangle&);
44
 
45
	static AABox box_and_split(const std::vector<Triangle>& invec,
46
														 std::vector<Triangle>& lvec,
47
														 std::vector<Triangle>& rvec);
48
 
49
};
50
 
51
#endif