[vtkusers] Re: how to access 3D volume

Divya Rathore divyaksr at iitk.ac.in
Tue Oct 4 00:47:01 EDT 2005


Check out ImagePlaneWidget.cpp (I would like to thank Dr. Nagarajan, raman_nagarajan at vsnl.net, a member of this list).

regards,
D. Rathore
  ----- Original Message ----- 
  From: Ravi Samala 
  To: vtkusers at vtk.org 
  Sent: Monday, October 03, 2005 7:02 PM
  Subject: [vtkusers] how to access 3D volume


  hi vtkusers,

   I am reading 2D slices and constructing a 3D volume, using the following code....

  vtkVolume16Reader *v16Img = vtkVolume16Reader::New();

  v16Img->SetDataDimensions (sizex,sizey);

  v16Img->SetImageRange (atoi(argv[3]),atoi(argv[4])); 

  v16Img->SetHeaderSize(HeadS);

  v16Img->SetFilePrefix (argv[2]); 

  v16Img->SetDataSpacing (0.1, 0.1, 0.5);

  v16Img->SetDataOrigin(0, 0, 0);

  cout<<"Image Volume Read...."<<endl;




  //CompositeFunction with option

  vtkVolumeRayCastCompositeFunction *compositeFunction = vtkVolumeRayCastCompositeFunction::New();

  compositeFunction->SetCompositeMethodToInterpolateFirst(); 



  //Mapper with selected RayCastFunction

  vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();

  volumeMapper->SetInput(v16Img -> GetOutput());

  volumeMapper->SetVolumeRayCastFunction(compositeFunction);



  // Create transfer mapping scalar value to opacity

  vtkPiecewiseFunction *pieceFunc = vtkPiecewiseFunction::New();

  pieceFunc->AddPoint(0, 0.0); // alpha value for the lower intensity limit

  pieceFunc->AddPoint(15000, 0.5); // alpha value for the upper intensity limit



  //Set Volume Property

  vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();

  volumeProperty->SetInterpolationTypeToLinear();

  volumeProperty->SetScalarOpacity(pieceFunc);

  volumeProperty->ShadeOn();



  //The special actor with properties

  vtkVolume *vol = vtkVolume::New();

  vol->SetMapper(volumeMapper);

  vol->SetProperty(volumeProperty);



  // An outline provides context around the data.

  vtkOutlineFilter *outlineData = vtkOutlineFilter::New();

  outlineData->SetInput((vtkDataSet *) v16Img->GetOutput());

  vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New();

  mapOutline->SetInput(outlineData->GetOutput());

  vtkActor *outline = vtkActor::New();

  outline->SetMapper(mapOutline);

  outline->GetProperty()->SetColor(0,0,0); 




  //Starting to Render

  vtkRenderer *renderer=vtkRenderer::New();

  renderer->AddVolume(vol); 

  renderer->SetBackground(1,1,1);



  vtkRenderWindow *renWin=vtkRenderWindow::New();

  renWin->SetSize(500,500);

  renWin->DoubleBufferOn(); 

  renWin->AddRenderer(renderer);


  vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();

  iren->SetRenderWindow(renWin);

  iren->Initialize(); 

  iren->Start();



  my question is : is there any way I can access individual slices and a point in the 3 dimensional space (like p(x,y,z).



  thanks in advance,



  Ravi.



------------------------------------------------------------------------------
  Yahoo! for Good
  Click here to donate to the Hurricane Katrina relief effort. 


------------------------------------------------------------------------------


  _______________________________________________
  This is the private VTK discussion list. 
  Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
  Follow this link to subscribe/unsubscribe:
  http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20051004/401100e1/attachment.htm>


More information about the vtkusers mailing list