]> Creatis software - cpPlugins.git/commitdiff
Suppor for image index list added
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 6 Apr 2016 23:24:02 +0000 (18:24 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 6 Apr 2016 23:24:02 +0000 (18:24 -0500)
lib/cpExtensions/DataStructures/ImageIndexesContainer.h [new file with mode: 0644]
lib/cpExtensions/Visualization/ImageIndexesContainerToPolyData.h [moved from lib/cpExtensions/Visualization/IndexesToPolyData.h with 67% similarity]
lib/cpExtensions/Visualization/ImageIndexesContainerToPolyData.hxx [moved from lib/cpExtensions/Visualization/IndexesToPolyData.hxx with 73% similarity]
lib/cpPlugins/ImageIndexesContainer.cxx [new file with mode: 0644]
lib/cpPlugins/ImageIndexesContainer.h [new file with mode: 0644]
lib/cpPlugins/ImageIndexesContainer.hxx [new file with mode: 0644]
lib/cpPlugins_Instances/Paths.i

diff --git a/lib/cpExtensions/DataStructures/ImageIndexesContainer.h b/lib/cpExtensions/DataStructures/ImageIndexesContainer.h
new file mode 100644 (file)
index 0000000..00dbf64
--- /dev/null
@@ -0,0 +1,66 @@
+#ifndef __CPEXTENSIONS__DATASTRUCTURES__IMAGEINDEXESCONTAINER__H__
+#define __CPEXTENSIONS__DATASTRUCTURES__IMAGEINDEXESCONTAINER__H__
+
+#include <vector>
+#include <itkImageBase.h>
+#include <itkSimpleDataObjectDecorator.h>
+
+namespace cpExtensions
+{
+  namespace DataStructures
+  {
+    /**
+     */
+    template< unsigned int _NDim >
+    class ImageIndexesContainer
+      : public itk::SimpleDataObjectDecorator< std::vector< itk::Index< _NDim > > >
+    {
+    public:
+      typedef itk::Index< _NDim >                          TIndex;
+      typedef std::vector< TIndex >                        TContainer;
+      typedef itk::SimpleDataObjectDecorator< TContainer > Superclass;
+
+      typedef ImageIndexesContainer           Self;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
+
+      typedef itk::ImageBase< _NDim > TImageBase;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( ImageIndexesContainer, itk::SimpleDataObjectDecorator );
+
+    public:
+      TImageBase* GetReferenceImage( )
+        { return( this->m_ReferenceImage ); }
+      const TImageBase* GetReferenceImage( ) const
+        { return( this->m_ReferenceImage ); }
+      void SetReferenceImage( const TImageBase* image )
+        {
+          this->m_ReferenceImage = TImageBase::New( );
+          this->m_ReferenceImage->SetDirection( image->GetDirection( ) );
+          this->m_ReferenceImage->SetOrigin( image->GetOrigin( ) );
+          this->m_ReferenceImage->SetSpacing( image->GetSpacing( ) );
+          this->Modified( );
+        }
+
+    protected:
+      ImageIndexesContainer( )          { }
+      virtual ~ImageIndexesContainer( ) { }
+
+    private:
+      // Purposely not implemented
+      ImageIndexesContainer( const Self& other );
+      Self& operator=( const Self& other );
+
+    protected:
+      typename TImageBase::Pointer m_ReferenceImage;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __CPEXTENSIONS__DATASTRUCTURES__IMAGEINDEXESCONTAINER__H__
+
+// eof - $RCSfile$
similarity index 67%
rename from lib/cpExtensions/Visualization/IndexesToPolyData.h
rename to lib/cpExtensions/Visualization/ImageIndexesContainerToPolyData.h
index 0dde70c273110abe601fc5f76943cf8d35a7abe9..561356794f8583124f0399f1a6f8f8f923b374aa 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __CPEXTENSIONS__VISUALIZATION__INDEXESTOPOLYDATA__H__
-#define __CPEXTENSIONS__VISUALIZATION__INDEXESTOPOLYDATA__H__
+#ifndef __CPEXTENSIONS__VISUALIZATION__IMAGEINDEXESCONTAINERTOPOLYDATA__H__
+#define __CPEXTENSIONS__VISUALIZATION__IMAGEINDEXESCONTAINERTOPOLYDATA__H__
 
 #include <vtkPolyDataAlgorithm.h>
 #include <itkImageBase.h>
@@ -11,11 +11,11 @@ namespace cpExtensions
     /**
      */
     template< class _TIndexes >
-    class IndexesToPolyData
+    class ImageIndexesContainerToPolyData
       : public vtkPolyDataAlgorithm
     {
     public:
-      typedef IndexesToPolyData Self;
+      typedef ImageIndexesContainerToPolyData Self;
 
       typedef _TIndexes TIndexes;
       typedef typename TIndexes::ComponentType TContainer;
@@ -23,7 +23,7 @@ namespace cpExtensions
       typedef itk::ImageBase< TIndex::Dimension > TImage;
 
     public:
-      vtkTypeMacro( IndexesToPolyData, vtkPolyDataAlgorithm );
+      vtkTypeMacro( ImageIndexesContainerToPolyData, vtkPolyDataAlgorithm );
 
     public:
       static Self* New( );
@@ -34,8 +34,8 @@ namespace cpExtensions
       void SetReferenceImage( const TImage* i );
 
     protected:
-      IndexesToPolyData( );
-      virtual ~IndexesToPolyData( );
+      ImageIndexesContainerToPolyData( );
+      virtual ~ImageIndexesContainerToPolyData( );
 
       int RequestData(
         vtkInformation* information,
@@ -50,7 +50,7 @@ namespace cpExtensions
 
     private:
       // Purposely not implemented
-      IndexesToPolyData( const Self& );
+      ImageIndexesContainerToPolyData( const Self& );
       void operator=( const Self& );
 
     protected:
@@ -63,9 +63,9 @@ namespace cpExtensions
 } // ecapseman
 
 #ifndef ITK_MANUAL_INSTANTIATION
-#include <cpExtensions/Visualization/IndexesToPolyData.hxx>
+#include <cpExtensions/Visualization/ImageIndexesContainerToPolyData.hxx>
 #endif // ITK_MANUAL_INSTANTIATION
 
-#endif //  __CPEXTENSIONS__VISUALIZATION__INDEXESTOPOLYDATA__H__
+#endif //  __CPEXTENSIONS__VISUALIZATION__IMAGEINDEXESCONTAINERTOPOLYDATA__H__
 
 // eof - $RCSfile$
similarity index 73%
rename from lib/cpExtensions/Visualization/IndexesToPolyData.hxx
rename to lib/cpExtensions/Visualization/ImageIndexesContainerToPolyData.hxx
index 3e6f00dfc2322d16eb11df529335c5ae633e79ce..8d677654a6e9bf6325ebe10ba45f02966fa2b8eb 100644 (file)
@@ -1,13 +1,13 @@
-#ifndef __CPEXTENSIONS__VISUALIZATION__INDEXESTOPOLYDATA__HXX__
-#define __CPEXTENSIONS__VISUALIZATION__INDEXESTOPOLYDATA__HXX__
+#ifndef __CPEXTENSIONS__VISUALIZATION__IMAGEINDEXESCONTAINERTOPOLYDATA__HXX__
+#define __CPEXTENSIONS__VISUALIZATION__IMAGEINDEXESCONTAINERTOPOLYDATA__HXX__
 
 #include <vtkInformation.h>
 #include <vtkInformationVector.h>
 
 // -------------------------------------------------------------------------
 template< class _TIndexes >
-typename cpExtensions::Visualization::IndexesToPolyData< _TIndexes >::
-Self* cpExtensions::Visualization::IndexesToPolyData< _TIndexes >::
+typename cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
+Self* cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
 New( )
 {
   return( new Self( ) );
@@ -15,8 +15,8 @@ New( )
 
 // -------------------------------------------------------------------------
 template< class _TIndexes >
-const typename cpExtensions::Visualization::IndexesToPolyData< _TIndexes >::
-TIndexes* cpExtensions::Visualization::IndexesToPolyData< _TIndexes >::
+const typename cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
+TIndexes* cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
 GetInput( ) const
 {
   return( this->m_Indexes );
@@ -24,8 +24,8 @@ GetInput( ) const
 
 // -------------------------------------------------------------------------
 template< class _TIndexes >
-const typename cpExtensions::Visualization::IndexesToPolyData< _TIndexes >::
-TImage* cpExtensions::Visualization::IndexesToPolyData< _TIndexes >::
+const typename cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
+TImage* cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
 GetReferenceImage( ) const
 {
   return( this->m_ReferenceImage );
@@ -33,12 +33,12 @@ GetReferenceImage( ) const
 
 // -------------------------------------------------------------------------
 template< class _TIndexes >
-void cpExtensions::Visualization::IndexesToPolyData< _TIndexes >::
-SetInput( const TIndexes* indexes )
+void cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
+SetInput( const TIndexes* imageindexescontainer )
 {
-  if( this->m_Indexes != indexes )
+  if( this->m_Indexes != imageindexescontainer )
   {
-    this->m_Indexes = indexes;
+    this->m_Indexes = imageindexescontainer;
     this->Modified( );
 
   } // fi
@@ -46,7 +46,7 @@ SetInput( const TIndexes* indexes )
 
 // -------------------------------------------------------------------------
 template< class _TIndexes >
-void cpExtensions::Visualization::IndexesToPolyData< _TIndexes >::
+void cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
 SetReferenceImage( const TImage* i )
 {
   if( this->m_ReferenceImage != i )
@@ -59,8 +59,8 @@ SetReferenceImage( const TImage* i )
 
 // -------------------------------------------------------------------------
 template< class _TIndexes >
-cpExtensions::Visualization::IndexesToPolyData< _TIndexes >::
-IndexesToPolyData( )
+cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
+ImageIndexesContainerToPolyData( )
   : vtkPolyDataAlgorithm( ),
     m_Indexes( NULL ),
     m_ReferenceImage( NULL )
@@ -70,14 +70,14 @@ IndexesToPolyData( )
 
 // -------------------------------------------------------------------------
 template< class _TIndexes >
-cpExtensions::Visualization::IndexesToPolyData< _TIndexes >::
-~IndexesToPolyData( )
+cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
+~ImageIndexesContainerToPolyData( )
 {
 }
 
 // -------------------------------------------------------------------------
 template< class _TIndexes >
-int cpExtensions::Visualization::IndexesToPolyData< _TIndexes >::
+int cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
 RequestData(
   vtkInformation* information,
   vtkInformationVector** input,
@@ -149,7 +149,7 @@ RequestData(
 // -------------------------------------------------------------------------
 template< class _TIndexes >
 int
-cpExtensions::Visualization::IndexesToPolyData< _TIndexes >::
+cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
 RequestInformation(
   vtkInformation* information,
   vtkInformationVector** input,
@@ -183,6 +183,6 @@ RequestInformation(
   return( 1 );
 }
 
-#endif //  __CPEXTENSIONS__VISUALIZATION__INDEXESTOPOLYDATA__HXX__
+#endif //  __CPEXTENSIONS__VISUALIZATION__IMAGEINDEXESCONTAINERTOPOLYDATA__HXX__
 
 // eof - $RCSfile$
diff --git a/lib/cpPlugins/ImageIndexesContainer.cxx b/lib/cpPlugins/ImageIndexesContainer.cxx
new file mode 100644 (file)
index 0000000..c7d2f8a
--- /dev/null
@@ -0,0 +1,39 @@
+#include <cpPlugins/ImageIndexesContainer.h>
+
+// -------------------------------------------------------------------------
+void cpPlugins::ImageIndexesContainer::
+SetITK( itk::LightObject* o )
+{
+  this->Superclass::SetITK( o );
+  bool     s = this->_ITK_2_VTK< 2 >( o );
+  if( !s ) s = this->_ITK_2_VTK< 3 >( o );
+  if( !s )
+  {
+    this->m_VTKObject = NULL;
+    this->m_ITKvVTK = NULL;
+
+  } // fi
+  this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ImageIndexesContainer::
+SetVTK( vtkObjectBase* o )
+{
+  // Do nothing
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::ImageIndexesContainer::
+ImageIndexesContainer( )
+  : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::ImageIndexesContainer::
+~ImageIndexesContainer( )
+{
+}
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/ImageIndexesContainer.h b/lib/cpPlugins/ImageIndexesContainer.h
new file mode 100644 (file)
index 0000000..3edfda3
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef __CPPLUGINS__IMAGEINDEXESCONTAINER__H__
+#define __CPPLUGINS__IMAGEINDEXESCONTAINER__H__
+
+#include <cpPlugins/DataObject.h>
+
+#include <vtkPolyDataAlgorithm.h>
+#include <vtkSmartPointer.h>
+
+namespace cpPlugins
+{
+  /**
+   */
+  class cpPlugins_EXPORT ImageIndexesContainer
+    : public DataObject
+  {
+  public:
+    typedef ImageIndexesContainer           Self;
+    typedef DataObject                      Superclass;
+    typedef itk::SmartPointer< Self >       Pointer;
+    typedef itk::SmartPointer< const Self > ConstPointer;
+
+  public:
+    itkNewMacro( Self );
+    itkTypeMacro( ImageIndexesContainer, DataObject );
+    cpPlugins_Id_Macro( ImageIndexesContainer, Object );
+
+  public:
+    virtual void SetITK( itk::LightObject* o ) ITK_OVERRIDE;
+    virtual void SetVTK( vtkObjectBase* o ) ITK_OVERRIDE;
+
+  protected:
+    ImageIndexesContainer( );
+    virtual ~ImageIndexesContainer( );
+
+    template< unsigned int _NDim >
+      inline bool _ITK_2_VTK( itk::LightObject* o );
+
+  private:
+    // Purposely not implemented
+    ImageIndexesContainer( const Self& );
+    Self& operator=( const Self& );
+
+  protected:
+    vtkSmartPointer< vtkPolyDataAlgorithm > m_ITKvVTK;
+  };
+
+} // ecapseman
+
+#include <cpPlugins/ImageIndexesContainer.hxx>
+
+#endif // __CPPLUGINS__IMAGEINDEXESCONTAINER__H__
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/ImageIndexesContainer.hxx b/lib/cpPlugins/ImageIndexesContainer.hxx
new file mode 100644 (file)
index 0000000..41bcd25
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef __CPPLUGINS__IMAGEINDEXESCONTAINER__HXX__
+#define __CPPLUGINS__IMAGEINDEXESCONTAINER__HXX__
+
+#include <cpPlugins_Instances/Path.h>
+
+// -------------------------------------------------------------------------
+template< unsigned int _NDim >
+bool cpPlugins::ImageIndexesContainer::
+_ITK_2_VTK( itk::LightObject* o )
+{
+  typedef
+    cpExtensions::DataStructures::ImageIndexesContainer< _NDim >
+    _TImageIndexesContainer;
+  typedef
+    cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TImageIndexesContainer >
+    _TFilter;
+
+  auto imageindexescontainer = dynamic_cast< _TImageIndexesContainer* >( o );
+  if( imageindexescontainer != NULL )
+  {
+    _TFilter* f = dynamic_cast< _TFilter* >( this->m_ITKvVTK.GetPointer( ) );
+    if( f == NULL )
+    {
+      vtkSmartPointer< _TFilter > nf = _TFilter::New( );
+      this->m_ITKvVTK = nf.GetPointer( );
+      f = nf.GetPointer( );
+
+    } // fi
+    f->SetInput( imageindexescontainer );
+    f->SetReferenceImage( imageindexescontainer->GetReferenceImage( ) );
+    f->Update( );
+
+    // Keep object track
+    this->m_ITKObject = o;
+    this->m_VTKObject = f->GetOutput( );
+    return( true );
+  }
+  else
+    return( false );
+}
+
+#endif // __CPPLUGINS__IMAGEINDEXESCONTAINER__HXX__
+
+// eof - $RCSfile$
index 03d83f9b7cd6bb4edc00d66cb61c9a1abc81727d..148ac75b5e76d737ae9da7333c54836fd51bd9fe 100644 (file)
@@ -1,14 +1,22 @@
 f cpPlugins_Instances/Base.h
 
 i cpExtensions/DataStructures/PolyLineParametricPath.h
+i cpExtensions/DataStructures/ImageIndexesContainer.h
 t itkPolyLineParametricPath.h
 t itkPath.h
 t itkParametricPath.h
 t itkVectorContainer.h
 t cpExtensions/Visualization/PolyLineParametricPathToPolyData.h
+t cpExtensions/Visualization/ImageIndexesContainerToPolyData.h
+t itkSimpleDataObjectDecorator.h
 
 d #dims=2;3
 
+c itk::SimpleDataObjectDecorator< std::vector< itk::Index< #dims > > >
+
 c itk::PolyLineParametricPath< #dims >
+c cpExtensions::DataStructures::ImageIndexesContainer< #dims >
+
 c cpExtensions::Visualization::PolyLineParametricPathToPolyData< cpExtensions::DataStructures::PolyLineParametricPath< #dims > >
+c cpExtensions::Visualization::ImageIndexesContainerToPolyData< cpExtensions::DataStructures::ImageIndexesContainer< #dims > >