void FileTests::testLockUnlock() { // Create pre-condition #ifndef _WIN32 CPPUNIT_ASSERT(!system("echo someStuff > testdir/existingFile")); #else CPPUNIT_ASSERT(!system("echo someStuff > testdir\\existingFile")); #endif CPPUNIT_ASSERT(exists("existingFile")); #ifndef _WIN32 File file1("testdir/existingFile"); File file2("testdir/existingFile"); #else File file1("testdir\\existingFile"); File file2("testdir\\existingFile"); #endif CPPUNIT_ASSERT(file1.lock(false)); CPPUNIT_ASSERT(!file1.lock(false)); CPPUNIT_ASSERT(file2.lock(false)); CPPUNIT_ASSERT(file2.unlock()); CPPUNIT_ASSERT(file1.unlock()); CPPUNIT_ASSERT(file1.lock()); CPPUNIT_ASSERT(file2.lock()); CPPUNIT_ASSERT(file2.unlock()); CPPUNIT_ASSERT(file1.unlock()); }
int main(int argc, char **argv) { try { // write std::map<std::string, int> m = { {"a",1}, {"b",2} }; std::map<std::string, std::vector<double>> mv = { {"a",{1.0, 2.0}}, {"b",{2.0, 3.0, 4.0}} }; { h5::file file1("test_map.h5", H5F_ACC_TRUNC); h5::group top1(file1); h5_write(top1, "map_int", m); h5_write(top1, "map_vec", mv); } // read std::map<std::string, int> mm = { {"c",1} }; std::map<std::string, std::vector<double>> mmv = { {"c",{1.0}} }; h5::file file2("test_map.h5", H5F_ACC_RDONLY); h5::group top2(file2); h5_read(top2, "map_int", mm); h5_read(top2, "map_vec", mmv); for (auto const & val: mm) std::cout << val.first << " " << val.second << std::endl; for (auto const & val: mmv) { std::cout << val.first << std::endl; for (auto const & x: val.second) std::cout << x << std::endl; } } TRIQS_CATCH_AND_ABORT; }
int main(int argc, const char *argv[]){ if(argc<3){ std::cerr << "umerge is copyright (c) 2016 by Ed Trager and released under GPL 2.0." << std::endl; std::cerr << "Usage: umerge file1 file2 <optional_prefix>" << std::endl; exit(1); } bool hasPrefix=false; std::string prefix; if(argc==4){ hasPrefix=true; prefix=argv[3]; } std::ifstream file1(argv[1]); std::ifstream file2(argv[2]); std::string line1; std::string line2; while (std::getline(file1, line1)){ std::getline(file2,line2); if(hasPrefix){ std::cout << prefix << "\t" << line1 << "\t" << line2 << std::endl; }else{ std::cout << line1 << "\t" << line2 << std::endl; } } return 0; }
int mergeGraphs(QString fileName1, QString fileName2, ATMProgressIFC *prg) { fileName1 = fileName1.split("\n")[0]; QFile file1(fileName1); if (!file1.open(QIODevice::ReadOnly)) { return -1; } QDataStream fileStream1(&file1); NarratorGraph *graph1 = new NarratorGraph(fileStream1, prg); file1.close(); fileName2 = fileName2.split("\n")[0]; QFile file2(fileName2); if (!file2.open(QIODevice::ReadOnly)) { return -1; } QDataStream fileStream2(&file2); NarratorGraph *graph2 = new NarratorGraph(fileStream2, prg); file2.close(); graph1->mergeWith(graph2); delete graph2; QFile file(fileName1.remove(".por") + "Merged.por"); if (!file.open(QIODevice::ReadWrite)) { return -1; } QDataStream fileStream(&file); graph1->serialize(fileStream); file.close(); delete graph1; return 0; }
void MainWindow::backup() { QDateTime date = QDateTime::currentDateTime(); QString path = QDir::currentPath()+"/database/"; QString path2 = QDir::currentPath() + "/backup/"; QFile file1(path+"data.db"); if(!file1.open(QIODevice::ReadOnly)) { QMessageBox::information(NULL,tr("打开数据库失败"),tr("无法打开数据库!")); return; } QString fileName = QDateTime::currentDateTime().toString(Qt::ISODate); for(int i=0;i<fileName.size();i++) { if(fileName.at(i) == ':' || fileName.at(i) == '-') fileName.remove(fileName.at(i)); } QString name =path2+fileName+".db"; qDebug()<<"data name:"<<name; if( file1.copy(name)) { QMessageBox::information(NULL,tr("备份成功"),QString(tr("数据库已备份至%1文件夹下.\n文件名为%2.db")) .arg(path2).arg(fileName)); } else QMessageBox::information(NULL,tr("备份"),tr("备份失败!")); if(file1.isOpen()) file1.close(); }
//============================================================================= // Book cluster tuple //============================================================================= void TbTupleWriter::bookClusters() { NTupleFilePtr file1(ntupleSvc(), "/NTUPLES/FILE1"); NTuplePtr nt(ntupleSvc(), "/NTUPLES/FILE1/TbTupleWriter/Clusters"); // Check if already booked. if (nt) return; nt = ntupleSvc()->book("/NTUPLES/FILE1/TbTupleWriter/Clusters", CLID_ColumnWiseTuple, "nTuple of Clusters"); nt->addItem("clID", m_clID); nt->addItem("clGx", m_clGx); nt->addItem("clGy", m_clGy); nt->addItem("clGz", m_clGz); nt->addItem("clLx", m_clLx); nt->addItem("clLy", m_clLy); nt->addItem("clTime", m_clTime); nt->addItem("clHTime", m_clHTime); nt->addItem("clSize", m_clSize); nt->addItem("clCharge", m_clCharge); nt->addItem("clIsTracked", m_clTracked); nt->addItem("clPlane", m_clPlane); nt->addItem("clEvtNo", m_clEvtNo); nt->addItem("clNHits", m_clN, 0, (int)m_maxclustersize); nt->addIndexedItem("hRow", m_clN, m_clhRow); nt->addIndexedItem("hCol", m_clN, m_clhCol); nt->addIndexedItem("sCol", m_clN, m_clsCol); nt->addIndexedItem("hHTime", m_clN, m_clhHTime); nt->addIndexedItem("hToT", m_clN, m_clhToT); }
TEST_F( PlatformFileSystemTests, File_Ops ) { std::vector< std::wstring > file_names; IP::File::Enumerate_Matching_Files( TEST_FILE_PATTERN, file_names ); ASSERT_TRUE( file_names.size() == 0 ); std::basic_ofstream< wchar_t > file1( TEST_FILE1.c_str(), std::ios_base::out | std::ios_base::trunc ); file1 << L"test1\n"; file1.close(); std::basic_ofstream< wchar_t > file2( TEST_FILE2.c_str(), std::ios_base::out | std::ios_base::trunc ); file2 << L"test2\n"; file2.close(); IP::File::Enumerate_Matching_Files( TEST_FILE_PATTERN, file_names ); ASSERT_TRUE( file_names.size() == 2 ); for ( uint32_t i = 0; i < file_names.size(); i++ ) { IP::File::Delete_File( file_names[ i ] ); } file_names.clear(); IP::File::Enumerate_Matching_Files( TEST_FILE_PATTERN, file_names ); ASSERT_TRUE( file_names.size() == 0 ); }
void PanoOutputDialog::EnableOutputOptions() { // check, if hdr images wxFileName file1(wxString(m_pano.getImage(0).getFilename().c_str(), HUGIN_CONV_FILENAME)); wxString ext1=file1.GetExt().Lower(); if(ext1==wxT(".hdr") || ext1==wxT(".exr")) { XRCCTRL(*this, "output_hdr", wxCheckBox)->SetValue(true); XRCCTRL(*this, "output_hdr", wxCheckBox)->Enable(true); XRCCTRL(*this, "output_hdr_bitmap", wxCheckBox)->Enable(true); return; } //hide hdr controls for simple interface if(m_guiLevel==GUI_SIMPLE) { XRCCTRL(*this, "output_hdr", wxCheckBox)->Hide(); XRCCTRL(*this, "output_hdr_bitmap", wxCheckBox)->Hide(); XRCCTRL(*this, "output_hdr_format_label", wxStaticText)->Hide(); XRCCTRL(*this, "output_hdr_format", wxChoice)->Hide(); XRCCTRL(*this, "output_hdr_compression_label", wxStaticText)->Hide(); XRCCTRL(*this, "output_hdr_tiff_compression", wxChoice)->Hide(); Layout(); GetSizer()->Fit(this); }; //single image or normal panorama, enable only normal output if(m_pano.getNrOfImages()==1 || m_stacks.size() >= 0.8 * m_pano.getNrOfImages()) { XRCCTRL(*this, "output_normal", wxCheckBox)->SetValue(true); XRCCTRL(*this, "output_normal", wxCheckBox)->Enable(true); XRCCTRL(*this, "output_normal_bitmap", wxCheckBox)->Enable(true); if(m_pano.getNrOfImages()==1 || m_stacks.size()==m_pano.getNrOfImages()) { return; }; }; XRCCTRL(*this, "output_fused_blended", wxCheckBox)->Enable(true); XRCCTRL(*this, "output_fused_blended_bitmap", wxCheckBox)->Enable(true); XRCCTRL(*this, "output_blended_fused", wxCheckBox)->Enable(true); XRCCTRL(*this, "output_blended_fused_bitmap", wxCheckBox)->Enable(true); if(m_guiLevel!=GUI_SIMPLE) { XRCCTRL(*this, "output_hdr", wxCheckBox)->Enable(true); XRCCTRL(*this, "output_hdr_bitmap", wxCheckBox)->Enable(true); }; if(m_pano.getNrOfImages() % m_stacks.size() == 0) { XRCCTRL(*this, "output_fused_blended", wxCheckBox)->SetValue(true); } else { if(m_exposureLayers.size()==1) { XRCCTRL(*this, "output_normal", wxCheckBox)->SetValue(true); } else { XRCCTRL(*this, "output_blended_fused", wxCheckBox)->SetValue(true); }; }; };
void readscore(int x) { score sc; fstream file("scores2.dat",ios::in); if(!file) { sc.setscore(x); cleardevice(); ofstream file1("scores2.dat"); file1.write((char *)&sc,sizeof(sc)); file1.close(); } else { file.read((char *)&sc,sizeof(sc)); file.close(); if(sc.retscore()<x) { sc.setscore(x); ofstream error("scores2.dat"); if((error.write((char *)&sc,sizeof(sc)))==0) { cout<<"\nERROR ERROR"; getch(); } error.close(); } } cleardevice(); file.close(); }
bool compareFiles(const QString& filename1, const QString& filename2) { // Compare sizes QFile file1(filename1); QFile file2(filename2); if (file1.size() != file2.size()) { return false; } // Compare contents bool equal = true; if (file1.open(QFile::ReadOnly) && file2.open(QFile::ReadOnly)) { while (!file1.atEnd()) { if (file1.read(1000) != file2.read(1000)) { equal = false; break; } } file1.close(); file2.close(); } else { equal = false; } return equal; }
void deletepatient::on_Delete_clicked() { QFile file("patient.dat"); QFile file1("temp.dat"); file.remove(); file1.rename("patient.dat"); pa=new prompta("Record deleted successfully!",this); pa->move(300,200); pa->show(); QTimer *msgBoxCloseTimer = new QTimer(this); msgBoxCloseTimer->setInterval(3000); msgBoxCloseTimer->setSingleShot(true); connect(msgBoxCloseTimer, SIGNAL(timeout()), pa, SLOT(reject())); // or accept() msgBoxCloseTimer->start(); pa->exec(); for(int i=0;i<ui->tableWidget->rowCount();i++) ui->tableWidget->removeRow(0); }
void jetPlot(std::string runNumber = "276282") { std::string fileName = "/data/dasu/l1tCaloSummary-" + runNumber + ".root"; TFile file1(fileName.c_str()); TTree *tree = (TTree*) file1.Get("Events"); TH1F *cJetPT = new TH1F("CentralJetPT", "PT Distribution", 300, 0, 300); tree->Project("CentralJetPT", "l1extraL1JetParticles_uct2016EmulatorDigis_Central_L1TCaloSummaryTest.obj.m_state.p4Polar_.fCoordinates.fPt"); cJetPT->SetLineColor(kBlue); TH1F *fJetPT = new TH1F("ForwardJetPT", "PT Distribution", 300, 0, 300); tree->Project("ForwardJetPT", "l1extraL1JetParticles_uct2016EmulatorDigis_Forward_L1TCaloSummaryTest.obj.m_state.p4Polar_.fCoordinates.fPt"); fJetPT->SetLineColor(kRed); TCanvas *canvas = new TCanvas(); gPad->SetLogy(1); gStyle->SetOptStat(0); cJetPT->Draw("HIST,E1"); fJetPT->Draw("SAME,HIST,E1"); TLegend *lg=new TLegend(0.55,0.55,0.85,0.85); lg->SetFillColor(kWhite); lg->AddEntry(cJetPT,"Central Jet PT","lf"); lg->AddEntry(fJetPT,"Forward Jet PT","lf"); lg->Draw(); fileName = "JetPlot-" + runNumber + ".png"; canvas->SaveAs(fileName.c_str()); }
inline BOOL Factory::GetExportPath(astring &strPath) { astring strKey = "ConfVideoExportKey"; astring strSysPath; if (m_SysPath.GetSystemPath(strSysPath) == FALSE) { return FALSE; } #ifdef WIN32 #ifndef _WIN64 astring strPathDefault = strSysPath + "vidstor\\export\\"; #else astring strPathDefault = strSysPath + "vidstor64\\export\\"; #endif #else astring strPathDefault = strSysPath + "vidstor/export/"; #endif if (m_Conf.GetCmnParam(strKey, strPath) == FALSE) { strPath = strPathDefault; m_Conf.SetCmnParam(strKey, strPath); Poco::File file1(strPath); file1.createDirectories(); } return TRUE; }
int main(){ CRNG rng; scalar_t m1[2][1] = {0, 0}; Mat mean_matrix(2, 1, CV_64FC1, m1); scalar_t m2[2][2] = {small_deviation, 0, 0, small_deviation}; Mat sigma_matrix(2, 2, CV_64FC1, m2); CCSV file1(".\\Matlab\\test1.csv"); CCSV file2(".\\Matlab\\test2.csv"); for(int i = 0; i < 1000; ++i){ vector<scalar_t> mean(2); mean[0] = 0; mean[1] = 0; vector<scalar_t> d(2); d[0] = 0; d[1] = 0; vector<vector<scalar_t> > body(100); for(int j = 0; j < 100; ++j){ vector<scalar_t> stem = get(mean_matrix, sigma_matrix, rng); mean[0] += stem[0]; mean[1] += stem[1]; body[j] = stem; } mean[0] /= 100; mean[1] /= 100; file1.put(mean); for(int j = 0; j < 100; ++j){ d[0] += (body[j][0]-mean[0])*(body[j][0]-mean[0]); d[1] += (body[j][1]-mean[1])*(body[j][1]-mean[1]); } d[0] /= 100; d[1] /= 100; file2.put(d); } }
void Blosum::print(const char * filename){ ofstream file1(filename); if(file1.is_open()){ }else{ cerr << "Error: couldn't open file " << filename << endl; exit(-1); } map<string, int>::iterator myit, myit1; for(myit=index.begin();myit!=index.end();++myit){ file1 << myit->first << "\t"; } file1 << endl; for(myit=index.begin();myit!=index.end();++myit){ for(myit1=index.begin();myit1!=index.end();++myit1){ file1 << values[index[myit->first]][index[myit1->first]] << "\t"; } file1 << endl; } file1.close(); }
ListAddress readFile(QString &openFilename, int maxCount) { QFile file1(openFilename); if (!file1.open(QIODevice::ReadOnly)) return ListAddress(); ListAddress addrs; QTextStream in(&file1); QTextCodec *defaultTextCodec = QTextCodec::codecForName("Windows-1251"); if (defaultTextCodec) in.setCodec(defaultTextCodec); int nRow=0; while (!in.atEnd()) { QString line = in.readLine(); if(!line.isEmpty()) { if(nRow>0) { Address a; a.setRawAddress(line); addrs.append(a); } nRow++; } //оставливаем обработку если получено нужное количество строк if(maxCount>0 && nRow >= maxCount) break; } file1.close(); return addrs; }
const bool EvaUserSetting::loadBuddyList( /*TQObject * receiver*/) { if(!isDirExisted(getEvaUserDir())){ TQDir d; if(!d.mkdir(getEvaUserDir())) return false; } //建立chat的新的库文件 sqlite3 *db=NULL; int rc; TQString sql=NULL; char *errmsg = 0; TQString fullNameSql = getEvaUserDir() + "/"+SqlFileName; TQFile file1(fullNameSql); if(!file1.exists()){ file1.close(); printf("建立chat库文件\n"); rc=sqlite3_open(fullNameSql.data(),&db); sql="CREATE TABLE chat( \ buddy INTEGER, sender INTEGER, sNick text,\ receiver INTEGER,rNick text,\ isNormal INTEGER,\ message text,time INTEGER,fontSize INTEGER,flag INTEGER,\ blue INTEGER,green INTEGER,red INTEGER,\ isQunMsg INTEGER);"; sqlite3_exec( db , sql.utf8().data() , 0 , 0 , &errmsg ); printf("create db chat :%s\n",errmsg); sqlite3_exec( db, "CREATE index idxchat on chat(buddy,isQunMsg,time)",0,0,&errmsg); sqlite3_exec( db, "CREATE index idxchata on chat(sender,receiver,time,isQunMsg)",0,0,&errmsg); printf("create index chat :%s\n",errmsg); sqlite3_exec( db,"CREATE TABLE sysmsg (time INTEGER,msgType INTEGER,type INTEGER,fromQQ INTEGER,toQQ INTEGER,message text,internalQunID INTEGER,commander INTEGER,code text,token text)",0,0,&errmsg); printf("create db sysmsg :%s\n",errmsg); sqlite3_exec( db, "CREATE index idxsys on sysmsg(time,msgType,type,fromQQ,toQQ,internalQunID,commander)",0,0,&errmsg); printf("create index sysmsg :%s\n",errmsg); }
void GaussSeidel::plotIterationLog() { const std::string cmd_filename = "plotconfig_it.gnu"; const std::string pic_filename = "iteractive_it.png"; const std::string dat1_filename = "data_it.txt"; // Solução numérica std::ofstream file1(dat1_filename.c_str()); for(tInteger i=0; i<nit; i++) file1<<i<<"\t"<<QtoD(L[i]/L[0])<<std::endl; file1.close(); std::ofstream file3(cmd_filename.c_str()); file3 << "set terminal pngcairo enhanced font \"arial,12\" size 1600, 1000 \n" "set output '" << pic_filename <<"'\n" "#set key inside right top vertical Right noreverse enhanced autotitles box linetype -1 linewidth 1.000\n" "set grid\n" "set logscale y\n" "set format y \"10^{%L}\" \n" "set lmargin 10 \n" "set title \"DESEMPENHO DE ITERAÇÃO \\n itmax = "<<imax<<" itol = "<<QtoD(itol)<<" nit = "<<nit-1<<"\"\n" "set ylabel \"L^{n}/L^{0}\" \n" "set xlabel 'Número de iterações'\n" "plot '" <<dat1_filename<<"' t\"\" with lines lt 2 lc 1 lw 2"; file3.close(); const std::string cmd1 = "gnuplot " + cmd_filename; // Gráfico com GNUPLOT const std::string cmd2 = "eog " + pic_filename; // Visualizador de imagem std::system(cmd1.c_str()); std::system(cmd2.c_str()); }
//============================================================================= // Book track tuple //============================================================================= void TbTupleWriter::bookTracks() { NTupleFilePtr file1(ntupleSvc(), "/NTUPLES/FILE1"); NTuplePtr nt(ntupleSvc(), "/NTUPLES/FILE1/TbTupleWriter/Tracks"); // Check if already booked. if (nt) return; nt = ntupleSvc()->book("/NTUPLES/FILE1/TbTupleWriter/Tracks", CLID_ColumnWiseTuple, "nTuple of Tracks"); nt->addItem("TkID", m_TkID); nt->addItem("TkTime", m_TkTime); nt->addItem("TkHTime", m_TkHTime); nt->addItem("TkNCl", m_TkNCl, 0, 10); nt->addItem("TkX", m_TkX0); nt->addItem("TkY", m_TkY0); nt->addItem("TkTx", m_TkTx); nt->addItem("TkTy", m_TkTy); nt->addItem("TkChi2PerNdof", m_TkChi2ndof); nt->addIndexedItem("TkClId", m_TkNCl, m_TkClId); nt->addItem("TkEvt",m_TkEvt); nt->addItem("TkNTg",m_TkNTg,0,(int)m_maxTriggers); nt->addIndexedItem("TkTgId",m_TkNTg,m_TkTgId); nt->addIndexedItem("TkTgPlane",m_TkNTg,m_TkTgPlane); nt->addIndexedItem("TkXResidual",m_TkNCl, m_TkXResidual); nt->addIndexedItem("TkYResidual",m_TkNCl, m_TkYResidual); }
void AddFocusDialog::on_tableWidget_itemClicked(QTableWidgetItem *item) { if (item->column()==0) { QString tmp; tmp.clear(); tmp+=".";tmp+="\\";tmp+="\\"; tmp+=vec[item->row()];tmp+="\\";tmp+="\\"; tmp+="information.txt"; QFile file(tmp); QTextStream in(&file); file.open(QIODevice::ReadOnly); QString t;t.clear();int i=0; while (!in.atEnd()) { QString s=in.readLine(); if (i!=0) {t+=s;t+="\n";}i++; } file.close(); QTextEdit* te=new QTextEdit; te->setText(t); te->show(); } else { QString tmp; tmp.clear(); tmp+=".";tmp+="\\";tmp+="\\"; tmp+=user;tmp+="\\";tmp+="\\"; tmp+="friends.txt"; QFile file(tmp); QTextStream in(&file); file.open(QIODevice::ReadOnly); bool check=false; while (!in.atEnd()) { QString s=in.readLine(); if (s==vec[item->row()]) { check=true; } } file.close(); if (!check) { QFile file1(tmp); QTextStream out(&file1); file1.open(QIODevice::Append); out<<vec[item->row()]<<endl; file1.close(); } QMessageBox* me=new QMessageBox; me->setText("Ìí¼Ó³É¹¦£¡"); me->show(); } pFD->setUser(user); }
details::details(QWidget *parent) : QDialog(parent), ui(new Ui::details) { ui->setupUi(this); this->setWindowTitle("TICKET CONFIRMED!!!"); QString filename="D:\\qt\\irctc3\\p-detail.txt"; QFile file(filename); if(!file.exists()){ qDebug() << "NO exist "<<filename; }else{ qDebug() << filename<<" exits..."; } QString line; QString name,age,gender; int i=0; ui->label->setText(ui->label->text()+"\nS.No.\tName\tAge\tGender\n"); if (file.open(QIODevice::ReadOnly | QIODevice::Text)){ QTextStream stream(&file); while (!stream.atEnd()){ line = stream.readLine(); name = line.split(" ").at(0); age = line.split(" ").at(1); gender=line.split(" ").at(2); i++; ui->label->setText(ui->label->text()+"\n"+QString::number(i)+"\t"+name+"\t"+age+"\t"+gender); } } file.close(); QString src,dst,date,arr_time,fare,avail,train_no,train_name,day; QString filename1="D:\\qt\\irctc3\\select.txt"; QFile file1(filename1); if(!file1.exists()){ qDebug() << "NO exist "<<filename1; }else{ qDebug() << filename1<<" exits..."; } QString line1; if (file1.open(QIODevice::ReadOnly | QIODevice::Text)){ QTextStream stream1(&file1); while (!stream1.atEnd()){ line1 = stream1.readLine(); train_no= line1.split(" ").at(0); train_name= line1.split(" ").at(1); arr_time= line1.split(" ").at(2); avail= line1.split(" ").at(3); fare= line1.split(" ").at(4); } } file1.close(); int f=fare.toInt(); f=(i)*f; ui->label->setText(ui->label->text()+"\n\nFare Details:\nTicket Fare: "+QString ::number(f)+"\nService Charge: 22.90\ntotal Fare: "+QString :: number(f+22.9) ); }
void Run(int PolynomialOrder, int Href, std::string GeoGridFile, int div) { int pOrder = PolynomialOrder; TPZReadGIDGrid myreader; TPZGeoMesh * gmesh = myreader.GeometricGIDMesh(GeoGridFile); { // Print Geometrical Base Mesh std::ofstream arg1("BaseGeoMesh.txt"); gmesh->Print(arg1); std::ofstream file1("BaseGeoMesh.vtk"); // In this option true -> let you use shrink paraview filter // PrintGMeshVTK(gmesh,file1); TPZVTKGeoMesh::PrintGMeshVTK(gmesh,file1, true); } // Modifying Geometric Mesh RefinamentoUniforme(gmesh, Href); { // Print Geometrical refined Base Mesh std::ofstream arg1("RefineGeoMesh.txt"); gmesh->Print(arg1); std::ofstream file1("RefineGeoMesh.vtk"); TPZVTKGeoMesh::PrintGMeshVTK(gmesh,file1, true); } TPZCompMesh * cmesh = ComputationalMesh(gmesh,PolynomialOrder); TPZAnalysis *MyAnalysis = new TPZAnalysis(cmesh); TPZSkylineStructMatrix strskyl(cmesh); MyAnalysis->SetStructuralMatrix(strskyl); TPZStepSolver<STATE> direct; direct.SetDirect(ELDLt); MyAnalysis->SetSolver(direct); REAL deltaT = 0.5; REAL maxTime = 10.0; SolveSystemTransient(deltaT, maxTime, MyAnalysis,cmesh); // MyAnalysis->Run(); // std::string plotfile("MyProblemSolution.vtk"); // PosProcess(myreader.fProblemDimension,*MyAnalysis, plotfile, div); }
void DecisionTree::FlushVpidToFile(vpid& v, const char* filename){ filebuf fb; fb.open(filename, ios::out); ostream file1(&fb); for(int i=0; i<v.size(); i++) file1 << v[i].first << "," << v[i].second << endl; fb.close(); }
bool init_unit_test() { std::ofstream file1("mapgen_1.csv"); file1 << csv1; std::ofstream file2("mapgen_2.csv"); file2 << csv2; return true; }
void FocusDialog::on_tableWidget_itemClicked(QTableWidgetItem *item) { if (item->column()==0) { QString tmp; tmp.clear(); tmp+=".";tmp+="\\";tmp+="\\"; tmp+=data[item->row()];tmp+="\\";tmp+="\\"; tmp+="information.txt"; QFile file(tmp); QTextStream in(&file); file.open(QIODevice::ReadOnly); QString t;t.clear();int i=0; while (!in.atEnd()) { QString s=in.readLine(); if (i!=0) {t+=s;t+="\n";}i++; } file.close(); QTextEdit* te=new QTextEdit; te->setText(t); te->show(); } else { QString tmp; tmp.clear(); tmp+=".";tmp+="\\";tmp+="\\"; tmp+=user;tmp+="\\";tmp+="\\"; tmp+="friends.txt"; QFile file(tmp); QTextStream in(&file); file.open(QIODevice::ReadOnly); QVector<QString> tmp_d;tmp_d.clear(); while (!in.atEnd()) { QString s=in.readLine(); if (s!=data[item->row()]) { tmp_d.push_back(s); } } file.close(); QFile file1(tmp); QTextStream out(&file1); file1.open(QIODevice::WriteOnly); for (int i=0;i<tmp_d.size();i++) out<<tmp_d[i]<<endl; file1.close(); QMessageBox* me=new QMessageBox; me->setText("取消成功!"); me->show(); } this->setUser(user); }
void overlay_plots(const string& fFile0, const string& fFile1, const double fYmax, const string& fPlot, const string& fLegendEnt1, const string& fLegendEnt2, const string& fName) { TProfile *p[2]; TFile file0(fFile0.c_str()); TDirectoryFile *subDir = (TDirectoryFile*)file0.Get("offsetAnalysis"); p[0] = (TProfile*)subDir->Get(fPlot.c_str()); TFile file1(fFile1.c_str()); subDir = (TDirectoryFile*)file1.Get("offsetAnalysis"); p[1] = (TProfile*)subDir->Get(fPlot.c_str()); p[0]->SetTitleOffset(1.5,"Y"); p[0]->GetXaxis()->SetTitleSize(0.04); p[0]->GetYaxis()->SetTitleSize(0.04); double ymax = ((p[0]->GetMaximum())>(p[1]->GetMaximum())) ? p[0]->GetMaximum() : p[1]->GetMaximum(); p[0]->GetYaxis()->SetRangeUser(0.,fYmax); TCanvas *c = new TCanvas("c","",800,800); c->cd(); p[0]->SetLineWidth(3); p[0]->SetLineColor(kRed); p[0]->SetFillColor(kRed); p[0]->Draw("hist"); p[1]->SetLineWidth(3); p[1]->SetLineColor(kBlack); p[1]->SetMarkerStyle(20); p[1]->SetMarkerColor(kBlack); p[1]->Draw("sames"); TLegend *legend = new TLegend(.57,.77,.9,.87); legend->SetBorderSize(1); legend->SetFillColor(0); // legend->SetFillStyle(0); legend->SetMargin(0.12); legend->AddEntry(p[0],fLegendEnt1.c_str(),"l"); legend->AddEntry(p[1],fLegendEnt2.c_str(),"l"); legend->Draw(); TLatex l; l.SetTextAlign(12); l.SetTextSize(0.04); l.SetTextFont(62); l.SetNDC(); l.DrawLatex(0.15,0.85,"CMS 2009 Preliminary"); string fileName = fName; c->SetGridy(); c->SaveAs(fileName.c_str()); delete legend; delete c; }
int linecnt(const char *file) { std::set<std::string> store; int line_cnt=0; { std::ifstream file1(file); std::string s; while (file1 && ! file1.fail() && ! file1.eof()) { std::getline(file1,s); line_cnt++; }; }; return line_cnt; };
void Importer::debug(const QString line, QChar symb) { QFile file1("1251.txt"); if (!file1.open(QFile::WriteOnly | QFile::Truncate)) return; QTextStream out(&file1); out.setCodec("UTF-8"); out << "line0 " << line[0].unicode() << " " << symb.unicode(); file1.close(); }
void append(const char *dstn,const char *src) { std::ofstream output(dstn,std::ios::app); { std::ifstream file1(src); std::string s; while (file1 && ! file1.fail() && ! file1.eof()) { std::getline(file1,s); output.write(s.c_str(),s.length()); output.write("\n",1); }; }; };
void Backend::writeSystemLastLogin(QString user, QString desktop){ QFile file1("/usr/local/share/PCDM/.lastlogin"); if(!file1.open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text)){ Backend::log("PCDM: Unable to save last login data to system directory"); }else{ QTextStream out(&file1); out << user << "\n" << desktop; file1.close(); } }