#define __cpExtensions__Algorithms__PolyLineParametricPathWriter__h__
#include <itkProcessObject.h>
+#include <itkImage.h>
// -------------------------------------------------------------------------
namespace cpExtensions
{
/**
*/
- template< class _TPolyLine >
+ template< class _TPolyLine, class _TImage = itk::Image< unsigned char, _TPolyLine::PathDimension > >
class PolyLineParametricPathWriter
: public itk::ProcessObject
{
public:
void SetInput( const _TPolyLine* input );
const _TPolyLine* GetInput( );
+
+ void SetImage( const _TImage* image );
+ const _TImage* GetImage( );
+
virtual void Update( );
protected:
#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(
}
// -------------------------------------------------------------------------
-template< class _TPolyLine >
+template< class _TPolyLine, class _TImage >
const _TPolyLine*
-cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine >::
+cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >::
GetInput( )
{
return(
}
// -------------------------------------------------------------------------
-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( ) );
}
// -------------------------------------------------------------------------
-template< class _TPolyLine >
-cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine >::
+template< class _TPolyLine, class _TImage >
+cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >::
PolyLineParametricPathWriter( )
: Superclass( ),
m_FileName( "" ),
}
// -------------------------------------------------------------------------
-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;
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
#include <cpInstances/DataObjects/PolyLineParametricPath.h>
// -------------------------------------------------------------------------
-void cpInstances::PolyLineParametricPath::
+void cpInstances::DataObjects::PolyLineParametricPath::
SetITK( itk::LightObject* o )
{
this->Superclass::SetITK( o );
}
// -------------------------------------------------------------------------
-void cpInstances::PolyLineParametricPath::
+void cpInstances::DataObjects::PolyLineParametricPath::
SetVTK( vtkObjectBase* o )
{
}
// -------------------------------------------------------------------------
-cpInstances::PolyLineParametricPath::
+cpInstances::DataObjects::PolyLineParametricPath::
PolyLineParametricPath( )
: Superclass( )
{
}
// -------------------------------------------------------------------------
-cpInstances::PolyLineParametricPath::
+cpInstances::DataObjects::PolyLineParametricPath::
~PolyLineParametricPath( )
{
}
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
PolyLineParametricPathToPolyData( )
: Superclass( )
{
- this->_ConfigureInput< cpInstances::PolyLineParametricPath >(
+ this->_ConfigureInput< cpInstances::DataObjects::PolyLineParametricPath >(
"Input", true, false
);
this->_ConfigureOutput< cpInstances::DataObjects::Mesh >( "Output" );
PolyLineParametricPathToSimple3DCurve( )
: Superclass( )
{
- this->_ConfigureInput< cpInstances::PolyLineParametricPath >(
+ this->_ConfigureInput< cpInstances::DataObjects::PolyLineParametricPath >(
"Input", true, false
);
this->_ConfigureOutput< cpInstances::DataObjects::Simple3DCurve >( "Output" );
#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>
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",
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( );
protected:
template< class _TPolyLineParametricPath >
inline void _GD0( _TPolyLineParametricPath* skeleton );
+
+ template< class _TImage, class _TPolyLineParametricPath >
+ inline void _GD1( _TImage* image, _TPolyLineParametricPath* skeleton );
};
} // ecapseman
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# > >