//#include #include #include "SceneGraph.h" #include "X3dExporter.h" #include "Intersectable.h" 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 "< 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::const_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); } } }