[vtkusers] Problem displaying actors when volume is being renderer
abhishek gattani
abhishekg4u at gmail.com
Tue Aug 16 14:09:16 EDT 2005
In refrence to my recent post I am pasting the source code so that it can
better help in understanding my problem. My vtkActor object is not visible
when vtkVolume is rendered. Is this a vtk limitation? are there any
workarounds? I tired using a vtkTextActor and that did get overlayed over
the volume. However,I want to be able to highlight points inside the volume
dynamically. Any pointers will be deeply appreciated. Thanks,
vtkRenderer *aRenderer = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(aRenderer);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
vtkVolume16Reader *v16 = vtkVolume16Reader::New();
v16->SetDataDimensions (64,64);
v16->SetImageRange (1,93);
v16->SetDataByteOrderToLittleEndian();
v16->SetFilePrefix (argv[1]); //this is the
VTKData-release-4-2\Data\headsq\quarter data set
v16->SetDataSpacing (3.2, 3.2, 1.5);
//Volume Rendering the dataset
vtkPiecewiseFunction* opacityTF = vtkPiecewiseFunction::New();
opacityTF->AddPoint(0,0);
opacityTF->AddPoint(255,1);
//create the volume property to describe how the volume would look like
vtkVolumeProperty* volumeProperty = vtkVolumeProperty::New();
//set the color and opacity transfer function to the volume property
volumeProperty->SetScalarOpacity(opacityTF);
volumeProperty->ShadeOn();
volumeProperty->SetAmbient(0.1);
volumeProperty->SetDiffuse(0.7);
volumeProperty->SetSpecular(.2);
volumeProperty->SetSpecularPower(10);
//create the ray cast function to render the data
vtkVolumeRayCastCompositeFunction* compositeFunction =
vtkVolumeRayCastCompositeFunction::New();
//create the volume mapper
vtkVolumeRayCastMapper* volumeMapper = vtkVolumeRayCastMapper::New();
//set the ray cast function to be used by the volume mapper
volumeMapper->SetVolumeRayCastFunction(compositeFunction);
volumeMapper->SetInput(v16->GetOutput());
volumeMapper->IntermixIntersectingGeometryOn();
//create the volume to hold the volume mapper and the volume property
vtkVolume* volume = vtkVolume::New();
//set the volume mapper and the property
volume->SetMapper(volumeMapper);
volume->SetProperty(volumeProperty);
//add the volume prop to the renderer
//Add a cone
vtkConeSource *cone = vtkConeSource::New();
cone->SetHeight( 3.0 );
cone->SetRadius( 1.0 );
cone->SetResolution( 10 );
vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
coneMapper->SetInput( cone->GetOutput() );
vtkActor *coneActor = vtkActor::New();
coneActor->SetMapper( coneMapper );
vtkCamera *aCamera = vtkCamera::New();
aCamera->SetViewUp (0, 0, -1);
aCamera->SetPosition (0, 1, 0);
aCamera->SetFocalPoint (0, 0, 0);
aCamera->ComputeViewPlaneNormal();
aRenderer->AddVolume(volume);
aRenderer->AddActor(coneActor );
aRenderer->SetActiveCamera(aCamera);
aRenderer->ResetCamera ();
aCamera->Dolly(1.5);
// Set a background color for the renderer and set the size of the
// render window (expressed in pixels).
aRenderer->SetBackground(1,1,1);
renWin->SetSize(640, 480);
aRenderer->ResetCameraClippingRange ();
// Initialize the event loop and then start it.
iren->Initialize();
iren->Start();
Cheers,
Abhishek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050816/d0d2acb4/attachment.htm>
More information about the vtkusers
mailing list