[vtkusers] 3D Image Display
Fabian Torres
dae.wong at gmail.com
Thu Mar 29 12:50:48 EDT 2012
Hi
I`m trying to create a 3D vtk image and initialized it in black. But when I
display the image on a renderer window I only get a flat 2D black Image.
How can I display the 3D cube created.
Here is the code that I`m using
vtkSmartPointer<vtkImageData> volume = vtkSmartPointer<vtkImageData>::New();
volume->SetNumberOfScalarComponents(3);
volume->SetScalarType(VTK_UNSIGNED_CHAR);
volume->SetOrigin(0,0,0);
volume->SetDimensions(volumeExtent[0]+10,volumeExtent[1]+10,volumeExtent[2]+10);
for(int i=0; i<volumeExtent[0]+9; i++){
for(int j=0; j<volumeExtent[1]+9; j++){
for(int k=0; k<volumeExtent[2]+9; k++){
unsigned char* pixel = static_cast<unsigned
char*>(volume->GetScalarPointer(i,j,k));
pixel[0] = 1;
pixel[1] = 1;
pixel[2] = 1;
}
}
}
vtkSmartPointer<vtkImageActor> volumeActor =
vtkSmartPointer<vtkImageActor>::New();
volumeActor->SetInput(volume);
volumeActor->SetPosition(volumeOrigin[0]+5,volumeOrigin[1]+5,volumeOrigin[2]+5);
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->SetBackground(1, 1, 1);
renderer->AddActor(volumeActor);
vtkSmartPointer<vtkRenderWindow> renwin =
vtkSmartPointer<vtkRenderWindow>::New();
renwin->AddRenderer(renderer);
renwin->Render();
--
Fabián Torres Robles
Maestria en Ciencias en Ingeniería Electrónica
Ingeniería en Sistemas Electrónicos
tel. 58081280, 0445534661338
e-mail fabian.trobles at gmail.com, dae.wong at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120329/c698e4e7/attachment.htm>
More information about the vtkusers
mailing list