Subversion Repositories gelsvn

Rev

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

Rev 595 Rev 630
1
/* ----------------------------------------------------------------------- *
1
/* ----------------------------------------------------------------------- *
2
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
2
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
3
 * Copyright (C) the authors and DTU Informatics
3
 * Copyright (C) the authors and DTU Informatics
4
 * For license and list of authors, see ../../doc/intro.pdf
4
 * For license and list of authors, see ../../doc/intro.pdf
5
 * ----------------------------------------------------------------------- */
5
 * ----------------------------------------------------------------------- */
6
 
6
 
7
/**
7
/**
8
 * @file OBox.h
8
 * @file OBox.h
9
 * @brief An oriented bounding box.
9
 * @brief An oriented bounding box.
10
 */
10
 */
11
 
11
 
12
#ifndef __GEOMETRY_OBOX__H
12
#ifndef __GEOMETRY_OBOX__H
13
#define __GEOMETRY_OBOX__H
13
#define __GEOMETRY_OBOX__H
14
 
14
 
15
#include <iostream>
15
#include <iostream>
16
#include <vector>
16
#include <vector>
17
#include "Triangle.h"
17
#include "Triangle.h"
18
#include "AABox.h"
18
#include "AABox.h"
19
 
19
 
20
namespace Geometry
20
namespace Geometry
21
{
21
{
22
 
22
 
23
class OBox
23
class OBox
24
{
24
{
25
	const CGLA::Mat3x3f R;
25
	const CGLA::Mat3x3f R;
26
	const AABox aabox;
26
	const AABox aabox;
27
 
27
 
28
public:
28
public:
29
	OBox() {}
29
	OBox() {}
30
 
30
 
31
	OBox(const CGLA::Mat3x3f& _R, const AABox& _aabox):
31
	OBox(const CGLA::Mat3x3f& _R, const AABox& _aabox):
32
		R(_R), aabox(_aabox) {}
32
		R(_R), aabox(_aabox) {}
33
 
33
 
34
	bool intersect(const CGLA::Vec3f&, const CGLA::Vec3f&) const;
34
	bool intersect(const CGLA::Vec3f&, const CGLA::Vec3f&) const;
35
 
35
 
36
	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
37
	{
37
	{
38
		aabox.minmax_sq_dist(R * p, dmin, dmax);
38
		aabox.minmax_sq_dist(R * p, dmin, dmax);
39
	}
39
	}
40
	
40
	
41
 
41
 
42
	static OBox box_triangle(const Triangle&);
42
	static OBox box_triangle(const Triangle&);
43
 
43
 
44
	static OBox box_and_split(const std::vector<Triangle>& invec,
44
	static OBox box_and_split(const std::vector<Triangle>& invec,
45
														 std::vector<Triangle>& lvec,
45
														 std::vector<Triangle>& lvec,
46
														 std::vector<Triangle>& rvec);
46
														 std::vector<Triangle>& rvec);
47
														 
47
														 
48
	const CGLA::Mat3x3f& get_rotation() const { return R; }
48
	const CGLA::Mat3x3f& get_rotation() const { return R; }
49
	const AABox& get_aabox() const { return aabox; }
49
	const AABox& get_aabox() const { return aabox; }
50
 
50
 
51
/* 	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);} */
52
 
52
 
53
/* 	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);} */
54
 
54
 
55
};
55
};
56
 
56
 
57
}
57
}
58
#endif
58
#endif
59
 
59