//#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(); ObjectContainer::const_iterator mi = node->mGeometry.begin(); for (; mi != node->mGeometry.end(); mi++) { instances->push_back(*mi); } SceneGraphNodeContainer::iterator ni = node->mChildren.begin(); for (; ni != node->mChildren.end(); ni++) { nodeStack.push(*ni); number++; } } 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++) { (*mi)->SetId(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 } }