[vtkusers] Rendering of 2 volumes.

Patrice Aussems p.aussems at skynet.be
Wed Aug 4 08:15:09 EDT 2004


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();  
	





More information about the vtkusers mailing list