From: Leonardo Flórez-Valencia Date: Wed, 2 Nov 2016 21:25:39 +0000 (-0500) Subject: ... X-Git-Tag: v0.1~65 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=cd024359dba23dd50e197abf1ed7d70737deb7fd;p=cpPlugins.git ... --- diff --git a/appli/CMakeLists.txt b/appli/CMakeLists.txt index cc05c08..ff999fe 100644 --- a/appli/CMakeLists.txt +++ b/appli/CMakeLists.txt @@ -1,5 +1,6 @@ SUBDIRS( bash + plugins examples PipelineEditor ) diff --git a/appli/PipelineEditor/CMakeLists.txt b/appli/PipelineEditor/CMakeLists.txt index 0febd97..4b1344f 100644 --- a/appli/PipelineEditor/CMakeLists.txt +++ b/appli/PipelineEditor/CMakeLists.txt @@ -6,10 +6,12 @@ IF(Qt4_FOUND) ${PROJECT_BINARY_DIR}/lib ) CompileAppFromDir(PipelineEditor ${CMAKE_CURRENT_SOURCE_DIR}) - TARGET_LINK_LIBRARIES( - PipelineEditor - cpBaseQtApplication - ) + IF(BUILD_PipelineEditor) + TARGET_LINK_LIBRARIES( + PipelineEditor + cpBaseQtApplication + ) + ENDIF(BUILD_PipelineEditor) ENDIF(Qt4_FOUND) ## eof - $RCSfile$ diff --git a/appli/plugins/CMakeLists.txt b/appli/plugins/CMakeLists.txt new file mode 100644 index 0000000..d9f331f --- /dev/null +++ b/appli/plugins/CMakeLists.txt @@ -0,0 +1,19 @@ +INCLUDE_DIRECTORIES( + ${PROJECT_SOURCE_DIR}/lib + ${PROJECT_BINARY_DIR}/lib + ) +SET( + _plugins_APPS + ExecutePipeline + ) +FOREACH(_app ${_plugins_APPS}) + ADD_EXECUTABLE(cpPlugins_plugins_${_app} ${_app}) + TARGET_LINK_LIBRARIES(cpPlugins_plugins_${_app} cpPlugins) + SET( + cpPlugins_plugins_${_app}_APP cpPlugins_plugins_${_app} + CACHE INTERNAL "bash program cpPlugins_plugins_${_app}" + ) +ENDFOREACH(_app) + + +## eof - $RCSfile$ diff --git a/appli/plugins/ExecutePipeline.cxx b/appli/plugins/ExecutePipeline.cxx new file mode 100644 index 0000000..a842d8d --- /dev/null +++ b/appli/plugins/ExecutePipeline.cxx @@ -0,0 +1,57 @@ +#include +#include +#include + +int main( int argc, char* argv[] ) +{ + // Manage inputs + if( argc < 2 ) + { + std::cerr + << "Usage: " << argv[ 0 ] + << " workspace [parameters]" << std::endl; + return( 1 ); + + } // fi + + // Create interface and load library + cpPlugins::Interface::Plugins::Pointer interface = + cpPlugins::Interface::Plugins::New( ); + try + { + interface->AddEnvironments( "." ); + interface->LoadPaths( "." ); + interface->LoadEnvironments( ); + interface->GuessPlugins( ); + } + catch( std::exception& err ) + { + std::cerr << "Error caught: " << err.what( ) << std::endl; + return( 1 ); + + } // yrt + + // Workspace + cpPlugins::Interface::Workspace::Pointer workspace = + cpPlugins::Interface::Workspace::New( ); + try + { + workspace->Load( argv[ 1 ] ); + } + catch( std::exception& err ) + { + std::cerr + << "Error loading workspace \"" << argv[ 1 ] + << "\": " << err.what( ) << std::endl; + return( 1 ); + + } // yrt + + // Execute filter + workspace->PrintExecutionOn( ); + workspace->Execute( ); + + return( 0 ); +} + +// eof - $RCSfile$ diff --git a/cmake/Functions.cmake b/cmake/Functions.cmake index 02ec213..9beaaae 100644 --- a/cmake/Functions.cmake +++ b/cmake/Functions.cmake @@ -323,22 +323,25 @@ FUNCTION( app_name app_dir ) -FILE(GLOB_RECURSE _files "${app_dir}/*") -PrepareSourceFiles(_srcs _hdrs _paths ${_files} ${ARGN}) -INCLUDE_DIRECTORIES( - ${_paths} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ) -IF(_srcs) - SET(_app_os_target) - IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - SET(_app_os_target WIN32) - ELSEIF(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - SET(_app_os_target MACOSX_BUNDLE) - ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - ADD_EXECUTABLE(${app_name} ${_app_os_target} ${_srcs} ${_hdrs}) -ENDIF(_srcs) +OPTION(BUILD_${app_name} "Build ${app_name}" OFF) +IF(BUILD_${app_name}) + FILE(GLOB_RECURSE _files "${app_dir}/*") + PrepareSourceFiles(_srcs _hdrs _paths ${_files} ${ARGN}) + INCLUDE_DIRECTORIES( + ${_paths} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ) + IF(_srcs) + SET(_app_os_target) + IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + SET(_app_os_target WIN32) + ELSEIF(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + SET(_app_os_target MACOSX_BUNDLE) + ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + ADD_EXECUTABLE(${app_name} ${_app_os_target} ${_srcs} ${_hdrs}) + ENDIF(_srcs) +ENDIF(BUILD_${app_name}) ENDFUNCTION() ## eof - $RCSfile$ diff --git a/lib/cpExtensions/Algorithms/PolyLineParametricPathToSimple3DCurve.cxx b/lib/cpExtensions/Algorithms/PolyLineParametricPathToSimple3DCurve.cxx index c3d575d..9eecda1 100644 --- a/lib/cpExtensions/Algorithms/PolyLineParametricPathToSimple3DCurve.cxx +++ b/lib/cpExtensions/Algorithms/PolyLineParametricPathToSimple3DCurve.cxx @@ -25,7 +25,7 @@ template< class _TPolyLine, class _TCurve > void cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >:: SetInput( _TPolyLine* pl ) { - this->Superclass::SetInput( 0, pl ); + this->Superclass::SetNthInput( 0, pl ); } // ------------------------------------------------------------------------- @@ -54,7 +54,7 @@ PolyLineParametricPathToSimple3DCurve( ) this->SetNumberOfRequiredInputs( 1 ); this->SetNumberOfRequiredOutputs( 1 ); typename _TCurve::Pointer curve = _TCurve::New( ); - this->Superclass::SetOutput( 0, curve ); + this->Superclass::SetNthOutput( 0, curve ); } // ------------------------------------------------------------------------- diff --git a/lib/cpExtensions/DataStructures/Skeleton.hxx b/lib/cpExtensions/DataStructures/Skeleton.hxx index ff00cb6..e6635ae 100644 --- a/lib/cpExtensions/DataStructures/Skeleton.hxx +++ b/lib/cpExtensions/DataStructures/Skeleton.hxx @@ -18,6 +18,8 @@ AddBranch( TPath* path ) return; // Add path + this->SetVertex( a, a ); + this->SetVertex( b, b ); this->AddEdge( a, b, path ); this->AddEdge( b, a, path ); // TODO: this->Modified( ); diff --git a/lib/cpPlugins/BaseObjects/Parameters.cxx b/lib/cpPlugins/BaseObjects/Parameters.cxx index d552786..1c63638 100644 --- a/lib/cpPlugins/BaseObjects/Parameters.cxx +++ b/lib/cpPlugins/BaseObjects/Parameters.cxx @@ -447,11 +447,11 @@ AddToOpenFileNameList( { if( i->second.first == OpenFileNameList ) { - auto pos = name.find_last_of( "/\\" ); + auto pos = v.find_last_of( "/\\" ); if( i->second.second == "" ) - i->second.second = name.substr( 0, pos ); + i->second.second = v.substr( 0, pos ); i->second.second += std::string( "#" ); - i->second.second += name.substr( pos + 1 ); + i->second.second += v.substr( pos + 1 ); this->Modified( ); } // fi @@ -486,11 +486,11 @@ AddToSaveFileNameList( { if( i->second.first == SaveFileNameList ) { - auto pos = name.find_last_of( "/\\" ); + auto pos = v.find_last_of( "/\\" ); if( i->second.second == "" ) - i->second.second = name.substr( 0, pos ); + i->second.second = v.substr( 0, pos ); i->second.second += std::string( "#" ); - i->second.second += name.substr( pos + 1 ); + i->second.second += v.substr( pos + 1 ); this->Modified( ); } // fi diff --git a/lib/cpPlugins/DataObjects/Image.d b/lib/cpPlugins/DataObjects/Image.d index 0d8a325..165a06a 100644 --- a/lib/cpPlugins/DataObjects/Image.d +++ b/lib/cpPlugins/DataObjects/Image.d @@ -13,6 +13,8 @@ DiffTensors3D itk::Image< itk::#diff_tensors#< #real_types# >, 3 > IntPixels_AllDims itk::Image< #all_ints#, #process_dims# > IntPixels_VisualDims itk::Image< #all_ints#, #process_dims# > +RealPixels_AllDims itk::Image< #real_types#, #process_dims# > +RealPixels_VisualDims itk::Image< #real_types#, #process_dims# > ScalarPixels_AllDims itk::Image< #scalar_pixels#, #process_dims# > ScalarPixels_VisualDims itk::Image< #scalar_pixels#, #visual_dims# > ColorPixels_AllDims itk::Image< itk::#color_pixels#< #scalar_pixels# >, #process_dims# > diff --git a/lib/cpPlugins/DataObjects/PolyLineParametricPath.cxx b/lib/cpPlugins/DataObjects/PolyLineParametricPath.cxx index cab593a..357f38a 100644 --- a/lib/cpPlugins/DataObjects/PolyLineParametricPath.cxx +++ b/lib/cpPlugins/DataObjects/PolyLineParametricPath.cxx @@ -1,32 +1,18 @@ #include #include +#include +#include // ------------------------------------------------------------------------- void cpPlugins::DataObjects::PolyLineParametricPath:: SetITK( itk::LightObject* o ) { - /* TODO - 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< _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 - */ + this->Superclass::SetITK( o ); + cpPlugins_Demangle_PolyLineParametricPath_All_1( o, _ITK_2_VTK ) + { + this->m_VTK = NULL; + this->m_ITKvVTK = NULL; + } } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/DataObjects/PolyLineParametricPath.d b/lib/cpPlugins/DataObjects/PolyLineParametricPath.d new file mode 100644 index 0000000..8fef127 --- /dev/null +++ b/lib/cpPlugins/DataObjects/PolyLineParametricPath.d @@ -0,0 +1,3 @@ +All cpExtensions::DataStructures::PolyLineParametricPath< #process_dims# > + +** eof - $RCSfile$ diff --git a/lib/cpPlugins/DataObjects/Skeleton.cxx b/lib/cpPlugins/DataObjects/Skeleton.cxx index 72a141d..098595a 100644 --- a/lib/cpPlugins/DataObjects/Skeleton.cxx +++ b/lib/cpPlugins/DataObjects/Skeleton.cxx @@ -1,32 +1,17 @@ #include #include +#include +#include // ------------------------------------------------------------------------- void cpPlugins::DataObjects::Skeleton:: SetITK( itk::LightObject* o ) { - /* TODO - 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 - */ + cpPlugins_Demangle_Skeleton_All_1( o, _ITK_2_VTK ) + { + this->m_VTK = NULL; + this->m_ITKvVTK = NULL; + } } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/DataObjects/Skeleton.d b/lib/cpPlugins/DataObjects/Skeleton.d new file mode 100644 index 0000000..d709d98 --- /dev/null +++ b/lib/cpPlugins/DataObjects/Skeleton.d @@ -0,0 +1,3 @@ +All cpExtensions::DataStructures::Skeleton< #process_dims# > + +** eof - $RCSfile$ diff --git a/plugins/IO/ImageJSkeletonWriter.cxx b/plugins/IO/ImageJSkeletonWriter.cxx new file mode 100644 index 0000000..1077242 --- /dev/null +++ b/plugins/IO/ImageJSkeletonWriter.cxx @@ -0,0 +1,109 @@ +#include +#include +#include +#include + +#include +#include + +#ifdef cpPlugins_QT4 +# include +#endif // cpPlugins_QT4 + +// ------------------------------------------------------------------------- +QDialog* cpPluginsIO::ImageJSkeletonWriter:: +CreateQDialog( ) +{ +#ifdef cpPlugins_QT4 + cpPlugins::QT::SaveFileDialog* dlg = NULL; + if( QApplication::instance( ) != NULL ) + { + dlg = new cpPlugins::QT::SaveFileDialog( ); + dlg->SetParameters( &( this->m_Parameters ), "FileName" ); + + } // fi + return( dlg ); +#else // cpPlugins_QT4 + return( NULL ); +#endif // cpPlugins_QT4 +} + +// ------------------------------------------------------------------------- +cpPluginsIO::ImageJSkeletonWriter:: +ImageJSkeletonWriter( ) + : Superclass( ) +{ + this->_ConfigureInput< cpPlugins::DataObjects::Skeleton >( "Input", true, false ); + this->m_Parameters.ConfigureAsSaveFileName( "FileName", "" ); + this->m_Parameters.SetAcceptedFileExtensions( + "FileName", + "ImageJ files (*.txt)" + ); +} + +// ------------------------------------------------------------------------- +cpPluginsIO::ImageJSkeletonWriter:: +~ImageJSkeletonWriter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsIO::ImageJSkeletonWriter:: +_GenerateData( ) +{ + auto o = this->GetInputData( "Input" ); + cpPlugins_Demangle_Skeleton_All_1( o, _GD0 ) + this->_Error( "Invalid input skeleton type." ); +} + +// ------------------------------------------------------------------------- +template< class _TSkeleton > +void cpPluginsIO::ImageJSkeletonWriter:: +_GD0( _TSkeleton* skeleton ) +{ + std::stringstream data; + unsigned long id = 1; + + auto mIt = skeleton->BeginEdgesRows( ); + for( ; mIt != skeleton->EndEdgesRows( ); ++mIt ) + { + /* TODO + mIt->first; --> this is the row index. <-- + */ + auto rIt = mIt->second.begin( ); + for( ; rIt != mIt->second.end( ); ++rIt ) + { + /* TODO + rIt->first; --> this is the column index. + */ + auto eIt = rIt->second.begin( ); + for( ; eIt != rIt->second.end( ); ++eIt ) + { + auto path = *eIt; + auto p0 = path->GetSmoothPoint( 0 ); + auto p1 = path->GetSmoothPoint( 1 ); + double length = p1.EuclideanDistanceTo( p0 ); + data + << id << "\t1\t" << length << "\t" + << p0[ 0 ] << "\t" << p0[ 1 ] << "\t"<< p0[ 2 ] << "\t" + << p1[ 0 ] << "\t" << p1[ 1 ] << "\t"<< p1[ 2 ] << "\t" + << p1.EuclideanDistanceTo( p0 ) << std::endl; + id++; + + } // rof + + } // rof + + } // rof + + if( + !( + cpExtensions::Write( + data.str( ), this->m_Parameters.GetSaveFileName( "FileName" ) + ) + ) + ) + this->_Error( "Could not write on ImageJ file." ); +} + +// eof - $RCSfile$ diff --git a/plugins/IO/ImageJSkeletonWriter.h b/plugins/IO/ImageJSkeletonWriter.h new file mode 100644 index 0000000..6adffbf --- /dev/null +++ b/plugins/IO/ImageJSkeletonWriter.h @@ -0,0 +1,28 @@ +#ifndef __cpPluginsIO__ImageJSkeletonWriter__h__ +#define __cpPluginsIO__ImageJSkeletonWriter__h__ + +#include +#include + +namespace cpPluginsIO +{ + /** + */ + class cpPluginsIO_EXPORT ImageJSkeletonWriter + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( ImageJSkeletonWriter, cpPlugins::BaseObjects::ProcessObject, IO ); + + public: + virtual QDialog* CreateQDialog( ) cpPlugins_OVERRIDE; + + protected: + template< class _TSkeleton > + inline void _GD0( _TSkeleton* skeleton ); + }; + +} // ecapseman + +#endif // __cpPluginsIO__ImageJSkeletonWriter__h__ + +// eof - $RCSfile$ diff --git a/plugins/Widgets/SeedWidget.cxx b/plugins/Widgets/SeedWidget.cxx index ab38f2e..cc589b1 100644 --- a/plugins/Widgets/SeedWidget.cxx +++ b/plugins/Widgets/SeedWidget.cxx @@ -164,34 +164,38 @@ _GD0_Image( vtkImageData* image ) std::string text = this->m_Parameters.GetString( "Text" ); std::vector< std::string > tok1, tok2; cpExtensions::Tokenize( tok1, text, "#" ); - for( auto t1 = tok1.begin( ); t1 != tok1.end( ); ++t1 ) + if( tok1.size( ) > seeds->GetPoints( )->GetNumberOfPoints( ) ) { - if( *t1 != "" ) + for( auto t1 = tok1.begin( ); t1 != tok1.end( ); ++t1 ) { - cpExtensions::Tokenize( tok2, *t1, " " ); - double x[ 3 ]; - for( unsigned int d = 0; d < 3; ++d ) + if( *t1 != "" ) { - if( d < tok2.size( ) ) + cpExtensions::Tokenize( tok2, *t1, " " ); + double x[ 3 ]; + for( unsigned int d = 0; d < 3; ++d ) { - std::istringstream str( tok2[ d ] ); - str >> x[ d ]; - } - else - x[ d ] = double( 0 ); - - } // rof + if( d < tok2.size( ) ) + { + std::istringstream str( tok2[ d ] ); + str >> x[ d ]; + } + else + x[ d ] = double( 0 ); + + } // rof + + seeds->GetPoints( )->InsertNextPoint( x ); + seeds->GetVerts( )->InsertNextCell( 1 ); + seeds->GetVerts( )->InsertCellPoint( + seeds->GetPoints( )->GetNumberOfPoints( ) - 1 + ); + seeds->Modified( ); - seeds->GetPoints( )->InsertNextPoint( x ); - seeds->GetVerts( )->InsertNextCell( 1 ); - seeds->GetVerts( )->InsertCellPoint( - seeds->GetPoints( )->GetNumberOfPoints( ) - 1 - ); - seeds->Modified( ); + } // fi - } // fi + } // rof - } // rof + } // fi } else {