[vtkusers] VolumeRender a 3D volume

Toh Da Jun tohdj at bii.a-star.edu.sg
Mon Jun 20 00:02:11 EDT 2005


 Hi all.

I took my mind off the development over the weekend...and voila...I 
solved the problem on monday morning!

I created a vtkImageData to represent the 3D volume and to hold the 
scalar values as well. This replaces the vtkPoints etc etc.

here's a snapshot...


Toh Da Jun


> Toh Da Jun wrote:
>
>> Hi all!
>>
>> I'm trying to volumerender a 3D volume. This volume is simply a 
>> rectangular box, somewhat like the one shown in 
>> "/VTK/IO/Tesing/Tcl/gaussian.tcl".
>> I need to be able to alter the colour display of the 3D Volume. 
>> Therefore, I use a set of 3D points to represent the volume, where I 
>> can change the scalar values and the colour display is altered.
>>
>> The problem is that the display does not reflect the changes.
>>
>>
>> _*
>> *_But when I alter the values in "m4_TotalDensity.cube" and run 
>> gaussian.tcl...the changes are correctly displayed (notice the red 
>> portions).
>>
>>
>> _*
>> here's a copy of my Java codes.*_
>>
>> public void create() {
>>         vtkUnstructuredGrid usGrid = new vtkUnstructuredGrid();
>>
>>         // Set up the Cell and Scalar arrays for use to display 
>> colour information
>>         m_Points = new vtkPoints();
>>         m_aCells = new vtkCellArray();
>>         m_aScalars = new vtkIntArray();
>>        
>>         int ID = 0;
>>         for (int k=0; k<m_iDimension_Z; k++)
>>             for (int i=0; i<m_iDimension_Y; i++) {
>>                 for (int j=0; j<m_iDimension_X; j++) {
>>                     m_Points.InsertPoint( ID, i, j, k );
>>                     m_aScalars.InsertValue( ID, k);
>>                     m_aCells.InsertNextCell(1);
>>                     m_aCells.InsertCellPoint( ID );
>>                     ID++;
>>                 }
>>             }
>>       
>>         usGrid.SetPoints(m_Points);
>>         usGrid.GetPointData().SetScalars(m_aScalars);
>>        
>>         // Gaussian Splatter
>>         vtkGaussianSplatter popSplatter = new vtkGaussianSplatter();
>>         popSplatter.SetInput(usGrid);
>>         
>> popSplatter.SetSampleDimensions(m_iDimension_X,m_iDimension_Y,m_iDimension_Z);
>>         popSplatter.SetRadius(0.01);
>>         popSplatter.ScalarWarpingOff();
>>
>>         vtkImageShiftScale readerSS = new vtkImageShiftScale();
>>         readerSS.SetInput(popSplatter.GetOutput());
>>         readerSS.SetScale(1);
>>         readerSS.SetOutputScalarTypeToUnsignedChar();
>>
>>         makeColourOpacityFilter();
>>        
>>         // Create a property for the volume and set the transfer 
>> functions.
>>         // Turn shading on and use trilinear interpolation
>>         vtkVolumeProperty volumeProperty = new vtkVolumeProperty();
>>         volumeProperty.SetColor(cTFun);//colorTransferFunction);//cTFun);
>>         
>> volumeProperty.SetScalarOpacity(opacityTransferFunction);//oTFun);
>>         volumeProperty.SetInterpolationTypeToLinear();
>>       
>>         // Create a ray function - this is a compositing ray function
>>         vtkVolumeRayCastCompositeFunction compositeFunction = new 
>> vtkVolumeRayCastCompositeFunction();
>>        
>>         // Create the volume mapper and set the ray function and 
>> scalar input
>>         vtkVolumeRayCastMapper volumeMapper = new 
>> vtkVolumeRayCastMapper();
>>         volumeMapper.SetInput(readerSS.GetOutput());
>>         volumeMapper.AutoAdjustSampleDistancesOn();
>>         volumeMapper.SetVolumeRayCastFunction(compositeFunction);
>>       
>>         // Create the volume and set the mapper and property
>>         vtkVolume volume = new vtkVolume();
>>         volume.SetMapper(volumeMapper);
>>         volume.SetProperty(volumeProperty);
>>        
>>         // Add this volume to the renderer and get a closer look
>>         m_Renderer.AddVolume(volume);
>> }
>>
>>
>> PLEASE HELP!!!
>>
>>
>> Toh Da Jun
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>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/20050620/2ea25c0f/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: snapshot4.jpg
Type: image/jpeg
Size: 8241 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050620/2ea25c0f/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 9476 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050620/2ea25c0f/attachment.jpeg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 7964 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050620/2ea25c0f/attachment-0001.jpeg>


More information about the vtkusers mailing list