[vtkusers] 3D rendering with Meta image

Urvoas, Paul paul.urvoas at philips.com
Tue Jul 13 03:32:00 EDT 2010


Hi,
I wrote a program to visualize a mhd volume with a Vtk volume rendering window.
I don't get, I manage to compile and execute it but the window is empty, I cannot visualize my volume in.
(My mhd file is good..)

Any ideas ? Thanks in advance.

This is my code :

int main(int argc, char* argv)
{

vtkImageData** ImageOriginale  = new vtkImageData*[10];

      int i=0;
      while(i<10)
      {
             ImageOriginale[i]=vtkImageData::New();
            ++i;
      }

      vtkViewImage3D* view;
      view=vtkViewImage3D::New();

      cout << "start" <<endl;

      vtkMetaImageReader* reader = vtkMetaImageReader::New();
      reader->SetFileName ("FILTER.mhd");

      reader->GetOutput()->Update();
      cout << "reader ok" <<endl;

      vtkImageCast* caster = vtkImageCast::New();
      caster->SetInput (reader->GetOutput());
      caster->SetOutputScalarTypeToUnsignedShort ();
      caster->GetOutput()->Update();

      ImageOriginale[0]->DeepCopy(caster->GetOutput()) ;

      caster->Delete();
      reader->Delete();

      int dims[3];
      ImageOriginale[0]->GetDimensions(dims);
      double spacing[3];

      ImageOriginale[0]->GetSpacing(spacing);

      view->SetImage(ImageOriginale[0]);

      view->SetLinkZoom (true);
      view->SetBackgroundColor (255.0,0.0,0.0);

 // view->SetRenderingModeToVR();
  view->SetVolumeRayCastFunctionToMIP();
 // view->SetCubeVisibility(1);

  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
  vtkRenderWindow *rwin = vtkRenderWindow::New();
  iren->SetRenderWindow ( rwin );
  vtkRenderer* ren = vtkRenderer::New();

  rwin->AddRenderer(ren);
  view->SetRenderWindow ( rwin );
  view->SetRenderer ( ren );

  rwin->Render();
  iren->Start();

  return 0;

}

________________________________
The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100713/d62562b3/attachment.htm>


More information about the vtkusers mailing list