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