[vtkusers] how to access 3D volume

Ravi Samala raviksamala at yahoo.com
Mon Oct 3 09:32:21 EDT 2005


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. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20051003/f85a8589/attachment.htm>


More information about the vtkusers mailing list