From 65e11480407fe343b2b56098257e0bb837f75df3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Wed, 26 Oct 2016 15:31:35 -0500 Subject: [PATCH] ... --- CMakeLists.txt | 33 +- appli/bash/BuildDemangleHeader.cxx.in | 348 ------------- appli/bash/BuildInstances.cxx.in | 314 ----------- appli/bash/Config.h.in | 288 ++++++++++ appli/bash/CreateDemanglers.cxx | 120 +++++ appli/bash/CreateInstances.cxx | 199 +++++++ appli/bash/CreatePlugins.cxx | 140 +++++ appli/bash/Utility.h.in | 92 ---- appli/examples/plugins/CMakeLists.txt | 7 +- cmake/Functions.cmake | 493 ++++++------------ cmake/Options.cmake | 42 +- cmake/{Qt4Tools.cmake => QtTools.cmake} | 0 lib/CMakeLists.txt | 70 ++- lib/Instances/BaseObjects.i | 24 + lib/Instances/BoundingBoxes.i | 10 + lib/Instances/CMakeLists.txt | 50 +- lib/Instances/ImageFiltersBases.i | 17 + lib/Instances/ImageIterators.i | 19 + lib/Instances/Meshes.i | 12 + lib/Instances/SimpleImages.i | 31 ++ lib/Instances/cpPlugins_BaseObjects.i | 35 -- lib/Instances/cpPlugins_BaseObjects_extra.cxx | 45 -- lib/Instances/cpPlugins_BoundingBoxes.i | 23 - lib/Instances/cpPlugins_ImageFilters.i | 47 -- lib/Instances/cpPlugins_ImageIterators.i | 59 --- .../cpPlugins_ImageNeighborhoodIterators.i | 27 - lib/Instances/cpPlugins_Images.i | 43 -- lib/Instances/cpPlugins_Images_extra.cxx | 19 - lib/Instances/cpPlugins_Meshes.i | 34 -- lib/Instances/cpPlugins_Paths.i | 34 -- lib/QCustomPlot/QCustomPlot.h | 4 +- lib/cpPlugins/BaseObjects/Demangle.h | 41 -- lib/cpPlugins/Config.h.in | 1 + lib/cpPlugins/DataObjects/BoundingBox.cxx | 123 +++++ lib/cpPlugins/DataObjects/BoundingBox.h | 2 +- lib/cpPlugins/DataObjects/BoundingBox.hxx | 132 ----- lib/cpPlugins/DataObjects/Image.cxx | 153 +++++- lib/cpPlugins/DataObjects/Image.d | 13 + lib/cpPlugins/DataObjects/Image.h | 11 +- lib/cpPlugins/DataObjects/Image.hxx | 99 ---- lib/cpPlugins/DataObjects/Mesh.cxx | 178 +++---- lib/cpPlugins/DataObjects/Mesh.d | 3 + lib/cpPlugins/DataObjects/Mesh.hxx | 2 +- .../DataObjects/PolyLineParametricPath.cxx | 38 +- .../DataObjects/PolyLineParametricPath.h | 1 - lib/cpPlugins/DataObjects/Skeleton.cxx | 38 +- lib/cpPlugins/DataObjects/Skeleton.h | 1 - .../DataObjects}/itkImageToVTKImageFilter.h | 0 .../DataObjects}/itkImageToVTKImageFilter.hxx | 0 .../DataObjects}/itkVTKImageToImageFilter.h | 0 .../DataObjects}/itkVTKImageToImageFilter.hxx | 0 plugins/CMakeLists.txt | 39 +- plugins/GenericFilters/DataReproducer.cxx | 2 +- plugins/GenericFilters/DataReproducer.h | 2 +- plugins/GenericFilters/JoinBoundingBoxes.cxx | 2 +- plugins/GenericFilters/JoinBoundingBoxes.h | 2 +- plugins/IO/IO.i | 22 + plugins/IO/ImageReader.cxx | 215 ++++---- plugins/IO/ImageReader.h | 6 +- plugins/IO/ImageWriter.cxx | 26 +- plugins/IO/ImageWriter.h | 12 +- plugins/ImageSources/ImageSources.i | 7 + plugins/ImageSources/RandomImageSource.cxx | 93 +++- plugins/ImageSources/RandomImageSource.h | 6 +- plugins/MeshFilters/AppendMeshesFilter.cxx | 18 +- plugins/MeshFilters/AppendMeshesFilter.h | 2 +- plugins/MeshSources/CylinderSource.cxx | 2 +- plugins/MeshSources/CylinderSource.h | 2 +- plugins/MeshSources/SphereSource.cxx | 2 +- plugins/MeshSources/SphereSource.h | 2 +- plugins/Widgets/LineWidget.cxx | 2 +- plugins/Widgets/LineWidget.h | 2 +- plugins/Widgets/SeedWidget.cxx | 2 +- plugins/Widgets/SeedWidget.h | 2 +- plugins/Widgets/SplineWidget.cxx | 17 +- plugins/Widgets/SplineWidget.h | 2 +- 76 files changed, 1811 insertions(+), 2193 deletions(-) delete mode 100644 appli/bash/BuildDemangleHeader.cxx.in delete mode 100644 appli/bash/BuildInstances.cxx.in create mode 100644 appli/bash/Config.h.in create mode 100644 appli/bash/CreateDemanglers.cxx create mode 100644 appli/bash/CreateInstances.cxx create mode 100644 appli/bash/CreatePlugins.cxx delete mode 100644 appli/bash/Utility.h.in rename cmake/{Qt4Tools.cmake => QtTools.cmake} (100%) create mode 100644 lib/Instances/BaseObjects.i create mode 100644 lib/Instances/BoundingBoxes.i create mode 100644 lib/Instances/ImageFiltersBases.i create mode 100644 lib/Instances/ImageIterators.i create mode 100644 lib/Instances/Meshes.i create mode 100644 lib/Instances/SimpleImages.i delete mode 100644 lib/Instances/cpPlugins_BaseObjects.i delete mode 100644 lib/Instances/cpPlugins_BaseObjects_extra.cxx delete mode 100644 lib/Instances/cpPlugins_BoundingBoxes.i delete mode 100644 lib/Instances/cpPlugins_ImageFilters.i delete mode 100644 lib/Instances/cpPlugins_ImageIterators.i delete mode 100644 lib/Instances/cpPlugins_ImageNeighborhoodIterators.i delete mode 100644 lib/Instances/cpPlugins_Images.i delete mode 100644 lib/Instances/cpPlugins_Images_extra.cxx delete mode 100644 lib/Instances/cpPlugins_Meshes.i delete mode 100644 lib/Instances/cpPlugins_Paths.i delete mode 100644 lib/cpPlugins/BaseObjects/Demangle.h delete mode 100644 lib/cpPlugins/DataObjects/BoundingBox.hxx create mode 100644 lib/cpPlugins/DataObjects/Image.d delete mode 100644 lib/cpPlugins/DataObjects/Image.hxx create mode 100644 lib/cpPlugins/DataObjects/Mesh.d rename lib/{Itk2Vtk => cpPlugins/DataObjects}/itkImageToVTKImageFilter.h (100%) rename lib/{Itk2Vtk => cpPlugins/DataObjects}/itkImageToVTKImageFilter.hxx (100%) rename lib/{Itk2Vtk => cpPlugins/DataObjects}/itkVTKImageToImageFilter.h (100%) rename lib/{Itk2Vtk => cpPlugins/DataObjects}/itkVTKImageToImageFilter.hxx (100%) create mode 100644 plugins/IO/IO.i create mode 100644 plugins/ImageSources/ImageSources.i diff --git a/CMakeLists.txt b/CMakeLists.txt index 82cc483..2e757da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,39 +37,40 @@ SET(prj_SHORT_VERSION "${prj_MAJOR_VERSION}") 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$ diff --git a/appli/bash/BuildDemangleHeader.cxx.in b/appli/bash/BuildDemangleHeader.cxx.in deleted file mode 100644 index 8eb395c..0000000 --- a/appli/bash/BuildDemangleHeader.cxx.in +++ /dev/null @@ -1,348 +0,0 @@ -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -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$ diff --git a/appli/bash/BuildInstances.cxx.in b/appli/bash/BuildInstances.cxx.in deleted file mode 100644 index dbff248..0000000 --- a/appli/bash/BuildInstances.cxx.in +++ /dev/null @@ -1,314 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -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$ diff --git a/appli/bash/Config.h.in b/appli/bash/Config.h.in new file mode 100644 index 0000000..f891794 --- /dev/null +++ b/appli/bash/Config.h.in @@ -0,0 +1,288 @@ +#ifndef __cpPlugins__bash__Config__h__ +#define __cpPlugins__bash__Config__h__ + +// ------------------------------------------------------------------------- +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// ------------------------------------------------------------------------- +#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$ diff --git a/appli/bash/CreateDemanglers.cxx b/appli/bash/CreateDemanglers.cxx new file mode 100644 index 0000000..1b34b25 --- /dev/null +++ b/appli/bash/CreateDemanglers.cxx @@ -0,0 +1,120 @@ +#include + +// ------------------------------------------------------------------------- +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$ diff --git a/appli/bash/CreateInstances.cxx b/appli/bash/CreateInstances.cxx new file mode 100644 index 0000000..6ffe2dc --- /dev/null +++ b/appli/bash/CreateInstances.cxx @@ -0,0 +1,199 @@ +#include + +// ------------------------------------------------------------------------- +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$ diff --git a/appli/bash/CreatePlugins.cxx b/appli/bash/CreatePlugins.cxx new file mode 100644 index 0000000..2184347 --- /dev/null +++ b/appli/bash/CreatePlugins.cxx @@ -0,0 +1,140 @@ +#include + +// ------------------------------------------------------------------------- +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$ diff --git a/appli/bash/Utility.h.in b/appli/bash/Utility.h.in deleted file mode 100644 index 7dda46f..0000000 --- a/appli/bash/Utility.h.in +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef __cpPlugins__bash__Utility__h__ -#define __cpPlugins__bash__Utility__h__ - -#include -#include -#include - -// ------------------------------------------------------------------------- -#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$ diff --git a/appli/examples/plugins/CMakeLists.txt b/appli/examples/plugins/CMakeLists.txt index 90cd146..e1f396b 100644 --- a/appli/examples/plugins/CMakeLists.txt +++ b/appli/examples/plugins/CMakeLists.txt @@ -12,13 +12,16 @@ FILE( ## ========================== ## == 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) diff --git a/cmake/Functions.cmake b/cmake/Functions.cmake index 287e693..4da395c 100644 --- a/cmake/Functions.cmake +++ b/cmake/Functions.cmake @@ -61,47 +61,116 @@ ENDFUNCTION() 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} @@ -109,347 +178,121 @@ IF(_sources) 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() diff --git a/cmake/Options.cmake b/cmake/Options.cmake index ab01d77..edd8126 100644 --- a/cmake/Options.cmake +++ b/cmake/Options.cmake @@ -2,22 +2,34 @@ ## == 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$ diff --git a/cmake/Qt4Tools.cmake b/cmake/QtTools.cmake similarity index 100% rename from cmake/Qt4Tools.cmake rename to cmake/QtTools.cmake diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 4caae27..e149793 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,50 +1,40 @@ ## ==================== -## == 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 == @@ -69,4 +59,4 @@ FOREACH(_lib ${cpPlugins_DynLibs}) FILE(APPEND ${PROJECT_BINARY_DIR}/cpPlugins_Libraries.config "${_lib}\n") ENDFOREACH(_lib) -## eof - $RCSfile$ +## eof - $RCSfilfe$ diff --git a/lib/Instances/BaseObjects.i b/lib/Instances/BaseObjects.i new file mode 100644 index 0000000..2923be1 --- /dev/null +++ b/lib/Instances/BaseObjects.i @@ -0,0 +1,24 @@ +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$ diff --git a/lib/Instances/BoundingBoxes.i b/lib/Instances/BoundingBoxes.i new file mode 100644 index 0000000..6e50565 --- /dev/null +++ b/lib/Instances/BoundingBoxes.i @@ -0,0 +1,10 @@ +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$ diff --git a/lib/Instances/CMakeLists.txt b/lib/Instances/CMakeLists.txt index 0ec835b..44e646d 100644 --- a/lib/Instances/CMakeLists.txt +++ b/lib/Instances/CMakeLists.txt @@ -1,34 +1,32 @@ -## =========================== -## == 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$ diff --git a/lib/Instances/ImageFiltersBases.i b/lib/Instances/ImageFiltersBases.i new file mode 100644 index 0000000..4d2044a --- /dev/null +++ b/lib/Instances/ImageFiltersBases.i @@ -0,0 +1,17 @@ +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$ diff --git a/lib/Instances/ImageIterators.i b/lib/Instances/ImageIterators.i new file mode 100644 index 0000000..5ff717d --- /dev/null +++ b/lib/Instances/ImageIterators.i @@ -0,0 +1,19 @@ +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$ diff --git a/lib/Instances/Meshes.i b/lib/Instances/Meshes.i new file mode 100644 index 0000000..6e37a2f --- /dev/null +++ b/lib/Instances/Meshes.i @@ -0,0 +1,12 @@ +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$ diff --git a/lib/Instances/SimpleImages.i b/lib/Instances/SimpleImages.i new file mode 100644 index 0000000..ab100bb --- /dev/null +++ b/lib/Instances/SimpleImages.i @@ -0,0 +1,31 @@ +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$ diff --git a/lib/Instances/cpPlugins_BaseObjects.i b/lib/Instances/cpPlugins_BaseObjects.i deleted file mode 100644 index d1b9569..0000000 --- a/lib/Instances/cpPlugins_BaseObjects.i +++ /dev/null @@ -1,35 +0,0 @@ -** ====================== -** == 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$ diff --git a/lib/Instances/cpPlugins_BaseObjects_extra.cxx b/lib/Instances/cpPlugins_BaseObjects_extra.cxx deleted file mode 100644 index 4f3ad9d..0000000 --- a/lib/Instances/cpPlugins_BaseObjects_extra.cxx +++ /dev/null @@ -1,45 +0,0 @@ -#define ITK_MANUAL_INSTANTIATION - -#include -#include -#include -#include - -#include -#include -#include - -// ------------------------------------------------------------------------- -#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$ diff --git a/lib/Instances/cpPlugins_BoundingBoxes.i b/lib/Instances/cpPlugins_BoundingBoxes.i deleted file mode 100644 index 06a9ccb..0000000 --- a/lib/Instances/cpPlugins_BoundingBoxes.i +++ /dev/null @@ -1,23 +0,0 @@ -** ====================== -** == 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 diff --git a/lib/Instances/cpPlugins_ImageFilters.i b/lib/Instances/cpPlugins_ImageFilters.i deleted file mode 100644 index c390172..0000000 --- a/lib/Instances/cpPlugins_ImageFilters.i +++ /dev/null @@ -1,47 +0,0 @@ -** ====================== -** == 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$ diff --git a/lib/Instances/cpPlugins_ImageIterators.i b/lib/Instances/cpPlugins_ImageIterators.i deleted file mode 100644 index 9aaa2ea..0000000 --- a/lib/Instances/cpPlugins_ImageIterators.i +++ /dev/null @@ -1,59 +0,0 @@ -** ====================== -** == 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$ diff --git a/lib/Instances/cpPlugins_ImageNeighborhoodIterators.i b/lib/Instances/cpPlugins_ImageNeighborhoodIterators.i deleted file mode 100644 index 1b7bd35..0000000 --- a/lib/Instances/cpPlugins_ImageNeighborhoodIterators.i +++ /dev/null @@ -1,27 +0,0 @@ -** ====================== -** == 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$ diff --git a/lib/Instances/cpPlugins_Images.i b/lib/Instances/cpPlugins_Images.i deleted file mode 100644 index 140d90c..0000000 --- a/lib/Instances/cpPlugins_Images.i +++ /dev/null @@ -1,43 +0,0 @@ -** ====================== -** == 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$ diff --git a/lib/Instances/cpPlugins_Images_extra.cxx b/lib/Instances/cpPlugins_Images_extra.cxx deleted file mode 100644 index 484078f..0000000 --- a/lib/Instances/cpPlugins_Images_extra.cxx +++ /dev/null @@ -1,19 +0,0 @@ -#define ITK_MANUAL_INSTANTIATION - -#include -#include -#include - -// ------------------------------------------------------------------------- -#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$ diff --git a/lib/Instances/cpPlugins_Meshes.i b/lib/Instances/cpPlugins_Meshes.i deleted file mode 100644 index 2d132fa..0000000 --- a/lib/Instances/cpPlugins_Meshes.i +++ /dev/null @@ -1,34 +0,0 @@ -** ====================== -** == 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$ diff --git a/lib/Instances/cpPlugins_Paths.i b/lib/Instances/cpPlugins_Paths.i deleted file mode 100644 index a74da61..0000000 --- a/lib/Instances/cpPlugins_Paths.i +++ /dev/null @@ -1,34 +0,0 @@ -** ====================== -** == 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$ diff --git a/lib/QCustomPlot/QCustomPlot.h b/lib/QCustomPlot/QCustomPlot.h index 7580968..a0de256 100644 --- a/lib/QCustomPlot/QCustomPlot.h +++ b/lib/QCustomPlot/QCustomPlot.h @@ -88,8 +88,8 @@ class QCPBars; # define QCP_LIB_DECL #endif */ -#include -#define QCP_LIB_DECL cpPlugins_QCustomPlot_EXPORT +#include +#define QCP_LIB_DECL cp_QCustomPlot_EXPORT /*! The QCP Namespace contains general enums and QFlags used throughout the QCustomPlot library diff --git a/lib/cpPlugins/BaseObjects/Demangle.h b/lib/cpPlugins/BaseObjects/Demangle.h deleted file mode 100644 index 87c05f3..0000000 --- a/lib/cpPlugins/BaseObjects/Demangle.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef __cpPlugins__BaseObjects__Demangle__h__ -#define __cpPlugins__BaseObjects__Demangle__h__ - -#include -#include - -#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$ diff --git a/lib/cpPlugins/Config.h.in b/lib/cpPlugins/Config.h.in index a57be19..1540cb0 100644 --- a/lib/cpPlugins/Config.h.in +++ b/lib/cpPlugins/Config.h.in @@ -4,6 +4,7 @@ #define ITK_MANUAL_INSTANTIATION #include <@prj_NAME@_Export.h> #include +#include /* * ========================================================================= diff --git a/lib/cpPlugins/DataObjects/BoundingBox.cxx b/lib/cpPlugins/DataObjects/BoundingBox.cxx index 0a0480c..dfceb29 100644 --- a/lib/cpPlugins/DataObjects/BoundingBox.cxx +++ b/lib/cpPlugins/DataObjects/BoundingBox.cxx @@ -1,6 +1,8 @@ #include #include #include +#include +#include // ------------------------------------------------------------------------- void cpPlugins::DataObjects::BoundingBox:: @@ -82,6 +84,38 @@ Blend( Self* other ) 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( ) @@ -121,4 +155,93 @@ _UpdateVTK( ) 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$ diff --git a/lib/cpPlugins/DataObjects/BoundingBox.h b/lib/cpPlugins/DataObjects/BoundingBox.h index 3d11272..2b5c9c8 100644 --- a/lib/cpPlugins/DataObjects/BoundingBox.h +++ b/lib/cpPlugins/DataObjects/BoundingBox.h @@ -79,7 +79,7 @@ namespace cpPlugins } // ecapseman -#include +// #include #endif // __cpPlugins__DataObjects__BoundingBox__h__ diff --git a/lib/cpPlugins/DataObjects/BoundingBox.hxx b/lib/cpPlugins/DataObjects/BoundingBox.hxx deleted file mode 100644 index e1618d7..0000000 --- a/lib/cpPlugins/DataObjects/BoundingBox.hxx +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef __cpPlugins__DataObjects__BoundingBox__hxx__ -#define __cpPlugins__DataObjects__BoundingBox__hxx__ - -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -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$ diff --git a/lib/cpPlugins/DataObjects/Image.cxx b/lib/cpPlugins/DataObjects/Image.cxx index d7e26d4..60ac5b3 100644 --- a/lib/cpPlugins/DataObjects/Image.cxx +++ b/lib/cpPlugins/DataObjects/Image.cxx @@ -1,14 +1,23 @@ #include -#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include // ------------------------------------------------------------------------- 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; @@ -32,29 +41,46 @@ SetVTK( vtkObjectBase* o ) } // 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( ); } @@ -71,4 +97,81 @@ cpPlugins::DataObjects::Image:: { } +// ------------------------------------------------------------------------- +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$ diff --git a/lib/cpPlugins/DataObjects/Image.d b/lib/cpPlugins/DataObjects/Image.d new file mode 100644 index 0000000..2682d2a --- /dev/null +++ b/lib/cpPlugins/DataObjects/Image.d @@ -0,0 +1,13 @@ +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$ diff --git a/lib/cpPlugins/DataObjects/Image.h b/lib/cpPlugins/DataObjects/Image.h index bfe1d67..3f87b75 100644 --- a/lib/cpPlugins/DataObjects/Image.h +++ b/lib/cpPlugins/DataObjects/Image.h @@ -3,7 +3,6 @@ #include #include -#include namespace cpPlugins { @@ -34,17 +33,17 @@ 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 diff --git a/lib/cpPlugins/DataObjects/Image.hxx b/lib/cpPlugins/DataObjects/Image.hxx deleted file mode 100644 index 3b0bd8e..0000000 --- a/lib/cpPlugins/DataObjects/Image.hxx +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef __cpPlugins__DataObjects__Image__hxx__ -#define __cpPlugins__DataObjects__Image__hxx__ - -#include -#include -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -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$ diff --git a/lib/cpPlugins/DataObjects/Mesh.cxx b/lib/cpPlugins/DataObjects/Mesh.cxx index 94c4087..c40bb02 100644 --- a/lib/cpPlugins/DataObjects/Mesh.cxx +++ b/lib/cpPlugins/DataObjects/Mesh.cxx @@ -5,99 +5,103 @@ 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 + */ } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/DataObjects/Mesh.d b/lib/cpPlugins/DataObjects/Mesh.d new file mode 100644 index 0000000..4713177 --- /dev/null +++ b/lib/cpPlugins/DataObjects/Mesh.d @@ -0,0 +1,3 @@ +Meshes itk::Mesh< #real_types#, #process_dims# > + +** eof - $RCSfile$ diff --git a/lib/cpPlugins/DataObjects/Mesh.hxx b/lib/cpPlugins/DataObjects/Mesh.hxx index 12bcd29..f9cc1bc 100644 --- a/lib/cpPlugins/DataObjects/Mesh.hxx +++ b/lib/cpPlugins/DataObjects/Mesh.hxx @@ -1,7 +1,7 @@ #ifndef __cpPlugins__DataObjects__Mesh__hxx__ #define __cpPlugins__DataObjects__Mesh__hxx__ -#include +// TODO: #include #include #include #include diff --git a/lib/cpPlugins/DataObjects/PolyLineParametricPath.cxx b/lib/cpPlugins/DataObjects/PolyLineParametricPath.cxx index cafafb9..cab593a 100644 --- a/lib/cpPlugins/DataObjects/PolyLineParametricPath.cxx +++ b/lib/cpPlugins/DataObjects/PolyLineParametricPath.cxx @@ -5,26 +5,28 @@ 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 + */ } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/DataObjects/PolyLineParametricPath.h b/lib/cpPlugins/DataObjects/PolyLineParametricPath.h index 1a0147b..a5c0896 100644 --- a/lib/cpPlugins/DataObjects/PolyLineParametricPath.h +++ b/lib/cpPlugins/DataObjects/PolyLineParametricPath.h @@ -2,7 +2,6 @@ #define __cpPlugins__DataObjects__PolyLineParametricPath__h__ #include -#include #include // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/DataObjects/Skeleton.cxx b/lib/cpPlugins/DataObjects/Skeleton.cxx index 52d3f3c..72a141d 100644 --- a/lib/cpPlugins/DataObjects/Skeleton.cxx +++ b/lib/cpPlugins/DataObjects/Skeleton.cxx @@ -5,26 +5,28 @@ 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 + */ } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/DataObjects/Skeleton.h b/lib/cpPlugins/DataObjects/Skeleton.h index 153635c..a924576 100644 --- a/lib/cpPlugins/DataObjects/Skeleton.h +++ b/lib/cpPlugins/DataObjects/Skeleton.h @@ -2,7 +2,6 @@ #define __cpPlugins__DataObjects__Skeleton__h__ #include -#include #include // ------------------------------------------------------------------------- diff --git a/lib/Itk2Vtk/itkImageToVTKImageFilter.h b/lib/cpPlugins/DataObjects/itkImageToVTKImageFilter.h similarity index 100% rename from lib/Itk2Vtk/itkImageToVTKImageFilter.h rename to lib/cpPlugins/DataObjects/itkImageToVTKImageFilter.h diff --git a/lib/Itk2Vtk/itkImageToVTKImageFilter.hxx b/lib/cpPlugins/DataObjects/itkImageToVTKImageFilter.hxx similarity index 100% rename from lib/Itk2Vtk/itkImageToVTKImageFilter.hxx rename to lib/cpPlugins/DataObjects/itkImageToVTKImageFilter.hxx diff --git a/lib/Itk2Vtk/itkVTKImageToImageFilter.h b/lib/cpPlugins/DataObjects/itkVTKImageToImageFilter.h similarity index 100% rename from lib/Itk2Vtk/itkVTKImageToImageFilter.h rename to lib/cpPlugins/DataObjects/itkVTKImageToImageFilter.h diff --git a/lib/Itk2Vtk/itkVTKImageToImageFilter.hxx b/lib/cpPlugins/DataObjects/itkVTKImageToImageFilter.hxx similarity index 100% rename from lib/Itk2Vtk/itkVTKImageToImageFilter.hxx rename to lib/cpPlugins/DataObjects/itkVTKImageToImageFilter.hxx diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 4e194de..ac17cbc 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -4,39 +4,42 @@ 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) diff --git a/plugins/GenericFilters/DataReproducer.cxx b/plugins/GenericFilters/DataReproducer.cxx index ed669bb..11988f2 100644 --- a/plugins/GenericFilters/DataReproducer.cxx +++ b/plugins/GenericFilters/DataReproducer.cxx @@ -1,4 +1,4 @@ -#include +#include #include // ------------------------------------------------------------------------- diff --git a/plugins/GenericFilters/DataReproducer.h b/plugins/GenericFilters/DataReproducer.h index e3b95ee..1c1623d 100644 --- a/plugins/GenericFilters/DataReproducer.h +++ b/plugins/GenericFilters/DataReproducer.h @@ -1,7 +1,7 @@ #ifndef __CPPLUGINSGenericFilters__DATAREPRODUCER__H__ #define __CPPLUGINSGenericFilters__DATAREPRODUCER__H__ -#include +#include #include namespace cpPluginsGenericFilters diff --git a/plugins/GenericFilters/JoinBoundingBoxes.cxx b/plugins/GenericFilters/JoinBoundingBoxes.cxx index ebae5dd..4385072 100644 --- a/plugins/GenericFilters/JoinBoundingBoxes.cxx +++ b/plugins/GenericFilters/JoinBoundingBoxes.cxx @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/plugins/GenericFilters/JoinBoundingBoxes.h b/plugins/GenericFilters/JoinBoundingBoxes.h index baa36a5..6b29a67 100644 --- a/plugins/GenericFilters/JoinBoundingBoxes.h +++ b/plugins/GenericFilters/JoinBoundingBoxes.h @@ -1,7 +1,7 @@ #ifndef __CPPLUGINSGENERICFILTERS__JOINBOUNDINGBOXES__H__ #define __CPPLUGINSGENERICFILTERS__JOINBOUNDINGBOXES__H__ -#include +#include #include namespace cpPluginsGenericFilters diff --git a/plugins/IO/IO.i b/plugins/IO/IO.i new file mode 100644 index 0000000..5470572 --- /dev/null +++ b/plugins/IO/IO.i @@ -0,0 +1,22 @@ +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$ diff --git a/plugins/IO/ImageReader.cxx b/plugins/IO/ImageReader.cxx index 0402e9e..f4639a1 100644 --- a/plugins/IO/ImageReader.cxx +++ b/plugins/IO/ImageReader.cxx @@ -1,15 +1,10 @@ -#include -#include +#include +#include #include #include #include - -#include -#include -#include -#include -#include +#include #ifdef cpPlugins_QT4 @@ -135,16 +130,22 @@ _GenerateData( ) 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 } @@ -161,7 +162,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< unsigned int _Dim > -void cpPluginsIO::ImageReader:: +bool cpPluginsIO::ImageReader:: _GD0( itk::ImageIOBase* io ) { typedef unsigned char uchar; @@ -172,124 +173,111 @@ _GD0( itk::ImageIOBase* io ) 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 ) { @@ -297,28 +285,13 @@ _GD0( itk::ImageIOBase* io ) } 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; @@ -334,10 +307,12 @@ _GD1( itk::ImageIOBase* io ) { f->Update( ); this->GetOutput( "Output" )->SetITK( f->GetOutput( ) ); + return( true ); } catch( itk::ExceptionObject& err ) { this->_Error( err.GetDescription( ) ); + return( false ); } // yrt } @@ -351,10 +326,12 @@ _GD1( itk::ImageIOBase* io ) { f->Update( ); this->GetOutput( "Output" )->SetITK( f->GetOutput( ) ); + return( true ); } catch( itk::ExceptionObject& err ) { this->_Error( err.GetDescription( ) ); + return( false ); } // yrt diff --git a/plugins/IO/ImageReader.h b/plugins/IO/ImageReader.h index 8c6945b..25d59d4 100644 --- a/plugins/IO/ImageReader.h +++ b/plugins/IO/ImageReader.h @@ -1,7 +1,7 @@ #ifndef __CPPLUGINSIO__IMAGEREADER__H__ #define __CPPLUGINSIO__IMAGEREADER__H__ -#include +#include #include namespace itk { class ImageIOBase; } @@ -20,10 +20,10 @@ namespace cpPluginsIO 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 diff --git a/plugins/IO/ImageWriter.cxx b/plugins/IO/ImageWriter.cxx index ac61cb9..d6d8f87 100644 --- a/plugins/IO/ImageWriter.cxx +++ b/plugins/IO/ImageWriter.cxx @@ -1,11 +1,11 @@ -#include -#include +#include +#include #include +#include +#include #include -#include - #ifdef cpPlugins_QT4 #include @@ -118,14 +118,28 @@ void cpPluginsIO::ImageWriter:: _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; diff --git a/plugins/IO/ImageWriter.h b/plugins/IO/ImageWriter.h index f20e05d..364e399 100644 --- a/plugins/IO/ImageWriter.h +++ b/plugins/IO/ImageWriter.h @@ -1,15 +1,10 @@ #ifndef __CPPLUGINSIO__IMAGEWRITER__H__ #define __CPPLUGINSIO__IMAGEWRITER__H__ -#include +#include #include #include -namespace itk -{ - class ImageIOBase; -} - namespace cpPluginsIO { /** @@ -24,7 +19,10 @@ 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 diff --git a/plugins/ImageSources/ImageSources.i b/plugins/ImageSources/ImageSources.i new file mode 100644 index 0000000..3d5426e --- /dev/null +++ b/plugins/ImageSources/ImageSources.i @@ -0,0 +1,7 @@ +header #define ITK_MANUAL_INSTANTIATION + +tinclude itkRandomImageSource:h|hxx + +instances itk::RandomImageSource< itk::Image< #scalar_pixels#, #process_dims# > > + +** eof - $RCSfile$ diff --git a/plugins/ImageSources/RandomImageSource.cxx b/plugins/ImageSources/RandomImageSource.cxx index b0ef6c4..d726fed 100644 --- a/plugins/ImageSources/RandomImageSource.cxx +++ b/plugins/ImageSources/RandomImageSource.cxx @@ -1,8 +1,7 @@ -#include +#include #include #include -#include // ------------------------------------------------------------------------- cpPluginsImageSources::RandomImageSource:: @@ -15,26 +14,44 @@ 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" ); } // ------------------------------------------------------------------------- @@ -47,36 +64,61 @@ cpPluginsImageSources::RandomImageSource:: 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; @@ -103,6 +145,7 @@ _GD1( ) filter->SetSpacing( out_spac ); filter->Update( ); this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); + return( true ); } // eof - $RCSfile$ diff --git a/plugins/ImageSources/RandomImageSource.h b/plugins/ImageSources/RandomImageSource.h index ad9b581..c85998e 100644 --- a/plugins/ImageSources/RandomImageSource.h +++ b/plugins/ImageSources/RandomImageSource.h @@ -1,7 +1,7 @@ #ifndef __cpPluginsImageSources__RandomImageSource__h__ #define __cpPluginsImageSources__RandomImageSource__h__ -#include +#include #include namespace cpPluginsImageSources @@ -19,10 +19,10 @@ 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 diff --git a/plugins/MeshFilters/AppendMeshesFilter.cxx b/plugins/MeshFilters/AppendMeshesFilter.cxx index 291d9e3..0d640e8 100644 --- a/plugins/MeshFilters/AppendMeshesFilter.cxx +++ b/plugins/MeshFilters/AppendMeshesFilter.cxx @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -8,13 +8,15 @@ cpPluginsMeshFilters::AppendMeshesFilter:: 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" ); } // ------------------------------------------------------------------------- diff --git a/plugins/MeshFilters/AppendMeshesFilter.h b/plugins/MeshFilters/AppendMeshesFilter.h index 468a0f0..161e91c 100644 --- a/plugins/MeshFilters/AppendMeshesFilter.h +++ b/plugins/MeshFilters/AppendMeshesFilter.h @@ -1,7 +1,7 @@ #ifndef __CPPLUGINSIMAGEMESH__APPENDMESHESFILTER__H__ #define __CPPLUGINSIMAGEMESH__APPENDMESHESFILTER__H__ -#include +#include #include namespace cpPluginsMeshFilters diff --git a/plugins/MeshSources/CylinderSource.cxx b/plugins/MeshSources/CylinderSource.cxx index 47d7fc6..5a11d78 100644 --- a/plugins/MeshSources/CylinderSource.cxx +++ b/plugins/MeshSources/CylinderSource.cxx @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/plugins/MeshSources/CylinderSource.h b/plugins/MeshSources/CylinderSource.h index 2b19ccd..03d83bd 100644 --- a/plugins/MeshSources/CylinderSource.h +++ b/plugins/MeshSources/CylinderSource.h @@ -1,7 +1,7 @@ #ifndef __CPPLUGINSMESHSOURCES__CYLINDERSOURCE__H__ #define __CPPLUGINSMESHSOURCES__CYLINDERSOURCE__H__ -#include +#include #include namespace cpPluginsMeshSources diff --git a/plugins/MeshSources/SphereSource.cxx b/plugins/MeshSources/SphereSource.cxx index 2da253a..8d52ce3 100644 --- a/plugins/MeshSources/SphereSource.cxx +++ b/plugins/MeshSources/SphereSource.cxx @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/plugins/MeshSources/SphereSource.h b/plugins/MeshSources/SphereSource.h index 4585c89..855b932 100644 --- a/plugins/MeshSources/SphereSource.h +++ b/plugins/MeshSources/SphereSource.h @@ -1,7 +1,7 @@ #ifndef __CPPLUGINSMESHSOURCES__SPHERESOURCE__H__ #define __CPPLUGINSMESHSOURCES__SPHERESOURCE__H__ -#include +#include #include namespace cpPluginsMeshSources diff --git a/plugins/Widgets/LineWidget.cxx b/plugins/Widgets/LineWidget.cxx index 953aa4d..f072a94 100644 --- a/plugins/Widgets/LineWidget.cxx +++ b/plugins/Widgets/LineWidget.cxx @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/plugins/Widgets/LineWidget.h b/plugins/Widgets/LineWidget.h index bd65e84..bd09ae2 100644 --- a/plugins/Widgets/LineWidget.h +++ b/plugins/Widgets/LineWidget.h @@ -1,7 +1,7 @@ #ifndef __cpPluginsWidgets__LineWidget__h__ #define __cpPluginsWidgets__LineWidget__h__ -#include +#include #include #include diff --git a/plugins/Widgets/SeedWidget.cxx b/plugins/Widgets/SeedWidget.cxx index fe19381..ab38f2e 100644 --- a/plugins/Widgets/SeedWidget.cxx +++ b/plugins/Widgets/SeedWidget.cxx @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/plugins/Widgets/SeedWidget.h b/plugins/Widgets/SeedWidget.h index 945ee03..0a0ccb9 100644 --- a/plugins/Widgets/SeedWidget.h +++ b/plugins/Widgets/SeedWidget.h @@ -1,7 +1,7 @@ #ifndef __CPPLUGINSWIDGETS__SEEDWIDGET__H__ #define __CPPLUGINSWIDGETS__SEEDWIDGET__H__ -#include +#include #include // ------------------------------------------------------------------------- diff --git a/plugins/Widgets/SplineWidget.cxx b/plugins/Widgets/SplineWidget.cxx index c89138a..bb68821 100644 --- a/plugins/Widgets/SplineWidget.cxx +++ b/plugins/Widgets/SplineWidget.cxx @@ -1,8 +1,9 @@ -#include +#include #include #include #include -#include + +#include #include #include @@ -94,18 +95,6 @@ _GenerateData( ) 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 ) diff --git a/plugins/Widgets/SplineWidget.h b/plugins/Widgets/SplineWidget.h index d89ccb7..3b17e0c 100644 --- a/plugins/Widgets/SplineWidget.h +++ b/plugins/Widgets/SplineWidget.h @@ -1,7 +1,7 @@ #ifndef __cpPluginsWidgets__SplineWidget__h__ #define __cpPluginsWidgets__SplineWidget__h__ -#include +#include #include #include -- 2.45.0