[vtkusers] Visualize 3D image (.mhd)

Urvoas, Paul paul.urvoas at philips.com
Mon Jul 12 07:08:15 EDT 2010


Hi,
I would like to visualize 3d mhd image with VTK, thanks to another program, I wrote the following code.
It crashes just after cout<<"caster ok" and I don't find my mistakes.

Thanks in advance,
Paul


int main(int argc, char* argv)
{

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

      vtkViewImage3D* view;

      cout << "start" <<endl;

      vtkMetaImageReader* reader = vtkMetaImageReader::New();
      reader->SetFileName ("Synthetic-04.mhd");
      reader->GetOutput()->Update();
      cout << "reader ok" <<endl;

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

      cout << "caster ok" <<endl;

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

      cout << "Copy volume to ImageOriaginale" <<endl;

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

      cout << "reader caster deleted" <<endl;

      int dims[3];
      ImageOriginale[0]->GetDimensions(dims);
      double spacing[3];
      ImageOriginale[0]->GetSpacing(spacing);
      cout << "spacing & dimension" <<endl;


  view->SetImage(ImageOriginale[0]);

  view->SetRenderingModeToVR();
  view->SetVolumeRayCastFunctionToMIP();

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


  view->SetImage (ImageOriginale[0]);
  view->SetRenderingModeToVR();
  view->SetVolumeRayCastFunctionToMIP();

  cout << "befor render" <<endl;
  renWin->Render();

}

________________________________
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/20100712/766cb1e6/attachment.htm>


More information about the vtkusers mailing list