[vtkusers] reading ascii files

de Boer Ingo I.deBoer at polytec.de
Thu Apr 1 05:47:37 EST 2004


Hi,

> I am trying to read a 3d file containing ascii data.
> Can you suggest how to go about it.

// Read some 3d points.
FILE *datei = fopen(argv[1],"rt");

vtkPolyData *data = vtkPolyData::New();
vtkPoints *points = vtkPoints::New();
	
int iCounter = 0;
while (!feof(datei))
{
 fprintf(stdout,"reading points: %i\r", iCounter);
 float x, y, z;
 fscanf(datei,"%f %f %f\n", &x, &y, &z);
 points->InsertPoint(iCounter++, x, y, z);
}
data->SetPoints(points);
fclose(datei);
fprintf(stdout,"\n\n");


greets 
  Ingo

---
Dr.-Ing. Ingo H. de Boer

Polytec GmbH
Polytec-Platz 1-7, 76337 Waldbronn, Germany
phone: ++49 7243 604 106
fax  : ++49 7243 604 255
  



More information about the vtkusers mailing list