From b07ef139fe5264b87e1f95dc43671ef5705eb3f7 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Thu, 1 Oct 2015 17:18:18 -0500 Subject: [PATCH] Plugin system is now instalable. Dependency to boost eliminated. --- CMakeLists.txt | 6 - appli/ImageMPR/ImageMPR.cxx | 6 - appli/bash/CMakeLists.txt | 1 - appli/bash/cpPlugins_createHost.cxx | 34 +++- cmake/cpPluginsConfig.cmake.in | 9 + .../SecondRankDiffusionTensorToPolyData.cxx | 181 ------------------ .../SecondRankDiffusionTensorToPolyData.h | 53 ----- .../SecondRankDiffusionTensorToPolyData.cxx | 82 -------- .../SecondRankDiffusionTensorToPolyData.h | 55 ------ 9 files changed, 37 insertions(+), 390 deletions(-) delete mode 100644 lib/cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.cxx delete mode 100644 lib/cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.h delete mode 100644 lib/cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.cxx delete mode 100644 lib/cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d1ed48a..83c4b84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,12 +50,6 @@ ENDIF(BUILD_SHARED_LIBRARIES) # Prepare header to build shared libs (windows) INCLUDE(GenerateExportHeader) -# Find boost -FIND_PACKAGE(Boost 1.30 COMPONENTS filesystem system REQUIRED) -IF(Boost_FOUND) - INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) -ENDIF(Boost_FOUND) - # Find ITK and VTK FIND_PACKAGE(ITK REQUIRED) FIND_PACKAGE(VTK REQUIRED) diff --git a/appli/ImageMPR/ImageMPR.cxx b/appli/ImageMPR/ImageMPR.cxx index f9613cb..5951d1f 100644 --- a/appli/ImageMPR/ImageMPR.cxx +++ b/appli/ImageMPR/ImageMPR.cxx @@ -298,7 +298,6 @@ _triggered_actionOpenSegmentation( ) void ImageMPR:: _triggered_actionOpenInputPolyData( ) { - /* // Show dialog and check if it was accepted QFileDialog dialog( this ); dialog.setFileMode( QFileDialog::ExistingFile ); @@ -360,14 +359,12 @@ _triggered_actionOpenInputPolyData( ) tr( "Error reading mesh" ), tr( err.c_str( ) ) ); - */ } // ------------------------------------------------------------------------- void ImageMPR:: _triggered_actionImageToImage( ) { - /* if( this->m_InputImage.IsNull( ) ) return; @@ -407,14 +404,12 @@ _triggered_actionImageToImage( ) tr( "Error executing filter" ), tr( err.c_str( ) ) ); - */ } // ------------------------------------------------------------------------- void ImageMPR:: _triggered_actionImageToMesh( ) { - /* if( this->m_InputImage.IsNull( ) ) return; @@ -456,7 +451,6 @@ _triggered_actionImageToMesh( ) tr( "Error executing filter" ), tr( err.c_str( ) ) ); - */ } // eof - $RCSfile$ diff --git a/appli/bash/CMakeLists.txt b/appli/bash/CMakeLists.txt index 33785d1..da6d729 100644 --- a/appli/bash/CMakeLists.txt +++ b/appli/bash/CMakeLists.txt @@ -9,7 +9,6 @@ SET( FOREACH(prog ${BASH_PROGRAMS}) ADD_EXECUTABLE(${prog} ${prog}.cxx) - TARGET_LINK_LIBRARIES(${prog} ${Boost_LIBRARIES}) ENDFOREACH(prog) ## eof - $RCSfile$ diff --git a/appli/bash/cpPlugins_createHost.cxx b/appli/bash/cpPlugins_createHost.cxx index 0914cca..6f8214d 100644 --- a/appli/bash/cpPlugins_createHost.cxx +++ b/appli/bash/cpPlugins_createHost.cxx @@ -1,9 +1,35 @@ +#include #include #include #include -#include +// ------------------------------------------------------------------------- +std::string GetFileName( const std::string& path ) +{ + // Extract filename + char* buffer = new char[ path.size( ) + 1 ]; + std::memcpy( buffer, path.c_str( ), path.size( ) ); + buffer[ path.size( ) ] = '\0'; + char* tok = std::strtok( buffer, "/\\" ); + char* ptr_fname = tok; + while( tok != NULL ) + { + ptr_fname = tok; + tok = std::strtok( NULL, "/\\" ); + } // elihw + std::string fname( ptr_fname ); + delete [] buffer; + + // Delete extension + std::size_t pos = fname.find_last_of( "." ); + if( pos != std::string::npos ) + fname = fname.substr( 0, pos ); + + return( fname ); +} + +// ------------------------------------------------------------------------- int main( int argc, char* argv[] ) { // Open file @@ -37,16 +63,12 @@ int main( int argc, char* argv[] ) << " using namespace " << argv[ 2 ] << ";" << std::endl; for( int i = 3; i < argc; ++i ) - { - boost::filesystem::path p( argv[ i ] ); output_code << " host.add( new " - << p.stem( ).generic_string( ) + << GetFileName( argv[ i ] ) << "Provider( ) );" << std::endl; - } // rof - output_code << " return( true );" << std::endl << "}" << std::endl; diff --git a/cmake/cpPluginsConfig.cmake.in b/cmake/cpPluginsConfig.cmake.in index df933c7..8c2e0a8 100644 --- a/cmake/cpPluginsConfig.cmake.in +++ b/cmake/cpPluginsConfig.cmake.in @@ -46,4 +46,13 @@ SET(cpExtensions_LIBRARY cpExtensions) SET(cpPlugins_Interface_LIBRARY cpPlugins_Interface) SET(cpPlugins_LIBRARY cpPlugins) +# ====================== +# -- Executable names -- +# ====================== + +SET( + cpPlugins_createHost_APP + @PROJECT_BINARY_DIR@/cpPlugins_createHost + ) + ## eof - $RCSfile$ diff --git a/lib/cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.cxx b/lib/cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.cxx deleted file mode 100644 index 0645898..0000000 --- a/lib/cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.cxx +++ /dev/null @@ -1,181 +0,0 @@ -// ------------------------------------------------------------------------- -// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) -// ------------------------------------------------------------------------- - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -template< class I > -typename cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >:: -Self* cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >:: -New( ) -{ - return( new Self ); -} - -// ------------------------------------------------------------------------- -template< class I > -void cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >:: -SetInputData( const I* image ) -{ - this->m_ITKImage = image; - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class I > -cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >:: -SecondRankDiffusionTensorToPolyData( ) - : vtkPolyDataAlgorithm( ) -{ - this->SetNumberOfInputPorts( 0 ); -} - -// ------------------------------------------------------------------------- -template< class I > -cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >:: -~SecondRankDiffusionTensorToPolyData( ) -{ -} - -// ------------------------------------------------------------------------- -template< class I > -int cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >:: -RequestData( - vtkInformation* request, - vtkInformationVector** inputVector, - vtkInformationVector* outputVector - ) -{ - if( this->m_ITKImage.IsNull( ) ) - return( 0 ); - - // get the info objects - vtkInformation* outInfo = outputVector->GetInformationObject( 0 ); - vtkPolyData* polyData = vtkPolyData::SafeDownCast( - outInfo->Get(vtkDataObject::DATA_OBJECT()) - ); - - itk::ImageRegionConstIteratorWithIndex< I > tensorIt( this->m_ITKImage, this->m_ITKImage->GetRequestedRegion() ); - - vtkSmartPointer points = vtkSmartPointer::New(); - vtkSmartPointer vtkTensors = vtkSmartPointer::New(); - vtkTensors->SetNumberOfComponents(9); - for ( tensorIt.GoToBegin(); !tensorIt.IsAtEnd(); ++tensorIt ) - { - typename I::IndexType tensorIndex = tensorIt.GetIndex(); - typename I::PixelType tensor = tensorIt.Get(); - typename I::PointType ptensor; - - // TODO: std::cout << "\n Index [" << tensorIndex[0] << ", " << tensorIndex[1] << ", " << tensorIndex[2] << "]" << std::endl; - this->m_ITKImage->TransformIndexToPhysicalPoint( tensorIndex, ptensor ); - vtkIdType vtkPointID = points->InsertNextPoint(ptensor[0], ptensor[1], ptensor[2]); - - /** - * Definition included in cdifTypes. - * typedef itk::SymmetricSecondRankTensor< double > Diffusion2ndRankTensor; - */ - //Diffusion2ndRankTensor Diffusion2ndRankTensor; - - - /** - * SYMMETRIC SECOND RANK TENSOR - * - * The upper-right triangle of the matrix: - * - * | 0 1 2 | - * | X 3 4 | - * | X X 5 | - * - * | xx xy xz | - * | X yy yz | - * | X X zz | - */ - /* - Diffusion2ndRankTensor = tensor[0]; - Diffusion2ndRankTensor = tensor[1]; - Diffusion2ndRankTensor = tensor[2]; - Diffusion2ndRankTensor = tensor[3]; - Diffusion2ndRankTensor = tensor[4]; - Diffusion2ndRankTensor = tensor[5]; - */ - typename I::PixelType::EigenValuesArrayType evalues; - typename I::PixelType::EigenVectorsMatrixType evectors; - - /** - * Return an array containing EigenValues, - * and a matrix containing Eigenvectors. - */ - tensor.ComputeEigenAnalysis(evalues, evectors); - - /* - std::cout << "[C-DIFFUSION - NRRD Tensors Example] Eigen values: " << evalues[0] << ", " << evalues[1] << ", " << evalues[2] << std::endl; - - std::cout << "[C-DIFFUSION - NRRD Tensors Example] Eigen vectors: " - - << "(" << evectors(0,0) << ", " << evectors(0,1) << ", " << evectors(0,2) << "), " - << "(" << evectors(1,0) << ", " << evectors(1,1) << ", " << evectors(1,2) << "), " - << "(" << evectors(2,0) << ", " << evectors(2,1) << ", " << evectors(2,2) << ")" << std::endl; - */ - evectors.GetVnlMatrix().scale_row(0, evalues[0]); - evectors.GetVnlMatrix().scale_row(1, evalues[1]); - evectors.GetVnlMatrix().scale_row(2, evalues[2]); - - /* - std::cout << "[C-DIFFUSION - NRRD Tensors Example] Eigen values x Eigen vectors : " - - << "(" << evectors(0,0) << ", " << evectors(0,1) << ", " << evectors(0,2) << "), " - << "(" << evectors(1,0) << ", " << evectors(1,1) << ", " << evectors(1,2) << "), " - << "(" << evectors(2,0) << ", " << evectors(2,1) << ", " << evectors(2,2) << ")" << std::endl; - */ - vtkTensors->InsertTuple9( - vtkPointID, - evectors(0,0), evectors(0,1), evectors(0,2), - evectors(1,0), evectors(1,1), evectors(1,2), - evectors(2,0), evectors(2,1), evectors(2,2) - ); - } // rof - - polyData->SetPoints( points ); - vtkSmartPointer pointData = polyData->GetPointData(); - pointData->SetTensors( vtkTensors ); - return( 1 ); - - /** - * VISUALISATION CODE BELOW - */ - -// vtkSmartPointer cubeSource = vtkSmartPointer::New(); -// cubeSource->Update(); -// -// vtkSmartPointer tensorGlyph = vtkSmartPointer::New(); -//#if VTK_MAJOR_VERSION <= 5 -// tensorGlyph->SetInput(polyData); -//#else -// tensorGlyph->SetInputData(polyData); -//#endif -// tensorGlyph->SetSourceConnection(cubeSource->GetOutputPort()); -// tensorGlyph->ColorGlyphsOff(); -// tensorGlyph->ThreeGlyphsOff(); -// tensorGlyph->ExtractEigenvaluesOff(); -// tensorGlyph->Update(); -// . -// . -// . - -} - -// ------------------------------------------------------------------------- -template class cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< itk::Image< itk::SymmetricSecondRankTensor< float, 3 >, 3 > >; -template class cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< itk::Image< itk::SymmetricSecondRankTensor< double, 3 >, 3 > >; - -// eof - $RCSfile$ diff --git a/lib/cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.h b/lib/cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.h deleted file mode 100644 index 1861263..0000000 --- a/lib/cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.h +++ /dev/null @@ -1,53 +0,0 @@ -// ------------------------------------------------------------------------- -// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) -// ------------------------------------------------------------------------- - -#ifndef __CPEXTENSIONS__ALGORITHMS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__ -#define __CPEXTENSIONS__ALGORITHMS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__ - -#include - -#include - -namespace cpExtensions -{ - namespace Algorithms - { - /** - */ - template< class I > - class cpExtensions_EXPORT SecondRankDiffusionTensorToPolyData - : public vtkPolyDataAlgorithm - { - public: - typedef SecondRankDiffusionTensorToPolyData Self; - - public: - static Self* New( ); - vtkTypeMacro( SecondRankDiffusionTensorToPolyData, vtkPolyDataAlgorithm ); - - void SetInputData( const I* image ); - - protected: - SecondRankDiffusionTensorToPolyData( ); - virtual ~SecondRankDiffusionTensorToPolyData( ); - - virtual int RequestData( - vtkInformation* , vtkInformationVector**, vtkInformationVector* - ); - - private: - SecondRankDiffusionTensorToPolyData( const Self& other ); - Self& operator=( const Self& other ); - - protected: - typename I::ConstPointer m_ITKImage; - }; - - } // ecapseman - -} // ecapseman - -#endif // __CPEXTENSIONS__ALGORITHMS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.cxx b/lib/cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.cxx deleted file mode 100644 index 62a5907..0000000 --- a/lib/cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.cxx +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include -#include - -#include -#include - -// ------------------------------------------------------------------------- -cpPlugins::Plugins::SecondRankDiffusionTensorToPolyData:: -SecondRankDiffusionTensorToPolyData( ) - : Superclass( ), - m_Algorithm( NULL ) -{ - this->m_ClassName = "cpPlugins::SecondRankDiffusionTensorToPolyData"; - this->m_ClassCategory = "ImageToMeshFilter"; - - this->SetNumberOfInputs( 1 ); - this->SetNumberOfOutputs( 1 ); - this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 ); - - using namespace cpPlugins::Interface; - this->m_Parameters = this->m_DefaultParameters; -} - -// ------------------------------------------------------------------------- -cpPlugins::Plugins::SecondRankDiffusionTensorToPolyData:: -~SecondRankDiffusionTensorToPolyData( ) -{ - if( this->m_Algorithm != NULL ) - this->m_Algorithm->Delete( ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::SecondRankDiffusionTensorToPolyData:: -_GenerateData( ) -{ - // Get input - cpPlugins::Interface::Image* image = - this->GetInput< cpPlugins::Interface::Image >( 0 ); - if( image == NULL ) - return( "SecondRankDiffusionTensorToPolyData: Input data is not a valid image." ); - - itk::DataObject* itk_image = NULL; - std::string r = ""; - cpPlugins_ImageArray_Input_Demangle( itk::SymmetricSecondRankTensor, float, 3, 3, image, itk_image, r, _RealGD ); - else cpPlugins_ImageArray_Input_Demangle( itk::SymmetricSecondRankTensor, double, 3, 3, image, itk_image, r, _RealGD ); - else - r = "SecondRankDiffusionTensorToPolyData: Input does not have a DiffusionTensor3D."; - return( r ); -} - -// ------------------------------------------------------------------------- -template< class I > -std::string cpPlugins::Plugins::SecondRankDiffusionTensorToPolyData:: -_RealGD( itk::DataObject* image ) -{ - typedef cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I > _F; - - // Configure filter - _F* f = NULL; - if( this->m_Algorithm == NULL ) - { - f = _F::New( ); - this->m_Algorithm = f; - - } // fi - f->SetInputData( dynamic_cast< I* >( image ) ); - this->m_Algorithm->Update( ); - - // Connect output - cpPlugins::Interface::Mesh* out = - this->GetOutput< cpPlugins::Interface::Mesh >( 0 ); - if( out != NULL ) - { - out->SetVTKMesh( this->m_Algorithm->GetOutput( ) ); - return( "" ); - } - else - return( "OtsuThresholdImageFilter: output not correctly created." ); -} - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.h b/lib/cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.h deleted file mode 100644 index ff03716..0000000 --- a/lib/cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef __CPPLUGINS__PLUGINS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__ -#define __CPPLUGINS__PLUGINS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__ - -#include -#include - -class vtkPolyDataAlgorithm; - -namespace cpPlugins -{ - namespace Plugins - { - /** - */ - class cpPlugins_EXPORT SecondRankDiffusionTensorToPolyData - : public cpPlugins::Interface::ImageToMeshFilter - { - public: - typedef SecondRankDiffusionTensorToPolyData Self; - typedef cpPlugins::Interface::ImageToMeshFilter Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( SecondRankDiffusionTensorToPolyData, cpPluginsInterfaceImageToMeshFilter ); - - protected: - SecondRankDiffusionTensorToPolyData( ); - virtual ~SecondRankDiffusionTensorToPolyData( ); - - virtual std::string _GenerateData( ); - - template< class I > - inline std::string _RealGD( itk::DataObject* image ); - - private: - // Purposely not implemented - SecondRankDiffusionTensorToPolyData( const Self& ); - Self& operator=( const Self& ); - - protected: - vtkPolyDataAlgorithm* m_Algorithm; - }; - - // --------------------------------------------------------------------- - CPPLUGINS_INHERIT_PROVIDER( SecondRankDiffusionTensorToPolyData ); - - } // ecapseman - -} // ecapseman - -#endif // __CPPLUGINS__PLUGINS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__ - -// eof - $RCSfile$ -- 2.47.1