Go to the documentation of this file.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
00027
00028
00029
00030
00031
00032
00033
00034
00038 #ifndef FCL_BV_NODE_H
00039 #define FCL_BV_NODE_H
00040
00041 #include "fcl/math/vec_3f.h"
00042 #include "fcl/math/matrix_3f.h"
00043
00044 #include "fcl/BV/BV.h"
00045 #include <iostream>
00046
00047 namespace fcl
00048 {
00049
00051 struct BVNodeBase
00052 {
00057 int first_child;
00058
00061 int first_primitive;
00062
00064 int num_primitives;
00065
00067 inline bool isLeaf() const { return first_child < 0; }
00068
00070 inline int primitiveId() const { return -(first_child + 1); }
00071
00073 inline int leftChild() const { return first_child; }
00074
00076 inline int rightChild() const { return first_child + 1; }
00077 };
00078
00080 template<typename BV>
00081 struct BVNode : public BVNodeBase
00082 {
00084 BV bv;
00085
00087 bool overlap(const BVNode& other) const
00088 {
00089 return bv.overlap(other.bv);
00090 }
00091
00093 FCL_REAL distance(const BVNode& other, Vec3f* P1 = NULL, Vec3f* P2 = NULL) const
00094 {
00095 return bv.distance(other.bv, P1, P2);
00096 }
00097
00099 Vec3f getCenter() const { return bv.center(); }
00100
00102 Matrix3f getOrientation() const { return Matrix3f::getIdentity(); }
00103 };
00104
00105 template<>
00106 inline Matrix3f BVNode<OBB>::getOrientation() const
00107 {
00108 return Matrix3f(bv.axis[0][0], bv.axis[1][0], bv.axis[2][0],
00109 bv.axis[0][1], bv.axis[1][1], bv.axis[2][1],
00110 bv.axis[0][2], bv.axis[1][2], bv.axis[2][2]);
00111 }
00112
00113 template<>
00114 inline Matrix3f BVNode<RSS>::getOrientation() const
00115 {
00116 return Matrix3f(bv.axis[0][0], bv.axis[1][0], bv.axis[2][0],
00117 bv.axis[0][1], bv.axis[1][1], bv.axis[2][1],
00118 bv.axis[0][2], bv.axis[1][2], bv.axis[2][2]);
00119 }
00120
00121 template<>
00122 inline Matrix3f BVNode<OBBRSS>::getOrientation() const
00123 {
00124 return Matrix3f(bv.obb.axis[0][0], bv.obb.axis[1][0], bv.obb.axis[2][0],
00125 bv.obb.axis[0][1], bv.obb.axis[1][1], bv.obb.axis[2][1],
00126 bv.obb.axis[0][2], bv.obb.axis[1][2], bv.obb.axis[2][2]);
00127 }
00128
00129
00130 }
00131
00132 #endif