From: Leonardo Florez-Valencia Date: Tue, 7 Jun 2016 00:05:05 +0000 (-0500) Subject: Bug smashed like a boss X-Git-Tag: v0.1~149 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=adb38e2972e7c2e287e73c7b03db344807729219;p=cpPlugins.git Bug smashed like a boss --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 89eb42a..93b62fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,20 @@ INCLUDE(cmake/cpPlugins_Options.cmake) INCLUDE(cmake/cpPlugins_KitwareTools.cmake) INCLUDE(cmake/cpPlugins_Qt4Tools.cmake) +## =================================== +## == Libraries to dynamically load == +## =================================== + +SET(cpPlugins_DynLibs) +FOREACH(i ${VTK_LIBRARIES}) + GET_TARGET_PROPERTY(lib_${i} ${i} LOCATION) + LIST(APPEND cpPlugins_DynLibs ${lib_${i}}) +ENDFOREACH(i) +FOREACH(i ${ITK_LIBRARIES}) + GET_TARGET_PROPERTY(lib_${i} ${i} LOCATION) + LIST(APPEND cpPlugins_DynLibs ${lib_${i}}) +ENDFOREACH(i) + ## ========================= ## == Include directories == ## ========================= diff --git a/appli/examples/plugins/CMakeLists.txt b/appli/examples/plugins/CMakeLists.txt index 0712ef1..12c8cd3 100644 --- a/appli/examples/plugins/CMakeLists.txt +++ b/appli/examples/plugins/CMakeLists.txt @@ -7,11 +7,12 @@ SET( example_ReadWriteImage example_ReadWriteImageWithWorkspace example_ShowImage + example_ShowSphere ) FOREACH(example ${examples_SOURCES}) ADD_EXECUTABLE(${example} ${example}.cxx) - TARGET_LINK_LIBRARIES(${example} cpExtensions cpPlugins) + TARGET_LINK_LIBRARIES(${example} cpPlugins) ENDFOREACH(example) IF(USE_QT4) diff --git a/appli/examples/plugins/QT/example_ActorProperties/CMakeLists.txt b/appli/examples/plugins/QT/example_ActorProperties/CMakeLists.txt new file mode 100644 index 0000000..63b05a0 --- /dev/null +++ b/appli/examples/plugins/QT/example_ActorProperties/CMakeLists.txt @@ -0,0 +1,58 @@ +SET(app_NAME "example_ActorProperties") + +INCLUDE_DIRECTORIES( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ) + +## ==================================================== +## = Source code, user interafaces and resources here = +## ==================================================== + +SET( + app_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/example_ActorProperties.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/main.cxx + ) + +SET( + app_HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/example_ActorProperties.h + ) + +SET( + app_UI + ${CMAKE_CURRENT_SOURCE_DIR}/example_ActorProperties.ui + ) + +## ===================== +## = Compilation rules = +## ===================== + +QT4_WRAP_UI(app_UI_HEADERS ${app_UI}) +QT4_WRAP_CPP(app_MOC_SOURCES ${app_HEADERS}) + +SET(GUI_TYPE "") +IF(WIN32) + SET(GUI_TYPE WIN32) +ENDIF(WIN32) +IF(APPLE) + SET(GUI_TYPE MACOSX_BUNDLE) +ENDIF(APPLE) + +ADD_EXECUTABLE( + ${app_NAME} + ${GUI_TYPE} + ${app_HEADERS} + ${app_UI_HEADERS} + ${app_SOURCES} + ${app_MOC_SOURCES} + ) + +TARGET_LINK_LIBRARIES( + ${app_NAME} + cpExtensions + cpPlugins + ) + +## eof - $RCSfile$ diff --git a/appli/examples/plugins/QT/example_ActorProperties/example_ActorProperties.cxx b/appli/examples/plugins/QT/example_ActorProperties/example_ActorProperties.cxx new file mode 100644 index 0000000..159b506 --- /dev/null +++ b/appli/examples/plugins/QT/example_ActorProperties/example_ActorProperties.cxx @@ -0,0 +1,104 @@ +#include "example_ActorProperties.h" +#include "ui_example_ActorProperties.h" + +#include +#include +#include +#include +#include +#include + +// ------------------------------------------------------------------------- +example_ActorProperties:: +example_ActorProperties( int argc, char* argv[], QWidget* parent ) + : Superclass( parent ), + m_UI( new Ui::example_ActorProperties ) +{ + this->m_UI->setupUi( this ); + this->m_Interface.GuessAccesiblePlugins( ); + + this->m_Renderer = vtkSmartPointer< vtkRenderer >::New( ); + this->m_UI->Viewer->GetRenderWindow( )->AddRenderer( this->m_Renderer ); + + + vtkSmartPointer< vtkSphereSource > sphere = + vtkSmartPointer< vtkSphereSource >::New( ); + vtkSmartPointer< vtkPolyDataMapper > mapper = + vtkSmartPointer< vtkPolyDataMapper >::New( ); + mapper->SetInputConnection( sphere->GetOutputPort( ) ); + vtkSmartPointer< vtkActor > actor = + vtkSmartPointer< vtkActor >::New( ); + actor->SetMapper( mapper ); + + this->m_Renderer->AddActor( actor ); + + //this->m_Renderer->ResetCamera( ); + //this->m_Renderer->Render( ); + // this->m_UI->Viewer->GetRenderWindow( )->Render( ); + + // Create reader + /* + try + { + */ + /* TODO + auto cylinder = this->m_Interface.Create( "MeshSources", "CylinderSource" ); + cylinder->Update( ); + */ + + /* TODO + this->m_Reader = this->m_Interface.Create( "IO", "ImageReader" ); + if( this->m_Reader.IsNull( ) ) + { + QMessageBox::critical( + this, + QMessageBox::tr( "Error" ), + QMessageBox::tr( "\"IO::ImageReader\" creation failed." ) + ); + std::exit( 1 ); + + } // fi + + // Configure filters + auto reader_params = this->m_Reader->GetParameters( ); + for( int i = 1; i < argc; ++i ) + reader_params->AddToOpenFileNameList( "FileNames", argv[ i ] ); + this->m_Reader->Update( ); + */ + /* + } + catch( itk::ExceptionObject& err1 ) + { + QMessageBox::critical( + this, + QMessageBox::tr( "Error" ), + QMessageBox::tr( err1.GetDescription( ) ) + ); + std::exit( 1 ); + } + catch( std::exception& err2 ) + { + QMessageBox::critical( + this, + QMessageBox::tr( "Error" ), + QMessageBox::tr( err2.what( ) ) + ); + std::exit( 1 ); + + } // yrt + */ + /* TODO + this->m_UI->Viewer->SetMainImage( + this->m_Reader->GetOutputData< vtkImageData >( "Output" ), + "MainImage" + ); + */ +} + +// ------------------------------------------------------------------------- +example_ActorProperties:: +~example_ActorProperties( ) +{ +} + +// eof - $RCSfile$ diff --git a/appli/examples/plugins/QT/example_ActorProperties/example_ActorProperties.h b/appli/examples/plugins/QT/example_ActorProperties/example_ActorProperties.h new file mode 100644 index 0000000..4f8b5b9 --- /dev/null +++ b/appli/examples/plugins/QT/example_ActorProperties/example_ActorProperties.h @@ -0,0 +1,42 @@ +#ifndef __EXAMPLE_ACTORPROPERTIES__H__ +#define __EXAMPLE_ACTORPROPERTIES__H__ + +#include +#include +#include +#include + +// ------------------------------------------------------------------------- +namespace Ui +{ + class example_ActorProperties; +} + +// ------------------------------------------------------------------------- +/** + */ +class example_ActorProperties + : public QMainWindow +{ + Q_OBJECT; + +public: + typedef example_ActorProperties Self; + typedef QMainWindow Superclass; + +public: + explicit example_ActorProperties( + int argc, char* argv[], + QWidget* parent = NULL + ); + virtual ~example_ActorProperties( ); + +private: + Ui::example_ActorProperties* m_UI; + vtkSmartPointer< vtkRenderer > m_Renderer; + cpPlugins::Interface m_Interface; +}; + +#endif // __CPEXAMPLE_ACTORPROPERTIES__H__ + +// eof - $RCSfile$ diff --git a/appli/examples/plugins/QT/example_ActorProperties/example_ActorProperties.ui b/appli/examples/plugins/QT/example_ActorProperties/example_ActorProperties.ui new file mode 100644 index 0000000..b5378d1 --- /dev/null +++ b/appli/examples/plugins/QT/example_ActorProperties/example_ActorProperties.ui @@ -0,0 +1,47 @@ + + + example_ActorProperties + + + + 0 + 0 + 800 + 600 + + + + + 800 + 600 + + + + MainWindow + + + + + + + + 0 + 200 + + + + + + + + + + QVTKWidget + QWidget +
QVTKWidget.h
+ 1 +
+
+ + +
diff --git a/appli/examples/plugins/QT/example_ActorProperties/main.cxx b/appli/examples/plugins/QT/example_ActorProperties/main.cxx new file mode 100644 index 0000000..5850dd6 --- /dev/null +++ b/appli/examples/plugins/QT/example_ActorProperties/main.cxx @@ -0,0 +1,80 @@ +#include "example_ActorProperties.h" +#include +#include + +// ------------------------------------------------------------------------- +int main( int argc, char* argv[] ) +{ + QApplication a( argc, argv ); + example_ActorProperties w( argc, argv ); + w.show( ); + return( a.exec( ) ); +} + +// ------------------------------------------------------------------------- +#ifdef _WIN32 + +#include +#include +#include +#include + +/** + */ +class Win32CommandLineConverter +{ +private: + std::unique_ptr< char*[ ] > argv_; + std::vector< std::unique_ptr< char[ ] > > storage_; + +public: + Win32CommandLineConverter( ) + { + LPWSTR cmd_line = GetCommandLineW( ); + int argc; + LPWSTR* w_argv = CommandLineToArgvW( cmd_line, &argc ); + argv_ = std::unique_ptr< char*[ ] >( new char*[ argc ] ); + storage_.reserve( argc ); + for( int i = 0; i < argc; ++i ) + { + storage_.push_back( ConvertWArg( w_argv[ i ] ) ); + argv_[ i ] = storage_.back( ).get( ); + + } // rof + LocalFree( w_argv ); + } + int argc( ) const + { + return( static_cast< int >(storage_.size( ) ) ); + } + char** argv( ) const + { + return( argv_.get( ) ); + } + static std::unique_ptr< char[ ] > ConvertWArg( LPWSTR w_arg ) + { + int size = WideCharToMultiByte( + CP_UTF8, 0, w_arg, -1, nullptr, 0, nullptr, nullptr + ); + std::unique_ptr< char[ ] > ret( new char[ size ] ); + WideCharToMultiByte( + CP_UTF8, 0, w_arg, -1, ret.get( ), size, nullptr, nullptr + ); + return( ret ); + } +}; + +int CALLBACK WinMain( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow + ) +{ + Win32CommandLineConverter cmd_line; + return( main( cmd_line.argc( ), cmd_line.argv( ) ) ); +} + +#endif + +// eof - $RCSfile$ diff --git a/appli/examples/plugins/example_LoadPlugins.cxx b/appli/examples/plugins/example_LoadPlugins.cxx index 21c61c0..3ed8fdb 100644 --- a/appli/examples/plugins/example_LoadPlugins.cxx +++ b/appli/examples/plugins/example_LoadPlugins.cxx @@ -11,13 +11,16 @@ int main( int argc, char* argv[] ) } // fi // Load interface - cpPlugins::Interface interface; + cpPlugins::Interface* interface = NULL; try { - interface.LoadPlugin( argv[ 1 ] ); + interface = new cpPlugins::Interface( ); + interface->LoadPlugin( argv[ 1 ] ); } catch( std::exception& err ) { + if( interface != NULL ) + delete interface; std::cerr << "Error caught: " << err.what( ) @@ -27,13 +30,13 @@ int main( int argc, char* argv[] ) } // yrt // Show loaded plugins - auto plugins = interface.GetPlugins( ); + auto plugins = interface->GetPlugins( ); for( auto pIt = plugins.begin( ); pIt != plugins.end( ); ++pIt ) std::cout << "Plugin: " << *pIt << std::endl; std::cout << std::endl; // Show loaded filters - auto filters = interface.GetFilters( ); + auto filters = interface->GetFilters( ); for( auto cIt = filters.begin( ); cIt != filters.end( ); ++cIt ) { std::cout << "Category: " << cIt->first << std::endl; @@ -43,6 +46,9 @@ int main( int argc, char* argv[] ) << std::endl; } // rof + + // Free all and finish + delete interface; return( 0 ); } diff --git a/appli/examples/plugins/example_LoadPluginsDirectory.cxx b/appli/examples/plugins/example_LoadPluginsDirectory.cxx index 803d390..99f4b62 100644 --- a/appli/examples/plugins/example_LoadPluginsDirectory.cxx +++ b/appli/examples/plugins/example_LoadPluginsDirectory.cxx @@ -5,32 +5,39 @@ int main( int argc, char* argv[] ) { if( argc < 2 ) { - std::cerr << "Usage: " << argv[ 0 ] << " plugins_libraries_dir" << std::endl; + std::cerr + << "Usage: " << argv[ 0 ] << " plugins_libraries_dir" << std::endl; return( 1 ); } // fi // Load interface - cpPlugins::Interface interface; + cpPlugins::Interface* interface = NULL; try { - interface.LoadPluginDir( argv[ 1 ] ); + interface = new cpPlugins::Interface( ); + interface->LoadPluginDir( argv[ 1 ] ); } catch( std::exception& err ) { - std::cerr << "Error caught: " << err.what( ) << std::endl; + if( interface != NULL ) + delete interface; + std::cerr + << "Error caught: " + << err.what( ) + << std::endl; return( 1 ); } // yrt // Show loaded plugins - auto plugins = interface.GetPlugins( ); + auto plugins = interface->GetPlugins( ); for( auto pIt = plugins.begin( ); pIt != plugins.end( ); ++pIt ) std::cout << "Plugin: " << *pIt << std::endl; std::cout << std::endl; // Show loaded filters - auto filters = interface.GetFilters( ); + auto filters = interface->GetFilters( ); for( auto cIt = filters.begin( ); cIt != filters.end( ); ++cIt ) { std::cout << "Category: " << cIt->first << std::endl; @@ -40,6 +47,9 @@ int main( int argc, char* argv[] ) << std::endl; } // rof + + // Free all and finish + delete interface; return( 0 ); } diff --git a/appli/examples/plugins/example_LoadPluginsFile.cxx b/appli/examples/plugins/example_LoadPluginsFile.cxx index 929a48c..52af772 100644 --- a/appli/examples/plugins/example_LoadPluginsFile.cxx +++ b/appli/examples/plugins/example_LoadPluginsFile.cxx @@ -11,13 +11,16 @@ int main( int argc, char* argv[] ) } // fi // Load interface - cpPlugins::Interface interface; + cpPlugins::Interface* interface = NULL; try { - interface.LoadPluginFile( argv[ 1 ] ); + interface = new cpPlugins::Interface( ); + interface->LoadPluginFile( argv[ 1 ] ); } catch( std::exception& err ) { + if( interface != NULL ) + delete interface; std::cerr << "Error caught: " << err.what( ) @@ -27,13 +30,13 @@ int main( int argc, char* argv[] ) } // yrt // Show loaded plugins - auto plugins = interface.GetPlugins( ); + auto plugins = interface->GetPlugins( ); for( auto pIt = plugins.begin( ); pIt != plugins.end( ); ++pIt ) std::cout << "Plugin: " << *pIt << std::endl; std::cout << std::endl; // Show loaded filters - auto filters = interface.GetFilters( ); + auto filters = interface->GetFilters( ); for( auto cIt = filters.begin( ); cIt != filters.end( ); ++cIt ) { std::cout << "Category: " << cIt->first << std::endl; @@ -43,6 +46,9 @@ int main( int argc, char* argv[] ) << std::endl; } // rof + + // Free all and finish + delete interface; return( 0 ); } diff --git a/appli/examples/plugins/example_ShowSphere.cxx b/appli/examples/plugins/example_ShowSphere.cxx new file mode 100644 index 0000000..9c64f8d --- /dev/null +++ b/appli/examples/plugins/example_ShowSphere.cxx @@ -0,0 +1,84 @@ +#include +#include + +#include +#include +#include +#include + +int main( int argc, char* argv[] ) +{ + // Load interface + cpPlugins::Interface* interface = NULL; + try + { + interface = new cpPlugins::Interface( ); + interface->GuessAccesiblePlugins( ); + } + catch( std::exception& err ) + { + if( interface != NULL ) + delete interface; + std::cerr + << "Error caught: " + << err.what( ) + << std::endl; + return( 1 ); + + } // yrt + + // Create filters + cpPlugins::ProcessObject::Pointer sphere; + int ret = 0; + try + { + sphere = interface->Create( "MeshSources", "SphereSource" ); + if( sphere.IsNull( ) ) + { + std::cerr + << "\"MeshSources::SphereSource\" creation failed." + << std::endl; + ret = 1; + + } // fi + } + catch( std::exception& err ) + { + std::cerr + << "Filter creation failed: " + << err.what( ) + << std::endl; + ret = 1; + + } // yrt + sphere->GetParameters( )->SetReal( "Radius", 5 ); + sphere->GetParameters( )->SetUint( "ThetaResolution", 100 ); + sphere->GetParameters( )->SetUint( "PhiResolution", 100 ); + sphere->Update( ); + + // Prepare scene + vtkSmartPointer< vtkRenderer > ren = + vtkSmartPointer< vtkRenderer >::New( ); + ren->SetBackground( 0, 0, 0 ); + ren->AddActor( sphere->GetOutput( "Output" )->GetVTKActor( ) ); + + vtkSmartPointer< vtkRenderWindow > win = + vtkSmartPointer< vtkRenderWindow >::New( ); + win->AddRenderer( ren ); + win->SetSize( 500, 500 ); + + vtkSmartPointer< vtkRenderWindowInteractor > iren = + vtkSmartPointer< vtkRenderWindowInteractor >::New( ); + iren->SetRenderWindow( win ); + + iren->Initialize( ); + ren->Render( ); + ren->ResetCamera( ); + iren->Start( ); + + // Ok finish + delete interface; + return( ret ); +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/CMakeLists.txt b/lib/cpPlugins/CMakeLists.txt index 7817df1..2e09b0f 100644 --- a/lib/cpPlugins/CMakeLists.txt +++ b/lib/cpPlugins/CMakeLists.txt @@ -14,6 +14,11 @@ CONFIGURE_FILE( ${PROJECT_BINARY_DIR}/lib/${lib_DIR}/Config.h @ONLY ) +CONFIGURE_FILE( + cpPlugins_DynLibs.h.in + ${PROJECT_BINARY_DIR}/lib/${lib_DIR}/cpPlugins_DynLibs.h + @ONLY + ) ## =============== ## = Source code = @@ -85,8 +90,11 @@ SET( SET( target_LIBRARIES - ${cpPlugins_LIBRARIES} + ${ITK_LIBRARIES} + ${VTK_LIBRARIES} + cpExtensions cpPlugins_tinyxml2 + ${cpPlugins_LIBRARIES} ) IF(NOT WIN32) SET( diff --git a/lib/cpPlugins/Interface.cxx b/lib/cpPlugins/Interface.cxx index 8b5e106..6ffc0fe 100644 --- a/lib/cpPlugins/Interface.cxx +++ b/lib/cpPlugins/Interface.cxx @@ -6,13 +6,42 @@ # include #endif // cpPlugins_SYS_WINDOWS #include +#include #include +// ------------------------------------------------------------------------- +unsigned int cpPlugins::Interface::InterfacesCount = 0; + // ------------------------------------------------------------------------- cpPlugins::Interface:: Interface( ) { this->UpdatePaths( ); + + // Explicitly load all ITK and VTK + if( Self::InterfacesCount == 0 ) + { + std::vector< std::string > libs; + cpPlugins::TokenizeString( libs, cpPlugins_DynLibs, ";" ); + this->_AddInstancesLib( libs, cpPlugins_CompilationDir ); + this->_AddInstancesLib( libs, cpPlugins_InstallationDir ); + + for( auto l = libs.begin( ); l != libs.end( ); ++l ) + { + std::string error = ""; + void* hnd = Self::_DLOpen( *l, error ); + if( hnd == NULL || error != "" ) + throw std::runtime_error( + std::string( "cpPlugins::Interface: Could not load library \"" ) + + *l + + std::string( "\": " ) + + error + ); + + } // rof + + } // fi + Self::InterfacesCount++; } // ------------------------------------------------------------------------- @@ -20,6 +49,12 @@ cpPlugins::Interface:: ~Interface( ) { this->UnloadAll( ); + Self::InterfacesCount--; + if( Self::InterfacesCount == 0 ) + { + // TODO: unload vtk and itk + + } // fi } // ------------------------------------------------------------------------- @@ -126,12 +161,14 @@ LoadPluginFile( const std::string& filename ) ); // Try to load the library - void* hnd = Self::_DLOpen( canonical ); - if( hnd == NULL ) + std::string error; + void* hnd = Self::_DLOpen( canonical, error ); + if( hnd == NULL || error != "" ) throw std::runtime_error( std::string( "cpPlugins::Interface: Could not load library \"" ) + filename + - std::string( "\"" ) + std::string( "\": " ) + + error ); // Get plugin name @@ -264,16 +301,40 @@ GetPlugins( ) const return( res ); } +// ------------------------------------------------------------------------- +template< class _TList > +void cpPlugins::Interface:: +_AddInstancesLib( _TList& libs, const std::string& path ) +{ + DIR* dir; + struct dirent* ent; + if( ( dir = opendir( path.c_str( ) ) ) != NULL ) + { + while( ( ent = readdir( dir ) ) != NULL ) + { + std::string fname = path + std::string( "/" ) + ent->d_name; + if( fname.find( "cpPlugins_Instances_" ) != std::string::npos ) + libs.push_back( fname ); + + } // elihw + closedir( dir ); + + } // fi +} + // ------------------------------------------------------------------------- void* cpPlugins::Interface:: -_DLOpen( const std::string& fname ) +_DLOpen( const std::string& fname, std::string& error ) { void* hnd = NULL; #ifdef cpPlugins_SYS_WINDOWS hnd = ::LoadLibraryA( fname.c_str( ) ); #else // cpPlugins_SYS_WINDOWS hnd = dlopen( fname.c_str( ), RTLD_NOW | RTLD_GLOBAL ); - dlerror( ); + if( hnd == NULL ) + error = dlerror( ); + else + dlerror( ); #endif // cpPlugins_SYS_WINDOWS return( hnd ); } diff --git a/lib/cpPlugins/Interface.h b/lib/cpPlugins/Interface.h index 0a31e63..4c7d5e6 100644 --- a/lib/cpPlugins/Interface.h +++ b/lib/cpPlugins/Interface.h @@ -47,7 +47,9 @@ namespace cpPlugins std::set< std::string > GetPlugins( ) const; protected: - static void* _DLOpen( const std::string& fname ); + template< class _TList > + inline void _AddInstancesLib( _TList& libs, const std::string& path ); + static void* _DLOpen( const std::string& fname, std::string& error ); static const char* _DLGetName( void* hnd ); static TFilters _DLGetFilters( void* hnd ); static TCreator _DLGetCreator( @@ -60,6 +62,8 @@ namespace cpPlugins TDynLibraries m_DynLibraries; TDynFilters m_DynFilters; TFilters m_Filters; + + static unsigned int InterfacesCount; }; } // ecapseman diff --git a/lib/cpPlugins/cpPlugins_DynLibs.h.in b/lib/cpPlugins/cpPlugins_DynLibs.h.in new file mode 100644 index 0000000..1014047 --- /dev/null +++ b/lib/cpPlugins/cpPlugins_DynLibs.h.in @@ -0,0 +1,6 @@ + +#define cpPlugins_CompilationDir "@PROJECT_BINARY_DIR@" +#define cpPlugins_InstallationDir "@CMAKE_INSTALL_PREFIX@/lib" +#define cpPlugins_DynLibs "@cpPlugins_DynLibs@" + +// eof - $RCSfile$ diff --git a/lib/cpPlugins_Instances/CMakeLists.txt b/lib/cpPlugins_Instances/CMakeLists.txt index 79eef7e..7437b20 100644 --- a/lib/cpPlugins_Instances/CMakeLists.txt +++ b/lib/cpPlugins_Instances/CMakeLists.txt @@ -5,18 +5,18 @@ SET(pfx "cpPlugins_Instances_") SET(arg ${pfx} ${prj_VER} ${prj_sVER}) -cpPlugins_WrapInstances(BaseObjects ${arg} ${ITK_LIBRARIES}) -cpPlugins_WrapInstances(Decorators ${arg} ${ITK_LIBRARIES}) +cpPlugins_WrapInstances(BaseObjects ${arg}) #${ITK_LIBRARIES}) +cpPlugins_WrapInstances(Decorators ${arg}) #${ITK_LIBRARIES}) cpPlugins_WrapInstances(Mesh ${arg} ${pfx}BaseObjects) cpPlugins_WrapInstances(Transforms ${arg} ${pfx}BaseObjects) cpPlugins_WrapInstances(ColorPixels ${arg} ${pfx}BaseObjects) cpPlugins_WrapInstances(ScalarImages ${arg} ${pfx}BaseObjects) cpPlugins_WrapInstances(ColorImages ${arg} ${pfx}ColorPixels ${pfx}ScalarImages) cpPlugins_WrapInstances(VectorImages ${arg} ${pfx}ScalarImages) -cpPlugins_WrapInstances(Paths ${arg} ${pfx}ScalarImages ${VTK_LIBRARIES}) +cpPlugins_WrapInstances(Paths ${arg} ${pfx}ScalarImages) # ${VTK_LIBRARIES}) cpPlugins_WrapInstances(NeighborhoodIterators ${arg} ${pfx}ScalarImages) cpPlugins_WrapInstances( - ImageITK2VTK ${arg} ${pfx}ScalarImages ${pfx}ColorImages ${pfx}VectorImages ${VTK_LIBRARIES} + ImageITK2VTK ${arg} ${pfx}ScalarImages ${pfx}ColorImages ${pfx}VectorImages # ${VTK_LIBRARIES} ) cpPlugins_WrapInstances( ImagesIO ${arg} ${pfx}ScalarImages ${pfx}ColorImages ${pfx}VectorImages ${pfx}Decorators diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index a995095..9d51a6a 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -2,6 +2,7 @@ SUBDIRS( cpPluginsGenericFilters cpPluginsIO cpPluginsImageFilters + cpPluginsMeshSources cpPluginsMeshFilters cpPluginsImageMeshFilters cpPluginsWidgets diff --git a/plugins/cpPluginsGenericFilters/CMakeLists.txt b/plugins/cpPluginsGenericFilters/CMakeLists.txt index 1d759cc..1c6e009 100644 --- a/plugins/cpPluginsGenericFilters/CMakeLists.txt +++ b/plugins/cpPluginsGenericFilters/CMakeLists.txt @@ -10,7 +10,6 @@ cpPlugins_WrapPlugins( "${lib_SOURCES}" "${lib_OTHER_SOURCES}" "${lib_QT4_HEADERS}" - cpPlugins ${cpPlugins_LIBRARIES} ) ## ======================== diff --git a/plugins/cpPluginsIO/CMakeLists.txt b/plugins/cpPluginsIO/CMakeLists.txt index cf0ac1c..aa7b377 100644 --- a/plugins/cpPluginsIO/CMakeLists.txt +++ b/plugins/cpPluginsIO/CMakeLists.txt @@ -10,7 +10,6 @@ cpPlugins_WrapPlugins( "${lib_SOURCES}" "${lib_OTHER_SOURCES}" "${lib_QT4_HEADERS}" - cpPlugins ${cpPlugins_LIBRARIES} ) ## ======================== diff --git a/plugins/cpPluginsImageFilters/CMakeLists.txt b/plugins/cpPluginsImageFilters/CMakeLists.txt index fa550da..ed6fdec 100644 --- a/plugins/cpPluginsImageFilters/CMakeLists.txt +++ b/plugins/cpPluginsImageFilters/CMakeLists.txt @@ -10,7 +10,6 @@ cpPlugins_WrapPlugins( "${lib_SOURCES}" "${lib_OTHER_SOURCES}" "${lib_QT4_HEADERS}" - cpPlugins ${cpPlugins_LIBRARIES} ) ## ======================== diff --git a/plugins/cpPluginsImageMeshFilters/CMakeLists.txt b/plugins/cpPluginsImageMeshFilters/CMakeLists.txt index 9ad287a..01d5725 100644 --- a/plugins/cpPluginsImageMeshFilters/CMakeLists.txt +++ b/plugins/cpPluginsImageMeshFilters/CMakeLists.txt @@ -10,7 +10,6 @@ cpPlugins_WrapPlugins( "${lib_SOURCES}" "${lib_OTHER_SOURCES}" "${lib_QT4_HEADERS}" - cpPlugins ${cpPlugins_LIBRARIES} ) ## ======================== diff --git a/plugins/cpPluginsMeshFilters/CMakeLists.txt b/plugins/cpPluginsMeshFilters/CMakeLists.txt index fc68d30..5eceecd 100644 --- a/plugins/cpPluginsMeshFilters/CMakeLists.txt +++ b/plugins/cpPluginsMeshFilters/CMakeLists.txt @@ -10,7 +10,6 @@ cpPlugins_WrapPlugins( "${lib_SOURCES}" "${lib_OTHER_SOURCES}" "${lib_QT4_HEADERS}" - cpPlugins ${cpPlugins_LIBRARIES} ) ## ======================== diff --git a/plugins/cpPluginsMeshSources/CMakeLists.txt b/plugins/cpPluginsMeshSources/CMakeLists.txt new file mode 100644 index 0000000..9fe09da --- /dev/null +++ b/plugins/cpPluginsMeshSources/CMakeLists.txt @@ -0,0 +1,26 @@ +SET(lib_NAME cpPluginsMeshSources) +FILE(GLOB lib_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/*.h") +FILE(GLOB lib_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cxx") +SET(lib_OTHER_SOURCES "") +SET(lib_QT4_HEADERS "") + +cpPlugins_WrapPlugins( + ${lib_NAME} ${prj_VER} ${prj_sVER} + "${lib_HEADERS}" + "${lib_SOURCES}" + "${lib_OTHER_SOURCES}" + "${lib_QT4_HEADERS}" + ) + +## ======================== +## -- Installation rules -- +## ======================== + +#INSTALL( +# TARGETS ${lib_NAME} +# RUNTIME DESTINATION bin +# LIBRARY DESTINATION lib +# ARCHIVE DESTINATION lib/static +# ) + +## eof - $RCSfile$ diff --git a/plugins/cpPluginsMeshSources/CylinderSource.cxx b/plugins/cpPluginsMeshSources/CylinderSource.cxx new file mode 100644 index 0000000..ba233f6 --- /dev/null +++ b/plugins/cpPluginsMeshSources/CylinderSource.cxx @@ -0,0 +1,37 @@ +#include +#include + +#include + +// ------------------------------------------------------------------------- +cpPluginsMeshSources::CylinderSource:: +CylinderSource( ) + : Superclass( ) +{ + this->_AddOutput< cpPlugins::Mesh >( "Output" ); + this->m_Parameters.ConfigureAsReal( "Height" ); + this->m_Parameters.ConfigureAsReal( "Radius" ); + this->m_Parameters.ConfigureAsUint( "Resolution" ); + this->m_Parameters.SetReal( "Radius", 1 ); + this->m_Parameters.SetUint( "Resolution", 8 ); +} + +// ------------------------------------------------------------------------- +cpPluginsMeshSources::CylinderSource:: +~CylinderSource( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsMeshSources::CylinderSource:: +_GenerateData( ) +{ + auto src = this->_CreateVTK< vtkCylinderSource >( ); + src->SetHeight( this->m_Parameters.GetReal( "Height" ) ); + src->SetRadius( this->m_Parameters.GetReal( "Radius" ) ); + src->SetResolution( this->m_Parameters.GetUint( "Resolution" ) ); + src->Update( ); + this->GetOutput( "Output" )->SetVTK( src->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsMeshSources/CylinderSource.h b/plugins/cpPluginsMeshSources/CylinderSource.h new file mode 100644 index 0000000..0e8d0b2 --- /dev/null +++ b/plugins/cpPluginsMeshSources/CylinderSource.h @@ -0,0 +1,41 @@ +#ifndef __CPPLUGINSMESHSOURCES__CYLINDERSOURCE__H__ +#define __CPPLUGINSMESHSOURCES__CYLINDERSOURCE__H__ + +#include +#include + +namespace cpPluginsMeshSources +{ + /** + */ + class cpPluginsMeshSources_EXPORT CylinderSource + : public cpPlugins::ProcessObject + { + public: + typedef CylinderSource Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( CylinderSource, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( CylinderSource, MeshSources ); + + protected: + CylinderSource( ); + virtual ~CylinderSource( ); + + virtual void _GenerateData( ) ITK_OVERRIDE; + + private: + // Purposely not implemented + CylinderSource( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSMESHSOURCES__CYLINDERSOURCE__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsMeshSources/SphereSource.cxx b/plugins/cpPluginsMeshSources/SphereSource.cxx new file mode 100644 index 0000000..96d7677 --- /dev/null +++ b/plugins/cpPluginsMeshSources/SphereSource.cxx @@ -0,0 +1,38 @@ +#include +#include + +#include + +// ------------------------------------------------------------------------- +cpPluginsMeshSources::SphereSource:: +SphereSource( ) + : Superclass( ) +{ + this->_AddOutput< cpPlugins::Mesh >( "Output" ); + this->m_Parameters.ConfigureAsReal( "Radius" ); + this->m_Parameters.ConfigureAsUint( "PhiResolution" ); + this->m_Parameters.ConfigureAsUint( "ThetaResolution" ); + this->m_Parameters.SetReal( "Radius", 1 ); + this->m_Parameters.SetUint( "PhiResolution", 8 ); + this->m_Parameters.SetUint( "ThetaResolution", 8 ); +} + +// ------------------------------------------------------------------------- +cpPluginsMeshSources::SphereSource:: +~SphereSource( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsMeshSources::SphereSource:: +_GenerateData( ) +{ + auto src = this->_CreateVTK< vtkSphereSource >( ); + src->SetRadius( this->m_Parameters.GetReal( "Radius" ) ); + src->SetPhiResolution( this->m_Parameters.GetUint( "PhiResolution" ) ); + src->SetThetaResolution( this->m_Parameters.GetUint( "ThetaResolution" ) ); + src->Update( ); + this->GetOutput( "Output" )->SetVTK( src->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsMeshSources/SphereSource.h b/plugins/cpPluginsMeshSources/SphereSource.h new file mode 100644 index 0000000..624b27e --- /dev/null +++ b/plugins/cpPluginsMeshSources/SphereSource.h @@ -0,0 +1,41 @@ +#ifndef __CPPLUGINSMESHSOURCES__SPHERESOURCE__H__ +#define __CPPLUGINSMESHSOURCES__SPHERESOURCE__H__ + +#include +#include + +namespace cpPluginsMeshSources +{ + /** + */ + class cpPluginsMeshSources_EXPORT SphereSource + : public cpPlugins::ProcessObject + { + public: + typedef SphereSource Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( SphereSource, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( SphereSource, MeshSources ); + + protected: + SphereSource( ); + virtual ~SphereSource( ); + + virtual void _GenerateData( ) ITK_OVERRIDE; + + private: + // Purposely not implemented + SphereSource( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSMESHSOURCES__SPHERESOURCE__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsWidgets/CMakeLists.txt b/plugins/cpPluginsWidgets/CMakeLists.txt index 934de3d..081f67f 100644 --- a/plugins/cpPluginsWidgets/CMakeLists.txt +++ b/plugins/cpPluginsWidgets/CMakeLists.txt @@ -10,7 +10,6 @@ cpPlugins_WrapPlugins( "${lib_SOURCES}" "${lib_OTHER_SOURCES}" "${lib_QT4_HEADERS}" - cpExtensions cpPlugins ${cpPlugins_LIBRARIES} ) ## ========================