Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 30th, 2012  |  syntax: None  |  size: 1.00 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. void CDonneesGraphe::load_array_3d(string &file_name,
  2.                 vector<CPoint3f> &tab)
  3. {
  4.         cout << "loading " <<file_name << " : debut..." << endl;
  5.         ifstream fichier( file_name.data() );
  6.         char line[TAILLE_MAX + 1] = "";
  7.         if (! fichier) {
  8.                 cout<<"probleme lecture fichier : "<<file_name<<" inexistant ou deja ouvert\n";
  9.                 return;
  10.         }
  11.         // ce test échoue si le fichier n'est pas ouvert
  12.         string ligne; // variable contenant chaque ligne lue
  13.  
  14.         // cette boucle s'arrête dès qu'une erreur de lecture survient
  15.         while ( getline( fichier, ligne ) )
  16.         {
  17.                 // afficher la ligne à l'écran
  18.                 strcpy(line, ligne.data());
  19.                 CPoint3f p(RNOVA, RNOVA, RNOVA);
  20.                 int col_count = sscanf(line, "%f %f %f", &p.X, &p.Y, &p.Z);
  21.     cout << col_count << endl;
  22.     cout << p.X << endl;
  23.     cout << p.Y << endl;
  24.     cout << p.Z << endl;
  25.     cout << line << endl;
  26.                 if (col_count == 3)
  27.                 {
  28.                         tab.push_back(p);
  29.                 }
  30.                 cout << line << endl;
  31.         }
  32.         cout << "loading " << tab.size() << file_name << " : fin" << endl;
  33.   fichier.close();
  34. }