]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/DataStructures/ITKAndVTKImage.h
Interactive filters synchronization debugged
[cpPlugins.git] / lib / cpExtensions / DataStructures / ITKAndVTKImage.h
index a3e2aacc03f4f9b5df69fcf51623e9b13832d8cc..dfcad3f6955cdefe441a103b79c7770434f53ace 100644 (file)
@@ -7,98 +7,98 @@
 #include <itkImageToVTKImageFilter.h>
 
 namespace cpExtensions
+{
+  namespace DataStructures
   {
-    namespace DataStructures
+    /**
+     */
+    template< typename P, unsigned int D >
+    struct ITKAndVTKImage
     {
-      /**
-       */
-      template< typename P, unsigned int D >
-      struct ITKAndVTKImage
-      {
-        typedef itk::Image< P, D >                   TImage;
-        typedef itk::ImageToVTKImageFilter< TImage > TItk2Vtk;
-
-        typename TImage::Pointer   ITK;
-        typename TItk2Vtk::Pointer VTK;
-
-        void CopyInformation( const itk::ImageBase< D >* i )
+      typedef itk::Image< P, D >                   TImage;
+      typedef itk::ImageToVTKImageFilter< TImage > TItk2Vtk;
+
+      typename TImage::Pointer   ITK;
+      typename TItk2Vtk::Pointer VTK;
+
+      void CopyInformation( const itk::ImageBase< D >* i )
+        {
+          this->ITK = TImage::New( );
+          this->ITK->SetLargestPossibleRegion( i->GetLargestPossibleRegion( ) );
+          this->ITK->SetRequestedRegion( i->GetRequestedRegion( ) );
+          this->ITK->SetBufferedRegion( i->GetBufferedRegion( ) );
+          this->ITK->SetSpacing( i->GetSpacing( ) );
+          this->ITK->SetOrigin( i->GetOrigin( ) );
+          this->ITK->SetDirection( i->GetDirection( ) );
+          this->ITK->Allocate( );
+        }
+
+      void SetItkImage( TImage* image )
+        {
+          this->ITK = image;
+          this->_Synch( );
+        }
+
+      std::string ReadFromFile( const std::string& filename )
+        {
+          typename itk::ImageFileReader< TImage >::Pointer r =
+            itk::ImageFileReader< TImage >::New( );
+          r->SetFileName( filename );
+          try
           {
-            this->ITK = TImage::New( );
-            this->ITK->SetLargestPossibleRegion( i->GetLargestPossibleRegion( ) );
-            this->ITK->SetRequestedRegion( i->GetRequestedRegion( ) );
-            this->ITK->SetBufferedRegion( i->GetBufferedRegion( ) );
-            this->ITK->SetSpacing( i->GetSpacing( ) );
-            this->ITK->SetOrigin( i->GetOrigin( ) );
-            this->ITK->SetDirection( i->GetDirection( ) );
-            this->ITK->Allocate( );
+            r->Update( );
           }
-
-        void SetItkImage( TImage* image )
+          catch( itk::ExceptionObject& err )
           {
-            this->ITK = image;
-            this->_Synch( );
-          }
-
-        std::string ReadFromFile( const std::string& filename )
-          {
-            typename itk::ImageFileReader< TImage >::Pointer r =
-              itk::ImageFileReader< TImage >::New( );
-            r->SetFileName( filename );
-            try
-            {
-              r->Update( );
-            }
-            catch( itk::ExceptionObject& err )
-            {
-              this->ITK = NULL;
-              return( err.GetDescription( ) );
-
-            } // fi
-            this->ITK = r->GetOutput( );
-            this->ITK->DisconnectPipeline( );
-            this->_Synch( );
-            return( "" );
-          }
-
-        std::string WriteToFile( const std::string& filename ) const
+            this->ITK = NULL;
+            return( err.GetDescription( ) );
+
+          } // fi
+          this->ITK = r->GetOutput( );
+          this->ITK->DisconnectPipeline( );
+          this->_Synch( );
+          return( "" );
+        }
+
+      std::string WriteToFile( const std::string& filename ) const
+        {
+          typename itk::ImageFileWriter< TImage >::Pointer w =
+            itk::ImageFileWriter< TImage >::New( );
+          w->SetFileName( filename );
+          w->SetInput( this->ITK );
+          try
           {
-            typename itk::ImageFileWriter< TImage >::Pointer w =
-              itk::ImageFileWriter< TImage >::New( );
-            w->SetFileName( filename );
-            w->SetInput( this->ITK );
-            try
-            {
-              w->Update( );
-            }
-            catch( itk::ExceptionObject& err )
-            {
-              return( err.GetDescription( ) );
-
-            } // fi
-            return( "" );
+            w->Update( );
           }
-
-        TImage* GetItkImage( )
-          { return( this->ITK ); }
-        vtkImageData* GetVtkImage( )
-          { return( this->VTK->GetOutput( ) ); }
-        const TImage* GetItkImage( ) const
-          { return( this->ITK ); }
-        const vtkImageData* GetVtkImage( ) const
-          { return( this->VTK->GetOutput( ) ); }
-        void DisconnectPipeline( )
-          { this->ITK->DisconnectPipeline( ); }
-
-        void _Synch( )
+          catch( itk::ExceptionObject& err )
           {
-            this->VTK = TItk2Vtk::New( );
-            this->VTK->SetInput( this->ITK );
-            this->VTK->Update( );
-          }
-
-      };
-
-    } // ecapseman
+            return( err.GetDescription( ) );
+
+          } // fi
+          return( "" );
+        }
+
+      TImage* GetItkImage( )
+        { return( this->ITK ); }
+      vtkImageData* GetVtkImage( )
+        { return( this->VTK->GetOutput( ) ); }
+      const TImage* GetItkImage( ) const
+        { return( this->ITK ); }
+      const vtkImageData* GetVtkImage( ) const
+        { return( this->VTK->GetOutput( ) ); }
+      void DisconnectPipeline( )
+        { this->ITK->DisconnectPipeline( ); }
+
+      void _Synch( )
+        {
+          this->VTK = TItk2Vtk::New( );
+          this->VTK->SetInput( this->ITK );
+          this->VTK->Update( );
+        }
+
+    };
+
+  } // ecapseman
 
 } // ecapseman