Subversion Repositories gelsvn

Rev

Rev 290 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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