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