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 ==
## =========================
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)
--- /dev/null
+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$
--- /dev/null
+#include "example_ActorProperties.h"
+#include "ui_example_ActorProperties.h"
+
+#include <vtkActor.h>
+#include <vtkSphereSource.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkRenderWindow.h>
+#include <vtkGenericOpenGLRenderWindow.h>
+#include <QMessageBox>
+
+// -------------------------------------------------------------------------
+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$
--- /dev/null
+#ifndef __EXAMPLE_ACTORPROPERTIES__H__
+#define __EXAMPLE_ACTORPROPERTIES__H__
+
+#include <QMainWindow>
+#include <cpPlugins/Interface.h>
+#include <vtkRenderer.h>
+#include <vtkSmartPointer.h>
+
+// -------------------------------------------------------------------------
+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$
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>example_ActorProperties</class>
+ <widget class="QMainWindow" name="example_ActorProperties">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>800</width>
+ <height>600</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="MainWidget">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QVTKWidget" name="Viewer" native="true">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>200</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>QVTKWidget</class>
+ <extends>QWidget</extends>
+ <header>QVTKWidget.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null
+#include "example_ActorProperties.h"
+#include <cstdlib>
+#include <QApplication>
+
+// -------------------------------------------------------------------------
+int main( int argc, char* argv[] )
+{
+ QApplication a( argc, argv );
+ example_ActorProperties w( argc, argv );
+ w.show( );
+ return( a.exec( ) );
+}
+
+// -------------------------------------------------------------------------
+#ifdef _WIN32
+
+#include <memory>
+#include <vector>
+#include <windows.h>
+#include <shellapi.h>
+
+/**
+ */
+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$
} // 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( )
} // 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;
<< std::endl;
} // rof
+
+ // Free all and finish
+ delete interface;
return( 0 );
}
{
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;
<< std::endl;
} // rof
+
+ // Free all and finish
+ delete interface;
return( 0 );
}
} // 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( )
} // 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;
<< std::endl;
} // rof
+
+ // Free all and finish
+ delete interface;
return( 0 );
}
--- /dev/null
+#include <iostream>
+#include <cpPlugins/Interface.h>
+
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkSmartPointer.h>
+
+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$
${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 =
SET(
target_LIBRARIES
- ${cpPlugins_LIBRARIES}
+ ${ITK_LIBRARIES}
+ ${VTK_LIBRARIES}
+ cpExtensions
cpPlugins_tinyxml2
+ ${cpPlugins_LIBRARIES}
)
IF(NOT WIN32)
SET(
# include <dlfcn.h>
#endif // cpPlugins_SYS_WINDOWS
#include <cpPlugins_dirent.h>
+#include <cpPlugins/cpPlugins_DynLibs.h>
#include <algorithm>
+// -------------------------------------------------------------------------
+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++;
}
// -------------------------------------------------------------------------
~Interface( )
{
this->UnloadAll( );
+ Self::InterfacesCount--;
+ if( Self::InterfacesCount == 0 )
+ {
+ // TODO: unload vtk and itk
+
+ } // fi
}
// -------------------------------------------------------------------------
);
// 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
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 );
}
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(
TDynLibraries m_DynLibraries;
TDynFilters m_DynFilters;
TFilters m_Filters;
+
+ static unsigned int InterfacesCount;
};
} // ecapseman
--- /dev/null
+
+#define cpPlugins_CompilationDir "@PROJECT_BINARY_DIR@"
+#define cpPlugins_InstallationDir "@CMAKE_INSTALL_PREFIX@/lib"
+#define cpPlugins_DynLibs "@cpPlugins_DynLibs@"
+
+// eof - $RCSfile$
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
cpPluginsGenericFilters
cpPluginsIO
cpPluginsImageFilters
+ cpPluginsMeshSources
cpPluginsMeshFilters
cpPluginsImageMeshFilters
cpPluginsWidgets
"${lib_SOURCES}"
"${lib_OTHER_SOURCES}"
"${lib_QT4_HEADERS}"
- cpPlugins ${cpPlugins_LIBRARIES}
)
## ========================
"${lib_SOURCES}"
"${lib_OTHER_SOURCES}"
"${lib_QT4_HEADERS}"
- cpPlugins ${cpPlugins_LIBRARIES}
)
## ========================
"${lib_SOURCES}"
"${lib_OTHER_SOURCES}"
"${lib_QT4_HEADERS}"
- cpPlugins ${cpPlugins_LIBRARIES}
)
## ========================
"${lib_SOURCES}"
"${lib_OTHER_SOURCES}"
"${lib_QT4_HEADERS}"
- cpPlugins ${cpPlugins_LIBRARIES}
)
## ========================
"${lib_SOURCES}"
"${lib_OTHER_SOURCES}"
"${lib_QT4_HEADERS}"
- cpPlugins ${cpPlugins_LIBRARIES}
)
## ========================
--- /dev/null
+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$
--- /dev/null
+#include <cpPluginsMeshSources/CylinderSource.h>
+#include <cpPlugins/Mesh.h>
+
+#include <vtkCylinderSource.h>
+
+// -------------------------------------------------------------------------
+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$
--- /dev/null
+#ifndef __CPPLUGINSMESHSOURCES__CYLINDERSOURCE__H__
+#define __CPPLUGINSMESHSOURCES__CYLINDERSOURCE__H__
+
+#include <plugins/cpPluginsMeshSources/cpPluginsMeshSources_Export.h>
+#include <cpPlugins/ProcessObject.h>
+
+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$
--- /dev/null
+#include <cpPluginsMeshSources/SphereSource.h>
+#include <cpPlugins/Mesh.h>
+
+#include <vtkSphereSource.h>
+
+// -------------------------------------------------------------------------
+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$
--- /dev/null
+#ifndef __CPPLUGINSMESHSOURCES__SPHERESOURCE__H__
+#define __CPPLUGINSMESHSOURCES__SPHERESOURCE__H__
+
+#include <plugins/cpPluginsMeshSources/cpPluginsMeshSources_Export.h>
+#include <cpPlugins/ProcessObject.h>
+
+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$
"${lib_SOURCES}"
"${lib_OTHER_SOURCES}"
"${lib_QT4_HEADERS}"
- cpExtensions cpPlugins ${cpPlugins_LIBRARIES}
)
## ========================