[vtkusers] VolumeRender a 3D volume

Toh Da Jun tohdj at bii.a-star.edu.sg
Fri Jun 17 05:55:13 EDT 2005


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050617/7789fdc1/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: snapshot3.jpg
Type: image/jpeg
Size: 9476 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050617/7789fdc1/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: snapshot2.jpg
Type: image/jpeg
Size: 7964 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050617/7789fdc1/attachment-0001.jpg>


More information about the vtkusers mailing list