]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Wed, 22 Feb 2017 20:48:49 +0000 (15:48 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Wed, 22 Feb 2017 20:48:49 +0000 (15:48 -0500)
lib/cpExtensions/Algorithms/PolyLineParametricPathWriter.h
lib/cpExtensions/Algorithms/PolyLineParametricPathWriter.hxx
lib/cpInstances/DataObjects/PolyLineParametricPath.cxx
lib/cpInstances/DataObjects/PolyLineParametricPath.h
plugins/cpExtensions/PolyLineParametricPathToPolyData.cxx
plugins/cpExtensions/PolyLineParametricPathToSimple3DCurve.cxx
plugins/cpExtensions/PolyLineParametricPathWriter.cxx
plugins/cpExtensions/PolyLineParametricPathWriter.h
plugins/cpExtensions/cpExtensions.i

index f699602d1583689012a911585f0058e089c51e12..deb6b30e68b1c713968e36cf11d927009226ac36 100644 (file)
@@ -6,6 +6,7 @@
 #define __cpExtensions__Algorithms__PolyLineParametricPathWriter__h__
 
 #include <itkProcessObject.h>
+#include <itkImage.h>
 
 // -------------------------------------------------------------------------
 namespace cpExtensions
@@ -14,7 +15,7 @@ namespace cpExtensions
   {
     /**
      */
-    template< class _TPolyLine >
+    template< class _TPolyLine, class _TImage = itk::Image< unsigned char, _TPolyLine::PathDimension > >
     class PolyLineParametricPathWriter
       : public itk::ProcessObject
     {
@@ -38,6 +39,10 @@ namespace cpExtensions
     public:
       void SetInput( const _TPolyLine* input );
       const _TPolyLine* GetInput( );
+
+      void SetImage( const _TImage* image );
+      const _TImage* GetImage( );
+
       virtual void Update( );
 
     protected:
index 8e9db8eeab926a28e6c1d04bb6226cad0c825045..d71c6e3aa640eb7d2d118b967883edac9ff6c4ac 100644 (file)
@@ -8,8 +8,8 @@
 #include <sstream>
 
 // -------------------------------------------------------------------------
-template< class _TPolyLine >
-void cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine >::
+template< class _TPolyLine, class _TImage >
+void cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >::
 SetInput( const _TPolyLine* input )
 {
   this->itk::ProcessObject::SetNthInput(
@@ -18,9 +18,9 @@ SetInput( const _TPolyLine* input )
 }
 
 // -------------------------------------------------------------------------
-template< class _TPolyLine >
+template< class _TPolyLine, class _TImage >
 const _TPolyLine*
-cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine >::
+cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >::
 GetInput( )
 {
   return(
@@ -31,8 +31,30 @@ GetInput( )
 }
 
 // -------------------------------------------------------------------------
-template< class _TPolyLine >
-void cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine >::
+template< class _TPolyLine, class _TImage >
+void cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >::
+SetImage( const _TImage* image )
+{
+  this->itk::ProcessObject::SetNthInput(
+    1, const_cast< _TImage* >( image )
+    );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPolyLine, class _TImage >
+const _TImage* cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >::
+GetImage( )
+{
+  return(
+    dynamic_cast< const _TImage* >(
+      this->itk::ProcessObject::GetInput( 1 )
+      )
+    );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPolyLine, class _TImage >
+void cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >::
 Update( )
 {
   _TPolyLine* input = const_cast< _TPolyLine* >( this->GetInput( ) );
@@ -47,8 +69,8 @@ Update( )
 }
 
 // -------------------------------------------------------------------------
-template< class _TPolyLine >
-cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine >::
+template< class _TPolyLine, class _TImage >
+cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >::
 PolyLineParametricPathWriter( )
   : Superclass( ),
     m_FileName( "" ),
@@ -58,21 +80,22 @@ PolyLineParametricPathWriter( )
 }
 
 // -------------------------------------------------------------------------
-template< class _TPolyLine >
-cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine >::
+template< class _TPolyLine, class _TImage >
+cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >::
 ~PolyLineParametricPathWriter( )
 {
 }
 
 // -------------------------------------------------------------------------
-template< class _TPolyLine >
-void cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine >::
+template< class _TPolyLine, class _TImage >
+void cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >::
 GenerateData( )
 {
   typedef typename _TPolyLine::TContinuousIndex _TContinuousIndex;
 
   // "Serialize" data
   const _TPolyLine* input = this->GetInput( );
+  const _TImage* image = this->GetImage( );
   unsigned int dim = _TPolyLine::PathDimension;
   std::stringstream buffer;
   long step = input->GetSize( ) / this->m_NumberOfPoints;
@@ -102,6 +125,15 @@ GenerateData( )
     buffer << idx[ 0 ];
     for( unsigned int d = 1; d < dim; ++d )
       buffer << " " << idx[ d ];
+    if( image != NULL )
+    {
+      typename _TImage::PointType pidx;
+      typename _TImage::IndexType iidx;
+      image->TransformContinuousIndexToPhysicalPoint( idx, pidx );
+      image->TransformPhysicalPointToIndex( pidx, iidx );
+      buffer << " " << image->GetPixel( iidx );
+
+    } // fi
     buffer << std::endl;
 
   } // rof
index 488be3886046fc55288ef31aac1b7861a8b4994e..623233f5f23e71d53625fe7bde197b45ead80b1b 100644 (file)
@@ -1,7 +1,7 @@
 #include <cpInstances/DataObjects/PolyLineParametricPath.h>
 
 // -------------------------------------------------------------------------
-void cpInstances::PolyLineParametricPath::
+void cpInstances::DataObjects::PolyLineParametricPath::
 SetITK( itk::LightObject* o )
 {
   this->Superclass::SetITK( o );
@@ -18,20 +18,20 @@ SetITK( itk::LightObject* o )
 }
 
 // -------------------------------------------------------------------------
-void cpInstances::PolyLineParametricPath::
+void cpInstances::DataObjects::PolyLineParametricPath::
 SetVTK( vtkObjectBase* o )
 {
 }
 
 // -------------------------------------------------------------------------
-cpInstances::PolyLineParametricPath::
+cpInstances::DataObjects::PolyLineParametricPath::
 PolyLineParametricPath( )
   : Superclass( )
 {
 }
 
 // -------------------------------------------------------------------------
-cpInstances::PolyLineParametricPath::
+cpInstances::DataObjects::PolyLineParametricPath::
 ~PolyLineParametricPath( )
 {
 }
index 49e30a0e00b95c283a0edd527b6ce3d765369ab0..fff6b6b98480aea4e0f289a8a2a73926b67f4dd6 100644 (file)
@@ -10,36 +10,40 @@ class vtkPolyLineParametricPathData;
 
 namespace cpInstances
 {
-  /**
-   */
-  class cpPluginsDataObjects_EXPORT PolyLineParametricPath
-    : public cpPlugins::Pipeline::DataObject
+  namespace DataObjects
   {
-  public:
-    typedef PolyLineParametricPath             Self;
-    typedef cpPlugins::Pipeline::DataObject Superclass;
-    typedef itk::SmartPointer< Self >          Pointer;
-    typedef itk::SmartPointer< const Self >    ConstPointer;
-
-  public:
-    itkNewMacro( Self );
-    itkTypeMacro( PolyLineParametricPath, cpPlugins::Pipeline::DataObject );
-    cpPlugins_Id_Macro( PolyLineParametricPath, Object );
-    cpPlugins_Compatibility_Macro;
-
-  public:
-    virtual void SetITK( itk::LightObject* o ) override;
-    virtual void SetVTK( vtkObjectBase* o ) override;
-
-  protected:
-    PolyLineParametricPath( );
-    virtual ~PolyLineParametricPath( );
-
-  private:
-    // Purposely not implemented
-    PolyLineParametricPath( const Self& );
-    Self& operator=( const Self& );
-  };
+    /**
+     */
+    class cpPluginsDataObjects_EXPORT PolyLineParametricPath
+      : public cpPlugins::Pipeline::DataObject
+    {
+    public:
+      typedef PolyLineParametricPath             Self;
+      typedef cpPlugins::Pipeline::DataObject Superclass;
+      typedef itk::SmartPointer< Self >          Pointer;
+      typedef itk::SmartPointer< const Self >    ConstPointer;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( PolyLineParametricPath, cpPlugins::Pipeline::DataObject );
+      cpPlugins_Id_Macro( PolyLineParametricPath, Object );
+      cpPlugins_Compatibility_Macro;
+
+    public:
+      virtual void SetITK( itk::LightObject* o ) override;
+      virtual void SetVTK( vtkObjectBase* o ) override;
+
+    protected:
+      PolyLineParametricPath( );
+      virtual ~PolyLineParametricPath( );
+
+    private:
+      // Purposely not implemented
+      PolyLineParametricPath( const Self& );
+      Self& operator=( const Self& );
+    };
+
+  } // ecapseman
 
 } // ecapseman
 
index cd69303a43322dd60c5fa0fde9e53d8a90d557d1..ff3a77e5642e3a54a493ba84d60ad8d5b8d3ba37 100644 (file)
@@ -10,7 +10,7 @@ cpPluginscpExtensions::PolyLineParametricPathToPolyData::
 PolyLineParametricPathToPolyData( )
   : Superclass( )
 {
-  this->_ConfigureInput< cpInstances::PolyLineParametricPath >(
+  this->_ConfigureInput< cpInstances::DataObjects::PolyLineParametricPath >(
     "Input", true, false
     );
   this->_ConfigureOutput< cpInstances::DataObjects::Mesh >( "Output" );
index 7b2b853ebf2a4a538d00763f0aa0ab87afeb536c..92a6d7a4e8f6b860d26b5f6621c84734dd63c608 100644 (file)
@@ -11,7 +11,7 @@ cpPluginscpExtensions::PolyLineParametricPathToSimple3DCurve::
 PolyLineParametricPathToSimple3DCurve( )
   : Superclass( )
 {
-  this->_ConfigureInput< cpInstances::PolyLineParametricPath >(
+  this->_ConfigureInput< cpInstances::DataObjects::PolyLineParametricPath >(
     "Input", true, false
     );
   this->_ConfigureOutput< cpInstances::DataObjects::Simple3DCurve >( "Output" );
index 7ee1be3d55140890801a3d17d4ed85765232817a..400d3eb33761254bc27db56626820e568702c268 100644 (file)
@@ -1,6 +1,8 @@
 #include <cpExtensions/PolyLineParametricPathWriter.h>
+#include <cpInstances/DataObjects/Image.h>
 #include <cpInstances/DataObjects/PolyLineParametricPath.h>
 
+#include <itkImage.h>
 #include <cpExtensions/DataStructures/PolyLineParametricPath.h>
 #include <cpExtensions/Algorithms/PolyLineParametricPathWriter.h>
 #include <cpPlugins/QT/SaveFileDialog.h>
@@ -32,7 +34,8 @@ cpPluginscpExtensions::PolyLineParametricPathWriter::
 PolyLineParametricPathWriter( )
   : Superclass( )
 {
-  this->_ConfigureInput< cpInstances::PolyLineParametricPath >( "Input", true, false );
+  this->_ConfigureInput< cpInstances::DataObjects::PolyLineParametricPath >( "Input", true, false );
+  this->_ConfigureInput< cpInstances::DataObjects::Image >( "Image", false, false );
   this->m_Parameters.ConfigureAsSaveFileName( "FileName", "" );
   this->m_Parameters.SetAcceptedFileExtensions(
     "FileName",
@@ -60,11 +63,22 @@ template< class _TPolyLineParametricPath >
 void cpPluginscpExtensions::PolyLineParametricPathWriter::
 _GD0( _TPolyLineParametricPath* skeleton )
 {
-  typedef cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLineParametricPath > _TWriter;
+  auto o = this->GetInputData( "Image" );
+  cpPlugins_Demangle_Image_ScalarPixels_2( o, _GD1, _TPolyLineParametricPath::PathDimension, skeleton )
+    this->_GD1< itk::Image< unsigned char, _TPolyLineParametricPath::PathDimension >, _TPolyLineParametricPath >( NULL, skeleton );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage, class _TPolyLineParametricPath >
+void cpPluginscpExtensions::PolyLineParametricPathWriter::
+_GD1( _TImage* image, _TPolyLineParametricPath* skeleton )
+{
+  typedef cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLineParametricPath, _TImage > _TWriter;
 
   auto filter = this->_CreateITK< _TWriter >( );
   filter->SetInput( skeleton );
   filter->SetFileName( this->m_Parameters.GetSaveFileName( "FileName" ) );
+  filter->SetImage( image );
   try
   {
     filter->Update( );
index e398b9e3d15834e4513bd15da129814d3fb722cf..6ef00467ff75660a1c359767aaf43cbb1a9cf3ca 100644 (file)
@@ -23,6 +23,9 @@ namespace cpPluginscpExtensions
   protected:
     template< class _TPolyLineParametricPath >
     inline void _GD0( _TPolyLineParametricPath* skeleton );
+
+    template< class _TImage, class _TPolyLineParametricPath >
+    inline void _GD1( _TImage* image, _TPolyLineParametricPath* skeleton );
   };
 
 } // ecapseman
index 4d3e1ea74db7a716f596b7726c15391d850cb36a..8ab94204f9792d11dc80e4d4bf43ac7b543a5d47 100644 (file)
@@ -3,8 +3,12 @@ header #define ITK_MANUAL_INSTANTIATION
 tinclude cpExtensions/Algorithms/SkeletonToImageFilter:h|hxx
 tinclude cpExtensions/Algorithms/SkeletonReader:h|hxx
 tinclude cpExtensions/Algorithms/SkeletonWriter:h|hxx
+tinclude cpExtensions/Algorithms/PolyLineParametricPathWriter:h|hxx
+cinclude cpExtensions/DataStructures/PolyLineParametricPath.h
 cinclude cpExtensions/DataStructures/Skeleton.h
 
+instances cpExtensions::Algorithms::PolyLineParametricPathWriter< cpExtensions::DataStructures::PolyLineParametricPath< #pdims# >, itk::Image< #scalar_types#, #pdims# > >
+
 instances cpExtensions::Algorithms::SkeletonToImageFilter< cpExtensions::DataStructures::Skeleton< #pdims# >, itk::Image< unsigned char, #pdims# > >
 
 instances cpExtensions::Algorithms::SkeletonReader< cpExtensions::DataStructures::Skeleton< #pdims# > >