From 7e29f3aec097ba1bff1894fed6eb1094276c5b72 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Fri, 12 Feb 2016 18:03:46 -0500 Subject: [PATCH] ... --- lib/cpPlugins/Interface/Image.cxx | 13 +- lib/cpPlugins/Interface/Image.h | 19 +- lib/cpPlugins/Interface/Image.hxx | 190 ++++++++---------- lib/cpPlugins/Interface/ImplicitFunction.cxx | 8 - lib/cpPlugins/Interface/ImplicitFunction.h | 2 - lib/cpPlugins/Interface/Mesh.cxx | 19 +- lib/cpPlugins/Interface/Mesh.h | 9 +- lib/cpPlugins/Interface/Mesh.hxx | 49 +++-- .../Interface/PolyLineParametricPath.cxx | 6 - .../Interface/PolyLineParametricPath.h | 10 +- .../Interface/PolyLineParametricPath.hxx | 17 +- lib/cpPlugins/Interface/ProcessObject.cxx | 26 ++- lib/cpPlugins/Interface/ProcessObject.h | 5 +- .../BasicFilters/AppendMeshesFilter.cxx | 6 +- .../BasicFilters/BinaryErodeImageFilter.cxx | 5 +- .../Plugins/IO/DicomSeriesReader.cxx | 8 +- lib/cpPlugins/Plugins/IO/ImageReader.cxx | 11 +- lib/cpPlugins/Plugins/IO/ImageWriter.cxx | 15 +- lib/cpPlugins/Plugins/IO/MeshReader.cxx | 4 + lib/cpPlugins/Plugins/IO/MeshWriter.cxx | 4 +- lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx | 33 +-- 21 files changed, 200 insertions(+), 259 deletions(-) diff --git a/lib/cpPlugins/Interface/Image.cxx b/lib/cpPlugins/Interface/Image.cxx index 48b9074..44deb4e 100644 --- a/lib/cpPlugins/Interface/Image.cxx +++ b/lib/cpPlugins/Interface/Image.cxx @@ -2,9 +2,18 @@ // ------------------------------------------------------------------------- void cpPlugins::Interface::Image:: -SetVTK( vtkObject* image ) +SetITK( itk::LightObject* o ) { - // this->m_VTKObject = image; + this->Superclass::SetITK( o ); + this->_ITK_2_VTK_0< 2 >( o ); + this->_ITK_2_VTK_0< 3 >( o ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::Interface::Image:: +SetVTK( vtkObjectBase* o ) +{ + this->Superclass::SetVTK( o ); std::cerr << "Image: TODO this!!!!" << std::endl; std::exit( 1 ); } diff --git a/lib/cpPlugins/Interface/Image.h b/lib/cpPlugins/Interface/Image.h index 729acdf..45b47fa 100644 --- a/lib/cpPlugins/Interface/Image.h +++ b/lib/cpPlugins/Interface/Image.h @@ -5,9 +5,6 @@ #include -// Some forward declarations -class vtkObject; - namespace cpPlugins { namespace Interface @@ -29,17 +26,21 @@ namespace cpPlugins cpPlugins_Id_Macro( Image, DataObject ); public: - template< class I > - inline void SetITK( itk::Object* object ); - - virtual void SetVTK( vtkObject* image ); + virtual void SetITK( itk::LightObject* o ); + virtual void SetVTK( vtkObjectBase* o ); protected: Image( ); virtual ~Image( ); + template< unsigned int D > + inline void _ITK_2_VTK_0( itk::LightObject* o ); + template< class P, unsigned int D > - inline void _ITK_2_VTK( itk::Object* object ); + inline void _ITK_2_VTK_1( itk::LightObject* o ); + + template< class I > + inline void _ITK_2_VTK_2( itk::LightObject* o ); private: // Purposely not implemented @@ -47,7 +48,7 @@ namespace cpPlugins Self& operator=( const Self& ); protected: - itk::ProcessObject::Pointer m_ITKvVTKConnection; + itk::ProcessObject::Pointer m_ITKvVTK; }; } // ecapseman diff --git a/lib/cpPlugins/Interface/Image.hxx b/lib/cpPlugins/Interface/Image.hxx index ab2c5ea..1bb8b77 100644 --- a/lib/cpPlugins/Interface/Image.hxx +++ b/lib/cpPlugins/Interface/Image.hxx @@ -16,129 +16,109 @@ #include // ------------------------------------------------------------------------- -#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_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_VTKImage_Demangle_AllDims( TI, T, o ) \ - cpPlugins_VTKImage_Demangle( TI, T, 2, o ); \ - else cpPlugins_VTKImage_Demangle( TI, T, 3, o ) - -// ------------------------------------------------------------------------- -#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 > +template< unsigned int D > void cpPlugins::Interface::Image:: -SetITK( itk::Object* object ) +_ITK_2_VTK_0( itk::LightObject* o ) { - // Check if input object has the desired type - I* image = dynamic_cast< I* >( object ); - if( image == NULL ) + if( dynamic_cast< itk::ImageBase< D >* >( o ) != NULL ) + { + this->_ITK_2_VTK_1< char, D >( o ); + this->_ITK_2_VTK_1< short, D >( o ); + this->_ITK_2_VTK_1< int, D >( o ); + this->_ITK_2_VTK_1< long, D >( o ); + this->_ITK_2_VTK_1< unsigned char, D >( o ); + this->_ITK_2_VTK_1< unsigned short, D >( o ); + this->_ITK_2_VTK_1< unsigned int, D >( o ); + this->_ITK_2_VTK_1< unsigned long, D >( o ); + this->_ITK_2_VTK_1< float, D >( o ); + this->_ITK_2_VTK_1< double, D >( o ); + this->_ITK_2_VTK_1< itk::RGBPixel< char >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBPixel< short >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBPixel< int >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBPixel< long >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBPixel< unsigned char >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBPixel< unsigned short >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBPixel< unsigned int >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBPixel< unsigned long >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBPixel< float >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBPixel< double >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBAPixel< char >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBAPixel< short >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBAPixel< int >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBAPixel< long >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBAPixel< unsigned char >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBAPixel< unsigned short >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBAPixel< unsigned int >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBAPixel< unsigned long >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBAPixel< float >, D >( o ); + this->_ITK_2_VTK_1< itk::RGBAPixel< double >, D >( o ); + this->_ITK_2_VTK_1< itk::DiffusionTensor3D< float >, D >( o ); + this->_ITK_2_VTK_1< itk::DiffusionTensor3D< double >, D >( o ); + this->_ITK_2_VTK_1< itk::Vector< float, D >, D >( o ); + this->_ITK_2_VTK_1< itk::Vector< double, D >, D >( o ); + this->_ITK_2_VTK_1< itk::CovariantVector< float, D >, D >( o ); + this->_ITK_2_VTK_1< itk::CovariantVector< double, D >, D >( o ); + this->_ITK_2_VTK_1< itk::Point< float, D >, D >( o ); + this->_ITK_2_VTK_1< itk::Point< double, D >, D >( o ); + this->_ITK_2_VTK_1< itk::SymmetricSecondRankTensor< float, D >, D >( o ); + this->_ITK_2_VTK_1< itk::SymmetricSecondRankTensor< double, D >, D >( o ); + } + else { - this->m_ITKObject = NULL; this->m_VTKObject = NULL; - this->m_ITKvVTKConnection = NULL; + this->m_ITKvVTK = NULL; this->Modified( ); - return; } // fi +} - // --------- TODO --------------- - typename I::DirectionType norm_dir; - norm_dir.SetIdentity( ); - image->SetDirection( norm_dir ); - // --------- TODO --------------- - - // Connect it to VTK - 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 +// ------------------------------------------------------------------------- +template< class P, unsigned int D > +void cpPlugins::Interface::Image:: +_ITK_2_VTK_1( itk::LightObject* o ) +{ + if( dynamic_cast< itk::Image< P, D >* >( o ) == NULL ) { this->m_VTKObject = NULL; - this->m_ITKvVTKConnection = NULL; - - } // fi - - // Keep objects - this->m_ITKObject = object; - this->Modified( ); + this->m_ITKvVTK = NULL; + this->Modified( ); + } + else + this->_ITK_2_VTK_2< itk::Image< P, D > >( o ); } // ------------------------------------------------------------------------- -template< class P, unsigned int D > +template< class I > void cpPlugins::Interface::Image:: -_ITK_2_VTK( itk::Object* object ) +_ITK_2_VTK_2( itk::LightObject* o ) { - typedef itk::Image< P, D > _I; - typedef itk::ImageToVTKImageFilter< _I > _I2Vtk; - - // Check (yes, again!!!) if input object has the desired type - _I* image = dynamic_cast< _I* >( object ); - if( image == NULL ) - return; - - // Connect it to VTK - _I2Vtk* f = - dynamic_cast< _I2Vtk* >( this->m_ITKvVTKConnection.GetPointer( ) ); - if( f == NULL ) + typedef itk::ImageToVTKImageFilter< I > _I2V; + + I* image = dynamic_cast< I* >( o ); + if( image != NULL ) + { + _I2V* f = dynamic_cast< _I2V* >( this->m_ITKvVTK.GetPointer( ) ); + if( f == NULL ) + { + typename _I2V::Pointer nf = _I2V::New( ); + this->m_ITKvVTK = nf; + f = nf.GetPointer( ); + + } // fi + f->SetInput( image ); + f->Update( ); + + // Keep object track + this->m_ITKObject = o; + this->m_VTKObject = f->GetOutput( ); + } + else { - typename _I2Vtk::Pointer nf = _I2Vtk::New( ); - this->m_ITKvVTKConnection = nf; - f = nf.GetPointer( ); + this->m_VTKObject = NULL; + this->m_ITKvVTK = NULL; } // fi - f->SetInput( image ); - f->Update( ); - - // Keep object track - this->m_VTKObject = f->GetOutput( ); + this->Modified( ); } #ifndef cpPlugins_Interface_EXPORTS diff --git a/lib/cpPlugins/Interface/ImplicitFunction.cxx b/lib/cpPlugins/Interface/ImplicitFunction.cxx index cae117d..5b1a538 100644 --- a/lib/cpPlugins/Interface/ImplicitFunction.cxx +++ b/lib/cpPlugins/Interface/ImplicitFunction.cxx @@ -52,14 +52,6 @@ cpPlugins_Interface_ImplicitFunction_DEF( Quadric ); cpPlugins_Interface_ImplicitFunction_DEF( Sphere ); cpPlugins_Interface_ImplicitFunction_DEF( Superquadric ); -// ------------------------------------------------------------------------- -void cpPlugins::Interface::ImplicitFunction:: -SetFunction( vtkImplicitFunction* function ) -{ - this->m_VTKObject = function; - this->Modified( ); -} - // ------------------------------------------------------------------------- cpPlugins::Interface::ImplicitFunction:: ImplicitFunction( ) diff --git a/lib/cpPlugins/Interface/ImplicitFunction.h b/lib/cpPlugins/Interface/ImplicitFunction.h index a8c8a78..f55a188 100644 --- a/lib/cpPlugins/Interface/ImplicitFunction.h +++ b/lib/cpPlugins/Interface/ImplicitFunction.h @@ -27,8 +27,6 @@ namespace cpPlugins itkTypeMacro( ImplicitFunction, DataObject ); public: - void SetFunction( vtkImplicitFunction* function ); - void SetFunctionToBox( ); void SetFunctionToCone( ); void SetFunctionToCylinder( ); diff --git a/lib/cpPlugins/Interface/Mesh.cxx b/lib/cpPlugins/Interface/Mesh.cxx index d56d192..29a3b49 100644 --- a/lib/cpPlugins/Interface/Mesh.cxx +++ b/lib/cpPlugins/Interface/Mesh.cxx @@ -9,7 +9,22 @@ // ------------------------------------------------------------------------- void cpPlugins::Interface::Mesh:: -SetVTK( vtkObject* object ) +SetITK( itk::LightObject* o ) +{ + this->Superclass::SetITK( o ); + this->_ITK_2_VTK< itk::Mesh< float, 2 > >( o ); + this->_ITK_2_VTK< itk::Mesh< double, 2 > >( o ); + this->_ITK_2_VTK< itk::Mesh< float, 3 > >( o ); + this->_ITK_2_VTK< itk::Mesh< double, 3 > >( o ); + this->_ITK_2_VTK< itk::QuadEdgeMesh< float, 2 > >( o ); + this->_ITK_2_VTK< itk::QuadEdgeMesh< double, 2 > >( o ); + this->_ITK_2_VTK< itk::QuadEdgeMesh< float, 3 > >( o ); + this->_ITK_2_VTK< itk::QuadEdgeMesh< double, 3 > >( o ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::Interface::Mesh:: +SetVTK( vtkObjectBase* o ) { typedef itk::Mesh< double, 3 > _TMesh; typedef _TMesh::CellType _TCell; @@ -18,7 +33,7 @@ SetVTK( vtkObject* object ) typedef itk::TriangleCell< _TCell > _TTriangle; typedef itk::PolygonCell< _TCell > _TPolygon; - vtkPolyData* mesh = dynamic_cast< vtkPolyData* >( object ); + vtkPolyData* mesh = dynamic_cast< vtkPolyData* >( o ); if( mesh == NULL ) { this->m_ITKObject = NULL; diff --git a/lib/cpPlugins/Interface/Mesh.h b/lib/cpPlugins/Interface/Mesh.h index d1aa65e..4d1f8fd 100644 --- a/lib/cpPlugins/Interface/Mesh.h +++ b/lib/cpPlugins/Interface/Mesh.h @@ -27,15 +27,16 @@ namespace cpPlugins cpPlugins_Id_Macro( Mesh, DataObject ); public: - template< class M > - inline void SetITK( M* mesh ); - - virtual void SetVTK( vtkObject* object ); + virtual void SetITK( itk::LightObject* o ); + virtual void SetVTK( vtkObjectBase* o ); protected: Mesh( ); virtual ~Mesh( ); + template< class M > + inline void _ITK_2_VTK( itk::LightObject* o ); + private: // Purposely not implemented Mesh( const Self& ); diff --git a/lib/cpPlugins/Interface/Mesh.hxx b/lib/cpPlugins/Interface/Mesh.hxx index 5c5e562..16504f0 100644 --- a/lib/cpPlugins/Interface/Mesh.hxx +++ b/lib/cpPlugins/Interface/Mesh.hxx @@ -11,37 +11,15 @@ #include #include -// ------------------------------------------------------------------------- -#define cpPlugins_Mesh_Import( N, T, D ) \ - cpPlugins_TEMPLATE_IMPORT( \ - 2(class cpPlugins_Interface_EXPORT itk::N< T, D >) \ - ) - -// ------------------------------------------------------------------------- - -#ifndef cpPlugins_Interface_EXPORTS - -cpPlugins_Mesh_Import( Mesh, float, 2 ); -cpPlugins_Mesh_Import( Mesh, double, 2 ); -cpPlugins_Mesh_Import( Mesh, float, 3 ); -cpPlugins_Mesh_Import( Mesh, double, 3 ); -cpPlugins_Mesh_Import( QuadEdgeMesh, float, 2 ); -cpPlugins_Mesh_Import( QuadEdgeMesh, double, 2 ); -cpPlugins_Mesh_Import( QuadEdgeMesh, float, 3 ); -cpPlugins_Mesh_Import( QuadEdgeMesh, double, 3 ); - -#endif // cpPlugins_Interface_EXPORTS - // ------------------------------------------------------------------------- template< class M > void cpPlugins::Interface::Mesh:: -SetITK( M* mesh ) +_ITK_2_VTK( itk::LightObject* o ) { - if( this->m_ITKObject.GetPointer( ) == mesh ) + M* mesh = dynamic_cast< M* >( o ); + if( mesh == NULL ) return; - this->m_ITKObject = mesh; - long numPoints = mesh->GetNumberOfPoints( ); if( numPoints == 0 ) return; @@ -92,6 +70,27 @@ SetITK( M* mesh ) this->Modified( ); } +// ------------------------------------------------------------------------- +#define cpPlugins_Mesh_Import( N, T, D ) \ + cpPlugins_TEMPLATE_IMPORT( \ + 2(class cpPlugins_Interface_EXPORT itk::N< T, D >) \ + ) + +// ------------------------------------------------------------------------- + +#ifndef cpPlugins_Interface_EXPORTS + +cpPlugins_Mesh_Import( Mesh, float, 2 ); +cpPlugins_Mesh_Import( Mesh, double, 2 ); +cpPlugins_Mesh_Import( Mesh, float, 3 ); +cpPlugins_Mesh_Import( Mesh, double, 3 ); +cpPlugins_Mesh_Import( QuadEdgeMesh, float, 2 ); +cpPlugins_Mesh_Import( QuadEdgeMesh, double, 2 ); +cpPlugins_Mesh_Import( QuadEdgeMesh, float, 3 ); +cpPlugins_Mesh_Import( QuadEdgeMesh, double, 3 ); + +#endif // cpPlugins_Interface_EXPORTS + #endif // __CPPLUGINS__INTERFACE__MESH__HXX__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/PolyLineParametricPath.cxx b/lib/cpPlugins/Interface/PolyLineParametricPath.cxx index be18d99..9f4bdde 100644 --- a/lib/cpPlugins/Interface/PolyLineParametricPath.cxx +++ b/lib/cpPlugins/Interface/PolyLineParametricPath.cxx @@ -1,11 +1,5 @@ #include -// ------------------------------------------------------------------------- -void cpPlugins::Interface::PolyLineParametricPath:: -SetVTK( vtkObject* path ) -{ -} - // ------------------------------------------------------------------------- cpPlugins::Interface::PolyLineParametricPath:: PolyLineParametricPath( ) diff --git a/lib/cpPlugins/Interface/PolyLineParametricPath.h b/lib/cpPlugins/Interface/PolyLineParametricPath.h index 62bde85..47c793d 100644 --- a/lib/cpPlugins/Interface/PolyLineParametricPath.h +++ b/lib/cpPlugins/Interface/PolyLineParametricPath.h @@ -2,9 +2,7 @@ #define __CPPLUGINS__INTERFACE__POLYLINEPARAMETRICPATH__H__ #include - -// Some forward declarations -class vtkObject; +#include namespace cpPlugins { @@ -26,12 +24,6 @@ namespace cpPlugins itkTypeMacro( PolyLineParametricPath, DataObject ); cpPlugins_Id_Macro( PolyLineParametricPath, DataObject ); - public: - template< class P > - inline void SetITK( itk::Object* object ); - - virtual void SetVTK( vtkObject* path ); - protected: PolyLineParametricPath( ); virtual ~PolyLineParametricPath( ); diff --git a/lib/cpPlugins/Interface/PolyLineParametricPath.hxx b/lib/cpPlugins/Interface/PolyLineParametricPath.hxx index 2c6724d..08105eb 100644 --- a/lib/cpPlugins/Interface/PolyLineParametricPath.hxx +++ b/lib/cpPlugins/Interface/PolyLineParametricPath.hxx @@ -1,22 +1,7 @@ #ifndef __CPPLUGINS__INTERFACE__POLYLINEPARAMETRICPATH__HXX__ #define __CPPLUGINS__INTERFACE__POLYLINEPARAMETRICPATH__HXX__ -#include - -// ------------------------------------------------------------------------- -template< class P > -void cpPlugins::Interface::PolyLineParametricPath:: -SetITK( itk::Object* object ) -{ - P* path = dynamic_cast< P* >( object ); - if( path != NULL ) - { - this->m_ITKObject = path; - this->m_VTKObject = NULL; - this->Modified( ); - - } // fi -} +// TODO: erase this file #endif // __CPPLUGINS__INTERFACE__POLYLINEPARAMETRICPATH__HXX__ diff --git a/lib/cpPlugins/Interface/ProcessObject.cxx b/lib/cpPlugins/Interface/ProcessObject.cxx index 809ef35..e2ea0de 100644 --- a/lib/cpPlugins/Interface/ProcessObject.cxx +++ b/lib/cpPlugins/Interface/ProcessObject.cxx @@ -7,6 +7,20 @@ #include #endif // cpPlugins_Interface_QT4 +// ------------------------------------------------------------------------- +void cpPlugins::Interface::ProcessObject:: +SetITK( itk::LightObject* o ) +{ + // Polymorphism: do nothing -> this is a filter!!! +} + +// ------------------------------------------------------------------------- +void cpPlugins::Interface::ProcessObject:: +SetVTK( vtkObjectBase* o ) +{ + // Polymorphism: do nothing -> this is a filter!!! +} + // ------------------------------------------------------------------------- std::set< std::string > cpPlugins::Interface::ProcessObject:: GetInputsNames( ) const @@ -138,7 +152,9 @@ Update( ) bool need_to_update = false; for( ; i != this->m_Inputs.end( ) && r == ""; ++i ) { - if( i->second.IsValid( ) ) + bool iv = i->second.IsValid( ); + bool ir = i->second.IsRequired( ); + if( iv || !ir ) { Self* src = dynamic_cast< Self* >( i->second->GetSource( ) ); if( src != NULL ) @@ -147,8 +163,12 @@ Update( ) r = src->Update( ); } // fi - - } // fi + } + else + r = + "ProcessObject: Required input \"" + + i->first + "@" + this->GetClassName( ) + + "\" is not valid (=NULL)."; } // rof diff --git a/lib/cpPlugins/Interface/ProcessObject.h b/lib/cpPlugins/Interface/ProcessObject.h index 9489c35..e139c99 100644 --- a/lib/cpPlugins/Interface/ProcessObject.h +++ b/lib/cpPlugins/Interface/ProcessObject.h @@ -55,6 +55,9 @@ namespace cpPlugins itkSetObjectMacro( MPRViewer, SimpleMPRWidget ); public: + virtual void SetITK( itk::LightObject* o ); + virtual void SetVTK( vtkObjectBase* o ); + // IO management std::set< std::string > GetInputsNames( ) const; std::set< std::string > GetOutputsNames( ) const; @@ -89,7 +92,7 @@ namespace cpPlugins ProcessObject( ); virtual ~ProcessObject( ); - void _AddInput( const std::string& name, bool required ); + void _AddInput( const std::string& name, bool required = true ); template< class O > inline void _AddOutput( const std::string& name ); template< class F > diff --git a/lib/cpPlugins/Plugins/BasicFilters/AppendMeshesFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/AppendMeshesFilter.cxx index 8ea4154..9cfc8be 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/AppendMeshesFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/AppendMeshesFilter.cxx @@ -8,8 +8,8 @@ cpPlugins::BasicFilters::AppendMeshesFilter:: AppendMeshesFilter( ) : Superclass( ) { - this->_AddInput( "Input0", true ); - this->_AddInput( "Input1", true ); + this->_AddInput( "Input0" ); + this->_AddInput( "Input1" ); this->_AddOutput< cpPlugins::Interface::Mesh >( "Output" ); } @@ -25,8 +25,6 @@ _GenerateData( ) { auto m0 = this->GetInputData< cpPlugins::Interface::Mesh >( "Input0" ); auto m1 = this->GetInputData< cpPlugins::Interface::Mesh >( "Input1" ); - if( m0 == NULL || m1 == NULL ) - return( "AppendMeshesFilter: No input meshes." ); auto filter = this->_CreateVTK< vtkAppendPolyData >( ); filter->AddInputData( m0->GetVTK< vtkPolyData >( ) ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx index 91402f5..0168f77 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx @@ -10,7 +10,7 @@ cpPlugins::BasicFilters::BinaryErodeImageFilter:: BinaryErodeImageFilter( ) : Superclass( ) { - this->_AddInput( "Input", true ); + this->_AddInput( "Input" ); this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); this->m_Parameters->ConfigureAsUint( "Radius" ); @@ -28,9 +28,6 @@ std::string cpPlugins::BasicFilters::BinaryErodeImageFilter:: _GenerateData( ) { auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" ); - if( image == NULL ) - return( "BinaryErodeImageFilter: No input image." ); - itk::DataObject* itk_image = NULL; std::string r = ""; cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 ); diff --git a/lib/cpPlugins/Plugins/IO/DicomSeriesReader.cxx b/lib/cpPlugins/Plugins/IO/DicomSeriesReader.cxx index 4136bb1..4710e59 100644 --- a/lib/cpPlugins/Plugins/IO/DicomSeriesReader.cxx +++ b/lib/cpPlugins/Plugins/IO/DicomSeriesReader.cxx @@ -24,8 +24,6 @@ class cpPlugins_IO_DicomSeriesReader_ParametersQtDialog : public cpPlugins::Interface::ParametersQtDialog { - // Q_OBJECT; - public: cpPlugins_IO_DicomSeriesReader_ParametersQtDialog( QWidget* parent = 0, Qt::WindowFlags f = 0 @@ -61,8 +59,10 @@ protected: QDialog* tree_dialog = new QDialog( parent ); QTreeWidget* tree_widget = new QTreeWidget( tree_dialog ); QList< QTreeWidgetItem* > tree_items; - std::map< std::string, std::map< std::string, std::vector< std::string > > > - found_files; + std::map< + std::string, + std::map< std::string, std::vector< std::string > > + > found_files; std::string main_dir_name = dialog.selectedFiles( ).begin( )->toStdString( ); diff --git a/lib/cpPlugins/Plugins/IO/ImageReader.cxx b/lib/cpPlugins/Plugins/IO/ImageReader.cxx index 66231c4..900940b 100644 --- a/lib/cpPlugins/Plugins/IO/ImageReader.cxx +++ b/lib/cpPlugins/Plugins/IO/ImageReader.cxx @@ -318,9 +318,6 @@ std::string cpPlugins::IO::ImageReader:: _RealGD( const TStringList& names ) { auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" ); - if( out == NULL ) - return( "ImageReader: No output object properly created." ); - std::string r = ""; if( names.size( ) == 1 ) { @@ -331,12 +328,12 @@ _RealGD( const TStringList& names ) try { reader->Update( ); - out->SetITK< I >( reader->GetOutput( ) ); + out->SetITK( reader->GetOutput( ) ); } catch( itk::ExceptionObject& err ) { r = "ImageReader: " + std::string( err.GetDescription( ) ); - out->SetITK< I >( NULL ); + out->SetITK( NULL ); } // yrt } @@ -350,12 +347,12 @@ _RealGD( const TStringList& names ) try { reader->Update( ); - out->SetITK< I >( reader->GetOutput( ) ); + out->SetITK( reader->GetOutput( ) ); } catch( itk::ExceptionObject& err ) { r = "ImageReader: " + std::string( err.GetDescription( ) ); - out->SetITK< I >( NULL ); + out->SetITK( NULL ); } // yrt } diff --git a/lib/cpPlugins/Plugins/IO/ImageWriter.cxx b/lib/cpPlugins/Plugins/IO/ImageWriter.cxx index 29334e1..234c916 100644 --- a/lib/cpPlugins/Plugins/IO/ImageWriter.cxx +++ b/lib/cpPlugins/Plugins/IO/ImageWriter.cxx @@ -8,7 +8,7 @@ cpPlugins::IO::ImageWriter:: ImageWriter( ) : Superclass( ) { - this->_AddInput( "Input", true ); + this->_AddInput( "Input" ); this->m_Parameters->ConfigureAsSaveFileName( "FileName" ); this->m_Parameters->SetAcceptedFileExtensions( "FileName", @@ -42,14 +42,10 @@ std::string cpPlugins::IO::ImageWriter:: _GD0_Image( ) { auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" ); - if( image == NULL ) - return( "ImageWriter: No input image." ); - itk::DataObject* itk_image = NULL; std::string r = ""; cpPlugins_Image_Demangle_AllTypes( D, image, itk_image, r, _RealGD ); else r = "ImageWriter: Input image type not supported."; - return( r ); } @@ -59,14 +55,10 @@ std::string cpPlugins::IO::ImageWriter:: _GD0_VectorImage( ) { auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" ); - if( image == NULL ) - return( "ImageWriter: No input image." ); - itk::DataObject* itk_image = NULL; std::string r = ""; cpPlugins_VectorImage_Demangle_AllTypes( D, image, itk_image, r, _RealGD ); else r = "ImageWriter: Input image type not supported."; - return( r ); } @@ -75,12 +67,9 @@ template< class I > std::string cpPlugins::IO::ImageWriter:: _RealGD( itk::DataObject* image ) { - // Get filename - std::string fname = this->m_Parameters->GetSaveFileName( "FileName" ); - typedef itk::ImageFileWriter< I > _W; _W* writer = this->_CreateITK< _W >( ); - writer->SetFileName( fname ); + writer->SetFileName( this->m_Parameters->GetSaveFileName( "FileName" ) ); writer->SetInput( dynamic_cast< I* >( image ) ); try { diff --git a/lib/cpPlugins/Plugins/IO/MeshReader.cxx b/lib/cpPlugins/Plugins/IO/MeshReader.cxx index 8dce561..c820c68 100644 --- a/lib/cpPlugins/Plugins/IO/MeshReader.cxx +++ b/lib/cpPlugins/Plugins/IO/MeshReader.cxx @@ -91,6 +91,10 @@ _GD1( ) return( "MeshReader: output not correctly created." ); return( "" ); } + else if( ext == "obj" ) + { + // TODO + } else if( ext == "vtk" ) { vtkPolyDataReader* pdr = this->_CreateVTK< vtkPolyDataReader >( ); diff --git a/lib/cpPlugins/Plugins/IO/MeshWriter.cxx b/lib/cpPlugins/Plugins/IO/MeshWriter.cxx index 46f9833..ac20473 100644 --- a/lib/cpPlugins/Plugins/IO/MeshWriter.cxx +++ b/lib/cpPlugins/Plugins/IO/MeshWriter.cxx @@ -10,7 +10,7 @@ cpPlugins::IO::MeshWriter:: MeshWriter( ) : Superclass( ) { - this->_AddInput( "Input", true ); + this->_AddInput( "Input" ); this->m_Parameters->ConfigureAsSaveFileName( "FileName" ); this->m_Parameters->SetAcceptedFileExtensions( "FileName", @@ -29,8 +29,6 @@ std::string cpPlugins::IO::MeshWriter:: _GenerateData( ) { auto mesh = this->GetInputData< cpPlugins::Interface::Mesh >( "Input" ); - if( mesh == NULL ) - return( "MeshWriter: No input mesh." ); vtkPolyData* i = mesh->GetVTK< vtkPolyData >( ); if( i == NULL ) return( "MeshWriter: No suitable input." ); diff --git a/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx b/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx index 383b4a2..ee8a59d 100644 --- a/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx +++ b/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx @@ -13,7 +13,7 @@ SeedWidget( ) : Superclass( ), m_Configured( false ) { - this->_AddInput( "ReferenceImage", true ); + this->_AddInput( "ReferenceImage" ); this->_AddOutput< cpPlugins::Interface::PointList >( "Output" ); this->m_Parameters->ConfigureAsBool( "SeedsAreInRealSpace" ); @@ -35,9 +35,6 @@ _GenerateData( ) auto image = this->GetInputData< cpPlugins::Interface::Image >( "ReferenceImage" ); - if( image == NULL ) - return( "SeedWidget: No input image." ); - itk::DataObject* itk_image = image->GetITK< _2DImage >( ); if( itk_image != NULL ) return( this->_GD0< _2DImage >( itk_image ) ); @@ -48,7 +45,6 @@ _GenerateData( ) return( this->_GD0< _3DImage >( itk_image ) ); } // fi - return( "SeedWidget: Input image dimension not supported." ); } @@ -119,33 +115,6 @@ _GD0( itk::DataObject* image ) s->SeedWidgetOn( ); } // fi - - /* TODO - auto iIt = this->m_Interactors.begin( ); - for( ; iIt != this->m_Interactors.end( ); ++iIt ) - { - _S* s = dynamic_cast< _S* >( ( *iIt )->GetInteractorStyle( ) ); - if( s != NULL ) - { - if( this->m_Configured ) - { - for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i ) - { - s->GetSeedAsPoint( i, aux_pnt ); - typename I::PointType seed; - for( unsigned int d = 0; d < dim; ++d ) - seed[ d ] = aux_pnt[ d ]; - out->AddPoint( seed ); - - } // rof - } - else - s->SeedWidgetOn( ); - - } // fi - - } // rof - */ this->m_Configured = true; return( "" ); } -- 2.47.1