From d1d816d1eaf980d5cd266798b8f7a0bbb089a383 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Sun, 4 Oct 2015 01:45:29 +0200 Subject: [PATCH] Widget integration (step 3/6). WARNING: IT DOES NOT COMPILE YET --- appli/ImageMPR/ImageMPR.cxx | 14 +- .../Visualization/ImageSliceActors.cxx | 26 +- .../Visualization/ImageSliceActors.h | 7 +- .../Interface/BaseProcessObjects.cxx | 22 +- lib/cpPlugins/Interface/BaseProcessObjects.h | 345 ++++++----- lib/cpPlugins/Interface/CMakeLists.txt | 66 +-- lib/cpPlugins/Interface/DataObject.cxx | 44 +- lib/cpPlugins/Interface/DataObject.h | 25 +- lib/cpPlugins/Interface/DataObject.hxx | 38 ++ lib/cpPlugins/Interface/Image.cxx | 257 +------- lib/cpPlugins/Interface/Image.h | 14 +- lib/cpPlugins/Interface/Image.hxx | 550 +++++++++--------- lib/cpPlugins/Interface/ImplicitFunction.cxx | 22 - lib/cpPlugins/Interface/ImplicitFunction.h | 15 - lib/cpPlugins/Interface/ImplicitFunction.hxx | 38 -- lib/cpPlugins/Interface/Mesh.cxx | 48 +- lib/cpPlugins/Interface/Mesh.h | 13 +- lib/cpPlugins/Interface/Mesh.hxx | 22 +- .../Interface/ParametersListWidget.cxx | 5 + .../Interface/ParametersListWidget.h | 6 + .../Interface/ParametersQtDialog.cxx | 4 + lib/cpPlugins/Interface/ParametersQtDialog.h | 6 + lib/cpPlugins/Interface/ProcessObject.cxx | 4 +- lib/cpPlugins/Interface/ProcessObject.h | 30 +- lib/cpPlugins/Interface/ProcessObject.hxx | 65 +++ .../BinaryThresholdImageFilter.cxx | 24 +- .../BasicFilters/BinaryThresholdImageFilter.h | 2 +- lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx | 33 +- lib/cpPlugins/Plugins/BasicFilters/Cutter.h | 10 - .../Plugins/BasicFilters/MarchingCubes.cxx | 24 +- .../Plugins/BasicFilters/MarchingCubes.h | 5 - .../BasicFilters/MedianImageFilter.cxx | 25 +- .../Plugins/BasicFilters/MedianImageFilter.h | 2 +- .../BasicFilters/OtsuThresholdImageFilter.cxx | 24 +- .../BasicFilters/OtsuThresholdImageFilter.h | 7 +- .../RGBImageToOtherChannelsFilter.cxx | 43 +- .../RGBImageToOtherChannelsFilter.h | 2 +- lib/cpPlugins/Plugins/IO/ImageReader.cxx | 30 +- lib/cpPlugins/Plugins/IO/ImageWriter.cxx | 34 +- lib/cpPlugins/Plugins/IO/MeshReader.cxx | 13 +- lib/cpPlugins/Plugins/IO/MeshReader.h | 3 - lib/cpPlugins/Plugins/IO/MeshWriter.cxx | 13 +- lib/cpPlugins/Plugins/IO/MeshWriter.h | 3 - 43 files changed, 827 insertions(+), 1156 deletions(-) create mode 100644 lib/cpPlugins/Interface/DataObject.hxx delete mode 100644 lib/cpPlugins/Interface/ImplicitFunction.hxx diff --git a/appli/ImageMPR/ImageMPR.cxx b/appli/ImageMPR/ImageMPR.cxx index 7fffc27..0100a13 100644 --- a/appli/ImageMPR/ImageMPR.cxx +++ b/appli/ImageMPR/ImageMPR.cxx @@ -194,7 +194,8 @@ _ConfigureMeshActors( ) { if( this->m_Mesh.IsNull( ) ) return( "Valid mesh not found." ); - + + this->m_Mesh->CreateVTKActor( ); vtkActor* vtk_actor = this->m_Mesh->GetVTKActor( ); if( vtk_actor != NULL ) { @@ -216,8 +217,9 @@ _ConfigureMeshActors( ) std::string lerr = this->m_Cutters[ i ]->Update( ); if( lerr == "" ) { + this->m_Cutters[ i ]->GetOutput< TPluginMesh >( 0 )->CreateVTKActor( ); vtkActor* actor = this->m_Cutters[ i ]->GetOutput< TPluginMesh >( 0 )->GetVTKActor( ); - mprActors->GetSliceActors( i )->AddActor( this->m_Cutters[ i ]->GetVTKAlgorithm( ), actor ); + mprActors->GetSliceActors( i )->AddActor( this->m_Cutters[ i ]->GetVTK< vtkAlgorithm >( ), actor ); if( i == 0 ) this->m_MPRObjects->GetXRenderer( )->AddActor( actor ); else if( i == 1 ) @@ -263,7 +265,7 @@ _triggered_actionOpenInputImage( ) std::string err = this->_LoadImage( this->m_Image ); if( err == "" ) { - vtkImageData* vtk_id = this->m_Image->GetVTKImageData( ); + vtkImageData* vtk_id = this->m_Image->GetVTK< vtkImageData >( ); if( vtk_id != NULL ) { this->m_MPRObjects->SetImage( vtk_id ); @@ -305,7 +307,7 @@ _triggered_actionOpenSegmentation( ) std::string err = this->_LoadImage( this->m_Segmentation ); if( err == "" ) { - vtkImageData* vtk_id = this->m_Segmentation->GetVTKImageData( ); + vtkImageData* vtk_id = this->m_Segmentation->GetVTK< vtkImageData >( ); if( vtk_id != NULL ) { this->m_MPRObjects->AddAuxiliaryImage( vtk_id ); @@ -413,7 +415,9 @@ _triggered_actionImageToImage( ) result->DisconnectPipeline( ); this->m_Image = result; if( this->m_Image.IsNotNull( ) ) - this->m_MPRObjects->SetImage( this->m_Image->GetVTKImageData( ) ); + this->m_MPRObjects->SetImage( + this->m_Image->GetVTK< vtkImageData >( ) + ); } else QMessageBox::critical( diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.cxx b/lib/cpExtensions/Visualization/ImageSliceActors.cxx index 31787e5..f945bd3 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.cxx +++ b/lib/cpExtensions/Visualization/ImageSliceActors.cxx @@ -170,10 +170,17 @@ GetPlaneFunction( ) const void cpExtensions::Visualization::ImageSliceActors:: AddActor( vtkAlgorithm* algorithm, vtkActor* actor ) { - this->OtherActors.push_back( std::pair< vtkSmartPointer< vtkAlgorithm >, vtkSmartPointer< vtkActor > >( algorithm, actor ) ); + this->OtherActors.push_back( TActorPair( algorithm, actor ) ); this->AddItem( actor ); } +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageSliceActors:: +AddActor( vtkActor* actor ) +{ + this->AddActor( NULL, actor ); +} + // ------------------------------------------------------------------------- void cpExtensions::Visualization::ImageSliceActors:: SetInterpolate( bool v ) @@ -376,12 +383,19 @@ SetSliceNumber( const int& slice ) // Prepare other actors to update for( unsigned int i = 0; i < this->OtherActors.size( ); ++i ) { -#error CLEAN UP CODING STYLE AND NULL POINTER CHECK + if( this->OtherActors[ i ].first.GetPointer( ) != NULL ) + { + this->OtherActors[ i ].first->Modified( ); + this->OtherActors[ i ].first->Update( ); + + } // fi + + if( this->OtherActors[ i ].second.GetPointer( ) != NULL ) + { + this->OtherActors[ i ].second->GetMapper( )->Modified( ); + this->OtherActors[ i ].second->Modified( ); - this->OtherActors[ i ].first->Modified( ); - this->OtherActors[ i ].first->Update( ); - this->OtherActors[ i ].second->GetMapper( )->Modified( ); - this->OtherActors[ i ].second->Modified( ); + } // fi } // rof diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.h b/lib/cpExtensions/Visualization/ImageSliceActors.h index 091b7bc..8889b2f 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.h +++ b/lib/cpExtensions/Visualization/ImageSliceActors.h @@ -55,6 +55,7 @@ namespace cpExtensions const vtkPlane* GetPlaneFunction( ) const; void AddActor( vtkAlgorithm* algorithm, vtkActor* actor ); + void AddActor( vtkActor* actor ); void SetInterpolate( bool v ); void InterpolateOn( ); @@ -86,7 +87,11 @@ namespace cpExtensions // Multiple actors std::vector< vtkSmartPointer< vtkImageSliceMapper > > SliceMappers; std::vector< vtkSmartPointer< vtkImageActor > > ImageActors; - std::vector< std::pair< vtkSmartPointer< vtkAlgorithm >, vtkSmartPointer< vtkActor > > > OtherActors; + + typedef + std::pair< vtkSmartPointer< vtkAlgorithm >, vtkSmartPointer< vtkActor > > + TActorPair; + std::vector< TActorPair > OtherActors; bool Interpolate; // Unique objects diff --git a/lib/cpPlugins/Interface/BaseProcessObjects.cxx b/lib/cpPlugins/Interface/BaseProcessObjects.cxx index 004d939..8177b75 100644 --- a/lib/cpPlugins/Interface/BaseProcessObjects.cxx +++ b/lib/cpPlugins/Interface/BaseProcessObjects.cxx @@ -1,15 +1,15 @@ #include -cpPlugins_Interface_Code_ProcessObject( SourceObject ); -cpPlugins_Interface_Code_ProcessObject( SinkObject ); -cpPlugins_Interface_Code_ProcessObject( FilterObject ); -cpPlugins_Interface_Code_ProcessObject( ImageSource ); -cpPlugins_Interface_Code_ProcessObject( MeshSource ); -cpPlugins_Interface_Code_ProcessObject( ImageSink ); -cpPlugins_Interface_Code_ProcessObject( MeshSink ); -cpPlugins_Interface_Code_ProcessObject( ImageToImageFilter ); -cpPlugins_Interface_Code_ProcessObject( ImageToMeshFilter ); -cpPlugins_Interface_Code_ProcessObject( MeshToImageFilter ); -cpPlugins_Interface_Code_ProcessObject( MeshToMeshFilter ); +cpPlugins_Code_ProcessObject( SourceObject ); +cpPlugins_Code_ProcessObject( SinkObject ); +cpPlugins_Code_ProcessObject( FilterObject ); +cpPlugins_Code_ProcessObject( ImageSource ); +cpPlugins_Code_ProcessObject( MeshSource ); +cpPlugins_Code_ProcessObject( ImageSink ); +cpPlugins_Code_ProcessObject( MeshSink ); +cpPlugins_Code_ProcessObject( ImageToImageFilter ); +cpPlugins_Code_ProcessObject( ImageToMeshFilter ); +cpPlugins_Code_ProcessObject( MeshToImageFilter ); +cpPlugins_Code_ProcessObject( MeshToMeshFilter ); // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/BaseProcessObjects.h b/lib/cpPlugins/Interface/BaseProcessObjects.h index 04c2982..d76d8b6 100644 --- a/lib/cpPlugins/Interface/BaseProcessObjects.h +++ b/lib/cpPlugins/Interface/BaseProcessObjects.h @@ -5,7 +5,7 @@ #include // ------------------------------------------------------------------------- -#define cpPlugins_Interface_Define_ProcessObject( O, S ) \ +#define cpPlugins_Define_ProcessObject( O, S ) \ class cpPlugins_Interface_EXPORT O \ : public S \ { \ @@ -25,7 +25,7 @@ } // ------------------------------------------------------------------------- -#define cpPlugins_Interface_Code_ProcessObject( O ) \ +#define cpPlugins_Code_ProcessObject( O ) \ cpPlugins::Interface::O::O( ) : Superclass( ) \ { \ this->m_ClassName = "cpPlugins::Interface::#O"; \ @@ -34,159 +34,204 @@ cpPlugins::Interface::O::~O( ) { } // ------------------------------------------------------------------------- -#define cpPlugins_Image_Input_Demangle( T, D, I, O, r, f ) \ - if( ( O = I->GetITKImage< itk::Image< T, D > >( ) ) != NULL ) \ - r = this->f< itk::Image< T, D > >( O ) - -// ------------------------------------------------------------------------- -#define cpPlugins_ImageArray_Input_Demangle( A, T, DP, DI, I, O, r, f ) \ - if( \ - ( O = I->GetITKImage< itk::Image< A< T, DP >, DI > >( ) ) != NULL \ - ) \ - r = this->f< itk::Image< A< T, DP >, DI > >( O ) - -// ------------------------------------------------------------------------- -#define cpPlugins_Image_Input_Demangle_Dimension_AllScalarTypes( D, I, O, r, f ) \ - cpPlugins_Image_Input_Demangle( char, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( short, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( int, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( long, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( float, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( double, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( unsigned char, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( unsigned short, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( unsigned int, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( unsigned long, D, I, O, r, f ) - -// ------------------------------------------------------------------------- -#define cpPlugins_Image_Input_Demangle_Dimension_AllTypes( D, I, O, r, f ) \ - cpPlugins_Image_Input_Demangle( char, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( short, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( int, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( long, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( float, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( double, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( unsigned char, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( unsigned short, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( unsigned int, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( unsigned long, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( \ - std::complex< float >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - std::complex< double >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBPixel< char >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBPixel< short >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBPixel< int >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBPixel< long >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBPixel< unsigned char >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBPixel< unsigned short >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBPixel< unsigned int >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBPixel< unsigned long >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBPixel< float >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBPixel< double >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBAPixel< char >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBAPixel< short >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBAPixel< int >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBAPixel< long >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBAPixel< unsigned char >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBAPixel< unsigned short >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBAPixel< unsigned int >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBAPixel< unsigned long >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBAPixel< float >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::RGBAPixel< double >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - itk::Offset< D >, D, I, O, r, f \ - ); \ - else cpPlugins_ImageArray_Input_Demangle( \ - itk::Vector, float, D, D, I, O, r, f \ - ); \ - else cpPlugins_ImageArray_Input_Demangle( \ - itk::Vector, double, D, D, I, O, r, f \ - ); \ - else cpPlugins_ImageArray_Input_Demangle( \ - itk::Point, float, D, D, I, O, r, f \ - ); \ - else cpPlugins_ImageArray_Input_Demangle( \ - itk::Point, double, D, D, I, O, r, f \ - ); \ - else cpPlugins_ImageArray_Input_Demangle( \ - itk::CovariantVector, float, D, D, I, O, r, f \ - ); \ - else cpPlugins_ImageArray_Input_Demangle( \ - itk::CovariantVector, double, D, D, I, O, r, f \ - ); \ - else cpPlugins_ImageArray_Input_Demangle( \ - itk::SymmetricSecondRankTensor, float, D, D, I, O, r, f \ - ); \ - else cpPlugins_ImageArray_Input_Demangle( \ - itk::SymmetricSecondRankTensor, double, D, D, I, O, r, f \ - ) +#define cpPlugins_Image_Demangle( T, D, I, O, R, F ) \ + if( ( O = I->GetITK< itk::Image< T, D > >( ) ) != NULL ) \ + R = this->F< itk::Image< T, D > >( O ) + +// ------------------------------------------------------------------------- +#define cpPlugins_ArrayImage_Demangle( A, T, DI, DA, I, O, R, F ) \ + if( ( O = I->GetITK< itk::Image< A< T, DA >, DI > >( ) ) != NULL ) \ + R = this->F< itk::Image< A< T, DA >, DI > >( O ) + +// ------------------------------------------------------------------------- +#define cpPlugins_VectorImage_Demangle( T, D, I, O, R, F ) \ + if( ( O = I->GetITK< itk::VectorImage< T, D > >( ) ) != NULL ) \ + R = this->F< itk::VectorImage< T, D > >( O ) + +// ------------------------------------------------------------------------- +#define cpPlugins_ArrayVectorImage_Demangle( A, T, DI, DA, I, O, R, F ) \ + if( ( O = I->GetITK< itk::VectorImage< A< T, DA >, DI > >( ) ) != NULL ) \ + R = this->F< itk::VectorImage< A< T, DA >, DI > >( O ) + +// ------------------------------------------------------------------------- +#define cpPlugins_Image_Demangle_AllScalarTypes( D, I, O, R, F ) \ + cpPlugins_Image_Demangle( char, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( short, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( int, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( long, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( unsigned char, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( unsigned short, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( unsigned int, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( unsigned long, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( float, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( double, D, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_Image_Demangle_AllComplexTypes( D, I, O, R, F ) \ + cpPlugins_Image_Demangle( std::complex< float >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( std::complex< double >, D, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_Image_Demangle_AllRGBTypes( D, I, O, R, F ) \ + cpPlugins_Image_Demangle( itk::RGBPixel< char >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBPixel< short >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBPixel< int >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBPixel< long >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBPixel< unsigned char >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBPixel< unsigned short >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBPixel< unsigned int >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBPixel< unsigned long >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBPixel< float >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBPixel< double >, D, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_Image_Demangle_AllRGBATypes( D, I, O, R, F ) \ + cpPlugins_Image_Demangle( itk::RGBAPixel< char >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBAPixel< short >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBAPixel< int >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBAPixel< long >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBAPixel< unsigned char >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBAPixel< unsigned short >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBAPixel< unsigned int >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBAPixel< unsigned long >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBAPixel< float >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::RGBAPixel< double >, D, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_Image_Demangle_AllDiffusionTensor3DTypes( D, I, O, R, F ) \ + cpPlugins_Image_Demangle( itk::DiffusionTensor3D< float >, D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::DiffusionTensor3D< double >, D, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_ArrayImage_Demangle_AllVectorTypes( DI, DA, I, O, R, F ) \ + cpPlugins_ArrayImage_Demangle( itk::Vector, float, DI, DA, I, O, R, F ); \ + else cpPlugins_ArrayImage_Demangle( itk::Vector, double, DI, DA, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_ArrayImage_Demangle_AllCovariantVectorTypes( DI, DA, I, O, R, F ) \ + cpPlugins_ArrayImage_Demangle( itk::CovariantVector, float, DI, DA, I, O, R, F ); \ + else cpPlugins_ArrayImage_Demangle( itk::CovariantVector, double, DI, DA, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_ArrayImage_Demangle_AllPointTypes( DI, DA, I, O, R, F ) \ + cpPlugins_ArrayImage_Demangle( itk::Point, float, DI, DA, I, O, R, F ); \ + else cpPlugins_ArrayImage_Demangle( itk::Point, double, DI, DA, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_ArrayImage_Demangle_AllSymmetricSecondRankTensorTypes( DI, DA, I, O, R, F ) \ + cpPlugins_ArrayImage_Demangle( itk::SymmetricSecondRankTensor, float, DI, DA, I, O, R, F ); \ + else cpPlugins_ArrayImage_Demangle( itk::SymmetricSecondRankTensor, double, DI, DA, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_Image_Demangle_AllTypes( D, I, O, R, F ) \ + cpPlugins_Image_Demangle_AllScalarTypes( D, I, O, R, F ); \ + else cpPlugins_Image_Demangle_AllComplexTypes( D, I, O, R, F ); \ + else cpPlugins_Image_Demangle_AllRGBTypes( D, I, O, R, F ); \ + else cpPlugins_Image_Demangle_AllRGBATypes( D, I, O, R, F ); \ + else cpPlugins_Image_Demangle_AllDiffusionTensor3DTypes( D, I, O, R, F ); \ + else cpPlugins_Image_Demangle( itk::Offset< D >, D, I, O, R, F ); \ + else cpPlugins_ArrayImage_Demangle_AllVectorTypes( D, D, I, O, R, F ); \ + else cpPlugins_ArrayImage_Demangle_AllCovariantVectorTypes( D, D, I, O, R, F ); \ + else cpPlugins_ArrayImage_Demangle_AllPointTypes( D, D, I, O, R, F ); \ + else cpPlugins_ArrayImage_Demangle_AllSymmetricSecondRankTensorTypes( D, D, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_VectorImage_Demangle_AllScalarTypes( D, I, O, R, F ) \ + cpPlugins_VectorImage_Demangle( char, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( short, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( int, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( long, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( unsigned char, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( unsigned short, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( unsigned int, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( unsigned long, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( float, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( double, D, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_VectorImage_Demangle_AllComplexTypes( D, I, O, R, F ) \ + cpPlugins_VectorImage_Demangle( std::complex< float >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( std::complex< double >, D, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_VectorImage_Demangle_AllRGBTypes( D, I, O, R, F ) \ + cpPlugins_VectorImage_Demangle( itk::RGBPixel< char >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBPixel< short >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBPixel< int >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBPixel< long >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBPixel< unsigned char >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBPixel< unsigned short >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBPixel< unsigned int >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBPixel< unsigned long >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBPixel< float >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBPixel< double >, D, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_VectorImage_Demangle_AllRGBATypes( D, I, O, R, F ) \ + cpPlugins_VectorImage_Demangle( itk::RGBAPixel< char >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBAPixel< short >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBAPixel< int >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBAPixel< long >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBAPixel< unsigned char >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBAPixel< unsigned short >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBAPixel< unsigned int >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBAPixel< unsigned long >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBAPixel< float >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::RGBAPixel< double >, D, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_VectorImage_Demangle_AllDiffusionTensor3DTypes( D, I, O, R, F ) \ + cpPlugins_VectorImage_Demangle( itk::DiffusionTensor3D< float >, D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::DiffusionTensor3D< double >, D, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_ArrayVectorImage_Demangle_AllVectorTypes( DI, DA, I, O, R, F ) \ + cpPlugins_ArrayVectorImage_Demangle( itk::Vector, float, DI, DA, I, O, R, F ); \ + else cpPlugins_ArrayVectorImage_Demangle( itk::Vector, double, DI, DA, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_ArrayVectorImage_Demangle_AllCovariantVectorTypes( DI, DA, I, O, R, F ) \ + cpPlugins_ArrayVectorImage_Demangle( itk::CovariantVector, float, DI, DA, I, O, R, F ); \ + else cpPlugins_ArrayVectorImage_Demangle( itk::CovariantVector, double, DI, DA, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_ArrayVectorImage_Demangle_AllPointTypes( DI, DA, I, O, R, F ) \ + cpPlugins_ArrayVectorImage_Demangle( itk::Point, float, DI, DA, I, O, R, F ); \ + else cpPlugins_ArrayVectorImage_Demangle( itk::Point, double, DI, DA, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_ArrayVectorImage_Demangle_AllSymmetricSecondRankTensorTypes( DI, DA, I, O, R, F ) \ + cpPlugins_ArrayVectorImage_Demangle( itk::SymmetricSecondRankTensor, float, DI, DA, I, O, R, F ); \ + else cpPlugins_ArrayVectorImage_Demangle( itk::SymmetricSecondRankTensor, double, DI, DA, I, O, R, F ) + +// ------------------------------------------------------------------------- +#define cpPlugins_VectorImage_Demangle_AllTypes( D, I, O, R, F ) \ + cpPlugins_VectorImage_Demangle_AllScalarTypes( D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle_AllComplexTypes( D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle_AllRGBTypes( D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle_AllRGBATypes( D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle_AllDiffusionTensor3DTypes( D, I, O, R, F ); \ + else cpPlugins_VectorImage_Demangle( itk::Offset< D >, D, I, O, R, F ); \ + else cpPlugins_ArrayVectorImage_Demangle_AllVectorTypes( D, D, I, O, R, F ); \ + else cpPlugins_ArrayVectorImage_Demangle_AllCovariantVectorTypes( D, D, I, O, R, F ); \ + else cpPlugins_ArrayVectorImage_Demangle_AllPointTypes( D, D, I, O, R, F ); \ + else cpPlugins_ArrayVectorImage_Demangle_AllSymmetricSecondRankTensorTypes( D, D, I, O, R, F ) namespace cpPlugins { namespace Interface { - cpPlugins_Interface_Define_ProcessObject( SourceObject, ProcessObject ); - cpPlugins_Interface_Define_ProcessObject( SinkObject, ProcessObject ); - cpPlugins_Interface_Define_ProcessObject( FilterObject, ProcessObject ); - cpPlugins_Interface_Define_ProcessObject( ImageSource, SourceObject ); - cpPlugins_Interface_Define_ProcessObject( MeshSource, SourceObject ); - cpPlugins_Interface_Define_ProcessObject( ImageSink, SinkObject ); - cpPlugins_Interface_Define_ProcessObject( MeshSink, SinkObject ); - cpPlugins_Interface_Define_ProcessObject( - ImageToImageFilter, FilterObject - ); - cpPlugins_Interface_Define_ProcessObject( - ImageToMeshFilter, FilterObject - ); - cpPlugins_Interface_Define_ProcessObject( - MeshToImageFilter, FilterObject - ); - cpPlugins_Interface_Define_ProcessObject( - MeshToMeshFilter, FilterObject - ); + cpPlugins_Define_ProcessObject( SourceObject, ProcessObject ); + cpPlugins_Define_ProcessObject( SinkObject, ProcessObject ); + cpPlugins_Define_ProcessObject( FilterObject, ProcessObject ); + cpPlugins_Define_ProcessObject( ImageSource, SourceObject ); + cpPlugins_Define_ProcessObject( MeshSource, SourceObject ); + cpPlugins_Define_ProcessObject( ImageSink, SinkObject ); + cpPlugins_Define_ProcessObject( MeshSink, SinkObject ); + cpPlugins_Define_ProcessObject( ImageToImageFilter, FilterObject ); + cpPlugins_Define_ProcessObject( ImageToMeshFilter, FilterObject ); + cpPlugins_Define_ProcessObject( MeshToImageFilter, FilterObject ); + cpPlugins_Define_ProcessObject( MeshToMeshFilter, FilterObject ); } // ecapseman diff --git a/lib/cpPlugins/Interface/CMakeLists.txt b/lib/cpPlugins/Interface/CMakeLists.txt index 8ee6221..a607fca 100644 --- a/lib/cpPlugins/Interface/CMakeLists.txt +++ b/lib/cpPlugins/Interface/CMakeLists.txt @@ -10,68 +10,14 @@ CONFIGURE_FILE( ## = Source code = ## =============== -SET( - LIB_HEADERS_H - BaseProcessObjects.h - DataObject.h - Image.h - ImplicitFunction.h - Interface.h - Macros.h - Mesh.h - Object.h - Parameters.h - ProcessObject.h - ) - -SET( - LIB_HEADERS_HPP - ) - -SET( - LIB_HEADERS_HXX - Image.hxx - ImplicitFunction.hxx - Mesh.hxx - Parameters.hxx - ProcessObject.hxx - ) - -SET( - LIB_SOURCES_C - ) -SET( - LIB_SOURCES_CPP - ) - -SET( - LIB_SOURCES_CXX - Instances_itkImage.cxx - Instances_itkVectorImage.cxx - Instances_itkMesh.cxx - BaseProcessObjects.cxx - DataObject.cxx - Image.cxx - ImplicitFunction.cxx - Interface.cxx - Mesh.cxx - Object.cxx - Parameters.cxx - ProcessObject.cxx - ) +FILE(GLOB LIB_HEADERS_H "*.h") +FILE(GLOB LIB_HEADERS_HPP "*.hpp") +FILE(GLOB LIB_HEADERS_HXX "*.hxx") +FILE(GLOB LIB_SOURCES_C "*.c") +FILE(GLOB LIB_SOURCES_CPP "*.cpp") +FILE(GLOB LIB_SOURCES_CXX "*.cxx") IF(USE_QT4) - SET( - LIB_HEADERS_H - ${LIB_HEADERS_H} - ParametersQtDialog.h - ) - SET( - LIB_SOURCES_CXX - ${LIB_SOURCES_CXX} - ParametersQtDialog.cxx - ) - SET( LIB_QT_UI ParametersListWidget.ui diff --git a/lib/cpPlugins/Interface/DataObject.cxx b/lib/cpPlugins/Interface/DataObject.cxx index d68d2b7..536ea81 100644 --- a/lib/cpPlugins/Interface/DataObject.cxx +++ b/lib/cpPlugins/Interface/DataObject.cxx @@ -1,4 +1,6 @@ #include + +#include #include #include @@ -32,29 +34,27 @@ SetSource( cpPlugins::Interface::Object* src ) void cpPlugins::Interface::DataObject:: DisconnectPipeline( ) { - if( this->m_ITKObject.IsNotNull( ) ) - { - // Disconnect input pipelines - this->m_ITKObject->DisconnectPipeline( ); - vtkImageData* vtk_image = - dynamic_cast< vtkImageData* >( this->m_VTKObject.GetPointer( ) ); - vtkPolyData* vtk_pd = - dynamic_cast< vtkPolyData* >( this->m_VTKObject.GetPointer( ) ); - 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; + // Disconnect input pipelines (ITK) + itk::DataObject* itk_obj = this->GetITK< itk::DataObject >( ); + if( itk_obj != NULL ) + itk_obj->DisconnectPipeline( ); - } // fi + // 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 diff --git a/lib/cpPlugins/Interface/DataObject.h b/lib/cpPlugins/Interface/DataObject.h index aad9977..3347b64 100644 --- a/lib/cpPlugins/Interface/DataObject.h +++ b/lib/cpPlugins/Interface/DataObject.h @@ -1,14 +1,13 @@ #ifndef __CPPLUGINS__INTERFACE__DATAOBJECT__H__ #define __CPPLUGINS__INTERFACE__DATAOBJECT__H__ -#include -#include -#include -#include #include #include -#include +#include + +#include +#include namespace cpPlugins { @@ -35,6 +34,18 @@ namespace cpPlugins void DisconnectPipeline( ); + template< class T > + inline T* GetITK( ); + + template< class T > + inline const T* GetITK( ) const; + + template< class T > + inline T* GetVTK( ); + + template< class T > + inline const T* GetVTK( ) const; + protected: DataObject( ); virtual ~DataObject( ); @@ -45,7 +56,7 @@ namespace cpPlugins Self& operator=( const Self& ); protected: - itk::DataObject::Pointer m_ITKObject; + itk::Object::Pointer m_ITKObject; vtkSmartPointer< vtkObject > m_VTKObject; Object::Pointer m_Source; }; @@ -54,6 +65,8 @@ namespace cpPlugins } // ecapseman +#include + #endif // __CPPLUGINS__INTERFACE__DATAOBJECT__H__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/DataObject.hxx b/lib/cpPlugins/Interface/DataObject.hxx new file mode 100644 index 0000000..a7e6c63 --- /dev/null +++ b/lib/cpPlugins/Interface/DataObject.hxx @@ -0,0 +1,38 @@ +#ifndef __CPPLUGINS__INTERFACE__DATAOBJECT__HXX__ +#define __CPPLUGINS__INTERFACE__DATAOBJECT__HXX__ + +// ------------------------------------------------------------------------- +template< class T > +T* cpPlugins::Interface::DataObject:: +GetITK( ) +{ + return( dynamic_cast< T* >( this->m_ITKObject.GetPointer( ) ) ); +} + +// ------------------------------------------------------------------------- +template< class T > +const T* cpPlugins::Interface::DataObject:: +GetITK( ) const +{ + return( dynamic_cast< const T* >( this->m_ITKObject.GetPointer( ) ) ); +} + +// ------------------------------------------------------------------------- +template< class T > +T* cpPlugins::Interface::DataObject:: +GetVTK( ) +{ + return( dynamic_cast< T* >( this->m_VTKObject.GetPointer( ) ) ); +} + +// ------------------------------------------------------------------------- +template< class T > +const T* cpPlugins::Interface::DataObject:: +GetVTK( ) const +{ + return( dynamic_cast< const T* >( this->m_VTKObject.GetPointer( ) ) ); +} + +#endif // __CPPLUGINS__INTERFACE__DATAOBJECT__HXX__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Image.cxx b/lib/cpPlugins/Interface/Image.cxx index b0d18b0..ad7b3ad 100644 --- a/lib/cpPlugins/Interface/Image.cxx +++ b/lib/cpPlugins/Interface/Image.cxx @@ -1,203 +1,14 @@ #include -/* TODO - #include - #include - - #define ITK_MANUAL_INSTANTIATION - #include - #include - - #include - #include - #include - #include - #include - #include - #include -*/ - -// ------------------------------------------------------------------------- -/* TODO - void cpPlugins::Interface::Image:: - SetITKDataObject( itk::DataObject* o ) - { - bool r; - if( dynamic_cast< itk::ImageBase< 1 >* >( o ) != NULL ) - { - cpPlugins_Image_Array_Demangle( - itk::Vector, float, 1, 1, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::Vector, double, 1, 1, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::Point, float, 1, 1, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::Point, double, 1, 1, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::CovariantVector, float, 1, 1, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::CovariantVector, double, 1, 1, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::SymmetricSecondRankTensor, float, 1, 1, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::SymmetricSecondRankTensor, double, 1, 1, o, _Type, r - ); - else r = this->_Dim< 1 >( o ); - } - else if( dynamic_cast< itk::ImageBase< 2 >* >( o ) != NULL ) - { - cpPlugins_Image_Demangle( - itk::RGBPixel< char >, 2, o, _Type, r - ); - else cpPlugins_Image_Demangle( - itk::RGBPixel< short >, 2, o, _Type, r - ); - else cpPlugins_Image_Demangle( - itk::RGBPixel< unsigned char >, 2, o, _Type, r - ); - else cpPlugins_Image_Demangle( - itk::RGBPixel< unsigned short >, 2, o, _Type, r - ); - else cpPlugins_Image_Demangle( - itk::RGBAPixel< char >, 2, o, _Type, r - ); - else cpPlugins_Image_Demangle( - itk::RGBAPixel< short >, 2, o, _Type, r - ); - else cpPlugins_Image_Demangle( - itk::RGBAPixel< unsigned char >, 2, o, _Type, r - ); - else cpPlugins_Image_Demangle( - itk::RGBAPixel< unsigned short >, 2, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::Vector, float, 2, 2, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::Vector, double, 2, 2, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::Point, float, 2, 2, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::Point, double, 2, 2, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::CovariantVector, float, 2, 2, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::CovariantVector, double, 2, 2, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::SymmetricSecondRankTensor, float, 2, 2, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::SymmetricSecondRankTensor, double, 2, 2, o, _Type, r - ); - else r = this->_Dim< 2 >( o ); - } - else if( dynamic_cast< itk::ImageBase< 3 >* >( o ) != NULL ) - { - cpPlugins_Image_Demangle( - itk::RGBPixel< char >, 3, o, _Type, r - ); - else cpPlugins_Image_Demangle( - itk::RGBPixel< short >, 3, o, _Type, r - ); - else cpPlugins_Image_Demangle( - itk::RGBPixel< unsigned char >, 3, o, _Type, r - ); - else cpPlugins_Image_Demangle( - itk::RGBPixel< unsigned short >, 3, o, _Type, r - ); - else cpPlugins_Image_Demangle( - itk::RGBAPixel< char >, 3, o, _Type, r - ); - else cpPlugins_Image_Demangle( - itk::RGBAPixel< short >, 3, o, _Type, r - ); - else cpPlugins_Image_Demangle( - itk::RGBAPixel< unsigned char >, 3, o, _Type, r - ); - else cpPlugins_Image_Demangle( - itk::RGBAPixel< unsigned short >, 3, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::Vector, float, 3, 3, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::Vector, double, 3, 3, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::Point, float, 3, 3, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::Point, double, 3, 3, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::CovariantVector, float, 3, 3, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::CovariantVector, double, 3, 3, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::SymmetricSecondRankTensor, float, 3, 3, o, _Type, r - ); - else cpPlugins_Image_Array_Demangle( - itk::SymmetricSecondRankTensor, double, 3, 3, o, _Type, r - ); - else cpPlugins_Image_Demangle( - itk::DiffusionTensor3D< float >, 3, o, _Type, r - ); - else cpPlugins_Image_Demangle( - itk::DiffusionTensor3D< double >, 3, o, _Type, r - ); - else r = this->_Dim< 3 >( o ); - } - else if( dynamic_cast< itk::ImageBase< 4 >* >( o ) != NULL ) - { - this->m_ITKObject = o; - this->m_VTKObject = NULL; - this->m_ITKvVTKConnection = NULL; - - } // fi - } -*/ - // ------------------------------------------------------------------------- void cpPlugins::Interface::Image:: -SetVTKImageData( vtkImageData* image ) +SetVTK( vtkObject* image ) { // this->m_VTKObject = image; std::cerr << "Image: TODO this!!!!" << std::endl; std::exit( 1 ); } -// ------------------------------------------------------------------------- -vtkImageData* cpPlugins::Interface::Image:: -GetVTKImageData( ) -{ - return( - dynamic_cast< vtkImageData* >( this->m_VTKObject.GetPointer( ) ) - ); -} - -// ------------------------------------------------------------------------- -const vtkImageData* cpPlugins::Interface::Image:: -GetVTKImageData( ) const -{ - return( - dynamic_cast< const vtkImageData* >( this->m_VTKObject.GetPointer( ) ) - ); -} - // ------------------------------------------------------------------------- cpPlugins::Interface::Image:: Image( ) @@ -213,70 +24,4 @@ cpPlugins::Interface::Image:: { } -// ------------------------------------------------------------------------- -/* TODO - template< unsigned int D > - bool cpPlugins::Interface::Image:: - _Dim( itk::DataObject* o ) - { - bool r; - cpPlugins_Image_Demangle( - char, D, o, _Type, r - ); - else cpPlugins_Image_Demangle( - short, D, o, _Type, r - ); - else cpPlugins_Image_Demangle( - int, D, o, _Type, r - ); - else cpPlugins_Image_Demangle( - long, D, o, _Type, r - ); - else cpPlugins_Image_Demangle( - unsigned char, D, o, _Type, r - ); - else cpPlugins_Image_Demangle( - unsigned short, D, o, _Type, r - ); - else cpPlugins_Image_Demangle( - unsigned int, D, o, _Type, r - ); - else cpPlugins_Image_Demangle( - unsigned long, D, o, _Type, r - ); - else cpPlugins_Image_Demangle( - float, D, o, _Type, r - ); - else cpPlugins_Image_Demangle( - double, D, o, _Type, r - ); - else - { - this->m_ITKObject = o; - this->m_VTKObject = NULL; - this->m_ITKvVTKConnection = NULL; - - } // fi - return( true ); - } - - // ------------------------------------------------------------------------- - template< class I > - bool cpPlugins::Interface::Image:: - _Type( itk::DataObject* o ) - { - typedef itk::ImageToVTKImageFilter< I > _F; - - typename _F::Pointer f = _F::New( ); - f->SetInput( dynamic_cast< I* >( o ) ); - f->Update( ); - - this->m_ITKObject = o; - this->m_VTKObject = f->GetOutput( ); - this->m_ITKvVTKConnection = f; - - return( true ); - } -*/ - // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Image.h b/lib/cpPlugins/Interface/Image.h index a5beda3..5d0d55b 100644 --- a/lib/cpPlugins/Interface/Image.h +++ b/lib/cpPlugins/Interface/Image.h @@ -30,24 +30,16 @@ namespace cpPlugins public: template< class I > - inline void SetITKImage( itk::DataObject* object ); + inline void SetITK( itk::Object* object ); - template< class I > - inline I* GetITKImage( ); - - template< class I > - inline const I* GetITKImage( ) const; - - virtual void SetVTKImageData( vtkImageData* image ); - virtual vtkImageData* GetVTKImageData( ); - virtual const vtkImageData* GetVTKImageData( ) const; + virtual void SetVTK( vtkObject* image ); protected: Image( ); virtual ~Image( ); template< class P, unsigned int D > - inline void _ITK_2_VTK( itk::DataObject* object ); + inline void _ITK_2_VTK( itk::Object* object ); private: // Purposely not implemented diff --git a/lib/cpPlugins/Interface/Image.hxx b/lib/cpPlugins/Interface/Image.hxx index b6794a3..2f5f1d5 100644 --- a/lib/cpPlugins/Interface/Image.hxx +++ b/lib/cpPlugins/Interface/Image.hxx @@ -3,7 +3,10 @@ #include +#include + #include +#include #include #include @@ -15,240 +18,29 @@ #include // ------------------------------------------------------------------------- -#define cpPlugins_Image_Demangle( TI, T, D, o ) \ - if( typeid( typename TI::PixelType ) == typeid( T ) ) \ +#define cpPlugins_VTKImage_Demangle( TI, T, D, o ) \ + if( typeid( TI ) == typeid( itk::Image< T, D > ) ) \ this->_ITK_2_VTK< T, D >( o ) // ------------------------------------------------------------------------- -#define cpPlugins_ImageArray_Demangle( TI, T, P, DP, DI, o ) \ - if( typeid( typename TI::PixelType ) == typeid( T< P, DP > ) ) \ +#define cpPlugins_VTKImageArray_Demangle( TI, T, P, DP, DI, o ) \ + if( typeid( TI ) == typeid( itk::Image< T< P, DP >, DI > ) ) \ this->_ITK_2_VTK< T< P, DP >, DI >( o ) // ------------------------------------------------------------------------- -#define cpPlugins_Image_Demangle_Dimension( TI, D, o ) \ - cpPlugins_Image_Demangle( TI, char, D, o ); \ - else cpPlugins_Image_Demangle( TI, short, D, o ); \ - else cpPlugins_Image_Demangle( TI, int, D, o ); \ - else cpPlugins_Image_Demangle( TI, long, D, o ); \ - else cpPlugins_Image_Demangle( TI, float, D, o ); \ - else cpPlugins_Image_Demangle( TI, double, D, o ); \ - else cpPlugins_Image_Demangle( TI, unsigned char, D, o ); \ - else cpPlugins_Image_Demangle( TI, unsigned short, D, o ); \ - else cpPlugins_Image_Demangle( TI, unsigned int, D, o ); \ - else cpPlugins_Image_Demangle( TI, unsigned long, D, o ); \ - else cpPlugins_Image_Demangle( TI, itk::RGBPixel< char >, D, o ); \ - else cpPlugins_Image_Demangle( TI, itk::RGBPixel< short >, D, o ); \ - else cpPlugins_Image_Demangle( \ - TI, itk::RGBPixel< unsigned char >, D, o \ - ); \ - else cpPlugins_Image_Demangle( \ - TI, itk::RGBPixel< unsigned short >, D, o \ - ); \ - else cpPlugins_Image_Demangle( TI, itk::RGBAPixel< char >, D, o ); \ - else cpPlugins_Image_Demangle( TI, itk::RGBAPixel< short >, D, o ); \ - else cpPlugins_Image_Demangle( \ - TI, itk::RGBAPixel< unsigned char >, D, o \ - ); \ - else cpPlugins_Image_Demangle( \ - TI, itk::RGBAPixel< unsigned short >, D, o \ - ); \ - else cpPlugins_ImageArray_Demangle( \ - TI, itk::Vector, float, D, D, o \ - ); \ - else cpPlugins_ImageArray_Demangle( \ - TI, itk::Vector, double, D, D, o \ - ); \ - else cpPlugins_ImageArray_Demangle( \ - TI, itk::CovariantVector, float, D, D, o \ - ); \ - else cpPlugins_ImageArray_Demangle( \ - TI, itk::CovariantVector, double, D, D, o \ - ); \ - else cpPlugins_ImageArray_Demangle( TI, itk::Point, float, D, D, o ); \ - else cpPlugins_ImageArray_Demangle( \ - TI, itk::Point, double, D, D, o \ - ); \ - else cpPlugins_ImageArray_Demangle( \ - TI, itk::SymmetricSecondRankTensor, float, D, D, o \ - ); \ - else cpPlugins_ImageArray_Demangle( \ - TI, itk::SymmetricSecondRankTensor, double, D, D, o \ - ) - -// ------------------------------------------------------------------------- -#define cpPlugins_Image_Import( T, D ) \ - cpPlugins_TEMPLATE_IMPORT( \ - 2(class cpPlugins_Interface_EXPORT itk::Image< T, D >) \ - ) - -// ------------------------------------------------------------------------- -#define cpPlugins_VTKImage_Import( T, D ) \ - cpPlugins_TEMPLATE_IMPORT( \ - 2( \ - class cpPlugins_Interface_EXPORT \ - itk::ImageToVTKImageFilter< itk::Image< T, D > > \ - ) \ - ) - -// ------------------------------------------------------------------------- -#define cpPlugins_ImageArray_Import( A, T, DA, DI ) \ - cpPlugins_TEMPLATE_IMPORT( \ - 3( \ - class cpPlugins_Interface_EXPORT \ - itk::Image< itk::A< T, DA >, DI > \ - ) \ - ) - -// ------------------------------------------------------------------------- -#define cpPlugins_VTKImageArray_Import( A, T, DA, DI ) \ - cpPlugins_TEMPLATE_IMPORT( \ - 3( \ - class cpPlugins_Interface_EXPORT \ - itk::ImageToVTKImageFilter< itk::Image< itk::A< T, DA >, DI > > \ - ) \ - ) - -// ------------------------------------------------------------------------- -#define cpPlugins_Image_Import_AllDimensions( T ) \ - cpPlugins_Image_Import( T, 2 ); \ - cpPlugins_Image_Import( T, 3 ); \ - cpPlugins_Image_Import( T, 4 ) - -// ------------------------------------------------------------------------- -#define cpPlugins_VTKImage_Import_AllDimensions( T ) \ - cpPlugins_VTKImage_Import( T, 2 ); \ - cpPlugins_VTKImage_Import( T, 3 ) - -// ------------------------------------------------------------------------- -#define cpPlugins_ImageArray_Import_AllDimensions( A, T ) \ - cpPlugins_ImageArray_Import( A, T, 2, 2 ); \ - cpPlugins_ImageArray_Import( A, T, 3, 3 ); \ - cpPlugins_ImageArray_Import( A, T, 4, 4 ) - -// ------------------------------------------------------------------------- -#define cpPlugins_VTKImageArray_Import_AllDimensions( A, T ) \ - cpPlugins_VTKImageArray_Import( A, T, 2, 2 ); \ - cpPlugins_VTKImageArray_Import( A, T, 3, 3 ) - -// ------------------------------------------------------------------------- -// ITK base clases - -#ifndef cpPlugins_Interface_EXPORTS - -cpPlugins_Image_Import_AllDimensions( char ); -cpPlugins_Image_Import_AllDimensions( short ); -cpPlugins_Image_Import_AllDimensions( int ); -cpPlugins_Image_Import_AllDimensions( long ); -cpPlugins_Image_Import_AllDimensions( unsigned char ); -cpPlugins_Image_Import_AllDimensions( unsigned short ); -cpPlugins_Image_Import_AllDimensions( unsigned int ); -cpPlugins_Image_Import_AllDimensions( unsigned long ); -cpPlugins_Image_Import_AllDimensions( float ); -cpPlugins_Image_Import_AllDimensions( double ); - -cpPlugins_Image_Import_AllDimensions( std::complex< float > ); -cpPlugins_Image_Import_AllDimensions( std::complex< double > ); - -cpPlugins_Image_Import_AllDimensions( itk::RGBPixel< char > ); -cpPlugins_Image_Import_AllDimensions( itk::RGBPixel< short > ); -cpPlugins_Image_Import_AllDimensions( itk::RGBPixel< int > ); -cpPlugins_Image_Import_AllDimensions( itk::RGBPixel< long > ); -cpPlugins_Image_Import_AllDimensions( itk::RGBPixel< unsigned char > ); -cpPlugins_Image_Import_AllDimensions( itk::RGBPixel< unsigned short > ); -cpPlugins_Image_Import_AllDimensions( itk::RGBPixel< unsigned int > ); -cpPlugins_Image_Import_AllDimensions( itk::RGBPixel< unsigned long > ); - -cpPlugins_Image_Import_AllDimensions( itk::RGBAPixel< char > ); -cpPlugins_Image_Import_AllDimensions( itk::RGBAPixel< short > ); -cpPlugins_Image_Import_AllDimensions( itk::RGBAPixel< int > ); -cpPlugins_Image_Import_AllDimensions( itk::RGBAPixel< long > ); -cpPlugins_Image_Import_AllDimensions( itk::RGBAPixel< unsigned char > ); -cpPlugins_Image_Import_AllDimensions( itk::RGBAPixel< unsigned short > ); -cpPlugins_Image_Import_AllDimensions( itk::RGBAPixel< unsigned int > ); -cpPlugins_Image_Import_AllDimensions( itk::RGBAPixel< unsigned long > ); - -cpPlugins_ImageArray_Import_AllDimensions( Vector, float ); -cpPlugins_ImageArray_Import_AllDimensions( Vector, double ); - -cpPlugins_ImageArray_Import_AllDimensions( CovariantVector, float ); -cpPlugins_ImageArray_Import_AllDimensions( CovariantVector, double ); - -cpPlugins_ImageArray_Import_AllDimensions( Point, float ); -cpPlugins_ImageArray_Import_AllDimensions( Point, double ); - -cpPlugins_ImageArray_Import_AllDimensions( - SymmetricSecondRankTensor, float - ); -cpPlugins_ImageArray_Import_AllDimensions( - SymmetricSecondRankTensor, double - ); - -cpPlugins_Image_Import( itk::DiffusionTensor3D< float >, 3 ); -cpPlugins_Image_Import( itk::DiffusionTensor3D< double >, 3 ); -cpPlugins_Image_Import( itk::Offset< 2 >, 2 ); -cpPlugins_Image_Import( itk::Offset< 3 >, 3 ); -cpPlugins_Image_Import( itk::Offset< 4 >, 4 ); +#define cpPlugins_VTKImage_Demangle_AllDims( TI, T, o ) \ + cpPlugins_VTKImage_Demangle( TI, T, 2, o ); \ + else cpPlugins_VTKImage_Demangle( TI, T, 3, o ) // ------------------------------------------------------------------------- -// ITK<->VTK base clases -cpPlugins_VTKImage_Import_AllDimensions( char ); -cpPlugins_VTKImage_Import_AllDimensions( short ); -cpPlugins_VTKImage_Import_AllDimensions( int ); -cpPlugins_VTKImage_Import_AllDimensions( long ); -cpPlugins_VTKImage_Import_AllDimensions( unsigned char ); -cpPlugins_VTKImage_Import_AllDimensions( unsigned short ); -cpPlugins_VTKImage_Import_AllDimensions( unsigned int ); -cpPlugins_VTKImage_Import_AllDimensions( unsigned long ); -cpPlugins_VTKImage_Import_AllDimensions( float ); -cpPlugins_VTKImage_Import_AllDimensions( double ); - -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBPixel< char > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBPixel< short > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBPixel< int > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBPixel< long > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBPixel< unsigned char > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBPixel< unsigned short > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBPixel< unsigned int > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBPixel< unsigned long > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBPixel< float > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBPixel< double > ); - -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< char > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< short > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< int > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< long > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< unsigned char > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< unsigned short > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< unsigned int > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< unsigned long > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< float > ); -cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< double > ); - -cpPlugins_VTKImageArray_Import_AllDimensions( Vector, float ); -cpPlugins_VTKImageArray_Import_AllDimensions( Vector, double ); - -cpPlugins_VTKImageArray_Import_AllDimensions( CovariantVector, float ); -cpPlugins_VTKImageArray_Import_AllDimensions( CovariantVector, double ); - -cpPlugins_VTKImageArray_Import_AllDimensions( Point, float ); -cpPlugins_VTKImageArray_Import_AllDimensions( Point, double ); - -cpPlugins_VTKImageArray_Import_AllDimensions( - SymmetricSecondRankTensor, float - ); -cpPlugins_VTKImageArray_Import_AllDimensions( - SymmetricSecondRankTensor, double - ); - -cpPlugins_VTKImage_Import( itk::DiffusionTensor3D< float >, 3 ); -cpPlugins_VTKImage_Import( itk::DiffusionTensor3D< double >, 3 ); - -#endif // cpPlugins_Interface_EXPORTS +#define cpPlugins_VTKImageArray_Demangle_AllDims( TI, T, P, o ) \ + cpPlugins_VTKImageArray_Demangle( TI, T, P, 2, 2, o ); \ + else cpPlugins_VTKImageArray_Demangle( TI, T, P, 3, 3, o ) // ------------------------------------------------------------------------- template< class I > void cpPlugins::Interface::Image:: -SetITKImage( itk::DataObject* object ) +SetITK( itk::Object* object ) { // Check if input object has the desired type I* image = dynamic_cast< I* >( object ); @@ -262,32 +54,46 @@ SetITKImage( itk::DataObject* object ) } // fi // Connect it to VTK - if( I::ImageDimension == 2 ) - { - cpPlugins_Image_Demangle_Dimension( I, 2, object ); - else - { - this->m_VTKObject = NULL; - this->m_ITKvVTKConnection = NULL; - - } // fi - } - else if( I::ImageDimension == 3 ) - { - cpPlugins_Image_Demangle_Dimension( I, 3, object ); - else cpPlugins_Image_Demangle( - I, itk::DiffusionTensor3D< float >, 3, object - ); - else cpPlugins_Image_Demangle( - I, itk::DiffusionTensor3D< double >, 3, object - ); - else - { - this->m_VTKObject = NULL; - this->m_ITKvVTKConnection = NULL; - - } // fi - } + cpPlugins_VTKImage_Demangle_AllDims( I, char, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, short, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, int, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, long, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, unsigned char, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, unsigned short, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, unsigned int, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, unsigned long, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, float, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, double, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< char >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< short >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< int >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< long >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< unsigned char >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< unsigned short >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< unsigned int >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< unsigned long >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< float >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< double >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< char >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< short >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< int >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< long >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< unsigned char >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< unsigned short >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< unsigned int >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< unsigned long >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< float >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< double >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::DiffusionTensor3D< float >, image ); + else cpPlugins_VTKImage_Demangle_AllDims( I, itk::DiffusionTensor3D< double >, image ); + else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::Vector, float, image ); + else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::Vector, double, image ); + else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::CovariantVector, float, image ); + else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::CovariantVector, double, image ); + else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::Point, float, image ); + else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::Point, double, image ); + else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::SymmetricSecondRankTensor, float, image ); + else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::SymmetricSecondRankTensor, double, image ); else { this->m_VTKObject = NULL; @@ -300,26 +106,10 @@ SetITKImage( itk::DataObject* object ) this->Modified( ); } -// ------------------------------------------------------------------------- -template< class I > -I* cpPlugins::Interface::Image:: -GetITKImage( ) -{ - return( dynamic_cast< I* >( this->m_ITKObject.GetPointer( ) ) ); -} - -// ------------------------------------------------------------------------- -template< class I > -const I* cpPlugins::Interface::Image:: -GetITKImage( ) const -{ - return( dynamic_cast< const I* >( this->m_ITKObject.GetPointer( ) ) ); -} - // ------------------------------------------------------------------------- template< class P, unsigned int D > void cpPlugins::Interface::Image:: -_ITK_2_VTK( itk::DataObject* object ) +_ITK_2_VTK( itk::Object* object ) { typedef itk::Image< P, D > _I; @@ -339,6 +129,236 @@ _ITK_2_VTK( itk::DataObject* object ) this->m_ITKvVTKConnection = f; } +#ifndef cpPlugins_Interface_EXPORTS + +// ========================================================================= +// ========== Declare import itk::Image types ========== +// ========================================================================= + +// ------------------------------------------------------------------------- +#define cpPlugins_ITKImage_Import( T, D ) \ + cpPlugins_TEMPLATE_IMPORT( \ + 2(class cpPlugins_Interface_EXPORT itk::Image< T, D >) \ + ) + +// ------------------------------------------------------------------------- +#define cpPlugins_ITKArrayImage_Import( A, T, DA, DI ) \ + cpPlugins_TEMPLATE_IMPORT( \ + 3(class cpPlugins_Interface_EXPORT itk::Image< A< T, DA >, DI >) \ + ) + +// ------------------------------------------------------------------------- +#define cpPlugins_ITKImage_AllDims_Import( T ) \ + cpPlugins_ITKImage_Import( T, 2 ); \ + cpPlugins_ITKImage_Import( T, 3 ); \ + cpPlugins_ITKImage_Import( T, 4 ) + +// ------------------------------------------------------------------------- +#define cpPlugins_ITKArrayImage_AllDims_Import( A, T ) \ + cpPlugins_ITKArrayImage_Import( A, T, 2, 2 ); \ + cpPlugins_ITKArrayImage_Import( A, T, 3, 3 ); \ + cpPlugins_ITKArrayImage_Import( A, T, 4, 4 ) + +// ------------------------------------------------------------------------- +#define cpPlugins_VTKImage_Import( T, D ) \ + cpPlugins_TEMPLATE_IMPORT( \ + 2( \ + class cpPlugins_Interface_EXPORT \ + itk::ImageToVTKImageFilter< itk::Image< T, D > > \ + ) \ + ) + +// ------------------------------------------------------------------------- +#define cpPlugins_VTKArrayImage_Import( A, T, DA, DI ) \ + cpPlugins_TEMPLATE_IMPORT( \ + 3(class \ + cpPlugins_Interface_EXPORT \ + itk::ImageToVTKImageFilter< itk::Image< A< T, DA >, DI > >) \ + ) + +// ------------------------------------------------------------------------- +#define cpPlugins_VTKImage_AllDims_Import( T ) \ + cpPlugins_VTKImage_Import( T, 2 ); \ + cpPlugins_VTKImage_Import( T, 3 ) + +// ------------------------------------------------------------------------- +#define cpPlugins_VTKArrayImage_AllDims_Import( A, T ) \ + cpPlugins_VTKArrayImage_Import( A, T, 2, 2 ); \ + cpPlugins_VTKArrayImage_Import( A, T, 3, 3 ) + +// ------------------------------------------------------------------------- +#define cpPlugins_Image_Import( T, D ) \ + cpPlugins_ITKImage_Import( T, D ); \ + cpPlugins_VTKImage_Import( T, D ) \ + +// ------------------------------------------------------------------------- +#define cpPlugins_Image_AllDims_Import( T ) \ + cpPlugins_ITKImage_AllDims_Import( T ); \ + cpPlugins_VTKImage_AllDims_Import( T ) \ + +// ------------------------------------------------------------------------- +#define cpPlugins_ArrayImage_AllDims_Import( A, T ) \ + cpPlugins_ITKArrayImage_AllDims_Import( A, T ); \ + cpPlugins_VTKArrayImage_AllDims_Import( A, T ) \ + +// ------------------------------------------------------------------------- +// ITK-VTK base clases +// ------------------------------------------------------------------------- + +cpPlugins_Image_AllDims_Import( char ); +cpPlugins_Image_AllDims_Import( short ); +cpPlugins_Image_AllDims_Import( int ); +cpPlugins_Image_AllDims_Import( long ); +cpPlugins_Image_AllDims_Import( unsigned char ); +cpPlugins_Image_AllDims_Import( unsigned short ); +cpPlugins_Image_AllDims_Import( unsigned int ); +cpPlugins_Image_AllDims_Import( unsigned long ); +cpPlugins_Image_AllDims_Import( float ); +cpPlugins_Image_AllDims_Import( double ); + +cpPlugins_Image_AllDims_Import( itk::RGBPixel< char > ); +cpPlugins_Image_AllDims_Import( itk::RGBPixel< short > ); +cpPlugins_Image_AllDims_Import( itk::RGBPixel< int > ); +cpPlugins_Image_AllDims_Import( itk::RGBPixel< long > ); +cpPlugins_Image_AllDims_Import( itk::RGBPixel< unsigned char > ); +cpPlugins_Image_AllDims_Import( itk::RGBPixel< unsigned short > ); +cpPlugins_Image_AllDims_Import( itk::RGBPixel< unsigned int > ); +cpPlugins_Image_AllDims_Import( itk::RGBPixel< unsigned long > ); +cpPlugins_Image_AllDims_Import( itk::RGBPixel< float > ); +cpPlugins_Image_AllDims_Import( itk::RGBPixel< double > ); + +cpPlugins_Image_AllDims_Import( itk::RGBAPixel< char > ); +cpPlugins_Image_AllDims_Import( itk::RGBAPixel< short > ); +cpPlugins_Image_AllDims_Import( itk::RGBAPixel< int > ); +cpPlugins_Image_AllDims_Import( itk::RGBAPixel< long > ); +cpPlugins_Image_AllDims_Import( itk::RGBAPixel< unsigned char > ); +cpPlugins_Image_AllDims_Import( itk::RGBAPixel< unsigned short > ); +cpPlugins_Image_AllDims_Import( itk::RGBAPixel< unsigned int > ); +cpPlugins_Image_AllDims_Import( itk::RGBAPixel< unsigned long > ); +cpPlugins_Image_AllDims_Import( itk::RGBAPixel< float > ); +cpPlugins_Image_AllDims_Import( itk::RGBAPixel< double > ); + +cpPlugins_Image_AllDims_Import( itk::DiffusionTensor3D< float > ); +cpPlugins_Image_AllDims_Import( itk::DiffusionTensor3D< double > ); + +cpPlugins_ArrayImage_AllDims_Import( itk::Vector, float ); +cpPlugins_ArrayImage_AllDims_Import( itk::Vector, double ); + +cpPlugins_ArrayImage_AllDims_Import( itk::CovariantVector, float ); +cpPlugins_ArrayImage_AllDims_Import( itk::CovariantVector, double ); + +cpPlugins_ArrayImage_AllDims_Import( itk::Point, float ); +cpPlugins_ArrayImage_AllDims_Import( itk::Point, double ); + +cpPlugins_ArrayImage_AllDims_Import( itk::SymmetricSecondRankTensor, float ); +cpPlugins_ArrayImage_AllDims_Import( itk::SymmetricSecondRankTensor, double ); + +// ------------------------------------------------------------------------- +// ITK-only base clases +// ------------------------------------------------------------------------- + +cpPlugins_ITKImage_AllDims_Import( std::complex< float > ); +cpPlugins_ITKImage_AllDims_Import( std::complex< double > ); + +cpPlugins_ITKImage_Import( itk::Offset< 2 >, 2 ); +cpPlugins_ITKImage_Import( itk::Offset< 3 >, 3 ); +cpPlugins_ITKImage_Import( itk::Offset< 4 >, 4 ); + +// ========================================================================= +// ========== Declare import itk::VectorImage types ========== +// ========================================================================= + +// ------------------------------------------------------------------------- +#define cpPlugins_VectorImage_Import( T, D ) \ + cpPlugins_TEMPLATE_IMPORT( \ + 2(class cpPlugins_Interface_EXPORT itk::VectorImage< T, D >) \ + ) + +// ------------------------------------------------------------------------- +#define cpPlugins_ArrayVectorImage_Import( A, T, DA, DI ) \ + cpPlugins_TEMPLATE_IMPORT( \ + 3(class \ + cpPlugins_Interface_EXPORT \ + itk::VectorImage< A< T, DA >, DI >) \ + ) + +// ------------------------------------------------------------------------- +#define cpPlugins_VectorImage_AllDims_Import( T ) \ + cpPlugins_VectorImage_Import( T, 2 ); \ + cpPlugins_VectorImage_Import( T, 3 ); \ + cpPlugins_VectorImage_Import( T, 4 ) + +// ------------------------------------------------------------------------- +#define cpPlugins_ArrayVectorImage_AllDims_Import( A, T ) \ + cpPlugins_ArrayVectorImage_Import( A, T, 2, 2 ); \ + cpPlugins_ArrayVectorImage_Import( A, T, 3, 3 ); \ + cpPlugins_ArrayVectorImage_Import( A, T, 4, 4 ) + +// ------------------------------------------------------------------------- +// ITK-VTK base clases +// ------------------------------------------------------------------------- + +cpPlugins_VectorImage_AllDims_Import( char ); +cpPlugins_VectorImage_AllDims_Import( short ); +cpPlugins_VectorImage_AllDims_Import( int ); +cpPlugins_VectorImage_AllDims_Import( long ); +cpPlugins_VectorImage_AllDims_Import( unsigned char ); +cpPlugins_VectorImage_AllDims_Import( unsigned short ); +cpPlugins_VectorImage_AllDims_Import( unsigned int ); +cpPlugins_VectorImage_AllDims_Import( unsigned long ); +cpPlugins_VectorImage_AllDims_Import( float ); +cpPlugins_VectorImage_AllDims_Import( double ); + +cpPlugins_VectorImage_AllDims_Import( std::complex< float > ); +cpPlugins_VectorImage_AllDims_Import( std::complex< double > ); + +cpPlugins_VectorImage_Import( itk::Offset< 2 >, 2 ); +cpPlugins_VectorImage_Import( itk::Offset< 3 >, 3 ); +cpPlugins_VectorImage_Import( itk::Offset< 4 >, 4 ); + +cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< char > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< short > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< int > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< long > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< unsigned char > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< unsigned short > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< unsigned int > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< unsigned long > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< float > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< double > ); + +cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< char > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< short > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< int > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< long > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< unsigned char > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< unsigned short > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< unsigned int > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< unsigned long > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< float > ); +cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< double > ); + +cpPlugins_VectorImage_AllDims_Import( itk::DiffusionTensor3D< float > ); +cpPlugins_VectorImage_AllDims_Import( itk::DiffusionTensor3D< double > ); + +cpPlugins_ArrayVectorImage_AllDims_Import( itk::Vector, float ); +cpPlugins_ArrayVectorImage_AllDims_Import( itk::Vector, double ); + +cpPlugins_ArrayVectorImage_AllDims_Import( itk::CovariantVector, float ); +cpPlugins_ArrayVectorImage_AllDims_Import( itk::CovariantVector, double ); + +cpPlugins_ArrayVectorImage_AllDims_Import( itk::Point, float ); +cpPlugins_ArrayVectorImage_AllDims_Import( itk::Point, double ); + +cpPlugins_ArrayVectorImage_AllDims_Import( + itk::SymmetricSecondRankTensor, float + ); +cpPlugins_ArrayVectorImage_AllDims_Import( + itk::SymmetricSecondRankTensor, double + ); + +#endif // cpPlugins_Interface_EXPORTS + #endif // __CPPLUGINS__INTERFACE__IMAGE__HXX__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ImplicitFunction.cxx b/lib/cpPlugins/Interface/ImplicitFunction.cxx index 1ffc516..5802ac8 100644 --- a/lib/cpPlugins/Interface/ImplicitFunction.cxx +++ b/lib/cpPlugins/Interface/ImplicitFunction.cxx @@ -49,28 +49,6 @@ cpPlugins_Interface_ImplicitFunction_DEF( Quadric ); cpPlugins_Interface_ImplicitFunction_DEF( Sphere ); cpPlugins_Interface_ImplicitFunction_DEF( Superquadric ); -// ------------------------------------------------------------------------- -vtkImplicitFunction* cpPlugins::Interface::ImplicitFunction:: -GetVTKImplicitFunction( ) -{ - return( - dynamic_cast< vtkImplicitFunction* >( - this->m_VTKObject.GetPointer( ) - ) - ); -} - -// ------------------------------------------------------------------------- -const vtkImplicitFunction* cpPlugins::Interface::ImplicitFunction:: -GetVTKImplicitFunction( ) const -{ - return( - dynamic_cast< const vtkImplicitFunction* >( - this->m_VTKObject.GetPointer( ) - ) - ); -} - // ------------------------------------------------------------------------- void cpPlugins::Interface::ImplicitFunction:: SetFunction( vtkImplicitFunction* function ) diff --git a/lib/cpPlugins/Interface/ImplicitFunction.h b/lib/cpPlugins/Interface/ImplicitFunction.h index 6b9c7ee..18ff63d 100644 --- a/lib/cpPlugins/Interface/ImplicitFunction.h +++ b/lib/cpPlugins/Interface/ImplicitFunction.h @@ -29,21 +29,6 @@ namespace cpPlugins itkTypeMacro( ImplicitFunction, DataObject ); public: - template< class F > - inline F* GetITKImplicitFunction( ); - - template< class F > - inline const F* GetITKImplicitFunction( ) const; - - template< class F > - inline F* GetVTKImplicitFunction( ); - - template< class F > - inline const F* GetVTKImplicitFunction( ) const; - - virtual vtkImplicitFunction* GetVTKImplicitFunction( ); - virtual const vtkImplicitFunction* GetVTKImplicitFunction( ) const; - void SetFunction( vtkImplicitFunction* function ); void SetFunctionToBox( ); diff --git a/lib/cpPlugins/Interface/ImplicitFunction.hxx b/lib/cpPlugins/Interface/ImplicitFunction.hxx deleted file mode 100644 index 307d437..0000000 --- a/lib/cpPlugins/Interface/ImplicitFunction.hxx +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __CPPLUGINS__INTERFACE__IMPLICITFUNCTION__HXX__ -#define __CPPLUGINS__INTERFACE__IMPLICITFUNCTION__HXX__ - -// ------------------------------------------------------------------------- -template< class F > -F* cpPlugins::Interface::ImplicitFunction:: -GetITKImplicitFunction( ) -{ - return( dynamic_cast< F* >( this->m_ITKObject.GetPointer( ) ) ); -} - -// ------------------------------------------------------------------------- -template< class F > -const F* cpPlugins::Interface::ImplicitFunction:: -GetITKImplicitFunction( ) const -{ - return( dynamic_cast< const F* >( this->m_ITKObject.GetPointer( ) ) ); -} - -// ------------------------------------------------------------------------- -template< class F > -F* cpPlugins::Interface::ImplicitFunction:: -GetVTKImplicitFunction( ) -{ - return( dynamic_cast< F* >( this->m_VTKObject.GetPointer( ) ) ); -} - -// ------------------------------------------------------------------------- -template< class F > -const F* cpPlugins::Interface::ImplicitFunction:: -GetVTKImplicitFunction( ) const -{ - return( dynamic_cast< const F* >( this->m_VTKObject.GetPointer( ) ) ); -} - -#endif // __CPPLUGINS__INTERFACE__IMPLICITFUNCTION__HXX__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Mesh.cxx b/lib/cpPlugins/Interface/Mesh.cxx index 8507a4b..e179c8e 100644 --- a/lib/cpPlugins/Interface/Mesh.cxx +++ b/lib/cpPlugins/Interface/Mesh.cxx @@ -4,33 +4,37 @@ // ------------------------------------------------------------------------- void cpPlugins::Interface::Mesh:: -SetVTKMesh( vtkPolyData* mesh ) +SetVTK( vtkObject* mesh ) { - this->m_VTKObject = mesh; - - this->m_Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( ); - this->m_Actor = vtkSmartPointer< vtkActor >::New( ); - - this->m_Mapper->SetInputData( mesh ); - this->m_Actor->SetMapper( this->m_Mapper ); - + if( dynamic_cast< vtkPolyData* >( mesh ) != NULL ) + this->m_VTKObject = mesh; + else + this->m_VTKObject = NULL; + this->m_Mapper = NULL; + this->m_Actor = NULL; this->Modified( ); } // ------------------------------------------------------------------------- -vtkPolyData* cpPlugins::Interface::Mesh:: -GetVTKMesh( ) +void cpPlugins::Interface::Mesh:: +CreateVTKActor( ) { - return( dynamic_cast< vtkPolyData* >( this->m_VTKObject.GetPointer( ) ) ); -} + vtkPolyData* pd = this->GetVTK< vtkPolyData >( ); + if( + pd != NULL && + ( + this->m_Mapper.GetPointer( ) == NULL || + this->m_Actor.GetPointer( ) == NULL + ) + ) + { + this->m_Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( ); + this->m_Actor = vtkSmartPointer< vtkActor >::New( ); + this->m_Mapper->SetInputData( pd ); + this->m_Actor->SetMapper( this->m_Mapper ); + this->Modified( ); -// ------------------------------------------------------------------------- -const vtkPolyData* cpPlugins::Interface::Mesh:: -GetVTKMesh( ) const -{ - return( - dynamic_cast< const vtkPolyData* >( this->m_VTKObject.GetPointer( ) ) - ); + } // fi } // ------------------------------------------------------------------------- @@ -50,7 +54,9 @@ GetVTKActor( ) const // ------------------------------------------------------------------------- cpPlugins::Interface::Mesh:: Mesh( ) - : Superclass( ) + : Superclass( ), + m_Mapper( NULL ), + m_Actor( NULL ) { this->m_ClassName = "cpPlugins::Interface::Mesh"; this->m_ClassCategory = "BasicObject"; diff --git a/lib/cpPlugins/Interface/Mesh.h b/lib/cpPlugins/Interface/Mesh.h index 75c5eb3..20c56fb 100644 --- a/lib/cpPlugins/Interface/Mesh.h +++ b/lib/cpPlugins/Interface/Mesh.h @@ -6,7 +6,6 @@ #include #include -#include #include namespace cpPlugins @@ -30,17 +29,11 @@ namespace cpPlugins public: template< class M > - inline void SetITKMesh( itk::DataObject* object ); + inline void SetITK( itk::Object* object ); - template< class M > - inline M* GetITKMesh( ); - - template< class M > - inline const M* GetITKMesh( ) const; + virtual void SetVTK( vtkObject* mesh ); - virtual void SetVTKMesh( vtkPolyData* mesh ); - virtual vtkPolyData* GetVTKMesh( ); - virtual const vtkPolyData* GetVTKMesh( ) const; + virtual void CreateVTKActor( ); virtual vtkActor* GetVTKActor( ); virtual const vtkActor* GetVTKActor( ) const; diff --git a/lib/cpPlugins/Interface/Mesh.hxx b/lib/cpPlugins/Interface/Mesh.hxx index e897f61..da89167 100644 --- a/lib/cpPlugins/Interface/Mesh.hxx +++ b/lib/cpPlugins/Interface/Mesh.hxx @@ -30,32 +30,12 @@ cpPlugins_Mesh_Import( QuadEdgeMesh, double, 3 ); // ------------------------------------------------------------------------- template< class M > void cpPlugins::Interface::Mesh:: -SetITKMesh( itk::DataObject* object ) +SetITK( itk::Object* object ) { std::cerr << "SetITKMesh: TODO" << std::endl; std::exit( 1 ); } -// ------------------------------------------------------------------------- -template< class M > -M* cpPlugins::Interface::Mesh:: -GetITKMesh( ) -{ - std::cerr << "GetITKMesh: TODO" << std::endl; - std::exit( 1 ); - return( NULL ); -} - -// ------------------------------------------------------------------------- -template< class M > -const M* cpPlugins::Interface::Mesh:: -GetITKMesh( ) const -{ - std::cerr << "GetITKMesh (const): TODO" << std::endl; - std::exit( 1 ); - return( NULL ); -} - #endif // __CPPLUGINS__INTERFACE__MESH__HXX__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ParametersListWidget.cxx b/lib/cpPlugins/Interface/ParametersListWidget.cxx index 752bb68..7ac8534 100644 --- a/lib/cpPlugins/Interface/ParametersListWidget.cxx +++ b/lib/cpPlugins/Interface/ParametersListWidget.cxx @@ -1,4 +1,7 @@ #include + +#ifdef cpPlugins_Interface_QT4 + #include #include @@ -134,4 +137,6 @@ _changeValuesCount( ) table->insertRow( table->rowCount( ) ); } +#endif // cpPlugins_Interface_QT4 + // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ParametersListWidget.h b/lib/cpPlugins/Interface/ParametersListWidget.h index eb186dd..60133e3 100644 --- a/lib/cpPlugins/Interface/ParametersListWidget.h +++ b/lib/cpPlugins/Interface/ParametersListWidget.h @@ -1,6 +1,10 @@ #ifndef __CPPLUGINS__INTERFACE__PARAMETERSLISTWIDGET__H__ #define __CPPLUGINS__INTERFACE__PARAMETERSLISTWIDGET__H__ +#include + +#ifdef cpPlugins_Interface_QT4 + #include #include @@ -46,6 +50,8 @@ namespace cpPlugins } // ecapseman +#endif // cpPlugins_Interface_QT4 + #endif // __CPPLUGINS__INTERFACE__PARAMETERSLISTWIDGET__H__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ParametersQtDialog.cxx b/lib/cpPlugins/Interface/ParametersQtDialog.cxx index e6c5f57..decfdc0 100644 --- a/lib/cpPlugins/Interface/ParametersQtDialog.cxx +++ b/lib/cpPlugins/Interface/ParametersQtDialog.cxx @@ -1,5 +1,7 @@ #include +#ifdef cpPlugins_Interface_QT4 + #include #include @@ -218,4 +220,6 @@ ParametersQtDialog( return( true ); } +#endif // cpPlugins_Interface_QT4 + // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ParametersQtDialog.h b/lib/cpPlugins/Interface/ParametersQtDialog.h index daf2517..6cc8ea4 100644 --- a/lib/cpPlugins/Interface/ParametersQtDialog.h +++ b/lib/cpPlugins/Interface/ParametersQtDialog.h @@ -1,6 +1,10 @@ #ifndef __CPPLUGINS__INTERFACE__PARAMETERSQTDIALOG__H__ #define __CPPLUGINS__INTERFACE__PARAMETERSQTDIALOG__H__ +#include + +#ifdef cpPlugins_Interface_QT4 + #include #include @@ -20,6 +24,8 @@ namespace cpPlugins } // ecapseman +#endif // cpPlugins_Interface_QT4 + #endif // __CPPLUGINS__INTERFACE__PARAMETERSQTDIALOG__H__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ProcessObject.cxx b/lib/cpPlugins/Interface/ProcessObject.cxx index a53476f..bc5f7f2 100644 --- a/lib/cpPlugins/Interface/ProcessObject.cxx +++ b/lib/cpPlugins/Interface/ProcessObject.cxx @@ -121,7 +121,9 @@ ExecConfigurationDialog( QWidget* parent ) // ------------------------------------------------------------------------- cpPlugins::Interface::ProcessObject:: ProcessObject( ) - : Superclass( ) + : Superclass( ), + m_ITKObject( NULL ), + m_VTKObject( NULL ) { this->m_ClassName = "cpPlugins::Interface::ProcessObject"; this->m_ClassCategory = "BasicObject"; diff --git a/lib/cpPlugins/Interface/ProcessObject.h b/lib/cpPlugins/Interface/ProcessObject.h index 51cf067..2a9fc91 100644 --- a/lib/cpPlugins/Interface/ProcessObject.h +++ b/lib/cpPlugins/Interface/ProcessObject.h @@ -15,7 +15,8 @@ typedef char QWidget #include -class vtkAlgorithm; +#include +#include namespace cpPlugins { @@ -36,11 +37,6 @@ namespace cpPlugins itkTypeMacro( ProcessObject, Object ); public: - virtual vtkAlgorithm* GetVTKAlgorithm( ) - { return( NULL ); } - virtual const vtkAlgorithm* GetVTKAlgorithm( ) const - { return( NULL ); } - virtual const Parameters& GetDefaultParameters( ) const; virtual void SetParameters( const Parameters& params ); @@ -57,6 +53,18 @@ namespace cpPlugins virtual bool ExecConfigurationDialog( QWidget* parent ); + template< class T > + inline T* GetITK( ); + + template< class T > + inline const T* GetITK( ) const; + + template< class T > + inline T* GetVTK( ); + + template< class T > + inline const T* GetVTK( ) const; + template< class T > inline T* GetInput( unsigned int idx ); @@ -73,6 +81,12 @@ namespace cpPlugins ProcessObject( ); virtual ~ProcessObject( ); + template< class F > + inline F* _CreateITK( ); + + template< class F > + inline F* _CreateVTK( ); + template< class O > inline void _MakeOutput( unsigned int idx ); @@ -84,7 +98,9 @@ namespace cpPlugins Self& operator=( const Self& ); protected: - itk::ProcessObject::Pointer m_RealProcessObject; + itk::ProcessObject::Pointer m_ITKObject; + vtkSmartPointer< vtkAlgorithm > m_VTKObject; + Parameters m_DefaultParameters; Parameters m_Parameters; diff --git a/lib/cpPlugins/Interface/ProcessObject.hxx b/lib/cpPlugins/Interface/ProcessObject.hxx index f84d4a6..50c03ce 100644 --- a/lib/cpPlugins/Interface/ProcessObject.hxx +++ b/lib/cpPlugins/Interface/ProcessObject.hxx @@ -1,6 +1,38 @@ #ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__ #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__ +// ------------------------------------------------------------------------- +template< class T > +T* cpPlugins::Interface::ProcessObject:: +GetITK( ) +{ + return( dynamic_cast< T* >( this->m_ITKObject.GetPointer( ) ) ); +} + +// ------------------------------------------------------------------------- +template< class T > +const T* cpPlugins::Interface::ProcessObject:: +GetITK( ) const +{ + return( dynamic_cast< const T* >( this->m_ITKObject.GetPointer( ) ) ); +} + +// ------------------------------------------------------------------------- +template< class T > +T* cpPlugins::Interface::ProcessObject:: +GetVTK( ) +{ + return( dynamic_cast< T* >( this->m_VTKObject.GetPointer( ) ) ); +} + +// ------------------------------------------------------------------------- +template< class T > +const T* cpPlugins::Interface::ProcessObject:: +GetVTK( ) const +{ + return( dynamic_cast< const T* >( this->m_VTKObject.GetPointer( ) ) ); +} + // ------------------------------------------------------------------------- template< class T > T* cpPlugins::Interface::ProcessObject:: @@ -49,6 +81,39 @@ GetOutput( unsigned int idx ) const return( NULL ); } +// ------------------------------------------------------------------------- +template< class F > +F* cpPlugins::Interface::ProcessObject:: +_CreateITK( ) +{ + F* filter = dynamic_cast< F* >( this->m_ITKObject.GetPointer( ) ); + if( filter == NULL ) + { + typename F::Pointer ptr = F::New( ); + this->m_ITKObject = ptr; + filter = ptr.GetPointer( ); + this->m_VTKObject = NULL; + + } // fi + return( filter ); +} + +// ------------------------------------------------------------------------- +template< class F > +F* cpPlugins::Interface::ProcessObject:: +_CreateVTK( ) +{ + F* filter = dynamic_cast< F* >( this->m_VTKObject.GetPointer( ) ); + if( filter == NULL ) + { + filter = F::New( ); + this->m_VTKObject = filter; + this->m_ITKObject = NULL; + + } // fi + return( filter ); +} + // ------------------------------------------------------------------------- template< class O > void cpPlugins::Interface::ProcessObject:: diff --git a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx index ea7c965..1a257a6 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx @@ -45,15 +45,9 @@ _GenerateData( ) itk::DataObject* itk_image = NULL; std::string r = ""; - cpPlugins_Image_Input_Demangle_Dimension_AllScalarTypes( - 2, image, itk_image, r, _DemangleOutput - ); - else cpPlugins_Image_Input_Demangle_Dimension_AllScalarTypes( - 3, image, itk_image, r, _DemangleOutput - ); - else cpPlugins_Image_Input_Demangle_Dimension_AllScalarTypes( - 4, image, itk_image, r, _DemangleOutput - ); + cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 ); + else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 ); + else cpPlugins_Image_Demangle_AllScalarTypes( 4, image, itk_image, r, _GD0 ); else r = "BinaryThresholdImageFilter: Input image type not supported."; return( r ); } @@ -61,7 +55,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class I > std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter:: -_DemangleOutput( itk::DataObject* image ) +_GD0( itk::DataObject* image ) { return( this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >( @@ -88,13 +82,7 @@ _RealGD( itk::DataObject* image ) _OP out_val = _OP( this->m_Parameters.GetValueAsReal( "OutsideValue" ) ); // Configure filter - _F* filter = dynamic_cast< _F* >( this->m_RealProcessObject.GetPointer( ) ); - if( filter == NULL ) - { - this->m_RealProcessObject = _F::New( ); - filter = dynamic_cast< _F* >( this->m_RealProcessObject.GetPointer( ) ); - - } // fi + _F* filter = this->_CreateITK< _F >( ); filter->SetInput( dynamic_cast< I* >( image ) ); filter->SetLowerThreshold( lower_val ); filter->SetUpperThreshold( upper_val ); @@ -107,7 +95,7 @@ _RealGD( itk::DataObject* image ) this->GetOutput< cpPlugins::Interface::Image >( 0 ); if( out != NULL ) { - out->SetITKImage< O >( filter->GetOutput( ) ); + out->SetITK< O >( filter->GetOutput( ) ); return( "" ); } else diff --git a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.h index 74a970f..4658f9d 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.h @@ -33,7 +33,7 @@ namespace cpPlugins virtual std::string _GenerateData( ); template< class I > - inline std::string _DemangleOutput( itk::DataObject* image ); + inline std::string _GD0( itk::DataObject* image ); template< class I, class O > inline std::string _RealGD( itk::DataObject* image ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx b/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx index 0ae95d5..32a7c5a 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx @@ -5,25 +5,10 @@ #include #include -// ------------------------------------------------------------------------- -vtkAlgorithm* cpPlugins::BasicFilters::Cutter:: -GetVTKAlgorithm( ) -{ - return( this->m_Algorithm ); -} - -// ------------------------------------------------------------------------- -const vtkAlgorithm* cpPlugins::BasicFilters::Cutter:: -GetVTKAlgorithm( ) const -{ - return( this->m_Algorithm ); -} - // ------------------------------------------------------------------------- cpPlugins::BasicFilters::Cutter:: Cutter( ) - : Superclass( ), - m_Algorithm( NULL ) + : Superclass( ) { this->m_ClassName = "cpPlugins::BasicFilters::Cutter"; this->m_ClassCategory = "MeshToMeshFilter"; @@ -39,8 +24,6 @@ Cutter( ) cpPlugins::BasicFilters::Cutter:: ~Cutter( ) { - if( this->m_Algorithm != NULL ) - this->m_Algorithm->Delete( ); } // ------------------------------------------------------------------------- @@ -55,20 +38,16 @@ _GenerateData( ) if( function == NULL ) return( "Cutter: Input data 1 is not a valid implicit function." ); - if( this->m_Algorithm != NULL ) - this->m_Algorithm->Delete( ); - - vtkCutter* cutter = vtkCutter::New( ); - cutter->SetInputData( mesh->GetVTKMesh( ) ); - cutter->SetCutFunction( function->GetVTKImplicitFunction( ) ); + vtkCutter* cutter = this->_CreateVTK< vtkCutter >( ); + cutter->SetInputData( mesh->GetVTK< vtkPolyData >( ) ); + cutter->SetCutFunction( function->GetVTK< vtkImplicitFunction >( ) ); cutter->GenerateTrianglesOff( ); - this->m_Algorithm = cutter; + cutter->Update( ); // Execute filter - this->m_Algorithm->Update( ); cpPlugins::Interface::Mesh* out = this->GetOutput< cpPlugins::Interface::Mesh >( 0 ); - out->SetVTKMesh( this->m_Algorithm->GetOutput( ) ); + out->SetVTK( cutter->GetOutput( ) ); return( "" ); } diff --git a/lib/cpPlugins/Plugins/BasicFilters/Cutter.h b/lib/cpPlugins/Plugins/BasicFilters/Cutter.h index 8887adc..52438a7 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/Cutter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/Cutter.h @@ -4,9 +4,6 @@ #include #include -class vtkAlgorithm; -class vtkPolyDataAlgorithm; - namespace cpPlugins { namespace BasicFilters @@ -26,10 +23,6 @@ namespace cpPlugins itkNewMacro( Self ); itkTypeMacro( Cutter, cpPluginsInterfaceMeshToMeshFilter ); - public: - virtual vtkAlgorithm* GetVTKAlgorithm( ); - virtual const vtkAlgorithm* GetVTKAlgorithm( ) const; - protected: Cutter( ); virtual ~Cutter( ); @@ -40,9 +33,6 @@ namespace cpPlugins // Purposely not implemented Cutter( const Self& ); Self& operator=( const Self& ); - - protected: - vtkPolyDataAlgorithm* m_Algorithm; }; // --------------------------------------------------------------------- diff --git a/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx index e061017..cca186c 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx @@ -9,8 +9,7 @@ // ------------------------------------------------------------------------- cpPlugins::BasicFilters::MarchingCubes:: MarchingCubes( ) - : Superclass( ), - m_Algorithm( NULL ) + : Superclass( ) { this->m_ClassName = "cpPlugins::BasicFilters::MarchingCubes"; this->m_ClassCategory = "ImageToMeshFilter"; @@ -28,8 +27,6 @@ MarchingCubes( ) cpPlugins::BasicFilters::MarchingCubes:: ~MarchingCubes( ) { - if( this->m_Algorithm != NULL ) - this->m_Algorithm->Delete( ); } // ------------------------------------------------------------------------- @@ -41,40 +38,39 @@ _GenerateData( ) this->GetInput< cpPlugins::Interface::Image >( 0 ); if( image == NULL ) return( "MarchingCubes: Input data is not a valid image." ); - vtkImageData* vtk_image = image->GetVTKImageData( ); + vtkImageData* vtk_image = image->GetVTK< vtkImageData >( ); if( vtk_image == NULL ) return( "MarchingCubes: Input does not have a valid VTK conversion." ); - if( this->m_Algorithm != NULL ) - this->m_Algorithm->Delete( ); - std::vector< double > values; this->m_Parameters.GetValueAsRealList( values, "Thresholds" ); + vtkPolyData* pd = NULL; if( vtk_image->GetDataDimension( ) == 2 ) { - vtkMarchingSquares* ms = vtkMarchingSquares::New( ); + vtkMarchingSquares* ms = this->_CreateVTK< vtkMarchingSquares >( ); ms->SetInputData( vtk_image ); for( unsigned int i = 0; i < values.size( ); ++i ) ms->SetValue( i, values[ i ] ); - this->m_Algorithm = ms; + ms->Update( ); + pd = ms->GetOutput( ); } else if( vtk_image->GetDataDimension( ) == 3 ) { - vtkMarchingCubes* mc = vtkMarchingCubes::New( ); + vtkMarchingCubes* mc = this->_CreateVTK< vtkMarchingCubes >( ); mc->ComputeNormalsOff( ); mc->SetInputData( vtk_image ); for( unsigned int i = 0; i < values.size( ); ++i ) mc->SetValue( i, values[ i ] ); - this->m_Algorithm = mc; + mc->Update( ); + pd = mc->GetOutput( ); } else return( "MarchingCubes: Input data does not have a valid dimension." ); // Execute filter - this->m_Algorithm->Update( ); cpPlugins::Interface::Mesh* out = this->GetOutput< cpPlugins::Interface::Mesh >( 0 ); - out->SetVTKMesh( this->m_Algorithm->GetOutput( ) ); + out->SetVTK( pd ); return( "" ); } diff --git a/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.h b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.h index a5790e9..3f9c22d 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.h +++ b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.h @@ -4,8 +4,6 @@ #include #include -class vtkPolyDataAlgorithm; - namespace cpPlugins { namespace BasicFilters @@ -35,9 +33,6 @@ namespace cpPlugins // Purposely not implemented MarchingCubes( const Self& ); Self& operator=( const Self& ); - - protected: - vtkPolyDataAlgorithm* m_Algorithm; }; // --------------------------------------------------------------------- diff --git a/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx index d806506..df145b8 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx @@ -39,15 +39,9 @@ _GenerateData( ) itk::DataObject* itk_image = NULL; std::string r = ""; - cpPlugins_Image_Input_Demangle_Dimension_AllScalarTypes( - 2, image, itk_image, r, _DemangleOutput - ); - else cpPlugins_Image_Input_Demangle_Dimension_AllScalarTypes( - 3, image, itk_image, r, _DemangleOutput - ); - else cpPlugins_Image_Input_Demangle_Dimension_AllScalarTypes( - 4, image, itk_image, r, _DemangleOutput - ); + cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 ); + else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 ); + else cpPlugins_Image_Demangle_AllScalarTypes( 4, image, itk_image, r, _GD0 ); else r = "MedianImageFilter: Input image type not supported."; return( r ); } @@ -55,7 +49,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class I > std::string cpPlugins::BasicFilters::MedianImageFilter:: -_DemangleOutput( itk::DataObject* image ) +_GD0( itk::DataObject* image ) { return( this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >( @@ -77,16 +71,9 @@ _RealGD( itk::DataObject* image ) rad_val.Fill( this->m_Parameters.GetValueAsUint( "Radius" ) ); // Configure filter - _F* filter = dynamic_cast< _F* >( this->m_RealProcessObject.GetPointer( ) ); - if( filter == NULL ) - { - this->m_RealProcessObject = _F::New( ); - filter = dynamic_cast< _F* >( this->m_RealProcessObject.GetPointer( ) ); - - } // fi + _F* filter = this->_CreateITK< _F >( ); filter->SetInput( dynamic_cast< I* >( image ) ); filter->SetRadius( rad_val ); - filter->Update( ); // Connect output @@ -94,7 +81,7 @@ _RealGD( itk::DataObject* image ) this->GetOutput< cpPlugins::Interface::Image >( 0 ); if( out != NULL ) { - out->SetITKImage< O >( filter->GetOutput( ) ); + out->SetITK< O >( filter->GetOutput( ) ); return( "" ); } else diff --git a/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.h index 8b3cbf7..ea2bb61 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.h @@ -33,7 +33,7 @@ namespace cpPlugins virtual std::string _GenerateData( ); template< class I > - inline std::string _DemangleOutput( itk::DataObject* image ); + inline std::string _GD0( itk::DataObject* image ); template< class I, class O > inline std::string _RealGD( itk::DataObject* image ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx index 6e0d36f..de924a6 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx @@ -43,15 +43,9 @@ _GenerateData( ) itk::DataObject* itk_image = NULL; std::string r = ""; - cpPlugins_Image_Input_Demangle_Dimension_AllScalarTypes( - 2, image, itk_image, r, _DemangleOutput - ); - else cpPlugins_Image_Input_Demangle_Dimension_AllScalarTypes( - 3, image, itk_image, r, _DemangleOutput - ); - else cpPlugins_Image_Input_Demangle_Dimension_AllScalarTypes( - 4, image, itk_image, r, _DemangleOutput - ); + cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 ); + else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 ); + else cpPlugins_Image_Demangle_AllScalarTypes( 4, image, itk_image, r, _GD0 ); else r = "OtsuThresholdImageFilter: Input image type not supported."; return( r ); } @@ -59,7 +53,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class I > std::string cpPlugins::BasicFilters::OtsuThresholdImageFilter:: -_DemangleOutput( itk::DataObject* image ) +_GD0( itk::DataObject* image ) { return( this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >( @@ -83,13 +77,7 @@ _RealGD( itk::DataObject* image ) _OP out_val = _OP( this->m_Parameters.GetValueAsReal( "OutsideValue" ) ); // Configure filter - _F* filter = dynamic_cast< _F* >( this->m_RealProcessObject.GetPointer( ) ); - if( filter == NULL ) - { - this->m_RealProcessObject = _F::New( ); - filter = dynamic_cast< _F* >( this->m_RealProcessObject.GetPointer( ) ); - - } // fi + _F* filter = this->_CreateITK< _F >( ); filter->SetInput( dynamic_cast< I* >( image ) ); filter->SetNumberOfHistogramBins( bins ); filter->SetInsideValue( in_val ); @@ -101,7 +89,7 @@ _RealGD( itk::DataObject* image ) this->GetOutput< cpPlugins::Interface::Image >( 0 ); if( out != NULL ) { - out->SetITKImage< O >( filter->GetOutput( ) ); + out->SetITK< O >( filter->GetOutput( ) ); return( "" ); } else diff --git a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.h index 6a112d0..b717062 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.h @@ -21,7 +21,10 @@ namespace cpPlugins public: itkNewMacro( Self ); - itkTypeMacro( OtsuThresholdImageFilter, cpPluginsInterfaceImageToImageFilter ); + itkTypeMacro( + OtsuThresholdImageFilter, + cpPluginsInterfaceImageToImageFilter + ); protected: OtsuThresholdImageFilter( ); @@ -30,7 +33,7 @@ namespace cpPlugins virtual std::string _GenerateData( ); template< class I > - inline std::string _DemangleOutput( itk::DataObject* image ); + inline std::string _GD0( itk::DataObject* image ); template< class I, class O > inline std::string _RealGD( itk::DataObject* image ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx index 7f5b1fc..38cec31 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx @@ -29,25 +29,6 @@ cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter:: { } -// ------------------------------------------------------------------------- -#define cpPlugins_Plugins_RGBImageToOtherChannelsFilter( P, D, I, O, r, f ) \ - cpPlugins_Image_Input_Demangle( P< char >, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( P< short >, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( P< int >, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( P< long >, D, I, O, r, f ); \ - else cpPlugins_Image_Input_Demangle( \ - P< unsigned char >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - P< unsigned short >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - P< unsigned int >, D, I, O, r, f \ - ); \ - else cpPlugins_Image_Input_Demangle( \ - P< unsigned long >, D, I, O, r, f \ - ) - // ------------------------------------------------------------------------- std::string cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter:: _GenerateData( ) @@ -59,15 +40,9 @@ _GenerateData( ) itk::DataObject* itk_image = NULL; std::string r = ""; - cpPlugins_Plugins_RGBImageToOtherChannelsFilter( - itk::RGBPixel, 2, image, itk_image, r, _DemangleOutput - ); - else cpPlugins_Plugins_RGBImageToOtherChannelsFilter( - itk::RGBPixel, 3, image, itk_image, r, _DemangleOutput - ); - else cpPlugins_Plugins_RGBImageToOtherChannelsFilter( - itk::RGBPixel, 4, image, itk_image, r, _DemangleOutput - ); + cpPlugins_Image_Demangle_AllRGBTypes( 2, image, itk_image, r, _GD0 ); + else cpPlugins_Image_Demangle_AllRGBTypes( 3, image, itk_image, r, _GD0 ); + else cpPlugins_Image_Demangle_AllRGBTypes( 4, image, itk_image, r, _GD0 ); else r = "RGBImageToOtherChannelsFilter: Input image type not supported."; return( r ); } @@ -75,7 +50,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class I > std::string cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter:: -_DemangleOutput( itk::DataObject* image ) +_GD0( itk::DataObject* image ) { typedef typename I::PixelType _P; @@ -107,13 +82,7 @@ _RealGD( itk::DataObject* image ) _F; // Configure filter - _F* filter = dynamic_cast< _F* >( this->m_RealProcessObject.GetPointer( ) ); - if( filter == NULL ) - { - this->m_RealProcessObject = _F::New( ); - filter = dynamic_cast< _F* >( this->m_RealProcessObject.GetPointer( ) ); - - } // fi + _F* filter = this->_CreateITK< _F >( ); filter->SetInput( dynamic_cast< I* >( image ) ); filter->Update( ); @@ -122,7 +91,7 @@ _RealGD( itk::DataObject* image ) this->GetOutput< cpPlugins::Interface::Image >( 0 ); if( out != NULL ) { - out->SetITKImage< _O >( filter->GetOutput( ) ); + out->SetITK< _O >( filter->GetOutput( ) ); return( "" ); } else diff --git a/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.h b/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.h index 6d215f1..bb559c8 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.h @@ -33,7 +33,7 @@ namespace cpPlugins virtual std::string _GenerateData( ); template< class I > - inline std::string _DemangleOutput( itk::DataObject* image ); + inline std::string _GD0( itk::DataObject* image ); template< class I, class C > inline std::string _RealGD( itk::DataObject* image ); diff --git a/lib/cpPlugins/Plugins/IO/ImageReader.cxx b/lib/cpPlugins/Plugins/IO/ImageReader.cxx index 4b1d365..fec0944 100644 --- a/lib/cpPlugins/Plugins/IO/ImageReader.cxx +++ b/lib/cpPlugins/Plugins/IO/ImageReader.cxx @@ -368,25 +368,17 @@ _RealGD( const TStringList& names ) { // Read single image typedef itk::ImageFileReader< I > _SR; - _SR* reader = - dynamic_cast< _SR* >( this->m_RealProcessObject.GetPointer( ) ); - if( reader == NULL ) - { - this->m_RealProcessObject = _SR::New( ); - reader = - dynamic_cast< _SR* >( this->m_RealProcessObject.GetPointer( ) ); - - } // fi + _SR* reader = this->_CreateITK< _SR >( ); reader->SetFileName( names[ 0 ] ); try { reader->Update( ); - out->SetITKImage< I >( reader->GetOutput( ) ); + out->SetITK< I >( reader->GetOutput( ) ); } catch( itk::ExceptionObject& err ) { r = "ImageReader: " + std::string( err.GetDescription( ) ); - out->SetITKImage< I >( NULL ); + out->SetITK< I >( NULL ); } // yrt } @@ -398,29 +390,19 @@ _RealGD( const TStringList& names ) ordered_names.insert( names[ i ] ); typedef itk::ImageSeriesReader< I > _MR; - _MR* reader = - dynamic_cast< _MR* >( this->m_RealProcessObject.GetPointer( ) ); - if( reader == NULL ) - { - this->m_RealProcessObject = _MR::New( ); - reader = - dynamic_cast< _MR* >( this->m_RealProcessObject.GetPointer( ) ); - - } // fi + _MR* reader = this->_CreateITK< _MR >( ); std::set< std::string >::const_iterator fnIt = ordered_names.begin( ); for( ; fnIt != ordered_names.end( ); ++fnIt ) - { reader->AddFileName( *fnIt ); - } try { reader->Update( ); - out->SetITKImage< I >( reader->GetOutput( ) ); + out->SetITK< I >( reader->GetOutput( ) ); } catch( itk::ExceptionObject& err ) { r = "ImageReader: " + std::string( err.GetDescription( ) ); - out->SetITKImage< I >( NULL ); + out->SetITK< I >( NULL ); } // yrt } diff --git a/lib/cpPlugins/Plugins/IO/ImageWriter.cxx b/lib/cpPlugins/Plugins/IO/ImageWriter.cxx index 6a0de2e..3330e68 100644 --- a/lib/cpPlugins/Plugins/IO/ImageWriter.cxx +++ b/lib/cpPlugins/Plugins/IO/ImageWriter.cxx @@ -34,23 +34,13 @@ _GenerateData( ) itk::DataObject* itk_image = NULL; std::string r = ""; - cpPlugins_Image_Input_Demangle_Dimension_AllTypes( - 2, image, itk_image, r, _RealGD - ); - else cpPlugins_Image_Input_Demangle_Dimension_AllTypes( - 3, image, itk_image, r, _RealGD - ); - else cpPlugins_Image_Input_Demangle_Dimension_AllTypes( - 4, image, itk_image, r, _RealGD - ); -#ifndef _WIN32 // win32: Nested loops error ???? - else cpPlugins_Image_Input_Demangle( - itk::DiffusionTensor3D< float >, 3, image, itk_image, r, _RealGD - ); - else cpPlugins_Image_Input_Demangle( - itk::DiffusionTensor3D< double >, 3, image, itk_image, r, _RealGD - ); -#endif // _WIN32 + + cpPlugins_Image_Demangle_AllTypes( 2, image, itk_image, r, _RealGD ); + else cpPlugins_Image_Demangle_AllTypes( 3, image, itk_image, r, _RealGD ); + else cpPlugins_Image_Demangle_AllTypes( 4, image, itk_image, r, _RealGD ); + else cpPlugins_VectorImage_Demangle_AllTypes( 2, image, itk_image, r, _RealGD ); + else cpPlugins_VectorImage_Demangle_AllTypes( 3, image, itk_image, r, _RealGD ); + else cpPlugins_VectorImage_Demangle_AllTypes( 4, image, itk_image, r, _RealGD ); else r = "ImageWriter: Input image type not supported."; return( r ); @@ -61,17 +51,11 @@ template< class I > std::string cpPlugins::IO::ImageWriter:: _RealGD( itk::DataObject* image ) { - typedef itk::ImageFileWriter< I > _W; - // Get filename std::string fname = this->m_Parameters.GetValueAsString( "FileName" ); - _W* writer = dynamic_cast< _W* >( this->m_RealProcessObject.GetPointer( ) ); - if( writer == NULL ) - { - this->m_RealProcessObject = _W::New( ); - writer = dynamic_cast< _W* >( this->m_RealProcessObject.GetPointer( ) ); - } // fi + typedef itk::ImageFileWriter< I > _W; + _W* writer = this->_CreateITK< _W >( ); writer->SetFileName( fname ); writer->SetInput( dynamic_cast< I* >( image ) ); try diff --git a/lib/cpPlugins/Plugins/IO/MeshReader.cxx b/lib/cpPlugins/Plugins/IO/MeshReader.cxx index b8da8a3..e6bba2b 100644 --- a/lib/cpPlugins/Plugins/IO/MeshReader.cxx +++ b/lib/cpPlugins/Plugins/IO/MeshReader.cxx @@ -46,8 +46,7 @@ ExecConfigurationDialog( QWidget* parent ) // ------------------------------------------------------------------------- cpPlugins::IO::MeshReader:: MeshReader( ) - : Superclass( ), - m_Reader( NULL ) + : Superclass( ) { this->m_ClassName = "cpPlugins::IO::MeshReader"; this->m_ClassCategory = "MeshReader"; @@ -68,8 +67,6 @@ MeshReader( ) cpPlugins::IO::MeshReader:: ~MeshReader( ) { - if( this->m_Reader != NULL ) - this->m_Reader = NULL; } // ------------------------------------------------------------------------- @@ -109,18 +106,14 @@ _GD1( ) Parameters::TString fname = this->m_Parameters.GetValueAsString( "FileName" ); - if( this->m_Reader != NULL ) - this->m_Reader->Delete( ); - - vtkPolyDataReader* pdr = vtkPolyDataReader::New( ); - this->m_Reader = pdr; + vtkPolyDataReader* pdr = this->_CreateVTK< vtkPolyDataReader >( ); pdr->SetFileName( fname.c_str( ) ); pdr->Update( ); cpPlugins::Interface::Mesh* out = this->GetOutput< cpPlugins::Interface::Mesh >( 0 ); if( out != NULL ) - out->SetVTKMesh( pdr->GetOutput( ) ); + out->SetVTK( pdr->GetOutput( ) ); else return( "MeshReader: output not correctly created." ); return( "" ); diff --git a/lib/cpPlugins/Plugins/IO/MeshReader.h b/lib/cpPlugins/Plugins/IO/MeshReader.h index f66e07c..5f721d2 100644 --- a/lib/cpPlugins/Plugins/IO/MeshReader.h +++ b/lib/cpPlugins/Plugins/IO/MeshReader.h @@ -44,9 +44,6 @@ namespace cpPlugins // Purposely not implemented MeshReader( const Self& ); Self& operator=( const Self& ); - - protected: - vtkDataReader* m_Reader; }; // --------------------------------------------------------------------- diff --git a/lib/cpPlugins/Plugins/IO/MeshWriter.cxx b/lib/cpPlugins/Plugins/IO/MeshWriter.cxx index ade28b8..ee8b666 100644 --- a/lib/cpPlugins/Plugins/IO/MeshWriter.cxx +++ b/lib/cpPlugins/Plugins/IO/MeshWriter.cxx @@ -8,8 +8,7 @@ // ------------------------------------------------------------------------- cpPlugins::IO::MeshWriter:: MeshWriter( ) - : Superclass( ), - m_Writer( NULL ) + : Superclass( ) { this->m_ClassName = "cpPlugins::IO::MeshWriter"; this->m_ClassCategory = "MeshWriter"; @@ -24,8 +23,6 @@ MeshWriter( ) cpPlugins::IO::MeshWriter:: ~MeshWriter( ) { - if( this->m_Writer != NULL ) - this->m_Writer->Delete( ); } // ------------------------------------------------------------------------- @@ -36,16 +33,12 @@ _GenerateData( ) this->GetInput< cpPlugins::Interface::Mesh >( 0 ); if( mesh == NULL ) return( "MeshWriter: No input mesh." ); - vtkPolyData* i = mesh->GetVTKMesh( ); + vtkPolyData* i = mesh->GetVTK< vtkPolyData >( ); if( i == NULL ) return( "MeshWriter: No suitable input." ); std::string fname = this->m_Parameters.GetValueAsString( "FileName" ); - if( this->m_Writer != NULL ) - this->m_Writer->Delete( ); - - vtkPolyDataWriter* pdw = vtkPolyDataWriter::New( ); - this->m_Writer = pdw; + vtkPolyDataWriter* pdw = this->_CreateVTK< vtkPolyDataWriter >( ); pdw->SetInputData( i ); pdw->SetFileName( fname.c_str( ) ); pdw->Update( ); diff --git a/lib/cpPlugins/Plugins/IO/MeshWriter.h b/lib/cpPlugins/Plugins/IO/MeshWriter.h index cd776f6..db13601 100644 --- a/lib/cpPlugins/Plugins/IO/MeshWriter.h +++ b/lib/cpPlugins/Plugins/IO/MeshWriter.h @@ -35,9 +35,6 @@ namespace cpPlugins // Purposely not implemented MeshWriter( const Self& ); Self& operator=( const Self& ); - - protected: - vtkDataWriter* m_Writer; }; // --------------------------------------------------------------------- -- 2.47.1