void ConvertFormula( std::string inputFileName, TSupportedFormats inputFormat, TSupportedFormats outputFormat, std::string outputFileName ) { shared_ptr<FormulaObj> obj(new FormulaObj(NT_MAIN)); MathMLParser mmlparser; CConvertLatex latexConverter; shared_ptr<MathObj> latexObj; if (inputFormat == SF_OPENMATH) { ConvertFromOM(inputFileName, obj); } if (inputFormat == SF_MATHML) { mmlparser.Pars(inputFileName); } if (inputFormat == SF_LATEX) { ifstream ifs(inputFileName); string str((istreambuf_iterator<char>(ifs)), istreambuf_iterator<char>()); latexObj = latexConverter.ConvertFromLatex(str); ifs.close(); } if (outputFormat == SF_OPENMATH) { if (inputFormat == SF_OPENMATH) { ConvertToOM(outputFileName, obj); } if (inputFormat == SF_MATHML) { ConvertToOM(outputFileName, mmlparser.GetData()); } if (inputFormat == SF_LATEX) { ConvertToOM(outputFileName, latexObj); } } if (outputFormat == SF_MATHML) { if (inputFormat == SF_OPENMATH) { mmlparser.SetData(obj); mmlparser.Save(outputFileName); } if (inputFormat == SF_MATHML) mmlparser.Save(outputFileName); if (inputFormat == SF_LATEX) { mmlparser.SetData(latexObj); mmlparser.Save(outputFileName); } } if (outputFormat == SF_LATEX) { string outStr; if (inputFormat == SF_LATEX) { latexConverter.ConvertToLatex(latexObj, outStr); } else if (inputFormat == SF_OPENMATH) { latexConverter.ConvertToLatex(obj, outStr); } else if (inputFormat == SF_MATHML) { latexConverter.ConvertToLatex(mmlparser.GetData(), outStr); } ofstream ofs(outputFileName, ios::out); ofs << outStr; ofs.close(); } }
void Application::Run() { double T1 = glfwGetTime(); bool RunLoop = true; if (RunMode == MODE_PLAY) { Game = new ScreenMainMenu(NULL); ((ScreenMainMenu*)Game)->Init(); }else if (RunMode == MODE_VSRGPREVIEW) { Game = new ScreenGameplay7K(); VSRG::Song* Sng = LoadSong7KFromFilename(InFile.path(), InFile.ParentDirectory().path(), NULL); ((ScreenGameplay7K*)Game)->Init (Sng, difIndex, Upscroll); }else if (RunMode == MODE_CONVERT) { VSRG::Song* Sng = LoadSong7KFromFilename(InFile.Filename().path(), InFile.ParentDirectory().path(), NULL); if (Sng) { // if (ConvertMode == CONV_OM) // for now this is the default ConvertToOM (Sng, OutFile.path(), Author); } RunLoop = false; }else if (RunMode == MODE_GENCACHE) { std::vector<VSRG::Song*> Songs; GameState::Printf("Generating cache...\n"); std::vector<String> Directories; Configuration::GetConfigListS("SongDirectories", Directories); for (std::vector<String>::iterator i = Directories.begin(); i != Directories.end(); i++) { FileManager::GetSongList7K(Songs, *i); } for (std::vector<VSRG::Song*>::iterator i = Songs.begin(); i != Songs.end(); i++) delete *i; RunLoop = false; } GameState::Printf("Time: %fs\n", glfwGetTime() - T1); if (!RunLoop) return; while (Game->IsScreenRunning() && !WindowFrame.ShouldCloseWindow()) { double newTime = glfwGetTime(); double delta = newTime - oldTime; ImageLoader::UpdateTextures(); WindowFrame.ClearWindow(); Game->Run(delta); MixerUpdate(); WindowFrame.SwapBuffers(); oldTime = newTime; } }