00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _bbox_h_
00027 #define _bbox_h_
00028
00029 #include "matvec3D.h"
00030 #include "mytools.h"
00031
00032 #include <iostream>
00033
00038 class BoundingBox
00039 {
00040 private:
00041 transf mTran;
00042 transf mTranInv;
00043 public:
00044 vec3 halfSize;
00045
00046 mutable bool mMark;
00047 BoundingBox(const transf &t, const vec3 &v) : mTran(t), mTranInv(t.inverse()),
00048 halfSize(v), mMark(false) {}
00049 BoundingBox(const BoundingBox &b) : mTran(b.getTran()), mTranInv(b.getTranInv()),
00050 halfSize(b.halfSize), mMark(b.mMark) {}
00051 BoundingBox() : mTran(), mTranInv(), halfSize(), mMark(false){}
00052 INLINE_RELEASE void applyTransform(const transf &t);
00053 void setTran(const transf &t) {
00054 mTran = t;
00055 mTranInv = mTran.inverse();
00056 }
00057 const transf& getTran() const {return mTran;}
00058 const transf& getTranInv() const {return mTranInv;}
00059 };
00060
00061 INLINE_RELEASE bool
00062 bboxOverlap(const BoundingBox &bb1, const BoundingBox &bb2, const transf &tran2To1);
00063
00064 INLINE_RELEASE double
00065 bboxDistanceSq(const BoundingBox &bb1, const BoundingBox &bb2, const transf &tran2To1);
00066
00067 INLINE_RELEASE double
00068 bboxDistanceApp(const BoundingBox &bb1, const BoundingBox &bb2);
00069
00070 INLINE_RELEASE double
00071 pointBoxDistanceSq(const BoundingBox &bbox, const position &p);
00072
00073 INLINE_RELEASE
00074 position closestPtBbox(const BoundingBox &bbox, const position &p);
00075
00076 #ifdef GRASPIT_RELEASE
00077 #include "bbox_inl.h"
00078 #endif
00079
00080 #endif