2
* ***** BEGIN GPL LICENSE BLOCK *****
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19
* All rights reserved.
21
* The Original Code is: all of this file.
23
* Contributor(s): none yet.
25
* ***** END GPL LICENSE BLOCK *****
28
/** \file boolop/intern/BOP_BBox.h
29
* \ingroup boolopintern
33
#ifndef __BOP_BBOX_H__
34
#define __BOP_BBOX_H__
36
#include "MT_Point3.h"
37
#include "BOP_MathUtils.h"
39
#define BOP_MAX(a, b) ((a > b) ? a : b)
40
#define BOP_MIN(a, b) ((a < b) ? a : b)
41
#define BOP_ABS(a) ((a < 0) ? -(a) : a)
61
BOP_BBox(const MT_Point3& p1,const MT_Point3& p2,const MT_Point3& p3);
62
inline void add(const MT_Point3& p)
64
m_minX = BOP_MIN(m_minX,p[0]);
65
m_minY = BOP_MIN(m_minY,p[1]);
66
m_minZ = BOP_MIN(m_minZ,p[2]);
67
m_maxX = BOP_MAX(m_maxX,p[0]);
68
m_maxY = BOP_MAX(m_maxY,p[1]);
69
m_maxZ = BOP_MAX(m_maxZ,p[2]);
72
inline const MT_Scalar getCenterX() const {return m_centerX;};
73
inline const MT_Scalar getCenterY() const {return m_centerY;};
74
inline const MT_Scalar getCenterZ() const {return m_centerZ;};
76
inline const MT_Scalar getExtentX() const {return m_extentX;};
77
inline const MT_Scalar getExtentY() const {return m_extentY;};
78
inline const MT_Scalar getExtentZ() const {return m_extentZ;};
80
inline void compute() {
81
m_extentX = (m_maxX-m_minX)/2.0f;
82
m_extentY = (m_maxY-m_minY)/2.0f;
83
m_extentZ = (m_maxZ-m_minZ)/2.0f;
84
m_centerX = m_minX+m_extentX;
85
m_centerY = m_minY+m_extentY;
86
m_centerZ = m_minZ+m_extentZ;
89
inline const bool intersect(const BOP_BBox& b) const {
90
return (!((BOP_comp(m_maxX,b.m_minX)<0) || (BOP_comp(b.m_maxX,m_minX)<0) ||
91
(BOP_comp(m_maxY,b.m_minY)<0) || (BOP_comp(b.m_maxY,m_minY)<0) ||
92
(BOP_comp(m_maxZ,b.m_minZ)<0) || (BOP_comp(b.m_maxZ,m_minZ)<0)));