INCLUDE(cmake/Restrictions.cmake)
INCLUDE(cmake/Options.cmake)
-INCLUDE(cmake/Functions.cmake)
INCLUDE(cmake/KitwareTools.cmake)
OPTION(USE_QT4 "Build Qt4-based code" OFF)
-INCLUDE(cmake/Qt4Tools.cmake)
IF(USE_QT4)
+ INCLUDE(cmake/QtTools.cmake)
SET(
cpPlugins_Qt4_VTKWidget QVTKWidget
CACHE STRING "Base Qt4-based vtkRenderWindow"
)
ENDIF(USE_QT4)
+INCLUDE(cmake/Functions.cmake)
## ===========================
## == Use all valid subdirs ==
## ===========================
-SET(
- _include_dirs
- .
- lib
- lib/Itk2Vtk
- lib/Instances
- )
-FOREACH(_dir ${_include_dirs})
- INCLUDE_DIRECTORIES(
- ${PROJECT_SOURCE_DIR}/${_dir}
- ${PROJECT_BINARY_DIR}/${_dir}
- )
-ENDFOREACH(_dir)
+#SET(
+# _include_dirs
+# .
+# lib
+# lib/Itk2Vtk
+# lib/Instances
+# )
+#FOREACH(_dir ${_include_dirs})
+# INCLUDE_DIRECTORIES(
+# ${PROJECT_SOURCE_DIR}/${_dir}
+# ${PROJECT_BINARY_DIR}/${_dir}
+# )
+#ENDFOREACH(_dir)
## ===========================
## == Build different parts ==
## ===========================
-SUBDIRS(appli cmake lib plugins)
+SUBDIRS(appli lib plugins)
+#SUBDIRS(appli cmake lib plugins)
## eof - $RCSfile$
+++ /dev/null
-#include <iostream>
-#include <sstream>
-#include <vector>
-#include <appli/bash/Utility.h>
-
-// -------------------------------------------------------------------------
-void Output(
- std::stringstream& out,
- const std::vector< std::string >& defs
- )
-{
- if( defs.size( ) > 0 )
- {
- for( unsigned int k = 0; k < defs.size( ); ++k )
- {
- std::string cast_str = "dynamic_cast< ";
- cast_str += defs[ k ];
- cast_str += "* >( _obj )";
- if( k == 0 )
- out
- << " if( " << cast_str << " != NULL ) \\" << std::endl
- << " this->_fun( " << cast_str << " )";
- else
- out
- << " else if( " << cast_str << " != NULL ) \\" << std::endl
- << " this->_fun( " << cast_str << " )";
- if( k < defs.size( ) - 1 )
- out << "; \\";
- out << std::endl;
-
- } // rof
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void Dims(
- std::stringstream& out,
- const std::string& macro,
- const std::vector< std::string >& dims
- )
-{
- for( unsigned int k = 0; k < dims.size( ); ++k )
- {
- if( k == 0 )
- out
- << " " << macro << dims[ k ] << " )";
- else
- out
- << " else " << macro << dims[ k ] << " )";
- if( k < dims.size( ) - 1 )
- out << "; \\";
- out << std::endl;
-
- } // rof
-}
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Get parameters from input
- if( argc < 2 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " output_filename" << std::endl;
- return( 1 );
-
- } // fi
- std::string output_filename = argv[ 1 ];
- std::stringstream out;
-
- out << "#ifndef __cpPlugins__DEMANGLEBASE_MACROS__h__" << std::endl;
- out << "#define __cpPlugins__DEMANGLEBASE_MACROS__h__" << std::endl << std::endl;
-
- // Get base types
- std::vector< std::string > int_types, real_types, process_dims, visual_dims;
- cpPlugins_bash::Tokenize( int_types, "@cpPlugins_INTEGER_TYPES@", ";" );
- cpPlugins_bash::Tokenize( real_types, "@cpPlugins_REAL_TYPES@", ";" );
- cpPlugins_bash::Tokenize( process_dims, "@cpPlugins_PROCESS_DIMENSIONS@", ";" );
- cpPlugins_bash::Tokenize( visual_dims, "@cpPlugins_VISUAL_DIMENSIONS@", ";" );
-
- // Process image base
- std::string op = "itk::ImageBase< ";
- std::string cl = " >";
- std::vector< std::string > process_dims_tokens;
- for( auto i = process_dims.begin( ); i != process_dims.end( ); ++i )
- process_dims_tokens.push_back( op + *i + cl );
-
- out
- << "#define cpPlugins_Demangle_ImageProcessDims( _obj, _fun ) \\"
- << std::endl;
- Output( out, process_dims_tokens );
- out << std::endl;
-
- // Visual image base
- std::vector< std::string > visual_dims_tokens;
- for( auto i = visual_dims.begin( ); i != visual_dims.end( ); ++i )
- visual_dims_tokens.push_back( op + *i + cl );
- out
- << "#define cpPlugins_Demangle_ImageVisualDims( _obj, _fun ) \\"
- << std::endl;
- Output( out, visual_dims_tokens );
- out << std::endl;
-
- // Integer types
- op = "itk::Image< ";
- cl = ", _dim >";
- std::vector< std::string > int_tokens;
- for( auto i = int_types.begin( ); i != int_types.end( ); ++i )
- {
- int_tokens.push_back( op + *i + cl );
- int_tokens.push_back( op + std::string( "unsigned " ) + *i + cl );
-
- } // rof
- out
- << "#define cpPlugins_Demangle_ImageIntegers( _obj, _fun, _dim ) \\"
- << std::endl;
- Output( out, int_tokens );
- out << std::endl;
- out
- << "#define cpPlugins_Demangle_ImageIntegers_Dims( _obj, _fun ) \\"
- << std::endl;
- Dims( out, "cpPlugins_Demangle_ImageIntegers( _obj, _fun, ", process_dims );
- out << std::endl;
-
- // Real types
- std::vector< std::string > real_tokens;
- for( auto i = real_types.begin( ); i != real_types.end( ); ++i )
- real_tokens.push_back( op + *i + cl );
- out
- << "#define cpPlugins_Demangle_ImageReals( _obj, _fun, _dim ) \\"
- << std::endl;
- Output( out, real_tokens );
- out << std::endl;
- out
- << "#define cpPlugins_Demangle_ImageReals_Dims( _obj, _fun ) \\"
- << std::endl;
- Dims( out, "cpPlugins_Demangle_ImageReals( _obj, _fun, ", process_dims );
- out << std::endl;
-
- // Complex types
- op = "itk::Image< std::complex< ";
- cl = " >, _dim >";
- std::vector< std::string > complex_tokens;
- for( auto i = real_types.begin( ); i != real_types.end( ); ++i )
- complex_tokens.push_back( op + *i + cl );
- out
- << "#define cpPlugins_Demangle_ImageComplexes( _obj, _fun, _dim ) \\"
- << std::endl;
- Output( out, complex_tokens );
- out << std::endl;
- out
- << "#define cpPlugins_Demangle_ImageComplexes_Dims( _obj, _fun ) \\"
- << std::endl;
- Dims( out, "cpPlugins_Demangle_ImageComplexes( _obj, _fun, ", process_dims );
- out << std::endl;
-
- // Color types
- op = "itk::Image< itk::RGBPixel< ";
- cl = " >, _dim >";
- std::vector< std::string > color_tokens;
- for( auto i = int_types.begin( ); i != int_types.end( ); ++i )
- color_tokens.push_back( op + *i + cl );
- for( auto i = int_types.begin( ); i != int_types.end( ); ++i )
- color_tokens.push_back( op + std::string( "unsigned " ) + *i + cl );
- for( auto i = real_types.begin( ); i != real_types.end( ); ++i )
- color_tokens.push_back( op + *i + cl );
- op = "itk::Image< itk::RGBAPixel< ";
- for( auto i = int_types.begin( ); i != int_types.end( ); ++i )
- color_tokens.push_back( op + *i + cl );
- for( auto i = int_types.begin( ); i != int_types.end( ); ++i )
- color_tokens.push_back( op + std::string( "unsigned " ) + *i + cl );
- for( auto i = real_types.begin( ); i != real_types.end( ); ++i )
- color_tokens.push_back( op + *i + cl );
- out
- << "#define cpPlugins_Demangle_ImageColors( _obj, _fun, _dim ) \\"
- << std::endl;
- Output( out, color_tokens );
- out << std::endl;
- out
- << "#define cpPlugins_Demangle_ImageColors_Dims( _obj, _fun ) \\"
- << std::endl;
- Dims( out, "cpPlugins_Demangle_ImageColors( _obj, _fun, ", process_dims );
- out << std::endl;
-
- // FixedArray types
- op = "itk::Image< itk::FixedArray< ";
- cl = ", _dim >, _dim >";
- std::vector< std::string > fixedarray_tokens;
- for( auto i = int_types.begin( ); i != int_types.end( ); ++i )
- fixedarray_tokens.push_back( op + *i + cl );
- for( auto i = int_types.begin( ); i != int_types.end( ); ++i )
- fixedarray_tokens.push_back( op + "unsigned " + *i + cl );
- for( auto i = real_types.begin( ); i != real_types.end( ); ++i )
- fixedarray_tokens.push_back( op + *i + cl );
- out
- << "#define cpPlugins_Demangle_ImageFixedArrays( _obj, _fun, _dim ) \\"
- << std::endl;
- Output( out, fixedarray_tokens );
- out << std::endl;
- out
- << "#define cpPlugins_Demangle_ImageFixedArrays_Dims( _obj, _fun ) \\"
- << std::endl;
- Dims( out, "cpPlugins_Demangle_ImageFixedArrays( _obj, _fun, ", process_dims );
- out << std::endl;
-
- // Covariant types
- op = "itk::Image< itk::CovariantVector< ";
- cl = ", _dim >, _dim >";
- std::vector< std::string > cov_tokens;
- for( auto i = real_types.begin( ); i != real_types.end( ); ++i )
- cov_tokens.push_back( op + *i + cl );
- out
- << "#define cpPlugins_Demangle_ImageCovariantVectors( _obj, _fun, _dim ) \\"
- << std::endl;
- Output( out, cov_tokens );
- out << std::endl;
- out
- << "#define cpPlugins_Demangle_ImageCovariantVectors_Dims( _obj, _fun ) \\"
- << std::endl;
- Dims(
- out, "cpPlugins_Demangle_ImageCovariantVectors( _obj, _fun, ", process_dims
- );
- out << std::endl;
-
- // Vector types
- op = "itk::Image< itk::Vector< ";
- cl = ", _dim >, _dim >";
- std::vector< std::string > vec_tokens;
- for( auto i = real_types.begin( ); i != real_types.end( ); ++i )
- vec_tokens.push_back( op + *i + cl );
- out
- << "#define cpPlugins_Demangle_ImageVectors( _obj, _fun, _dim ) \\"
- << std::endl;
- Output( out, vec_tokens );
- out << std::endl;
- out
- << "#define cpPlugins_Demangle_ImageVectors_Dims( _obj, _fun ) \\"
- << std::endl;
- Dims( out, "cpPlugins_Demangle_ImageVectors( _obj, _fun, ", process_dims );
- out << std::endl;
-
- // Point types
- op = "itk::Image< itk::Point< ";
- cl = ", _dim >, _dim >";
- std::vector< std::string > pnt_tokens;
- for( auto i = real_types.begin( ); i != real_types.end( ); ++i )
- pnt_tokens.push_back( op + *i + cl );
- out
- << "#define cpPlugins_Demangle_ImagePoints( _obj, _fun, _dim ) \\"
- << std::endl;
- Output( out, pnt_tokens );
- out << std::endl;
- out
- << "#define cpPlugins_Demangle_ImagePoints_Dims( _obj, _fun ) \\"
- << std::endl;
- Dims( out, "cpPlugins_Demangle_ImagePoints( _obj, _fun, ", process_dims );
- out << std::endl;
-
- // 2nd rank types
- op = "itk::Image< itk::SymmetricSecondRankTensor< ";
- cl = ", _dim >, _dim >";
- std::vector< std::string > sym_tokens;
- for( auto i = real_types.begin( ); i != real_types.end( ); ++i )
- sym_tokens.push_back( op + *i + cl );
- out
- << "#define cpPlugins_Demangle_ImageSymmetricSecondRankTensors( _obj, _fun, _dim ) \\"
- << std::endl;
- Output( out, sym_tokens );
- out << std::endl;
- out
- << "#define cpPlugins_Demangle_ImageSymmetricSecondRankTensors_Dims( _obj, _fun ) \\"
- << std::endl;
- Dims( out, "cpPlugins_Demangle_ImageSymmetricSecondRankTensors( _obj, _fun, ", process_dims );
- out << std::endl;
-
- // Diffusion tensors
- op = "itk::Image< itk::DiffusionTensor3D< ";
- cl = " >, 3 >";
- std::vector< std::string > diff_tokens;
- for( auto i = real_types.begin( ); i != real_types.end( ); ++i )
- diff_tokens.push_back( op + *i + cl );
- out
- << "#define cpPlugins_Demangle_ImageDiffusionTensors3D( _obj, _fun ) \\"
- << std::endl;
- Output( out, diff_tokens );
- out << std::endl;
-
- // Matrix types
- op = "itk::Image< itk::Matrix< ";
- cl = ", _dim, _dim >, _dim >";
- std::vector< std::string > mat_tokens;
- for( auto i = real_types.begin( ); i != real_types.end( ); ++i )
- mat_tokens.push_back( op + *i + cl );
- out
- << "#define cpPlugins_Demangle_ImageMatrices( _obj, _fun, _dim ) \\"
- << std::endl;
- Output( out, mat_tokens );
- out << std::endl;
- out
- << "#define cpPlugins_Demangle_ImageMatrices_Dims( _obj, _fun ) \\"
- << std::endl;
- Dims( out, "cpPlugins_Demangle_ImageMatrices( _obj, _fun, ", process_dims );
- out << std::endl;
-
- // Offset types
- op = "itk::Image< itk::Offset< ";
- cl = " > >";
- std::vector< std::string > off_tokens;
- for( auto i = process_dims.begin( ); i != process_dims.end( ); ++i )
- off_tokens.push_back( op + *i + cl );
- out
- << "#define cpPlugins_Demangle_ImageOffsets( _obj, _fun ) \\"
- << std::endl;
- Output( out, off_tokens );
- out << std::endl;
-
- // Real types
- op = "itk::Mesh< ";
- cl = ", _dim >";
- std::vector< std::string > mesh_tokens;
- for( auto i = real_types.begin( ); i != real_types.end( ); ++i )
- mesh_tokens.push_back( op + *i + cl );
- out
- << "#define cpPlugins_Demangle_Meshes( _obj, _fun, _dim ) \\"
- << std::endl;
- Output( out, mesh_tokens );
- out << std::endl;
- out
- << "#define cpPlugins_Demangle_Meshes_Dims( _obj, _fun ) \\"
- << std::endl;
- Dims( out, "cpPlugins_Demangle_Meshes( _obj, _fun, ", visual_dims );
- out << std::endl;
-
- out << std::endl;
- out << "#endif // __cpPlugins__DEMANGLEBASE_MACROS__h__" << std::endl << std::endl;
-
- if( !( cpPlugins_bash::Write( out.str( ), output_filename ) ) )
- {
- std::cerr << "Error writing header" << std::endl;
- return( 1 );
-
- } // fi
- return( 0 );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#include <cmath>
-#include <deque>
-#include <iostream>
-#include <map>
-#include <sstream>
-#include <vector>
-#include <appli/bash/Utility.h>
-
-// -------------------------------------------------------------------------
-typedef std::map< char, std::vector< std::string > > TCommands;
-typedef std::map< std::string, std::vector< std::string > > TDefinitions;
-
-// -------------------------------------------------------------------------
-void AddDefinitions( TDefinitions& defs, const std::string& cmd );
-void InitDefinitions( TDefinitions& defs );
-void Lines( TCommands& commands, const std::deque< std::string >& lines );
-void ExpandDefinitions( TDefinitions& defs );
-std::vector< std::string > Expand(
- const std::vector< std::string >& commands, const TDefinitions& defs
- );
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Get parameters from input
- if( argc < 5 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " definitions library_name source_prefix number_of_files" << std::endl;
- return( 1 );
-
- } // fi
- std::string input_definitions = argv[ 1 ];
- std::string library_name = argv[ 2 ];
- std::string source_prefix = argv[ 3 ];
- std::string header_file = source_prefix + std::string( ".h" );
- std::stringstream nfiles_str( argv[ 4 ] );
- unsigned int number_of_files;
- nfiles_str >> number_of_files;
-
- // Read input instances
- std::string buffer;
- if( !cpPlugins_bash::Read( buffer, input_definitions ) )
- {
- std::cerr
- << "Error reading input instances from \""
- << input_definitions << "\""
- << std::endl;
- return( 1 );
-
- } // fi
-
- // Put it in a line-by-line structure
- std::deque< std::string > lines;
- cpPlugins_bash::Tokenize( lines, buffer, "\n" );
-
- // Parse commands
- TCommands commands;
- Lines( commands, lines );
-
- // Init definitions
- TDefinitions defs;
- InitDefinitions( defs );
- auto dIt = commands.find( 'd' );
- if( dIt != commands.end( ) )
- {
- for( auto vIt = dIt->second.begin( ); vIt != dIt->second.end( ); ++vIt )
- AddDefinitions( defs, *vIt );
-
- } // fi
-
- // Expand definitions
- ExpandDefinitions( defs );
-
- // Expand code
- std::vector< std::string > before;
- auto bIt = commands.find( 'b' );
- if( bIt != commands.end( ) )
- before = bIt->second;
- auto templates = Expand( commands[ 't' ], defs );
- auto includes = Expand( commands[ 'i' ], defs );
- auto classes = Expand( commands[ 'c' ], defs );
-
- // Write header file
- std::stringstream header;
- header
- << "#ifndef __" << library_name << "__h__" << std::endl
- << "#define __" << library_name << "__h__" << std::endl << std::endl
- << "#define ITK_MANUAL_INSTANTIATION" << std::endl;
- for( auto i = before.begin( ); i != before.end( ); ++i )
- header << std::endl << *i;
- header << std::endl;
- for( auto i = includes.begin( ); i != includes.end( ); ++i )
- header << "#include <" << *i << ">" << std::endl;
- for( auto i = templates.begin( ); i != templates.end( ); ++i )
- header << "#include <" << *i << ".h>" << std::endl;
- header << std::endl;
- /* TODO
- for( auto i = classes.begin( ); i != classes.end( ); ++i )
- header
- << "extern template class " << *i << ";" << std::endl;
- */
- header
- << std::endl << "#endif // __" << library_name << "__H__" << std::endl;
- if( !( cpPlugins_bash::Write( header.str( ), header_file ) ) )
- {
- std::cerr << "Error writing header" << std::endl;
- return( 1 );
-
- } // fi
-
- // Write source code
- unsigned int classes_per_file =
- ( unsigned int )(
- std::floor( double( classes.size( ) ) / double( number_of_files ) )
- );
- if( classes_per_file == 0 )
- classes_per_file = 1;
- std::vector< std::vector< std::string > > all_lines( 1 );
- for( unsigned int c_id = 0; c_id < classes.size( ); ++c_id )
- {
- all_lines[ all_lines.size( ) - 1 ].push_back( classes[ c_id ] );
- if( c_id % classes_per_file == classes_per_file - 1 )
- all_lines.push_back( std::vector< std::string >( ) );
-
- } // rof
-
- // Paranoiac code
- while( all_lines.size( ) > number_of_files )
- {
- all_lines[ all_lines.size( ) - 2 ].insert(
- all_lines[ all_lines.size( ) - 2 ].end( ),
- all_lines[ all_lines.size( ) - 1 ].begin( ),
- all_lines[ all_lines.size( ) - 1 ].end( )
- );
- all_lines.pop_back( );
-
- } // elihw
- while( all_lines.size( ) < number_of_files )
- all_lines.push_back( std::vector< std::string >( ) );
-
- // Real write
- for( unsigned int f_id = 0; f_id < all_lines.size( ); ++f_id )
- {
- std::stringstream source;
- source << "#define ITK_MANUAL_INSTANTIATION" << std::endl;
- source
- << "#include <" << library_name << "_Export.h>"
- << std::endl;
- for( auto i = before.begin( ); i != before.end( ); ++i )
- source << std::endl << *i;
- source << std::endl;
- if( templates.size( ) > 0 )
- {
- for( auto i = includes.begin( ); i != includes.end( ); ++i )
- source << "#include <" << *i << ">" << std::endl;
-
- for( auto i = templates.begin( ); i != templates.end( ); ++i )
- {
- source << "#include <" << *i << ".h>" << std::endl;
- source << "#include <" << *i << ".hxx>" << std::endl;
-
- } // rof
- source << std::endl;
-
- } // fi
- for(
- auto c_it = all_lines[ f_id ].begin( );
- c_it != all_lines[ f_id ].end( );
- ++c_it
- )
- source
- << "template class " << library_name << "_EXPORT "
- << *c_it << ";" << std::endl;
- source << std::endl << "// eof" << std::endl;
- std::stringstream source_file;
- source_file
- << source_prefix << "_" << f_id << ".cxx";
- if( !( cpPlugins_bash::Write( source.str( ), source_file.str( ) ) ) )
- {
- std::cerr << "Error writing header" << std::endl;
- return( 1 );
-
- } // fi
-
- } // rof
- return( 0 );
-}
-
-// -------------------------------------------------------------------------
-void AddDefinitions( TDefinitions& defs, const std::string& cmd )
-{
- std::vector< std::string > tokens;
- cpPlugins_bash::Tokenize( tokens, cmd, "=;" );
- for( unsigned int i = 1; i < tokens.size( ); ++i )
- defs[ tokens[ 0 ] ].push_back( tokens[ i ] );
-}
-
-// -------------------------------------------------------------------------
-void InitDefinitions( TDefinitions& defs )
-{
- AddDefinitions( defs, "integers=@cpPlugins_INTEGER_TYPES@" );
- AddDefinitions( defs, "reals=@cpPlugins_REAL_TYPES@" );
- AddDefinitions( defs, "colors=RGBPixel;RGBAPixel" );
- AddDefinitions( defs, "vectors=CovariantVector;Point;SymmetricSecondRankTensor;Vector" );
- AddDefinitions( defs, "tensors=DiffusionTensor3D" );
- AddDefinitions( defs, "matrices=Matrix" );
- AddDefinitions( defs, "process_dims=@cpPlugins_PROCESS_DIMENSIONS@" );
- AddDefinitions( defs, "visual_dims=@cpPlugins_VISUAL_DIMENSIONS@" );
- AddDefinitions( defs, "naturals=unsigned #integers#" );
- AddDefinitions( defs, "pixels=#integers#;#naturals#;#reals#" );
-}
-
-// -------------------------------------------------------------------------
-void Lines( TCommands& commands, const std::deque< std::string >& lines )
-{
- std::string buffer;
-
- for( auto l = lines.begin( ); l != lines.end( ); ++l )
- {
- auto pos = l->find_first_not_of( " " );
- char cmd = tolower( ( *l )[ pos ] );
- commands[ cmd ].push_back(
- l->substr( l->find_first_not_of( " ", pos + 1 ) )
- );
-
- } // elihw
-}
-
-// -------------------------------------------------------------------------
-void ExpandDefinitions( TDefinitions& defs )
-{
- for( auto d = defs.begin( ); d != defs.end( ); ++d )
- {
- std::deque< std::string > q;
- q.insert( q.end( ), d->second.begin( ), d->second.end( ) );
-
- std::vector< std::string > n;
- while( q.size( ) > 0 )
- {
- auto v = q.front( );
- q.pop_front( );
-
- auto pos = v.find( "#" );
- if( pos != std::string::npos )
- {
- auto epos = v.find( "#", pos + 1 );
- auto tok = v.substr( pos, epos - pos + 1 );
- auto id = tok.substr( 1, tok.size( ) - 2 );
- auto rd = defs.find( id );
- if( rd != defs.end( ) )
- for( auto r = rd->second.begin( ); r != rd->second.end( ); ++r )
- q.push_back( cpPlugins_bash::Replace( v, tok, *r ) );
- }
- else
- n.push_back( v );
-
- } // elihw
- d->second = n;
-
- } // rof
-}
-
-// -------------------------------------------------------------------------
-std::vector< std::string > Expand(
- const std::vector< std::string >& commands, const TDefinitions& defs
- )
-{
- std::vector< std::string > lines;
- std::deque< std::string > q;
- q.insert( q.end( ), commands.begin( ), commands.end( ) );
- while( q.size( ) > 0 )
- {
- auto v = q.front( );
- q.pop_front( );
-
- auto d_pos = v.find( "$" );
- auto n_pos = v.find( "#" );
-
- if( d_pos != std::string::npos )
- {
- auto e_pos = v.find( "$", d_pos + 1 );
- auto tok = v.substr( d_pos, e_pos - d_pos + 1 );
- std::vector< std::string > tokens;
- cpPlugins_bash::Tokenize( tokens, tok, "$;" );
- for( auto t = tokens.begin( ); t != tokens.end( ); ++t )
- {
- if( *t == " ")
- q.push_front( cpPlugins_bash::Replace( v, tok, "" ) );
- else
- q.push_front( cpPlugins_bash::Replace( v, tok, *t ) );
-
- } // rof
- }
- else if( n_pos != std::string::npos )
- {
- auto e_pos = v.find( "#", n_pos + 1 );
- auto tok = v.substr( n_pos, e_pos - n_pos + 1 );
- auto id = tok.substr( 1, tok.size( ) - 2 );
- auto rd = defs.find( id );
- if( rd != defs.end( ) )
- for( auto r = rd->second.begin( ); r != rd->second.end( ); ++r )
- q.push_front( cpPlugins_bash::Replace( v, tok, *r ) );
- }
- else
- lines.push_back( v );
-
- } // elihw
-
- return( lines );
-}
-
-// eof - $RCSfile$
--- /dev/null
+#ifndef __cpPlugins__bash__Config__h__
+#define __cpPlugins__bash__Config__h__
+
+// -------------------------------------------------------------------------
+#include <cmath>
+#include <cstring>
+#include <deque>
+#include <fstream>
+#include <iostream>
+#include <map>
+#include <queue>
+#include <sstream>
+#include <string>
+
+// -------------------------------------------------------------------------
+#define cpPlugins_CONFIG_INTEGER_TYPES "@cpPlugins_CONFIG_INTEGER_TYPES@"
+#define cpPlugins_CONFIG_REAL_TYPES "@cpPlugins_CONFIG_REAL_TYPES@"
+#define cpPlugins_CONFIG_PROCESS_DIMENSIONS "@cpPlugins_CONFIG_PROCESS_DIMENSIONS@"
+#define cpPlugins_CONFIG_VISUAL_DIMENSIONS "@cpPlugins_CONFIG_VISUAL_DIMENSIONS@"
+#define cpPlugins_CONFIG_COLOR_PIXELS "@cpPlugins_CONFIG_COLOR_PIXELS@"
+#define cpPlugins_CONFIG_VECTORS "@cpPlugins_CONFIG_VECTORS@"
+#define cpPlugins_CONFIG_DIFFUSIONTENSORS "@cpPlugins_CONFIG_DIFFUSIONTENSORS@"
+#define cpPlugins_CONFIG_MATRICES "@cpPlugins_CONFIG_MATRICES@"
+
+// -------------------------------------------------------------------------
+#define cpPlugins_bash_OS_@CMAKE_SYSTEM_NAME@
+#ifdef cpPlugins_bash_OS_Windows
+# define cpPlugins_bash_STRTOK( A, B, N ) strtok_s( A, B, N )
+# define cpPlugins_bash_SPRINTF( B, S, O ) sprintf_s( B, S, "%s", O );
+#else // cpPlugins_bash_OS_Windows
+# define cpPlugins_bash_STRTOK( A, B, N ) std::strtok( A, B )
+# define cpPlugins_bash_SPRINTF( B, S, O ) std::sprintf( B, "%s", O );
+#endif // cpPlugins_bash_OS_Windows
+
+// -------------------------------------------------------------------------
+typedef std::deque< std::string > TStrings;
+typedef std::map< std::string, TStrings > TCommands;
+
+/**
+ */
+namespace cpPlugins_bash
+{
+ // -----------------------------------------------------------------------
+ template< class _TTokens >
+ inline void Tokenize(
+ _TTokens& tokens, const std::string& str, const std::string& delims
+ )
+ {
+ tokens.clear( );
+ if( str.size( ) > 0 )
+ {
+ auto ssize = str.size( );
+ char* buffer = new char[ ssize + 1 ];
+ for( unsigned long i = 0; i < ssize; ++i )
+ buffer[ i ] = str[ i ];
+ buffer[ ssize ] = '\0';
+ char* next;
+ char* it = cpPlugins_bash_STRTOK( buffer, delims.c_str( ), &next );
+ while( it != NULL )
+ {
+ tokens.push_back( std::string( it ) );
+ it = cpPlugins_bash_STRTOK( NULL, delims.c_str( ), &next );
+
+ } // elihw
+ delete [] buffer;
+
+ } // fi
+ }
+
+ // -----------------------------------------------------------------------
+ inline std::string Replace(
+ const std::string& str, const std::string& sub, const std::string& nsub
+ )
+ {
+ std::string res = str;
+ size_t index;
+ while( ( index = res.find( sub ) ) != std::string::npos )
+ res.replace( index, sub.size( ), nsub );
+ return( res );
+ }
+
+ // -----------------------------------------------------------------------
+ inline bool Read( std::string& buffer, const std::string& fname )
+ {
+ buffer = "";
+ std::ifstream file_stream( fname.c_str( ) );
+ if( !file_stream )
+ return( false );
+ file_stream.seekg( 0, std::ios::end );
+ buffer.reserve( ( unsigned int )( file_stream.tellg( ) ) );
+ file_stream.seekg( 0, std::ios::beg );
+ buffer.assign(
+ ( std::istreambuf_iterator< char >( file_stream ) ),
+ std::istreambuf_iterator< char >( )
+ );
+ file_stream.close( );
+ return( true );
+ }
+
+ // -----------------------------------------------------------------------
+ inline bool Write( const std::string& buffer, const std::string& fname )
+ {
+ std::ofstream file_stream( fname.c_str( ), std::ofstream::binary );
+ if( !file_stream )
+ return( false );
+ file_stream.write( buffer.c_str( ), buffer.size( ) );
+ return( true );
+ }
+
+ // -----------------------------------------------------------------------
+ inline void Parse( TCommands& commands, const TStrings& lines )
+ {
+ for( auto l = lines.begin( ); l != lines.end( ); ++l )
+ {
+ auto line = l->substr( l->find_first_not_of( " " ) );
+ if( line != "" )
+ {
+ if( line[ 0 ] != '*' )
+ {
+ auto cmd = line.substr( 0, line.find( " " ) );
+ auto args = line.substr( line.find( " " ) + 1 );
+ commands[ cmd ].push_back( args );
+
+ } // fi
+
+ } // fi
+
+ } // rof
+ }
+
+ // -----------------------------------------------------------------------
+ inline void LoadDefinitions( TCommands& commands )
+ {
+ commands[ "define" ].push_back(
+ std::string( "int_types=" ) +
+ std::string( cpPlugins_CONFIG_INTEGER_TYPES )
+ );
+ commands[ "define" ].push_back(
+ std::string( "real_types=" ) +
+ std::string( cpPlugins_CONFIG_REAL_TYPES )
+ );
+ commands[ "define" ].push_back(
+ std::string( "process_dims=" ) +
+ std::string( cpPlugins_CONFIG_PROCESS_DIMENSIONS )
+ );
+ commands[ "define" ].push_back(
+ std::string( "visual_dims=" ) +
+ std::string( cpPlugins_CONFIG_VISUAL_DIMENSIONS )
+ );
+ commands[ "define" ].push_back(
+ std::string( "color_pixels=" ) +
+ std::string( cpPlugins_CONFIG_COLOR_PIXELS )
+ );
+ commands[ "define" ].push_back(
+ std::string( "vectors=" ) +
+ std::string( cpPlugins_CONFIG_VECTORS )
+ );
+ commands[ "define" ].push_back(
+ std::string( "diff_tensors=" ) +
+ std::string( cpPlugins_CONFIG_DIFFUSIONTENSORS )
+ );
+ commands[ "define" ].push_back(
+ std::string( "matrices=" ) +
+ std::string( cpPlugins_CONFIG_MATRICES )
+ );
+ commands[ "define" ].push_back(
+ std::string( "uint_types=unsigned #int_types#" )
+ );
+ commands[ "define" ].push_back(
+ std::string( "scalar_pixels=#int_types#;#uint_types#;#real_types#" )
+ );
+ }
+
+ // -----------------------------------------------------------------------
+ inline void ExpandDefinitions(
+ TCommands& definitions, const TCommands& commands
+ )
+ {
+ definitions.clear( );
+ auto defs = commands.find( "define" );
+ if( defs == commands.end( ) )
+ return;
+
+ std::map< std::string, std::string > values;
+ for( auto dIt = defs->second.begin( ); dIt != defs->second.end( ); ++dIt )
+ {
+ TStrings toks;
+ cpPlugins_bash::Tokenize( toks, *dIt, "=" );
+ if( toks.size( ) == 2 )
+ {
+ auto name = toks[ 0 ].substr( toks[ 0 ].find_first_not_of( " " ) );
+ auto val = toks[ 1 ].substr( toks[ 1 ].find_first_not_of( " " ) );
+ values[ name ] = val;
+
+ } // fi
+
+ } // rof
+ for( auto vIt = values.begin( ); vIt != values.end( ); ++vIt )
+ {
+ TStrings toks;
+ cpPlugins_bash::Tokenize( toks, vIt->second, ";" );
+ for( auto tIt = toks.begin( ); tIt != toks.end( ); ++tIt )
+ definitions[ vIt->first ].push_back( *tIt );
+
+ } // rof
+ for( auto dIt = definitions.begin( ); dIt != definitions.end( ); ++dIt )
+ {
+ auto name = std::string( "#" ) + dIt->first + std::string( "#" );
+ for( auto eIt = definitions.begin( ); eIt != definitions.end( ); ++eIt )
+ {
+ if( eIt != dIt )
+ {
+ auto vIt = eIt->second.begin( );
+ while( vIt != eIt->second.end( ) )
+ {
+ if( vIt->find( name ) != std::string::npos )
+ {
+ for(
+ auto wIt = dIt->second.begin( );
+ wIt != dIt->second.end( );
+ ++wIt
+ )
+ eIt->second.push_back(
+ cpPlugins_bash::Replace( *vIt, name, *wIt )
+ );
+ vIt = eIt->second.erase( vIt );
+ }
+ else
+ ++vIt;
+
+ } // elihw
+
+ } // fi
+
+ } // rof
+
+ } // rof
+ }
+
+ // -----------------------------------------------------------------------
+ inline void Expand(
+ TStrings& tfiles,
+ const TCommands& definitions,
+ const TCommands& commands,
+ const std::string& cmd
+ )
+ {
+ tfiles.clear( );
+ auto tIt = commands.find( cmd );
+ if( tIt == commands.end( ) )
+ return;
+
+ for( auto fIt = tIt->second.begin( ); fIt != tIt->second.end( ); ++fIt )
+ {
+ std::queue< std::string > q;
+ q.push( *fIt );
+ while( q.size( ) > 0 )
+ {
+ auto value = q.front( );
+ q.pop( );
+ auto spos = value.find( "#" );
+ if( spos != std::string::npos )
+ {
+ auto name = value.substr( spos + 1 );
+ auto epos = name.find( "#" );
+ name = name.substr( 0, epos );
+ auto dIt = definitions.find( name );
+ if( dIt != definitions.end( ) )
+ {
+ name = std::string( "#" ) + name + std::string( "#" );
+ for( auto vIt = dIt->second.begin( ); vIt != dIt->second.end( ); ++vIt )
+ q.push( cpPlugins_bash::Replace( value, name, *vIt ) );
+
+ } // fi
+ }
+ else
+ tfiles.push_back( value );
+
+ } // rof
+
+ } // rof
+ }
+
+} // ecapseman
+
+#endif // __cpPlugins__bash__Config__h__
+
+// eof - $RCSfile$
--- /dev/null
+#include <bash/Config.h>
+
+// -------------------------------------------------------------------------
+int main( int argc, char* argv[] )
+{
+ // Get inputs
+ if( argc < 4 )
+ {
+ std::cerr
+ << "Usage: " << argv[ 0 ]
+ << " definitons_file object_name output_file"
+ << std::endl;
+ return( 1 );
+
+ } // fi
+ std::string definitions_filename = argv[ 1 ];
+ std::string object_name = argv[ 2 ];
+ std::string output_filename = argv[ 3 ];
+
+ // Read inputs
+ std::string definitions_buffer;
+ if( !( cpPlugins_bash::Read( definitions_buffer, definitions_filename ) ) )
+ {
+ std::cout
+ << argv[ 0 ]
+ << ": Error reading definitions file \"" << definitions_filename
+ << "\"" << std::endl;
+ return( 1 );
+
+ } // fi
+
+ // Put it in a line-by-line structure
+ TStrings definitions_lines;
+ cpPlugins_bash::Tokenize( definitions_lines, definitions_buffer, "\n" );
+
+ // Parse input file
+ TCommands commands;
+ cpPlugins_bash::Parse( commands, definitions_lines );
+
+ // Load pre-compiled definitions
+ cpPlugins_bash::LoadDefinitions( commands );
+
+ // Expand definitions
+ TCommands definitions;
+ cpPlugins_bash::ExpandDefinitions( definitions, commands );
+
+ // Expand data
+ std::stringstream data;
+ data
+ << "#ifndef __cpPlugins__Demangler__" << object_name << "__h__" << std::endl
+ << "#define __cpPlugins__Demangler__" << object_name << "__h__" << std::endl
+ << std::endl;
+
+ for( auto cIt = commands.begin( ); cIt != commands.end( ); ++cIt )
+ {
+ if( cIt->first == "define" )
+ continue;
+
+ TStrings instances;
+ cpPlugins_bash::Expand( instances, definitions, commands, cIt->first );
+ TStrings toks;
+ cpPlugins_bash::Tokenize( toks, cIt->first, "|" );
+ if( toks.size( ) > 1 )
+ {
+ data
+ << "#define cpPlugins_Demangle_" << object_name << "_"
+ << toks[ 0 ] << "( o, f, ";
+ for( unsigned int i = 1; i < toks.size( ); ++i )
+ data << toks[ i ] << ", ";
+ data << "a ) \\";
+ }
+ else
+ data
+ << "#define cpPlugins_Demangle_" << object_name << "_"
+ << toks[ 0 ] << "( o, f, a ) \\";
+ data << std::endl;
+ std::string prefix = "";
+ for( auto iIt = instances.begin( ); iIt != instances.end( ); ++iIt )
+ {
+ data
+ << " " << prefix
+ << "if( dynamic_cast< " << *iIt << "* >( o ) != NULL ) \\"
+ << std::endl
+ << " this->f( a dynamic_cast< " << *iIt << "* >( o ) ); \\"
+ << std::endl;
+ prefix = "else ";
+
+ } // rof
+ data << " " << prefix << std::endl << std::endl;
+
+ } // rof
+
+ data
+ << "#endif // __cpPlugins__Demangler__" << object_name << "__h__"
+ << std::endl;
+ if( !( cpPlugins_bash::Write( data.str( ), output_filename ) ) )
+ {
+ std::cerr << "Error writing file." << std::endl;
+ return( 1 );
+
+ } // fi
+
+
+
+ /* TODO
+ TStrings instances;
+ cpPlugins_bash::Expand( instances, definitions, commands, "instances" );
+
+ // Build all instances
+ for( auto iIt = instances.begin( ); iIt != instances.end( ); ++iIt )
+ {
+ std::cout << *iIt << std::endl;
+
+ } // rof
+ */
+
+ return( 0 );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#include <bash/Config.h>
+
+// -------------------------------------------------------------------------
+int main( int argc, char* argv[] )
+{
+ // Get inputs
+ if( argc < 5 )
+ {
+ std::cerr
+ << "Usage: " << argv[ 0 ]
+ << " definitons_file library_name output_path number_of_sources"
+ << std::endl;
+ return( 1 );
+
+ } // fi
+ std::string definitions_filename = argv[ 1 ];
+ std::string library_name = argv[ 2 ];
+ std::string output_path = argv[ 3 ];
+ unsigned int number_of_sources = std::atoi( argv[ 4 ] );
+
+ // Read inputs
+ std::string definitions_buffer;
+ if( !( cpPlugins_bash::Read( definitions_buffer, definitions_filename ) ) )
+ {
+ std::cout
+ << argv[ 0 ]
+ << ": Error reading definitions file \"" << definitions_filename
+ << "\"" << std::endl;
+ return( 1 );
+
+ } // fi
+
+ // Put it in a line-by-line structure
+ TStrings definitions_lines;
+ cpPlugins_bash::Tokenize( definitions_lines, definitions_buffer, "\n" );
+
+ // Parse input file
+ TCommands commands;
+ cpPlugins_bash::Parse( commands, definitions_lines );
+
+ // Load pre-compiled definitions
+ cpPlugins_bash::LoadDefinitions( commands );
+
+ // Expand definitions
+ TCommands definitions;
+ cpPlugins_bash::ExpandDefinitions( definitions, commands );
+ definitions[ "_export_" ].clear( );
+ definitions[ "_export_" ].push_back( library_name + std::string( "_EXPORT" ) );
+
+ // Expand data
+ TStrings tfiles, cfiles, instances, minstances;
+ cpPlugins_bash::Expand( tfiles, definitions, commands, "tinclude" );
+ cpPlugins_bash::Expand( cfiles, definitions, commands, "cinclude" );
+ cpPlugins_bash::Expand( instances, definitions, commands, "instances" );
+ cpPlugins_bash::Expand( minstances, definitions, commands, "minstances" );
+
+ // Build all instances
+ TStrings all_instances;
+ for( auto iIt = instances.begin( ); iIt != instances.end( ); ++iIt )
+ {
+ std::stringstream str;
+ str << "template class " << library_name << "_EXPORT " << *iIt;
+ all_instances.push_back( str.str( ) );
+
+ } // rof
+ for( auto iIt = minstances.begin( ); iIt != minstances.end( ); ++iIt )
+ {
+ std::stringstream str;
+ str << "template " << *iIt;
+ all_instances.push_back( str.str( ) );
+
+ } // rof
+
+ // Prepare header file
+ std::stringstream header;
+ header
+ << "// Automaticaly generated file. Please do not modify." << std::endl
+ << "#ifndef __" << library_name << "__h__" << std::endl
+ << "#define __" << library_name << "__h__" << std::endl << std::endl;
+
+ auto hIt = commands.find( "header" );
+ if( hIt != commands.end( ) )
+ {
+ for( auto vIt = hIt->second.begin( ); vIt != hIt->second.end( ); ++vIt )
+ header << *vIt << std::endl;
+ header << std::endl;
+
+ } // fi
+
+ if( tfiles.size( ) > 0 )
+ {
+ for( auto tIt = tfiles.begin( ); tIt != tfiles.end( ); ++tIt )
+ {
+ TStrings toks;
+ cpPlugins_bash::Tokenize( toks, *tIt, ":|" );
+ if( toks.size( ) == 3 )
+ header
+ << "#include <" << toks[ 0 ] << "." << toks[ 1 ] << ">" << std::endl;
+
+ } // rof
+ header << std::endl;
+
+ } // fi
+ header << "#endif // __" << library_name << "__h__" << std::endl;
+
+ // Write header
+ std::stringstream header_filename;
+ header_filename << output_path << "/" << library_name << ".h";
+ if( !( cpPlugins_bash::Write( header.str( ), header_filename.str( ) ) ) )
+ {
+ std::cerr << "Error writing header file." << std::endl;
+ return( 1 );
+
+ } // fi
+
+ // Write source code
+ unsigned int instances_per_file =
+ ( unsigned int )(
+ std::floor( double( all_instances.size( ) ) / double( number_of_sources ) )
+ );
+ if( instances_per_file == 0 )
+ instances_per_file = 1;
+ std::vector< std::vector< std::string > > all_lines( 1 );
+ for( unsigned int c_id = 0; c_id < all_instances.size( ); ++c_id )
+ {
+ all_lines[ all_lines.size( ) - 1 ].push_back( all_instances[ c_id ] );
+ if( c_id % instances_per_file == instances_per_file - 1 )
+ all_lines.push_back( std::vector< std::string >( ) );
+
+ } // rof
+
+ // Paranoiac code
+ while( all_lines.size( ) > number_of_sources )
+ {
+ all_lines[ all_lines.size( ) - 2 ].insert(
+ all_lines[ all_lines.size( ) - 2 ].end( ),
+ all_lines[ all_lines.size( ) - 1 ].begin( ),
+ all_lines[ all_lines.size( ) - 1 ].end( )
+ );
+ all_lines.pop_back( );
+
+ } // elihw
+ while( all_lines.size( ) < number_of_sources )
+ all_lines.push_back( std::vector< std::string >( ) );
+
+ // Real write
+ for( unsigned int f_id = 0; f_id < all_lines.size( ); ++f_id )
+ {
+ std::stringstream source;
+ source
+ << "#include <" << library_name << "_Export.h>"
+ << std::endl;
+ source
+ << "#include <" << output_path<< "/" << library_name << ".h>"
+ << std::endl << std::endl;
+ if( tfiles.size( ) > 0 )
+ {
+ for( auto tIt = tfiles.begin( ); tIt != tfiles.end( ); ++tIt )
+ {
+ TStrings toks;
+ cpPlugins_bash::Tokenize( toks, *tIt, ":|" );
+ if( toks.size( ) == 3 )
+ source << "#include <" << toks[ 0 ] << "." << toks[ 2 ] << ">" << std::endl;
+
+ } // rof
+ source << std::endl;
+
+ } // fi
+
+ if( cfiles.size( ) > 0 )
+ {
+ for( auto cIt = cfiles.begin( ); cIt != cfiles.end( ); ++cIt )
+ source << "#include <" << *cIt << ">" << std::endl;
+ source << std::endl;
+
+ } // fi
+
+ for(
+ auto c_it = all_lines[ f_id ].begin( );
+ c_it != all_lines[ f_id ].end( );
+ ++c_it
+ )
+ source << *c_it << ";" << std::endl;
+ source << std::endl << "// eof" << std::endl;
+ std::stringstream source_file;
+ source_file
+ << output_path << "/" << library_name << "_" << f_id << ".cxx";
+ if( !( cpPlugins_bash::Write( source.str( ), source_file.str( ) ) ) )
+ {
+ std::cerr << "Error writing source code." << std::endl;
+ return( 1 );
+
+ } // fi
+
+ } // rof
+ return( 0 );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#include <bash/Config.h>
+
+// -------------------------------------------------------------------------
+typedef std::deque< std::string > TStrings;
+
+// -------------------------------------------------------------------------
+int main( int argc, char* argv[] )
+{
+ // Get inputs
+ if( argc < 3 )
+ {
+ std::cerr
+ << "Usage: " << argv[ 0 ]
+ << " definitons_file library_name"
+ << std::endl;
+ return( 1 );
+
+ } // fi
+ std::string definitions_filename = argv[ 1 ];
+ std::string library_name = argv[ 2 ];
+
+ // Read inputs
+ std::string definitions_buffer;
+ if( !( cpPlugins_bash::Read( definitions_buffer, definitions_filename ) ) )
+ {
+ std::cout
+ << argv[ 0 ]
+ << ": Error reading definitions file \"" << definitions_filename
+ << "\"" << std::endl;
+ return( 1 );
+
+ } // fi
+
+ // Put it in a line-by-line structure
+ TStrings definitions_lines;
+ cpPlugins_bash::Tokenize( definitions_lines, definitions_buffer, "\n" );
+
+ // Parse input file
+ TCommands commands;
+ cpPlugins_bash::Parse( commands, definitions_lines );
+
+ // Load pre-compiled definitions
+ cpPlugins_bash::LoadDefinitions( commands );
+
+ // Expand definitions
+ TCommands definitions;
+ cpPlugins_bash::ExpandDefinitions( definitions, commands );
+ definitions[ "_export_" ].clear( );
+ definitions[ "_export_" ].push_back( library_name + std::string( "_EXPORT" ) );
+
+ // Get class data
+ std::string class_name = commands[ "class" ][ 0 ];
+ std::string namespace_name = commands[ "namespace" ][ 0 ];
+ std::string superclass_name = commands[ "superclass" ][ 0 ];
+ std::stringstream header;
+ header
+ << "namespace "
+ << namespace_name << std::endl << "{" << std::endl
+ << " class "
+ << class_name << std::endl
+ << " : public " << superclass_name << std::endl
+ << " {" << std::endl
+ << " public:" << std::endl
+ << " typedef " << class_name << " Self;" << std::endl
+ << " typedef " << superclass_name << " Superclass;" << std::endl
+ << " typedef itk::SmartPointer< Self > Pointer;" << std::endl
+ << " typedef itk::SmartPointer< const Self > Pointer;" << std::endl
+ << " protected:" << std::endl
+ << " " << class_name << "( );" << std::endl
+ << " virtual ~" << class_name << "( );" << std::endl
+ << " virtual void _GenerateData( ) ITK_OVERRIDE;" << std::endl;
+
+ auto inputs = commands.find( "input" );
+ std::stringstream template_args, input_args;
+ unsigned long id = 0;
+ for(
+ auto iIt = inputs->second.begin( );
+ iIt != inputs->second.end( );
+ ++iIt, ++id
+ )
+ {
+ TStrings toks;
+ cpPlugins_bash::Tokenize( toks, *iIt, "|" );
+ if( iIt == inputs->second.begin( ) )
+ {
+ template_args << "class _T" << toks[ 2 ];
+ input_args << " _T" << toks[ 2 ] << "* input_" << toks[ 2 ];
+ }
+ else
+ {
+ template_args << ", class _T" << toks[ 2 ];
+ input_args << ", _T" << toks[ 2 ] << "* input_" << toks[ 2 ];
+ } // fi
+
+ header
+ << " template< " << template_args.str( ) << " >" << std::endl
+ << " inline void _GD_" << id << "( " << input_args.str( )
+ << " );" << std::endl;
+
+ } // rof
+
+ header
+ << " private:" << std::endl
+ << " " << class_name << "( const Self& );" << std::endl
+ << " Self& operator=( const Self& );" << std::endl;
+
+ header
+ << " };" << std::endl << std::endl
+ << "} // ecapseman" << std::endl;
+
+ // Source code
+ std::stringstream source;
+
+ source
+ << namespace_name << "::" << class_name << "::" << std::endl
+ << class_name << "( )" << std::endl
+ << " : Superclass( )" << std::endl
+ << "{" << std::endl
+ << "}" << std::endl << std::endl;
+
+ source
+ << namespace_name << "::" << class_name << "::" << std::endl
+ << "~" << class_name << "( )" << std::endl
+ << "{" << std::endl
+ << "}" << std::endl << std::endl;
+
+ source
+ << "void " << namespace_name << "::" << class_name << "::" << std::endl
+ << "_GenerateData( )" << std::endl
+ << "{" << std::endl
+ << " auto i = this->Get" << std::endl
+ << "}" << std::endl << std::endl;
+
+
+ std::cout << source.str( ) << std::endl;
+
+ return( 0 );
+}
+
+// eof - $RCSfile$
+++ /dev/null
-#ifndef __cpPlugins__bash__Utility__h__
-#define __cpPlugins__bash__Utility__h__
-
-#include <cstring>
-#include <fstream>
-#include <string>
-
-// -------------------------------------------------------------------------
-#define cpPlugins_bash_OS_@CMAKE_SYSTEM_NAME@
-#ifdef cpPlugins_bash_OS_Windows
-# define cpPlugins_bash_STRTOK( A, B, N ) strtok_s( A, B, N )
-# define cpPlugins_bash_SPRINTF( B, S, O ) sprintf_s( B, S, "%s", O );
-#else // cpPlugins_bash_OS_Windows
-# define cpPlugins_bash_STRTOK( A, B, N ) std::strtok( A, B )
-# define cpPlugins_bash_SPRINTF( B, S, O ) std::sprintf( B, "%s", O );
-#endif // cpPlugins_bash_OS_Windows
-
-// -------------------------------------------------------------------------
-namespace cpPlugins_bash
-{
- // -----------------------------------------------------------------------
- template< class _TTokens >
- inline void Tokenize(
- _TTokens& tokens, const std::string& str, const std::string& delims
- )
- {
- tokens.clear( );
- if( str.size( ) > 0 )
- {
- auto ssize = str.size( );
- char* buffer = new char[ ssize + 1 ];
- for( unsigned long i = 0; i < ssize; ++i )
- buffer[ i ] = str[ i ];
- buffer[ ssize ] = '\0';
- char* next;
- char* it = cpPlugins_bash_STRTOK( buffer, delims.c_str( ), &next );
- while( it != NULL )
- {
- tokens.push_back( std::string( it ) );
- it = cpPlugins_bash_STRTOK( NULL, delims.c_str( ), &next );
-
- } // elihw
- delete [] buffer;
-
- } // fi
- }
-
- // -----------------------------------------------------------------------
- inline std::string Replace(
- const std::string& str, const std::string& sub, const std::string& nsub
- )
- {
- std::string res = str;
- size_t index;
- while( ( index = res.find( sub ) ) != std::string::npos )
- res.replace( index, sub.size( ), nsub );
- return( res );
- }
-
- // -----------------------------------------------------------------------
- inline bool Read( std::string& buffer, const std::string& fname )
- {
- buffer = "";
- std::ifstream file_stream( fname.c_str( ) );
- if( !file_stream )
- return( false );
- file_stream.seekg( 0, std::ios::end );
- buffer.reserve( ( unsigned int )( file_stream.tellg( ) ) );
- file_stream.seekg( 0, std::ios::beg );
- buffer.assign(
- ( std::istreambuf_iterator< char >( file_stream ) ),
- std::istreambuf_iterator< char >( )
- );
- file_stream.close( );
- return( true );
- }
-
- // -----------------------------------------------------------------------
- inline bool Write( const std::string& buffer, const std::string& fname )
- {
- std::ofstream file_stream( fname.c_str( ), std::ofstream::binary );
- if( !file_stream )
- return( false );
- file_stream.write( buffer.c_str( ), buffer.size( ) );
- return( true );
- }
-
-} // ecapseman
-
-#endif // __cpPlugins__bash__Utility__h__
-
-// eof - $RCSfile$
## ==========================
## == Compile source files ==
## ==========================
-
+INCLUDE_DIRECTORIES(
+ ${PROJECT_SOURCE_DIR}/lib
+ ${PROJECT_BINARY_DIR}/lib
+ )
FOREACH(_src ${all_SOURCE_CXX_FILES})
GET_FILENAME_COMPONENT(_name ${_src} NAME_WE)
ADD_EXECUTABLE(${_pfx}_${_name} ${_src})
TARGET_LINK_LIBRARIES(
${_pfx}_${_name}
- ${cpPlugins_LIB}
+ cpPlugins
)
ENDFOREACH(_src)
FUNCTION(
CreateLib
lib_name
- lib_dir
lib_type
- lib_source_files
- lib_header_files
- lib_qt_ui_files
- lib_version
- lib_short_version
)
-## -- Configure inputs to be cmake-path compatible
-NormPaths(_sources ${lib_source_files})
-NormPaths(_headers ${lib_header_files})
-NormPaths(_qt_uis ${lib_qt_ui_files})
+
+## -- Configure inputs
+SET(_config_extensions .c.in .cpp.in .cxx.in .h.in .hpp.in .hxx.in .ui.in)
+SET(_all_files)
+FOREACH(_file ${ARGN})
+ GET_FILENAME_COMPONENT(_ext ${_file} EXT)
+ LIST(FIND _config_extensions ${_ext} _cfg)
+ IF(NOT ${_cfg} EQUAL -1)
+ STRING(
+ REPLACE
+ ${PROJECT_SOURCE_DIR}
+ ${PROJECT_BINARY_DIR}
+ _file_bin
+ ${_file}
+ )
+ STRING(LENGTH ${_file_bin} _file_bin_len)
+ MATH(EXPR _file_bin_len "${_file_bin_len}-3")
+ STRING(SUBSTRING ${_file_bin} 0 ${_file_bin_len} _file_bin)
+ CONFIGURE_FILE(${_file} ${_file_bin} @ONLY)
+ LIST(APPEND _all_files ${_file_bin})
+ ELSE(NOT ${_cfg} EQUAL -1)
+ LIST(APPEND _all_files ${_file})
+ ENDIF(NOT ${_cfg} EQUAL -1)
+ENDFOREACH(_file)
+
+## -- Separate files
+SET(_sources_extensions .c .cpp .cxx)
+SET(_headers_extensions .h .hpp .hxx)
+SET(_qt_ui_extensions .ui)
+SET(_demangler_extensions .d)
+SET(_srcs)
+SET(_hdrs)
+SET(_qts)
+SET(_demanglers)
+FOREACH(_file ${_all_files})
+ GET_FILENAME_COMPONENT(_ext ${_file} EXT)
+ LIST(FIND _sources_extensions ${_ext} _src)
+ LIST(FIND _headers_extensions ${_ext} _hdr)
+ LIST(FIND _qt_ui_extensions ${_ext} _ui)
+ LIST(FIND _demangler_extensions ${_ext} _dem)
+ IF(NOT ${_src} EQUAL -1)
+ LIST(APPEND _srcs ${_file})
+ ENDIF(NOT ${_src} EQUAL -1)
+ IF(NOT ${_hdr} EQUAL -1)
+ LIST(APPEND _hdrs ${_file})
+ ENDIF(NOT ${_hdr} EQUAL -1)
+ IF(NOT ${_ui} EQUAL -1)
+ LIST(APPEND _qts ${_file})
+ ENDIF(NOT ${_ui} EQUAL -1)
+ IF(NOT ${_dem} EQUAL -1)
+ LIST(APPEND _demanglers ${_file})
+ ENDIF(NOT ${_dem} EQUAL -1)
+ENDFOREACH(_file)
# -- Prepare Qt4-based code
IF(Qt4_FOUND)
## -- Guess what headers sould be qt-moc'ed
- Wrap_Qt_CPP(_qt_moc_sources ${_headers})
- IF(_qt_moc_sources)
- SET(_sources ${_sources} ${_qt_moc_sources})
- ENDIF(_qt_moc_sources)
+ Wrap_Qt_CPP(_moc ${_hdrs})
+ IF(_moc)
+ LIST(APPEND _srcs ${_moc})
+ ENDIF(_moc)
## -- Guess what qt-ui's sould be qt-uic'ed
## -- Wrap qt-ui headers: this is equivalent to QT4_WRAP_UI except to change
## -- the output file
- Wrap_Qt_UI(_qt_ui_headers ${_qt_uis})
- IF(_qt_ui_headers)
- SET(_headers ${_headers} ${_qt_ui_headers})
- SET(_sources ${_sources} ${_qt_ui_headers})
- ENDIF(_qt_ui_headers)
+ Wrap_Qt_UI(_qt_hdrs ${_qts})
+ IF(_qt_hdrs)
+ LIST(APPEND _hdrs ${_qt_hdrs})
+ ENDIF(_qt_hdrs)
ENDIF(Qt4_FOUND)
-## -- Ok, compile library
-IF(_sources)
- NormPaths(_cur_binary_dir ${CMAKE_CURRENT_BINARY_DIR})
- ADD_LIBRARY(${lib_name} ${lib_type} ${_sources} ${_headers})
- #SET_TARGET_PROPERTIES(
- # ${lib_name}
- # PROPERTIES
- # VERSION "${lib_version}"
- # SOVERSION "${lib_short_version}"
- # )
+## -- Create demanglers
+FOREACH(_d ${_demanglers})
+ STRING(
+ REPLACE
+ ${PROJECT_SOURCE_DIR}
+ ${PROJECT_BINARY_DIR}
+ _d_bin
+ ${_d}
+ )
+ GET_FILENAME_COMPONENT(_d_path ${_d_bin} DIRECTORY)
+ GET_FILENAME_COMPONENT(_out_name ${_d_bin} NAME_WE)
+ SET(_d_out ${_d_path}/${_out_name}_Demanglers.h)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${_d_out}
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${_d_path}
+ COMMAND ${cpPlugins_bash_CreateDemanglers_APP} ${_d} ${_out_name} ${_d_out}
+ DEPENDS ${cpPlugins_bash_CreateDemanglers_APP} ${_d}
+ )
+ LIST(APPEND _hdrs ${_d_out})
+ENDFOREACH(_d)
+
+## -- Real compilation
+SET(_hdrs_paths)
+FOREACH(_hdr ${_hdrs})
+ GET_FILENAME_COMPONENT(_path ${_hdr} DIRECTORY)
+ LIST(FIND _hdrs_paths ${_path} _path_idx)
+ IF(${_path_idx} EQUAL -1)
+ LIST(APPEND _hdrs_paths ${_path})
+ ENDIF(${_path_idx} EQUAL -1)
+ENDFOREACH(_hdr)
+INCLUDE_DIRECTORIES(
+ ${_hdrs_paths}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ )
+IF(_srcs)
+ ADD_LIBRARY(${lib_name} ${lib_type} ${_srcs} ${_hdrs})
GENERATE_EXPORT_HEADER(
${lib_name}
BASE_NAME ${lib_name}
EXPORT_FILE_NAME ${lib_name}_Export.h
STATIC_DEFINE ${lib_name}_BUILT_AS_STATIC
)
- SET(${lib_name}_LIB ${lib_name} CACHE INTERNAL "Library ${lib_name}")
-ENDIF(_sources)
+ENDIF(_srcs)
ENDFUNCTION()
## -------------------------------------------------------------------------
FUNCTION(
- LibFromDir
+ CompileLibFromDir
lib_name
- lib_dir
lib_type
- lib_source_dir
- lib_version
- lib_short_version
- )
-
-## -- Configure inputs to be cmake-path compatible
-NormPaths(_global_source_dir ${PROJECT_SOURCE_DIR})
-NormPaths(_global_binary_dir ${PROJECT_BINARY_DIR})
-NormPaths(_source_dir ${lib_source_dir})
-STRING(REPLACE "${_global_source_dir}" "" _local_source_dir ${_source_dir})
-SET(_binary_dir ${_global_binary_dir}${_local_source_dir})
-
-## -- Some useful variables
-SET(_sources_extensions .c .cpp .cxx)
-SET(_headers_extensions .h .hpp .hxx)
-SET(_qt_ui_extensions .ui)
-SET(_dirs ${_source_dir} ${_binary_dir})
-SET(_sources)
-SET(_headers)
-SET(_qt_uis)
-
-## -- Glob source code
-FOREACH(_d ${_dirs})
- FOREACH(_e ${_sources_extensions})
- FILE(GLOB_RECURSE _f "${_d}/*${_e}")
- SET(_sources ${_sources} ${_f})
- ENDFOREACH(_e)
- FOREACH(_e ${_headers_extensions})
- FILE(GLOB_RECURSE _f "${_d}/*${_e}")
- SET(_headers ${_headers} ${_f})
- ENDFOREACH(_e)
- FOREACH(_e ${_qt_ui_extensions})
- FILE(GLOB_RECURSE _f "${_d}/*${_e}")
- SET(_qt_uis ${_qt_uis} ${_f})
- ENDFOREACH(_e)
-ENDFOREACH(_d)
-
-## -- Configure some files
-FILE(GLOB_RECURSE _configs "${_source_dir}/*.in")
-FOREACH(_c ${_configs})
-
- ## -- Build input and output names
- NormPaths(_input_file ${_c})
- GET_FILENAME_COMPONENT(_input_name ${_input_file} NAME)
- GET_FILENAME_COMPONENT(_input_dir ${_input_file} DIRECTORY)
- STRING(REPLACE ".in" "" _output_name ${_input_name})
- STRING(REPLACE "${_global_source_dir}" "" _output_dir ${_input_dir})
- SET(_output_file "${_global_binary_dir}${_output_dir}/${_output_name}")
-
- ## -- Configure file
- CONFIGURE_FILE(${_input_file} ${_output_file} @ONLY)
-
- ## -- Add it to the correct list
- GET_FILENAME_COMPONENT(_output_ext ${_output_name} EXT)
- IF(
- "${_output_ext}" STREQUAL ".h"
- OR
- "${_output_ext}" STREQUAL ".hpp"
- OR
- "${_output_ext}" STREQUAL ".hxx"
- )
- SET(_headers ${_headers})
- ENDIF()
- IF(
- "${_output_ext}" STREQUAL ".c"
- OR
- "${_output_ext}" STREQUAL ".cpp"
- OR
- "${_output_ext}" STREQUAL ".cxx"
- )
- SET(_sources ${_sources})
- ENDIF()
- IF("${_output_ext}" STREQUAL ".ui")
- SET(_qt_uis ${_qt_uis})
- ENDIF()
-ENDFOREACH(_c)
-IF(ARGN)
- LIST(APPEND _sources ${ARGN})
-ENDIF(ARGN)
-
-## -- Create library
-CreateLib(
- ${lib_name} ${lib_dir} ${lib_type}
- "${_sources}" "${_headers}" "${_qt_uis}"
- "${lib_version}" "${lib_short_version}"
+ lib_dir
)
-
+FILE(GLOB_RECURSE _files "${lib_dir}/*")
+CreateLib(${lib_name} ${lib_type} ${_files} ${ARGN})
ENDFUNCTION()
## -------------------------------------------------------------------------
FUNCTION(
CompileInstances
out_lib_name
- lib_dir
def_file
number_of_files
- prefix
- version
- short_version
)
-## -- Configure inputs to be cmake-path compatible
-NormPaths(_def_file ${def_file})
-GET_FILENAME_COMPONENT(_def_name ${_def_file} NAME_WE)
-GET_FILENAME_COMPONENT(_def_dir ${_def_file} DIRECTORY)
-NormPaths(_global_source_dir ${PROJECT_SOURCE_DIR})
-NormPaths(_global_binary_dir ${PROJECT_BINARY_DIR})
-STRING(REPLACE "${_global_source_dir}" "" _out_dir ${_def_dir})
-SET(_out_base "${_global_binary_dir}${_out_dir}")
-SET(_out_header "${_out_base}/${_def_name}.h")
-SET(_lib_name "${prefix}${_def_name}")
-SET(_input_extra_code "${_global_source_dir}${_out_dir}/${_def_name}_extra.cxx")
+
+### -- Configure inputs to be cmake-path compatible
+SET(_src_dir ${CMAKE_CURRENT_SOURCE_DIR})
+SET(_bin_dir ${CMAKE_CURRENT_BINARY_DIR})
+SET(_def_file "${_src_dir}/${def_file}")
## -- Infere source code filenames
MATH(EXPR _last_range "${number_of_files}-1")
-SET(_out_code)
+SET(_out_code "${_bin_dir}/${out_lib_name}.h")
FOREACH(_n RANGE 0 ${_last_range})
- LIST(APPEND _out_code ${_out_base}/${_def_name}_${_n}.cxx)
+ LIST(APPEND _out_code ${_bin_dir}/${out_lib_name}_${_n}.cxx)
ENDFOREACH(_n)
-## -- Add extra code, if any
-SET(_all_out_code ${_out_code})
-IF(EXISTS ${_input_extra_code})
- LIST(APPEND _all_out_code ${_input_extra_code})
-ENDIF(EXISTS ${_input_extra_code})
-
## -- Command to write source code
ADD_CUSTOM_COMMAND(
- OUTPUT ${_out_header} ${_out_code}
- DEPENDS ${cpPlugins_bash_BuildInstances_APP} ${_def_file}
- COMMAND ${cpPlugins_bash_BuildInstances_APP} ${_def_file} ${_lib_name} ${_out_base}/${_def_name} ${number_of_files}
+ OUTPUT ${_out_code}
+ DEPENDS ${cpPlugins_bash_CreateInstances_APP} ${_def_file}
+ COMMAND ${cpPlugins_bash_CreateInstances_APP} ${_def_file} ${out_lib_name} ${_bin_dir} ${number_of_files}
)
## -- Create library
-CreateLib(
- "${_lib_name}" ${lib_dir} SHARED
- "${_all_out_code}" "${_out_header}" ""
- "${version}" "${short_version}"
- )
-
-## -- Return value
-SET(${out_lib_name} ${_lib_name} PARENT_SCOPE)
+CreateLib(${out_lib_name} SHARED "${_out_code}")
ENDFUNCTION()
## -------------------------------------------------------------------------
-FUNCTION(Wrap_cpPlugins output_lib source_dir version short_version prefix)
-
-## -- Configure inputs to be cmake-path compatible
-NormPaths(_source_dir ${source_dir})
-NormPaths(_global_source_dir ${PROJECT_SOURCE_DIR})
-NormPaths(_global_binary_dir ${PROJECT_BINARY_DIR})
-STRING(REPLACE "${_global_source_dir}" "" _out_dir ${_source_dir})
-SET(_out_dir "${_global_binary_dir}${_out_dir}")
-FILE(MAKE_DIRECTORY ${_out_dir})
-GET_FILENAME_COMPONENT(_lib_name ${_source_dir} NAME_WE)
-SET(_lib_name ${prefix}${_lib_name})
-
-## -- Get source code
-FILE(GLOB_RECURSE _hdr_h "${_source_dir}/*.h")
-FILE(GLOB_RECURSE _hdr_hxx "${_source_dir}/*.hxx")
-FILE(GLOB_RECURSE _hdr_hpp "${_source_dir}/*.hpp")
-FILE(GLOB_RECURSE _src_c "${_source_dir}/*.c")
-FILE(GLOB_RECURSE _src_cxx "${_source_dir}/*.cxx")
-FILE(GLOB_RECURSE _src_cpp "${_source_dir}/*.cpp")
-FILE(GLOB_RECURSE _qt_ui "${_source_dir}/*.ui")
+FUNCTION(
+ CreatePlugin
+ lib_name
+ lib_dir
+ number_of_files
+ )
-## -- Identify sources to wrap
+GET_FILENAME_COMPONENT(_lib_dir ${lib_dir} REALPATH)
+FILE(GLOB_RECURSE _files "${_lib_dir}/*")
SET(_hdr_to_wrap)
-FOREACH(_h ${_hdr_h})
- FILE(READ ${_h} _txt)
+SET(_instances)
+FOREACH(_file ${_files})
+ FILE(READ ${_file} _txt)
STRING(FIND "${_txt}" "cpPluginsObject" _res)
IF(NOT ${_res} EQUAL -1)
- LIST(APPEND _hdr_to_wrap ${_h})
+ LIST(APPEND _hdr_to_wrap ${_file})
ENDIF(NOT ${_res} EQUAL -1)
-ENDFOREACH(_h)
-
-## -- Integrate all source files
-SET(_all_src ${_src_c} ${_src_cpp} ${_src_cxx})
-SET(_all_hdr ${_hdr_h} ${_hdr_hpp} ${_hdr_hxx})
+ GET_FILENAME_COMPONENT(_ext ${_file} EXT)
+ IF(${_ext} STREQUAL ".i")
+ LIST(APPEND _instances ${_file})
+ ENDIF(${_ext} STREQUAL ".i")
+ENDFOREACH(_file)
+
+IF(_instances)
+ FOREACH(_instance ${_instances})
+ STRING(
+ REPLACE
+ ${PROJECT_SOURCE_DIR}
+ ${PROJECT_BINARY_DIR}
+ _out_dir
+ ${_lib_dir}
+ )
+ MATH(EXPR _last_range "${number_of_files}-1")
+ SET(_out_code "${_out_dir}/${lib_name}.h")
+ FOREACH(_n RANGE 0 ${_last_range})
+ LIST(APPEND _out_code ${_out_dir}/${lib_name}_${_n}.cxx)
+ ENDFOREACH(_n)
+
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${_out_code}
+ DEPENDS ${cpPlugins_bash_CreateInstances_APP} ${_instance}
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${_out_dir}
+ COMMAND ${cpPlugins_bash_CreateInstances_APP} ${_instance} ${lib_name} ${_out_dir} ${number_of_files}
+ )
+ LIST(APPEND _files ${_out_code})
+ ENDFOREACH(_instance)
+ENDIF(_instances)
-## -- Wrap plugins
IF(_hdr_to_wrap)
- SET(_host ${_out_dir}/${_lib_name}_host.cxx)
+ STRING(
+ REPLACE
+ ${PROJECT_SOURCE_DIR}
+ ${PROJECT_BINARY_DIR}
+ _out_dir
+ ${_lib_dir}
+ )
+ SET(_host ${_out_dir}/${lib_name}_host.cxx)
ADD_CUSTOM_COMMAND(
OUTPUT ${_host}
DEPENDS ${cpPlugins_bash_HostCreator_APP} ${_hdr_to_wrap}
- COMMAND ${cpPlugins_bash_HostCreator_APP} ${_lib_name} ${_host} ${_hdr_to_wrap}
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${_out_dir}
+ COMMAND ${cpPlugins_bash_HostCreator_APP} ${lib_name} ${_host} ${_hdr_to_wrap}
)
- SET(_all_src ${_all_src} ${_host})
+ LIST(APPEND _files ${_host})
ENDIF(_hdr_to_wrap)
-## -- Ok, build library
-IF(_all_src)
- CreateLib(
- ${_lib_name} leo SHARED
- "${_all_src}" "${_all_hdr}" "${_qt_ui}"
- "${version}" "${short_version}"
- ${ARGN}
- )
- SET(${output_lib} ${_lib_name} PARENT_SCOPE)
-ELSE(_all_src)
- MESSAGE(FATAL_ERROR "No source code found to build \"${_lib_name}\"")
-ENDIF(_all_src)
-ENDFUNCTION()
-
-## -------------------------------------------------------------------------
-FUNCTION(AppFromDir output_app source_dir)
-
-## -- Configure inputs to be cmake-path compatible
-NormPaths(_global_source_dir ${PROJECT_SOURCE_DIR})
-NormPaths(_global_binary_dir ${PROJECT_BINARY_DIR})
-NormPaths(_source_dir ${source_dir})
-STRING(REPLACE "${_global_source_dir}" "" _local_source_dir ${_source_dir})
-SET(_binary_dir ${_global_binary_dir}${_local_source_dir})
-IF(${output_app})
- SET(_app_name ${${output_app}})
-ELSE(${output_app})
- GET_FILENAME_COMPONENT(_app_name ${_source_dir} NAME_WE)
-ENDIF(${output_app})
-SET(_app_name_option OFF)
-IF(ARGN)
- LIST(GET ARGN 0 _app_name_option)
-ENDIF(ARGN)
-OPTION(
- BUILD_${_app_name}
- "Build \"${_app_name}\" application"
- ${_app_name_option}
- )
-
-## -- Real build commands
-IF(BUILD_${_app_name})
- ## -- Some useful variables
- SET(_sources_extensions .c .cpp .cxx)
- SET(_headers_extensions .h .hpp .hxx)
- SET(_qt_ui_extensions .ui)
- SET(_dirs ${_source_dir} ${_binary_dir})
- SET(_sources)
- SET(_headers)
- SET(_qt_uis)
-
- ## -- Glob source code
- FOREACH(_d ${_dirs})
- FOREACH(_e ${_sources_extensions})
- FILE(GLOB_RECURSE _f "${_d}/*${_e}")
- SET(_sources ${_sources} ${_f})
- ENDFOREACH(_e)
- FOREACH(_e ${_headers_extensions})
- FILE(GLOB_RECURSE _f "${_d}/*${_e}")
- SET(_headers ${_headers} ${_f})
- ENDFOREACH(_e)
- FOREACH(_e ${_qt_ui_extensions})
- FILE(GLOB_RECURSE _f "${_d}/*${_e}")
- SET(_qt_uis ${_qt_uis} ${_f})
- ENDFOREACH(_e)
- ENDFOREACH(_d)
-
- ## -- Configure some files
- FILE(GLOB_RECURSE _configs "${_source_dir}/*.in")
- FOREACH(_c ${_configs})
-
- ## -- Build input and output names
- NormPaths(_input_file ${_c})
- GET_FILENAME_COMPONENT(_input_name ${_input_file} NAME)
- GET_FILENAME_COMPONENT(_input_dir ${_input_file} DIRECTORY)
- STRING(REPLACE ".in" "" _output_name ${_input_name})
- STRING(REPLACE "${_global_source_dir}" "" _output_dir ${_input_dir})
- SET(_output_file "${_global_binary_dir}${_output_dir}/${_output_name}")
-
- ## -- Configure file
- CONFIGURE_FILE(${_input_file} ${_output_file} @ONLY)
-
- ## -- Add it to the correct list
- GET_FILENAME_COMPONENT(_output_ext ${_output_name} EXT)
- IF(
- "${_output_ext}" STREQUAL ".h"
- OR
- "${_output_ext}" STREQUAL ".hpp"
- OR
- "${_output_ext}" STREQUAL ".hxx"
- )
- SET(_headers ${_headers})
- ENDIF()
- IF(
- "${_output_ext}" STREQUAL ".c"
- OR
- "${_output_ext}" STREQUAL ".cpp"
- OR
- "${_output_ext}" STREQUAL ".cxx"
- )
- SET(_sources ${_sources})
- ENDIF()
- IF("${_output_ext}" STREQUAL ".ui")
- SET(_qt_uis ${_qt_uis})
- ENDIF()
- ENDFOREACH(_c)
-
- # -- Prepare Qt4-based code
- IF(Qt4_FOUND)
-
- ## -- Guess what headers sould be qt-moc'ed
- Wrap_Qt_CPP(_qt_moc_sources ${_headers})
- IF(_qt_moc_sources)
- SET(_sources ${_sources} ${_qt_moc_sources})
- ENDIF(_qt_moc_sources)
- ## -- Guess what qt-ui's sould be qt-uic'ed
- ## -- Wrap qt-ui headers: this is equivalent to QT4_WRAP_UI except to
- ## -- change the output file
- Wrap_Qt_UI(_qt_ui_headers ${_qt_uis})
- IF(_qt_ui_headers)
- SET(_headers ${_headers} ${_qt_ui_headers})
- SET(_sources ${_sources} ${_qt_ui_headers})
- ENDIF(_qt_ui_headers)
- ENDIF(Qt4_FOUND)
-
- ## -- Ok, compile application
- IF(_sources)
- 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} ${_sources})
- SET(${output_app} ${_app_name} PARENT_SCOPE)
- ELSE(_sources)
- SET(${output_app} "" PARENT_SCOPE)
- MESSAGE(FATAL_ERROR "No source code found to build \"${_app_name}\"")
- ENDIF(_sources)
-ENDIF(BUILD_${_app_name})
+CreateLib(${lib_name} SHARED ${_files})
ENDFUNCTION()
## == Some configurable options ==
## ===============================
-SET(cpPlugins_NUMBER_OF_FILES "10" CACHE STRING "Number of compiled files.")
-SET(
- cpPlugins_INTEGER_TYPES
- "char;short;int;long" CACHE STRING "Accepted integer types."
- )
-SET(
- cpPlugins_REAL_TYPES
- "float;double" CACHE STRING "Accepted real types."
- )
-SET(
- cpPlugins_PROCESS_DIMENSIONS
- "1;2;3;4" CACHE STRING "Accepted processing dimensions."
- )
+SET(cpPlugins_CONFIG_NUMBER_OF_FILES "10" CACHE STRING "Number of compiled files.")
+SET(cpPlugins_CONFIG_INTEGER_TYPES "char;short;int;long" CACHE STRING "Accepted integer types.")
+SET(cpPlugins_CONFIG_REAL_TYPES "float;double" CACHE STRING "Accepted real types.")
+SET(cpPlugins_CONFIG_PROCESS_DIMENSIONS "1;2;3;4" CACHE STRING "Accepted processing dimensions.")
+SET(cpPlugins_CONFIG_VISUAL_DIMENSIONS "2;3" CACHE STRING "Accepted visual dimensions.")
+SET(cpPlugins_CONFIG_COLOR_PIXELS "RGBPixel;RGBAPixel" CACHE STRING "Accepted color pixels.")
+SET(cpPlugins_CONFIG_VECTORS "CovariantVector;Point;SymmetricSecondRankTensor;Vector" CACHE STRING "Accepted vectors.")
+SET(cpPlugins_CONFIG_DIFFUSIONTENSORS "DiffusionTensor3D" CACHE STRING "Accepted diffusion tensors.")
+SET(cpPlugins_CONFIG_MATRICES "Matrix" CACHE STRING "Accepted matrices.")
+
SET(
- cpPlugins_VISUAL_DIMENSIONS
- "2;3" CACHE STRING "Accepted visual dimensions."
+ _all_configs
+ cpPlugins_CONFIG_INTEGER_TYPES
+ cpPlugins_CONFIG_REAL_TYPES
+ cpPlugins_CONFIG_PROCESS_DIMENSIONS
+ cpPlugins_CONFIG_VISUAL_DIMENSIONS
+ cpPlugins_CONFIG_COLOR_PIXELS
+ cpPlugins_CONFIG_VECTORS
+ cpPlugins_CONFIG_DIFFUSIONTENSORS
+ cpPlugins_CONFIG_MATRICES
)
+SET(_real_configs)
+FOREACH(_cfg ${_all_configs})
+ FOREACH(_type ${${_cfg}})
+ LIST(APPEND _real_configs "${_cfg}_${_type}")
+ ENDFOREACH(_type)
+ENDFOREACH(_cfg)
+
+SET(cpPlugins_ALL_CONFIGS "${_real_configs}" CACHE INTERNAL "All valid configurations." FORCE)
## eof - $RCSfile$
## ====================
-## == Some variables ==
+## == Base libraries ==
## ====================
-SET(_dir ${CMAKE_CURRENT_SOURCE_DIR})
-SET(_ver "${prj_VERSION}" "${prj_SHORT_VERSION}")
+CompileLibFromDir(cp_tinyxml2 SHARED tinyxml2)
+IF(USE_QT4)
+ CompileLibFromDir(cp_QCustomPlot SHARED QCustomPlot)
+ TARGET_LINK_LIBRARIES(cp_QCustomPlot ${QT_LIBRARIES})
+ENDIF(USE_QT4)
+CompileLibFromDir(cpExtensions SHARED cpExtensions)
+TARGET_LINK_LIBRARIES(cpExtensions ${QT_LIBRARIES} ${ITK_LIBRARIES} ${VTK_LIBRARIES})
-## ===========================
-## == Third party libraries ==
-## ===========================
-
-LibFromDir(cpPlugins_tinyxml2 ${PROJECT_BINARY_DIR}/lib SHARED ${_dir}/tinyxml2 ${_ver})
-IF(Qt4_FOUND)
- LibFromDir(cpPlugins_QCustomPlot ${PROJECT_BINARY_DIR}/lib SHARED ${_dir}/QCustomPlot ${_ver})
- TARGET_LINK_LIBRARIES(cpPlugins_QCustomPlot ${QT_LIBRARIES})
-ENDIF(Qt4_FOUND)
-LibFromDir(cpExtensions ${PROJECT_BINARY_DIR}/lib SHARED ${_dir}/cpExtensions ${_ver})
-TARGET_LINK_LIBRARIES(cpExtensions ${ITK_LIBRARIES} ${VTK_LIBRARIES} ${QT_LIBRARIES})
-
-## =====================
-## == Build instances ==
-## =====================
+## ===============
+## == Instances ==
+## ===============
SUBDIRS(Instances)
-## ========================
-## == Build main library ==
-## ========================
-
-SET(_demangle_dir "${CMAKE_CURRENT_BINARY_DIR}/cpPlugins/BaseObjects")
-ADD_CUSTOM_COMMAND(
- OUTPUT "${_demangle_dir}/DemangleBase.h"
- COMMAND ${CMAKE_COMMAND} -E make_directory ${_demangle_dir}
- COMMAND ${cpPlugins_bash_BuildDemangleHeader_APP} "${_demangle_dir}/DemangleBase.h"
- DEPENDS ${cpPlugins_bash_BuildDemangleHeader_APP}
+## ==================
+## == Main library ==
+## ==================
+
+FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cpPlugins/RealConfig.h "#ifndef __cpPlugins__RealConfig__h__\n")
+FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/cpPlugins/RealConfig.h "#define __cpPlugins__RealConfig__h__\n\n")
+FOREACH(_def ${cpPlugins_ALL_CONFIGS})
+ FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/cpPlugins/RealConfig.h "#define ${_def}\n")
+ENDFOREACH(_def)
+FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/cpPlugins/RealConfig.h "\n#endif // __cpPlugins__RealConfig__h__\n")
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/Instances)
+CompileLibFromDir(cpPlugins SHARED cpPlugins ${CMAKE_CURRENT_BINARY_DIR}/cpPlugins/RealConfig.h)
+TARGET_LINK_LIBRARIES(
+ cpPlugins
+ cp_tinyxml2
+ cpExtensions
+ ${QT_LIBRARIES} ${ITK_LIBRARIES} ${VTK_LIBRARIES}
+ ${cpPlugins_Instances}
)
-LibFromDir(cpPlugins ${PROJECT_BINARY_DIR}/lib SHARED ${_dir}/cpPlugins ${_ver} ${_demangle_dir}/DemangleBase.h)
-TARGET_LINK_LIBRARIES(cpPlugins cpPlugins_tinyxml2 cpExtensions ${cpPlugins_Instances})
-
-## ======================
-## == Build Qt library ==
-## ======================
-
-IF(Qt4_FOUND)
- LibFromDir(cpBaseQtApplication ${PROJECT_BINARY_DIR}/lib SHARED ${_dir}/cpBaseQtApplication ${_ver})
- TARGET_LINK_LIBRARIES(cpBaseQtApplication ${cpPlugins_LIB})
-ENDIF(Qt4_FOUND)
## ===================================
## == Libraries to dynamically load ==
FILE(APPEND ${PROJECT_BINARY_DIR}/cpPlugins_Libraries.config "${_lib}\n")
ENDFOREACH(_lib)
-## eof - $RCSfile$
+## eof - $RCSfilfe$
--- /dev/null
+header #define ITK_MANUAL_INSTANTIATION
+
+tinclude itkArray:h|hxx
+tinclude itkFixedArray:h|hxx
+tinclude itk#color_pixels#:h|hxx
+tinclude itk#vectors#:h|hxx
+tinclude itk#matrices#:h|hxx
+tinclude itk#diff_tensors#:h|hxx
+tinclude itkSymmetricEigenAnalysis:h|hxx
+
+instances itk::Array< #scalar_pixels# >
+instances itk::FixedArray< #scalar_pixels#, #process_dims# >
+instances itk::FixedArray< #scalar_pixels#, 8 >
+instances itk::#color_pixels#< #scalar_pixels# >
+instances itk::#vectors#< #real_types#, #process_dims# >
+instances itk::#diff_tensors#< #real_types# >
+instances itk::#matrices#< #real_types#, #process_dims#, #process_dims# >
+instances itk::SymmetricEigenAnalysis< itk::Matrix< #real_types#, #process_dims#, #process_dims# >, itk::FixedArray< #real_types#, #process_dims# >, itk::Matrix< #real_types#, #process_dims#, #process_dims# > >
+
+define my_vectors=Vector;Point
+
+minstances #_export_# std::ostream& itk::operator<< < #real_types#, #process_dims# >( std::ostream& a, itk::#my_vectors#< #real_types#, #process_dims# > const& b )
+
+** eof - $RCSfile$
--- /dev/null
+header #define ITK_MANUAL_INSTANTIATION
+
+tinclude itkBoundingBox:h|hxx
+
+cinclude itkVectorContainer.hxx
+
+instances itk::BoundingBox< unsigned long, #process_dims#, float, itk::VectorContainer< unsigned long, itk::Point< #real_types#, #process_dims# > > >
+instances itk::BoundingBox< unsigned long, #process_dims#, double, itk::VectorContainer< unsigned long, itk::Point< #real_types#, #process_dims# > > >
+
+** eof - $RCSfile$
-## ===========================
-## == Compile each instance ==
-## ===========================
+SET(
+ _all_defs
+ BaseObjects
+ SimpleImages
+ ImageIterators
+ ImageFiltersBases
+ BoundingBoxes
+ Meshes
+ )
-FILE(GLOB _instances "${CMAKE_CURRENT_SOURCE_DIR}/*.i")
-SET(_all_instances)
-FOREACH(_instance ${_instances})
+SET(_all_libs)
+FOREACH(_def ${_all_defs})
CompileInstances(
- _lib_name
- ${PROJECT_BINARY_DIR}/lib
- ${_instance} ${cpPlugins_NUMBER_OF_FILES}
- "" "${prj_VERSION}" "${prj_SHORT_VERSION}"
+ cpInstances_${_def}
+ ${_def}.i
+ ${cpPlugins_CONFIG_NUMBER_OF_FILES}
)
- LIST(APPEND _all_instances ${_lib_name})
-ENDFOREACH(_instance)
+ LIST(APPEND _all_libs cpInstances_${_def})
+ENDFOREACH(_def)
SET(
- cpPlugins_Instances ${_all_instances}
+ cpPlugins_Instances ${_all_libs}
CACHE INTERNAL "All valid instances." FORCE
)
-## ===========
-## == Links ==
-## ===========
-SET(_pfx "cpPlugins_")
-TARGET_LINK_LIBRARIES(${_pfx}BaseObjects ${ITK_LIBRARIES})
-TARGET_LINK_LIBRARIES(${_pfx}Images ${_pfx}BaseObjects)
-TARGET_LINK_LIBRARIES(${_pfx}BoundingBoxes ${_pfx}BaseObjects)
-TARGET_LINK_LIBRARIES(${_pfx}Meshes ${_pfx}BoundingBoxes)
-TARGET_LINK_LIBRARIES(${_pfx}ImageIterators ${_pfx}Images)
-TARGET_LINK_LIBRARIES(${_pfx}ImageFilters ${_pfx}Images ${_pfx}ImageIterators)
-TARGET_LINK_LIBRARIES(${_pfx}ImageNeighborhoodIterators ${_pfx}Images)
-TARGET_LINK_LIBRARIES(${_pfx}Paths ${VTK_LIBRARIES} ${_pfx}Images)
+TARGET_LINK_LIBRARIES(cpInstances_BaseObjects ${ITK_LIBRARIES})
+TARGET_LINK_LIBRARIES(cpInstances_SimpleImages cpInstances_BaseObjects)
+TARGET_LINK_LIBRARIES(cpInstances_ImageIterators cpInstances_SimpleImages)
+TARGET_LINK_LIBRARIES(cpInstances_ImageFiltersBases cpInstances_SimpleImages)
+TARGET_LINK_LIBRARIES(cpInstances_BoundingBoxes cpInstances_BaseObjects)
+TARGET_LINK_LIBRARIES(cpInstances_Meshes cpInstances_BoundingBoxes)
-## eof - $RCSfile$
+## eof - $RCSfilfe$
--- /dev/null
+header #define ITK_MANUAL_INSTANTIATION
+
+tinclude itkImageSource:h|hxx
+
+cinclude itk#color_pixels#.h
+cinclude itk#vectors#.h
+cinclude itk#diff_tensors#.h
+cinclude itk#matrices#.h
+
+instances itk::ImageSource< itk::Image< #scalar_pixels#, #process_dims# > >
+instances itk::ImageSource< itk::Image< itk::#color_pixels#< #scalar_pixels# >, #process_dims# > >
+instances itk::ImageSource< itk::Image< itk::#vectors#< #real_types#, #process_dims# >, #process_dims# > >
+instances itk::ImageSource< itk::Image< itk::#diff_tensors#< #real_types# >, 3 > >
+instances itk::ImageSource< itk::Image< itk::#matrices#< #real_types#, #process_dims#, #process_dims# >, #process_dims# > >
+instances itk::ImageSource< itk::Image< itk::Offset< #process_dims# >, #process_dims# > >
+
+** eof - $RCSfile$
--- /dev/null
+header #define ITK_MANUAL_INSTANTIATION
+
+define iter=ImageRegionConstIterator;ImageRegionIterator;ImageScanlineConstIterator;ImageScanlineIterator
+
+tinclude itk#iter#:h|hxx
+
+cinclude itk#color_pixels#.h
+cinclude itk#vectors#.h
+cinclude itk#diff_tensors#.h
+cinclude itk#matrices#.h
+
+instances itk::#iter#< itk::Image< #scalar_pixels#, #process_dims# > >
+instances itk::#iter#< itk::Image< itk::#color_pixels#< #scalar_pixels# >, #process_dims# > >
+instances itk::#iter#< itk::Image< itk::#vectors#< #real_types#, #process_dims# >, #process_dims# > >
+instances itk::#iter#< itk::Image< itk::#diff_tensors#< #real_types# >, 3 > >
+instances itk::#iter#< itk::Image< itk::#matrices#< #real_types#, #process_dims#, #process_dims# >, #process_dims# > >
+instances itk::#iter#< itk::Image< itk::Offset< #process_dims# >, #process_dims# > >
+
+** eof - $RCSfile$
--- /dev/null
+header #define ITK_MANUAL_INSTANTIATION
+
+tinclude itkMesh:h|hxx
+tinclude itkPointSet:h|hxx
+
+cinclude itkMapContainer.hxx
+cinclude itkVectorContainer.hxx
+
+instances itk::PointSet< #real_types#, #visual_dims# >
+instances itk::Mesh< #real_types#, #visual_dims# >
+
+** eof - $RCSfile$
--- /dev/null
+header #define ITK_MANUAL_INSTANTIATION
+
+tinclude itkImageRegion:h|hxx
+tinclude itkImageBase:h|hxx
+tinclude itkImage:h|hxx
+tinclude itkImportImageContainer:h|hxx
+
+cinclude itk#color_pixels#.h
+cinclude itk#vectors#.h
+cinclude itk#diff_tensors#.h
+cinclude itk#matrices#.h
+
+instances itk::ImportImageContainer< unsigned long, #scalar_pixels# >
+instances itk::ImportImageContainer< unsigned long, itk::#color_pixels#< #scalar_pixels# > >
+instances itk::ImportImageContainer< unsigned long, itk::#vectors#< #real_types#, #process_dims# > >
+instances itk::ImportImageContainer< unsigned long, itk::#diff_tensors#< #real_types# > >
+instances itk::ImportImageContainer< unsigned long, itk::#matrices#< #real_types#, #process_dims#, #process_dims# > >
+instances itk::ImportImageContainer< unsigned long, itk::Offset< #process_dims# > >
+instances itk::ImageRegion< #process_dims# >
+instances itk::ImageBase< #process_dims# >
+
+instances itk::Image< #scalar_pixels#, #process_dims# >
+instances itk::Image< itk::#color_pixels#< #scalar_pixels# >, #process_dims# >
+instances itk::Image< itk::#vectors#< #real_types#, #process_dims# >, #process_dims# >
+instances itk::Image< itk::#diff_tensors#< #real_types# >, 3 >
+instances itk::Image< itk::#matrices#< #real_types#, #process_dims#, #process_dims# >, #process_dims# >
+instances itk::Image< itk::Offset< #process_dims# >, #process_dims# >
+
+minstances #_export_# std::ostream& itk::operator<< < #process_dims# >( std::ostream& a, itk::ImageRegion< #process_dims# > const& b )
+
+** eof - $RCSfile$
+++ /dev/null
-** ======================
-** == Some definitions ==
-** ======================
-
-** ==============
-** == Includes ==
-** ==============
-
-t itk$Array2D;Array;FixedArray$
-t itk#colors#
-t itk#vectors#
-t itk#tensors#
-t itk#matrices#
-t itkSimpleDataObjectDecorator
-t itkSymmetricEigenAnalysis
-
-** ==================
-** == Dependencies ==
-** ==================
-
-** ===============
-** == Instances ==
-** ===============
-
-c itk::Array< #pixels# >
-c itk::FixedArray< #pixels#, $#process_dims#;6;10$ >
-c itk::FixedArray< #reals#, $6;10$ >
-c itk::#colors#< #pixels# >
-c itk::#vectors#< #reals#, #process_dims# >
-c itk::#tensors#< #reals# >
-c itk::#matrices#< #reals#, #process_dims#, #process_dims# >
-c itk::SimpleDataObjectDecorator< #pixels# >
-c itk::SymmetricEigenAnalysis< itk::Matrix< #reals#, #process_dims#, #process_dims# >, itk::FixedArray< #reals#, #process_dims# >, itk::Matrix< #reals#, #process_dims#, #process_dims# > >
-
-** eof - $RCSfile$
+++ /dev/null
-#define ITK_MANUAL_INSTANTIATION
-
-#include <cpPlugins_BaseObjects_Export.h>
-#include <itkFixedArray.h>
-#include <itkPoint.h>
-#include <itkVector.h>
-
-#include <itkFixedArray.hxx>
-#include <itkPoint.hxx>
-#include <itkVector.hxx>
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Instances_BaseObjects_extra_Array( V, T, D ) \
- template cpPlugins_BaseObjects_EXPORT \
- std::ostream& itk::operator<< < T, D >( \
- std::ostream& a, itk::V< T, D > const& b \
- )
-
-cpPlugins_Instances_BaseObjects_extra_Array( Point, float, 1 );
-cpPlugins_Instances_BaseObjects_extra_Array( Point, float, 2 );
-cpPlugins_Instances_BaseObjects_extra_Array( Point, float, 3 );
-cpPlugins_Instances_BaseObjects_extra_Array( Point, float, 4 );
-cpPlugins_Instances_BaseObjects_extra_Array( Vector, float, 1 );
-cpPlugins_Instances_BaseObjects_extra_Array( Vector, float, 2 );
-cpPlugins_Instances_BaseObjects_extra_Array( Vector, float, 3 );
-cpPlugins_Instances_BaseObjects_extra_Array( Vector, float, 4 );
-cpPlugins_Instances_BaseObjects_extra_Array( FixedArray, float, 1 );
-cpPlugins_Instances_BaseObjects_extra_Array( FixedArray, float, 2 );
-cpPlugins_Instances_BaseObjects_extra_Array( FixedArray, float, 3 );
-cpPlugins_Instances_BaseObjects_extra_Array( FixedArray, float, 4 );
-
-cpPlugins_Instances_BaseObjects_extra_Array( Point, double, 1 );
-cpPlugins_Instances_BaseObjects_extra_Array( Point, double, 2 );
-cpPlugins_Instances_BaseObjects_extra_Array( Point, double, 3 );
-cpPlugins_Instances_BaseObjects_extra_Array( Point, double, 4 );
-cpPlugins_Instances_BaseObjects_extra_Array( Vector, double, 1 );
-cpPlugins_Instances_BaseObjects_extra_Array( Vector, double, 2 );
-cpPlugins_Instances_BaseObjects_extra_Array( Vector, double, 3 );
-cpPlugins_Instances_BaseObjects_extra_Array( Vector, double, 4 );
-cpPlugins_Instances_BaseObjects_extra_Array( FixedArray, double, 1 );
-cpPlugins_Instances_BaseObjects_extra_Array( FixedArray, double, 2 );
-cpPlugins_Instances_BaseObjects_extra_Array( FixedArray, double, 3 );
-cpPlugins_Instances_BaseObjects_extra_Array( FixedArray, double, 4 );
-
-// eof - $RCSfile$
+++ /dev/null
-** ======================
-** == Some definitions ==
-** ======================
-
-d reals1=#reals#
-d reals2=#reals#
-
-** ==============
-** == Includes ==
-** ==============
-
-i cpPlugins_BaseObjects.h
-t itkBoundingBox
-t itkVectorContainer
-
-** ===============
-** == Instances ==
-** ===============
-
-c itk::VectorContainer< unsigned long, itk::Point< #reals#, #visual_dims# > >
-c itk::BoundingBox< unsigned long, #visual_dims#, #reals1#, itk::VectorContainer< unsigned long, itk::Point< #reals2#, #visual_dims# > > >
-
-** eof - $RCSfile$
\ No newline at end of file
+++ /dev/null
-** ======================
-** == Some definitions ==
-** ======================
-
-d i_pixels=#pixels#
-d o_pixels=#pixels#
-d filters=InPlaceImageFilter;ImageToImageFilter
-
-** ==============
-** == Includes ==
-** ==============
-
-i cpPlugins_Images.h
-t itkImageSource
-t itk#filters#
-t itkRecursiveSeparableImageFilter
-
-** ==================
-** == Dependencies ==
-** ==================
-
-** ===============
-** == Instances ==
-** ===============
-
-c itk::ImageSource< itk::Image< #pixels#, #process_dims# > >
-c itk::ImageSource< itk::Image< itk::#colors#< #pixels# >, #process_dims# > >
-c itk::ImageSource< itk::Image< std::complex< #reals# >, #process_dims# > >
-c itk::ImageSource< itk::Image< itk::#vectors#< #reals#, #process_dims# >, #process_dims# > >
-c itk::ImageSource< itk::Image< itk::#tensors#< #reals# >, #process_dims# > >
-c itk::ImageSource< itk::Image< itk::#matrices#< #reals#, #process_dims#, #process_dims# >, #process_dims# > >
-c itk::ImageSource< itk::Image< itk::FixedArray< #pixels#, #process_dims# >, #process_dims# > >
-c itk::ImageSource< itk::Image< itk::Offset< #process_dims# >, #process_dims# > >
-
-c itk::#filters#< itk::Image< #i_pixels#, #process_dims# >, itk::Image< #o_pixels#, #process_dims# > >
-c itk::#filters#< itk::Image< std::complex< #reals# >, #process_dims# >, itk::Image< std::complex< #reals# >, #process_dims# > >
-c itk::#filters#< itk::Image< itk::#colors#< #pixels# >, #process_dims# >, itk::Image< itk::#colors#< #pixels# >, #process_dims# > >
-c itk::#filters#< itk::Image< itk::#vectors#< #reals#, #process_dims# >, #process_dims# >, itk::Image< itk::#vectors#< #reals#, #process_dims# >, #process_dims# > >
-c itk::#filters#< itk::Image< itk::#tensors#< #reals# >, #process_dims# >, itk::Image< itk::#tensors#< #reals# >, #process_dims# > >
-c itk::#filters#< itk::Image< itk::#matrices#< #reals#, #process_dims#, #process_dims# >, #process_dims# >, itk::Image< itk::#matrices#< #reals#, #process_dims#, #process_dims# >, #process_dims# > >
-c itk::#filters#< itk::Image< itk::FixedArray< #pixels#, #process_dims# >, #process_dims# >, itk::Image< itk::FixedArray< #pixels#, #process_dims# >, #process_dims# > >
-c itk::#filters#< itk::Image< itk::Offset< #process_dims# >, #process_dims# >, itk::Image< itk::Offset< #process_dims# >, #process_dims# > >
-c itk::#filters#< itk::Image< #pixels#, #process_dims# >, itk::Image< itk::#vectors#< #reals#, #process_dims# >, #process_dims# > >
-c itk::#filters#< itk::Image< itk::#vectors#< #reals#, #process_dims# >, #process_dims# >, itk::Image< #pixels#, #process_dims# > >
-c itk::RecursiveSeparableImageFilter< itk::Image< #i_pixels#, #process_dims# >, itk::Image< #o_pixels#, #process_dims# > >
-
-** eof - $RCSfile$
+++ /dev/null
-** ======================
-** == Some definitions ==
-** ======================
-
-d it=Region;Scanline
-d itwi=Linear;Region
-
-** ==============
-** == Includes ==
-** ==============
-
-i cpPlugins_Images.h
-t itkImage#it#$ ;Const$Iterator
-t itkImage$ ;Const$IteratorWithIndex
-t itkImage#itwi#$ ;Const$IteratorWithIndex
-
-** ==================
-** == Dependencies ==
-** ==================
-
-** ===============
-** == Instances ==
-** ===============
-
-b #define ITK_LEGACY_REMOVE
-c itk::Image#it#$ ;Const$Iterator< itk::Image< #pixels#, #process_dims# > >
-c itk::Image$ ;Const$IteratorWithIndex< itk::Image< #pixels#, #process_dims# > >
-c itk::Image#itwi#$ ;Const$IteratorWithIndex< itk::Image< #pixels#, #process_dims# > >
-
-
-c itk::Image#it#$ ;Const$Iterator< itk::Image< itk::#colors#< #pixels# >, #process_dims# > >
-c itk::Image$ ;Const$IteratorWithIndex< itk::Image< itk::#colors#< #pixels# >, #process_dims# > >
-c itk::Image#itwi#$ ;Const$IteratorWithIndex< itk::Image< itk::#colors#< #pixels# >, #process_dims# > >
-
-c itk::Image#it#$ ;Const$Iterator< itk::Image< std::complex< #reals# >, #process_dims# > >
-c itk::Image$ ;Const$IteratorWithIndex< itk::Image< std::complex< #reals# >, #process_dims# > >
-c itk::Image#itwi#$ ;Const$IteratorWithIndex< itk::Image< std::complex< #reals# >, #process_dims# > >
-
-c itk::Image#it#$ ;Const$Iterator< itk::Image< itk::#vectors#< #reals#, #process_dims# >, #process_dims# > >
-c itk::Image$ ;Const$IteratorWithIndex< itk::Image< itk::#vectors#< #reals#, #process_dims# >, #process_dims# > >
-c itk::Image#itwi#$ ;Const$IteratorWithIndex< itk::Image< itk::#vectors#< #reals#, #process_dims# >, #process_dims# > >
-
-c itk::Image#it#$ ;Const$Iterator< itk::Image< itk::#tensors#< #reals# >, #process_dims# > >
-c itk::Image$ ;Const$IteratorWithIndex< itk::Image< itk::#tensors#< #reals# >, #process_dims# > >
-c itk::Image#itwi#$ ;Const$IteratorWithIndex< itk::Image< itk::#tensors#< #reals# >, #process_dims# > >
-
-c itk::Image#it#$ ;Const$Iterator< itk::Image< itk::#matrices#< #reals#, #process_dims#, #process_dims# >, #process_dims# > >
-c itk::Image$ ;Const$IteratorWithIndex< itk::Image< itk::#matrices#< #reals#, #process_dims#, #process_dims# >, #process_dims# > >
-c itk::Image#itwi#$ ;Const$IteratorWithIndex< itk::Image< itk::#matrices#< #reals#, #process_dims#, #process_dims# >, #process_dims# > >
-
-c itk::Image#it#$ ;Const$Iterator< itk::Image< itk::FixedArray< #pixels#, #process_dims# >, #process_dims# > >
-c itk::Image$ ;Const$IteratorWithIndex< itk::Image< itk::FixedArray< #pixels#, #process_dims# >, #process_dims# > >
-c itk::Image#itwi#$ ;Const$IteratorWithIndex< itk::Image< itk::FixedArray< #pixels#, #process_dims# >, #process_dims# > >
-
-c itk::Image#it#$ ;Const$Iterator< itk::Image< itk::Offset< #process_dims# >, #process_dims# > >
-c itk::Image$ ;Const$IteratorWithIndex< itk::Image< itk::Offset< #process_dims# >, #process_dims# > >
-c itk::Image#itwi#$ ;Const$IteratorWithIndex< itk::Image< itk::Offset< #process_dims# >, #process_dims# > >
-
-** eof - $RCSfile$
+++ /dev/null
-** ======================
-** == Some definitions ==
-** ======================
-
-** ==============
-** == Includes ==
-** ==============
-
-i cpPlugins_Images.h
-t itk$ ;Const;Shaped;ConstShaped$NeighborhoodIterator
-t itkNeighborhood
-t itkZeroFluxNeumannBoundaryCondition
-
-** ==================
-** == Dependencies ==
-** ==================
-
-** ===============
-** == Instances ==
-** ===============
-
-c itk::Neighborhood< #pixels#*, #process_dims#, itk::NeighborhoodAllocator< #pixels#* > >
-c itk::Neighborhood< #pixels#, #process_dims#, itk::NeighborhoodAllocator< #pixels# > >
-c itk::ZeroFluxNeumannBoundaryCondition< itk::Image< #pixels#, #process_dims# >, itk::Image< #pixels#, #process_dims# > >
-c itk::$ ;Const;Shaped;ConstShaped$NeighborhoodIterator< itk::Image< #pixels#, #process_dims# >, itk::ZeroFluxNeumannBoundaryCondition< itk::Image< #pixels#, #process_dims# >, itk::Image< #pixels#, #process_dims# > > >
-
-** eof - $RCSfile$
+++ /dev/null
-** ======================
-** == Some definitions ==
-** ======================
-
-** ==============
-** == Includes ==
-** ==============
-
-i cpPlugins_BaseObjects.h
-i complex
-t itkImportImageContainer
-t itkImageBase
-t itkImage
-t itkImageRegion
-
-** ==================
-** == Dependencies ==
-** ==================
-
-** ===============
-** == Instances ==
-** ===============
-
-c itk::ImportImageContainer< unsigned long, #pixels# >
-c itk::ImportImageContainer< unsigned long, itk::#colors#< #pixels# > >
-c itk::ImportImageContainer< unsigned long, std::complex< #reals# > >
-c itk::ImportImageContainer< unsigned long, itk::#vectors#< #reals#, #process_dims# > >
-c itk::ImportImageContainer< unsigned long, itk::#tensors#< #reals# > >
-c itk::ImportImageContainer< unsigned long, itk::#matrices#< #reals#, #process_dims#, #process_dims# > >
-c itk::ImportImageContainer< unsigned long, itk::FixedArray< #pixels#, #process_dims# > >
-c itk::ImportImageContainer< unsigned long, itk::Offset< #process_dims# > >
-
-c itk::Image$Base;Region$< #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# >
-c itk::Image< itk::#tensors#< #reals# >, #process_dims# >
-c itk::Image< itk::#matrices#< #reals#, #process_dims#, #process_dims# >, #process_dims# >
-c itk::Image< itk::FixedArray< #pixels#, #process_dims# >, #process_dims# >
-c itk::Image< itk::Offset< #process_dims# >, #process_dims# >
-
-** eof - $RCSfile$
+++ /dev/null
-#define ITK_MANUAL_INSTANTIATION
-
-#include <cpPlugins_Images_Export.h>
-#include <itkImageRegion.h>
-#include <itkImageRegion.hxx>
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Instances_Images_Region( D ) \
- template cpPlugins_Images_EXPORT \
- std::ostream& itk::operator<< < D >( \
- std::ostream& a, itk::ImageRegion< D > const& b \
- )
-
-cpPlugins_Instances_Images_Region( 1 );
-cpPlugins_Instances_Images_Region( 2 );
-cpPlugins_Instances_Images_Region( 3 );
-cpPlugins_Instances_Images_Region( 4 );
-
-// eof - $RCSfile$
+++ /dev/null
-** ======================
-** == Some definitions ==
-** ======================
-
-** ==============
-** == Includes ==
-** ==============
-
-i cpPlugins_BaseObjects.h
-t itk$Mesh;PointSet$
-t itk$Polygon;Triangle;Line;Vertex$Cell
-t itkCellInterface
-t itkMapContainer
-t itkVectorContainer
-
-** ==================
-** == Dependencies ==
-** ==================
-
-** ===============
-** == Instances ==
-** ===============
-
-c itk::MapContainer< unsigned long, unsigned long >
-
-c itk::CellInterface< #reals#, itk::CellTraitsInfo< #visual_dims#, float, float, unsigned long, unsigned long, unsigned long, itk::Point< float, #visual_dims# >, itk::VectorContainer< unsigned long, itk::Point< float, #visual_dims# > >, std::set< unsigned long > > >
-
-c itk::VectorContainer< unsigned long, itk::CellInterface< #reals#, itk::CellTraitsInfo< #visual_dims#, float, float, unsigned long, unsigned long, unsigned long, itk::Point< float, #visual_dims# >, itk::VectorContainer< unsigned long, itk::Point< float, #visual_dims# > >, std::set< unsigned long > > >* >
-
-c itk::$Polygon;Triangle;Line;Vertex$Cell< itk::CellInterface< #reals#, itk::CellTraitsInfo< #visual_dims#, float, float, unsigned long, unsigned long, unsigned long, itk::Point< float, #visual_dims# >, itk::VectorContainer< unsigned long, itk::Point< float, #visual_dims# > >, std::set< unsigned long > > > >
-
-c itk::$Mesh;PointSet$< #reals#, #visual_dims# >
-
-** eof - $RCSfile$
+++ /dev/null
-** ======================
-** == Some definitions ==
-** ======================
-
-** ==============
-** == Includes ==
-** ==============
-
-i cpPlugins_Images.h
-t cpExtensions/Algorithms/BezierCurveFunction
-t cpExtensions/DataStructures/PolyLineParametricPath
-t cpExtensions/DataStructures/Skeleton
-t cpExtensions/DataStructures/Graph
-t itkPath
-t itkParametricPath
-t itkPolyLineParametricPath
-t itkVectorContainer
-
-** ==================
-** == Dependencies ==
-** ==================
-
-** ===============
-** == Instances ==
-** ===============
-
-c cpExtensions::Algorithms::BezierCurveFunction< itk::Vector< #reals#, #process_dims# > >
-c itk::Path< double, itk::ContinuousIndex< double, #process_dims# >, #process_dims# >
-c itk::ParametricPath< #process_dims# >
-c itk::PolyLineParametricPath< #process_dims# >
-c cpExtensions::DataStructures::PolyLineParametricPath< #process_dims# >
-c cpExtensions::DataStructures::Skeleton< #process_dims# >
-
-** eof - $RCSfile$
# define QCP_LIB_DECL
#endif
*/
-#include <cpPlugins_QCustomPlot_Export.h>
-#define QCP_LIB_DECL cpPlugins_QCustomPlot_EXPORT
+#include <cp_QCustomPlot_Export.h>
+#define QCP_LIB_DECL cp_QCustomPlot_EXPORT
/*!
The QCP Namespace contains general enums and QFlags used throughout the QCustomPlot library
+++ /dev/null
-#ifndef __cpPlugins__BaseObjects__Demangle__h__
-#define __cpPlugins__BaseObjects__Demangle__h__
-
-#include <cpPlugins/Config.h>
-#include <cpPlugins/BaseObjects/DemangleBase.h>
-
-#define cpPlugins_Demangle_ImageScalars( _obj, _fun, _dim ) \
- cpPlugins_Demangle_ImageIntegers( _obj, _fun, _dim ); \
- else cpPlugins_Demangle_ImageReals( _obj, _fun, _dim )
-
-#define cpPlugins_Demangle_ImageScalars_Dims( _obj, _fun ) \
- cpPlugins_Demangle_ImageIntegers_Dims( _obj, _fun ); \
- else cpPlugins_Demangle_ImageReals_Dims( _obj, _fun )
-
-#define cpPlugins_Demangle_ImageAll( _obj, _fun, _dim ) \
- cpPlugins_Demangle_ImageIntegers_Dims( _obj, _fun, _dim ); \
- else cpPlugins_Demangle_ImageReals_Dims( _obj, _fun, _dim ); \
- else cpPlugins_Demangle_ImageComplexes_Dims( _obj, _fun, _dim ); \
- else cpPlugins_Demangle_ImageColors_Dims( _obj, _fun, _dim ); \
- else cpPlugins_Demangle_ImageFixedArrays_Dims( _obj, _fun, _dim ); \
- else cpPlugins_Demangle_ImageCovariantVectors_Dims( _obj, _fun, _dim ); \
- else cpPlugins_Demangle_ImageVectors_Dims( _obj, _fun, _dim ); \
- else cpPlugins_Demangle_ImagePoints_Dims( _obj, _fun, _dim ); \
- else cpPlugins_Demangle_ImageSymmetricSecondRankTensors_Dims( _obj, _fun, _dim ); \
- else cpPlugins_Demangle_ImageMatrices_Dims( _obj, _fun, _dim )
-
-#define cpPlugins_Demangle_ImageAll_Dims( _obj, _fun ) \
- cpPlugins_Demangle_ImageIntegers_Dims( _obj, _fun ); \
- else cpPlugins_Demangle_ImageReals_Dims( _obj, _fun ); \
- else cpPlugins_Demangle_ImageComplexes_Dims( _obj, _fun ); \
- else cpPlugins_Demangle_ImageColors_Dims( _obj, _fun ); \
- else cpPlugins_Demangle_ImageFixedArrays_Dims( _obj, _fun ); \
- else cpPlugins_Demangle_ImageCovariantVectors_Dims( _obj, _fun ); \
- else cpPlugins_Demangle_ImageVectors_Dims( _obj, _fun ); \
- else cpPlugins_Demangle_ImagePoints_Dims( _obj, _fun ); \
- else cpPlugins_Demangle_ImageSymmetricSecondRankTensors_Dims( _obj, _fun ); \
- else cpPlugins_Demangle_ImageMatrices_Dims( _obj, _fun )
-
-#endif // __cpPlugins__BaseObjects__Demangle__h__
-
-// eof - $RCSfile$
#define ITK_MANUAL_INSTANTIATION
#include <@prj_NAME@_Export.h>
#include <stdexcept>
+#include <cpPlugins/RealConfig.h>
/*
* =========================================================================
#include <cpPlugins/DataObjects/BoundingBox.h>
#include <limits>
#include <vtkDataSet.h>
+#include <cpInstances_SimpleImages.h>
+#include <cpInstances_Meshes.h>
// -------------------------------------------------------------------------
void cpPlugins::DataObjects::BoundingBox::
this->Modified( );
}
+// -------------------------------------------------------------------------
+template< class _TPoint >
+void cpPlugins::DataObjects::BoundingBox::
+SetMinimum( const _TPoint& p )
+{
+ this->_SetPoint( 0, p );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPoint >
+void cpPlugins::DataObjects::BoundingBox::
+SetMaximum( const _TPoint& p )
+{
+ this->_SetPoint( 1, p );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPoint >
+_TPoint cpPlugins::DataObjects::BoundingBox::
+GetMinimum( ) const
+{
+ return( this->_GetPoint< _TPoint >( 0 ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPoint >
+_TPoint cpPlugins::DataObjects::BoundingBox::
+GetMaximum( ) const
+{
+ return( this->_GetPoint< _TPoint >( 1 ) );
+}
+
// -------------------------------------------------------------------------
cpPlugins::DataObjects::BoundingBox::
BoundingBox( )
this->m_VTK = this->m_Outline->GetOutput( );
}
+// -------------------------------------------------------------------------
+template< class _TPoint >
+void cpPlugins::DataObjects::BoundingBox::
+_SetPoint( unsigned int m, const _TPoint& p )
+{
+ this->m_Points[ m ].clear( );
+ for( unsigned int d = 0; d < _TPoint::PointDimension; ++d )
+ this->m_Points[ m ].push_back( double( p[ d ] ) );
+ this->_UpdateVTK( );
+ this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPoint >
+_TPoint cpPlugins::DataObjects::BoundingBox::
+_GetPoint( unsigned int m ) const
+{
+ unsigned int dim = this->m_Points[ m ].size( );
+ dim = ( _TPoint::PointDimension < dim )? _TPoint::PointDimension: dim;
+ _TPoint p;
+ p.Fill( 0 );
+ for( unsigned int d = 0; d < dim; ++d )
+ p[ d ] = this->m_Points[ m ][ d ];
+ return( p );
+}
+
+// -------------------------------------------------------------------------
+template< unsigned int _NDim >
+bool cpPlugins::DataObjects::BoundingBox::
+_ITKImage( itk::LightObject* o )
+{
+ auto image = dynamic_cast< itk::ImageBase< _NDim >* >( o );
+ if( image == NULL )
+ return( false );
+
+ auto region = image->GetLargestPossibleRegion( );
+ auto i0 = region.GetIndex( );
+ auto i1 = i0 + region.GetSize( );
+
+ typename itk::ImageBase< _NDim >::PointType p0, p1;
+ image->TransformIndexToPhysicalPoint( i0, p0 );
+ image->TransformIndexToPhysicalPoint( i1, p1 );
+ this->m_Points[ 0 ].clear( );
+ this->m_Points[ 1 ].clear( );
+
+ for( unsigned int d = 0; d < _NDim; ++d )
+ {
+ this->m_Points[ 0 ].push_back( double( p0[ d ] ) );
+ this->m_Points[ 1 ].push_back( double( p1[ d ] ) );
+
+ } // rof
+ this->Modified( );
+ return( true );
+}
+
+// -------------------------------------------------------------------------
+template< class _TScalar, unsigned int _NDim >
+bool cpPlugins::DataObjects::BoundingBox::
+_ITKPointSet( itk::LightObject* o )
+{
+ typedef itk::PointSet< _TScalar, _NDim > _TPointSet;
+ typedef itk::BoundingBox< typename _TPointSet::PointIdentifier, _NDim, _TScalar, typename _TPointSet::PointsContainer > _TBBox;
+
+ auto ps = dynamic_cast< _TPointSet* >( o );
+ if( ps == NULL )
+ return( false );
+
+ this->m_Points[ 0 ].clear( );
+ this->m_Points[ 1 ].clear( );
+
+ typename _TBBox::Pointer bb = _TBBox::New( );
+ bb->SetPoints( ps->GetPoints( ) );
+ if( bb->ComputeBoundingBox( ) )
+ {
+ auto p0 = bb->GetMinimum( );
+ auto p1 = bb->GetMaximum( );
+ for( unsigned int d = 0; d < _NDim; ++d )
+ {
+ this->m_Points[ 0 ].push_back( double( p0[ d ] ) );
+ this->m_Points[ 1 ].push_back( double( p1[ d ] ) );
+
+ } // rof
+ this->Modified( );
+ return( true );
+ }
+ else
+ return( false );
+}
+
// eof - $RCSfile$
} // ecapseman
-#include <cpPlugins/DataObjects/BoundingBox.hxx>
+// #include <cpPlugins/DataObjects/BoundingBox.hxx>
#endif // __cpPlugins__DataObjects__BoundingBox__h__
+++ /dev/null
-#ifndef __cpPlugins__DataObjects__BoundingBox__hxx__
-#define __cpPlugins__DataObjects__BoundingBox__hxx__
-
-#include <cpPlugins/DataObjects/Image.h>
-#include <cpPlugins/DataObjects/Mesh.h>
-#include <itkBoundingBox.h>
-#include <itkPointSet.h>
-
-// -------------------------------------------------------------------------
-template< class _TPoint >
-void cpPlugins::DataObjects::BoundingBox::
-SetMinimum( const _TPoint& p )
-{
- this->_SetPoint( 0, p );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPoint >
-void cpPlugins::DataObjects::BoundingBox::
-SetMaximum( const _TPoint& p )
-{
- this->_SetPoint( 1, p );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPoint >
-_TPoint cpPlugins::DataObjects::BoundingBox::
-GetMinimum( ) const
-{
- return( this->_GetPoint< _TPoint >( 0 ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPoint >
-_TPoint cpPlugins::DataObjects::BoundingBox::
-GetMaximum( ) const
-{
- return( this->_GetPoint< _TPoint >( 1 ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPoint >
-void cpPlugins::DataObjects::BoundingBox::
-_SetPoint( unsigned int m, const _TPoint& p )
-{
- this->m_Points[ m ].clear( );
- for( unsigned int d = 0; d < _TPoint::PointDimension; ++d )
- this->m_Points[ m ].push_back( double( p[ d ] ) );
- this->_UpdateVTK( );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPoint >
-_TPoint cpPlugins::DataObjects::BoundingBox::
-_GetPoint( unsigned int m ) const
-{
- unsigned int dim = this->m_Points[ m ].size( );
- dim = ( _TPoint::PointDimension < dim )? _TPoint::PointDimension: dim;
- _TPoint p;
- p.Fill( 0 );
- for( unsigned int d = 0; d < dim; ++d )
- p[ d ] = this->m_Points[ m ][ d ];
- return( p );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _NDim >
-bool cpPlugins::DataObjects::BoundingBox::
-_ITKImage( itk::LightObject* o )
-{
- auto image = dynamic_cast< itk::ImageBase< _NDim >* >( o );
- if( image == NULL )
- return( false );
-
- auto region = image->GetLargestPossibleRegion( );
- auto i0 = region.GetIndex( );
- auto i1 = i0 + region.GetSize( );
-
- typename itk::ImageBase< _NDim >::PointType p0, p1;
- image->TransformIndexToPhysicalPoint( i0, p0 );
- image->TransformIndexToPhysicalPoint( i1, p1 );
- this->m_Points[ 0 ].clear( );
- this->m_Points[ 1 ].clear( );
-
- for( unsigned int d = 0; d < _NDim; ++d )
- {
- this->m_Points[ 0 ].push_back( double( p0[ d ] ) );
- this->m_Points[ 1 ].push_back( double( p1[ d ] ) );
-
- } // rof
- this->Modified( );
- return( true );
-}
-
-// -------------------------------------------------------------------------
-template< class _TScalar, unsigned int _NDim >
-bool cpPlugins::DataObjects::BoundingBox::
-_ITKPointSet( itk::LightObject* o )
-{
- typedef itk::PointSet< _TScalar, _NDim > _TPointSet;
- typedef itk::BoundingBox< typename _TPointSet::PointIdentifier, _NDim, _TScalar, typename _TPointSet::PointsContainer > _TBBox;
-
- auto ps = dynamic_cast< _TPointSet* >( o );
- if( ps == NULL )
- return( false );
-
- this->m_Points[ 0 ].clear( );
- this->m_Points[ 1 ].clear( );
-
- typename _TBBox::Pointer bb = _TBBox::New( );
- bb->SetPoints( ps->GetPoints( ) );
- if( bb->ComputeBoundingBox( ) )
- {
- auto p0 = bb->GetMinimum( );
- auto p1 = bb->GetMaximum( );
- for( unsigned int d = 0; d < _NDim; ++d )
- {
- this->m_Points[ 0 ].push_back( double( p0[ d ] ) );
- this->m_Points[ 1 ].push_back( double( p1[ d ] ) );
-
- } // rof
- this->Modified( );
- return( true );
- }
- else
- return( false );
-}
-
-#endif // __cpPlugins__DataObjects__BoundingBox__hxx__
-
-// eof - $RCSfile$
#include <cpPlugins/DataObjects/Image.h>
-#include <cpPlugins/DataObjects/Image.hxx>
+#include <cpPlugins/DataObjects/Image_Demanglers.h>
+#include <cpInstances_BaseObjects.h>
+#include <cpInstances_SimpleImages.h>
+
+#include <itkImageToVTKImageFilter.h>
+#include <itkVTKImageToImageFilter.h>
+
+#include <itkImageToVTKImageFilter.hxx>
+#include <itkVTKImageToImageFilter.hxx>
+#include <itkVTKImageExport.hxx>
+#include <itkVTKImageImport.hxx>
// -------------------------------------------------------------------------
void cpPlugins::DataObjects::Image::
SetITK( itk::LightObject* o )
{
this->Superclass::SetITK( o );
- cpPlugins_Demangle_ImageVisualDims( o, _ITK_2_VTK_0 );
- else cpPlugins_Demangle_ImageDiffusionTensors3D( o, _ITK_2_VTK_1 );
- else
+ cpPlugins_Demangle_Image_VisualDims( o, _ITK_2_VTK_0, );
+ cpPlugins_Demangle_Image_DiffTensors3D( o, _ITK_2_VTK_1, );
{
this->m_VTK = NULL;
this->m_ITKvVTK = NULL;
} // fi
- // Connect both worlds
- this->_VTK_2_ITK_0< unsigned char >( img );
+ bool success = false;
+ auto stype = img->GetScalarType( );
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_char
+ if( stype == VTK_CHAR ) success = this->_VTK_2_ITK_0< char >( img );
+ if( stype == VTK_UNSIGNED_CHAR ) success = this->_VTK_2_ITK_0< unsigned char >( img );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_char
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_short
+ if( stype == VTK_CHAR ) success = this->_VTK_2_ITK_0< short >( img );
+ if( stype == VTK_UNSIGNED_CHAR ) success = this->_VTK_2_ITK_0< unsigned short >( img );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_short
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_int
+ if( stype == VTK_CHAR ) success = this->_VTK_2_ITK_0< int >( img );
+ if( stype == VTK_UNSIGNED_CHAR ) success = this->_VTK_2_ITK_0< unsigned int >( img );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_int
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_long
+ if( stype == VTK_CHAR ) success = this->_VTK_2_ITK_0< long >( img );
+ if( stype == VTK_UNSIGNED_CHAR ) success = this->_VTK_2_ITK_0< unsigned long >( img );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_long
+#ifdef cpPlugins_CONFIG_REAL_TYPES_float
+ if( stype == VTK_CHAR ) success = this->_VTK_2_ITK_0< float >( img );
+#endif // cpPlugins_CONFIG_REAL_TYPES_float
+#ifdef cpPlugins_CONFIG_REAL_TYPES_double
+ if( stype == VTK_CHAR ) success = this->_VTK_2_ITK_0< double >( img );
+#endif // cpPlugins_CONFIG_REAL_TYPES_double
/* TODO
- switch( img->GetScalarType( ) )
- {
- case VTK_CHAR: this->_VTK_2_ITK_0< char >( img ); break;
- case VTK_SHORT: this->_VTK_2_ITK_0< short >( img ); break;
- case VTK_INT: this->_VTK_2_ITK_0< int >( img ); break;
- case VTK_LONG: this->_VTK_2_ITK_0< long >( img ); break;
- case VTK_UNSIGNED_CHAR: this->_VTK_2_ITK_0< unsigned char >( img ); break;
- case VTK_UNSIGNED_SHORT: this->_VTK_2_ITK_0< unsigned short >( img ); break;
- case VTK_UNSIGNED_INT: this->_VTK_2_ITK_0< unsigned int >( img ); break;
- case VTK_UNSIGNED_LONG: this->_VTK_2_ITK_0< unsigned long >( img ); break;
- case VTK_FLOAT: this->_VTK_2_ITK_0< float >( img ); break;
- case VTK_DOUBLE: this->_VTK_2_ITK_0< double >( img ); break;
- default:
- {
- this->m_ITK = NULL;
- this->m_ITKvVTK = NULL;
-
- }
- } // hctiws
+ #define cpPlugins_CONFIG_COLOR_PIXELS_RGBPixel
+ #define cpPlugins_CONFIG_COLOR_PIXELS_RGBAPixel
+ #define cpPlugins_CONFIG_VECTORS_CovariantVector
+ #define cpPlugins_CONFIG_VECTORS_Point
+ #define cpPlugins_CONFIG_VECTORS_SymmetricSecondRankTensor
+ #define cpPlugins_CONFIG_VECTORS_Vector
+ #define cpPlugins_CONFIG_DIFFUSIONTENSORS_DiffusionTensor3D
+ #define cpPlugins_CONFIG_MATRICES_Matrix
*/
+ if( !success )
+ {
+ this->m_ITK = NULL;
+ this->m_ITKvVTK = NULL;
+
+ } // fi
this->Modified( );
}
{
}
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpPlugins::DataObjects::Image::
+_ITK_2_VTK_0( _TImage* image )
+{
+ cpPlugins_Demangle_Image_ScalarPixels( image, _ITK_2_VTK_1, _TImage::ImageDimension, );
+ cpPlugins_Demangle_Image_ColorPixels( image, _ITK_2_VTK_1, _TImage::ImageDimension, );
+ cpPlugins_Demangle_Image_VectorPixels( image, _ITK_2_VTK_1, _TImage::ImageDimension, );
+ {
+ this->m_VTK = NULL;
+ this->m_ITKvVTK = NULL;
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpPlugins::DataObjects::Image::
+_ITK_2_VTK_1( _TImage* image )
+{
+ typedef itk::ImageToVTKImageFilter< _TImage > _TFilter;
+ _TFilter* f = dynamic_cast< _TFilter* >( this->m_ITKvVTK.GetPointer( ) );
+ if( f == NULL )
+ {
+ typename _TFilter::Pointer nf = _TFilter::New( );
+ this->m_ITKvVTK = nf;
+ f = nf.GetPointer( );
+
+ } // fi
+ f->SetInput( image );
+ f->Update( );
+
+ // Keep object track
+ this->m_ITK = image;
+ this->m_VTK = f->GetOutput( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPixel >
+bool cpPlugins::DataObjects::Image::
+_VTK_2_ITK_0( vtkImageData* image )
+{
+ bool success = false;
+ unsigned int dim = image->GetDataDimension( );
+#ifdef cpPlugins_CONFIG_VISUAL_DIMENSIONS_2
+ if( dim == 2 ) success = this->_VTK_2_ITK_1< _TPixel, 2 >( image );
+#endif // cpPlugins_CONFIG_VISUAL_DIMENSIONS_2
+#ifdef cpPlugins_CONFIG_VISUAL_DIMENSIONS_3
+ if( dim == 3 ) success = this->_VTK_2_ITK_1< _TPixel, 3 >( image );
+#endif // cpPlugins_CONFIG_VISUAL_DIMENSIONS_2
+ return( success );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPixel, unsigned int _VDim >
+bool cpPlugins::DataObjects::Image::
+_VTK_2_ITK_1( vtkImageData* image )
+{
+ typedef itk::Image< _TPixel, _VDim > _TImage;
+ typedef itk::VTKImageToImageFilter< _TImage > _TFilter;
+ _TFilter* f = dynamic_cast< _TFilter* >( this->m_ITKvVTK.GetPointer( ) );
+ if( f == NULL )
+ {
+ typename _TFilter::Pointer nf = _TFilter::New( );
+ this->m_ITKvVTK = nf;
+ f = nf.GetPointer( );
+
+ } // fi
+ f->SetInput( image );
+ f->Update( );
+
+ // Keep object track
+ this->m_VTK = image;
+ this->m_ITK = f->GetOutput( );
+ return( true );
+}
+
// eof - $RCSfile$
--- /dev/null
+define all_ints=#int_types#;unsigned #int_types#
+
+ProcessDims itk::ImageBase< #process_dims# >
+VisualDims itk::ImageBase< #visual_dims# >
+
+IntPixels|d itk::Image< #all_ints#, d >
+RealPixels|d itk::Image< #real_types#, d >
+ScalarPixels|d itk::Image< #scalar_pixels#, d >
+ColorPixels|d itk::Image< itk::#color_pixels#< #scalar_pixels# >, d >
+VectorPixels|d itk::Image< itk::#vectors#< #real_types#, d >, d >
+DiffTensors3D itk::Image< itk::#diff_tensors#< #real_types# >, 3 >
+
+** eof - $RCSfile$
#include <cpPlugins/BaseObjects/DataObject.h>
#include <itkProcessObject.h>
-#include <cpPlugins_Images.h>
namespace cpPlugins
{
Image( );
virtual ~Image( );
- template< unsigned int _VDim >
- inline void _ITK_2_VTK_0( itk::ImageBase< _VDim >* image );
+ template< class _TImage >
+ inline void _ITK_2_VTK_0( _TImage* image );
template< class _TImage >
- inline void _ITK_2_VTK_1( _TImage* image );
+ inline void _ITK_2_VTK_1( _TImage* image );
template< class _TPixel >
- inline void _VTK_2_ITK_0( vtkImageData* image );
+ inline bool _VTK_2_ITK_0( vtkImageData* image );
template< class _TPixel, unsigned int _VDim >
- inline void _VTK_2_ITK_1( vtkImageData* image );
+ inline bool _VTK_2_ITK_1( vtkImageData* image );
private:
// Purposely not implemented
+++ /dev/null
-#ifndef __cpPlugins__DataObjects__Image__hxx__
-#define __cpPlugins__DataObjects__Image__hxx__
-
-#include <itkImageToVTKImageFilter.h>
-#include <itkVTKImageToImageFilter.h>
-#include <itkImageToVTKImageFilter.hxx>
-#include <itkVTKImageToImageFilter.hxx>
-#include <itkVTKImageExport.hxx>
-#include <itkVTKImageImport.hxx>
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void cpPlugins::DataObjects::Image::
-_ITK_2_VTK_0( itk::ImageBase< _VDim >* image )
-{
- cpPlugins_Demangle_ImageIntegers( image, _ITK_2_VTK_1, _VDim );
- else cpPlugins_Demangle_ImageReals( image, _ITK_2_VTK_1, _VDim );
- else cpPlugins_Demangle_ImageColors( image, _ITK_2_VTK_1, _VDim );
- else cpPlugins_Demangle_ImageFixedArrays( image, _ITK_2_VTK_1, _VDim );
- else cpPlugins_Demangle_ImageCovariantVectors( image, _ITK_2_VTK_1, _VDim );
- else cpPlugins_Demangle_ImagePoints( image, _ITK_2_VTK_1, _VDim );
- else cpPlugins_Demangle_ImageVectors( image, _ITK_2_VTK_1, _VDim );
- else cpPlugins_Demangle_ImageSymmetricSecondRankTensors( image, _ITK_2_VTK_1, _VDim );
- else
- {
- this->m_VTK = NULL;
- this->m_ITKvVTK = NULL;
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-void cpPlugins::DataObjects::Image::
-_ITK_2_VTK_1( _TImage* image )
-{
- typedef itk::ImageToVTKImageFilter< _TImage > _TFilter;
- _TFilter* f = dynamic_cast< _TFilter* >( this->m_ITKvVTK.GetPointer( ) );
- if( f == NULL )
- {
- typename _TFilter::Pointer nf = _TFilter::New( );
- this->m_ITKvVTK = nf;
- f = nf.GetPointer( );
-
- } // fi
- f->SetInput( image );
- f->Update( );
-
- // Keep object track
- this->m_ITK = image;
- this->m_VTK = f->GetOutput( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPixel >
-void cpPlugins::DataObjects::Image::
-_VTK_2_ITK_0( vtkImageData* image )
-{
- if( image->GetDataDimension( ) == 2 )
- this->_VTK_2_ITK_1< _TPixel, 2 >( image );
- else if( image->GetDataDimension( ) == 3 )
- this->_VTK_2_ITK_1< _TPixel, 3 >( image );
- else
- {
- this->m_ITK = NULL;
- this->m_ITKvVTK = NULL;
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TPixel, unsigned int _VDim >
-void cpPlugins::DataObjects::Image::
-_VTK_2_ITK_1( vtkImageData* image )
-{
- typedef itk::Image< _TPixel, _VDim > _TImage;
- typedef itk::VTKImageToImageFilter< _TImage > _TFilter;
- _TFilter* f = dynamic_cast< _TFilter* >( this->m_ITKvVTK.GetPointer( ) );
-
- std::cout << typeid( _TImage ).name( ) << std::endl;
-
- if( f == NULL )
- {
- typename _TFilter::Pointer nf = _TFilter::New( );
- this->m_ITKvVTK = nf;
- f = nf.GetPointer( );
-
- } // fi
- f->SetInput( image );
- f->Update( );
-
- // Keep object track
- this->m_VTK = image;
- this->m_ITK = f->GetOutput( );
-}
-
-#endif // __cpPlugins__DataObjects__Image__hxx__
-
-// eof - $RCSfile$
void cpPlugins::DataObjects::Mesh::
SetITK( itk::LightObject* o )
{
- this->Superclass::SetITK( o );
- bool s = false;
- cpPlugins_Demangle_Meshes_Dims( o, _ITK_2_VTK );
+ /* TODO
+ this->Superclass::SetITK( o );
+ bool s = false;
+ cpPlugins_Demangle_Meshes_Dims( o, _ITK_2_VTK );
+ */
}
// -------------------------------------------------------------------------
void cpPlugins::DataObjects::Mesh::
SetVTK( vtkObjectBase* o )
{
- typedef itk::Mesh< double, 3 > _TMesh;
- typedef _TMesh::CellType _TCell;
- typedef _TCell::CellAutoPointer _TCellAutoPointer;
- typedef itk::LineCell< _TCell > _TLine;
- typedef itk::TriangleCell< _TCell > _TTriangle;
- typedef itk::PolygonCell< _TCell > _TPolygon;
-
- vtkPolyData* mesh = dynamic_cast< vtkPolyData* >( o );
- if( mesh == NULL )
- {
- this->m_ITK = NULL;
- this->Modified( );
- return;
-
- } // fi
-
- if( this->m_VTK.GetPointer( ) != mesh )
- {
- this->m_VTK = mesh;
-
- // Copy points
- _TMesh::Pointer imesh = _TMesh::New( );
- double point[ 3 ];
- for( long i = 0; i < mesh->GetNumberOfPoints( ); ++i )
- {
- mesh->GetPoint( i, point );
- _TMesh::PointType ipoint;
- ipoint[ 0 ] = point[ 0 ];
- ipoint[ 1 ] = point[ 1 ];
- ipoint[ 2 ] = point[ 2 ];
- imesh->SetPoint( i, ipoint );
-
- } // rof
-
- // Copy cells
- vtkCellArray* arrays[ 4 ];
- arrays[ 0 ] = mesh->GetLines( );
- arrays[ 1 ] = mesh->GetPolys( );
- arrays[ 2 ] = NULL; // TODO: mesh->GetStrips( );
- arrays[ 3 ] = mesh->GetVerts( );
-
- for( unsigned int c = 0; c < 4; c++ )
- {
- if( arrays[ c ] != NULL )
- {
- vtkSmartPointer< vtkIdList > ids =
- vtkSmartPointer< vtkIdList >::New( );
- arrays[ c ]->InitTraversal( );
- while( arrays[ c ]->GetNextCell( ids ) == 1 )
- {
- long nPoints = ids->GetNumberOfIds( );
- _TCellAutoPointer icell;
- if( nPoints == 2 )
- {
- icell.TakeOwnership( new _TLine );
- icell->SetPointId( 0, ids->GetId( 0 ) );
- icell->SetPointId( 1, ids->GetId( 1 ) );
- }
- else if( nPoints == 3 )
- {
- icell.TakeOwnership( new _TTriangle );
- icell->SetPointId( 0, ids->GetId( 0 ) );
- icell->SetPointId( 1, ids->GetId( 1 ) );
- icell->SetPointId( 2, ids->GetId( 2 ) );
- }
- else if( nPoints > 3 )
- {
- _TPolygon* polygon = new _TPolygon( );
- for( long j = 0; j < nPoints; ++j )
- polygon->AddPointId( ids->GetId( j ) );
- icell.TakeOwnership( polygon );
-
- } // fi
- imesh->SetCell( imesh->GetNumberOfCells( ), icell );
-
- } // elihw
-
- } // fi
-
- } // rof
- this->m_ITK = imesh;
- this->Modified( );
-
- } // fi
+ /* TODO
+ typedef itk::Mesh< double, 3 > _TMesh;
+ typedef _TMesh::CellType _TCell;
+ typedef _TCell::CellAutoPointer _TCellAutoPointer;
+ typedef itk::LineCell< _TCell > _TLine;
+ typedef itk::TriangleCell< _TCell > _TTriangle;
+ typedef itk::PolygonCell< _TCell > _TPolygon;
+
+ vtkPolyData* mesh = dynamic_cast< vtkPolyData* >( o );
+ if( mesh == NULL )
+ {
+ this->m_ITK = NULL;
+ this->Modified( );
+ return;
+
+ } // fi
+
+ if( this->m_VTK.GetPointer( ) != mesh )
+ {
+ this->m_VTK = mesh;
+
+ // Copy points
+ _TMesh::Pointer imesh = _TMesh::New( );
+ double point[ 3 ];
+ for( long i = 0; i < mesh->GetNumberOfPoints( ); ++i )
+ {
+ mesh->GetPoint( i, point );
+ _TMesh::PointType ipoint;
+ ipoint[ 0 ] = point[ 0 ];
+ ipoint[ 1 ] = point[ 1 ];
+ ipoint[ 2 ] = point[ 2 ];
+ imesh->SetPoint( i, ipoint );
+
+ } // rof
+
+ // Copy cells
+ vtkCellArray* arrays[ 4 ];
+ arrays[ 0 ] = mesh->GetLines( );
+ arrays[ 1 ] = mesh->GetPolys( );
+ arrays[ 2 ] = NULL; // TODO: mesh->GetStrips( );
+ arrays[ 3 ] = mesh->GetVerts( );
+
+ for( unsigned int c = 0; c < 4; c++ )
+ {
+ if( arrays[ c ] != NULL )
+ {
+ vtkSmartPointer< vtkIdList > ids =
+ vtkSmartPointer< vtkIdList >::New( );
+ arrays[ c ]->InitTraversal( );
+ while( arrays[ c ]->GetNextCell( ids ) == 1 )
+ {
+ long nPoints = ids->GetNumberOfIds( );
+ _TCellAutoPointer icell;
+ if( nPoints == 2 )
+ {
+ icell.TakeOwnership( new _TLine );
+ icell->SetPointId( 0, ids->GetId( 0 ) );
+ icell->SetPointId( 1, ids->GetId( 1 ) );
+ }
+ else if( nPoints == 3 )
+ {
+ icell.TakeOwnership( new _TTriangle );
+ icell->SetPointId( 0, ids->GetId( 0 ) );
+ icell->SetPointId( 1, ids->GetId( 1 ) );
+ icell->SetPointId( 2, ids->GetId( 2 ) );
+ }
+ else if( nPoints > 3 )
+ {
+ _TPolygon* polygon = new _TPolygon( );
+ for( long j = 0; j < nPoints; ++j )
+ polygon->AddPointId( ids->GetId( j ) );
+ icell.TakeOwnership( polygon );
+
+ } // fi
+ imesh->SetCell( imesh->GetNumberOfCells( ), icell );
+
+ } // elihw
+
+ } // fi
+
+ } // rof
+ this->m_ITK = imesh;
+ this->Modified( );
+
+ } // fi
+ */
}
// -------------------------------------------------------------------------
--- /dev/null
+Meshes itk::Mesh< #real_types#, #process_dims# >
+
+** eof - $RCSfile$
#ifndef __cpPlugins__DataObjects__Mesh__hxx__
#define __cpPlugins__DataObjects__Mesh__hxx__
-#include <cpPlugins_Meshes.h>
+// TODO: #include <cpPlugins_Meshes.h>
#include <vtkCellArray.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
void cpPlugins::DataObjects::PolyLineParametricPath::
SetITK( itk::LightObject* o )
{
- typedef cpExtensions::DataStructures::PolyLineParametricPath< 1 > _T1;
- typedef cpExtensions::DataStructures::PolyLineParametricPath< 2 > _T2;
- typedef cpExtensions::DataStructures::PolyLineParametricPath< 3 > _T3;
- typedef cpExtensions::DataStructures::PolyLineParametricPath< 4 > _T4;
+ /* TODO
+ typedef cpExtensions::DataStructures::PolyLineParametricPath< 1 > _T1;
+ typedef cpExtensions::DataStructures::PolyLineParametricPath< 2 > _T2;
+ typedef cpExtensions::DataStructures::PolyLineParametricPath< 3 > _T3;
+ typedef cpExtensions::DataStructures::PolyLineParametricPath< 4 > _T4;
- this->Superclass::SetITK( o );
- auto l1 = dynamic_cast< _T1* >( o );
- auto l2 = dynamic_cast< _T2* >( o );
- auto l3 = dynamic_cast< _T3* >( o );
- auto l4 = dynamic_cast< _T4* >( o );
- if ( l1 != NULL ) this->_ITK_2_VTK( l1 );
- else if( l2 != NULL ) this->_ITK_2_VTK( l2 );
- else if( l3 != NULL ) this->_ITK_2_VTK( l3 );
- else if( l4 != NULL ) this->_ITK_2_VTK( l4 );
- else
- {
- this->m_VTK = NULL;
- this->m_ITKvVTK = NULL;
+ this->Superclass::SetITK( o );
+ auto l1 = dynamic_cast< _T1* >( o );
+ auto l2 = dynamic_cast< _T2* >( o );
+ auto l3 = dynamic_cast< _T3* >( o );
+ auto l4 = dynamic_cast< _T4* >( o );
+ if ( l1 != NULL ) this->_ITK_2_VTK( l1 );
+ else if( l2 != NULL ) this->_ITK_2_VTK( l2 );
+ else if( l3 != NULL ) this->_ITK_2_VTK( l3 );
+ else if( l4 != NULL ) this->_ITK_2_VTK( l4 );
+ else
+ {
+ this->m_VTK = NULL;
+ this->m_ITKvVTK = NULL;
- } // fi
+ } // fi
+ */
}
// -------------------------------------------------------------------------
#define __cpPlugins__DataObjects__PolyLineParametricPath__h__
#include <cpPlugins/BaseObjects/DataObject.h>
-#include <cpPlugins_Paths.h>
#include <vtkSmartPointer.h>
// -------------------------------------------------------------------------
void cpPlugins::DataObjects::Skeleton::
SetITK( itk::LightObject* o )
{
- typedef cpExtensions::DataStructures::Skeleton< 1 > _T1;
- typedef cpExtensions::DataStructures::Skeleton< 2 > _T2;
- typedef cpExtensions::DataStructures::Skeleton< 3 > _T3;
- typedef cpExtensions::DataStructures::Skeleton< 4 > _T4;
+ /* TODO
+ typedef cpExtensions::DataStructures::Skeleton< 1 > _T1;
+ typedef cpExtensions::DataStructures::Skeleton< 2 > _T2;
+ typedef cpExtensions::DataStructures::Skeleton< 3 > _T3;
+ typedef cpExtensions::DataStructures::Skeleton< 4 > _T4;
- this->Superclass::SetITK( o );
- auto l1 = dynamic_cast< _T1* >( o );
- auto l2 = dynamic_cast< _T2* >( o );
- auto l3 = dynamic_cast< _T3* >( o );
- auto l4 = dynamic_cast< _T4* >( o );
- if ( l1 != NULL ) this->_ITK_2_VTK( l1 );
- else if( l2 != NULL ) this->_ITK_2_VTK( l2 );
- else if( l3 != NULL ) this->_ITK_2_VTK( l3 );
- else if( l4 != NULL ) this->_ITK_2_VTK( l4 );
- else
- {
- this->m_VTK = NULL;
- this->m_ITKvVTK = NULL;
+ this->Superclass::SetITK( o );
+ auto l1 = dynamic_cast< _T1* >( o );
+ auto l2 = dynamic_cast< _T2* >( o );
+ auto l3 = dynamic_cast< _T3* >( o );
+ auto l4 = dynamic_cast< _T4* >( o );
+ if ( l1 != NULL ) this->_ITK_2_VTK( l1 );
+ else if( l2 != NULL ) this->_ITK_2_VTK( l2 );
+ else if( l3 != NULL ) this->_ITK_2_VTK( l3 );
+ else if( l4 != NULL ) this->_ITK_2_VTK( l4 );
+ else
+ {
+ this->m_VTK = NULL;
+ this->m_ITKvVTK = NULL;
- } // fi
+ } // fi
+ */
}
// -------------------------------------------------------------------------
#define __cpPlugins__DataObjects__Skeleton__h__
#include <cpPlugins/BaseObjects/DataObject.h>
-#include <cpPlugins_Paths.h>
#include <vtkSmartPointer.h>
// -------------------------------------------------------------------------
SET(
_dirlist
- AnisotropicDiffusion
+ #AnisotropicDiffusion
GenericFilters
- ImageArithmeticFilters
- ImageBooleanFilters
- ImageDistanceMaps
- ImageGenericFilters
- ImageGradientFilters
- ImageMeshFilters
+ #ImageArithmeticFilters
+ #ImageBooleanFilters
+ #ImageDistanceMaps
+ #ImageGenericFilters
+ #ImageGradientFilters
+ #ImageMeshFilters
ImageSources
- ImageThresholdFilters
+ #ImageThresholdFilters
IO
MeshFilters
MeshSources
Widgets
)
-IF(ParabolicMorphology_LOADED)
- LIST(APPEND _dirlist ImageParaMorphologyFilters)
-ENDIF(ParabolicMorphology_LOADED)
+#IF(ParabolicMorphology_LOADED)
+# LIST(APPEND _dirlist ImageParaMorphologyFilters)
+#ENDIF(ParabolicMorphology_LOADED)
## ===============================
## == Build each plugin library ==
## ===============================
+INCLUDE_DIRECTORIES(
+ ${PROJECT_SOURCE_DIR}/lib
+ ${PROJECT_BINARY_DIR}/lib
+ ${PROJECT_SOURCE_DIR}/lib/Instances
+ ${PROJECT_BINARY_DIR}/lib/Instances
+ )
FOREACH(_dir ${_dirlist})
- Wrap_cpPlugins(
- _plugin
- ${CMAKE_CURRENT_SOURCE_DIR}/${_dir}
- ${prj_VERSION} ${prj_SHORT_VERSION}
- cpPlugins
- )
+ CreatePlugin(cpPlugins${_dir} ${_dir} ${cpPlugins_CONFIG_NUMBER_OF_FILES})
TARGET_LINK_LIBRARIES(
- ${_plugin} ${cpPlugins_LIB} ${cpExtensions_LIB} ${cpPlugins_Instances}
+ cpPlugins${_dir}
+ cpPlugins cpExtensions
+ ${cpPlugins_Instances}
)
ENDFOREACH(_dir)
-#include <plugins/GenericFilters/DataReproducer.h>
+#include <GenericFilters/DataReproducer.h>
#include <cpPlugins/BaseObjects/DataObject.h>
// -------------------------------------------------------------------------
#ifndef __CPPLUGINSGenericFilters__DATAREPRODUCER__H__
#define __CPPLUGINSGenericFilters__DATAREPRODUCER__H__
-#include <plugins/cpPluginsGenericFilters_Export.h>
+#include <cpPluginsGenericFilters_Export.h>
#include <cpPlugins/BaseObjects/ProcessObject.h>
namespace cpPluginsGenericFilters
-#include <plugins/GenericFilters/JoinBoundingBoxes.h>
+#include <GenericFilters/JoinBoundingBoxes.h>
#include <cpPlugins/BaseObjects/DataObject.h>
#include <cpPlugins/DataObjects/BoundingBox.h>
#ifndef __CPPLUGINSGENERICFILTERS__JOINBOUNDINGBOXES__H__
#define __CPPLUGINSGENERICFILTERS__JOINBOUNDINGBOXES__H__
-#include <plugins/cpPluginsGenericFilters_Export.h>
+#include <cpPluginsGenericFilters_Export.h>
#include <cpPlugins/BaseObjects/ProcessObject.h>
namespace cpPluginsGenericFilters
--- /dev/null
+header #define ITK_MANUAL_INSTANTIATION
+
+define io=ImageFileReader;ImageSeriesReader;ImageFileWriter
+
+tinclude itk#io#:h|hxx
+
+cinclude itk#color_pixels#.h
+cinclude itk#vectors#.h
+cinclude itk#diff_tensors#.h
+cinclude itk#matrices#.h
+cinclude itkConvertPixelBuffer.hxx
+cinclude itkImageAlgorithm.hxx
+cinclude itkSimpleDataObjectDecorator.hxx
+
+instances itk::#io#< itk::Image< #scalar_pixels#, #process_dims# > >
+instances itk::#io#< itk::Image< itk::#color_pixels#< #scalar_pixels# >, #process_dims# > >
+instances itk::#io#< itk::Image< itk::#vectors#< #real_types#, #process_dims# >, #process_dims# > >
+instances itk::#io#< itk::Image< itk::#diff_tensors#< #real_types# >, 3 > >
+instances itk::#io#< itk::Image< itk::#matrices#< #real_types#, #process_dims#, #process_dims# >, #process_dims# > >
+instances itk::#io#< itk::Image< itk::Offset< #process_dims# >, #process_dims# > >
+
+** eof - $RCSfile$
-#include <plugins/IO/ImageReader.h>
-#include <plugins/IO/ImageReaderQDialog.h>
+#include <IO/ImageReader.h>
+#include <IO/ImageReaderQDialog.h>
#include <cpPlugins/DataObjects/Image.h>
#include <itkImageFileReader.h>
#include <itkImageSeriesReader.h>
-
-#include <itkImageFileReader.hxx>
-#include <itkImageSeriesReader.hxx>
-#include <itkConvertPixelBuffer.hxx>
-#include <itkImageAlgorithm.hxx>
-#include <itkSimpleDataObjectDecorator.hxx>
+#include <itkImageIOFactory.h>
#ifdef cpPlugins_QT4
io->ReadImageInformation( );
if( fnames.size( ) >= 1 )
{
- switch( io->GetNumberOfDimensions( ) )
- {
- case 1: this->_GD0< 1 >( io ); break;
- case 2: this->_GD0< 2 >( io ); break;
- case 3: this->_GD0< 3 >( io ); break;
- case 4: this->_GD0< 4 >( io ); break;
- default:
+ bool success = false;
+ unsigned int dim = io->GetNumberOfDimensions( );
+#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_1
+ if( dim == 1 ) success = this->_GD0< 1 >( io );
+#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_1
+#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_2
+ if( dim == 2 ) success = this->_GD0< 2 >( io );
+#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_2
+#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_3
+ if( dim == 3 ) success = this->_GD0< 3 >( io );
+#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_3
+#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_4
+ if( dim == 4 ) success = this->_GD0< 4 >( io );
+#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_4
+ if( !success )
this->_Error( "Image dimension not supported." );
- break;
- } // hctiws
} // fi
}
// -------------------------------------------------------------------------
template< unsigned int _Dim >
-void cpPluginsIO::ImageReader::
+bool cpPluginsIO::ImageReader::
_GD0( itk::ImageIOBase* io )
{
typedef unsigned char uchar;
itk::ImageIOBase::IOComponentType ct = io->GetComponentType( );
itk::ImageIOBase::IOPixelType pt = io->GetPixelType( );
+ bool success = false;
if( pt == itk::ImageIOBase::SCALAR )
{
- switch( ct )
- {
- case itk::ImageIOBase::CHAR : this->_GD1< char, _Dim >( io ); break;
- case itk::ImageIOBase::SHORT : this->_GD1< short, _Dim >( io ); break;
- case itk::ImageIOBase::INT : this->_GD1< int, _Dim >( io ); break;
- case itk::ImageIOBase::LONG : this->_GD1< long, _Dim >( io ); break;
- case itk::ImageIOBase::FLOAT : this->_GD1< float, _Dim >( io ); break;
- case itk::ImageIOBase::DOUBLE : this->_GD1< double, _Dim >( io ); break;
- case itk::ImageIOBase::UCHAR : this->_GD1< uchar, _Dim >( io ); break;
- case itk::ImageIOBase::USHORT : this->_GD1< ushort, _Dim >( io ); break;
- case itk::ImageIOBase::UINT : this->_GD1< uint, _Dim >( io ); break;
- case itk::ImageIOBase::ULONG : this->_GD1< ulong, _Dim >( io ); break;
- default: this->_Error( "Scalar pixel type not supported." ); break;
- } // hctiws
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_char
+ if( ct == itk::ImageIOBase::CHAR ) success = this->_GD1< char, _Dim >( io );
+ if( ct == itk::ImageIOBase::UCHAR ) success = this->_GD1< uchar, _Dim >( io );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_char
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_short
+ if( ct == itk::ImageIOBase::SHORT ) success = this->_GD1< short, _Dim >( io );
+ if( ct == itk::ImageIOBase::USHORT ) success = this->_GD1< ushort, _Dim >( io );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_short
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_int
+ if( ct == itk::ImageIOBase::INT ) success = this->_GD1< int, _Dim >( io );
+ if( ct == itk::ImageIOBase::UINT ) success = this->_GD1< uint, _Dim >( io );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_int
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_long
+ if( ct == itk::ImageIOBase::LONG ) success = this->_GD1< long, _Dim >( io );
+ if( ct == itk::ImageIOBase::ULONG ) success = this->_GD1< ulong, _Dim >( io );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_long
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_float
+ if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< float, _Dim >( io );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_float
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_double
+ if( ct == itk::ImageIOBase::DOUBLE ) success = this->_GD1< double, _Dim >( io );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_double
}
else if( pt == itk::ImageIOBase::RGB )
{
- switch( ct )
- {
- case itk::ImageIOBase::CHAR : this->_GD1< itk::RGBPixel< char >, _Dim >( io ); break;
- case itk::ImageIOBase::SHORT : this->_GD1< itk::RGBPixel< short >, _Dim >( io ); break;
- case itk::ImageIOBase::INT : this->_GD1< itk::RGBPixel< int >, _Dim >( io ); break;
- case itk::ImageIOBase::LONG : this->_GD1< itk::RGBPixel< long >, _Dim >( io ); break;
- case itk::ImageIOBase::FLOAT : this->_GD1< itk::RGBPixel< float >, _Dim >( io ); break;
- case itk::ImageIOBase::DOUBLE : this->_GD1< itk::RGBPixel< double >, _Dim >( io ); break;
- case itk::ImageIOBase::UCHAR : this->_GD1< itk::RGBPixel< uchar >, _Dim >( io ); break;
- case itk::ImageIOBase::USHORT : this->_GD1< itk::RGBPixel< ushort >, _Dim >( io ); break;
- case itk::ImageIOBase::UINT : this->_GD1< itk::RGBPixel< uint >, _Dim >( io ); break;
- case itk::ImageIOBase::ULONG : this->_GD1< itk::RGBPixel< ulong >, _Dim >( io ); break;
- default: this->_Error( "RGB pixel type not supported." ); break;
- } // hctiws
+#ifdef cpPlugins_CONFIG_COLOR_PIXELS_RGBPixel
+# ifdef cpPlugins_CONFIG_INTEGER_TYPES_char
+ if( ct == itk::ImageIOBase::CHAR ) success = this->_GD1< itk::RGBPixel< char >, _Dim >( io );
+ if( ct == itk::ImageIOBase::UCHAR ) success = this->_GD1< itk::RGBPixel< uchar >, _Dim >( io );
+# endif // cpPlugins_CONFIG_INTEGER_TYPES_char
+# ifdef cpPlugins_CONFIG_INTEGER_TYPES_short
+ if( ct == itk::ImageIOBase::SHORT ) success = this->_GD1< itk::RGBPixel< short >, _Dim >( io );
+ if( ct == itk::ImageIOBase::USHORT ) success = this->_GD1< itk::RGBPixel< ushort >, _Dim >( io );
+# endif // cpPlugins_CONFIG_INTEGER_TYPES_short
+# ifdef cpPlugins_CONFIG_INTEGER_TYPES_int
+ if( ct == itk::ImageIOBase::INT ) success = this->_GD1< itk::RGBPixel< int >, _Dim >( io );
+ if( ct == itk::ImageIOBase::UINT ) success = this->_GD1< itk::RGBPixel< uint >, _Dim >( io );
+# endif // cpPlugins_CONFIG_INTEGER_TYPES_int
+# ifdef cpPlugins_CONFIG_INTEGER_TYPES_long
+ if( ct == itk::ImageIOBase::LONG ) success = this->_GD1< itk::RGBPixel< long >, _Dim >( io );
+ if( ct == itk::ImageIOBase::ULONG ) success = this->_GD1< itk::RGBPixel< ulong >, _Dim >( io );
+# endif // cpPlugins_CONFIG_INTEGER_TYPES_long
+# ifdef cpPlugins_CONFIG_INTEGER_TYPES_float
+ if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< itk::RGBPixel< float >, _Dim >( io );
+# endif // cpPlugins_CONFIG_INTEGER_TYPES_float
+# ifdef cpPlugins_CONFIG_INTEGER_TYPES_double
+ if( ct == itk::ImageIOBase::DOUBLE ) success = this->_GD1< itk::RGBPixel< double >, _Dim >( io );
+# endif // cpPlugins_CONFIG_INTEGER_TYPES_double
+#endif // cpPlugins_CONFIG_COLOR_PIXELS_RGBPixel
}
else if( pt == itk::ImageIOBase::RGBA )
{
- switch( ct )
- {
- case itk::ImageIOBase::CHAR : this->_GD1< itk::RGBAPixel< char >, _Dim >( io ); break;
- case itk::ImageIOBase::SHORT : this->_GD1< itk::RGBAPixel< short >, _Dim >( io ); break;
- case itk::ImageIOBase::INT : this->_GD1< itk::RGBAPixel< int >, _Dim >( io ); break;
- case itk::ImageIOBase::LONG : this->_GD1< itk::RGBAPixel< long >, _Dim >( io ); break;
- case itk::ImageIOBase::FLOAT : this->_GD1< itk::RGBAPixel< float >, _Dim >( io ); break;
- case itk::ImageIOBase::DOUBLE : this->_GD1< itk::RGBAPixel< double >, _Dim >( io ); break;
- case itk::ImageIOBase::UCHAR : this->_GD1< itk::RGBAPixel< uchar >, _Dim >( io ); break;
- case itk::ImageIOBase::USHORT : this->_GD1< itk::RGBAPixel< ushort >, _Dim >( io ); break;
- case itk::ImageIOBase::UINT : this->_GD1< itk::RGBAPixel< uint >, _Dim >( io ); break;
- case itk::ImageIOBase::ULONG : this->_GD1< itk::RGBAPixel< ulong >, _Dim >( io ); break;
- default: this->_Error( "RGBA pixel type not supported." ); break;
- } // hctiws
+#ifdef cpPlugins_CONFIG_COLOR_PIXELS_RGBAPixel
+# ifdef cpPlugins_CONFIG_INTEGER_TYPES_char
+ if( ct == itk::ImageIOBase::CHAR ) success = this->_GD1< itk::RGBAPixel< char >, _Dim >( io );
+ if( ct == itk::ImageIOBase::UCHAR ) success = this->_GD1< itk::RGBAPixel< uchar >, _Dim >( io );
+# endif // cpPlugins_CONFIG_INTEGER_TYPES_char
+# ifdef cpPlugins_CONFIG_INTEGER_TYPES_short
+ if( ct == itk::ImageIOBase::SHORT ) success = this->_GD1< itk::RGBAPixel< short >, _Dim >( io );
+ if( ct == itk::ImageIOBase::USHORT ) success = this->_GD1< itk::RGBAPixel< ushort >, _Dim >( io );
+# endif // cpPlugins_CONFIG_INTEGER_TYPES_short
+# ifdef cpPlugins_CONFIG_INTEGER_TYPES_int
+ if( ct == itk::ImageIOBase::INT ) success = this->_GD1< itk::RGBAPixel< int >, _Dim >( io );
+ if( ct == itk::ImageIOBase::UINT ) success = this->_GD1< itk::RGBAPixel< uint >, _Dim >( io );
+# endif // cpPlugins_CONFIG_INTEGER_TYPES_int
+# ifdef cpPlugins_CONFIG_INTEGER_TYPES_long
+ if( ct == itk::ImageIOBase::LONG ) success = this->_GD1< itk::RGBAPixel< long >, _Dim >( io );
+ if( ct == itk::ImageIOBase::ULONG ) success = this->_GD1< itk::RGBAPixel< ulong >, _Dim >( io );
+# endif // cpPlugins_CONFIG_INTEGER_TYPES_long
+# ifdef cpPlugins_CONFIG_INTEGER_TYPES_float
+ if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< itk::RGBAPixel< float >, _Dim >( io );
+# endif // cpPlugins_CONFIG_INTEGER_TYPES_float
+# ifdef cpPlugins_CONFIG_INTEGER_TYPES_double
+ if( ct == itk::ImageIOBase::DOUBLE ) success = this->_GD1< itk::RGBAPixel< double >, _Dim >( io );
+# endif // cpPlugins_CONFIG_INTEGER_TYPES_double
+#endif // cpPlugins_CONFIG_COLOR_PIXELS_RGBAPixel
}
else if( pt == itk::ImageIOBase::COMPLEX )
{
- switch( ct )
- {
- case itk::ImageIOBase::FLOAT : this->_GD1< std::complex< float >, _Dim >( io ); break;
- case itk::ImageIOBase::DOUBLE : this->_GD1< std::complex< double >, _Dim >( io ); break;
- default: this->_Error( "Complex pixel type not supported." ); break;
- } // hctiws
}
else if( pt == itk::ImageIOBase::COVARIANTVECTOR )
{
- switch( ct )
- {
- case itk::ImageIOBase::FLOAT : this->_GD1< itk::CovariantVector< float, _Dim >, _Dim >( io ); break;
- case itk::ImageIOBase::DOUBLE : this->_GD1< itk::CovariantVector< double, _Dim >, _Dim >( io ); break;
- default: this->_Error( "CovariantVector pixel type not supported." ); break;
- } // hctiws
}
else if( pt == itk::ImageIOBase::POINT )
{
- switch( ct )
- {
- case itk::ImageIOBase::FLOAT : this->_GD1< itk::Point< float, _Dim >, _Dim >( io ); break;
- case itk::ImageIOBase::DOUBLE : this->_GD1< itk::Point< double, _Dim >, _Dim >( io ); break;
- default: this->_Error( "Point pixel type not supported." ); break;
- } // hctiws
}
else if( pt == itk::ImageIOBase::VECTOR )
{
- switch( ct )
- {
- case itk::ImageIOBase::FLOAT : this->_GD1< itk::Vector< float, _Dim >, _Dim >( io ); break;
- case itk::ImageIOBase::DOUBLE : this->_GD1< itk::Vector< double, _Dim >, _Dim >( io ); break;
- default: this->_Error( "Vector pixel type not supported." ); break;
- } // hctiws
}
else if( pt == itk::ImageIOBase::SYMMETRICSECONDRANKTENSOR )
{
- switch( ct )
- {
- case itk::ImageIOBase::FLOAT : this->_GD1< itk::SymmetricSecondRankTensor< float, _Dim >, _Dim >( io ); break;
- case itk::ImageIOBase::DOUBLE : this->_GD1< itk::SymmetricSecondRankTensor< double, _Dim >, _Dim >( io ); break;
- default: this->_Error( "SymmetricSecondRankTensor pixel type not supported." ); break;
- } // hctiws
}
else if( pt == itk::ImageIOBase::DIFFUSIONTENSOR3D )
{
if( _Dim == 3 )
{
- switch( ct )
- {
- case itk::ImageIOBase::FLOAT : this->_GD1< itk::DiffusionTensor3D< float >, 3 >( io ); break;
- case itk::ImageIOBase::DOUBLE : this->_GD1< itk::DiffusionTensor3D< double >, 3 >( io ); break;
- default: this->_Error( "DiffusionTensor3D pixel type not supported." ); break;
- } // hctiws
}
else
this->_Error( "DiffusionTensor3D dimension not supported." );
}
else if( pt == itk::ImageIOBase::MATRIX )
{
- switch( ct )
- {
- case itk::ImageIOBase::FLOAT : this->_GD1< itk::Matrix< float, _Dim, _Dim >, _Dim >( io ); break;
- case itk::ImageIOBase::DOUBLE : this->_GD1< itk::Matrix< double, _Dim, _Dim >, _Dim >( io ); break;
- default: this->_Error( "Matrix pixel type not supported." ); break;
- } // hctiws
}
else if( pt == itk::ImageIOBase::OFFSET )
{
}
else if( pt == itk::ImageIOBase::FIXEDARRAY )
{
- switch( ct )
- {
- case itk::ImageIOBase::CHAR : this->_GD1< itk::FixedArray< char, _Dim >, _Dim >( io ); break;
- case itk::ImageIOBase::SHORT : this->_GD1< itk::FixedArray< short, _Dim >, _Dim >( io ); break;
- case itk::ImageIOBase::INT : this->_GD1< itk::FixedArray< int, _Dim >, _Dim >( io ); break;
- case itk::ImageIOBase::LONG : this->_GD1< itk::FixedArray< long, _Dim >, _Dim >( io ); break;
- case itk::ImageIOBase::FLOAT : this->_GD1< itk::FixedArray< float, _Dim >, _Dim >( io ); break;
- case itk::ImageIOBase::DOUBLE : this->_GD1< itk::FixedArray< double, _Dim >, _Dim >( io ); break;
- case itk::ImageIOBase::UCHAR : this->_GD1< itk::FixedArray< uchar, _Dim >, _Dim >( io ); break;
- case itk::ImageIOBase::USHORT : this->_GD1< itk::FixedArray< ushort, _Dim >, _Dim >( io ); break;
- case itk::ImageIOBase::UINT : this->_GD1< itk::FixedArray< uint, _Dim >, _Dim >( io ); break;
- case itk::ImageIOBase::ULONG : this->_GD1< itk::FixedArray< ulong, _Dim >, _Dim >( io ); break;
- default: this->_Error( "Scalar pixel type not supported." ); break;
- } // hctiws
}
- else
- this->_Error( "Image pixel type not yet supported." );
+ return( success );
}
// -------------------------------------------------------------------------
template< class _TPixel, unsigned int _Dim >
-void cpPluginsIO::ImageReader::
+bool cpPluginsIO::ImageReader::
_GD1( itk::ImageIOBase* io )
{
typedef itk::Image< _TPixel, _Dim > _TImage;
{
f->Update( );
this->GetOutput( "Output" )->SetITK( f->GetOutput( ) );
+ return( true );
}
catch( itk::ExceptionObject& err )
{
this->_Error( err.GetDescription( ) );
+ return( false );
} // yrt
}
{
f->Update( );
this->GetOutput( "Output" )->SetITK( f->GetOutput( ) );
+ return( true );
}
catch( itk::ExceptionObject& err )
{
this->_Error( err.GetDescription( ) );
+ return( false );
} // yrt
#ifndef __CPPLUGINSIO__IMAGEREADER__H__
#define __CPPLUGINSIO__IMAGEREADER__H__
-#include <plugins/cpPluginsIO_Export.h>
+#include <cpPluginsIO_Export.h>
#include <cpPlugins/BaseObjects/ProcessObject.h>
namespace itk { class ImageIOBase; }
protected:
template< unsigned int _Dim >
- inline void _GD0( itk::ImageIOBase* io );
+ inline bool _GD0( itk::ImageIOBase* io );
template< class _TPixel, unsigned int _Dim >
- inline void _GD1( itk::ImageIOBase* io );
+ inline bool _GD1( itk::ImageIOBase* io );
};
} // ecapseman
-#include <plugins/IO/ImageWriter.h>
-#include <plugins/IO/ImageWriterQDialog.h>
+#include <IO/ImageWriter.h>
+#include <IO/ImageWriterQDialog.h>
#include <cpPlugins/DataObjects/Image.h>
+#include <cpPlugins/DataObjects/Image_Demanglers.h>
+#include <cpInstances_SimpleImages.h>
#include <itkImageFileWriter.h>
-#include <itkImageFileWriter.hxx>
-
#ifdef cpPlugins_QT4
#include <QApplication>
_GenerateData( )
{
auto o = this->GetInputData( "Input" );
- cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 );
- else this->_Error( "Invalid input image." );
+ cpPlugins_Demangle_Image_ProcessDims( o, _GD0, );
+ cpPlugins_Demangle_Image_DiffTensors3D( o, _GD1, );
+ this->_Error( "Invalid input image dimension." );
}
// -------------------------------------------------------------------------
template< class _TImage >
void cpPluginsIO::ImageWriter::
_GD0( _TImage* image )
+{
+ cpPlugins_Demangle_Image_IntPixels( image, _GD1, _TImage::ImageDimension, );
+ cpPlugins_Demangle_Image_RealPixels( image, _GD1, _TImage::ImageDimension, );
+ cpPlugins_Demangle_Image_ScalarPixels( image, _GD1, _TImage::ImageDimension, );
+ cpPlugins_Demangle_Image_ColorPixels( image, _GD1, _TImage::ImageDimension, );
+ cpPlugins_Demangle_Image_VectorPixels( image, _GD1, _TImage::ImageDimension, );
+ this->_Error( "Invalid input image pixel type." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpPluginsIO::ImageWriter::
+_GD1( _TImage* image )
{
typedef itk::ImageFileWriter< _TImage > _TFilter;
#ifndef __CPPLUGINSIO__IMAGEWRITER__H__
#define __CPPLUGINSIO__IMAGEWRITER__H__
-#include <plugins/cpPluginsIO_Export.h>
+#include <cpPluginsIO_Export.h>
#include <cpPlugins/BaseObjects/ProcessObject.h>
#include <cpPlugins/DataObjects/Image.h>
-namespace itk
-{
- class ImageIOBase;
-}
-
namespace cpPluginsIO
{
/**
protected:
template< class _TImage >
- inline void _GD0( _TImage* image );
+ inline void _GD0( _TImage* image );
+
+ template< class _TImage >
+ inline void _GD1( _TImage* image );
};
} // ecapseman
--- /dev/null
+header #define ITK_MANUAL_INSTANTIATION
+
+tinclude itkRandomImageSource:h|hxx
+
+instances itk::RandomImageSource< itk::Image< #scalar_pixels#, #process_dims# > >
+
+** eof - $RCSfile$
-#include <plugins/ImageSources/RandomImageSource.h>
+#include <ImageSources/RandomImageSource.h>
#include <cpPlugins/DataObjects/Image.h>
#include <itkRandomImageSource.h>
-#include <itkRandomImageSource.hxx>
// -------------------------------------------------------------------------
cpPluginsImageSources::RandomImageSource::
this->m_Parameters.ConfigureAsRealList( "Spacing" );
std::vector< std::string > pixels;
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_char
pixels.push_back( "char" );
- pixels.push_back( "short" );
- pixels.push_back( "int" );
- pixels.push_back( "long" );
pixels.push_back( "uchar" );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_char
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_short
+ pixels.push_back( "short" );
pixels.push_back( "ushort" );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_short
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_int
+ pixels.push_back( "int" );
pixels.push_back( "uint" );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_int
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_long
+ pixels.push_back( "long" );
pixels.push_back( "ulong" );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_long
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_float
pixels.push_back( "float" );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_float
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_double
pixels.push_back( "double" );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_double
this->m_Parameters.ConfigureAsChoices( "PixelType", pixels );
- this->m_Parameters.SetSelectedChoice( "PixelType", "uchar" );
std::vector< std::string > dims;
+#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_1
dims.push_back( "1" );
+#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_1
+#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_2
dims.push_back( "2" );
+#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_2
+#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_3
dims.push_back( "3" );
+#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_3
+#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_4
dims.push_back( "4" );
+#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_4
this->m_Parameters.ConfigureAsChoices( "Dimension", dims );
- this->m_Parameters.SetSelectedChoice( "Dimension", "2" );
}
// -------------------------------------------------------------------------
void cpPluginsImageSources::RandomImageSource::
_GenerateData( )
{
+ bool success = false;
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." );
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_char
+ if( pixel == "char" ) success = this->_GD0< char >( );
+ if( pixel == "uchar" ) success = this->_GD0< unsigned char >( );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_char
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_short
+ if( pixel == "short" ) success = this->_GD0< short >( );
+ if( pixel == "ushort" ) success = this->_GD0< unsigned short >( );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_short
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_int
+ if( pixel == "int" ) success = this->_GD0< int >( );
+ if( pixel == "uint" ) success = this->_GD0< unsigned int >( );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_int
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_long
+ if( pixel == "long" ) success = this->_GD0< long >( );
+ if( pixel == "ulong" ) success = this->_GD0< unsigned long >( );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_long
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_float
+ if( pixel == "float" ) success = this->_GD0< float >( );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_float
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_double
+ if( pixel == "double" ) success = this->_GD0< double >( );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_double
+ if( !success )
+ this->_Error( "Invalid pixel type." );
}
// -------------------------------------------------------------------------
template< class _TPixel >
-void cpPluginsImageSources::RandomImageSource::
+bool cpPluginsImageSources::RandomImageSource::
_GD0( )
{
+ bool success = false;
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." );
+#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_1
+ if( dim == "1" ) success = this->_GD1< _TPixel, 1 >( );
+#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_1
+#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_2
+ if( dim == "2" ) success = this->_GD1< _TPixel, 2 >( );
+#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_2
+#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_3
+ if( dim == "3" ) success = this->_GD1< _TPixel, 3 >( );
+#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_3
+#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_4
+ if( dim == "4" ) success = this->_GD1< _TPixel, 4 >( );
+#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_4
+ if( !success )
+ this->_Error( "Invalid dimension." );
+ return( success );
}
// -------------------------------------------------------------------------
template< class _TPixel, unsigned int _VDim >
-void cpPluginsImageSources::RandomImageSource::
+bool cpPluginsImageSources::RandomImageSource::
_GD1( )
{
typedef itk::Image< _TPixel, _VDim > _TImage;
filter->SetSpacing( out_spac );
filter->Update( );
this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
+ return( true );
}
// eof - $RCSfile$
#ifndef __cpPluginsImageSources__RandomImageSource__h__
#define __cpPluginsImageSources__RandomImageSource__h__
-#include <plugins/cpPluginsImageSources_Export.h>
+#include <cpPluginsImageSources_Export.h>
#include <cpPlugins/BaseObjects/ProcessObject.h>
namespace cpPluginsImageSources
protected:
template< class _TPixel >
- inline void _GD0( );
+ inline bool _GD0( );
template< class _TPixel, unsigned int _VDim >
- inline void _GD1( );
+ inline bool _GD1( );
};
} // ecapseman
-#include <plugins/MeshFilters/AppendMeshesFilter.h>
+#include <MeshFilters/AppendMeshesFilter.h>
#include <cpPlugins/DataObjects/Mesh.h>
#include <vtkAppendPolyData.h>
AppendMeshesFilter( )
: Superclass( )
{
- this->_ConfigureInput< cpPlugins::DataObjects::Mesh >( "Input0", true, false );
- this->_ConfigureInput< cpPlugins::DataObjects::Mesh >( "Input1", true, false );
- this->_ConfigureInput< cpPlugins::DataObjects::Mesh >( "Input2", false, false );
- this->_ConfigureInput< cpPlugins::DataObjects::Mesh >( "Input3", false, false );
- this->_ConfigureInput< cpPlugins::DataObjects::Mesh >( "Input4", false, false );
- this->_ConfigureInput< cpPlugins::DataObjects::Mesh >( "Input5", false, false );
- this->_ConfigureOutput< cpPlugins::DataObjects::Mesh >( "Output" );
+ typedef cpPlugins::DataObjects::Mesh _TMesh;
+
+ this->_ConfigureInput< _TMesh >( "Input0", true, false );
+ this->_ConfigureInput< _TMesh >( "Input1", true, false );
+ this->_ConfigureInput< _TMesh >( "Input2", false, false );
+ this->_ConfigureInput< _TMesh >( "Input3", false, false );
+ this->_ConfigureInput< _TMesh >( "Input4", false, false );
+ this->_ConfigureInput< _TMesh >( "Input5", false, false );
+ this->_ConfigureOutput< _TMesh >( "Output" );
}
// -------------------------------------------------------------------------
#ifndef __CPPLUGINSIMAGEMESH__APPENDMESHESFILTER__H__
#define __CPPLUGINSIMAGEMESH__APPENDMESHESFILTER__H__
-#include <plugins/cpPluginsMeshFilters_Export.h>
+#include <cpPluginsMeshFilters_Export.h>
#include <cpPlugins/BaseObjects/ProcessObject.h>
namespace cpPluginsMeshFilters
-#include <plugins/MeshSources/CylinderSource.h>
+#include <MeshSources/CylinderSource.h>
#include <cpPlugins/DataObjects/Mesh.h>
#include <vtkCylinderSource.h>
#ifndef __CPPLUGINSMESHSOURCES__CYLINDERSOURCE__H__
#define __CPPLUGINSMESHSOURCES__CYLINDERSOURCE__H__
-#include <plugins/cpPluginsMeshSources_Export.h>
+#include <cpPluginsMeshSources_Export.h>
#include <cpPlugins/BaseObjects/ProcessObject.h>
namespace cpPluginsMeshSources
-#include <plugins/MeshSources/SphereSource.h>
+#include <MeshSources/SphereSource.h>
#include <cpPlugins/DataObjects/Mesh.h>
#include <vtkSphereSource.h>
#ifndef __CPPLUGINSMESHSOURCES__SPHERESOURCE__H__
#define __CPPLUGINSMESHSOURCES__SPHERESOURCE__H__
-#include <plugins/cpPluginsMeshSources_Export.h>
+#include <cpPluginsMeshSources_Export.h>
#include <cpPlugins/BaseObjects/ProcessObject.h>
namespace cpPluginsMeshSources
-#include <plugins/Widgets/LineWidget.h>
+#include <Widgets/LineWidget.h>
#include <cpPlugins/DataObjects/Image.h>
#include <cpPlugins/DataObjects/Mesh.h>
#include <cpExtensions/Visualization/WindowLevelImageActor.h>
#ifndef __cpPluginsWidgets__LineWidget__h__
#define __cpPluginsWidgets__LineWidget__h__
-#include <plugins/cpPluginsWidgets_Export.h>
+#include <cpPluginsWidgets_Export.h>
#include <cpPlugins/BaseObjects/Widget.h>
#include <set>
-#include <plugins/Widgets/SeedWidget.h>
+#include <Widgets/SeedWidget.h>
#include <cpPlugins/DataObjects/Image.h>
#include <cpPlugins/DataObjects/Mesh.h>
#ifndef __CPPLUGINSWIDGETS__SEEDWIDGET__H__
#define __CPPLUGINSWIDGETS__SEEDWIDGET__H__
-#include <plugins/cpPluginsWidgets_Export.h>
+#include <cpPluginsWidgets_Export.h>
#include <cpPlugins/BaseObjects/Widget.h>
// -------------------------------------------------------------------------
-#include <plugins/Widgets/SplineWidget.h>
+#include <Widgets/SplineWidget.h>
#include <cpPlugins/DataObjects/Image.h>
#include <cpPlugins/DataObjects/Mesh.h>
#include <cpExtensions/Visualization/WindowLevelImageActor.h>
-#include <cpPlugins_BaseObjects.h>
+
+#include <itkVector.h>
#include <vtkImageData.h>
#include <vtkRenderer.h>
typedef std::vector< _TVector > _TVectors;
unsigned long nPoints = this->m_Contour->GetNumberOfPoints( );
- double area = 0.0;
- for( unsigned long i = 0; i < nPoints; ++i )
- {
- double p[ 3 ], q[ 3 ];
- this->m_Contour->GetPoint( i, p );
- this->m_Contour->GetPoint( ( i + 1 ) % nPoints, q );
-
- area += ( p[ 0 ] * q[ 1 ] ) - ( q[ 0 ] - p[ 1 ] );
-
- } // rof
- std::cout << "Area: " << area << std::endl;
-
unsigned long support = nPoints / 10;
_TVectors pp, qp;
for( unsigned long i = 0; i < support; ++i )
#ifndef __cpPluginsWidgets__SplineWidget__h__
#define __cpPluginsWidgets__SplineWidget__h__
-#include <plugins/cpPluginsWidgets_Export.h>
+#include <cpPluginsWidgets_Export.h>
#include <cpPlugins/BaseObjects/Widget.h>
#include <vtkSmartPointer.h>