void analyseLwo(const std::string& filename, bool modify) { std::cout << "--- " << filename << " ---" << std::endl; std::ifstream istream(filename.c_str(), std::ios::binary); std::vector<char> vectorBuffer((std::istreambuf_iterator<char>(istream)), std::istreambuf_iterator<char>()); Chunk form; form.id = "FORM"; form.size = vectorBuffer.size(); form.chunkSizeBytes = 4; parseFromStream(vectorBuffer, 0, form); if (!form.subChunks.empty()) { dumpChunks(form.subChunks[0]); } istream.close(); if (!modify) return; // Write modified LWO std::string modFile = filename.substr(0, filename.length() - 4) + "_modified.lwo"; std::ofstream output(modFile.c_str(), std::ios::binary); if (!form.subChunks.empty()) { filterFile(form.subChunks[0]); writeFile(output, form.subChunks[0]); } }
void BpdeMainWindow::plot() { std::string cmd = getSource("/home/ashamin/diploma/src/Bpde/gui/R/isoterms.R"); R.parseEvalQ(cmd); filterFile(); svg->load(svgfile); }
void QtDensity::plot(void) { const char *kernelstrings[] = { "gaussian", "epanechnikov", "rectangular", "triangular", "cosine" }; m_R["bw"] = m_bw; m_R["kernel"] = kernelstrings[m_kernel]; // that passes the string to R std::string cmd0 = "svg(width=6,height=6,pointsize=10,filename=tfile); "; std::string cmd1 = "plot(density(y, bw=bw/100, kernel=kernel), xlim=range(y)+c(-2,2), main=\"Kernel: "; std::string cmd2 = "\"); points(y, rep(0, length(y)), pch=16, col=rgb(0,0,0,1/4)); dev.off()"; std::string cmd = cmd0 + cmd1 + kernelstrings[m_kernel] + cmd2; // stick the selected kernel in the middle m_R.parseEvalQ(cmd); filterFile(); // we need to simplify the svg file for display by Qt m_svg->load(m_svgfile); }
bool visualStudioProject::createProjectFile(){ string project = ofFilePath::join(projectDir,projectName + ".vcxproj"); string user = ofFilePath::join(projectDir,projectName + ".vcxproj.user"); string solution = ofFilePath::join(projectDir,projectName + ".sln"); string filters = ofFilePath::join(projectDir, projectName + ".vcxproj.filters"); ofFile::copyFromTo(ofFilePath::join(templatePath,"emptyExample.vcxproj"),project,false, true); ofFile::copyFromTo(ofFilePath::join(templatePath,"emptyExample.vcxproj.user"),user, false, true); ofFile::copyFromTo(ofFilePath::join(templatePath,"emptyExample.sln"),solution, false, true); ofFile::copyFromTo(ofFilePath::join(templatePath,"emptyExample.vcxproj.filters"),filters, false, true); ofFile::copyFromTo(ofFilePath::join(templatePath,"icon.rc"), projectDir + "icon.rc", false, true); ofFile filterFile(filters); string temp = filterFile.readToBuffer(); pugi::xml_parse_result result = filterXmlDoc.load(temp.c_str()); if (result.status==pugi::status_ok) ofLogVerbose() << "loaded filter "; else ofLogVerbose() << "problem loading filter "; findandreplaceInTexfile(solution,"emptyExample",projectName); findandreplaceInTexfile(user,"emptyExample",projectName); findandreplaceInTexfile(project,"emptyExample",projectName); string relRoot = getOFRelPath(ofFilePath::removeTrailingSlash(projectDir)); if (relRoot != "../../../"){ string relRootWindows = relRoot; // let's make it windows friendly: for(int i = 0; i < relRootWindows.length(); i++) { if( relRootWindows[i] == '/' ) relRootWindows[i] = '\\'; } // sln has windows paths: findandreplaceInTexfile(solution, "..\\..\\..\\", relRootWindows); // vcx has unixy paths: //..\..\..\libs findandreplaceInTexfile(project, "../../../", relRoot); } return true; }
void filterFile(Chunk& chunk) { std::cout << "Filtering chunk " << chunk.id << std::endl; chunk.subChunks.erase(std::remove_if(chunk.subChunks.begin(), chunk.subChunks.end(), [](const Chunk& chunk) { return chunk.id == "VMAD" || chunk.id == "CLIP" || chunk.id == "PIXB" || chunk.id == "AAST" || chunk.id == "WRPW" || chunk.id == "WRPH" || chunk.id == "WRAP" || chunk.id == "IMAG" || chunk.id == "LUMI" || chunk.id == "DIFF" || chunk.id == "SPEC" || chunk.id == "REFL" || chunk.id == "TRAN" || chunk.id == "SMAN" || chunk.id == "SIDE" || chunk.id == "GLOS" || chunk.id == "RIND" // || chunk.id == "COLR" ; }), chunk.subChunks.end()); // Filter all subchunks for (Chunk& subChunk : chunk.subChunks) { filterFile(subChunk); } // Recalculate size after diving in chunk.size = chunk.getSize(); }