From e8aa06dcf9c9fe4391ece860ffd2d4e9c80e289d Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Wed, 6 Apr 2016 17:45:25 -0500 Subject: [PATCH] PolyLineParametricPath support added --- cmake/cpPluginsConfig.cmake.in | 45 ++++++++------ .../DataStructures/PolyLineParametricPath.h | 62 +++++++++++++++++++ .../PolyLineParametricPathToPolyData.hxx | 15 +++-- lib/cpPlugins/Path.cxx | 39 ++++++++++++ lib/cpPlugins/Path.h | 53 ++++++++++++++++ lib/cpPlugins/Path.hxx | 44 +++++++++++++ lib/cpPlugins_Instances/CMakeLists.txt | 2 +- lib/cpPlugins_Instances/Paths.i | 4 ++ 8 files changed, 238 insertions(+), 26 deletions(-) create mode 100644 lib/cpExtensions/DataStructures/PolyLineParametricPath.h create mode 100644 lib/cpPlugins/Path.cxx create mode 100644 lib/cpPlugins/Path.h create mode 100644 lib/cpPlugins/Path.hxx diff --git a/cmake/cpPluginsConfig.cmake.in b/cmake/cpPluginsConfig.cmake.in index b467890..b612b9d 100644 --- a/cmake/cpPluginsConfig.cmake.in +++ b/cmake/cpPluginsConfig.cmake.in @@ -99,25 +99,30 @@ SET(cpPipelineEditor_LIBRARY cpPipelineEditor) # ====================== # -- Executable names -- # ====================== - -IF(MSVC) - FIND_PROGRAM( - cpPlugins_HostCreator_APP - NAMES cpPlugins_HostCreator - HINTS /usr /usr/local - PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@/Debug @PROJECT_BINARY_DIR@/Release @PROJECT_BINARY_DIR@/MinSizeRel @PROJECT_BINARY_DIR@/RelWithDebInfo - PATH_SUFFIXES bin sbin - DOC "Where is cpPlugins_HostCreator?" - ) -ELSE(MSVC) - FIND_PROGRAM( - cpPlugins_HostCreator_APP - NAMES cpPlugins_HostCreator - HINTS /usr /usr/local - PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@ - PATH_SUFFIXES bin sbin - DOC "Where is cpPlugins_HostCreator?" - ) -ENDIF(MSVC) +SET( + exec_PROGRAMS + cpPlugins_CreateInstances + cpPlugins_HostCreator + ) +FOREACH(prog ${exec_PROGRAMS}) + IF(MSVC) + FIND_PROGRAM( + NAMES ${prog} + HINTS /usr /usr/local + PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@/Debug @PROJECT_BINARY_DIR@/Release @PROJECT_BINARY_DIR@/MinSizeRel @PROJECT_BINARY_DIR@/RelWithDebInfo + PATH_SUFFIXES bin sbin + DOC "Where is ${prog}?" + ) + ELSE(MSVC) + FIND_PROGRAM( + ${prog} + NAMES ${prog} + HINTS /usr /usr/local + PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@ + PATH_SUFFIXES bin sbin + DOC "Where is ${prog}?" + ) + ENDIF(MSVC) +ENDFOREACH(prog) ## eof - $RCSfile$ diff --git a/lib/cpExtensions/DataStructures/PolyLineParametricPath.h b/lib/cpExtensions/DataStructures/PolyLineParametricPath.h new file mode 100644 index 0000000..77828ee --- /dev/null +++ b/lib/cpExtensions/DataStructures/PolyLineParametricPath.h @@ -0,0 +1,62 @@ +#ifndef __CPEXTENSIONS__DATASTRUCTURES__POLYLINEPARAMETRICPATH__H__ +#define __CPEXTENSIONS__DATASTRUCTURES__POLYLINEPARAMETRICPATH__H__ + +#include +#include + +namespace cpExtensions +{ + namespace DataStructures + { + /** + */ + template< unsigned int _NDim > + class PolyLineParametricPath + : public itk::PolyLineParametricPath< _NDim > + { + public: + typedef PolyLineParametricPath Self; + typedef itk::PolyLineParametricPath< _NDim > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef itk::ImageBase< _NDim > TImageBase; + + public: + itkNewMacro( Self ); + itkTypeMacro( PolyLineParametricPath, itk::PolyLineParametricPath ); + + 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: + PolyLineParametricPath( ) { } + virtual ~PolyLineParametricPath( ) { } + + private: + // Purposely not implemented + PolyLineParametricPath( const Self& other ); + Self& operator=( const Self& other ); + + protected: + typename TImageBase::Pointer m_ReferenceImage; + }; + + } // ecapseman + +} // ecapseman + +#endif // __CPEXTENSIONS__DATASTRUCTURES__POLYLINEPARAMETRICPATH__H__ + +// eof - $RCSfile$ diff --git a/lib/cpExtensions/Visualization/PolyLineParametricPathToPolyData.hxx b/lib/cpExtensions/Visualization/PolyLineParametricPathToPolyData.hxx index 131c32e..1c17463 100644 --- a/lib/cpExtensions/Visualization/PolyLineParametricPathToPolyData.hxx +++ b/lib/cpExtensions/Visualization/PolyLineParametricPathToPolyData.hxx @@ -3,6 +3,7 @@ #include #include +#include // ------------------------------------------------------------------------- template< class _TPolyLine > @@ -119,8 +120,10 @@ RequestData( points->SetNumberOfPoints( lst->Size( ) ); // Prepare cells - vtkSmartPointer< vtkCellArray > verts = - vtkSmartPointer< vtkCellArray >::New( ); + /* TODO + vtkSmartPointer< vtkCellArray > verts = + vtkSmartPointer< vtkCellArray >::New( ); + */ vtkSmartPointer< vtkCellArray > lines = vtkSmartPointer< vtkCellArray >::New( ); @@ -148,8 +151,10 @@ RequestData( points->SetPoint( i, idx[ 0 ], idx[ 1 ], idx[ 2 ] ); } // fi - verts->InsertNextCell( 1 ); - verts->InsertCellPoint( i ); + /* TODO + verts->InsertNextCell( 1 ); + verts->InsertCellPoint( i ); + */ if( i > 0 ) { lines->InsertNextCell( 2 ); @@ -160,7 +165,7 @@ RequestData( } // rof out->SetPoints( points ); - out->SetVerts( verts ); + // TODO: out->SetVerts( verts ); out->SetLines( lines ); return( 1 ); } diff --git a/lib/cpPlugins/Path.cxx b/lib/cpPlugins/Path.cxx new file mode 100644 index 0000000..5f58269 --- /dev/null +++ b/lib/cpPlugins/Path.cxx @@ -0,0 +1,39 @@ +#include + +// ------------------------------------------------------------------------- +void cpPlugins::Path:: +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::Path:: +SetVTK( vtkObjectBase* o ) +{ + // Do nothing +} + +// ------------------------------------------------------------------------- +cpPlugins::Path:: +Path( ) + : Superclass( ) +{ +} + +// ------------------------------------------------------------------------- +cpPlugins::Path:: +~Path( ) +{ +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Path.h b/lib/cpPlugins/Path.h new file mode 100644 index 0000000..d7aa111 --- /dev/null +++ b/lib/cpPlugins/Path.h @@ -0,0 +1,53 @@ +#ifndef __CPPLUGINS__PATH__H__ +#define __CPPLUGINS__PATH__H__ + +#include + +#include +#include + +namespace cpPlugins +{ + /** + */ + class cpPlugins_EXPORT Path + : public DataObject + { + public: + typedef Path Self; + typedef DataObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( Path, DataObject ); + cpPlugins_Id_Macro( Path, Object ); + + public: + virtual void SetITK( itk::LightObject* o ) ITK_OVERRIDE; + virtual void SetVTK( vtkObjectBase* o ) ITK_OVERRIDE; + + protected: + Path( ); + virtual ~Path( ); + + template< unsigned int _NDim > + inline bool _ITK_2_VTK( itk::LightObject* o ); + + private: + // Purposely not implemented + Path( const Self& ); + Self& operator=( const Self& ); + + protected: + vtkSmartPointer< vtkPolyDataAlgorithm > m_ITKvVTK; + }; + +} // ecapseman + +#include + +#endif // __CPPLUGINS__PATH__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Path.hxx b/lib/cpPlugins/Path.hxx new file mode 100644 index 0000000..b6fb093 --- /dev/null +++ b/lib/cpPlugins/Path.hxx @@ -0,0 +1,44 @@ +#ifndef __CPPLUGINS__PATH__HXX__ +#define __CPPLUGINS__PATH__HXX__ + +#include + +// ------------------------------------------------------------------------- +template< unsigned int _NDim > +bool cpPlugins::Path:: +_ITK_2_VTK( itk::LightObject* o ) +{ + typedef + cpExtensions::DataStructures::PolyLineParametricPath< _NDim > + _TPath; + typedef + cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPath > + _TFilter; + + auto path = dynamic_cast< _TPath* >( o ); + if( path != 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( path ); + f->SetReferenceImage( path->GetReferenceImage( ) ); + f->Update( ); + + // Keep object track + this->m_ITKObject = o; + this->m_VTKObject = f->GetOutput( ); + return( true ); + } + else + return( false ); +} + +#endif // __CPPLUGINS__PATH__HXX__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins_Instances/CMakeLists.txt b/lib/cpPlugins_Instances/CMakeLists.txt index 2bbc988..f040a22 100644 --- a/lib/cpPlugins_Instances/CMakeLists.txt +++ b/lib/cpPlugins_Instances/CMakeLists.txt @@ -46,7 +46,7 @@ SET( ## Target links TARGET_LINK_LIBRARIES(cpPlugins_Base ${ITK_LIBRARIES}) TARGET_LINK_LIBRARIES(cpPlugins_Transforms ${ITK_LIBRARIES} cpPlugins_Base) -TARGET_LINK_LIBRARIES(cpPlugins_Paths cpPlugins_Base) +TARGET_LINK_LIBRARIES(cpPlugins_Paths cpPlugins_Base ${VTK_LIBRARIES}) TARGET_LINK_LIBRARIES(cpPlugins_Mesh cpPlugins_Base) TARGET_LINK_LIBRARIES(cpPlugins_Image cpPlugins_Base) TARGET_LINK_LIBRARIES(cpPlugins_ImageIterators ${ITK_LIBRARIES} cpPlugins_Image) diff --git a/lib/cpPlugins_Instances/Paths.i b/lib/cpPlugins_Instances/Paths.i index 36f6ef4..03d83f9 100644 --- a/lib/cpPlugins_Instances/Paths.i +++ b/lib/cpPlugins_Instances/Paths.i @@ -1,10 +1,14 @@ f cpPlugins_Instances/Base.h +i cpExtensions/DataStructures/PolyLineParametricPath.h t itkPolyLineParametricPath.h t itkPath.h t itkParametricPath.h t itkVectorContainer.h +t cpExtensions/Visualization/PolyLineParametricPathToPolyData.h d #dims=2;3 c itk::PolyLineParametricPath< #dims > +c cpExtensions::Visualization::PolyLineParametricPathToPolyData< cpExtensions::DataStructures::PolyLineParametricPath< #dims > > + -- 2.47.1