//#include #include #include "SceneGraph.h" #include "X3dExporter.h" #include "Intersectable.h" namespace GtpVisibilityPreprocessor { bool SceneGraph::Export( const string filename ) { if (strstr(filename.c_str(), ".x3d")) { X3dExporter exporter(filename); exporter.ExportScene(mRoot); return true; } else { cerr<<"Error: Currently unsuported export format, filename "<clear(); int number = 0; stack nodeStack; nodeStack.push(mRoot); while (!nodeStack.empty()) { SceneGraphNode *node = nodeStack.top(); nodeStack.pop(); cout << "here3.958" << endl;cout << "here3.9587654" << endl; ObjectContainer::const_iterator mi = node->mGeometry.begin(); cout << "here3.958" << endl; for (; mi != node->mGeometry.end(); mi++) { cout << "here3.9886" << endl; instances->push_back(*mi); } cout << "here3.969999" << endl; SceneGraphNodeContainer::iterator ni = node->mChildren.begin(); for (; ni != node->mChildren.end(); ni++) { nodeStack.push(*ni); cout << "here3.959" << endl; number++; } cout << "here3.96" << endl; } return number; } int SceneGraph::AssignObjectIds() { int id = 1; stack nodeStack; nodeStack.push(mRoot); while (!nodeStack.empty()) { SceneGraphNode *node = nodeStack.top(); nodeStack.pop(); ObjectContainer::iterator mi = node->mGeometry.begin(); for (; mi != node->mGeometry.end(); mi++) { // $$ JB remove object id=2601 (for debugging purposes in atlanta scene) if (1) //id != 2601) (*mi)->SetId(id++); else { node->mGeometry.erase(mi); --mi; id++; } } SceneGraphNodeContainer::iterator ni = node->mChildren.begin(); for (; ni != node->mChildren.end(); ni++) { nodeStack.push(*ni); } } // return max id return id; } void SceneGraph::GetStatistics(int &intersectables, int &faces) const { stack nodeStack; nodeStack.push(mRoot); faces = 0; intersectables = 0; while (!nodeStack.empty()) { SceneGraphNode *node = nodeStack.top(); nodeStack.pop(); ObjectContainer::const_iterator mi = node->mGeometry.begin(); for (; mi != node->mGeometry.end(); mi++) { intersectables++; faces += (*mi)->NumberOfFaces(); } SceneGraphNodeContainer::iterator ni = node->mChildren.begin(); for (; ni != node->mChildren.end(); ni++) { nodeStack.push(*ni); } } } void SceneGraphNode::UpdateBox() { AxisAlignedBox3 box; box.Initialize(); ObjectContainer::const_iterator mi = mGeometry.begin(); for (; mi != mGeometry.end(); mi++) box.Include((*mi)->GetBox()); SceneGraphNodeContainer::iterator ni = mChildren.begin(); for (; ni != mChildren.end(); ni++) { (*ni)->UpdateBox(); box.Include((*ni)->mBox); } mBox = box; } void SceneGraph::ExportScene(const string filename) { } void SceneGraph::LoadScene(const string filename) { // load binary version of mesh } }