Subversion Repositories gelsvn

Rev

Rev 460 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 460 Rev 595
-
 
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 OBox.h
-
 
9
 * @brief An oriented bounding box.
-
 
10
 */
-
 
11
 
1
#ifndef __GEOMETRY_OBOX__H
12
#ifndef __GEOMETRY_OBOX__H
2
#define __GEOMETRY_OBOX__H
13
#define __GEOMETRY_OBOX__H
3
 
14
 
4
#include <iostream>
15
#include <iostream>
5
#include <vector>
16
#include <vector>
6
#include "Triangle.h"
17
#include "Triangle.h"
7
#include "AABox.h"
18
#include "AABox.h"
8
 
19
 
9
namespace Geometry
20
namespace Geometry
10
{
21
{
11
 
22
 
12
class OBox
23
class OBox
13
{
24
{
14
	const CGLA::Mat3x3f R;
25
	const CGLA::Mat3x3f R;
15
	const AABox aabox;
26
	const AABox aabox;
16
 
27
 
17
public:
28
public:
18
	OBox() {}
29
	OBox() {}
19
 
30
 
20
	OBox(const CGLA::Mat3x3f& _R, const AABox& _aabox):
31
	OBox(const CGLA::Mat3x3f& _R, const AABox& _aabox):
21
		R(_R), aabox(_aabox) {}
32
		R(_R), aabox(_aabox) {}
22
 
33
 
23
	bool intersect(const CGLA::Vec3f&, const CGLA::Vec3f&) const;
34
	bool intersect(const CGLA::Vec3f&, const CGLA::Vec3f&) const;
24
 
35
 
25
	void minmax_sq_dist(const CGLA::Vec3f& p, float& dmin, float& dmax) const
36
	void minmax_sq_dist(const CGLA::Vec3f& p, float& dmin, float& dmax) const
26
	{
37
	{
27
		aabox.minmax_sq_dist(R * p, dmin, dmax);
38
		aabox.minmax_sq_dist(R * p, dmin, dmax);
28
	}
39
	}
29
	
40
	
30
 
41
 
31
	static OBox box_triangle(const Triangle&);
42
	static OBox box_triangle(const Triangle&);
32
 
43
 
33
	static OBox box_and_split(const std::vector<Triangle>& invec,
44
	static OBox box_and_split(const std::vector<Triangle>& invec,
34
														 std::vector<Triangle>& lvec,
45
														 std::vector<Triangle>& lvec,
35
														 std::vector<Triangle>& rvec);
46
														 std::vector<Triangle>& rvec);
36
														 
47
														 
37
	const CGLA::Mat3x3f& get_rotation() const { return R; }
48
	const CGLA::Mat3x3f& get_rotation() const { return R; }
38
	const AABox& get_aabox() const { return aabox; }
49
	const AABox& get_aabox() const { return aabox; }
39
 
50
 
40
/* 	const CGLA::Vec3f& get_pmin() const {assert(0); return CGLA::Vec3f(0);} */
51
/* 	const CGLA::Vec3f& get_pmin() const {assert(0); return CGLA::Vec3f(0);} */
41
 
52
 
42
/* 	const CGLA::Vec3f& get_pmax() const {assert(0); return CGLA::Vec3f(0);} */
53
/* 	const CGLA::Vec3f& get_pmax() const {assert(0); return CGLA::Vec3f(0);} */
43
 
54
 
44
};
55
};
45
 
56
 
46
}
57
}
47
#endif
58
#endif
48
 
59