[vtkusers] vtkImageData not rendering 0 row?

Mike Jackson imikejackson at gmail.com
Tue Apr 15 18:47:12 EDT 2008


I am trying to render a simple 2D array of data. I have selected to  
read my data into a vtkImageData object. The data is simply 1 or 0  
and so I am initializing the vtkImageData object as follows:

   image->SetScalarType(VTK_TYPE_UINT8);
   image->SetSpacing( 1.0, 1.0, 1.0 );
   image->SetOrigin( 0, 0, 0 );
   image->SetDimensions(1003, 445, 1);
   image->SetNumberOfScalarComponents( 1 );
   image->AllocateScalars();
   image->GetPointData()->GetScalars()->SetName("Precipitate Voxels");

I then just try to "draw" some test data along the y=0 and y=444 rows.
   vtkTypeUInt8* imgDataPtr = NULL;
   imgDataPtr = static_cast<vtkTypeUInt8*>( image->GetScalarPointer 
(0, 0, 0) );
   ::memset(imgDataPtr, 2, 1003);
   imgDataPtr = static_cast<vtkTypeUInt8*>( image->GetScalarPointer 
(0, 444, 0) );
   ::memset(imgDataPtr, 2, 1003);

When I render I use a lookup table to color by scalar value. The  
actual rendering though only shows a solid color along the y=444 row.  
If I instead change the code to be:
   vtkTypeUInt8* imgDataPtr = NULL;
   imgDataPtr = static_cast<vtkTypeUInt8*>( image->GetScalarPointer 
(0, 1, 0) );
   ::memset(imgDataPtr, 2, 1003);
   imgDataPtr = static_cast<vtkTypeUInt8*>( image->GetScalarPointer 
(0, 444, 0) );
   ::memset(imgDataPtr, 2, 1003);

.. Then I get a colored row along the bottom. I thought it might have  
been my crude vtk rendering code so I saved the data using the  
vtkXMLImageDataWriter class and then loaded it up in both ParaView  
CVS and ParaView 2.6.1. All show the same thing that the original vtk  
Render window showed which isn't what I _think_ I should be seeing.

I am pretty sure it is a simple error on my part, but I just do not  
see what I am doing wrong.

Thanks for any help or info or pointing me in the right direction.

--
Mike Jackson
imikejackson & gmail * com




More information about the vtkusers mailing list