[vtkusers] Help vtkPNMReader

Anderson Cordeiro anderson at programmer.net
Thu Dec 9 23:40:19 EST 2004


Hi!

This is my first try with volume rendering in VTK. I have 188 ppm files and want to use them to view a volume. The following code works, but shows only a black box. What is wrong/missing?

void main ()
{
        vtkRenderer *ren1 = vtkRenderer::New();
        vtkRenderWindow *renWin = vtkRenderWindow::New();
        renWin->AddRenderer(ren1);

        vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
        iren->SetRenderWindow(renWin);

// reads 188 104x128 PPM files

        vtkPNMReader *pnm = vtkPNMReader::New();
        pnm->SetDataExtent(0,103,0,127,0,188);
        pnm->SetFilePrefix("..\\PPM-Imgs\\a_vm1001-m.ppm");

// volume stuff

        vtkVolumeProperty * volumeProperty = vtkVolumeProperty::New();
        volumeProperty->ShadeOn();
        volumeProperty->SetInterpolationTypeToLinear();

        vtkVolumeRayCastCompositeFunction * compositeFunction = vtkVolumeRayCastCompositeFunction::New();
        vtkVolumeRayCastMapper * volumeMapper = vtkVolumeRayCastMapper::New();
        volumeMapper->SetInput(pnm->GetOutput());
        volumeMapper->SetVolumeRayCastFunction(compositeFunction);

        vtkVolume * volume = vtkVolume::New();
        volume->SetMapper(volumeMapper);
        volume->SetProperty(volumeProperty);

        ren1->AddVolume(volume);
        ren1->SetBackground(0.2,0.3,0.4);
        renWin->SetSize(800,500);

// interact with data

        renWin->Render();
        ren1->GetActiveCamera()->Zoom(1.4);
        renWin->Render();
        iren->Start();

// Clean up

        ren1->Delete();
        renWin->Delete();
        iren->Delete();
        pnm->Delete();
        volumeProperty->Delete();
        compositeFunction->Delete();
        volumeMapper->Delete();
        volume->Delete();
}

Thank you
Anderson
-- 
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm




More information about the vtkusers mailing list