[vtkusers] one problem about volume rending program

Amy Squillacote amy.squillacote at kitware.com
Mon Dec 4 08:35:59 EST 2006


The vtkVolumeRayCastMapper can only operate on data that is of type
unsigned char or unsigned short. To render your data, you should either
use the vtkFixedPointVolumeRayCastMapper
(http://www.vtk.org/doc/nightly/html/classvtkFixedPointVolumeRayCastMapper.html)
instead (which can operate on data with any scalar type) or you should
pass your data through a vtkImageShiftScale
(http://www.vtk.org/doc/nightly/html/classvtkImageShiftScale.html) to
change its type to either unsigned char or unsigned short before passing
it to the vtkVolumeRayCastMapper.

- Amy

wjynyny wrote:
> I have written one program about volume rending .When compiled,there
> are no bugs.But when executed,there exits one window named
> vtkOutputWindow displaying the message"
>
> ERROR: In
> F:\vtk1\VTK5.0\vtk-5.0.0\VolumeRendering\vtkVolumeRayCastMapper.cxx,
> line 318
>
> vtkVolumeRayCastMapper (0x0279E840): Cannot volume render data of type
> short, only unsigned char or unsigned short."
>
> And the final imagine can not be get.
>
> The CT imagine files are DICOM format.The path is"e:/test/dcmdir"
>
> the primary programs are as follows:
>
> ren = vtkRenderer::New();
> renWin = vtkWin32OpenGLRenderWindow::New();
> iren = vtkWin32RenderWindowInteractor::New();
>    renWin->AddRenderer(this->ren);
>
> // setup the parent window
>    renWin->SetParentId(this->GetDlgItem(IDC_RENDER)->m_hWnd);
>    iren->SetRenderWindow(renWin);
>    vtkDICOMImageReader *m_DicomReader = vtkDICOMImageReader::New();
> m_DicomReader->SetDirectoryName ("e:/test/dcmdir");
> m_DicomReader->Update();
>
> vtkVolumeRayCastCompositeFunction *ComositeFun =   
> vtkVolumeRayCastCompositeFunction::New();
> vtkVolumeRayCastMapper *VolMapper = vtkVolumeRayCastMapper::New();
> VolMapper->SetInputConnection(m_DicomReader->GetOutputPort());
> VolMapper->SetVolumeRayCastFunction(ComositeFun);
> vtkVolume *Volume = vtkVolume::New();
> Volume->SetMapper(VolMapper);
>
> vtkColorTransferFunction *gTFun = vtkColorTransferFunction::New();
> gTFun->AddRGBSegment(128.0,126/255.0,16/255.0,16/255.0,
> 255.0,64/255.0,255/255.0,16/255.0);
> vtkVolumeProperty *VolProperty = vtkVolumeProperty::New();
> VolProperty->SetColor(gTFun);
>
>
> vtkPiecewiseFunction *oTFun = vtkPiecewiseFunction::New();
> oTFun->AddSegment(48,0.0,255,1.0);
> VolProperty->SetScalarOpacity(oTFun);
> VolProperty->SetInterpolationTypeToLinear();
> VolProperty->ShadeOn();
> Volume->SetProperty(VolProperty);
> ren->AddVolume(Volume);
> ren->SetBackground(1,1,1);
>
> CRect rect;
> this->GetDlgItem(IDC_RENDER)->GetClientRect(&rect);
> iren->Initialize();
> renWin->SetSize(rect.right-rect.left,rect.bottom-rect.top);
> ren->ResetCameraClippingRange();
> ren->ResetCamera();
> ren->GetActiveCamera()->Zoom(1);
>   iren->Start();
> AfxMessageBox("init ok");
> please help me find the error,and tell me how to solve the problem in
> detail.Thanks a lot!
>
>
>
>
> 年 末 数 码 1 0 0 元 专 场 ( 图 )
> 百 种 数 码 精 品 1 9 元 起 1 0 0 元 封 顶 , 不 抢 真 的 悔 死 你 ( 图
> )
> <http://adtaobao.allyes.com/main/adfclick?db=adtaobao&bid=600,597,58&cid=30015,198,1&sid=32501&show=ignore&url=http://www.taobao.com/theme/promotion/main.php/71154>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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
>   



More information about the vtkusers mailing list