[Insight-users] Register and Delete

Luis Ibanez luis.ibanez at kitware.com
Fri, 16 Apr 2004 06:07:29 -0400


Hi Toon,

There is a much better way to connect ITK and VTK filters.

Please use the classes in:

         InsightApplications/Auxiliary/vtk
			itkImageToVTKImageFilter.h
			itkImageToVTKImageFilter.txx
			itkVTKImageToImageFilter.h
			itkVTKImageToImageFilter.txx

You will also find detail about how to do this
in the Tutorial sessions:

      http://www.itk.org/HTML/Tutorials.htm

in particular in:

   http://www.itk.org/CourseWare/Training/GettingStarted-II.pdf


Regards,


    Luis




-----------------------
Toon Huysmans wrote:

> Hi,
> 
>     I want to do a very simple thing, visualize a itk image in a
> vtkRenderer, and I did it!  But I had to add some extra Register()'s and
> leave out some Delete()'s otherwise the application crashes when an update
> is propagated from the renderer down to the Image.
> 
>     The attached method works but the use of register and delete is
> inconsistent.
>     So I was wondering if anyone could tell me how to correctly use
> Register() and Delete() in the attached method.
> 
> 
> Toon.
> 
> // view the image in the renderer
> void    SegmentationBase::viewImage(ImageType::Pointer im, vtkRenderer *ren)
> {
>     // connect itk with vtk
>     ImageExportType::Pointer itkExporter = ImageExportType::New();
>     vtkImageImport* vtkImporter = vtkImageImport::New();
> 
>     //If I dont do this it will crash!
>     itkExporter->Register();
>     vtkImporter->Register(NULL);
> 
>     itkExporter->SetInput(image);
>     itkExporter->Update();
> 
>     vtkImporter->SetDataScalarTypeToUnsignedChar();
> 
>     ConnectPipelines(itkExporter, vtkImporter);
> 
>     vtkImporter->Update();
> 
>     //Use three orthogonal ImagePlaneWidgets to view the Image
>     vtkOrthogonalImagePlaneSet *planeSet =
> vtkOrthogonalImagePlaneSet::New();
>     planeSet->SetInput(vtkImporter->GetOutput());
>     planeSet->On();
>     planeSet->SetInteractor(ren->GetRenderWindow()->GetInteractor());
> 
>     //outline of the image
>     vtkOutlineFilter *outline = vtkOutlineFilter::New();
>     outline->SetInput((vtkImporter->GetOutput()));
> 
>     vtkPolyDataMapper *outlineMapper = vtkPolyDataMapper::New();
>     outlineMapper->SetInput(outline->GetOutput());
> 
>     vtkActor *outlineActor = vtkActor::New();
>     outlineActor->SetMapper(outlineMapper);
> 
>     ren->AddActor(outlineActor);
> 
>     outline->Delete();
>     outlineMapper->Delete();
>     outlineActor->Delete();
> 
>     // If I delete any of these it also crashes
>     //itkExporter->Delete();
>     //vtkImporter->Delete();
>     //planeSet->Delete();
> }
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>