]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 12 Feb 2016 23:03:46 +0000 (18:03 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 12 Feb 2016 23:03:46 +0000 (18:03 -0500)
21 files changed:
lib/cpPlugins/Interface/Image.cxx
lib/cpPlugins/Interface/Image.h
lib/cpPlugins/Interface/Image.hxx
lib/cpPlugins/Interface/ImplicitFunction.cxx
lib/cpPlugins/Interface/ImplicitFunction.h
lib/cpPlugins/Interface/Mesh.cxx
lib/cpPlugins/Interface/Mesh.h
lib/cpPlugins/Interface/Mesh.hxx
lib/cpPlugins/Interface/PolyLineParametricPath.cxx
lib/cpPlugins/Interface/PolyLineParametricPath.h
lib/cpPlugins/Interface/PolyLineParametricPath.hxx
lib/cpPlugins/Interface/ProcessObject.cxx
lib/cpPlugins/Interface/ProcessObject.h
lib/cpPlugins/Plugins/BasicFilters/AppendMeshesFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx
lib/cpPlugins/Plugins/IO/DicomSeriesReader.cxx
lib/cpPlugins/Plugins/IO/ImageReader.cxx
lib/cpPlugins/Plugins/IO/ImageWriter.cxx
lib/cpPlugins/Plugins/IO/MeshReader.cxx
lib/cpPlugins/Plugins/IO/MeshWriter.cxx
lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx

index 48b90740a68b7a0e6753c344ed32ee2528ac44b9..44deb4e4e9eb9b478536790ff208a96d0407936b 100644 (file)
@@ -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 );
 }
index 729acdf682aaaa382d4e50db41ab40dadda85666..45b47faf37175195f59d7249eafa4b2721c70464 100644 (file)
@@ -5,9 +5,6 @@
 
 #include <itkProcessObject.h>
 
-// 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
index ab2c5ea00c9b6399ce0afa635dd1bba997b50805..1bb8b77be545eb3c5af9add91d94aab9cb6db618 100644 (file)
 #include <itkVector.h>
 
 // -------------------------------------------------------------------------
-#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
index cae117db7938bd1ca795752b70d3f2791a08ea9a..5b1a5388dd9f5aef91d4764a3e538c4d277651e8 100644 (file)
@@ -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( )
index a8c8a7841de14bc876e5ef254820efd6a610a86c..f55a18812728f377fbeab3b9cb5c6c08c9f064f2 100644 (file)
@@ -27,8 +27,6 @@ namespace cpPlugins
       itkTypeMacro( ImplicitFunction, DataObject );
 
     public:
-      void SetFunction( vtkImplicitFunction* function );
-
       void SetFunctionToBox( );
       void SetFunctionToCone( );
       void SetFunctionToCylinder( );
index d56d1929aebeb81719640b70f20d80460975c775..29a3b499ec1eefd790e7d352cbcced5e8a54eb38 100644 (file)
@@ -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;
index d1aa65e54a141bf13e5b7351fa1df15c2b281036..4d1f8fd3494a0146cb1b92398a578d66d373c5ce 100644 (file)
@@ -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& );
index 5c5e5626c5b8690d3a502267b69a377f8ee3862d..16504f095a31d9ea9ee3be828fbbf9c907a73fec 100644 (file)
 #include <vtkPoints.h>
 #include <vtkPolyData.h>
 
-// -------------------------------------------------------------------------
-#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$
index be18d995188c680a4ec4f2745959ae37abac0334..9f4bdde4d50d8a488123c995114b4152baee4ef8 100644 (file)
@@ -1,11 +1,5 @@
 #include <cpPlugins/Interface/PolyLineParametricPath.h>
 
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::PolyLineParametricPath::
-SetVTK( vtkObject* path )
-{
-}
-
 // -------------------------------------------------------------------------
 cpPlugins::Interface::PolyLineParametricPath::
 PolyLineParametricPath( )
index 62bde85050df8500e1c2b729ed7f6768fe3f0187..47c793d2b9e16919119d11205d213cc93de9d0db 100644 (file)
@@ -2,9 +2,7 @@
 #define __CPPLUGINS__INTERFACE__POLYLINEPARAMETRICPATH__H__
 
 #include <cpPlugins/Interface/DataObject.h>
-
-// Some forward declarations
-class vtkObject;
+#include <itkPolyLineParametricPath.h>
 
 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( );
index 2c6724dd634f1f2d65a484fd7fc86a8bf8c8010b..08105eb61f5ec4638efb7294b4f59bd600afbee7 100644 (file)
@@ -1,22 +1,7 @@
 #ifndef __CPPLUGINS__INTERFACE__POLYLINEPARAMETRICPATH__HXX__
 #define __CPPLUGINS__INTERFACE__POLYLINEPARAMETRICPATH__HXX__
 
-#include <itkPolyLineParametricPath.h>
-
-// -------------------------------------------------------------------------
-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__
 
index 809ef35c5dd91584beb59021dda536ea047ed088..e2ea0de61e79640917d122c376c24a2eed027b2f 100644 (file)
@@ -7,6 +7,20 @@
 #include <cpPlugins/Interface/SimpleMPRWidget.h>
 #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
 
index 9489c35b6c8da1bb2f950df183b2dd4efdaf9845..e139c994d5e86f9107963ae6acea31fcd626d564 100644 (file)
@@ -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 >
index 8ea415453b735ac0ea1845e80c7f8be15f68069b..9cfc8bed6505def49b5ce0316d09830b4d882626 100644 (file)
@@ -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 >( ) );
index 91402f5b4b1595a8e850a2b7b775c2ee10867a08..0168f77c6882a241a200946a6d214cbf9b41e45f 100644 (file)
@@ -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 );
index 4136bb1377c3ce97e97af231b76d420609a7728b..4710e59a3905ca257a7e1b472464afffb9f02577 100644 (file)
@@ -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( );
index 66231c451e73042f85399dbcc6e714cc6fada814..900940bfcaf97c7a9d0e22149e1a56065d55b700 100644 (file)
@@ -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
   }
index 29334e148a6b96caadc683bbfce9a70ca7cea591..234c916f99f5955407294607dc9edd948ebc1eeb 100644 (file)
@@ -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
   {
index 8dce5610aa72221d108b4f991b8b6767227c18dc..c820c68a9620fdca76405c5c260c81aa544fa9a7 100644 (file)
@@ -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 >( );
index 46f983309100d80414c2a93eda2d348031c43ea2..ac20473985e79ed484a45924ef30c9d515bffc86 100644 (file)
@@ -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." );
index 383b4a202804249da69d0187b3caf6729938a3b6..ee8a59dfe3062d763e09ac186fe6164295af5c29 100644 (file)
@@ -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( "" );
 }