00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00028 #include "../include/IPSA/ipsaclasses.h"
00029 #include "../include/IPSA/IpsaSimulator.h"
00030 #include "../include/IPSA/viewer/instructions/SaveIVFile.h"
00031
00032 #include <Inventor/actions/SoWriteAction.h>
00033
00034
00035 namespace {
00036 const std::string FILE_SUFFIX = ".iv";
00037 }
00038
00039 Instruction::tExecResultType SaveIVFile::vExecute(std::vector<std::string>& Instr, std::ostringstream& answer, unsigned int& numberOfReturnValues)
00040 {
00041 numberOfReturnValues = 0;
00042 std::string outputFileName = Instr.at(1);
00043
00044 if (outputFileName.empty())
00045 return eBAD_FILENAME;
00046
00047
00048 const std::string::size_type suffixPos = outputFileName.rfind(FILE_SUFFIX);
00049 if (suffixPos == std::string::npos
00050 || suffixPos != outputFileName.length() - (FILE_SUFFIX.length() + 1) )
00051 {
00052 outputFileName.append(FILE_SUFFIX);
00053 }
00054
00055
00056
00057 SoOutput out;
00058 out.openFile(outputFileName.c_str());
00059 SoWriteAction wa(&out);
00060 wa.apply(ipsaSimulator->getSceneGraph());
00061 out.closeFile();
00062
00063 return eOK;
00064 }