
Untitled
By: a guest on
Jun 30th, 2012 | syntax:
None | size: 1.00 KB | hits: 12 | expires: Never
void CDonneesGraphe::load_array_3d(string &file_name,
vector<CPoint3f> &tab)
{
cout << "loading " <<file_name << " : debut..." << endl;
ifstream fichier( file_name.data() );
char line[TAILLE_MAX + 1] = "";
if (! fichier) {
cout<<"probleme lecture fichier : "<<file_name<<" inexistant ou deja ouvert\n";
return;
}
// ce test échoue si le fichier n'est pas ouvert
string ligne; // variable contenant chaque ligne lue
// cette boucle s'arrête dès qu'une erreur de lecture survient
while ( getline( fichier, ligne ) )
{
// afficher la ligne à l'écran
strcpy(line, ligne.data());
CPoint3f p(RNOVA, RNOVA, RNOVA);
int col_count = sscanf(line, "%f %f %f", &p.X, &p.Y, &p.Z);
cout << col_count << endl;
cout << p.X << endl;
cout << p.Y << endl;
cout << p.Z << endl;
cout << line << endl;
if (col_count == 3)
{
tab.push_back(p);
}
cout << line << endl;
}
cout << "loading " << tab.size() << file_name << " : fin" << endl;
fichier.close();
}