[vtkusers] 3D rendering with Meta image

Sebastien Jourdain sebastien.jourdain at kitware.com
Wed Jul 14 08:00:56 EDT 2010


Try to replace

reader->GetOutput()->Update();

by

reader->Update();

On Tue, Jul 13, 2010 at 3:32 AM, Urvoas, Paul <paul.urvoas at philips.com> wrote:
> 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.
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK 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