]> Creatis software - FrontAlgorithms.git/blobdiff - appli/CTBronchi/Image.hxx
...
[FrontAlgorithms.git] / appli / CTBronchi / Image.hxx
index 4b6fa9b8ff1c37ae2285b89e2bfbe1349a59c000..86ce8ebc7551c3d8f2032b127a42f41f5622362a 100644 (file)
@@ -4,6 +4,7 @@
 #ifndef __CTBronchi__Image__hxx__
 #define __CTBronchi__Image__hxx__
 
+#include "Filter.h"
 #include <itkImageFileReader.h>
 #include <itkImageFileWriter.h>
 
@@ -61,57 +62,64 @@ void CTBronchi::Image< _TPixel, _VDim >::
 Set( TImage* image )
 {
   this->m_Image = image;
-  this->m_Image->DisconnectPipeline( );
+  if( this->m_Image.IsNotNull( ) )
+    this->m_Image->DisconnectPipeline( );
 }
 
 // -------------------------------------------------------------------------
 template< class _TPixel, unsigned int _VDim >
 void CTBronchi::Image< _TPixel, _VDim >::
-Set( const TImage::Pointer& image )
+Set( const typename TImage::Pointer& image )
 {
   this->m_Image = image.GetPointer( );
-  this->m_Image->DisconnectPipeline( );
+  if( this->m_Image.IsNotNull( ) )
+    this->m_Image->DisconnectPipeline( );
 }
 
 // -------------------------------------------------------------------------
 template< class _TPixel, unsigned int _VDim >
-void CTBronchi::Image< _TPixel, _VDim >::
+double CTBronchi::Image< _TPixel, _VDim >::
 Load( const std::string& fname )
 {
-  typedef itk::ImageFileReader< TImage > _TReader;
-  typename _TReader::Pointer r = _TReader::New( );
-  r->SetFileName( fname );
+  typedef CTBronchi::Filter< itk::ImageFileReader< TImage > > _TReader;
+  _TReader r;
+  r.Get( )->SetFileName( fname );
   try
   {
-    r->Update( );
-    this->Set( r->GetOutput( ) );
+    double t = r.Update( );
+    this->Set( r.Get( )->GetOutput( ) );
+    return( t );
   }
   catch( ... )
   {
     this->Set( NULL );
+    return( -1 );
 
   } // yrt
 }
 
 // -------------------------------------------------------------------------
 template< class _TPixel, unsigned int _VDim >
-void CTBronchi::Image< _TPixel, _VDim >::
+double CTBronchi::Image< _TPixel, _VDim >::
 Save( const std::string& fname )
 {
-  typedef itk::ImageFileWriter< TImage > _TWriter;
+  typedef CTBronchi::Filter< itk::ImageFileWriter< TImage > > _TWriter;
 
+  double t = -1;
   if( this->IsNotNull( ) )
   {
-    typename _TWriter::Pointer w = _TWriter::New( );
-    w->SetFileName( fname );
-    w->SetInput( this->m_Image );
+    _TWriter w;
+    w.Get( )->SetFileName( fname );
+    w.Get( )->UseCompressionOn( );
+    w.Get( )->SetInput( this->m_Image );
     try
     {
-      w->Update( );
+      t = w.Update( );
     }
     catch( ... ) { }
 
   } // fi
+  return( t );
 }
 
 #endif // __CTBronchi__Image__hxx__