Explorer.cc

Go to the documentation of this file.
00001 #include <esg/explorer/Explorer.h>
00002 #include <esg/iterator/IteratorSDS.h>
00003 
00004 using namespace esg;
00005 
00006 bool Explorer::_explore(SceneGraphObject& obj)
00007 {
00008     const Transform* pTr = obj.transformation();
00009 
00010     if (pTr) { // new transformation => update stack
00011         Matrix4* auxMat = new Matrix4(pTr->get());
00012         if (!_trStack.empty()) auxMat->mul(*_trStack.top(), *auxMat);
00013         _trStack.push(auxMat);
00014         _accept_new_transformation(*auxMat);
00015     }
00016 
00017     /*
00018      * Inspect subnodes and/or attributes
00019      */
00020     bool ret = (obj.hasSubnodes()) ?  _iterate(obj) : _process_leaf(obj);
00021 
00022     /*
00023      * Erase my transform. matrix after backtracking children
00024      */
00025     if (pTr && !_trStack.empty()) {
00026         delete _trStack.top();
00027         _trStack.pop();
00028     }
00029 
00030     return ret;
00031 }
00032 
00033 bool Explorer::_iterate(SceneGraphObject& obj)
00034 {
00035     SceneGraphObject* pCandidate;
00036     IteratorSDS*      pIter = obj.traverseSubnodes();
00037 
00038     if (!pIter) return false;
00039     
00040     pIter->initChildrenSearch();
00041 
00042     bool ret = false;
00043     pCandidate = pIter->firstChild();
00044     while (pCandidate) {
00045         if (_explore(*pCandidate)) ret = true;
00046         pCandidate = pIter->nextChild();
00047     }
00048     delete pIter;
00049     
00050     return ret;
00051 }
00052 
00053 // ----- public -----
00054 
00055 void Explorer::explore(SceneGraphObject& obj)
00056 {
00057     while (!_trStack.empty()) { delete _trStack.top(); _trStack.pop(); }
00058     (void) _explore(obj);
00059 }
00060 
00061 
00062 
00063 
00064 

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