[vtkusers] Processing images from a .vtk file

Daniele Avitabile d.avitabile at gmail.com
Fri Mar 2 14:49:14 EST 2007


Hi everybody,

I am really new of vtk, and I am trying to write a code that reads an ASCII
.vtk file containing a grid defined by structured points and a scalar field.
I want to obtain an image of the scalar field plotted on the structured
grid. At the moment I wrote the following code

 vtkStructuredPointsReader * reader = vtkStructuredPointsReader::New();
    reader->SetFileName("plotSolution.vtk");

  vtkImageViewer * viewer = vtkImageViewer::New();
    //viewer->SetInput(imageData);
    viewer->SetInputConnection(reader->GetOutputPort());
    viewer->SetZSlice(0);
    viewer->SetColorWindow(20.0);
    viewer->SetColorLevel(0.0);
    viewer->Render();

  usleep(5000000);

  reader->Delete();
  viewer->Delete();

but the image displayed is simply black. The file I am using is correct (it
is displayed correctly if I read it from Paraview).
Does anybody know how to do (or where to find an example) to read from a
.vtk file to an ImageViewer?

Thanks in advance for your help.

Daniele
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070302/c0a980bf/attachment.htm>


More information about the vtkusers mailing list