[vtkusers] ironProt + vtkVolumeRayCastMapper example
Paul McGuinness
mcguinpg at maths.tcd.ie
Thu Jul 3 08:34:15 EDT 2003
Hi All,
Below is my example of raycasting that I downloaded from the
internet on the the ironProt.vtk datafile. Some of you will recognise this
the code below, but I cannot get it to compile on vtk-4.2.2.
It throws up the error:
Building object file ironpot.o...
/home/cs/pmcguinn/visual/project/ironpot.cxx: In function `int main (int,
char **)':
/home/cs/pmcguinn/visual/project/ironpot.cxx:152: no matching function for
call to
`vtkVolumeRayCastMapper::SetInput (vtkStructuredPoints *)'
/usr/local/include/vtk/vtkVolumeMapper.h:59: candidates are: void
vtkVolumeMapper::SetInput
(vtkImageData *)
I have spent the last two days playing around with the code modifying it,
using vtkVolumeMapper, converting structuredpoints into Imagedata,
but nothing seems to get it to work.
Has anyone got this code to work using vtk 4.2.2?
Thanks.
Paul.
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkStructuredPointsReader.h"
#include "vtkPiecewiseFunction.h"
#include "vtkVolumeProperty.h"
#include "vtkVolumeRayCastCompositeFunction.h"
#include "vtkVolumeRayCastMapper.h"
#include "vtkVolume.h"
#include "vtkColorTransferFunction.h"
#include "vtkCamera.h"
int main( int argc, char *argv[] )
{
vtkRenderer *renderer = vtkRenderer::New();
vtkRenderWindow *renWindow = vtkRenderWindow::New();
vtkRenderWindowInteractor *interactor =
vtkRenderWindowInteractor::New();
vtkStructuredPointsReader *reader =
vtkStructuredPointsReader::New();
vtkPiecewiseFunction *opacity = vtkPiecewiseFunction::New();
vtkColorTransferFunction *color =
vtkColorTransferFunction::New();
vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
vtkVolumeRayCastCompositeFunction *compositeFunction =
vtkVolumeRayCastCompositeFunction::New();
vtkVolumeRayCastMapper *volumeMapper =
vtkVolumeRayCastMapper::New();
vtkVolume *volume = vtkVolume::New();
renWindow->SetSize(400,400);
reader->SetFileName("ironProt.vtk");
reader->Update();
opacity->AddSegment(0, 0.0, 255, 0.5);
color->AddRGBPoint(64, 1.0, 0.0, 0.0);
color->AddRGBPoint(128, 1.0, 1.0, 0.0);
color->AddRGBPoint(196, 0.0, 1.0, 1.0);
volumeProperty->SetColor(color);
volumeProperty->SetScalarOpacity(opacity);
volumeProperty->SetInterpolationTypeToLinear();
volumeProperty->ShadeOn();
volumeMapper->SetInput(reader->GetOutput());
volumeMapper->SetVolumeRayCastFunction(compositeFunction);
volume->SetMapper(volumeMapper);
volume->SetProperty(volumeProperty);
renderer->SetBackground(0.2, 0.2, 0.8);
renderer->AddVolume(volume);
renderer->GetActiveCamera()->Azimuth(20.0);
renderer->GetActiveCamera()->Dolly(1.60);
renderer->ResetCameraClippingRange();
interactor->SetRenderWindow(renWindow);
renWindow->AddRenderer(renderer);
renWindow->Render();
interactor->Start();
renderer->Delete();
renWindow->Delete();
interactor->Delete();
reader->Delete();
opacity->Delete();
color->Delete();
volumeProperty->Delete();
compositeFunction->Delete();
volumeMapper->Delete();
volume->Delete();
return 0;
}
More information about the vtkusers
mailing list