]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/DataObjects/Skeleton.cxx
...
[cpPlugins.git] / lib / cpPlugins / DataObjects / Skeleton.cxx
1 #include <cpPlugins/DataObjects/Skeleton.h>
2 #include <cpExtensions/Visualization/SkeletonToPolyData.h>
3
4 // -------------------------------------------------------------------------
5 void cpPlugins::DataObjects::Skeleton::
6 SetITK( itk::LightObject* o )
7 {
8   typedef cpExtensions::DataStructures::Skeleton< 1 > _T1;
9   typedef cpExtensions::DataStructures::Skeleton< 2 > _T2;
10   typedef cpExtensions::DataStructures::Skeleton< 3 > _T3;
11   typedef cpExtensions::DataStructures::Skeleton< 4 > _T4;
12
13   this->Superclass::SetITK( o );
14   auto l1 = dynamic_cast< _T1* >( o );
15   auto l2 = dynamic_cast< _T2* >( o );
16   auto l3 = dynamic_cast< _T3* >( o );
17   auto l4 = dynamic_cast< _T4* >( o );
18   if     ( l1 != NULL ) this->_ITK_2_VTK( l1 );
19   else if( l2 != NULL ) this->_ITK_2_VTK( l2 );
20   else if( l3 != NULL ) this->_ITK_2_VTK( l3 );
21   else if( l4 != NULL ) this->_ITK_2_VTK( l4 );
22   else
23   {
24     this->m_VTK = NULL;
25     this->m_ITKvVTK = NULL;
26
27   } // fi
28 }
29
30 // -------------------------------------------------------------------------
31 void cpPlugins::DataObjects::Skeleton::
32 SetVTK( vtkObjectBase* o )
33 {
34   // Do nothing
35   this->m_ITK = NULL;
36   this->m_VTK = NULL;
37   this->m_ITKvVTK = NULL;
38 }
39
40 // -------------------------------------------------------------------------
41 cpPlugins::DataObjects::Skeleton::
42 Skeleton( )
43   : Superclass( )
44 {
45 }
46
47 // -------------------------------------------------------------------------
48 cpPlugins::DataObjects::Skeleton::
49 ~Skeleton( )
50 {
51 }
52
53 // -------------------------------------------------------------------------
54 template< class _TSkeleton >
55 void cpPlugins::DataObjects::Skeleton::
56 _ITK_2_VTK( _TSkeleton* sk )
57 {
58   typedef
59     cpExtensions::Visualization::SkeletonToPolyData< _TSkeleton >
60     _TFilter;
61   _TFilter* f = dynamic_cast< _TFilter* >( this->m_ITKvVTK.GetPointer( ) );
62   if( f == NULL )
63   {
64     _TFilter* nf = _TFilter::New( );
65     this->m_ITKvVTK = nf;
66     f = nf;
67
68   } // fi
69   f->SetInput( sk );
70   f->Update( );
71
72   // Keep object track
73   this->m_ITK = sk;
74   this->m_VTK = f->GetOutput( );
75 }
76
77 // eof - $RCSfile$