[vtkusers] Rendering of 2 volumes.

John Biddiscombe jbiddiscombe at skippingmouse.co.uk
Wed Aug 4 09:33:26 EDT 2004


You'll need to turn on IntermixGeometry on the volume so that it blends the
polydata actors with it's own image. It's in the mapper somewhere I think

JB

----- Original Message ----- 
From: "Patrice Aussems" <p.aussems at skynet.be>
To: <vtkusers at vtk.org>
Sent: Wednesday, August 04, 2004 1:15 PM
Subject: [vtkusers] Rendering of 2 volumes.


> Hi,
>
> I want to render 2 different volume in a same window but when I try I
> just have the volume of the head (vtkPNGReader) and not the vtkSphere.
> Can Sb help me to solve my problem?
>
> thanks
>
> Patrice Aussems
>
> Here are a sample of my code:
>
>
> vtkSphereSource *sphere = vtkSphereSource::New();
>   sphere->SetThetaResolution(7);
>   sphere->SetPhiResolution(7);
>
>
> vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
>   sphereMapper->SetInput(outlinesphere->GetOutput());
>
> vtkActor * sphereActor = vtkActor::New();
>   sphereActor->SetMapper(sphereMapper);
>
>
>
> vtkPNGReader * readerMR = vtkPNGReader::New();
>   readerMR->SetFilePattern("MR/%d.png");
>   readerMR->SetDataExtent(1,256,1,256,0,126);
>   readerMR->SetDataSpacing(1,1,1.5);
>   readerMR->SetDataOrigin(0,0,0);
>   readerMR->UpdateWholeExtent();
>
> vtkImageData *imageDatal = vtkImageData::New();
>   imageDatal = readerMR->GetOutput();
>
> vtkVolumeRayCastCompositeFunction  *compositeFunctionMR =
> vtkVolumeRayCastCompositeFunction::New();
>
> vtkVolumeRayCastMapper *volumeMapperMR = vtkVolumeRayCastMapper::New();
>   volumeMapperMR->SetInput(readerMR->GetOutput());
>   volumeMapperMR->SetVolumeRayCastFunction(compositeFunctionMR);
>
>
> vtkPiecewiseFunction *tfunMR = vtkPiecewiseFunction::New();
>   tfunMR->AddPoint(75,   0.0);
>   tfunMR->AddPoint(76,   0.01);
>   tfunMR->AddPoint(125,  0.01);
>   tfunMR->AddPoint(126,  0.01);
>   tfunMR->AddPoint(225,  0.01);
>   tfunMR->AddPoint(226,  0);
>
>
> vtkVolumeProperty *volumePropertyMR = vtkVolumeProperty::New();
>   volumePropertyMR->SetScalarOpacity(tfunMR);
>   volumePropertyMR->SetInterpolationTypeToLinear();
>   volumePropertyMR->ShadeOn();
>
>
> newvolMR = vtkVolume::New();
>   newvolMR->SetMapper(volumeMapperMR);
>   newvolMR->SetProperty(volumePropertyMR);
>
>
> vtkOutlineFilter *outlineMR = vtkOutlineFilter::New();
>   outlineMR->SetInput((vtkDataSet *)imageDatal);
>
>
> vtkPolyDataMapper *outlineMapperMR = vtkPolyDataMapper::New();
>   outlineMapperMR->SetInput(outlineMR->GetOutput());
>
> vtkActor *outlineActorl = vtkActor::New();
>   outlineActorl->SetMapper(outlineMapperMR);
>   outlineActorl->GetProperty()->SetColor(0,0,1);
>
>
> vtkCamera *Cameralost= vtkCamera::New();
>   Cameralost->SetViewUp (0, 0, 1);
>   Cameralost->SetPosition(ren->GetActiveCamera()->GetPosition());
>   Cameralost->SetFocalPoint(ren->GetActiveCamera()->GetFocalPoint());
>   Cameralost->ComputeViewPlaneNormal();
>   Cameralost->Zoom (0.5);
>
> ren2->SetBackground(1,1,1);
> ren2->AddActor(sphereActor);
> ren2->AddActor(outlineActorl);
> ren2->AddVolume(newvolMR);
> ren2->SetActiveCamera(Cameralost);
>
>
> renwin2->Render();
>
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list