]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/ImageIndexesContainer.hxx
d7a50168271be2b3f206b8a79099228244598020
[cpPlugins.git] / lib / cpPlugins / ImageIndexesContainer.hxx
1 #ifndef __CPPLUGINS__IMAGEINDEXESCONTAINER__HXX__
2 #define __CPPLUGINS__IMAGEINDEXESCONTAINER__HXX__
3
4 #include <cpPlugins_Instances/Paths.h>
5
6 // -------------------------------------------------------------------------
7 template< unsigned int _NDim >
8 bool cpPlugins::ImageIndexesContainer::
9 _ITK_2_VTK( itk::LightObject* o )
10 {
11   typedef
12     cpExtensions::DataStructures::ImageIndexesContainer< _NDim >
13     _TImageIndexesContainer;
14   typedef
15     cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TImageIndexesContainer >
16     _TFilter;
17
18   auto cont = dynamic_cast< _TImageIndexesContainer* >( o );
19   if( cont != NULL )
20   {
21     _TFilter* f = dynamic_cast< _TFilter* >( this->m_ITKvVTK.GetPointer( ) );
22     if( f == NULL )
23     {
24       vtkSmartPointer< _TFilter > nf = _TFilter::New( );
25       this->m_ITKvVTK = nf.GetPointer( );
26       f = nf.GetPointer( );
27
28     } // fi
29     f->SetInput( cont );
30     f->SetReferenceImage( cont->GetReferenceImage( ) );
31     f->Update( );
32
33     // Keep object track
34     this->m_ITKObject = o;
35     this->m_VTKObject = f->GetOutput( );
36     return( true );
37   }
38   else
39     return( false );
40 }
41
42 #endif // __CPPLUGINS__IMAGEINDEXESCONTAINER__HXX__
43
44 // eof - $RCSfile$