[vtkusers] one problem about volume rending program

wjynyny wjynyny at 126.com
Sun Dec 3 22:19:38 EST 2006


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"
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT face="Times New Roman" size=3>ERROR: In F:\vtk1\VTK5.0\vtk-5.0.0\VolumeRendering\vtkVolumeRayCastMapper.cxx, line 318</FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT face="Times New Roman" size=3>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!

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


More information about the vtkusers mailing list