From: Leonardo Florez-Valencia Date: Mon, 29 Dec 2014 11:50:00 +0000 (+0100) Subject: PolyLineParametricPath data type added X-Git-Tag: v0.1~427 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=4c4b03aa87446a1aa78563fb75cc6d1956d7d64e;p=cpPlugins.git PolyLineParametricPath data type added --- diff --git a/lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.cxx b/lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.cxx new file mode 100644 index 0000000..85c03c1 --- /dev/null +++ b/lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.cxx @@ -0,0 +1,30 @@ +#include + +// ------------------------------------------------------------------------- +std::string cpPlugins::Interface::ImageToPolyLineParametricPathFilter:: +GetClassName( ) const +{ + return( "cpPlugins::Interface::ImageToPolyLineParametricPathFilter" ); +} + +// ------------------------------------------------------------------------- +std::string cpPlugins::Interface::ImageToPolyLineParametricPathFilter:: +GetClassType( ) const +{ + return( "ImageToPolyLineParametricPathFilter" ); +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::ImageToPolyLineParametricPathFilter:: +ImageToPolyLineParametricPathFilter( ) + : Superclass( ) +{ +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::ImageToPolyLineParametricPathFilter:: +~ImageToPolyLineParametricPathFilter( ) +{ +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.h b/lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.h new file mode 100644 index 0000000..1b274cc --- /dev/null +++ b/lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.h @@ -0,0 +1,48 @@ +#ifndef __CPPLUGINS__INTERFACE__IMAGETOPOLYLINEPARAMETRICPATHFILTER__H__ +#define __CPPLUGINS__INTERFACE__IMAGETOPOLYLINEPARAMETRICPATHFILTER__H__ + +#include +#include + +namespace cpPlugins +{ + namespace Interface + { + /** + */ + class cpPlugins_Interface_EXPORT ImageToPolyLineParametricPathFilter + : public FilterObject + { + public: + typedef ImageToPolyLineParametricPathFilter Self; + typedef FilterObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef Superclass::TParameter TParameter; + typedef Superclass::TParameters TParameters; + + public: + itkTypeMacro( ImageToPolyLineParametricPathFilter, FilterObject ); + + public: + virtual std::string GetClassName( ) const; + virtual std::string GetClassType( ) const; + + protected: + ImageToPolyLineParametricPathFilter( ); + virtual ~ImageToPolyLineParametricPathFilter( ); + + private: + // Purposely not implemented + ImageToPolyLineParametricPathFilter( const Self& ); + Self& operator=( const Self& ); + }; + + } // ecapseman + +} // ecapseman + +#endif // __CPPLUGINS__INTERFACE__IMAGETOPOLYLINEPARAMETRICPATHFILTER__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Instances_itkPolyLineParametricPath.cxx b/lib/cpPlugins/Interface/Instances_itkPolyLineParametricPath.cxx new file mode 100644 index 0000000..9c450fd --- /dev/null +++ b/lib/cpPlugins/Interface/Instances_itkPolyLineParametricPath.cxx @@ -0,0 +1,19 @@ +#include +#include +#include + +template class itk::PolyLineParametricPath< 1 >; +template class itk::PolyLineParametricPath< 2 >; +template class itk::PolyLineParametricPath< 3 >; +template class itk::PolyLineParametricPath< 4 >; + +template class +itk::VectorContainer< unsigned int, itk::ContinuousIndex< double, 1 > >; +template class +itk::VectorContainer< unsigned int, itk::ContinuousIndex< double, 2 > >; +template class +itk::VectorContainer< unsigned int, itk::ContinuousIndex< double, 3 > >; +template class +itk::VectorContainer< unsigned int, itk::ContinuousIndex< double, 4 > >; + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/PolyLineParametricPath.cxx b/lib/cpPlugins/Interface/PolyLineParametricPath.cxx new file mode 100644 index 0000000..23fa0c7 --- /dev/null +++ b/lib/cpPlugins/Interface/PolyLineParametricPath.cxx @@ -0,0 +1,107 @@ +#include + +#include +#include + +#define ITK_MANUAL_INSTANTIATION +#include +#include + +// ------------------------------------------------------------------------- +std::string cpPlugins::Interface::PolyLineParametricPath:: +GetClassName( ) const +{ + return( "cpPlugins::Interface::PolyLineParametricPath" ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::Interface::PolyLineParametricPath:: +SetRealDataObject( itk::DataObject* dobj, itk::DataObject* ref_image ) +{ + typedef itk::PolyLineParametricPath< 2 > _T2; + typedef itk::PolyLineParametricPath< 3 > _T3; + + this->Superclass::SetRealDataObject( dobj ); + + if( ref_image != NULL ) + { + if( dynamic_cast< _T2* >( dobj ) != NULL ) + this->_VTK< 2 >( ref_image ); + else if( dynamic_cast< _T3* >( dobj ) != NULL ) + this->_VTK< 3 >( ref_image ); + + } // fi +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::PolyLineParametricPath:: +PolyLineParametricPath( ) + : Superclass( ) +{ + this->m_PolyData = vtkSmartPointer< vtkPolyData >::New( ); +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::PolyLineParametricPath:: +~PolyLineParametricPath( ) +{ +} + +// ------------------------------------------------------------------------- +template< unsigned int D > +void cpPlugins::Interface::PolyLineParametricPath:: +_VTK( itk::DataObject* ref_image ) +{ + typedef itk::PolyLineParametricPath< D > _TPath; + typedef typename _TPath::VertexListType _TVertices; + typedef typename _TPath::ContinuousIndexType _TIndex; + typedef itk::ImageBase< D > _TImage; + typedef typename _TImage::PointType _TPoint; + + _TPath* path = + dynamic_cast< _TPath* >( this->m_RealDataObject.GetPointer( ) ); + if( path == NULL ) + return; + const _TVertices* vertices = path->GetVertexList( ); + if( vertices == NULL ) + return; + const _TImage* image = dynamic_cast< const _TImage* >( ref_image ); + + vtkSmartPointer< vtkPoints > points = + vtkSmartPointer< vtkPoints >::New( ); + vtkSmartPointer< vtkCellArray > lines = + vtkSmartPointer< vtkCellArray >::New( ); + double x, y, z; + for( unsigned int i = 0; i < vertices->Size( ); ++i ) + { + _TIndex idx = vertices->GetElement( i ); + if( image != NULL ) + { + _TPoint pnt; + image->TransformContinuousIndexToPhysicalPoint( idx, pnt ); + x = double( pnt[ 0 ] ); + y = double( pnt[ 1 ] ); + z = ( D == 3 )? double( pnt[ 2 ] ): double( 0 ); + } + else + { + x = double( idx[ 0 ] ); + y = double( idx[ 1 ] ); + z = ( D == 3 )? double( idx[ 2 ] ): double( 0 ); + + } // fi + points->InsertNextPoint( x, y, z ); + if( i > 0 ) + { + lines->InsertNextCell( 2 ); + lines->InsertCellPoint( i - 1 ); + lines->InsertCellPoint( i ); + + } // fi + + } // rof + this->m_PolyData->SetPoints( points ); + this->m_PolyData->SetLines( lines ); +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/PolyLineParametricPath.h b/lib/cpPlugins/Interface/PolyLineParametricPath.h new file mode 100644 index 0000000..0c3268b --- /dev/null +++ b/lib/cpPlugins/Interface/PolyLineParametricPath.h @@ -0,0 +1,61 @@ +#ifndef __CPPLUGINS__INTERFACE__POLYLINEPARAMETRICPATH__H__ +#define __CPPLUGINS__INTERFACE__POLYLINEPARAMETRICPATH__H__ + +#include +#include +#include +#include +#include + +#include +#include + +namespace cpPlugins +{ + namespace Interface + { + /** + */ + class cpPlugins_Interface_EXPORT PolyLineParametricPath + : public DataObject + { + public: + typedef PolyLineParametricPath Self; + typedef DataObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( PolyLineParametricPath, DataObject ); + + public: + virtual std::string GetClassName( ) const; + virtual void SetRealDataObject( + itk::DataObject* dobj, + itk::DataObject* ref_image = NULL + ); + + protected: + PolyLineParametricPath( ); + virtual ~PolyLineParametricPath( ); + + template< unsigned int D > + void _VTK( itk::DataObject* ref_image ); + + private: + // Purposely not implemented + PolyLineParametricPath( const Self& ); + Self& operator=( const Self& ); + + protected: + vtkSmartPointer< vtkPolyData > m_PolyData; + }; + + } // ecapseman + +} // ecapseman + +#endif // __CPPLUGINS__INTERFACE__POLYLINEPARAMETRICPATH__H__ + +// eof - $RCSfile$