From a3cae0375976d524c957493a3cc565b9f5b20bce Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Sun, 20 Sep 2015 12:25:41 +0200 Subject: [PATCH] ... --- CMakeLists.txt | 7 + appli/CMakeLists.txt | 2 +- appli/examples/CMakeLists.txt | 16 +- .../Algorithms/BezierCurveFunction.h | 2 + .../Algorithms/GradientFunctionBase.h | 2 + .../Algorithms/GulsunTekMedialness.h | 2 + .../Algorithms/ImageFunctionFilter.h | 2 + .../Algorithms/InertiaMedialness.h | 2 + .../Algorithms/InertiaTensorFunction.h | 2 + lib/cpExtensions/Algorithms/IsoImageSlicer.h | 32 ++-- .../IterativeGaussianModelEstimator.h | 2 + .../Algorithms/KalmanConstantFilter.h | 14 +- lib/cpExtensions/Algorithms/KalmanFilter.h | 108 +++++++------- .../Algorithms/LightCompensationFilter.h | 2 + .../MultiScaleGaussianImageFilter.h | 2 + .../Algorithms/ParallelImageMean.h | 2 + .../RGBImageToOtherChannelsFilter.h | 2 + lib/cpExtensions/CMakeLists.txt | 2 +- lib/cpExtensions/DataStructures/QuadEdge.h | 2 + .../DataStructures/QuadEdgeCell.h | 2 + .../DataStructures/QuadEdgeIterators.h | 2 + .../DataStructures/QuadEdgeMesh.h | 2 + lib/cpExtensions/IO/MeshReader.h | 2 + lib/cpExtensions/IO/WaveFrontOBJReader.h | 2 + lib/cpExtensions/Visualization/MeshMapper.h | 2 + .../Visualization/OpenGLMeshMapper.h | 2 + .../Interface/BaseProcessObjects.cxx | 8 +- lib/cpPlugins/Interface/BaseProcessObjects.h | 103 ++++++++++++- lib/cpPlugins/Interface/Image.h | 3 + lib/cpPlugins/Interface/Image.hxx | 139 +++++++++++++++++- lib/cpPlugins/Interface/ProcessObject.h | 12 ++ lib/cpPlugins/Interface/ProcessObject.hxx | 44 ++++++ lib/cpPlugins/Plugins/CMakeLists.txt | 2 + lib/cpPlugins/Plugins/ImageReader.cxx | 32 +++- lib/cpPlugins/Plugins/ImageReader.h | 6 +- lib/cpPlugins/Plugins/ImageWriter.cxx | 42 ++++-- lib/cpPlugins/Plugins/ImageWriter.h | 8 +- lib/cpPlugins/Plugins/Instances_itkImage.cxx | 94 +++--------- lib/cpPlugins/Plugins/Instances_itkMesh.cxx | 18 ++- lib/cpPlugins/Plugins/MarchingCubes.cxx | 27 ++-- lib/cpPlugins/Plugins/MarchingCubes.h | 4 +- lib/cpPlugins/Plugins/MeshReader.cxx | 12 +- lib/cpPlugins/Plugins/MeshReader.h | 4 +- lib/cpPlugins/Plugins/MeshWriter.cxx | 10 +- lib/cpPlugins/Plugins/MeshWriter.h | 4 +- .../Plugins/OtsuThresholdImageFilter.cxx | 109 +++++++++++--- .../Plugins/OtsuThresholdImageFilter.h | 10 +- 47 files changed, 643 insertions(+), 267 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 16233dd..83c4b84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,13 @@ SET( OPTION(USE_QT4 "Build Qt4-based code" OFF) OPTION(BUILD_EXAMPLES "Build examples" OFF) +OPTION(BUILD_SHARED_LIBRARIES "Build libraries as shared" OFF) +IF(BUILD_SHARED_LIBRARIES) + SET(LIBRARY_TYPE SHARED) +ELSE(BUILD_SHARED_LIBRARIES) + SET(LIBRARY_TYPE STATIC) +ENDIF(BUILD_SHARED_LIBRARIES) + ## ======================== ## = Packages and options = ## ======================== diff --git a/appli/CMakeLists.txt b/appli/CMakeLists.txt index 7ca64d4..6e05ded 100644 --- a/appli/CMakeLists.txt +++ b/appli/CMakeLists.txt @@ -1,7 +1,7 @@ IF(BUILD_EXAMPLES) SUBDIRS( examples - ImageMPR + #ImageMPR ) ENDIF(BUILD_EXAMPLES) diff --git a/appli/examples/CMakeLists.txt b/appli/examples/CMakeLists.txt index 1de245a..1e5b943 100644 --- a/appli/examples/CMakeLists.txt +++ b/appli/examples/CMakeLists.txt @@ -6,10 +6,10 @@ SET( EXAMPLES_PROGRAMS ## example_TestParameters - #example_LoadPlugins - #example_ReadWriteImage - #example_MarchingCubes - #example_OtsuFilter + example_LoadPlugins + example_ReadWriteImage + example_MarchingCubes + example_OtsuFilter ## example_ReadImageSeriesWriteImage ## example_ReadQuadEdgeMesh ## example_RenderQuadEdgeMesh @@ -23,10 +23,10 @@ FOREACH(prog ${EXAMPLES_PROGRAMS}) ${prog} ${prog}.cxx ) - #TARGET_LINK_LIBRARIES( - # ${prog} - # cpPlugins_Interface - # ) + TARGET_LINK_LIBRARIES( + ${prog} + cpPlugins_Interface + ) ENDFOREACH(prog) SET( diff --git a/lib/cpExtensions/Algorithms/BezierCurveFunction.h b/lib/cpExtensions/Algorithms/BezierCurveFunction.h index ee512da..2deba45 100644 --- a/lib/cpExtensions/Algorithms/BezierCurveFunction.h +++ b/lib/cpExtensions/Algorithms/BezierCurveFunction.h @@ -67,7 +67,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__ALGORITHMS__BEZIERCURVEFUNCTION__H__ diff --git a/lib/cpExtensions/Algorithms/GradientFunctionBase.h b/lib/cpExtensions/Algorithms/GradientFunctionBase.h index 2c4f5b6..0472cc4 100644 --- a/lib/cpExtensions/Algorithms/GradientFunctionBase.h +++ b/lib/cpExtensions/Algorithms/GradientFunctionBase.h @@ -75,7 +75,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__ALGORITHMS__GRADIENTFUNCTIONBASE__H__ diff --git a/lib/cpExtensions/Algorithms/GulsunTekMedialness.h b/lib/cpExtensions/Algorithms/GulsunTekMedialness.h index 27c1c7e..2fdf61c 100644 --- a/lib/cpExtensions/Algorithms/GulsunTekMedialness.h +++ b/lib/cpExtensions/Algorithms/GulsunTekMedialness.h @@ -76,7 +76,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__ALGORITHMS__GULSUNTEKMEDIALNESS__H__ diff --git a/lib/cpExtensions/Algorithms/ImageFunctionFilter.h b/lib/cpExtensions/Algorithms/ImageFunctionFilter.h index 9c0e76d..39007a5 100644 --- a/lib/cpExtensions/Algorithms/ImageFunctionFilter.h +++ b/lib/cpExtensions/Algorithms/ImageFunctionFilter.h @@ -97,7 +97,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION // TODO: #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__ALGORITHMS__IMAGEFUNCTIONFILTER__H__ diff --git a/lib/cpExtensions/Algorithms/InertiaMedialness.h b/lib/cpExtensions/Algorithms/InertiaMedialness.h index e9ad2a9..e385513 100644 --- a/lib/cpExtensions/Algorithms/InertiaMedialness.h +++ b/lib/cpExtensions/Algorithms/InertiaMedialness.h @@ -206,7 +206,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION // TODO: #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__ALGORITHMS__INERTIAMEDIALNESS__H__ diff --git a/lib/cpExtensions/Algorithms/InertiaTensorFunction.h b/lib/cpExtensions/Algorithms/InertiaTensorFunction.h index de097a4..ecb341d 100644 --- a/lib/cpExtensions/Algorithms/InertiaTensorFunction.h +++ b/lib/cpExtensions/Algorithms/InertiaTensorFunction.h @@ -171,7 +171,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION // #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__ALGORITHMS__INERTIATENSORFUNCTION__H__ diff --git a/lib/cpExtensions/Algorithms/IsoImageSlicer.h b/lib/cpExtensions/Algorithms/IsoImageSlicer.h index 2582cf9..cf4968d 100644 --- a/lib/cpExtensions/Algorithms/IsoImageSlicer.h +++ b/lib/cpExtensions/Algorithms/IsoImageSlicer.h @@ -158,28 +158,28 @@ namespace cpExtensions void operator=( const Self& ); \ }; -namespace cpPlugins +namespace cpExtensions { - namespace Extensions + namespace Algorithms { - namespace Algorithms - { - CPPLUGINS_DEFINE_ISOIMAGESLICER( - IsoImageSlicer, - itk::ResampleImageFilter, - itk::InterpolateImageFunction - ); - CPPLUGINS_DEFINE_ISOIMAGESLICER( - VectorIsoImageSlicer, - itk::VectorResampleImageFilter, - itk::VectorInterpolateImageFunction - ); - - } // ecapseman + CPPLUGINS_DEFINE_ISOIMAGESLICER( + IsoImageSlicer, + itk::ResampleImageFilter, + itk::InterpolateImageFunction + ); + CPPLUGINS_DEFINE_ISOIMAGESLICER( + VectorIsoImageSlicer, + itk::VectorResampleImageFilter, + itk::VectorInterpolateImageFunction + ); } // ecapseman +} // ecapseman + +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__ALGORITHMS__ISOIMAGESLICER__H__ diff --git a/lib/cpExtensions/Algorithms/IterativeGaussianModelEstimator.h b/lib/cpExtensions/Algorithms/IterativeGaussianModelEstimator.h index 8a30510..5cf7332 100644 --- a/lib/cpExtensions/Algorithms/IterativeGaussianModelEstimator.h +++ b/lib/cpExtensions/Algorithms/IterativeGaussianModelEstimator.h @@ -102,7 +102,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__ALGORITHMS__ITERATIVEGAUSSIANMODELESTIMATOR__H__ diff --git a/lib/cpExtensions/Algorithms/KalmanConstantFilter.h b/lib/cpExtensions/Algorithms/KalmanConstantFilter.h index e9d0192..860a8f3 100644 --- a/lib/cpExtensions/Algorithms/KalmanConstantFilter.h +++ b/lib/cpExtensions/Algorithms/KalmanConstantFilter.h @@ -34,17 +34,17 @@ namespace cpExtensions public: void Configure( unsigned int m ); - /// Iteration methods - virtual void Initialize( ); + // Iteration methods + virtual void Initialize( ); protected: - KalmanConstantFilter( ); - virtual ~KalmanConstantFilter( ); + KalmanConstantFilter( ); + virtual ~KalmanConstantFilter( ); private: - // Purposely not implemented. - KalmanConstantFilter( const Self& ); - void operator=( const Self& ); + // Purposely not implemented. + KalmanConstantFilter( const Self& ); + void operator=( const Self& ); }; } // ecapseman diff --git a/lib/cpExtensions/Algorithms/KalmanFilter.h b/lib/cpExtensions/Algorithms/KalmanFilter.h index a96c620..bd0c17a 100644 --- a/lib/cpExtensions/Algorithms/KalmanFilter.h +++ b/lib/cpExtensions/Algorithms/KalmanFilter.h @@ -130,83 +130,85 @@ namespace cpExtensions void Configure( unsigned int s, unsigned int i, unsigned int m ); - /// Iteration methods - virtual void Initialize( ); - virtual void Predict( ); - virtual void Innovate( ); - virtual void Filtrate( ); - virtual void OneStep( ) + // Iteration methods + virtual void Initialize( ); + virtual void Predict( ); + virtual void Innovate( ); + virtual void Filtrate( ); + virtual void OneStep( ) { this->Predict( ); this->Innovate( ); this->Filtrate( ); } - virtual void NSteps( unsigned int n ) + virtual void NSteps( unsigned int n ) { for( unsigned int i = 0; i < n; i++ ) this->OneStep( ); } - unsigned int CurrentIteration( ) const + unsigned int CurrentIteration( ) const { return( this->m_I ); } - unsigned char CurrentStep( ) const + unsigned char CurrentStep( ) const { return( this->m_Step ); } protected: - KalmanFilter( ); - virtual ~KalmanFilter( ); + KalmanFilter( ); + virtual ~KalmanFilter( ); private: - // Purposely not implemented - KalmanFilter( const Self& ); - void operator=( const Self& ); + // Purposely not implemented + KalmanFilter( const Self& ); + void operator=( const Self& ); protected: - // Filter dimensions - unsigned int m_StateSize; - unsigned int m_InputSize; - unsigned int m_MeasureSize; - - // Transition matrices - TMatrix m_A; /// Transition - TMatrix m_B; /// Input control - TMatrix m_H; /// Measure - TMatrix m_Id; /// Identity matrix - - // Noise matrices - TMatrix m_Q; /// Process noise covariance - TMatrix m_R; /// Measure noise covariance - - // Initial values - TVector m_x0; /// Initial state - TMatrix m_P0; /// Initial error covariance - - // Loop vectors - TVector m_u; /// Last real input - TVector m_m; /// Last real measure - TVector m_xm; /// A priori state - TVector m_xp; /// A posteriori state - - // Loop matrices - TMatrix m_K; /// kalman gain - TMatrix m_Pm; /// A priori error - TMatrix m_Pp; /// A posteriori error - - // Loop values - unsigned int m_I; /// Current iteration - unsigned char m_Step; /// Current step within current iteration - - // ----------------------------------------------------------------- - // Classic kronecker product operator - // ----------------------------------------------------------------- - template< class M > - static void Kronecker( M& AkB, const M& A, const M& B ); + // Filter dimensions + unsigned int m_StateSize; + unsigned int m_InputSize; + unsigned int m_MeasureSize; + + // Transition matrices + TMatrix m_A; // Transition + TMatrix m_B; // Input control + TMatrix m_H; // Measure + TMatrix m_Id; // Identity matrix + + // Noise matrices + TMatrix m_Q; // Process noise covariance + TMatrix m_R; // Measure noise covariance + + // Initial values + TVector m_x0; // Initial state + TMatrix m_P0; // Initial error covariance + + // Loop vectors + TVector m_u; // Last real input + TVector m_m; // Last real measure + TVector m_xm; // A priori state + TVector m_xp; // A posteriori state + + // Loop matrices + TMatrix m_K; // kalman gain + TMatrix m_Pm; // A priori error + TMatrix m_Pp; // A posteriori error + + // Loop values + unsigned int m_I; // Current iteration + unsigned char m_Step; // Current step within current iteration + + // ------------------------------------------------------------------- + // Classic kronecker product operator + // ------------------------------------------------------------------- + template< class M > + static void Kronecker( M& AkB, const M& A, const M& B ); }; } // ecapseman } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__ALGORITHMS__KALMANFILTER__H__ diff --git a/lib/cpExtensions/Algorithms/LightCompensationFilter.h b/lib/cpExtensions/Algorithms/LightCompensationFilter.h index d219c7d..a3c28ff 100644 --- a/lib/cpExtensions/Algorithms/LightCompensationFilter.h +++ b/lib/cpExtensions/Algorithms/LightCompensationFilter.h @@ -56,7 +56,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__ALGORITHMS__LIGHTCOMPENSATIONFILTER__H__ diff --git a/lib/cpExtensions/Algorithms/MultiScaleGaussianImageFilter.h b/lib/cpExtensions/Algorithms/MultiScaleGaussianImageFilter.h index 079d9d4..5dba45b 100644 --- a/lib/cpExtensions/Algorithms/MultiScaleGaussianImageFilter.h +++ b/lib/cpExtensions/Algorithms/MultiScaleGaussianImageFilter.h @@ -93,7 +93,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__ALGORITHMS__MULTISCALEGAUSSIANIMAGEFILTER__H__ diff --git a/lib/cpExtensions/Algorithms/ParallelImageMean.h b/lib/cpExtensions/Algorithms/ParallelImageMean.h index 1fe204a..6122ce3 100644 --- a/lib/cpExtensions/Algorithms/ParallelImageMean.h +++ b/lib/cpExtensions/Algorithms/ParallelImageMean.h @@ -61,7 +61,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__ALGORITHMS__PARALLELIMAGEMEAN__H__ diff --git a/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.h b/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.h index b537015..eec919d 100644 --- a/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.h +++ b/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.h @@ -71,7 +71,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__ALGORITHMS__RGBIMAGETOOTHERCHANNELSFILTER__H__ diff --git a/lib/cpExtensions/CMakeLists.txt b/lib/cpExtensions/CMakeLists.txt index 376a353..8819756 100644 --- a/lib/cpExtensions/CMakeLists.txt +++ b/lib/cpExtensions/CMakeLists.txt @@ -45,7 +45,7 @@ FILE(GLOB LIB_Visualization_SOURCES_CXX "Visualization/*.cxx") ADD_LIBRARY( ${LIBRARY_NAME} - SHARED + ${LIBRARY_TYPE} ${LIB_SOURCES_C} ${LIB_SOURCES_CPP} ${LIB_SOURCES_CXX} diff --git a/lib/cpExtensions/DataStructures/QuadEdge.h b/lib/cpExtensions/DataStructures/QuadEdge.h index 1914d03..bcb1f88 100644 --- a/lib/cpExtensions/DataStructures/QuadEdge.h +++ b/lib/cpExtensions/DataStructures/QuadEdge.h @@ -462,7 +462,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__DATASTRUCTURES__QUADEDGE__H__ diff --git a/lib/cpExtensions/DataStructures/QuadEdgeCell.h b/lib/cpExtensions/DataStructures/QuadEdgeCell.h index d177e3d..84ae92f 100644 --- a/lib/cpExtensions/DataStructures/QuadEdgeCell.h +++ b/lib/cpExtensions/DataStructures/QuadEdgeCell.h @@ -117,7 +117,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__DATASTRUCTURES__QUADEDGECELL__H__ diff --git a/lib/cpExtensions/DataStructures/QuadEdgeIterators.h b/lib/cpExtensions/DataStructures/QuadEdgeIterators.h index c1a06a7..c82ac34 100644 --- a/lib/cpExtensions/DataStructures/QuadEdgeIterators.h +++ b/lib/cpExtensions/DataStructures/QuadEdgeIterators.h @@ -164,7 +164,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__DATASTRUCTURES__QUADEDGEITERATORS__H__ diff --git a/lib/cpExtensions/DataStructures/QuadEdgeMesh.h b/lib/cpExtensions/DataStructures/QuadEdgeMesh.h index 7ce48fe..40cdf1f 100644 --- a/lib/cpExtensions/DataStructures/QuadEdgeMesh.h +++ b/lib/cpExtensions/DataStructures/QuadEdgeMesh.h @@ -276,7 +276,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__DATASTRUCTURES__QUADEDGEMESH__H__ diff --git a/lib/cpExtensions/IO/MeshReader.h b/lib/cpExtensions/IO/MeshReader.h index d6e8e1f..af16293 100644 --- a/lib/cpExtensions/IO/MeshReader.h +++ b/lib/cpExtensions/IO/MeshReader.h @@ -55,7 +55,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__IO__MESHREADER__H__ diff --git a/lib/cpExtensions/IO/WaveFrontOBJReader.h b/lib/cpExtensions/IO/WaveFrontOBJReader.h index 98274d8..4cd7446 100644 --- a/lib/cpExtensions/IO/WaveFrontOBJReader.h +++ b/lib/cpExtensions/IO/WaveFrontOBJReader.h @@ -72,7 +72,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__IO__WAVEFRONTOBJREADER__H__ diff --git a/lib/cpExtensions/Visualization/MeshMapper.h b/lib/cpExtensions/Visualization/MeshMapper.h index e833f12..c6aee51 100644 --- a/lib/cpExtensions/Visualization/MeshMapper.h +++ b/lib/cpExtensions/Visualization/MeshMapper.h @@ -96,7 +96,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__VISUALIZATION__MESHMAPPER__H__ diff --git a/lib/cpExtensions/Visualization/OpenGLMeshMapper.h b/lib/cpExtensions/Visualization/OpenGLMeshMapper.h index 02ffeac..ff80ce3 100644 --- a/lib/cpExtensions/Visualization/OpenGLMeshMapper.h +++ b/lib/cpExtensions/Visualization/OpenGLMeshMapper.h @@ -69,7 +69,9 @@ namespace cpExtensions } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__VISUALIZATION__OPENGLMESHMAPPER__H__ diff --git a/lib/cpPlugins/Interface/BaseProcessObjects.cxx b/lib/cpPlugins/Interface/BaseProcessObjects.cxx index 8f03de0..004d939 100644 --- a/lib/cpPlugins/Interface/BaseProcessObjects.cxx +++ b/lib/cpPlugins/Interface/BaseProcessObjects.cxx @@ -7,9 +7,9 @@ cpPlugins_Interface_Code_ProcessObject( ImageSource ); cpPlugins_Interface_Code_ProcessObject( MeshSource ); cpPlugins_Interface_Code_ProcessObject( ImageSink ); cpPlugins_Interface_Code_ProcessObject( MeshSink ); -cpPlugins_Interface_Code_ProcessObject( ImageToImageFitler ); -cpPlugins_Interface_Code_ProcessObject( ImageToMeshFitler ); -cpPlugins_Interface_Code_ProcessObject( MeshToImageFitler ); -cpPlugins_Interface_Code_ProcessObject( MeshToMeshFitler ); +cpPlugins_Interface_Code_ProcessObject( ImageToImageFilter ); +cpPlugins_Interface_Code_ProcessObject( ImageToMeshFilter ); +cpPlugins_Interface_Code_ProcessObject( MeshToImageFilter ); +cpPlugins_Interface_Code_ProcessObject( MeshToMeshFilter ); // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/BaseProcessObjects.h b/lib/cpPlugins/Interface/BaseProcessObjects.h index 687a00f..688a955 100644 --- a/lib/cpPlugins/Interface/BaseProcessObjects.h +++ b/lib/cpPlugins/Interface/BaseProcessObjects.h @@ -33,6 +33,101 @@ } \ 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< 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::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< 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::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 \ + ) + namespace cpPlugins { namespace Interface @@ -44,10 +139,10 @@ namespace cpPlugins cpPlugins_Interface_Define_ProcessObject( MeshSource, SourceObject ); cpPlugins_Interface_Define_ProcessObject( ImageSink, SinkObject ); cpPlugins_Interface_Define_ProcessObject( MeshSink, SinkObject ); - cpPlugins_Interface_Define_ProcessObject( ImageToImageFitler, FilterObject ); - cpPlugins_Interface_Define_ProcessObject( ImageToMeshFitler, FilterObject ); - cpPlugins_Interface_Define_ProcessObject( MeshToImageFitler, FilterObject ); - cpPlugins_Interface_Define_ProcessObject( MeshToMeshFitler, FilterObject ); + cpPlugins_Interface_Define_ProcessObject( ImageToImageFilter, FilterObject ); + cpPlugins_Interface_Define_ProcessObject( ImageToMeshFilter, FilterObject ); + cpPlugins_Interface_Define_ProcessObject( MeshToImageFilter, FilterObject ); + cpPlugins_Interface_Define_ProcessObject( MeshToMeshFilter, FilterObject ); } // ecapseman diff --git a/lib/cpPlugins/Interface/Image.h b/lib/cpPlugins/Interface/Image.h index 6902b70..1da443b 100644 --- a/lib/cpPlugins/Interface/Image.h +++ b/lib/cpPlugins/Interface/Image.h @@ -64,6 +64,9 @@ namespace cpPlugins Image( ); virtual ~Image( ); + template< class P, unsigned int D > + inline void _ITK_2_VTK( itk::DataObject* object ); + /* TODO template< unsigned int D > bool _Dim( itk::DataObject* o ); diff --git a/lib/cpPlugins/Interface/Image.hxx b/lib/cpPlugins/Interface/Image.hxx index bd8ee04..bb1c667 100644 --- a/lib/cpPlugins/Interface/Image.hxx +++ b/lib/cpPlugins/Interface/Image.hxx @@ -2,8 +2,78 @@ #define __CPPLUGINS__INTERFACE__IMAGE__HXX__ #define ITK_MANUAL_INSTANTIATION +#include #include +#include +#include +#include +#include +#include +#include +#include + +// ------------------------------------------------------------------------- +#define cpPlugins_Image_Demangle( TI, T, D, o ) \ + if( typeid( typename TI::PixelType ) == typeid( T ) ) \ + 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 > ) ) \ + 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 \ + ) + // ------------------------------------------------------------------------- template< class I > void cpPlugins::Interface::Image:: @@ -12,18 +82,50 @@ SetITKImage( itk::DataObject* object ) // Check if input object has the desired type I* image = dynamic_cast< I* >( object ); if( image == NULL ) - return; + { + this->m_ITKObject = NULL; + this->m_VTKObject = NULL; + this->m_ITKvVTKConnection = NULL; + this->Modified( ); + + } // fi // Connect it to VTK - typename itk::ImageToVTKImageFilter< I >::Pointer f = - itk::ImageToVTKImageFilter< I >::New( ); - f->SetInput( image ); - f->Update( ); + 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 + } + else + { + this->m_VTKObject = NULL; + this->m_ITKvVTKConnection = NULL; + + } // fi // Keep objects this->m_ITKObject = object; - this->m_VTKObject = f->GetOutput( ); - this->m_ITKvVTKConnection = f; this->Modified( ); } @@ -43,6 +145,29 @@ 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 ) +{ + typedef itk::Image< P, D > _I; + + // Check if input object has the desired type + _I* image = dynamic_cast< _I* >( object ); + if( image == NULL ) + return; + + // Connect it to VTK + typename itk::ImageToVTKImageFilter< _I >::Pointer f = + itk::ImageToVTKImageFilter< _I >::New( ); + f->SetInput( image ); + f->Update( ); + + // Keep objects + this->m_VTKObject = f->GetOutput( ); + this->m_ITKvVTKConnection = f; +} + #endif // __CPPLUGINS__INTERFACE__IMAGE__HXX__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ProcessObject.h b/lib/cpPlugins/Interface/ProcessObject.h index 31a9e62..ee5bedd 100644 --- a/lib/cpPlugins/Interface/ProcessObject.h +++ b/lib/cpPlugins/Interface/ProcessObject.h @@ -50,6 +50,18 @@ namespace cpPlugins template< class O > inline void _MakeOutput( unsigned int idx ); + template< class T > + inline T* _Input( unsigned int idx ); + + template< class T > + inline const T* _Input( unsigned int idx ) const; + + template< class T > + inline T* _Output( unsigned int idx ); + + template< class T > + inline const T* _Output( unsigned int idx ) const; + virtual std::string _GenerateData( ) = 0; private: diff --git a/lib/cpPlugins/Interface/ProcessObject.hxx b/lib/cpPlugins/Interface/ProcessObject.hxx index 6dcbb7d..7b4e080 100644 --- a/lib/cpPlugins/Interface/ProcessObject.hxx +++ b/lib/cpPlugins/Interface/ProcessObject.hxx @@ -12,6 +12,50 @@ _MakeOutput( unsigned int idx ) this->m_Outputs[ idx ]->SetSource( this ); } +// ------------------------------------------------------------------------- +template< class T > +T* cpPlugins::Interface::ProcessObject:: +_Input( unsigned int idx ) +{ + if( idx < this->m_Inputs.size( ) ) + return( dynamic_cast< T* >( this->m_Inputs[ idx ].GetPointer( ) ) ); + else + return( NULL ); +} + +// ------------------------------------------------------------------------- +template< class T > +const T* cpPlugins::Interface::ProcessObject:: +_Input( unsigned int idx ) const +{ + if( idx < this->m_Inputs.size( ) ) + return( dynamic_cast< const T* >( this->m_Inputs[ idx ].GetPointer( ) ) ); + else + return( NULL ); +} + +// ------------------------------------------------------------------------- +template< class T > +T* cpPlugins::Interface::ProcessObject:: +_Output( unsigned int idx ) +{ + if( idx < this->m_Outputs.size( ) ) + return( dynamic_cast< T* >( this->m_Outputs[ idx ].GetPointer( ) ) ); + else + return( NULL ); +} + +// ------------------------------------------------------------------------- +template< class T > +const T* cpPlugins::Interface::ProcessObject:: +_Output( unsigned int idx ) const +{ + if( idx < this->m_Outputs.size( ) ) + return( dynamic_cast< const T* >( this->m_Outputs[ idx ].GetPointer( ) ) ); + else + return( NULL ); +} + #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/CMakeLists.txt b/lib/cpPlugins/Plugins/CMakeLists.txt index ccb6f75..21a1217 100644 --- a/lib/cpPlugins/Plugins/CMakeLists.txt +++ b/lib/cpPlugins/Plugins/CMakeLists.txt @@ -23,6 +23,8 @@ SET( ) SET( LIB_SOURCES_CXX + Instances_itkImage.cxx + Instances_itkMesh.cxx Host.cxx ImageReader.cxx ImageWriter.cxx diff --git a/lib/cpPlugins/Plugins/ImageReader.cxx b/lib/cpPlugins/Plugins/ImageReader.cxx index 2439971..d4ca0ba 100644 --- a/lib/cpPlugins/Plugins/ImageReader.cxx +++ b/lib/cpPlugins/Plugins/ImageReader.cxx @@ -66,7 +66,6 @@ _GenerateData( ) { switch( io->GetNumberOfDimensions( ) ) { - case 1: r = this->_GD0< 1 >( io, names ); break; case 2: r = this->_GD0< 2 >( io, names ); break; case 3: r = this->_GD0< 3 >( io, names ); break; case 4: r = this->_GD0< 4 >( io, names ); break; @@ -283,9 +282,6 @@ _GD0( itk::ImageIOBase* io, const TStringList& names ) { switch( D ) { - case 1: - r = this->_RealGD< itk::Offset< 1 >, 1 >( names ); - break; case 2: r = this->_RealGD< itk::Offset< 2 >, 2 >( names ); break; @@ -436,12 +432,22 @@ _RealGD( const TStringList& names ) try { reader->Update( ); - this->m_Outputs[ 0 ]->SetITKDataObject( reader->GetOutput( ) ); + cpPlugins::Interface::Image* out = + this->_Output< cpPlugins::Interface::Image >( 0 ); + if( out != NULL ) + out->SetITKImage< _I >( reader->GetOutput( ) ); + else + r = "ImageReader: output not correctly created."; } catch( itk::ExceptionObject& err ) { r = "ImageReader: " + std::string( err.GetDescription( ) ); - this->m_Outputs[ 0 ]->SetITKDataObject( NULL ); + cpPlugins::Interface::Image* out = + this->_Output< cpPlugins::Interface::Image >( 0 ); + if( out != NULL ) + out->SetITKImage< _I >( NULL ); + else + r = "ImageReader: output not correctly created."; } // yrt } @@ -468,12 +474,22 @@ _RealGD( const TStringList& names ) try { reader->Update( ); - this->m_Outputs[ 0 ]->SetITKDataObject( reader->GetOutput( ) ); + cpPlugins::Interface::Image* out = + this->_Output< cpPlugins::Interface::Image >( 0 ); + if( out != NULL ) + out->SetITKImage< _I >( reader->GetOutput( ) ); + else + r = "ImageReader: output not correctly created."; } catch( itk::ExceptionObject& err ) { r = "ImageReader: " + std::string( err.GetDescription( ) ); - this->m_Outputs[ 0 ]->SetITKDataObject( NULL ); + cpPlugins::Interface::Image* out = + this->_Output< cpPlugins::Interface::Image >( 0 ); + if( out != NULL ) + out->SetITKImage< _I >( NULL ); + else + r = "ImageReader: output not correctly created."; } // yrt } diff --git a/lib/cpPlugins/Plugins/ImageReader.h b/lib/cpPlugins/Plugins/ImageReader.h index f52d409..47fff41 100644 --- a/lib/cpPlugins/Plugins/ImageReader.h +++ b/lib/cpPlugins/Plugins/ImageReader.h @@ -3,8 +3,8 @@ #include -#include -#include +#include +#include #define ITK_MANUAL_INSTANTIATION #include @@ -15,7 +15,7 @@ namespace cpPlugins { /** */ - class cpPlugins_EXPORT ImageReader + class /*cpPlugins_EXPORT*/ ImageReader : public cpPlugins::Interface::ImageSource { public: diff --git a/lib/cpPlugins/Plugins/ImageWriter.cxx b/lib/cpPlugins/Plugins/ImageWriter.cxx index 176e9f6..955d191 100644 --- a/lib/cpPlugins/Plugins/ImageWriter.cxx +++ b/lib/cpPlugins/Plugins/ImageWriter.cxx @@ -1,4 +1,5 @@ #include +#include #include @@ -40,17 +41,31 @@ cpPlugins::Plugins::ImageWriter:: std::string cpPlugins::Plugins::ImageWriter:: _GenerateData( ) { - itk::DataObject* i = this->m_Inputs[ 0 ]->GetITKDataObject( ); - return( this->_DemangleImageDimension( i ) ); -} + cpPlugins::Interface::Image* image = + this->_Input< cpPlugins::Interface::Image >( 0 ); + if( image == NULL ) + return( "ImageWriter: No input image." ); -// ------------------------------------------------------------------------- -namespace cpPlugins -{ - namespace Plugins - { - cpPlugins_Image_Demangle_Methods_Code( ImageWriter, _RealGD ); - } + 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 + ); + 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 + ); + else r = "ImageWriter: Input image type not supported."; + + return( r ); } // ------------------------------------------------------------------------- @@ -59,12 +74,9 @@ std::string cpPlugins::Plugins::ImageWriter:: _RealGD( itk::DataObject* image ) { typedef itk::ImageFileWriter< I > _W; - + // Get filename - using namespace cpPlugins::Interface; - Parameters::TString fname = - this->m_Parameters.GetValueAsString( "FileName" ); - + std::string fname = this->m_Parameters.GetValueAsString( "FileName" ); _W* writer = dynamic_cast< _W* >( this->m_RealProcessObject.GetPointer( ) ); if( writer == NULL ) { diff --git a/lib/cpPlugins/Plugins/ImageWriter.h b/lib/cpPlugins/Plugins/ImageWriter.h index 31bdad1..4fc04f5 100644 --- a/lib/cpPlugins/Plugins/ImageWriter.h +++ b/lib/cpPlugins/Plugins/ImageWriter.h @@ -1,8 +1,8 @@ #ifndef __CPPLUGINS__PLUGINS__IMAGEWRITER__H__ #define __CPPLUGINS__PLUGINS__IMAGEWRITER__H__ -#include -#include +#include +#include namespace cpPlugins { @@ -29,10 +29,8 @@ namespace cpPlugins virtual std::string _GenerateData( ); - cpPlugins_Image_Demangle_Methods( ImageWriter ); - template< class I > - std::string _RealGD( itk::DataObject* image ); + inline std::string _RealGD( itk::DataObject* image ); private: // Purposely not implemented diff --git a/lib/cpPlugins/Plugins/Instances_itkImage.cxx b/lib/cpPlugins/Plugins/Instances_itkImage.cxx index a6308b8..ef29677 100644 --- a/lib/cpPlugins/Plugins/Instances_itkImage.cxx +++ b/lib/cpPlugins/Plugins/Instances_itkImage.cxx @@ -1,3 +1,5 @@ +#include + #include #undef ITK_MANUAL_INSTANTIATION @@ -14,28 +16,31 @@ #include // ------------------------------------------------------------------------- -#define cpPlugins_I_itk( p, d ) \ - template class itk::Image< p, d >; +#define cpPlugins_I_itk( p, d ) \ + template class cpPlugins_EXPORT itk::Image< p, d >; // ------------------------------------------------------------------------- -#define cpPlugins_I_itk_array( a, p, da, di ) \ - template class itk::Image< a< p, da >, di >; +#define cpPlugins_I_itk_array( a, p, da, di ) \ + template class cpPlugins_EXPORT itk::Image< a< p, da >, di >; // ------------------------------------------------------------------------- #define cpPlugins_I_itk_Container( p ) \ - template class itk::ImportImageContainer< itk::SizeValueType, p >; + template class cpPlugins_EXPORT \ + itk::ImportImageContainer< itk::SizeValueType, p >; // ------------------------------------------------------------------------- -#define cpPlugins_I_itk_array_Container( a, p, d ) \ - template class itk::ImportImageContainer< itk::SizeValueType, a< p, d > >; +#define cpPlugins_I_itk_array_Container( a, p, d ) \ + template class cpPlugins_EXPORT \ + itk::ImportImageContainer< itk::SizeValueType, a< p, d > >; // ------------------------------------------------------------------------- #define cpPlugins_I_itk_vtk( p, d ) \ - template class itk::ImageToVTKImageFilter< itk::Image< p, d > >; + template class cpPlugins_EXPORT \ + itk::ImageToVTKImageFilter< itk::Image< p, d > >; // ------------------------------------------------------------------------- #define cpPlugins_I_itk_vtk_array( a, p, da, di ) \ - template class \ + template class cpPlugins_EXPORT \ itk::ImageToVTKImageFilter< itk::Image< a< p, da > , di > >; // ------------------------------------------------------------------------- @@ -43,11 +48,13 @@ namespace itk { - template std::ostream& operator<<( - std::ostream& os, const ImageRegion< 1 >& obj - ); - template class Point< double, 1 >; - template class Vector< double, 1 >; + /* TODO + template cpPlugins_EXPORT std::ostream& operator<<( + std::ostream& os, const ImageRegion< 1 >& obj + ); + template class cpPlugins_EXPORT Point< double, 1 >; + template class cpPlugins_EXPORT Vector< double, 1 >; + */ } // ecapseman @@ -71,36 +78,27 @@ cpPlugins_I_itk_Container( itk::RGBAPixel< char > ); cpPlugins_I_itk_Container( itk::RGBAPixel< short > ); cpPlugins_I_itk_Container( itk::RGBAPixel< unsigned char > ); cpPlugins_I_itk_Container( itk::RGBAPixel< unsigned short > ); -cpPlugins_I_itk_Container( itk::Offset< 1 > ); cpPlugins_I_itk_Container( itk::Offset< 2 > ); cpPlugins_I_itk_Container( itk::Offset< 3 > ); cpPlugins_I_itk_Container( itk::Offset< 4 > ); -cpPlugins_I_itk_array_Container( itk::Vector, float, 1 ); -cpPlugins_I_itk_array_Container( itk::Vector, double, 1 ); cpPlugins_I_itk_array_Container( itk::Vector, float, 2 ); cpPlugins_I_itk_array_Container( itk::Vector, double, 2 ); cpPlugins_I_itk_array_Container( itk::Vector, float, 3 ); cpPlugins_I_itk_array_Container( itk::Vector, double, 3 ); cpPlugins_I_itk_array_Container( itk::Vector, float, 4 ); cpPlugins_I_itk_array_Container( itk::Vector, double, 4 ); -cpPlugins_I_itk_array_Container( itk::Point, float, 1 ); -cpPlugins_I_itk_array_Container( itk::Point, double, 1 ); cpPlugins_I_itk_array_Container( itk::Point, float, 2 ); cpPlugins_I_itk_array_Container( itk::Point, double, 2 ); cpPlugins_I_itk_array_Container( itk::Point, float, 3 ); cpPlugins_I_itk_array_Container( itk::Point, double, 3 ); cpPlugins_I_itk_array_Container( itk::Point, float, 4 ); cpPlugins_I_itk_array_Container( itk::Point, double, 4 ); -cpPlugins_I_itk_array_Container( itk::CovariantVector, float, 1 ); -cpPlugins_I_itk_array_Container( itk::CovariantVector, double, 1 ); cpPlugins_I_itk_array_Container( itk::CovariantVector, float, 2 ); cpPlugins_I_itk_array_Container( itk::CovariantVector, double, 2 ); cpPlugins_I_itk_array_Container( itk::CovariantVector, float, 3 ); cpPlugins_I_itk_array_Container( itk::CovariantVector, double, 3 ); cpPlugins_I_itk_array_Container( itk::CovariantVector, float, 4 ); cpPlugins_I_itk_array_Container( itk::CovariantVector, double, 4 ); -cpPlugins_I_itk_array_Container( itk::SymmetricSecondRankTensor, float, 1 ); -cpPlugins_I_itk_array_Container( itk::SymmetricSecondRankTensor, double, 1 ); cpPlugins_I_itk_array_Container( itk::SymmetricSecondRankTensor, float, 2 ); cpPlugins_I_itk_array_Container( itk::SymmetricSecondRankTensor, double, 2 ); cpPlugins_I_itk_array_Container( itk::SymmetricSecondRankTensor, float, 3 ); @@ -110,17 +108,6 @@ cpPlugins_I_itk_array_Container( itk::SymmetricSecondRankTensor, double, 4 ); cpPlugins_I_itk_Container( itk::DiffusionTensor3D< float > ); cpPlugins_I_itk_Container( itk::DiffusionTensor3D< double > ); -cpPlugins_I_itk( char, 1 ); -cpPlugins_I_itk( short, 1 ); -cpPlugins_I_itk( int, 1 ); -cpPlugins_I_itk( long, 1 ); -cpPlugins_I_itk( unsigned char, 1 ); -cpPlugins_I_itk( unsigned short, 1 ); -cpPlugins_I_itk( unsigned int, 1 ); -cpPlugins_I_itk( unsigned long, 1 ); -cpPlugins_I_itk( float, 1 ); -cpPlugins_I_itk( double, 1 ); - cpPlugins_I_itk( char, 2 ); cpPlugins_I_itk( short, 2 ); cpPlugins_I_itk( int, 2 ); @@ -154,15 +141,10 @@ cpPlugins_I_itk( unsigned long, 4 ); cpPlugins_I_itk( float, 4 ); cpPlugins_I_itk( double, 4 ); -cpPlugins_I_itk( std::complex< float >, 1 ); -cpPlugins_I_itk( std::complex< double >, 1 ); - cpPlugins_I_itk( std::complex< float >, 2 ); cpPlugins_I_itk( std::complex< double >, 2 ); - cpPlugins_I_itk( std::complex< float >, 3 ); cpPlugins_I_itk( std::complex< double >, 3 ); - cpPlugins_I_itk( std::complex< float >, 4 ); cpPlugins_I_itk( std::complex< double >, 4 ); @@ -170,12 +152,10 @@ cpPlugins_I_itk( itk::RGBPixel< char >, 2 ); cpPlugins_I_itk( itk::RGBPixel< short >, 2 ); cpPlugins_I_itk( itk::RGBPixel< unsigned char >, 2 ); cpPlugins_I_itk( itk::RGBPixel< unsigned short >, 2 ); - cpPlugins_I_itk( itk::RGBPixel< char >, 3 ); cpPlugins_I_itk( itk::RGBPixel< short >, 3 ); cpPlugins_I_itk( itk::RGBPixel< unsigned char >, 3 ); cpPlugins_I_itk( itk::RGBPixel< unsigned short >, 3 ); - cpPlugins_I_itk( itk::RGBPixel< char >, 4 ); cpPlugins_I_itk( itk::RGBPixel< short >, 4 ); cpPlugins_I_itk( itk::RGBPixel< unsigned char >, 4 ); @@ -185,24 +165,19 @@ cpPlugins_I_itk( itk::RGBAPixel< char >, 2 ); cpPlugins_I_itk( itk::RGBAPixel< short >, 2 ); cpPlugins_I_itk( itk::RGBAPixel< unsigned char >, 2 ); cpPlugins_I_itk( itk::RGBAPixel< unsigned short >, 2 ); - cpPlugins_I_itk( itk::RGBAPixel< char >, 3 ); cpPlugins_I_itk( itk::RGBAPixel< short >, 3 ); cpPlugins_I_itk( itk::RGBAPixel< unsigned char >, 3 ); cpPlugins_I_itk( itk::RGBAPixel< unsigned short >, 3 ); - cpPlugins_I_itk( itk::RGBAPixel< char >, 4 ); cpPlugins_I_itk( itk::RGBAPixel< short >, 4 ); cpPlugins_I_itk( itk::RGBAPixel< unsigned char >, 4 ); cpPlugins_I_itk( itk::RGBAPixel< unsigned short >, 4 ); -cpPlugins_I_itk( itk::Offset< 1 >, 1 ); cpPlugins_I_itk( itk::Offset< 2 >, 2 ); cpPlugins_I_itk( itk::Offset< 3 >, 3 ); cpPlugins_I_itk( itk::Offset< 4 >, 4 ); -cpPlugins_I_itk_array( itk::Vector, float, 1, 1 ); -cpPlugins_I_itk_array( itk::Vector, double, 1, 1 ); cpPlugins_I_itk_array( itk::Vector, float, 2, 2 ); cpPlugins_I_itk_array( itk::Vector, double, 2, 2 ); cpPlugins_I_itk_array( itk::Vector, float, 3, 3 ); @@ -210,8 +185,6 @@ cpPlugins_I_itk_array( itk::Vector, double, 3, 3 ); cpPlugins_I_itk_array( itk::Vector, float, 4, 4 ); cpPlugins_I_itk_array( itk::Vector, double, 4, 4 ); -cpPlugins_I_itk_array( itk::Point, float, 1, 1 ); -cpPlugins_I_itk_array( itk::Point, double, 1, 1 ); cpPlugins_I_itk_array( itk::Point, float, 2, 2 ); cpPlugins_I_itk_array( itk::Point, double, 2, 2 ); cpPlugins_I_itk_array( itk::Point, float, 3, 3 ); @@ -219,8 +192,6 @@ cpPlugins_I_itk_array( itk::Point, double, 3, 3 ); cpPlugins_I_itk_array( itk::Point, float, 4, 4 ); cpPlugins_I_itk_array( itk::Point, double, 4, 4 ); -cpPlugins_I_itk_array( itk::CovariantVector, float, 1, 1 ); -cpPlugins_I_itk_array( itk::CovariantVector, double, 1, 1 ); cpPlugins_I_itk_array( itk::CovariantVector, float, 2, 2 ); cpPlugins_I_itk_array( itk::CovariantVector, double, 2, 2 ); cpPlugins_I_itk_array( itk::CovariantVector, float, 3, 3 ); @@ -228,8 +199,6 @@ cpPlugins_I_itk_array( itk::CovariantVector, double, 3, 3 ); cpPlugins_I_itk_array( itk::CovariantVector, float, 4, 4 ); cpPlugins_I_itk_array( itk::CovariantVector, double, 4, 4 ); -cpPlugins_I_itk_array( itk::SymmetricSecondRankTensor, float, 1, 1 ); -cpPlugins_I_itk_array( itk::SymmetricSecondRankTensor, double, 1, 1 ); cpPlugins_I_itk_array( itk::SymmetricSecondRankTensor, float, 2, 2 ); cpPlugins_I_itk_array( itk::SymmetricSecondRankTensor, double, 2, 2 ); cpPlugins_I_itk_array( itk::SymmetricSecondRankTensor, float, 3, 3 ); @@ -248,17 +217,6 @@ cpPlugins_I_itk( itk::DiffusionTensor3D< double >, 3 ); // ------------------------------------------------------------------------- // Possible itk types that could be connected to vtk -cpPlugins_I_itk_vtk( char, 1 ); -cpPlugins_I_itk_vtk( short, 1 ); -cpPlugins_I_itk_vtk( int, 1 ); -cpPlugins_I_itk_vtk( long, 1 ); -cpPlugins_I_itk_vtk( unsigned char, 1 ); -cpPlugins_I_itk_vtk( unsigned short, 1 ); -cpPlugins_I_itk_vtk( unsigned int, 1 ); -cpPlugins_I_itk_vtk( unsigned long, 1 ); -cpPlugins_I_itk_vtk( float, 1 ); -cpPlugins_I_itk_vtk( double, 1 ); - cpPlugins_I_itk_vtk( char, 2 ); cpPlugins_I_itk_vtk( short, 2 ); cpPlugins_I_itk_vtk( int, 2 ); @@ -285,7 +243,6 @@ cpPlugins_I_itk_vtk( itk::RGBPixel< char >, 2 ); cpPlugins_I_itk_vtk( itk::RGBPixel< short >, 2 ); cpPlugins_I_itk_vtk( itk::RGBPixel< unsigned char >, 2 ); cpPlugins_I_itk_vtk( itk::RGBPixel< unsigned short >, 2 ); - cpPlugins_I_itk_vtk( itk::RGBPixel< char >, 3 ); cpPlugins_I_itk_vtk( itk::RGBPixel< short >, 3 ); cpPlugins_I_itk_vtk( itk::RGBPixel< unsigned char >, 3 ); @@ -295,35 +252,26 @@ cpPlugins_I_itk_vtk( itk::RGBAPixel< char >, 2 ); cpPlugins_I_itk_vtk( itk::RGBAPixel< short >, 2 ); cpPlugins_I_itk_vtk( itk::RGBAPixel< unsigned char >, 2 ); cpPlugins_I_itk_vtk( itk::RGBAPixel< unsigned short >, 2 ); - cpPlugins_I_itk_vtk( itk::RGBAPixel< char >, 3 ); cpPlugins_I_itk_vtk( itk::RGBAPixel< short >, 3 ); cpPlugins_I_itk_vtk( itk::RGBAPixel< unsigned char >, 3 ); cpPlugins_I_itk_vtk( itk::RGBAPixel< unsigned short >, 3 ); -cpPlugins_I_itk_vtk_array( itk::Vector, float, 1, 1 ); -cpPlugins_I_itk_vtk_array( itk::Vector, double, 1, 1 ); cpPlugins_I_itk_vtk_array( itk::Vector, float, 2, 2 ); cpPlugins_I_itk_vtk_array( itk::Vector, double, 2, 2 ); cpPlugins_I_itk_vtk_array( itk::Vector, float, 3, 3 ); cpPlugins_I_itk_vtk_array( itk::Vector, double, 3, 3 ); -cpPlugins_I_itk_vtk_array( itk::Point, float, 1, 1 ); -cpPlugins_I_itk_vtk_array( itk::Point, double, 1, 1 ); cpPlugins_I_itk_vtk_array( itk::Point, float, 2, 2 ); cpPlugins_I_itk_vtk_array( itk::Point, double, 2, 2 ); cpPlugins_I_itk_vtk_array( itk::Point, float, 3, 3 ); cpPlugins_I_itk_vtk_array( itk::Point, double, 3, 3 ); -cpPlugins_I_itk_vtk_array( itk::CovariantVector, float, 1, 1 ); -cpPlugins_I_itk_vtk_array( itk::CovariantVector, double, 1, 1 ); cpPlugins_I_itk_vtk_array( itk::CovariantVector, float, 2, 2 ); cpPlugins_I_itk_vtk_array( itk::CovariantVector, double, 2, 2 ); cpPlugins_I_itk_vtk_array( itk::CovariantVector, float, 3, 3 ); cpPlugins_I_itk_vtk_array( itk::CovariantVector, double, 3, 3 ); -cpPlugins_I_itk_vtk_array( itk::SymmetricSecondRankTensor, float, 1, 1 ); -cpPlugins_I_itk_vtk_array( itk::SymmetricSecondRankTensor, double, 1, 1 ); cpPlugins_I_itk_vtk_array( itk::SymmetricSecondRankTensor, float, 2, 2 ); cpPlugins_I_itk_vtk_array( itk::SymmetricSecondRankTensor, double, 2, 2 ); cpPlugins_I_itk_vtk_array( itk::SymmetricSecondRankTensor, float, 3, 3 ); diff --git a/lib/cpPlugins/Plugins/Instances_itkMesh.cxx b/lib/cpPlugins/Plugins/Instances_itkMesh.cxx index 575db64..7a462f3 100644 --- a/lib/cpPlugins/Plugins/Instances_itkMesh.cxx +++ b/lib/cpPlugins/Plugins/Instances_itkMesh.cxx @@ -1,14 +1,16 @@ +#include + #undef ITK_MANUAL_INSTANTIATION #include #include -template class itk::Mesh< float, 2 >; -template class itk::Mesh< float, 3 >; -template class itk::Mesh< double, 2 >; -template class itk::Mesh< double, 3 >; -template class itk::QuadEdgeMesh< float, 2 >; -template class itk::QuadEdgeMesh< float, 3 >; -template class itk::QuadEdgeMesh< double, 2 >; -template class itk::QuadEdgeMesh< double, 3 >; +template class cpPlugins_EXPORT itk::Mesh< float, 2 >; +template class cpPlugins_EXPORT itk::Mesh< float, 3 >; +template class cpPlugins_EXPORT itk::Mesh< double, 2 >; +template class cpPlugins_EXPORT itk::Mesh< double, 3 >; +template class cpPlugins_EXPORT itk::QuadEdgeMesh< float, 2 >; +template class cpPlugins_EXPORT itk::QuadEdgeMesh< float, 3 >; +template class cpPlugins_EXPORT itk::QuadEdgeMesh< double, 2 >; +template class cpPlugins_EXPORT itk::QuadEdgeMesh< double, 3 >; // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/MarchingCubes.cxx b/lib/cpPlugins/Plugins/MarchingCubes.cxx index bc56f9c..8187b42 100644 --- a/lib/cpPlugins/Plugins/MarchingCubes.cxx +++ b/lib/cpPlugins/Plugins/MarchingCubes.cxx @@ -36,34 +36,31 @@ std::string cpPlugins::Plugins::MarchingCubes:: _GenerateData( ) { // Get input - cpPlugins::Interface::Image* input = - dynamic_cast< cpPlugins::Interface::Image* >( - this->m_Inputs[ 0 ].GetPointer( ) - ); - if( input == NULL ) + cpPlugins::Interface::Image* image = + this->_Input< cpPlugins::Interface::Image >( 0 ); + if( image == NULL ) return( "MarchingCubes: Input data is not a valid image." ); - vtkImageData* vtk_input = - dynamic_cast< vtkImageData* >( input->GetVTKDataObject( ) ); - if( vtk_input == NULL ) - return( "MarchingCubes: Input does not have a valid conversion to VTK." ); + vtkImageData* vtk_image = image->GetVTKImageData( ); + 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" ); - if( vtk_input->GetDataDimension( ) == 2 ) + if( vtk_image->GetDataDimension( ) == 2 ) { vtkMarchingSquares* ms = vtkMarchingSquares::New( ); - ms->SetInputData( vtk_input ); + ms->SetInputData( vtk_image ); for( unsigned int i = 0; i < values.size( ); ++i ) ms->SetValue( i, values[ i ] ); this->m_Algorithm = ms; } - else if( vtk_input->GetDataDimension( ) == 3 ) + else if( vtk_image->GetDataDimension( ) == 3 ) { vtkMarchingCubes* mc = vtkMarchingCubes::New( ); - mc->SetInputData( vtk_input ); + mc->SetInputData( vtk_image ); for( unsigned int i = 0; i < values.size( ); ++i ) mc->SetValue( i, values[ i ] ); this->m_Algorithm = mc; @@ -73,7 +70,9 @@ _GenerateData( ) // Execute filter this->m_Algorithm->Update( ); - this->m_Outputs[ 0 ]->SetVTKDataObject( this->m_Algorithm->GetOutput( ) ); + cpPlugins::Interface::Mesh* out = + this->_Output< cpPlugins::Interface::Mesh >( 0 ); + out->SetVTKMesh( this->m_Algorithm->GetOutput( ) ); return( "" ); } diff --git a/lib/cpPlugins/Plugins/MarchingCubes.h b/lib/cpPlugins/Plugins/MarchingCubes.h index 1976e68..b675bba 100644 --- a/lib/cpPlugins/Plugins/MarchingCubes.h +++ b/lib/cpPlugins/Plugins/MarchingCubes.h @@ -1,8 +1,8 @@ #ifndef __CPPLUGINS__PLUGINS__MARCHINGCUBES__H__ #define __CPPLUGINS__PLUGINS__MARCHINGCUBES__H__ -#include -#include +#include +#include class vtkPolyDataAlgorithm; diff --git a/lib/cpPlugins/Plugins/MeshReader.cxx b/lib/cpPlugins/Plugins/MeshReader.cxx index 5338c32..e658d86 100644 --- a/lib/cpPlugins/Plugins/MeshReader.cxx +++ b/lib/cpPlugins/Plugins/MeshReader.cxx @@ -37,7 +37,9 @@ _GenerateData( ) using namespace cpPlugins::Interface; Parameters::TUint dim = this->m_Parameters.GetValueAsUint( "Dimension" ); std::string r = "MeshReader: Mesh dimension not supported."; - if( dim == 3 ) + if( dim == 2 ) + r = this->_GD0< 2 >( ); + else if( dim == 3 ) r = this->_GD0< 3 >( ); return( r ); } @@ -72,7 +74,13 @@ _GD1( ) this->m_Reader = pdr; pdr->SetFileName( fname.c_str( ) ); pdr->Update( ); - this->m_Outputs[ 0 ]->SetVTKDataObject( pdr->GetOutput( ) ); + + cpPlugins::Interface::Mesh* out = + this->_Output< cpPlugins::Interface::Mesh >( 0 ); + if( out != NULL ) + out->SetVTKMesh( pdr->GetOutput( ) ); + else + return( "MeshReader: output not correctly created." ); return( "" ); } diff --git a/lib/cpPlugins/Plugins/MeshReader.h b/lib/cpPlugins/Plugins/MeshReader.h index 33132c1..394f6a8 100644 --- a/lib/cpPlugins/Plugins/MeshReader.h +++ b/lib/cpPlugins/Plugins/MeshReader.h @@ -1,8 +1,8 @@ #ifndef __CPPLUGINS__PLUGINS__MESHREADER__H__ #define __CPPLUGINS__PLUGINS__MESHREADER__H__ -#include -#include +#include +#include class vtkDataReader; diff --git a/lib/cpPlugins/Plugins/MeshWriter.cxx b/lib/cpPlugins/Plugins/MeshWriter.cxx index beaee04..5b06347 100644 --- a/lib/cpPlugins/Plugins/MeshWriter.cxx +++ b/lib/cpPlugins/Plugins/MeshWriter.cxx @@ -1,4 +1,5 @@ #include +#include #include #include @@ -31,10 +32,11 @@ cpPlugins::Plugins::MeshWriter:: std::string cpPlugins::Plugins::MeshWriter:: _GenerateData( ) { - vtkPolyData* i = - dynamic_cast< vtkPolyData* >( - this->m_Inputs[ 0 ]->GetVTKDataObject( ) - ); + cpPlugins::Interface::Mesh* mesh = + this->_Input< cpPlugins::Interface::Mesh >( 0 ); + if( mesh == NULL ) + return( "MeshWriter: No input mesh." ); + vtkPolyData* i = mesh->GetVTKMesh( ); if( i == NULL ) return( "MeshWriter: No suitable input." ); std::string fname = this->m_Parameters.GetValueAsString( "FileName" ); diff --git a/lib/cpPlugins/Plugins/MeshWriter.h b/lib/cpPlugins/Plugins/MeshWriter.h index b626209..d1fc2cc 100644 --- a/lib/cpPlugins/Plugins/MeshWriter.h +++ b/lib/cpPlugins/Plugins/MeshWriter.h @@ -1,8 +1,8 @@ #ifndef __CPPLUGINS__PLUGINS__MESHWRITER__H__ #define __CPPLUGINS__PLUGINS__MESHWRITER__H__ -#include -#include +#include +#include class vtkDataWriter; diff --git a/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.cxx index 7988bca..a23bc12 100644 --- a/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.cxx +++ b/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.cxx @@ -48,25 +48,30 @@ cpPlugins::Plugins::OtsuThresholdImageFilter:: std::string cpPlugins::Plugins::OtsuThresholdImageFilter:: _GenerateData( ) { - itk::DataObject* i = this->m_Inputs[ 0 ]->GetITKDataObject( ); - return( this->_DemangleImageDimension( i ) ); -} + cpPlugins::Interface::Image* image = + this->_Input< cpPlugins::Interface::Image >( 0 ); + if( image == NULL ) + return( "OtsuThresholdImageFilter: No input image." ); -// ------------------------------------------------------------------------- -namespace cpPlugins -{ - namespace Plugins - { - cpPlugins_Image_Demangle_Methods_Code_Only_Scalars( - OtsuThresholdImageFilter, _DemangleInput - ); - } + 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 + ); + else r = "OtsuThresholdImageFilter: Input image type not supported."; + return( r ); } // ------------------------------------------------------------------------- template< class I > std::string cpPlugins::Plugins::OtsuThresholdImageFilter:: -_DemangleInput( itk::DataObject* image ) +_DemangleOutput( itk::DataObject* image ) { return( this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >( @@ -77,16 +82,19 @@ _DemangleInput( itk::DataObject* image ) // ------------------------------------------------------------------------- template< class I, class O > -std::string cpPlugins::Plugins::OtsuThresholdImageFilter:: +inline std::string cpPlugins::Plugins::OtsuThresholdImageFilter:: _RealGD( itk::DataObject* image ) { typedef itk::OtsuThresholdImageFilter< I, O > _F; typedef typename O::PixelType _OP; - unsigned int bins = this->m_Parameters.GetValueAsUint( "NumberOfHistogramBins" ); - _OP in = _OP( this->m_Parameters.GetValueAsReal( "InsideValue" ) ); - _OP out = _OP( this->m_Parameters.GetValueAsReal( "OutsideValue" ) ); + // Get parameters + unsigned int bins = + this->m_Parameters.GetValueAsUint( "NumberOfHistogramBins" ); + _OP in_val = _OP( this->m_Parameters.GetValueAsReal( "InsideValue" ) ); + _OP out_val = _OP( this->m_Parameters.GetValueAsReal( "OutsideValue" ) ); + // Configure filter _F* filter = dynamic_cast< _F* >( this->m_RealProcessObject.GetPointer( ) ); if( filter == NULL ) { @@ -96,12 +104,69 @@ _RealGD( itk::DataObject* image ) } // fi filter->SetInput( dynamic_cast< I* >( image ) ); filter->SetNumberOfHistogramBins( bins ); - filter->SetInsideValue( in ); - filter->SetOutsideValue( out ); + filter->SetInsideValue( in_val ); + filter->SetOutsideValue( out_val ); filter->Update( ); - this->m_Outputs[ 0 ]->SetITKDataObject( filter->GetOutput( ) ); - - return( "" ); + + // Connect output + cpPlugins::Interface::Image* out = + this->_Output< cpPlugins::Interface::Image >( 0 ); + if( out != NULL ) + { + out->SetITKImage< O >( filter->GetOutput( ) ); + return( "" ); + } + else + return( "OtsuThresholdImageFilter: output not correctly created." ); } +// ------------------------------------------------------------------------- +/* TODO + namespace cpPlugins + { + namespace Plugins + { + cpPlugins_Image_Demangle_Methods_Code_Only_Scalars( + OtsuThresholdImageFilter, _DemangleInput + ); + } + } + + // ------------------------------------------------------------------------- + template< class I > + std::string cpPlugins::Plugins::OtsuThresholdImageFilter:: + _DemangleInput( itk::DataObject* image ) + { + } + + // ------------------------------------------------------------------------- + template< class I, class O > + std::string cpPlugins::Plugins::OtsuThresholdImageFilter:: + _RealGD( itk::DataObject* image ) + { + typedef itk::OtsuThresholdImageFilter< I, O > _F; + typedef typename O::PixelType _OP; + + unsigned int bins = this->m_Parameters.GetValueAsUint( "NumberOfHistogramBins" ); + _OP in = _OP( this->m_Parameters.GetValueAsReal( "InsideValue" ) ); + _OP out = _OP( this->m_Parameters.GetValueAsReal( "OutsideValue" ) ); + + _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 + filter->SetInput( dynamic_cast< I* >( image ) ); + filter->SetNumberOfHistogramBins( bins ); + filter->SetInsideValue( in ); + filter->SetOutsideValue( out ); + filter->Update( ); + this->m_Outputs[ 0 ]->SetITKDataObject( filter->GetOutput( ) ); + + return( "" ); + } +*/ + // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.h b/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.h index da26fd0..3d35287 100644 --- a/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.h +++ b/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.h @@ -1,8 +1,8 @@ #ifndef __CPPLUGINS__PLUGINS__OTSUTHRESHOLDIMAGEFILTER__H__ #define __CPPLUGINS__PLUGINS__OTSUTHRESHOLDIMAGEFILTER__H__ -#include -#include +#include +#include namespace cpPlugins { @@ -29,13 +29,11 @@ namespace cpPlugins virtual std::string _GenerateData( ); - cpPlugins_Image_Demangle_Methods( OtsuThresholdImageFilter ); - template< class I > - std::string _DemangleInput( itk::DataObject* image ); + inline std::string _DemangleOutput( itk::DataObject* image ); template< class I, class O > - std::string _RealGD( itk::DataObject* image ); + inline std::string _RealGD( itk::DataObject* image ); private: // Purposely not implemented -- 2.47.1