Valerie,<br>you have to create a vtkpolyData instance. I have a function that reads a XYZ ASCII file (whose name you pass as argument) and creates the polydata (actually, inside the polydata, instances od vtkPoints and vtkCellArray are used). Once you have the polydata, you´ll proceed with visualization using the vtkPolyData -> vtkPolyDataMapper -> vtkActor pipeline
<br><br>Here is the function.<br><br> Luca<br><br><br>vtkPolyData *xyzreader (char *name) {<br> <br> double x[3];<br> FILE *f;<br> char LINE[256];<br> <br> <br> if ( (f = fopen(name, "r")) == NULL ) {
<br> fprintf (stderr, "Error while opening file %s!\n", name);<br> return NULL;<br> }<br> vtkPoints *points = vtkPoints::New();<br> vtkPolyData *poly = vtkPolyData::New();<br>
vtkCellArray *conn = vtkCellArray::New();<br> <br> // Create geometry of point cloud<br> while ( fgets(LINE, 256, f) != NULL ) {<br> <br> if (sscanf(LINE, "%lf %lf %lf", &x[0], &x[1], &x[2]) != 3) {
<br> fprintf (stderr, "I/O Error!\n");<br> fclose (f);<br> return NULL;<br> }<br> points->InsertNextPoint(x);<br> } // End of while loop<br> <br> // Create topology of point cloud. This is necessary!
<br> for (int i = 0; i < points->GetNumberOfPoints(); i++)<br> conn->InsertNextCell(1, &i);<br> <br> poly->SetPoints(points);<br> poly->SetVerts(conn);<br> points->Delete();
<br> conn->Delete();<br> <br> fclose (f);<br> return poly;<br> }<br>