FDH14Tree.cc

Go to the documentation of this file.
00001 #include <esg/spacesorting/FDH14Tree.h>
00002 #include <esg/explorer/NExtentsExplorer.h>
00003 #include <esg/explorer/ExtentExplorer.h>
00004 
00005 using namespace esg;
00006 
00007 
00008 Geometry* FDH14Tree::_create_bv(List<SceneGraphObject>& list)
00009 {
00010     return (Geometry*) new FDH14(list);
00011 }
00012 
00013 Geometry* FDH14Tree::_create_bv(Geometry& bv1, Geometry& bv2)
00014 {
00015     return (Geometry*) new FDH14(bv1, bv2);
00016 }
00017 
00018 Geometry* FDH14Tree::_create_bv(SceneGraphObject& obj)
00019 {
00020 #if defined(_MSC_VER)
00021     float *fdhVal = new float [2*_dirs];
00022 #else
00023     float fdhVal [2*_dirs];
00024 #endif
00025     
00026     NExtentsExplorer explorer(_fdhMat, _dirs);
00027     explorer.explore(obj);
00028     for (unsigned i = 0; i < _dirs; i++) {
00029         explorer.explore(obj);
00030         fdhVal[i]       =   explorer.result(i).max;
00031         fdhVal[i+_dirs] = - explorer.result(i).min;
00032     }
00033 
00034     FDH14 * pFDH = new FDH14(fdhVal);
00035 
00036 #if defined(_MSC_VER)
00037     delete [] fdhVal;
00038 #endif
00039 
00040     return pFDH;
00041 }
00042 
00043 Geometry* FDH14Tree::_create_bv(const float* fdhVal, unsigned)
00044 {
00045     return (Geometry*) new FDH14(fdhVal);
00046 }
00047 
00048 DistRot* FDH14Tree::_create_dist_rot(BVH::Node * pNode)
00049 {
00050     return new FDH14DistRot(((FDH14*)pNode->bv)->_values,
00051                             _pRotInfo,
00052                             _scaleRatio);
00053 }
00054 
00055 void FDH14Tree::_dr_init(const Matrix4* pMyTr,
00056                          const Matrix4* pHisTr,
00057                          BVH*           pPartner)
00058 {
00059     FDHTree::_dr_init(NULL,NULL,pPartner);
00060     
00061     if (_pRotInfo) { delete _pRotInfo; _pRotInfo = NULL; }
00062     
00063     Matrix4 * pMat = multiTrans(pHisTr, pMyTr, _scaleRatio);
00064     if (pMat) {
00065         _pRotInfo = new FDH14::RotInfo(*pMat);
00066         delete pMat;
00067     } 
00068 }
00069 
00070 void FDH14Tree::_duplicate_attributes(const SDS& src)
00071 {
00072   FDHTree::_duplicate_attributes(src);
00073   if (((FDH14Tree&)src)._pRotInfo)
00074       _pRotInfo = ((FDH14Tree&)src)._pRotInfo->clone();
00075   else
00076       _pRotInfo = NULL;
00077 }
00078 
00079 
00080 
00081 //-------- public ----------
00082 
00083 FDH14Tree::FDH14Tree(unsigned ll, unsigned dl, bool delayBuild,
00084                      BVList::SplitStrategy ss)
00085   : FDHTree(ll, dl, FDH14::FDHMat, FDH14::DIRS, delayBuild,ss)
00086 {
00087     _pRotInfo = NULL;
00088 }
00089 
00090 SDS* FDH14Tree::clone() const
00091 {
00092   FDH14Tree* ret = new FDH14Tree();
00093   ret->_duplicate_attributes(*this);
00094   return ret;
00095 }
00096 
00097 

Generated on Wed Jun 28 12:24:30 2006 for esg by  doxygen 1.4.6