From eb7e1229343f1d74c24a4008aae1425180bb95c8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Tue, 18 Oct 2016 18:00:33 -0500 Subject: [PATCH] ... --- lib/cpExtensions/DataStructures/Graph.h | 8 +- .../Visualization/SkeletonToPolyData.cxx | 2 +- .../DataObjects/PolyLineParametricPath.cxx | 13 +++- lib/cpPlugins/DataObjects/Skeleton.cxx | 77 +++++++++++++++++++ lib/cpPlugins/DataObjects/Skeleton.h | 61 +++++++++++++++ 5 files changed, 152 insertions(+), 9 deletions(-) create mode 100644 lib/cpPlugins/DataObjects/Skeleton.cxx create mode 100644 lib/cpPlugins/DataObjects/Skeleton.h diff --git a/lib/cpExtensions/DataStructures/Graph.h b/lib/cpExtensions/DataStructures/Graph.h index ed2d6ae..d9e913d 100644 --- a/lib/cpExtensions/DataStructures/Graph.h +++ b/lib/cpExtensions/DataStructures/Graph.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace cpExtensions @@ -20,11 +20,11 @@ namespace cpExtensions */ template< class _TVertex, class _TCost, class _TIndex = unsigned long, class _TIndexCompare = std::less< _TIndex > > class Graph - : public itk::LightObject + : public itk::DataObject { public: typedef Graph Self; - typedef itk::LightObject Superclass; + typedef itk::DataObject Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; @@ -41,7 +41,7 @@ namespace cpExtensions public: itkNewMacro( Self ); - itkTypeMacro( Graph, itk::LightObject ); + itkTypeMacro( Graph, itk::DataObject ); public: /*! \brief Iterators over vertices. diff --git a/lib/cpExtensions/Visualization/SkeletonToPolyData.cxx b/lib/cpExtensions/Visualization/SkeletonToPolyData.cxx index 8f5f4db..5aa7d20 100644 --- a/lib/cpExtensions/Visualization/SkeletonToPolyData.cxx +++ b/lib/cpExtensions/Visualization/SkeletonToPolyData.cxx @@ -109,8 +109,8 @@ RequestData( if( i > 0 ) { lines->InsertNextCell( 2 ); + lines->InsertCellPoint( points->GetNumberOfPoints( ) - 2 ); lines->InsertCellPoint( points->GetNumberOfPoints( ) - 1 ); - lines->InsertCellPoint( points->GetNumberOfPoints( ) ); } // fi diff --git a/lib/cpPlugins/DataObjects/PolyLineParametricPath.cxx b/lib/cpPlugins/DataObjects/PolyLineParametricPath.cxx index 82e9957..cafafb9 100644 --- a/lib/cpPlugins/DataObjects/PolyLineParametricPath.cxx +++ b/lib/cpPlugins/DataObjects/PolyLineParametricPath.cxx @@ -5,11 +5,16 @@ void cpPlugins::DataObjects::PolyLineParametricPath:: SetITK( itk::LightObject* o ) { + typedef cpExtensions::DataStructures::PolyLineParametricPath< 1 > _T1; + typedef cpExtensions::DataStructures::PolyLineParametricPath< 2 > _T2; + typedef cpExtensions::DataStructures::PolyLineParametricPath< 3 > _T3; + typedef cpExtensions::DataStructures::PolyLineParametricPath< 4 > _T4; + this->Superclass::SetITK( o ); - auto l1 = dynamic_cast< cpExtensions::DataStructures::PolyLineParametricPath< 1 >* >( o ); - auto l2 = dynamic_cast< cpExtensions::DataStructures::PolyLineParametricPath< 2 >* >( o ); - auto l3 = dynamic_cast< cpExtensions::DataStructures::PolyLineParametricPath< 3 >* >( o ); - auto l4 = dynamic_cast< cpExtensions::DataStructures::PolyLineParametricPath< 4 >* >( o ); + auto l1 = dynamic_cast< _T1* >( o ); + auto l2 = dynamic_cast< _T2* >( o ); + auto l3 = dynamic_cast< _T3* >( o ); + auto l4 = dynamic_cast< _T4* >( o ); if ( l1 != NULL ) this->_ITK_2_VTK( l1 ); else if( l2 != NULL ) this->_ITK_2_VTK( l2 ); else if( l3 != NULL ) this->_ITK_2_VTK( l3 ); diff --git a/lib/cpPlugins/DataObjects/Skeleton.cxx b/lib/cpPlugins/DataObjects/Skeleton.cxx new file mode 100644 index 0000000..52d3f3c --- /dev/null +++ b/lib/cpPlugins/DataObjects/Skeleton.cxx @@ -0,0 +1,77 @@ +#include +#include + +// ------------------------------------------------------------------------- +void cpPlugins::DataObjects::Skeleton:: +SetITK( itk::LightObject* o ) +{ + typedef cpExtensions::DataStructures::Skeleton< 1 > _T1; + typedef cpExtensions::DataStructures::Skeleton< 2 > _T2; + typedef cpExtensions::DataStructures::Skeleton< 3 > _T3; + typedef cpExtensions::DataStructures::Skeleton< 4 > _T4; + + this->Superclass::SetITK( o ); + auto l1 = dynamic_cast< _T1* >( o ); + auto l2 = dynamic_cast< _T2* >( o ); + auto l3 = dynamic_cast< _T3* >( o ); + auto l4 = dynamic_cast< _T4* >( o ); + if ( l1 != NULL ) this->_ITK_2_VTK( l1 ); + else if( l2 != NULL ) this->_ITK_2_VTK( l2 ); + else if( l3 != NULL ) this->_ITK_2_VTK( l3 ); + else if( l4 != NULL ) this->_ITK_2_VTK( l4 ); + else + { + this->m_VTK = NULL; + this->m_ITKvVTK = NULL; + + } // fi +} + +// ------------------------------------------------------------------------- +void cpPlugins::DataObjects::Skeleton:: +SetVTK( vtkObjectBase* o ) +{ + // Do nothing + this->m_ITK = NULL; + this->m_VTK = NULL; + this->m_ITKvVTK = NULL; +} + +// ------------------------------------------------------------------------- +cpPlugins::DataObjects::Skeleton:: +Skeleton( ) + : Superclass( ) +{ +} + +// ------------------------------------------------------------------------- +cpPlugins::DataObjects::Skeleton:: +~Skeleton( ) +{ +} + +// ------------------------------------------------------------------------- +template< class _TSkeleton > +void cpPlugins::DataObjects::Skeleton:: +_ITK_2_VTK( _TSkeleton* sk ) +{ + typedef + cpExtensions::Visualization::SkeletonToPolyData< _TSkeleton > + _TFilter; + _TFilter* f = dynamic_cast< _TFilter* >( this->m_ITKvVTK.GetPointer( ) ); + if( f == NULL ) + { + _TFilter* nf = _TFilter::New( ); + this->m_ITKvVTK = nf; + f = nf; + + } // fi + f->SetInput( sk ); + f->Update( ); + + // Keep object track + this->m_ITK = sk; + this->m_VTK = f->GetOutput( ); +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/DataObjects/Skeleton.h b/lib/cpPlugins/DataObjects/Skeleton.h new file mode 100644 index 0000000..153635c --- /dev/null +++ b/lib/cpPlugins/DataObjects/Skeleton.h @@ -0,0 +1,61 @@ +#ifndef __cpPlugins__DataObjects__Skeleton__h__ +#define __cpPlugins__DataObjects__Skeleton__h__ + +#include +#include +#include + +// ------------------------------------------------------------------------- +class vtkPolyDataAlgorithm; + +// ------------------------------------------------------------------------- +namespace cpPlugins +{ + namespace DataObjects + { + /** + */ + class cpPlugins_EXPORT Skeleton + : public cpPlugins::BaseObjects::DataObject + { + public: + typedef Skeleton Self; + typedef cpPlugins::BaseObjects::DataObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( + Skeleton, cpPlugins::BaseObjects::DataObject + ); + cpPlugins_Id_Macro( Skeleton, Object ); + cpPlugins_Compatibility_Macro; + + public: + virtual void SetITK( itk::LightObject* o ) cpPlugins_OVERRIDE; + virtual void SetVTK( vtkObjectBase* o ) cpPlugins_OVERRIDE; + + protected: + Skeleton( ); + virtual ~Skeleton( ); + + template< class _TSkeleton > + inline void _ITK_2_VTK( _TSkeleton* sk ); + + private: + // Purposely not implemented + Skeleton( const Self& ); + Self& operator=( const Self& ); + + protected: + vtkSmartPointer< vtkPolyDataAlgorithm > m_ITKvVTK; + }; + + } // ecapseman + +} // ecapseman + +#endif // __cpPlugins__DataObjects__Skeleton__h__ + +// eof - $RCSfile$ -- 2.45.0