]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/DataObject.cxx
...
[cpPlugins.git] / lib / cpPlugins / DataObject.cxx
1 #include <cpPlugins/DataObject.h>
2 #include <itkDataObject.h>
3 #include <vtkImageData.h>
4 #include <vtkPolyData.h>
5
6 // -------------------------------------------------------------------------
7 cpPlugins::ProcessObject* cpPlugins::DataObject::
8 GetSource( )
9 {
10   return( this->m_Source );
11 }
12
13 // -------------------------------------------------------------------------
14 const cpPlugins::ProcessObject* cpPlugins::DataObject::
15 GetSource( ) const
16 {
17   return( this->m_Source );
18 }
19
20 // -------------------------------------------------------------------------
21 void cpPlugins::DataObject::
22 SetSource( cpPlugins::ProcessObject* src )
23 {
24   if( this->m_Source != src )
25   {
26     this->m_Source = src;
27     this->Modified( );
28
29   } // fi
30 }
31
32 // -------------------------------------------------------------------------
33 void cpPlugins::DataObject::
34 DisconnectFromPipeline( )
35 {
36   // Disconnect input pipelines (ITK)
37   itk::DataObject* itk_obj = this->GetITK< itk::DataObject >( );
38   if( itk_obj != NULL )
39     itk_obj->DisconnectPipeline( );
40
41   // Disconnect input pipelines (VTK)
42   vtkImageData* vtk_image = this->GetVTK< vtkImageData >( );
43   vtkPolyData* vtk_pd = this->GetVTK< vtkPolyData >( );
44   if( vtk_image != NULL )
45   {
46     vtkSmartPointer< vtkImageData > d =
47       vtkSmartPointer< vtkImageData >::New( );
48     d->ShallowCopy( vtk_image );
49     this->m_VTKObject = d;
50   }
51   else if( vtk_pd != NULL )
52   {
53     vtkSmartPointer< vtkPolyData > d =
54       vtkSmartPointer< vtkPolyData >::New( );
55     d->ShallowCopy( vtk_pd );
56     this->m_VTKObject = d;
57
58   } // fi
59
60   // Unbind source
61   this->m_Source = NULL;
62   this->Modified( );
63 }
64
65 // -------------------------------------------------------------------------
66 vtkProp* cpPlugins::DataObject::
67 GetVTKActor( )
68 {
69   if( this->m_Actor.GetPointer( ) == NULL )
70     this->_CreateVTKActor( );
71   return( this->m_Actor.GetPointer( ) );
72 }
73
74 // -------------------------------------------------------------------------
75 const vtkProp* cpPlugins::DataObject::
76 GetVTKActor( ) const
77 {
78   if( this->m_Actor.GetPointer( ) == NULL )
79     this->_CreateVTKActor( );
80   return( this->m_Actor.GetPointer( ) );
81 }
82
83 // -------------------------------------------------------------------------
84 cpPlugins::DataObject::
85 DataObject( )
86   : Superclass( ),
87     m_Source( NULL )
88 {
89 }
90
91 // -------------------------------------------------------------------------
92 cpPlugins::DataObject::
93 ~DataObject( )
94 {
95 }
96
97 // -------------------------------------------------------------------------
98 void cpPlugins::DataObject::
99 _CreateVTKActor( ) const
100 {
101 }
102
103 // eof - $RCSfile$