]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Pipeline/DataObject.cxx
yet another refactoring
[cpPlugins.git] / lib / cpPlugins / Pipeline / DataObject.cxx
diff --git a/lib/cpPlugins/Pipeline/DataObject.cxx b/lib/cpPlugins/Pipeline/DataObject.cxx
new file mode 100644 (file)
index 0000000..7afa1c7
--- /dev/null
@@ -0,0 +1,92 @@
+#include <cpPlugins/Pipeline/DataObject.h>
+
+#include <itkDataObject.h>
+#include <vtkImageData.h>
+#include <vtkPolyData.h>
+#include <vtkUnstructuredGrid.h>
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Pipeline::DataObject::
+IsCompatible( const Self* other ) const
+{
+  return( true );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Pipeline::ProcessObject*
+cpPlugins::Pipeline::DataObject::
+GetSource( )
+{
+  return( this->m_Source );
+}
+
+// -------------------------------------------------------------------------
+const cpPlugins::Pipeline::ProcessObject*
+cpPlugins::Pipeline::DataObject::
+GetSource( ) const
+{
+  return( this->m_Source );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Pipeline::DataObject::
+SetSource( cpPlugins::Pipeline::ProcessObject* src )
+{
+  if( this->m_Source != src )
+  {
+    this->m_Source = src;
+    this->Modified( );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Pipeline::DataObject::
+DisconnectFromPipeline( )
+{
+  // Disconnect input pipelines (ITK)
+  itk::DataObject::Pointer itk_obj = this->GetITK< itk::DataObject >( );
+  if( itk_obj.IsNotNull( ) )
+    itk_obj->DisconnectPipeline( );
+
+  // Disconnect input pipelines (VTK)
+  bool      ok = this->_DisconnectVTK< vtkImageData >( );
+  if( !ok ) ok = this->_DisconnectVTK< vtkPolyData >( );
+
+  // Unbind source
+  this->m_Source = NULL;
+  this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Pipeline::DataObject::
+DataObject( )
+  : Superclass( ),
+    m_Source( NULL )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Pipeline::DataObject::
+~DataObject( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TType >
+bool cpPlugins::Pipeline::DataObject::
+_DisconnectVTK( )
+{
+  _TType* v = dynamic_cast< _TType* >( this->m_VTK.GetPointer( ) );
+  if( v != NULL )
+  {
+    vtkSmartPointer< _TType > d = vtkSmartPointer< _TType >::New( );
+    d->ShallowCopy( v );
+    this->m_VTK = d;
+    return( true );
+  }
+  else
+    return( false );
+}
+
+// eof - $RCSfile$