[vtkusers] Creating a volume from binary files

Amy Squillacote amy.squillacote at kitware.com
Thu Feb 15 08:48:06 EST 2007


Hi Francois,

vtkVolumeRayCastMapper cannot handle data of type short, so you have two 
options:

1. Switch to another volume mapper that does handle this type of data. 
vtkFixedPointVolumeRayCastMapper is probably what you're looking for.
2. If for some reason you really want to use this particular volume 
mapper, then you need to change the data type of your volume. You can 
use vtkImageShiftScale to accomplish this.

- Amy

Francois Louis LAILLIER wrote:
>
> 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.
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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
>   

-- 
Amy Squillacote
Kitware, Inc.
28 Corporate Drive
Clifton Park, NY 12065
Phone: (518) 371-3971 x106




More information about the vtkusers mailing list