From: Leonardo Florez-Valencia Date: Wed, 31 Dec 2014 10:06:29 +0000 (+0100) Subject: More on parameters simplification X-Git-Tag: v0.1~425 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=d33ff8f25fd903eca28c2f088adc8f68e7738135;p=cpPlugins.git More on parameters simplification --- diff --git a/lib/cpPlugins/Interface/FilterObject.h b/lib/cpPlugins/Interface/FilterObject.h index 9f526c4..9718d76 100644 --- a/lib/cpPlugins/Interface/FilterObject.h +++ b/lib/cpPlugins/Interface/FilterObject.h @@ -19,9 +19,6 @@ namespace cpPlugins typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef Superclass::TParameter TParameter; - typedef Superclass::TParameters TParameters; - public: itkTypeMacro( FilterObject, ProcessObject ); diff --git a/lib/cpPlugins/Interface/ImageSink.h b/lib/cpPlugins/Interface/ImageSink.h index 3895e21..526a466 100644 --- a/lib/cpPlugins/Interface/ImageSink.h +++ b/lib/cpPlugins/Interface/ImageSink.h @@ -19,9 +19,6 @@ namespace cpPlugins typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef Superclass::TParameter TParameter; - typedef Superclass::TParameters TParameters; - public: itkTypeMacro( ImageSink, SinkObject ); diff --git a/lib/cpPlugins/Interface/ImageSource.h b/lib/cpPlugins/Interface/ImageSource.h index 2e8b80c..56004bf 100644 --- a/lib/cpPlugins/Interface/ImageSource.h +++ b/lib/cpPlugins/Interface/ImageSource.h @@ -19,9 +19,6 @@ namespace cpPlugins typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef Superclass::TParameter TParameter; - typedef Superclass::TParameters TParameters; - public: itkTypeMacro( ImageSource, SourceObject ); diff --git a/lib/cpPlugins/Interface/ImageToImageFilter.h b/lib/cpPlugins/Interface/ImageToImageFilter.h index d7ac57a..5da8bf2 100644 --- a/lib/cpPlugins/Interface/ImageToImageFilter.h +++ b/lib/cpPlugins/Interface/ImageToImageFilter.h @@ -19,9 +19,6 @@ namespace cpPlugins typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef Superclass::TParameter TParameter; - typedef Superclass::TParameters TParameters; - public: itkTypeMacro( ImageToImageFilter, FilterObject ); diff --git a/lib/cpPlugins/Interface/ImageToMeshFilter.h b/lib/cpPlugins/Interface/ImageToMeshFilter.h index 472f47a..70dc9a2 100644 --- a/lib/cpPlugins/Interface/ImageToMeshFilter.h +++ b/lib/cpPlugins/Interface/ImageToMeshFilter.h @@ -19,9 +19,6 @@ namespace cpPlugins typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef Superclass::TParameter TParameter; - typedef Superclass::TParameters TParameters; - public: itkTypeMacro( ImageToMeshFilter, FilterObject ); diff --git a/lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.h b/lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.h index 1b274cc..716bfad 100644 --- a/lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.h +++ b/lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.h @@ -19,9 +19,6 @@ namespace cpPlugins typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef Superclass::TParameter TParameter; - typedef Superclass::TParameters TParameters; - public: itkTypeMacro( ImageToPolyLineParametricPathFilter, FilterObject ); diff --git a/lib/cpPlugins/Interface/MeshSink.h b/lib/cpPlugins/Interface/MeshSink.h index b110cb3..5eab768 100644 --- a/lib/cpPlugins/Interface/MeshSink.h +++ b/lib/cpPlugins/Interface/MeshSink.h @@ -19,9 +19,6 @@ namespace cpPlugins typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef Superclass::TParameter TParameter; - typedef Superclass::TParameters TParameters; - public: itkTypeMacro( MeshSink, SinkObject ); diff --git a/lib/cpPlugins/Interface/MeshSource.h b/lib/cpPlugins/Interface/MeshSource.h index 9c5c3d2..745f62d 100644 --- a/lib/cpPlugins/Interface/MeshSource.h +++ b/lib/cpPlugins/Interface/MeshSource.h @@ -19,9 +19,6 @@ namespace cpPlugins typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef Superclass::TParameter TParameter; - typedef Superclass::TParameters TParameters; - public: itkTypeMacro( MeshSource, SourceObject ); diff --git a/lib/cpPlugins/Interface/MeshToImageFilter.h b/lib/cpPlugins/Interface/MeshToImageFilter.h index b6447d2..e8f0b83 100644 --- a/lib/cpPlugins/Interface/MeshToImageFilter.h +++ b/lib/cpPlugins/Interface/MeshToImageFilter.h @@ -19,9 +19,6 @@ namespace cpPlugins typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef Superclass::TParameter TParameter; - typedef Superclass::TParameters TParameters; - public: itkTypeMacro( MeshToImageFilter, FilterObject ); diff --git a/lib/cpPlugins/Interface/MeshToMeshFilter.h b/lib/cpPlugins/Interface/MeshToMeshFilter.h index 7121c0e..d47197f 100644 --- a/lib/cpPlugins/Interface/MeshToMeshFilter.h +++ b/lib/cpPlugins/Interface/MeshToMeshFilter.h @@ -19,9 +19,6 @@ namespace cpPlugins typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef Superclass::TParameter TParameter; - typedef Superclass::TParameters TParameters; - public: itkTypeMacro( MeshToMeshFilter, FilterObject ); diff --git a/lib/cpPlugins/Interface/Parameters.cxx b/lib/cpPlugins/Interface/Parameters.cxx index dd8cece..c51cde6 100644 --- a/lib/cpPlugins/Interface/Parameters.cxx +++ b/lib/cpPlugins/Interface/Parameters.cxx @@ -3,6 +3,48 @@ #include #include +// ------------------------------------------------------------------------- +#define cpPlugins_Interface_Parameters_SetMacro( TYPE ) \ + void cpPlugins::Interface::Parameters:: \ + SetValueAs##TYPE( const TString& name, const T##TYPE& v ) \ + { \ + TParameters::iterator pIt = this->m_Parameters.find( name ); \ + if( pIt == this->m_Parameters.end( ) ) \ + return; \ + if( pIt->second.first != Self::TYPE ) \ + return; \ + std::stringstream ss; \ + ss << v; \ + pIt->second.second = ss.str( ); \ + } + +cpPlugins_Interface_Parameters_SetMacro( String ); +cpPlugins_Interface_Parameters_SetMacro( Int ); +cpPlugins_Interface_Parameters_SetMacro( Uint ); +cpPlugins_Interface_Parameters_SetMacro( Real ); + +// ------------------------------------------------------------------------- +#define cpPlugins_Interface_Parameters_SetArrayMacro( TYPE, ATYPE ) \ + void cpPlugins::Interface::Parameters:: \ + SetValueAs##TYPE( const TString& name, const TUint& n, ... ) \ + { \ + TParameters::iterator pIt = this->m_Parameters.find( name ); \ + if( pIt == this->m_Parameters.end( ) ) \ + return; \ + if( pIt->second.first != Self::TYPE ) \ + return; \ + va_list v_lst; \ + va_start( v_lst, n ); \ + std::stringstream ss; \ + for( TUint i = 0; i < n; ++i ) \ + ss << va_arg( v_lst, ATYPE ) << ","; \ + va_end( v_lst ); \ + pIt->second.second = ss.str( ); \ + } + +cpPlugins_Interface_Parameters_SetArrayMacro( Index, long ); +cpPlugins_Interface_Parameters_SetArrayMacro( Point, double ); + // ------------------------------------------------------------------------- cpPlugins::Interface::Parameters:: Parameters( ) @@ -35,116 +77,40 @@ operator=( const Self& other ) // ------------------------------------------------------------------------- void cpPlugins::Interface::Parameters:: -Configure( const Self::Type& type, const std::string& name ) +Configure( const Self::Type& type, const TString& name ) { this->m_Parameters[ name ] = TParameter( type, "" ); } // ------------------------------------------------------------------------- -void cpPlugins::Interface::Parameters:: -SetValueAsString( const std::string& name, const std::string& v ) -{ - TParameters::iterator pIt = this->m_Parameters.find( name ); - if( pIt == this->m_Parameters.end( ) ) - return; - if( pIt->second.first != Self::String ) - return; - - pIt->second.second = v; -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Parameters:: -SetValueAsInt( const std::string& name, const TInt& v ) -{ - TParameters::iterator pIt = this->m_Parameters.find( name ); - if( pIt == this->m_Parameters.end( ) ) - return; - if( pIt->second.first != Self::Int ) - return; - - std::stringstream ss; - ss << v; - pIt->second.second = ss.str( ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Parameters:: -SetValueAsUint( const std::string& name, const TUint& v ) -{ - TParameters::iterator pIt = this->m_Parameters.find( name ); - if( pIt == this->m_Parameters.end( ) ) - return; - if( pIt->second.first != Self::Uint ) - return; - - std::stringstream ss; - ss << v; - pIt->second.second = ss.str( ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Parameters:: -SetValueAsReal( const std::string& name, const TReal& v ) -{ - TParameters::iterator pIt = this->m_Parameters.find( name ); - if( pIt == this->m_Parameters.end( ) ) - return; - if( pIt->second.first != Self::Real ) - return; - - std::stringstream ss; - ss << v; - pIt->second.second = ss.str( ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Parameters:: -SetValueAsIndex( const std::string& name, const TUint& n, ... ) +std::vector< cpPlugins::Interface::Parameters::TString > +cpPlugins::Interface::Parameters:: +GetParameters( ) const { - TParameters::iterator pIt = this->m_Parameters.find( name ); - if( pIt == this->m_Parameters.end( ) ) - return; - if( pIt->second.first != Self::Index ) - return; - - va_list v_lst; - va_start( v_lst, n ); - - std::stringstream ss; - for( TUint i = 0; i < n; ++i ) - ss << va_arg( v_lst, long ) << ":"; - va_end( v_lst ); - - pIt->second.second = ss.str( ); + std::vector< TString > parameters; + TParameters::const_iterator pIt = this->m_Parameters.begin( ); + for( ; pIt != this->m_Parameters.end( ); ++pIt ) + parameters.push_back( pIt->first ); + return( parameters ); } // ------------------------------------------------------------------------- -void cpPlugins::Interface::Parameters:: -SetValueAsPoint( const std::string& name, const TUint& n, ... ) +cpPlugins::Interface::Parameters:: +Type cpPlugins::Interface::Parameters:: +GetParameterType( const TString& name ) const { - TParameters::iterator pIt = this->m_Parameters.find( name ); + TParameters::const_iterator pIt = this->m_Parameters.find( name ); if( pIt == this->m_Parameters.end( ) ) - return; - if( pIt->second.first != Self::Point ) - return; - - va_list v_lst; - va_start( v_lst, n ); - - std::stringstream ss; - for( TUint i = 0; i < n; ++i ) - ss << va_arg( v_lst, double ) << ":"; - va_end( v_lst ); - - pIt->second.second = ss.str( ); + return( Self::NoType ); + return( pIt->second.first ); } // ------------------------------------------------------------------------- -const std::string& cpPlugins::Interface::Parameters:: -GetValueAsString( const std::string& name ) const +const cpPlugins::Interface::Parameters:: +TString& cpPlugins::Interface::Parameters:: +GetValueAsString( const TString& name ) const { - static const std::string null_str = ""; + static const TString null_str = ""; TParameters::const_iterator pIt = this->m_Parameters.find( name ); if( pIt == this->m_Parameters.end( ) ) return( null_str ); @@ -157,71 +123,65 @@ GetValueAsString( const std::string& name ) const // ------------------------------------------------------------------------- cpPlugins::Interface::Parameters:: TInt cpPlugins::Interface::Parameters:: -GetValueAsInt( const std::string& name ) const +GetValueAsInt( const TString& name ) const { - static const std::string null_str = ""; TParameters::const_iterator pIt = this->m_Parameters.find( name ); if( pIt == this->m_Parameters.end( ) ) return( TInt( 0 ) ); if( pIt->second.first != Self::Int ) return( TInt( 0 ) ); - - return( std::atoi( pIt->second.second.c_str( ) ) ); + return( TInt( std::atoi( pIt->second.second.c_str( ) ) ) ); } // ------------------------------------------------------------------------- cpPlugins::Interface::Parameters:: TUint cpPlugins::Interface::Parameters:: -GetValueAsUint( const std::string& name ) const +GetValueAsUint( const TString& name ) const { - static const std::string null_str = ""; TParameters::const_iterator pIt = this->m_Parameters.find( name ); if( pIt == this->m_Parameters.end( ) ) return( TUint( 0 ) ); if( pIt->second.first != Self::Uint ) return( TUint( 0 ) ); - - return( std::atoi( pIt->second.second.c_str( ) ) ); + return( TUint( std::atoi( pIt->second.second.c_str( ) ) ) ); } // ------------------------------------------------------------------------- cpPlugins::Interface::Parameters:: TReal cpPlugins::Interface::Parameters:: -GetValueAsReal( const std::string& name ) const +GetValueAsReal( const TString& name ) const { - static const std::string null_str = ""; TParameters::const_iterator pIt = this->m_Parameters.find( name ); if( pIt == this->m_Parameters.end( ) ) return( TReal( 0 ) ); if( pIt->second.first != Self::Real ) return( TReal( 0 ) ); - - return( std::atof( pIt->second.second.c_str( ) ) ); + return( TReal( std::atof( pIt->second.second.c_str( ) ) ) ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::Parameters:: GetValueAsStringList( - std::vector< std::string >& lst, const std::string& name + std::vector< TString >& lst, const TString& name ) const { } // ------------------------------------------------------------------------- void cpPlugins::Interface::Parameters:: -GetValueAsIntList( std::vector< TInt >& lst, const std::string& name ) const +GetValueAsIntList( std::vector< TInt >& lst, const TString& name ) const { } // ------------------------------------------------------------------------- void cpPlugins::Interface::Parameters:: -GetValueAsUintList( std::vector< TUint >& lst, const std::string& name ) const +GetValueAsUintList( std::vector< TUint >& lst, const TString& name ) const { } // ------------------------------------------------------------------------- void cpPlugins::Interface::Parameters:: -GetValueAsRealList( std::vector< TReal >& lst, const std::string& name ) const +GetValueAsRealList( std::vector< TReal >& lst, const TString& name ) const { } diff --git a/lib/cpPlugins/Interface/Parameters.h b/lib/cpPlugins/Interface/Parameters.h index a806ee7..7a7578a 100644 --- a/lib/cpPlugins/Interface/Parameters.h +++ b/lib/cpPlugins/Interface/Parameters.h @@ -29,14 +29,17 @@ namespace cpPlugins UintList, RealList, IndexList, - PointList + PointList, + NoType }; - typedef std::pair< Self::Type, std::string > TParameter; - typedef std::map< std::string, TParameter > TParameters; typedef long TInt; typedef unsigned long TUint; typedef double TReal; + typedef std::string TString; + + typedef std::pair< Self::Type, TString > TParameter; + typedef std::map< TString, TParameter > TParameters; public: Parameters( ); @@ -45,76 +48,78 @@ namespace cpPlugins Self& operator=( const Self& other ); - void Configure( const Self::Type& type, const std::string& name ); - void SetValueAsString( const std::string& name, const std::string& v ); - void SetValueAsInt( const std::string& name, const TInt& v ); - void SetValueAsUint( const std::string& name, const TUint& v ); - void SetValueAsReal( const std::string& name, const TReal& v ); - void SetValueAsIndex( const std::string& name, const TUint& n, ... ); - void SetValueAsPoint( const std::string& name, const TUint& n, ... ); + void Configure( const Self::Type& type, const TString& name ); + void SetValueAsString( const TString& name, const TString& v ); + void SetValueAsInt( const TString& name, const TInt& v ); + void SetValueAsUint( const TString& name, const TUint& v ); + void SetValueAsReal( const TString& name, const TReal& v ); + void SetValueAsIndex( const TString& name, const TUint& n, ... ); + void SetValueAsPoint( const TString& name, const TUint& n, ... ); template< class I > void SetValueAsStringList( - const std::string& name, const I& b, const I& e + const TString& name, const I& b, const I& e ); template< class I > void SetValueAsIntList( - const std::string& name, const I& b, const I& e + const TString& name, const I& b, const I& e ); template< class I > void SetValueAsUintList( - const std::string& name, const I& b, const I& e + const TString& name, const I& b, const I& e ); template< class I > void SetValueAsRealList( - const std::string& name, const I& b, const I& e + const TString& name, const I& b, const I& e ); template< class I > void SetValueAsIndexList( - const std::string& name, const I& b, const I& e + const TString& name, const I& b, const I& e ); template< class I > void SetValueAsPointList( - const std::string& name, const I& b, const I& e + const TString& name, const I& b, const I& e ); - const std::string& GetValueAsString( const std::string& name ) const; - TInt GetValueAsInt( const std::string& name ) const; - TUint GetValueAsUint( const std::string& name ) const; - TReal GetValueAsReal( const std::string& name ) const; + std::vector< TString > GetParameters( ) const; + Self::Type GetParameterType( const TString& name ) const; + const TString& GetValueAsString( const TString& name ) const; + TInt GetValueAsInt( const TString& name ) const; + TUint GetValueAsUint( const TString& name ) const; + TReal GetValueAsReal( const TString& name ) const; template< class I > - I GetValueAsIndex( const std::string& name ) const; + I GetValueAsIndex( const TString& name ) const; template< class P > - P GetValueAsPoint( const std::string& name ) const; + P GetValueAsPoint( const TString& name ) const; void GetValueAsStringList( - std::vector< std::string >& lst, const std::string& name + std::vector< TString >& lst, const TString& name ) const; void GetValueAsIntList( - std::vector< TInt >& lst, const std::string& name + std::vector< TInt >& lst, const TString& name ) const; void GetValueAsUintList( - std::vector< TUint >& lst, const std::string& name + std::vector< TUint >& lst, const TString& name ) const; void GetValueAsRealList( - std::vector< TReal >& lst, const std::string& name + std::vector< TReal >& lst, const TString& name ) const; template< class I > void GetValueAsIndexList( - std::vector< I >& lst, const std::string& name + std::vector< I >& lst, const TString& name ) const; template< class P > void GetValueAsPointList( - std::vector< P >& lst, const std::string& name + std::vector< P >& lst, const TString& name ) const; diff --git a/lib/cpPlugins/Interface/Parameters.hxx b/lib/cpPlugins/Interface/Parameters.hxx index ac30bc9..f0c3a27 100644 --- a/lib/cpPlugins/Interface/Parameters.hxx +++ b/lib/cpPlugins/Interface/Parameters.hxx @@ -1,126 +1,91 @@ #ifndef __CPPLUGINS__INTERFACE__PARAMETERS__HXX__ #define __CPPLUGINS__INTERFACE__PARAMETERS__HXX__ +#include #include // ------------------------------------------------------------------------- -template< class I > -void cpPlugins::Interface::Parameters:: -SetValueAsStringList( const std::string& name, const I& b, const I& e ) -{ - TParameters::iterator pIt = this->m_Parameters.find( name ); - if( pIt == this->m_Parameters.end( ) ) - return; - if( pIt->second.first != Self::StringList ) - return; - - std::stringstream ss; - for( I i = b; i != e; ++i ) - ss << *i << ":"; - pIt->second = ss.str( ); -} - -// ------------------------------------------------------------------------- -template< class I > -void cpPlugins::Interface::Parameters:: -SetValueAsIntList( const std::string& name, const I& b, const I& e ) -{ - TParameters::iterator pIt = this->m_Parameters.find( name ); - if( pIt == this->m_Parameters.end( ) ) - return; - if( pIt->second.first != Self::IntList ) - return; - - std::stringstream ss; - for( I i = b; i != e; ++i ) - ss << *i << ":"; - pIt->second = ss.str( ); -} - -// ------------------------------------------------------------------------- -template< class I > -void cpPlugins::Interface::Parameters:: -SetValueAsUintList( const std::string& name, const I& b, const I& e ) -{ - TParameters::iterator pIt = this->m_Parameters.find( name ); - if( pIt == this->m_Parameters.end( ) ) - return; - if( pIt->second.first != Self::UintList ) - return; - - std::stringstream ss; - for( I i = b; i != e; ++i ) - ss << *i << ":"; - pIt->second = ss.str( ); -} - -// ------------------------------------------------------------------------- -template< class I > -void cpPlugins::Interface::Parameters:: -SetValueAsRealList( const std::string& name, const I& b, const I& e ) -{ - TParameters::iterator pIt = this->m_Parameters.find( name ); - if( pIt == this->m_Parameters.end( ) ) - return; - if( pIt->second.first != Self::RealList ) - return; - - std::stringstream ss; - for( I i = b; i != e; ++i ) - ss << *i << ":"; - pIt->second = ss.str( ); -} - -// ------------------------------------------------------------------------- -template< class I > -void cpPlugins::Interface::Parameters:: -SetValueAsIndexList( const std::string& name, const I& b, const I& e ) -{ - // TODO -} - -// ------------------------------------------------------------------------- -template< class I > -void cpPlugins::Interface::Parameters:: -SetValueAsPointList( const std::string& name, const I& b, const I& e ) -{ - // TODO -} +#define cpPlugins_Interface_Parameters_SetListMacro( TYPE ) \ + template< class I > \ + void cpPlugins::Interface::Parameters:: \ + SetValueAs##TYPE##List( const TString& name, const I& b, const I& e ) \ + { \ + TParameters::iterator pIt = this->m_Parameters.find( name ); \ + if( pIt == this->m_Parameters.end( ) ) \ + return; \ + if( pIt->second.first != Self::TYPE##List ) \ + return; \ + std::stringstream ss; \ + for( I i = b; i != e; ++i ) \ + ss << *i << ":"; \ + pIt->second = ss.str( ); \ + } + +cpPlugins_Interface_Parameters_SetListMacro( String ); +cpPlugins_Interface_Parameters_SetListMacro( Int ); +cpPlugins_Interface_Parameters_SetListMacro( Uint ); +cpPlugins_Interface_Parameters_SetListMacro( Real ); +cpPlugins_Interface_Parameters_SetListMacro( Index ); +cpPlugins_Interface_Parameters_SetListMacro( Point ); // ------------------------------------------------------------------------- template< class I > I cpPlugins::Interface::Parameters:: -GetValueAsIndex( const std::string& name ) const +GetValueAsIndex( const TString& name ) const { + I idx; TParameters::iterator pIt = this->m_Parameters.find( name ); - if( pIt == this->m_Parameters.end( ) ) - return( I( ) ); - if( pIt->second.first != Self::Index ) - return( I( ) ); - - // TODO: - return( I( ) ); + if( pIt != this->m_Parameters.end( ) ) + { + if( pIt->second.first == Self::Index ) + { + std::istringstream ss( pIt->second.second ); + std::string token; + unsigned int i = 0; + while( std::getline( ss, token, ',' ) ) + { + if( token != "" ) + idx[ i++ ] = std::atoi( token.c_str( ) ); + + } // elihw + + } // fi + + } // fi + return( idx ); } // ------------------------------------------------------------------------- template< class P > P cpPlugins::Interface::Parameters:: -GetValueAsPoint( const std::string& name ) const +GetValueAsPoint( const TString& name ) const { + P pnt; TParameters::iterator pIt = this->m_Parameters.find( name ); - if( pIt == this->m_Parameters.end( ) ) - return( P( ) ); - if( pIt->second.first != Self::Point ) - return( P( ) ); - - // TODO: - return( P( ) ); + if( pIt != this->m_Parameters.end( ) ) + { + if( pIt->second.first == Self::Point ) + { + std::istringstream ss( pIt->second.second ); + std::string token; + unsigned int i = 0; + while( std::getline( ss, token, ',' ) ) + { + if( token != "" ) + pnt[ i++ ] = std::atof( token.c_str( ) ); + + } // elihw + + } // fi + + } // fi + return( pnt ); } // ------------------------------------------------------------------------- template< class I > void cpPlugins::Interface::Parameters:: -GetValueAsIndexList( std::vector< I >& lst, const std::string& name ) const +GetValueAsIndexList( std::vector< I >& lst, const TString& name ) const { lst.clear( ); TParameters::iterator pIt = this->m_Parameters.find( name ); @@ -135,7 +100,7 @@ GetValueAsIndexList( std::vector< I >& lst, const std::string& name ) const // ------------------------------------------------------------------------- template< class P > void cpPlugins::Interface::Parameters:: -GetValueAsPointList( std::vector< P >& lst, const std::string& name ) const +GetValueAsPointList( std::vector< P >& lst, const TString& name ) const { lst.clear( ); TParameters::iterator pIt = this->m_Parameters.find( name ); diff --git a/lib/cpPlugins/Interface/ProcessObject.cxx b/lib/cpPlugins/Interface/ProcessObject.cxx index e05e7a8..61eaf96 100644 --- a/lib/cpPlugins/Interface/ProcessObject.cxx +++ b/lib/cpPlugins/Interface/ProcessObject.cxx @@ -15,8 +15,8 @@ GetClassType( ) const } // ------------------------------------------------------------------------- -const cpPlugins::Interface::ProcessObject:: -TParameters& cpPlugins::Interface::ProcessObject:: +const cpPlugins::Interface::Parameters& +cpPlugins::Interface::ProcessObject:: GetDefaultParameters( ) const { return( this->m_DefaultParameters ); @@ -24,7 +24,7 @@ GetDefaultParameters( ) const // ------------------------------------------------------------------------- void cpPlugins::Interface::ProcessObject:: -SetParameters( const TParameters& params ) +SetParameters( const cpPlugins::Interface::Parameters& params ) { this->m_Parameters = params; this->Modified( ); diff --git a/lib/cpPlugins/Interface/ProcessObject.h b/lib/cpPlugins/Interface/ProcessObject.h index f4c80ae..a977928 100644 --- a/lib/cpPlugins/Interface/ProcessObject.h +++ b/lib/cpPlugins/Interface/ProcessObject.h @@ -1,12 +1,11 @@ #ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__ #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__ -#include -#include #include #include #include #include +#include namespace cpPlugins { @@ -23,17 +22,14 @@ namespace cpPlugins typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef std::pair< std::string, std::string > TParameter; - typedef std::map< std::string, TParameter > TParameters; - public: itkTypeMacro( ProcessObject, Object ); public: virtual std::string GetClassName( ) const; virtual std::string GetClassType( ) const; - virtual const TParameters& GetDefaultParameters( ) const; - virtual void SetParameters( const TParameters& params ); + virtual const Parameters& GetDefaultParameters( ) const; + virtual void SetParameters( const Parameters& params ); virtual unsigned int GetNumberOfInputs( ) const; virtual unsigned int GetNumberOfOutputs( ) const; @@ -72,8 +68,8 @@ namespace cpPlugins protected: itk::ProcessObject::Pointer m_RealProcessObject; - TParameters m_DefaultParameters; - TParameters m_Parameters; + Parameters m_DefaultParameters; + Parameters m_Parameters; std::vector< DataObject::Pointer > m_Inputs; std::vector< DataObject::Pointer > m_Outputs; diff --git a/lib/cpPlugins/Interface/SinkObject.h b/lib/cpPlugins/Interface/SinkObject.h index 52723d1..4edc44c 100644 --- a/lib/cpPlugins/Interface/SinkObject.h +++ b/lib/cpPlugins/Interface/SinkObject.h @@ -19,9 +19,6 @@ namespace cpPlugins typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef Superclass::TParameter TParameter; - typedef Superclass::TParameters TParameters; - public: itkTypeMacro( SinkObject, ProcessObject ); diff --git a/lib/cpPlugins/Interface/SourceObject.h b/lib/cpPlugins/Interface/SourceObject.h index 0c036ce..ecb528c 100644 --- a/lib/cpPlugins/Interface/SourceObject.h +++ b/lib/cpPlugins/Interface/SourceObject.h @@ -19,9 +19,6 @@ namespace cpPlugins typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef Superclass::TParameter TParameter; - typedef Superclass::TParameters TParameters; - public: itkTypeMacro( SourceObject, ProcessObject ); diff --git a/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h b/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h index d9fe353..2f61c3e 100644 --- a/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h +++ b/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h @@ -19,9 +19,6 @@ namespace cpPlugins typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef Superclass::TParameter TParameter; - typedef Superclass::TParameters TParameters; - public: itkNewMacro( Self ); itkTypeMacro( @@ -39,10 +36,10 @@ namespace cpPlugins virtual std::string _GenerateData( ); template< unsigned int D > - std::string _GD0( ); + std::string _GD0( ); template< class P, unsigned int D > - std::string _GD1( ); + std::string _GD1( ); private: // Purposely not implemented