[vtkusers] Creating a volume from binary files

Francois Louis LAILLIER flaillier at eldim.fr
Thu Feb 15 05:11:32 EST 2007


Hello vtkusers,

 

First I am French and I am sorry for my English.

 

I develop a render of 3D volume from binary files.

 

I use vtkvolumeRaycastmapper, but I have an error witch say "ERROR: In
C:\Hoffman\ActivizCom\VTKCom\Rendering\vtkVolumeRayCastMapper.cxx, line
328

vtkOpenGLVolumeRayCastMapper (0x00ABDBB0): Cannot volume render data of
type short, only unsigned char or unsigned short."

 

But I need use short data type. How can I do to use this type of data? I
want keep the grey level of my data.

 

I program in Visual basic 6 language, I give you my source to other
developers whose develops in this language because it's rare.

 

You must create a button and a vtkrenderwindowControl1

 

Private Sub Command1_Click()

 

'Creation de la fenetre de rendu

Set renWin = vtkRenderWindowControl1.GetRenderWindow

Dim render As vtkRenderer

Set render = New vtkRenderer

renWin.AddRenderer render

 

 

'ouverture des Data

 

Dim xspace As Single

xspace = 250 / 768 '25cm for 768 pixels

Dim yspace As Single

yspace = 187.5 / 576

Dim zspace As Single

zspace = 1#

Dim image As vtkImageReader

Set image = New vtkImageReader

image.SetFilePrefix "C:\\Images\\imageunsigned\\img"

image.SetDataByteOrderToLittleEndian

image.SetFileDimensionality 2

image.SetNumberOfScalarComponents 1

image.SetDataExtent 0, 768, 0, 576, 1, 24

image.SetDataSpacing xspace, yspace, zspace

image.SetDataOrigin 0, 0, 0

image.Update

 

'Creation du volume

 

Dim volume As vtkVolume

Set volume = New vtkVolume

Dim volumemapper As vtkVolumeRayCastMapper

Set volumemapper = New vtkVolumeRayCastMapper

Dim fonction As vtkVolumeRayCastCompositeFunction

Set fonction = New vtkVolumeRayCastCompositeFunction

volumemapper.SetVolumeRayCastFunction fonction

volumemapper.SetInput image.GetOutput

volume.SetMapper volumemapper

 

Dim camera As vtkCamera

Set camera = New vtkCamera

camera.SetViewUp 0, 0, -1

camera.SetPosition 0, 1, 0

camera.SetFocalPoint 0, 0, 0

camera.ComputeViewPlaneNormal

 

render.AddActor volume

render.SetActiveCamera camera

render.ResetCamera

render.SetBackground 1, 1, 1

renWin.render

 

 

End Sub

 

Best regards, francois laillier.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070215/f82505c9/attachment.htm>


More information about the vtkusers mailing list