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