void step(double& t){ int nx, ny, nz, alarm; double *A, *Bx, *By, *Bz, dt, *parx, *pary, *parz; nx = n[0]; ny = n[1]; nz = n[2]; parx = new double[(nz)*(ny)*5]; pary = new double[(nz)*5]; parz = new double[5]; A = new double[5]; Bx = new double[5]; By = new double[5]; Bz = new double[5]; init_aux(parx, pary, parz); dt = 42; for(int ix = 2; ix < nx+2; ix++){ for(int iy = 2; iy < ny+2; iy++){ for(int iz = 2; iz < nz+2;iz++){ if(obstacle(ix,iy,iz,0) > 0){ flux(&parx[(iy-2)*nz + (iz-2)], ix, iy, iz, Bx, 'X', dt); flux(&pary[iz-2], ix, iy, iz, By, 'Y', dt); flux(parz, ix, iy, iz, Bz, 'Z', dt); f(ix, iy, iz, A); for(int i = 0; i < 5; i++){ A[i] = A[i] + dt*(Bx[i]/dif[0][ix-2] + By[i]/dif[1][iy-2] + Bz[i]/dif[2][iz-2]); } f_inv(ix, iy, iz, A); } } } } recalc_dif_p(); t = t + dt; }
void hll_flux(double primL[], double primR[], double F[], int nq, double x, double w, struct parList *pars) { double sL, sR, sC; double U[nq], UL[nq], UR[nq], FL[nq], FR[nq]; prim2cons(primL, UL, x, 1.0, pars); prim2cons(primR, UR, x, 1.0, pars); flux(primL, FL, x, pars); flux(primR, FR, x, pars); wave_speeds(primL, primR, &sL, &sR, &sC, x, pars); int q; if(sL > w) for(q=0; q<nq; q++) { U[q] = UL[q]; F[q] = FL[q]; } else if(sR < w) for(q=0; q<nq; q++) { U[q] = UR[q]; F[q] = FR[q]; } else for(q=0; q<nq; q++) { U[q] = (sR*UR[q] - sL*UL[q] - (FR[q] - FL[q])) / (sR - sL); F[q] = (sR*FL[q] - sL*FR[q] + sL*sR*(UR[q] - UL[q])) / (sR - sL); } for(q=0; q<nq; q++) F[q] -= w*U[q]; }
ArrayB2 TransportSweeper::get_pin_flux(MeshTreatment treatment) const { assert(core_mesh_); ArrayB2 flux(core_mesh_->n_reg(treatment), n_group_); auto flux_it = flux.begin(); for (int ig = 0; ig < n_group_; ig++) { ArrayB1 flux_1g(flux(blitz::Range::all(), ig)); this->get_pin_flux_1g(ig, flux_1g, treatment); } return flux; }
void MidiWindow::saveConf() { QFile file("data/config/midi/"+ui->profilBox->currentText()+".conf"); if(file.open(QIODevice::WriteOnly)) { QTextStream flux(&file); flux.setCodec("UTF-8"); flux << ui->spinSwitchDisplay->value() << " "; flux << ui->spinBassTimeSpeed->value() << " "; flux << ui->spinGamma->value() << " "; flux << ui->spinBrightness->value() << " "; flux << ui->spinTimeSpeed->value() << " "; flux << ui->spin1Effect1->value() << " "; flux << ui->spin1Effect2->value() << " "; flux << ui->spin1Effect3->value() << " "; flux << ui->spin1Effect4->value() << " "; flux << ui->spin2Effect1->value() << " "; flux << ui->spin2Effect2->value() << " "; flux << ui->spin2Effect3->value() << " "; flux << ui->spin2Effect4->value() << " "; flux << ui->cloneFaderCheck->isChecked() << " "; file.close(); } else { QMessageBox::critical(this, "Midi profil", "Can't save the profil"); } }
QStringList ReadInput::readRPY() { QFile fichier(file); if(!fichier.exists()) { QMessageBox::information(0,"info","n'existe pas"); } if(fichier.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream flux(&fichier); if(!flux.atEnd()) { flux.seek(posRPY); QString line = flux.readLine(); QStringList list=recuperationRPY(line); posRPY=flux.pos(); fichier.close(); return list; } else { fichier.close(); QMessageBox::information(0,"info","fichier fermé"); } } else { QMessageBox::information(0,"info","ne peux pas ouvrir"); } return QStringList(); }
int main (int argc, char *argv[]) { double h0, hmin, hmax, tol, t, x[6], h, T; x[2]=1; x[3]=0; x[4]=0; x[5]=1; if (argc!=4 || sscanf(argv[1],"%lf",&hmin)!=1 || sscanf(argv[2],"%lf",&hmax)!=1 || sscanf(argv[3],"%lf",&tol)!=1 ) { fprintf(stderr, "./rf_pendol hmin hmax tol\n"); return -1; } while (scanf("%lf %lf %lf %lf",&x[0],&x[1],&h0, &T)==4) { fprintf(stderr, "x0,x1: %lf,%lf\n", x[0],x[1]); t=0; h=h0; flux(&t,x,&h,T,hmin,hmax,tol,4E2,N,pendol,NULL); printf("%.16G %.16G %.16G %G\n", t, x[0], x[1], h); printf("%.2lf %.2lf\n%.2lf %.2lf\n", x[2], x[4], x[3], x[5] ); } return 0; }
void ChoixConfig::MAJNoms() { QFile configName(QString("../RTKBASE/data/ConfigNames")); configName.open(QIODevice::ReadOnly | QIODevice::Text); QString line; QStringList list; QTextStream flux(&configName); while(! flux.atEnd()) { line = flux.readLine(); qDebug()<<line; list<<line; } configName.close(); ui->Custom1Button->setText(list[0].simplified()); ui->Custom2Button->setText(list[1].simplified()); ui->Custom3Button->setText(list[2].simplified()); ui->Custom4Button->setText(list[3].simplified()); ui->Custom5Button->setText(list[4].simplified()); ui->Custom6Button->setText(list[5].simplified()); ui->Custom7Button->setText(list[6].simplified()); ui->Custom8Button->setText(list[7].simplified()); ui->Custom9Button->setText(list[8].simplified()); ui->Custom10Button->setText(list[9].simplified()); ui->Custom11Button->setText(list[10].simplified()); ui->Custom12Button->setText(list[11].simplified()); }
//prend en paramètre le chemin vers le fichier et le score // enregistre seulement si supérieur au meilleur score void sauverMeilleurScore(QString fichier_nom,int score) { // Création d'un objet QFile QFile file(fichier_nom); // On ouvre notre fichier en lecture seule et on vérifie l'ouverture if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qWarning() <<fichier_nom; }// Création d'un objet QTextStream à partir de notre objet QFile QTextStream flux(&file); //récupération du meilleur score dans le fichier int score_fichier; flux >> score_fichier; file.close(); QFile file_w(fichier_nom); file_w.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file_w); // écriture du score actuel seulement s'il est meilleur que le précédent score enregistré qWarning() << QString::number(score); if (score > score_fichier) out << score; // optional, as QFile destructor will already do it: file_w.close(); }
Real aneurismFluxInVectorial(const Real& t, const Real& x, const Real& y, const Real& z, const ID& i) { //Components for Simone's mesh /* Real n1(-0.000019768882940); Real n2(-0.978289616345544); Real n3( 0.207242433298975); */ /* Real n1(-0.67460); Real n2(-0.19888); Real n3(-0.17089); */ Real n1(-0.671731456); Real n2(-0.204172511); Real n3(-0.712102827); Real flux(fluxFunctionAneurysm(t,x,y,z,i)); //Simone's area //Real area(0.0907122); // Computed with the triangle on the INLET boundary //Real area(0.0777195); //fluidsmooth Real area(0.193529); //fluidBig switch(i) { case 0: return n1*flux/area; case 1: return n2*flux/area; case 2: return n3*flux/area; default: return 0.0; } }
// in this function, we call the updateSoln function, compute // the update, then subtract off the extra pieces to return the // diffusive part of the update void EBLevelTGA::computeDiffusion(LevelData<EBCellFAB>& a_diffusiveTerm, LevelData<EBCellFAB>& a_phiOld, LevelData<EBCellFAB>& a_src, EBFluxRegister* a_fineFluxRegPtr, EBFluxRegister* a_crseFluxRegPtr, const LevelData<EBCellFAB>* a_crsePhiOldPtr, const LevelData<EBCellFAB>* a_crsePhiNewPtr, Real a_oldTime, Real a_crseOldTime, Real a_crseNewTime, Real a_dt, int a_level, bool a_zeroPhi, bool a_rhsAlreadyKappaWeighted ) { CH_assert(m_isEBLGSet); // first compute updated solution int ncomp = a_phiOld.nComp(); //the IntVect::Zero is important here. EBFluxFactory fact(m_eblg[a_level].getEBISL()); LevelData<EBFluxFAB> flux(m_grids[a_level], ncomp, IntVect::Unit, fact); BaseLevelTGA<LevelData<EBCellFAB>, EBFluxFAB, EBFluxRegister>::computeDiffusion (a_diffusiveTerm, a_phiOld, a_src, flux, a_fineFluxRegPtr, a_crseFluxRegPtr, a_crsePhiOldPtr, a_crsePhiNewPtr, a_oldTime, a_crseOldTime, a_crseNewTime, a_dt, a_level, a_zeroPhi, a_rhsAlreadyKappaWeighted); }
void EBLevelCrankNicolson::updateSoln(LevelData<EBCellFAB>& a_phiNew, LevelData<EBCellFAB>& a_phiOld, LevelData<EBCellFAB>& a_src, EBFluxRegister* a_fineFluxRegPtr, EBFluxRegister* a_crseFluxRegPtr, const LevelData<EBCellFAB>* a_crsePhiOldPtr, const LevelData<EBCellFAB>* a_crsePhiNewPtr, Real a_oldTime, Real a_crseOldTime, Real a_crseNewTime, Real a_dt, int a_level, bool a_zeroPhi, bool a_rhsAlreadyKappaWeighted, int a_fluxStartComponent) { CH_assert(m_isEBLGSet); // first compute updated solution int ncomp = a_phiOld.nComp(); EBFluxFactory fact(m_eblg[a_level].getEBISL()); //the IntVect::Zero is important here. LevelData<EBFluxFAB> flux(m_grids[a_level], ncomp, IntVect::Zero, fact); BaseLevelCrankNicolson<LevelData<EBCellFAB>, EBFluxFAB, EBFluxRegister>::updateSoln (a_phiNew, a_phiOld, a_src, flux, a_fineFluxRegPtr, a_crseFluxRegPtr, a_crsePhiOldPtr, a_crsePhiNewPtr, a_oldTime, a_crseOldTime, a_crseNewTime, a_dt, a_level, a_zeroPhi, a_rhsAlreadyKappaWeighted, a_fluxStartComponent); }
void CommandInterpretor::buildTree(std::string file){ std::vector<Command*> res; std::ifstream flux(file.c_str()); if (flux){ std::string line; std::string commandName; std::vector<std::string> commands; while (getline(flux,line)){ std::vector<std::string> splitted=splitLine(line); if (splitted[0]=="<command"){ commandName=splitted[1].substr(0,splitted[1].size()-1); }else if(splitted[0]=="</command>"){ std::vector<std::string> copy; for(unsigned i(0);i<commands.size();++i){ copy.push_back(commands[i]); } commands=std::vector<std::string>(); Command* toAdd=new Command(commandName,copy); res.push_back(toAdd); }else if(line.size()>=1){ commands.push_back(line); } } }else{ throw("[Erreur] Didn't succeed in opening .xml file"); } this->commands_=res; }
void batterie::timerEvent(QTimerEvent *event) { QFile fichier("/home/pierre/Documents/batterie/niveauBatterie.txt"); QString ligne; QTextStream flux(&fichier); if(fichier.open(QIODevice::ReadOnly | QIODevice::Text)) { while(!flux.atEnd()) { ligne = fichier.readLine(); } fichier.close(); } else ligne = "Impossible d'ouvrir le fichier !"; progressBar->setValue(ligne.toInt()); if(ligne.toInt() >= 90) setStyleSheet("QProgressBar::chunk{background-color:green}"); else if(ligne.toInt() >= 50 && ligne.toInt() < 90) setStyleSheet("QProgressBar::chunk{background-color:yellow}"); else if(ligne.toInt() >= 20 && ligne.toInt() < 50) setStyleSheet("QProgressBar::chunk{background-color:orange}"); else if(ligne.toInt() < 20) setStyleSheet("QProgressBar::chunk{background-color:red}"); }
void config::read_config(){ QFile fichier(fileName); fichier.open(QIODevice::ReadOnly | QIODevice::Text); QTextStream flux(&fichier); // traitement des ligne du fichier QString ligne; int n_ligne = 0; while(! flux.atEnd()) { ligne = flux.readLine(); if (n_ligne == 1){ //IP du serveur IP = ligne; qDebug() << IP; }else if (n_ligne == 3){ //port du serveur port = ligne; qDebug() << port; }else if (n_ligne == 5){ //port du serveur data_container = ligne; qDebug() << data_container; } n_ligne += 1; } }
/** * @brief Article::load */ void Article::load() { //1er cas : si on a déjà chargé les modifications faites sur le fichier, on ne le recharge pas. if (loaded) return; //2e cas: else { QFile fichier(NotesManager::getInstance()->getFilename(id)); //2e cas a: on vérifie que le fichier existe if (fichier.open(QIODevice::ReadOnly | QIODevice::Text)){ QTextStream flux(&fichier); //On enlève la première ligne : type de la note flux.readLine(); //Lecture du titre de la note title = flux.readLine(); //Lecture de la description de la note content = flux.readAll(); loaded = true; fichier.close(); } //2e cas b else { NoteException("Erreur : tentative de charger un fichier non crée"); } } }
map<int, pair<int, int> > FileParser::retrieveTowers() { map<int, pair<int, int> > towers; // Map distance-estimation des tours ifstream flux(this->file.c_str()); string delimiter = "\t"; // Délimiteur entre la distance et l'estimation if (flux) { string ligne; int i = 0; int j = 1; while (getline(flux, ligne)) { if (i > 1) { // Les deux premières lignes représentent le nombre de tireurs et de tours string distanceStr = ligne.substr(0, ligne.find(delimiter)); ligne.erase(0, ligne.find(delimiter) + delimiter.length()); string estimateStr = ligne.substr(0, ligne.find(delimiter)); int distance = atoi(distanceStr.c_str()); int estimate = atoi(estimateStr.c_str()); pair<int, int> p = make_pair(distance, estimate); towers[j++] = p; } i++; } } else { cout << "Impossible d'ouvrir le fichier " << this->file << endl; } flux.close(); return towers; }
void scnreader_model::SavePartInTxt(int d, int f, QString pathname) { //open the file QFile file(pathname); //If there is an error QString MesErreur=" The file"; MesErreur.push_back(pathname); MesErreur.push_back("have not been saved, check the write permission!"); //Test if you can write into the file if(file.open(QIODevice::WriteOnly )){ //if you can, initialize flu and line QTextStream flux(&file); //defines the codec of file flux.setCodec("UTF-8"); //get coordinates points of cloud and write it for(int i=d;i<=f; i++){ if(this->nuage.contains(i)) { QVector<PointGL *> * vec=this->nuage.value(i); for(int j=0;j<vec->size(); j++){ flux << QString::number(vec->at(j)->getX()) << "\t" << QString::number(vec->at(j)->getY()) << "\t" << QString::number(vec->at(j)->getZ()) << "\t" << endl; } } } file.close(); }else throw Erreur(MesErreur.toStdString()); }
//********************************************************************** PHX_EVALUATE_FIELDS(NeumannResidual,workset) { residual.deep_copy(ScalarT(0.0)); for (std::size_t cell = 0; cell < workset.num_cells; ++cell) { for (std::size_t ip = 0; ip < num_ip; ++ip) { normal_dot_flux(cell,ip) = ScalarT(0.0); for (std::size_t dim = 0; dim < num_dim; ++dim) { normal_dot_flux(cell,ip) += normal(cell,ip,dim) * flux(cell,ip,dim); } } } // const Intrepid::FieldContainer<double> & weighted_basis = workset.bases[basis_index]->weighted_basis; const Teuchos::RCP<const BasisValues2<double> > bv = workset.bases[basis_index]; for (std::size_t cell = 0; cell < workset.num_cells; ++cell) { for (std::size_t basis = 0; basis < residual.dimension(1); ++basis) { for (std::size_t qp = 0; qp < num_ip; ++qp) { residual(cell,basis) += normal_dot_flux(cell,qp)*bv->weighted_basis_scalar(cell,basis,qp); } } } if(workset.num_cells>0) Intrepid::FunctionSpaceTools:: integrate<ScalarT>(residual, normal_dot_flux, (workset.bases[basis_index])->weighted_basis_scalar, Intrepid::COMP_BLAS); }
/** * @brief HtmlExportStrategy::exportNote * @param n * @param header * @return */ QString HtmlExportStrategy::exportNote(Note *n, bool header){ QString exp; QTextStream flux(&exp); flux.setCodec("UTF-8"); //header flux<<"<html>"<<endl<<"<head>"<<endl<<"</head>"<<endl<<"<body>"<<endl; if (n == NULL) { return ""; } if (dynamic_cast<Article*>(n) != NULL) { flux<<HtmlExportStrategy::exportNoteArt(dynamic_cast<Article*>(n)); } else if (dynamic_cast<Image*>(n) != NULL) { flux<<HtmlExportStrategy::exportNoteIm(dynamic_cast<Image*>(n)); } else if (dynamic_cast<Audio*>(n) != NULL) { flux<<HtmlExportStrategy::exportNoteAud(dynamic_cast<Audio*>(n)); } else if (dynamic_cast<Video*>(n) != NULL) { flux<<HtmlExportStrategy::exportNoteVid(dynamic_cast<Video*>(n)); } else if (dynamic_cast<Document*>(n) != NULL) { flux<<HtmlExportStrategy::exportNoteDoc(dynamic_cast<Document*>(n)); } else throw NoteException("erreur : le type n'est pas conforme"); //footer flux<<"</body>"<<endl<<"</html>"<<endl; return exp; }
void MainWindow::Supprimer_Session(QString Nom_Session) { int reponse = QMessageBox::question(this, "Vraiment?", "Etes-vous sûr de vouloir supprimer la session "+Nom_Session+" ?", QMessageBox::Yes | QMessageBox::No); if (reponse == QMessageBox::Yes) { //toute la philosophie est de ne modifier que le fichier liste_session et de réinstancier le paramètre F_Accueil ! QFile *fichier = Fenetre_Accueil->get_Liste_Sessions(); fichier->open(QIODevice::ReadWrite | QIODevice::Text); QTextStream flux(fichier); QString contenu; while (!flux.atEnd()) { QString ligne=flux.readLine(); if (ligne!=Nom_Session) contenu=contenu.append(ligne+"\n"); } fichier->resize(0); fichier->write(contenu.toLatin1(),contenu.size()); fichier->close(); F_Accueil *Nlle_fenetre = new F_Accueil; Nlle_fenetre->setParent(this); Nlle_fenetre->move(0,0); Fenetre_Accueil=Nlle_fenetre; QObject::connect(Fenetre_Accueil,SIGNAL(Signal_Ouvrir_Session(QString)),this,SLOT(Afficher_Fenetre_Session(QString))); Retour_Accueil(); } }
//********************************************************************** PHX_EVALUATE_FIELDS(InterfaceResidual,workset) { residual.deep_copy(ScalarT(0.0)); for (std::size_t cell = 0; cell < workset.num_cells; ++cell) { for (std::size_t ip = 0; ip < num_ip; ++ip) { normal_dot_flux(cell,ip) = ScalarT(0.0); for (std::size_t dim = 0; dim < num_dim; ++dim) { normal_dot_flux(cell,ip) += normal(cell,ip,dim) * flux(cell,ip,dim); } } } // const Kokkos::DynRankView<double,PHX::Device> & weighted_basis = this->wda(workset).bases[basis_index]->weighted_basis; const Teuchos::RCP<const BasisValues2<double> > bv = this->wda(workset).bases[basis_index]; for (std::size_t cell = 0; cell < workset.num_cells; ++cell) { for (std::size_t basis = 0; basis < residual.dimension(1); ++basis) { for (std::size_t qp = 0; qp < num_ip; ++qp) { residual(cell,basis) += normal_dot_flux(cell,qp)*bv->weighted_basis_scalar(cell,basis,qp); } } } if(workset.num_cells>0) Intrepid2::FunctionSpaceTools:: integrate<ScalarT>(residual, normal_dot_flux, (this->wda(workset).bases[basis_index])->weighted_basis_scalar, Intrepid2::COMP_CPP); }
/*--------------------------------------------------- * Time march use Runge-Kutta method * ------------------------------------------------*/ void RKtvd3(int ik, double dt) { int nc; void flux(double **rhs); void fluxchem(double **rhs); void updateq(int nc, double **q, double **qs, double **RHS, double dt, int ik); void updateqs(int nc, double **q, double **qs, double **RHS, double dt, int ik); void chemsource(int nc, double **q, double **qs, double *tem, double **RHS); nc = config1.Nc; if(config1.gasModel == 0) { /* Perfect Gas Solver */ flux(rhs); updateq(nc, U.q, U.qs, rhs, dt, ik); } else { /* Real Gas Solver */ fluxchem(rhs); if(config1.reacModel!= 0) chemsource(nc, U.q, U.qs, U.tem, rhs); updateqs(nc, U.q, U.qs, rhs, dt, ik); } }
void hllc_flux(double primL[], double primR[], double F[], int nq, double x, double w, struct parList *pars) { double sL, sR, sC; double U[nq], UL[nq], UR[nq], FL[nq], FR[nq]; prim2cons(primL, UL, x, 1.0, pars); prim2cons(primR, UR, x, 1.0, pars); flux(primL, FL, x, pars); flux(primR, FR, x, pars); wave_speeds(primL, primR, &sL, &sR, &sC, x, pars); int q; if(sL > w) for(q=0; q<nq; q++) { U[q] = UL[q]; F[q] = FL[q]; } else if(sR < w) for(q=0; q<nq; q++) { U[q] = UR[q]; F[q] = FR[q]; } else if(sL <= w && w <= sC) { Ustar(primL, U, sL, sC, x, pars); for(q=0; q<nq; q++) F[q] = FL[q] + sL*(U[q]-UL[q]); } else if(sC < w && w <= sR) { Ustar(primR, U, sR, sC, x, pars); for(q=0; q<nq; q++) F[q] = FR[q] + sR*(U[q]-UR[q]); } else { printf("ERROR: wave speeds in HLLC. sL=%.12lg, s=%.12lg, sR=%.12lg\n", sL, sC, sR); } for(q=0; q<nq; q++) F[q] -= w*U[q]; }
KOKKOS_INLINE_FUNCTION void Fourier<EvalT, Traits>::operator () (const int i) const { for (PHX::index_size_type qp = 0; qp < num_qp; ++qp) for (PHX::index_size_type dim = 0; dim < num_dim; ++dim) flux(i,qp,dim) = - density(i,qp) * dc(i,qp) * grad_temp(i,qp,dim); }
/** * @brief HtmlExportStrategy::exportNoteIm * @param i * @return */ QString HtmlExportStrategy::exportNoteIm(Image* i) { QString exp; QTextStream flux(&exp); flux.setCodec("UTF-8"); // Génération du flux correspondant à l'HTML flux<<"<img src=\""<<i->getPath()<<"\" title =\""<<i->getTitle()<<"\" alt = \""<<i->getDescription()<<"\" >"; return exp; }
void Note::save(){ QFile fichier(NotesManager::getInstance().getPath()+QString::number(id)); fichier.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream flux(&fichier); flux<<toQString(); fichier.close(); isModified = false; }
/** * @brief HtmlExportStrategy::exportNoteArt * @param a * @return */ QString HtmlExportStrategy::exportNoteArt(Article* a) { QString exp; QTextStream flux(&exp); flux.setCodec("UTF-8"); // Génération du flux correspondant à l'HTML flux<<"<h1><b>"<<a->getTitle()<<"</b></h1>"<<endl; flux<<"<p>"<<a->getContent()<<"</p>"<<endl; return exp; }
/** * Methode qui retourne le template HTML des documents * @return le template HTML */ QString ValidDocument::loadTemplate(){ QFile file(QDir::fromNativeSeparators(QDir::homePath()+"/.QFacturation/template.html")); file.open(QIODevice::ReadOnly | QIODevice::Text); QTextStream flux(&file); QString content=flux.readAll(); flux.flush(); file.close(); return content; }
PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent) { // Variables load from the config.ini file QFile configFile(QCoreApplication::applicationDirPath() + "/data/config/config.ini"); QString fileHomePage; QString fileSearchEngine; QString fileDownloadPath; QString fileZoomTextOnly; bool isZoomEnabled; QString fileJs; bool isJsEnabled; QString fileFlash; bool isFlashEnabled; if (!configFile.exists()) { QMessageBox::critical(NULL, tr("Error"), tr("<p>Configuration file missing ! Please try to reinstall.</p><p>The application will stop.</p>")); qApp->quit(); } else { if (configFile.open(QIODevice::ReadOnly)) { QTextStream flux(&configFile); flux >> fileHomePage; flux >> fileSearchEngine; flux >> fileDownloadPath; flux >> fileZoomTextOnly; flux >> fileJs; flux >> fileFlash; if (fileZoomTextOnly == "true") { isZoomEnabled = true; } else { isZoomEnabled = false; } if (fileJs == "true") { isJsEnabled = true; } else { isJsEnabled = false; } if (fileFlash == "true") { isFlashEnabled = true; } else { isFlashEnabled = false; } configFile.close(); } }
Mesh Mesh::readObj(QString path) { Mesh m; // lecture d'un objet QFile QFile file(path); printf( "\n%s has been loaded\n\n",path.toLocal8Bit().data() ); // On ouvre notre fichier en lecture seule et on vérifie l'ouverture if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return m; // Création d'un objet QTextStream a partir de notre objet QFile QTextStream flux(&file); while (!flux.atEnd()) { QString line = flux.readLine().toLocal8Bit().data(); QStringList opperation = line.split(" "); if (opperation.at(0) == "v") { // qDebug() << opperation.at(0); Geometry::Point3D p = Geometry::Point3D(opperation.at(1).toDouble(),opperation.at(2).toDouble(),opperation.at(3).toDouble()); m.m_tabPoint.push_back(p); } else if (opperation.at(0) == "vn") { Geometry::Vector vn = Geometry::Vector(opperation.at(1).toDouble(),opperation.at(2).toDouble(),opperation.at(3).toDouble()); m.m_tabNorme.push_back(vn); } else if (opperation.at(0) == "f") { for (int i=1;i<4;i++) { QStringList v = opperation.at(i).split("//"); m.m_tabTopologie.push_back(v.at(0).toInt()-1); m.m_tabTopologie.push_back(v.at(1).toInt()-1); } } } // On choisit le codec correspondant au jeu de caractère que l'on souhaite ; ici, UTF-8 // flux.setCodec("UTF-8"); // Écriture des différentes lignes dans le fichier //flux << data << endl; return m; }