-CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
+CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
## ========================
## == Project definition ==
c itk::ImportImageContainer< unsigned long, itk::Offset< #process_dims# > >
c itk::Image$Base;Region$< #process_dims# >
-c itk::Image< #pixels#, #process_dims# >
+c itk::Image< $bool;#pixels#$, #process_dims# >
c itk::Image< itk::#colors#< #pixels# >, #process_dims# >
c itk::Image< std::complex< #reals# >, #process_dims# >
c itk::Image< itk::#vectors#< #reals#, #process_dims# >, #process_dims# >
// Get the plugins interface
this->m_Plugins = TPlugins::New( );
- try { this->m_Plugins->AddEnvironments( env.str( ) ); } catch( ... ) { }
try { this->m_Plugins->OpenEnvironments( env.str( ) ); } catch( ... ) { }
try { this->m_Plugins->SaveEnvironments( this->m_RunPath ); } catch( ... ) { }
this->updateEnvironment( );
std::stringstream dir;
dir << cpExtensions::CanonicalPath( *i );
if( dir.str( ) != "" )
- {
- if( !cpExtensions::IsPathSeparator( dir.str( ).back( ) ) )
- dir << cpExtensions_PATH_SEPARATOR;
- std::stringstream name;
- name << dir.str( ) << cpPlugins_CONFIG;
- std::ifstream check( name.str( ).c_str( ), std::ifstream::binary );
- if( check )
- this->m_Paths.insert( dir.str( ) );
- check.close( );
-
- } // fi
+ this->m_Paths.insert( dir.str( ) );
} // rof
}
void cpPlugins::Interface::Plugins::
SaveEnvironments( const std::string& dir ) const
{
- if( this->m_Paths.size( ) > 0 )
- {
- std::stringstream buffer;
- auto i = this->m_Paths.begin( );
- for( auto i = this->m_Paths.begin( ); i != this->m_Paths.end( ); ++i )
- buffer << *i << std::endl;
+ std::stringstream buffer;
+ for( auto i = this->m_Paths.begin( ); i != this->m_Paths.end( ); ++i )
+ buffer << *i << std::endl;
- std::stringstream fname;
- fname << dir;
- if( !cpExtensions::IsPathSeparator( dir.back( ) ) )
- fname << cpExtensions_PATH_SEPARATOR;
- fname << cpPlugins_PATHS;
- if( !cpExtensions::Write( buffer.str( ), fname.str( ) ) )
- throw std::runtime_error( "Error writing environment file." );
- }
- else
- throw std::runtime_error( "No paths to save." );
+ std::stringstream fname;
+ fname << dir;
+ if( !cpExtensions::IsPathSeparator( dir.back( ) ) )
+ fname << cpExtensions_PATH_SEPARATOR;
+ fname << cpPlugins_PATHS;
+ if( !cpExtensions::Write( buffer.str( ), fname.str( ) ) )
+ throw std::runtime_error( "Error writing environment file." );
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::Plugins::
OpenEnvironments( const std::string& dir )
{
- std::stringstream fname;
- fname << dir;
- if( !cpExtensions::IsPathSeparator( dir.back( ) ) )
- fname << cpExtensions_PATH_SEPARATOR;
- fname << cpPlugins_PATHS;
- std::string buffer;
- if( cpExtensions::Read( buffer, fname.str( ) ) )
+ std::vector< std::string > tokens;
+ cpExtensions::Tokenize( tokens, dir, cpPlugins_ENV_SEPARATOR );
+ for( auto tIt = tokens.begin( ); tIt != tokens.end( ); ++tIt )
{
- std::istringstream input( buffer );
- std::stringstream paths;
- for( std::string line; std::getline( input, line ); )
- paths << line << cpPlugins_ENV_SEPARATOR;
- this->AddEnvironments( paths.str( ) );
- }
- else
- throw std::runtime_error( "Error opening environment file." );
+ std::stringstream fname;
+ fname << *tIt;
+ if( !cpExtensions::IsPathSeparator( dir.back( ) ) )
+ fname << cpExtensions_PATH_SEPARATOR;
+ fname << cpPlugins_PATHS;
+ std::string buffer;
+ if( cpExtensions::Read( buffer, fname.str( ) ) )
+ {
+ std::istringstream input( buffer );
+ std::stringstream paths;
+ for( std::string line; std::getline( input, line ); )
+ paths << line << cpPlugins_ENV_SEPARATOR;
+ this->AddEnvironments( paths.str( ) );
+ }
+ else
+ {
+ bool success = true;
+ try
+ {
+ this->LoadDirectory( dir );
+ }
+ catch( ... )
+ {
+ success = false;
+
+ } // yrt
+ if( success )
+ this->AddEnvironments( dir );
+
+ } // fi
+
+ } // rof
}
// -------------------------------------------------------------------------
if( p != NULL )
str << p << cpPlugins_ENV_SEPARATOR;
str << ".";
- this->AddEnvironments( str.str( ) );
+ this->OpenEnvironments( str.str( ) );
// Try to read locally defined paths
- std::vector< std::string > tokens;
- cpExtensions::Tokenize( tokens, str.str( ), cpPlugins_ENV_SEPARATOR );
- for( auto t = tokens.begin( ); t != tokens.end( ); ++t )
- this->OpenEnvironments( *t );
+ /* TODO
+ std::vector< std::string > tokens;
+ cpExtensions::Tokenize( tokens, str.str( ), cpPlugins_ENV_SEPARATOR );
+ for( auto t = tokens.begin( ); t != tokens.end( ); ++t )
+ {
+ try
+ {
+ this->OpenEnvironments( *t );
+ }
+ catch( ... ) { }
+
+ } // rof
+ */
}
// -------------------------------------------------------------------------
ImageGenericFilters
ImageGradientFilters
ImageMeshFilters
+ ImageSources
ImageThresholdFilters
IO
MeshFilters
--- /dev/null
+#include <plugins/ImageGenericFilters/RescaleIntensityImageFilter.h>
+#include <cpPlugins/DataObjects/Image.h>
+
+#include <itkRescaleIntensityImageFilter.h>
+#include <itkRescaleIntensityImageFilter.hxx>
+#include <itkUnaryFunctorImageFilter.hxx>
+#include <itkMinimumMaximumImageCalculator.hxx>
+
+// -------------------------------------------------------------------------
+cpPluginsImageGenericFilters::RescaleIntensityImageFilter::
+RescaleIntensityImageFilter( )
+ : Superclass( )
+{
+ this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input", true, false );
+ this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" );
+
+ this->m_Parameters.ConfigureAsReal( "OutputMinimum" );
+ this->m_Parameters.ConfigureAsReal( "OutputMaximum" );
+
+ this->m_Parameters.SetReal( "OutputMinimum", 0 );
+ this->m_Parameters.SetReal( "OutputMaximum", 1 );
+}
+
+// -------------------------------------------------------------------------
+cpPluginsImageGenericFilters::RescaleIntensityImageFilter::
+~RescaleIntensityImageFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPluginsImageGenericFilters::RescaleIntensityImageFilter::
+_GenerateData( )
+{
+ auto o = this->GetInputData( "Input" );
+ cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 );
+ else this->_Error( "Invalid input image." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpPluginsImageGenericFilters::RescaleIntensityImageFilter::
+_GD0( _TImage* input )
+{
+ typedef itk::RescaleIntensityImageFilter< _TImage > _TFilter;
+
+ auto filter = this->_CreateITK< _TFilter >( );
+ filter->SetInput( input );
+ filter->SetOutputMinimum( this->m_Parameters.GetReal( "OutputMinimum" ) );
+ filter->SetOutputMaximum( this->m_Parameters.GetReal( "OutputMaximum" ) );
+ filter->Update( );
+ this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __cpPluginsImageGenericFilters__RescaleIntensityImageFilter__h__
+#define __cpPluginsImageGenericFilters__RescaleIntensityImageFilter__h__
+
+#include <plugins/cpPluginsImageGenericFilters_Export.h>
+#include <cpPlugins/BaseObjects/ProcessObject.h>
+
+namespace cpPluginsImageGenericFilters
+{
+ /**
+ */
+ class cpPluginsImageGenericFilters_EXPORT RescaleIntensityImageFilter
+ : public cpPlugins::BaseObjects::ProcessObject
+ {
+ cpPluginsObject(
+ RescaleIntensityImageFilter,
+ cpPlugins::BaseObjects::ProcessObject,
+ ImageFilters
+ );
+
+ protected:
+ template< class _TImage >
+ inline void _GD0( _TImage* input );
+ };
+
+} // ecapseman
+
+#endif // __cpPluginsImageGenericFilters__RescaleIntensityImageFilter__h__
+
+// eof - $RCSfile$
--- /dev/null
+#include <plugins/ImageSources/RandomImageSource.h>
+#include <cpPlugins/DataObjects/Image.h>
+
+#include <itkRandomImageSource.h>
+#include <itkRandomImageSource.hxx>
+
+// -------------------------------------------------------------------------
+cpPluginsImageSources::RandomImageSource::
+RandomImageSource( )
+ : Superclass( )
+{
+ this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" );
+
+ this->m_Parameters.ConfigureAsUintList( "Size" );
+ this->m_Parameters.ConfigureAsRealList( "Spacing" );
+
+ std::vector< std::string > pixels;
+ pixels.push_back( "char" );
+ pixels.push_back( "short" );
+ pixels.push_back( "int" );
+ pixels.push_back( "long" );
+ pixels.push_back( "uchar" );
+ pixels.push_back( "ushort" );
+ pixels.push_back( "uint" );
+ pixels.push_back( "ulong" );
+ pixels.push_back( "float" );
+ pixels.push_back( "double" );
+ this->m_Parameters.ConfigureAsChoices( "PixelType", pixels );
+ this->m_Parameters.SetSelectedChoice( "PixelType", "uchar" );
+
+ std::vector< std::string > dims;
+ dims.push_back( "1" );
+ dims.push_back( "2" );
+ dims.push_back( "3" );
+ dims.push_back( "4" );
+ this->m_Parameters.ConfigureAsChoices( "Dimension", dims );
+ this->m_Parameters.SetSelectedChoice( "Dimension", "2" );
+}
+
+// -------------------------------------------------------------------------
+cpPluginsImageSources::RandomImageSource::
+~RandomImageSource( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPluginsImageSources::RandomImageSource::
+_GenerateData( )
+{
+ auto pixel = this->m_Parameters.GetSelectedChoice( "PixelType" );
+ if ( pixel == "char" ) this->_GD0< char >( );
+ else if( pixel == "short" ) this->_GD0< short >( );
+ else if( pixel == "int" ) this->_GD0< int >( );
+ else if( pixel == "long" ) this->_GD0< long >( );
+ else if( pixel == "uchar" ) this->_GD0< unsigned char >( );
+ else if( pixel == "ushort" ) this->_GD0< unsigned short >( );
+ else if( pixel == "uint" ) this->_GD0< unsigned int >( );
+ else if( pixel == "ulong" ) this->_GD0< unsigned long >( );
+ else if( pixel == "float" ) this->_GD0< float >( );
+ else if( pixel == "double" ) this->_GD0< double >( );
+ else this->_Error( "Invalid pixel type." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPixel >
+void cpPluginsImageSources::RandomImageSource::
+_GD0( )
+{
+ auto dim = this->m_Parameters.GetSelectedChoice( "Dimension" );
+ if ( dim == "1" ) this->_GD1< _TPixel, 1 >( );
+ else if( dim == "2" ) this->_GD1< _TPixel, 2 >( );
+ else if( dim == "3" ) this->_GD1< _TPixel, 3 >( );
+ else if( dim == "4" ) this->_GD1< _TPixel, 4 >( );
+ else this->_Error( "Invalid dimension." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPixel, unsigned int _VDim >
+void cpPluginsImageSources::RandomImageSource::
+_GD1( )
+{
+ typedef itk::Image< _TPixel, _VDim > _TImage;
+ typedef itk::RandomImageSource< _TImage > _TFilter;
+
+ auto size = this->m_Parameters.GetUintList( "Size" );
+ auto spacing = this->m_Parameters.GetRealList( "Spacing" );
+ if( size.size( ) < _VDim )
+ this->_Error( "Invalid size." );
+ if( spacing.size( ) < _VDim )
+ this->_Error( "Invalid spacing." );
+
+ typename _TImage::SizeType out_size;
+ typename _TImage::SpacingType out_spac;
+ for( unsigned int i = 0; i < _VDim; ++i )
+ {
+ out_size[ i ] = size[ i ];
+ out_spac[ i ] = spacing[ i ];
+
+ } // rof
+
+ _TFilter* filter = this->_CreateITK< _TFilter >( );
+ filter->SetSize( out_size );
+ filter->SetSpacing( out_spac );
+ filter->Update( );
+ this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __cpPluginsImageSources__RandomImageSource__h__
+#define __cpPluginsImageSources__RandomImageSource__h__
+
+#include <plugins/cpPluginsImageSources_Export.h>
+#include <cpPlugins/BaseObjects/ProcessObject.h>
+
+namespace cpPluginsImageSources
+{
+ /**
+ */
+ class cpPluginsImageSources_EXPORT RandomImageSource
+ : public cpPlugins::BaseObjects::ProcessObject
+ {
+ cpPluginsObject(
+ RandomImageSource,
+ cpPlugins::BaseObjects::ProcessObject,
+ ImageSources
+ );
+
+ protected:
+ template< class _TPixel >
+ inline void _GD0( );
+
+ template< class _TPixel, unsigned int _VDim >
+ inline void _GD1( );
+ };
+
+} // ecapseman
+
+#endif // __cpPluginsImageSources__RandomImageSource__h__
+
+// eof - $RCSfile$