X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface%2FDataObject.cxx;h=0bbe13bdeb4973d0d23ee9b11c3f350aabcca5e5;hb=a89305e04527ebe2e81d0d1a62bbe34e0d35a141;hp=4ec6223b6096d995f662b45e276311ae598035f7;hpb=1adce86c283e253ec41f762652bc477d56d617a5;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/DataObject.cxx b/lib/cpPlugins/Interface/DataObject.cxx index 4ec6223..0bbe13b 100644 --- a/lib/cpPlugins/Interface/DataObject.cxx +++ b/lib/cpPlugins/Interface/DataObject.cxx @@ -1,52 +1,89 @@ #include -// ------------------------------------------------------------------------- -cpPlugins::Interface::DataObject:: -DataObject( ) - : Superclass( ), - m_Source( NULL ) -{ -} +#include +#include +#include +#include // ------------------------------------------------------------------------- -cpPlugins::Interface::DataObject:: -~DataObject( ) +cpPlugins::Interface::ProcessObject* cpPlugins::Interface::DataObject:: +GetSource( ) { + auto ptr = reinterpret_cast< ProcessObject::Pointer* >( this->m_Source ); + return( ptr->GetPointer( ) ); } // ------------------------------------------------------------------------- -std::string cpPlugins::Interface::DataObject:: -GetClassName( ) const +const cpPlugins::Interface::ProcessObject* cpPlugins::Interface::DataObject:: +GetSource( ) const { - return( "cpPlugins::Interface::DataObject" ); + auto ptr = reinterpret_cast< ProcessObject::Pointer* >( this->m_Source ); + return( ptr->GetPointer( ) ); } // ------------------------------------------------------------------------- -itk::DataObject* cpPlugins::Interface::DataObject:: -GetDataObject( ) const +void cpPlugins::Interface::DataObject:: +SetSource( cpPlugins::Interface::ProcessObject* src ) { - return( this->m_DataObject ); + auto ptr = reinterpret_cast< ProcessObject::Pointer* >( this->m_Source ); + if( ptr->GetPointer( ) != src ) + { + *ptr = src; + this->Modified( ); + + } // fi } // ------------------------------------------------------------------------- void cpPlugins::Interface::DataObject:: -SetDataObject( itk::DataObject* dobj ) +DisconnectFromPipeline( ) { - this->m_DataObject = dobj; + // Disconnect input pipelines (ITK) + itk::DataObject* itk_obj = this->GetITK< itk::DataObject >( ); + if( itk_obj != NULL ) + itk_obj->DisconnectPipeline( ); + + // Disconnect input pipelines (VTK) + vtkImageData* vtk_image = this->GetVTK< vtkImageData >( ); + vtkPolyData* vtk_pd = this->GetVTK< vtkPolyData >( ); + if( vtk_image != NULL ) + { + vtkSmartPointer< vtkImageData > d = + vtkSmartPointer< vtkImageData >::New( ); + d->ShallowCopy( vtk_image ); + this->m_VTKObject = d; + } + else if( vtk_pd != NULL ) + { + vtkSmartPointer< vtkPolyData > d = + vtkSmartPointer< vtkPolyData >::New( ); + d->ShallowCopy( vtk_pd ); + this->m_VTKObject = d; + + } // fi + + // Unbind source + auto ptr = reinterpret_cast< ProcessObject::Pointer* >( this->m_Source ); + *ptr = NULL; + this->Modified( ); } // ------------------------------------------------------------------------- -cpPlugins::Interface::ProcessObject* cpPlugins::Interface::DataObject:: -GetSource( ) const +cpPlugins::Interface::DataObject:: +DataObject( ) + : Superclass( ) { - return( this->m_Source ); + this->m_Source = new ProcessObject::Pointer( ); } // ------------------------------------------------------------------------- -void cpPlugins::Interface::DataObject:: -SetSource( cpPlugins::Interface::ProcessObject* src ) +cpPlugins::Interface::DataObject:: +~DataObject( ) { - this->m_Source = src; + /* TODO + auto ptr = reinterpret_cast< ProcessObject::Pointer* >( this->m_Source ); + delete ptr; + */ } // eof - $RCSfile$