]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 18 Feb 2016 04:23:19 +0000 (23:23 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 18 Feb 2016 04:23:19 +0000 (23:23 -0500)
30 files changed:
appli/cpPipelineEditor/App_cpPipelineEditor.cxx
lib/cpExtensions/DataStructures/VectorValuesContainer.h [new file with mode: 0644]
lib/cpPlugins/Interface/PointList.cxx
lib/cpPlugins/Interface/PointList.h
lib/cpPlugins/Interface/PointList.hxx
lib/cpPlugins/Interface/Workspace.cxx
lib/cpPlugins/Interface/Workspace.h
lib/cpPlugins/Plugins/BasicFilters/AppendMeshesFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx
lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/ImageInterpolatorSource.cxx
lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.h
lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx
lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/MultiplyImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/SignedMaurerDistanceMapImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx
lib/cpPlugins/Plugins/BasicFilters/TriangleMeshToBinaryImageFilter.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
lib/cpPlugins/Plugins/Widgets/SeedWidget.h

index df947d5443593d5d0ab772602c7d491a448f4275..af73df5f21c95b66ef258eb01a51a44d5663abad 100644 (file)
@@ -309,7 +309,7 @@ _ShowFilterOutput(
   auto filter = this->m_Workspace->GetFilter( filter_name );
   if( filter != NULL )
   {
-    auto output = filter->GetOutputData< _TDataObject >( output_name );
+    auto output = filter->GetOutputData( output_name );
     if( output != NULL )
     {
       std::string data_name = output_name + "@" + filter_name;
diff --git a/lib/cpExtensions/DataStructures/VectorValuesContainer.h b/lib/cpExtensions/DataStructures/VectorValuesContainer.h
new file mode 100644 (file)
index 0000000..eea4e40
--- /dev/null
@@ -0,0 +1,66 @@
+#ifndef __CPEXTENSIONS__DATASTRUCTURES__VECTORVALUESCONTAINER__H__
+#define __CPEXTENSIONS__DATASTRUCTURES__VECTORVALUESCONTAINER__H__
+
+#include <vector>
+#include <itkSimpleDataObjectDecorator.h>
+#include <itkSmartPointer.h>
+
+namespace cpExtensions
+{
+  namespace DataStructures
+  {
+    /**
+     */
+    template< class T >
+    class VectorValuesContainer
+      : public itk::SimpleDataObjectDecorator< std::vector< T > >
+    {
+    public:
+      typedef std::vector< T >                             TDecorated;
+      typedef VectorValuesContainer                        Self;
+      typedef itk::SimpleDataObjectDecorator< TDecorated > Superclass;
+      typedef itk::SmartPointer< Self >                    Pointer;
+      typedef itk::SmartPointer< const Self >              ConstPointer;
+
+      typedef T TValue;
+      typedef typename TDecorated::iterator          Iterator;
+      typedef typename TDecorated::const_iterator    ConstIterator;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( VectorValuesContainer, itkSimpleDataObjectDecorator );
+
+    public:
+      void PushBack( const T& v )
+        { this->Get( ).push_back( v ); this->Modified( ); }
+      void PopBack( const T& v )
+        { this->Get( ).pop_back( ); this->Modified( ); }
+      Iterator Begin( )
+        { return( this->Get( ).begin( ) ); }
+      Iterator End( )
+        { return( this->Get( ).end( ) ); }
+      ConstIterator Begin( ) const
+        { return( this->Get( ).begin( ) ); }
+      ConstIterator End( ) const
+        { return( this->Get( ).end( ) ); }
+
+    protected:
+      VectorValuesContainer( )
+        : Superclass( )
+        { }
+      virtual ~VectorValuesContainer( )
+        { }
+
+    private:
+      // Purposely not implemented
+      VectorValuesContainer( const Self& other );
+      Self& operator=( const Self& other );
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __CPEXTENSIONS__DATASTRUCTURES__VECTORVALUESCONTAINER__H__
+
+// eof - $RCSfile$
index 8c3f2321f047e42243fffe06bc0dbff386611ea9..69acc92398734047a9b825a78c5f8e8d287291ed 100644 (file)
@@ -1,35 +1,10 @@
 #include <cpPlugins/Interface/PointList.h>
 
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::PointList::
-HaveEuclideanPoints( ) const
-{
-  return( this->m_HaveEuclideanPoints );
-}
-
-// -------------------------------------------------------------------------
-unsigned long cpPlugins::Interface::PointList::
-GetNumberOfPoints( ) const
-{
-  return( this->m_NumberOfPoints );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::PointList::
-Clear( )
-{
-  this->m_ITKObject = NULL;
-  this->m_VTKObject = NULL;
-  this->m_NumberOfPoints = 0;
-}
-
 // -------------------------------------------------------------------------
 cpPlugins::Interface::PointList::
 PointList( )
-  : Superclass( ),
-    m_HaveEuclideanPoints( true )
+  : Superclass( )
 {
-  this->Clear( );
 }
 
 // -------------------------------------------------------------------------
index 6f43b32aef99afebea85f76446f69db1ffe3f0d9..286825c862979b9d90a4e97d79194aa6cea9c950 100644 (file)
@@ -23,22 +23,6 @@ namespace cpPlugins
       itkTypeMacro( PointList, DataObject );
       cpPlugins_Id_Macro( PointList, DataObject );
 
-      itkBooleanMacro( HaveEuclideanPoints );
-      itkGetConstMacro( HaveEuclideanPoints, bool );
-      itkSetMacro( HaveEuclideanPoints, bool );
-
-    public:
-      bool HaveEuclideanPoints( ) const;
-      unsigned long GetNumberOfPoints( ) const;
-
-      void Clear( );
-
-      template< class P >
-        inline void AddPoint( const P& p );
-
-      template< class P >
-        inline P GetPoint( const unsigned long& i ) const;
-
     protected:
       PointList( );
       virtual ~PointList( );
@@ -47,10 +31,6 @@ namespace cpPlugins
       // Purposely not implemented
       PointList( const Self& );
       Self& operator=( const Self& );
-
-    protected:
-      unsigned long m_NumberOfPoints;
-      bool m_HaveEuclideanPoints;
     };
 
   } // ecapseman
index 95e9e1fa5a89db2c345fa01b9bf389427cee702e..651e4cdcce17123ed446ff85af17c6399294c0b9 100644 (file)
@@ -1,52 +1,7 @@
 #ifndef __CPPLUGINS__INTERFACE__POINTLIST__HXX__
 #define __CPPLUGINS__INTERFACE__POINTLIST__HXX__
 
-#include <itkSimpleDataObjectDecorator.h>
-#include <utility>
-#include <vector>
-
-// -------------------------------------------------------------------------
-template< class P >
-void cpPlugins::Interface::PointList::
-AddPoint( const P& p )
-{
-  typedef itk::SimpleDataObjectDecorator< std::vector< P > > _T;
-
-  _T* container = NULL;
-  if( this->m_NumberOfPoints == 0 )
-  {
-    typename _T::Pointer obj = _T::New( );
-    container = obj.GetPointer( );
-    this->m_ITKObject = container;
-  }
-  else
-    container = dynamic_cast< _T* >( this->m_ITKObject.GetPointer( ) );
-
-  if( container != NULL )
-  {
-    container->Get( ).push_back( p );
-    this->m_NumberOfPoints += 1;
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class P >
-P cpPlugins::Interface::PointList::
-GetPoint( const unsigned long& i ) const
-{
-  typedef itk::SimpleDataObjectDecorator< std::vector< P > > _T;
-
-  P ret;
-  if( i < this->m_NumberOfPoints )
-  {
-    _T* container = dynamic_cast< _T* >( this->m_ITKObject.GetPointer( ) );
-    if( container != NULL )
-      ret = container->Get( )[ i ];
-    
-  } // fi
-  return( ret );
-}
+// TODO: erase this file
 
 #endif // __CPPLUGINS__INTERFACE__POINTLIST__HXX__
 
index 437b03793ed9addc12481385c8bbeca5c8e5305d..a65aec6dcce66bf027a0a7ec0aadbc8968142e35 100644 (file)
@@ -339,6 +339,42 @@ GetExposedOutputPorts( ) const
   return( this->m_ExposedOutputPorts );
 }
 
+// -------------------------------------------------------------------------
+cpPlugins::Interface::
+OutputProcessObjectPort& cpPlugins::Interface::Workspace::
+GetExposedOutput( const std::string& name )
+{
+  static OutputProcessObjectPort null_port;
+
+  auto i = this->m_ExposedOutputPorts.find( name );
+  if( i != this->m_ExposedOutputPorts.end( ) )
+  {
+    TFilter* filter = this->GetFilter( i->second.first );
+    if( filter != NULL )
+      return( filter->GetOutput( i->second.second ) );
+
+  } // fi
+  return( null_port );
+}
+
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::
+OutputProcessObjectPort& cpPlugins::Interface::Workspace::
+GetExposedOutput( const std::string& name ) const
+{
+  static const OutputProcessObjectPort null_port;
+
+  auto i = this->m_ExposedOutputPorts.find( name );
+  if( i != this->m_ExposedOutputPorts.end( ) )
+  {
+    const TFilter* filter = this->GetFilter( i->second.first );
+    if( filter != NULL )
+      return( filter->GetOutput( i->second.second ) );
+
+  } // fi
+  return( null_port );
+}
+
 // -------------------------------------------------------------------------
 std::string cpPlugins::Interface::Workspace::
 Execute( )
index dedb8b4f37db57edc4e829a7c53a04c05d7f5653..75ef769d9f53dfe9f58b2c7658c6d72d5c158795 100644 (file)
@@ -126,10 +126,8 @@ namespace cpPlugins
       const TExposedPorts& GetExposedInputPorts( ) const;
       const TExposedPorts& GetExposedOutputPorts( ) const;
 
-      TData* GetExposedInput( const std::string& name );
-      const TData* GetExposedInput( const std::string& name ) const;
-      TData* GetExposedOutput( const std::string& name );
-      const TData* GetExposedOutput( const std::string& name ) const;
+      OutputProcessObjectPort& GetExposedOutput( const std::string& name );
+      const OutputProcessObjectPort& GetExposedOutput( const std::string& name ) const;
 
       // Pipeline execution
       std::string Execute( );
index 9cfc8bed6505def49b5ce0316d09830b4d882626..9d6a9f4ae100721f1f910aaa76ebddec3486644f 100644 (file)
@@ -23,15 +23,15 @@ cpPlugins::BasicFilters::AppendMeshesFilter::
 std::string cpPlugins::BasicFilters::AppendMeshesFilter::
 _GenerateData( )
 {
-  auto m0 = this->GetInputData< cpPlugins::Interface::Mesh >( "Input0" );
-  auto m1 = this->GetInputData< cpPlugins::Interface::Mesh >( "Input1" );
+  auto m0 = this->GetInputData( "Input0" );
+  auto m1 = this->GetInputData( "Input1" );
 
   auto filter = this->_CreateVTK< vtkAppendPolyData >( );
   filter->AddInputData( m0->GetVTK< vtkPolyData >( ) );
   filter->AddInputData( m1->GetVTK< vtkPolyData >( ) );
   filter->Update( );
 
-  auto out = this->GetOutputData< cpPlugins::Interface::Mesh >( "Output" );
+  auto out = this->GetOutputData( "Output" );
   out->SetVTK( filter->GetOutput( ) );
   return( "" );
 }
index f4dd37b7f8e64bed757b81ff2508327f5c3954e2..4391732b024614a538d8d30ce6ec41635cb4e434 100644 (file)
@@ -27,7 +27,7 @@ cpPlugins::BasicFilters::BinaryErodeImageFilter::
 std::string cpPlugins::BasicFilters::BinaryErodeImageFilter::
 _GenerateData( )
 {
-  auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" );
+  auto image = this->GetInputData( "Input" );
   itk::DataObject* itk_image = NULL;
   std::string r = "";
   cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
@@ -75,7 +75,7 @@ _RealGD( itk::DataObject* image )
   filter->Update( );
 
   // Connect output
-  auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
+  auto out = this->GetOutputData( "Output" );
   out->SetITK( filter->GetOutput( ) );
   return( "" );
 }
index af2c26ae01d11f165081115cf1dfdc5b6b558d0d..ab26ffacde08135a3907851fd5a00da6f44c2832 100644 (file)
@@ -32,7 +32,7 @@ cpPlugins::BasicFilters::BinaryThresholdImageFilter::
 std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter::
 _GenerateData( )
 {
-  auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" );
+  auto image = this->GetInputData( "Input" );
   itk::DataObject* itk_image = NULL;
   std::string r = "";
   cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
@@ -81,7 +81,7 @@ _RealGD( itk::DataObject* image )
   filter->Update( );
 
   // Connect output
-  auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
+  auto out = this->GetOutputData( "Output" );
   out->SetITK( filter->GetOutput( ) );
   return( "" );
 }
index a6a916cbd48f129f92bb30ef916236473c3d161e..2afadd58691e04c0f04db481d40bbb8d58ee3541 100644 (file)
@@ -29,11 +29,8 @@ std::string cpPlugins::BasicFilters::Cutter::
 _GenerateData( )
 {
   // Get inputs
-  auto mesh = this->GetInputData< cpPlugins::Interface::Mesh >( "InputMesh" );
-  auto function =
-    this->GetInputData< cpPlugins::Interface::ImplicitFunction >(
-      "InputFunction"
-      );
+  auto mesh = this->GetInputData( "InputMesh" );
+  auto function = this->GetInputData( "InputFunction" );
   vtkCutter* cutter = this->_CreateVTK< vtkCutter >( );
   cutter->DebugOn( );
   cutter->SetInputData( mesh->GetVTK< vtkPolyData >( ) );
@@ -43,7 +40,7 @@ _GenerateData( )
   cutter->Update( );
 
   // Execute filter
-  auto out = this->GetOutputData< cpPlugins::Interface::Mesh >( "Output" );
+  auto out = this->GetOutputData( "Output" );
   out->SetVTK( cutter->GetOutput( ) );
 
   return( "" );
index 12cb54034c2e9e2bb26b831d5af315f1dbb6d05e..a700a01cef465a78bb3b59d259788085d4612f33 100644 (file)
@@ -28,7 +28,7 @@ cpPlugins::BasicFilters::ExtractSliceImageFilter::
 std::string cpPlugins::BasicFilters::ExtractSliceImageFilter::
 _GenerateData( )
 {
-  auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" );
+  auto image = this->GetInputData( "Input" );
   itk::DataObject* itk_image = NULL;
   std::string r = "";
 /*
@@ -76,7 +76,7 @@ _RealGD( itk::DataObject* image )
   filter->Update( );
 
   // Connect output
-  auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
+  auto out = this->GetOutputData( "Output" );
   out->SetITK( filter->GetOutput( ) );
   return( "" );
 }
index 0a1aa5c2c979829c263b3e52e68d9abd9765d02d..bffab1674d0cb975f86d4f76272f1c0e49c8f16a 100644 (file)
@@ -35,8 +35,7 @@ cpPlugins::BasicFilters::ImageInterpolatorSource::
 std::string cpPlugins::BasicFilters::ImageInterpolatorSource::
 _GenerateData( )
 {
-  auto image =
-    this->GetInputData< cpPlugins::Interface::Image >( "ReferenceImage" );
+  auto image = this->GetInputData( "ReferenceImage" );
   itk::DataObject* itk_image = NULL;
   std::string r = "";
   cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
@@ -91,8 +90,7 @@ template< class T >
 std::string cpPlugins::BasicFilters::ImageInterpolatorSource::
 _GD1( )
 {
-  auto out =
-    this->GetOutputData< cpPlugins::Interface::DataObject >( "Output" );
+  auto out = this->GetOutputData( "Output" );
   if( out->GetITK< T >( ) == NULL )
   {
     typename T::Pointer res = T::New( );
index e8e9b101e8888c32f6c5d5769e4e2d574d3fdfc7..6a077f500c2106a25309010fb18a9d21ed175628 100644 (file)
@@ -130,7 +130,7 @@ ExecConfigurationDialog( QWidget* parent )
   
   // Get bounding box
   double bbox[ 6 ];
-  auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" );
+  auto image = this->GetInputData( "Input" );
   bool input_found = false;
   if( image != NULL )
   {
@@ -138,7 +138,7 @@ ExecConfigurationDialog( QWidget* parent )
     input_found = true;
 
   } // fi
-  auto mesh = this->GetInputData< cpPlugins::Interface::Mesh >( "Input" );
+  auto mesh = this->GetInputData( "Input" );
   if( mesh != NULL )
   {
     mesh->GetVTK< vtkPolyData >( )->GetBounds( bbox );
@@ -216,10 +216,10 @@ cpPlugins::BasicFilters::MacheteFilter::
 std::string cpPlugins::BasicFilters::MacheteFilter::
 _GenerateData( )
 {
-  auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" );
+  auto image = this->GetInputData( "Input" );
   if( image != NULL )
     return( this->_FromImage( image ) );
-  auto mesh = this->GetInputData< cpPlugins::Interface::Mesh >( "Input" );
+  auto mesh = this->GetInputData( "Input" );
   if( mesh == NULL )
     return( this->_FromMesh( mesh ) );
   return( "MacheteFilter: No valid input." );
@@ -227,7 +227,7 @@ _GenerateData( )
 
 // -------------------------------------------------------------------------
 std::string cpPlugins::BasicFilters::MacheteFilter::
-_FromImage( cpPlugins::Interface::Image* image )
+_FromImage( cpPlugins::Interface::DataObject* image )
 {
   itk::DataObject* itk_image = NULL;
   std::string r = "";
@@ -239,7 +239,7 @@ _FromImage( cpPlugins::Interface::Image* image )
 
 // -------------------------------------------------------------------------
 std::string cpPlugins::BasicFilters::MacheteFilter::
-_FromMesh( cpPlugins::Interface::Mesh* mesh )
+_FromMesh( cpPlugins::Interface::DataObject* mesh )
 {
   return( "" );
 }
@@ -286,18 +286,18 @@ _RealImage( itk::DataObject* dobj )
   filter->Update( );
 
   // Connect outputs (and correct their types and names)
-  _TImage* pos_out = this->GetOutputData< _TImage >( "PositiveOutput" );
+  _TObj* pos_out = this->GetOutputData( "PositiveOutput" );
   if( pos_out == NULL )
   {
     this->_AddOutput< _TImage >( "PositiveOutput" );
-    pos_out = this->GetOutputData< _TImage >( "PositiveOutput" );
+    pos_out = this->GetOutputData( "PositiveOutput" );
 
   } // fi
-  _TImage* neg_out = this->GetOutputData< _TImage >( "NegativeOutput" );
+  _TObj* neg_out = this->GetOutputData( "NegativeOutput" );
   if( neg_out == NULL )
   {
     this->_AddOutput< _TImage >( "NegativeOutput" );
-    neg_out = this->GetOutputData< _TImage >( "NegativeOutput" );
+    neg_out = this->GetOutputData( "NegativeOutput" );
 
   } // fi
 
index 75e52cd5e8563ea9496faa7accf7b246af4876d6..05068a484731b8e59dcd3c9ca8122d142043f9c3 100644 (file)
@@ -88,8 +88,8 @@ namespace cpPlugins
 
       virtual std::string _GenerateData( );
 
-      std::string _FromImage( cpPlugins::Interface::Image* image );
-      std::string _FromMesh( cpPlugins::Interface::Mesh* mesh );
+      std::string _FromImage( cpPlugins::Interface::DataObject* image );
+      std::string _FromMesh( cpPlugins::Interface::DataObject* mesh );
 
       template< class I >
         inline std::string _RealImage( itk::DataObject* dobj );
index 7f9d251523494fd0e97f246f0f4727a3a9440ac6..ea7bc98676d4660ec9a6c8b0dd38e99da8fffc76 100644 (file)
@@ -38,7 +38,7 @@ cpPlugins::BasicFilters::MacheteImageFilter::
 std::string cpPlugins::BasicFilters::MacheteImageFilter::
 _GenerateData()
 {
-  auto image = this->GetInputData< cpPlugins::Interface::Image >("Input");
+  auto image = this->GetInputData("Input");
   itk::DataObject* itk_image = NULL;
   std::string r = "";
   cpPlugins_Image_Demangle_AllScalarTypes(2, image, itk_image, r, _GD0);
@@ -86,7 +86,7 @@ _RealGD(itk::DataObject* image)
   filter->Update();
 
   // Connect output
-  auto out = this->GetOutputData< cpPlugins::Interface::Image >("Output");
+  auto out = this->GetOutputData("Output");
   out->SetITK( filter->GetOutput( ) );
   return("");
 }
index 388b75e293ef3f4f202d4351fcdf8614cde72877..f05296ee062d022175f8f993a82f1059dc947c84 100644 (file)
@@ -28,7 +28,7 @@ std::string cpPlugins::BasicFilters::MarchingCubes::
 _GenerateData( )
 {
   // Get input
-  auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" );
+  auto image = this->GetInputData( "Input" );
   vtkImageData* vtk_image = image->GetVTK< vtkImageData >( );
   if( vtk_image == NULL )
     return( "MarchingCubes: Input does not have a valid VTK conversion." );
@@ -59,7 +59,7 @@ _GenerateData( )
     return( "MarchingCubes: Input data does not have a valid dimension." );
 
   // Execute filter
-  auto out = this->GetOutputData< cpPlugins::Interface::Mesh >( "Output" );
+  auto out = this->GetOutputData( "Output" );
   out->SetVTK( pd );
   return( "" );
 }
index 0046f07e76abe73bdd10bd614fcfc636ffdd31f4..a7fdb3b8c96afebfda2fc7b699d15644d6cce4a2 100644 (file)
@@ -25,7 +25,7 @@ cpPlugins::BasicFilters::MedianImageFilter::
 std::string cpPlugins::BasicFilters::MedianImageFilter::
 _GenerateData( )
 {
-  auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" );
+  auto image = this->GetInputData( "Input" );
   itk::DataObject* itk_image = NULL;
   std::string r = "";
   cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
@@ -66,7 +66,7 @@ _RealGD( itk::DataObject* image )
   filter->Update( );
 
   // Connect output
-  auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
+  auto out = this->GetOutputData( "Output" );
   out->SetITK( filter->GetOutput( ) );
   return( "" );
 }
index 48d1a9e31c7db58ba6231f7903ea29383c73f0a7..c1822ed138c22f3a734fd705fbc9653d9a11d7e4 100644 (file)
@@ -26,7 +26,7 @@ cpPlugins::BasicFilters::MultiplyImageFilter::
 std::string cpPlugins::BasicFilters::MultiplyImageFilter::
 _GenerateData( )
 {
-  auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input0" );
+  auto image = this->GetInputData( "Input0" );
   itk::DataObject* itk_image = NULL;
   std::string r = "";
   cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
@@ -62,7 +62,7 @@ _RealGD( itk::DataObject* image )
   filter->Update( );
 
   // Connect output
-  auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
+  auto out = this->GetOutputData( "Output" );
   out->SetITK( filter->GetOutput( ) );
   return( "" );
 }
index 5c419ae4e1bf6e61930742365e10332ee79c1e27..6ce525a784bd5900da47e4b7440039cb1985e7af 100644 (file)
@@ -30,7 +30,7 @@ cpPlugins::BasicFilters::OtsuThresholdImageFilter::
 std::string cpPlugins::BasicFilters::OtsuThresholdImageFilter::
 _GenerateData( )
 {
-  auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" );
+  auto image = this->GetInputData( "Input" );
   itk::DataObject* itk_image = NULL;
   std::string r = "";
   cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
@@ -74,7 +74,7 @@ _RealGD( itk::DataObject* image )
   filter->Update( );
 
   // Connect output
-  auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
+  auto out = this->GetOutputData( "Output" );
   out->SetITK( filter->GetOutput( ) );
   return( "" );
 }
index f7fdfff5641ee384d8f2df2a662013467ccf0209..92b8ac5e094cecf404a59b8ab8a66c734434aa0f 100644 (file)
@@ -30,7 +30,7 @@ cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter::
 std::string cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter::
 _GenerateData( )
 {
-  auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" );
+  auto image = this->GetInputData( "Input" );
   itk::DataObject* itk_image = NULL;
   std::string r = "";
   cpPlugins_Image_Demangle_AllRGBTypes( 2, image, itk_image, r, _GD0 );
@@ -80,7 +80,7 @@ _RealGD( itk::DataObject* image )
   filter->Update( );
 
   // Connect output
-  auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
+  auto out = this->GetOutputData( "Output" );
   out->SetITK( filter->GetOutput( ) );
   return( "" );
 }
index 90fa01946e5ef426d477428101e15557eb8b9b0f..f2f2ce6eed22d6b1799aeaa6571e1ddb1a712c5a 100644 (file)
@@ -38,7 +38,7 @@ cpPlugins::BasicFilters::SignedMaurerDistanceMapImageFilter::
 std::string cpPlugins::BasicFilters::SignedMaurerDistanceMapImageFilter::
 _GenerateData( )
 {
-  auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" );
+  auto image = this->GetInputData( "Input" );
   itk::DataObject* itk_image = NULL;
   std::string r = "";
   cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
@@ -94,7 +94,7 @@ _RealGD( itk::DataObject* image )
   filter->Update( );
 
   // Connect output
-  auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
+  auto out = this->GetOutputData( "Output" );
   out->SetITK( filter->GetOutput( ) );
   return( "" );
 }
index df01a691e34cb3a56ae4dedccdcffd32ebf03d98..1497134a969b193955b3f40740a23118e8a1ad31 100644 (file)
@@ -50,7 +50,7 @@ _GenerateData( )
   src->Update( );
 
   // Execute filter
-  auto out = this->GetOutputData< cpPlugins::Interface::Mesh >( "Output" );
+  auto out = this->GetOutputData( "Output" );
   out->SetVTK( src->GetOutput( ) );
   return( "" );
 }
index 5dc3f68c6d2bf18cdb13f7e605758048b27bac48..cc2e388f036a9ab97e8b8f729488d8d6ba98e1f3 100644 (file)
@@ -35,7 +35,7 @@ _GenerateData( )
   typedef itk::Mesh< float, 3 > _3F;
   typedef itk::Mesh< double, 3 > _3D;
 
-  auto input = this->GetInputData< cpPlugins::Interface::Mesh >( "Input" );
+  auto input = this->GetInputData( "Input" );
   auto in_3f = input->GetITK< _3F >( );
   auto in_3d = input->GetITK< _3D >( );
   if     ( in_3f != NULL ) return( this->_GD0( in_3f ) );
@@ -116,7 +116,7 @@ _RealGD( M* mesh )
   filter->Update( );
 
   // Connect output
-  auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
+  auto out = this->GetOutputData( "Output" );
   out->SetITK( filter->GetOutput( ) );
   return( "" );
 }
index 900940bfcaf97c7a9d0e22149e1a56065d55b700..de091b1ded850503e7cb9b6f261f8800ab92160e 100644 (file)
@@ -317,7 +317,7 @@ template< class I >
 std::string cpPlugins::IO::ImageReader::
 _RealGD( const TStringList& names )
 {
-  auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
+  auto out = this->GetOutputData( "Output" );
   std::string r = "";
   if( names.size( ) == 1 )
   {
index 234c916f99f5955407294607dc9edd948ebc1eeb..f2afa0fb236ba1bf1fb7a7836561a5e7a8adade1 100644 (file)
@@ -41,7 +41,7 @@ template< unsigned int D >
 std::string cpPlugins::IO::ImageWriter::
 _GD0_Image( )
 {
-  auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" );
+  auto image = this->GetInputData( "Input" );
   itk::DataObject* itk_image = NULL;
   std::string r = "";
   cpPlugins_Image_Demangle_AllTypes( D, image, itk_image, r, _RealGD );
@@ -54,7 +54,7 @@ template< unsigned int D >
 std::string cpPlugins::IO::ImageWriter::
 _GD0_VectorImage( )
 {
-  auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" );
+  auto image = this->GetInputData( "Input" );
   itk::DataObject* itk_image = NULL;
   std::string r = "";
   cpPlugins_VectorImage_Demangle_AllTypes( D, image, itk_image, r, _RealGD );
index 040f8aef0adc3cd4ca6dda27db1276dffa609a95..3042d6745557c7d8c0fa4c58020126ec14d98240 100644 (file)
@@ -84,7 +84,7 @@ _GD1( )
     stlr->SetFileName( fname.c_str( ) );
     stlr->Update( );
 
-    auto out = this->GetOutputData< cpPlugins::Interface::Mesh >( "Output" );
+    auto out = this->GetOutputData( "Output" );
     out->SetVTK( stlr->GetOutput( ) );
     return( "" );
   }
@@ -98,7 +98,7 @@ _GD1( )
     pdr->SetFileName( fname.c_str( ) );
     pdr->Update( );
 
-    auto out = this->GetOutputData< cpPlugins::Interface::Mesh >( "Output" );
+    auto out = this->GetOutputData( "Output" );
     out->SetVTK( pdr->GetOutput( ) );
     return( "" );
   }
index ac20473985e79ed484a45924ef30c9d515bffc86..c9ba1c9d535897bb2af86d416368979503691c79 100644 (file)
@@ -28,7 +28,7 @@ cpPlugins::IO::MeshWriter::
 std::string cpPlugins::IO::MeshWriter::
 _GenerateData( )
 {
-  auto mesh = this->GetInputData< cpPlugins::Interface::Mesh >( "Input" );
+  auto mesh = this->GetInputData( "Input" );
   vtkPolyData* i = mesh->GetVTK< vtkPolyData >( );
   if( i == NULL )
     return( "MeshWriter: No suitable input." );
index 58cbed574e677b8953c389c94d0e4a83ce1ef19e..fbd30d2cfce27a860169f054eef3a052acc16972 100644 (file)
@@ -4,6 +4,7 @@
 #include <cpPlugins/Interface/PointList.h>
 #include <cpPlugins/Interface/SimpleMPRWidget.h>
 #include <cpExtensions/Interaction/ImageInteractorStyle.h>
+#include <cpExtensions/DataStructures/VectorValuesContainer.h>
 
 #include <vtkRenderWindowInteractor.h>
 
@@ -41,8 +42,7 @@ _GenerateData( )
   typedef itk::ImageBase< 2 > _2DImage;
   typedef itk::ImageBase< 3 > _3DImage;
 
-  auto image =
-    this->GetInputData< cpPlugins::Interface::Image >( "ReferenceImage" );
+  auto image = this->GetInputData( "ReferenceImage" );
   itk::DataObject* itk_image = image->GetITK< _2DImage >( );
   if( itk_image != NULL )
     return( this->_GD0< _2DImage >( itk_image ) );
@@ -60,19 +60,28 @@ _GenerateData( )
 template< class I >
 std::string cpPlugins::Widgets::SeedWidget::
 _GD0( itk::DataObject* image )
+{
+  if( this->m_Parameters->GetBool( "SeedsAreInRealSpace" ) )
+    return( this->_GD1_Points< I >( dynamic_cast< I* >( image ) ) );
+  else
+    return( this->_GD1_Vertices< I >( dynamic_cast< I* >( image ) ) );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+std::string cpPlugins::Widgets::SeedWidget::
+_GD1_Points( I* image )
 {
   typedef cpExtensions::Interaction::ImageInteractorStyle _S;
+  typedef itk::Point< double, I::ImageDimension > _P;
+  typedef cpExtensions::DataStructures::VectorValuesContainer< _P > _Container;
+
+  auto container = this->_CreateITK< _Container >( );
 
-  I* base_image = dynamic_cast< I* >( image );
-  auto out =
-    this->GetOutputData< cpPlugins::Interface::PointList >( "Output" );
   double aux_pnt[ 3 ];
   unsigned int dim = ( I::ImageDimension < 3 )? I::ImageDimension: 3;
-  bool real_space = this->m_Parameters->GetBool( "SeedsAreInRealSpace" );
 
-  // Prepare output
-  out->Clear( );
-  out->SetHaveEuclideanPoints( real_space );
+  container->Get( ).clear( );
 
   // MPR
   if( this->m_MPRViewer != NULL )
@@ -90,18 +99,10 @@ _GD0( itk::DataObject* image )
           for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
           {
             s->GetSeedAsPoint( i, aux_pnt );
-            typename I::PointType seed;
+            _P seed;
             for( unsigned int d = 0; d < dim; ++d )
               seed[ d ] = aux_pnt[ d ];
-
-            if( !real_space )
-            {
-              typename I::IndexType index;
-              if( base_image->TransformPhysicalPointToIndex( seed, index ) )
-                out->AddPoint( index );
-            }
-            else
-              out->AddPoint( seed );
+            container->PushBack( seed );
 
           } // rof
         }
@@ -123,17 +124,88 @@ _GD0( itk::DataObject* image )
       for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
       {
         s->GetSeedAsPoint( i, aux_pnt );
-        typename I::PointType seed;
+        _P seed;
         for( unsigned int d = 0; d < dim; ++d )
           seed[ d ] = aux_pnt[ d ];
-        if( !real_space )
+        container->PushBack( seed );
+
+      } // rof
+    }
+    else
+      s->SeedWidgetOn( );
+
+  } // fi
+  this->m_Configured = true;
+
+  auto out = this->GetOutputData( "Output" );
+  out->SetITK( container );
+  return( "" );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+std::string cpPlugins::Widgets::SeedWidget::
+_GD1_Vertices( I* image )
+{
+  typedef cpExtensions::Interaction::ImageInteractorStyle _S;
+  typedef cpExtensions::DataStructures::VectorValuesContainer< typename I::IndexType > _Container;
+
+  auto container = this->_CreateITK< _Container >( );
+
+  double aux_pnt[ 3 ];
+  unsigned int dim = ( I::ImageDimension < 3 )? I::ImageDimension: 3;
+
+  container->Get( ).clear( );
+
+  // MPR
+  if( this->m_MPRViewer != NULL )
+  {
+    for( unsigned int i = 0; i < 4; ++i )
+    {
+      _S* s =
+        dynamic_cast< _S* >(
+          this->m_MPRViewer->GetInteractor( i )->GetInteractorStyle( )
+          );
+      if( s != NULL )
+      {
+        if( this->m_Configured )
         {
-          typename I::IndexType index;
-          if( base_image->TransformPhysicalPointToIndex( seed, index ) )
-            out->AddPoint( index );
+          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 ];
+            typename I::IndexType idx;
+            if( image->TransformPhysicalPointToIndex( seed, idx ) )
+              container->PushBack( idx );
+
+          } // rof
         }
         else
-          out->AddPoint( seed );
+          s->SeedWidgetOn( );
+
+      } // fi
+
+    } // rof
+
+  } // fi
+
+  // Single interactor
+  _S* s = dynamic_cast< _S* >( this->m_SingleInteractor );
+  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 ];
+        typename I::IndexType idx;
+        if( image->TransformPhysicalPointToIndex( seed, idx ) )
+          container->PushBack( idx );
 
       } // rof
     }
@@ -142,6 +214,9 @@ _GD0( itk::DataObject* image )
 
   } // fi
   this->m_Configured = true;
+
+  auto out = this->GetOutputData( "Output" );
+  out->SetITK( container );
   return( "" );
 }
 
index ee6aa1661cab4ef71594405d25d8292bf2daa73f..5d11e1d465bc20bf74b320b592832d9398620003 100644 (file)
@@ -36,6 +36,12 @@ namespace cpPlugins
       template< class I >
         inline std::string _GD0( itk::DataObject* image );
 
+      template< class I >
+        inline std::string _GD1_Points( I* image );
+
+      template< class I >
+        inline std::string _GD1_Vertices( I* image );
+
     private:
       // Purposely not implemented
       SeedWidget( const Self& );