Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

SceneToFile.cpp

Go to the documentation of this file.
00001 #include "SceneToFile.h"
00002 #include "DefaultDFS.h"
00003 #include "SceneToFileCoreVisitor.h"
00004 
00005 #include <fstream>
00006 #include <iostream>
00007 
00008 using namespace X3DTK;
00009 using namespace std;
00010 
00011 SceneToFile::SceneToFile(DFS *dfs)
00012 : X3DSceneToFile()
00013 {
00014   globalVariables = GVManager::getInstanceOf<SceneToFileGlobalVariables>();
00015   
00016   if (dfs == 0)
00017   {
00018     dfs = new DefaultDFS();
00019     defaultDFSUSE = true;
00020   }  
00021   else
00022   {
00023     this->dfs = dfs;
00024     defaultDFSUSE = false;
00025   }
00026   
00027   dfs->setComponentVisitor(new SceneToFileCoreVisitor());
00028 }
00029 
00030 SceneToFile::~SceneToFile()
00031 {
00032   if (defaultDFSUSE)
00033     delete dfs;
00034 }
00035 
00036 void SceneToFile::setComponentVisitor(X3DComponentVisitor *component)
00037 {
00038   dfs->setComponentVisitor(component);
00039 }
00040 
00041 void SceneToFile::toFile(Scene *S, const SFString &file) const
00042 {
00043   ofstream output(file);
00044   
00045   output << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
00046   output << "<X3D>" << endl;
00047   dfs->traverse(S);
00048   MFString text = globalVariables->getOutput();
00049   
00050   for (MFString::const_iterator it = text.begin(); it != text.end(); ++it)
00051     output << (*it) << endl;
00052 
00053   output << "</X3D>" << endl;
00054 }

Generated on Wed May 14 10:03:11 2003 for X3DToolKit by doxygen1.3