From cf717a1b27814f3a8b92e957351d8e0c65463fc8 Mon Sep 17 00:00:00 2001 From: Daniel Gonzalez Date: Wed, 29 May 2013 15:48:34 +0200 Subject: [PATCH] By Leonardo Florez MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Bonjour à tous, Aujourd'hui je me suis plongé dans la compilation des creaTools avec ITK 4.3 et VTK 5.10. La chose marque plutôt pas mal, mais il m'a fallu introduire des changements dans le code. J'ai fait ces ajouts avec du code "différentiel" (en utilisant le preprocesseur de C++ pour détecter la version d'ITK et donc laisser le code utilisable depuis itk 3 ou itk 4). Je vous joins un "patch" avec les changements (je n'ai pas accès git pour faire un "commit" depuis ici...). Pour appliquer le patch, il faut aller au repertoire avec les sources de creatools (là où il y a un repertoire par projet), copier ici le patch ci-joint et executer la commande: "patch -p1 < patch_creatools". L'explication des changements est: - Il faut compiler ITK 4 avec l'option "ITK_USE_CONCEPT_CHECKING" en "OFF". La cause c'est le système de "demangling" des pointeurs vers des objets "itk::Image" utilisé dans bbitk, qui est peu trop générique. J'ai une idée pour le faire marcher d'une façon plus propre, mais il me faudrait quelques jours de plus. - bbtk, bbfy: j'ai rajouté un "tag" xml: verbosePreprocessor. Cela pour permettre au programmeur de jouer avec le preprocesseur (#if et cie.) de C++ et avoir du code "différentiel" (par exemple, pour utiliser des filtres itk 3 qui n'existent plus dans itk 4). - bbtk, BBTKConfigurePackage_src.cmake: la variable d'environnement LD_LIBRARY_PATH était effacée au moment d'invoquer bbfy, donc bbfy ne marchait plus. - bbtk, bbitkDICOMSeriesFileNames.xml: le nouveau "tag" xml est utilisé ici (itkDICOMSeriesFileNames n'existe plus dans itk 3, dans itk 4 s'appelle itkGDCMSeriesFileNames). - crea: CDMUtilities.*: un template n'était pas bien utilisé (une instantiation explicite était nécessaire). - crea: modelCDMProjectsTreeNode.h: une méthode manquait. - creaBruker/testBruker2Dicom: les librairies de BOOST doivent être enchaînées en dernier... Magique! - creaImageIO/TestWxGimmickReaderDialog/CMakeLists.txt: il y manquait l'enchaînement vers les librairies ITK. - creaImageIO/src/creaImageIOWxAnySimpleDlg.cpp: des classes itk 3 qui n'existent plus dans itk 4. Voilà! J'espère que ça peut vous être utile. Amicalement, Leo --- .../TestWxGimmickReaderDialog/CMakeLists.txt | 2 +- ...bbcreaImageIOItkImagesChooserDialogBox.cxx | 97 ++++++++++++++----- src/creaImageIOWxAnySimpleDlg.cpp | 14 ++- 3 files changed, 84 insertions(+), 29 deletions(-) diff --git a/appli/TestWxGimmickReaderDialog/CMakeLists.txt b/appli/TestWxGimmickReaderDialog/CMakeLists.txt index fa7307b..255ab8f 100644 --- a/appli/TestWxGimmickReaderDialog/CMakeLists.txt +++ b/appli/TestWxGimmickReaderDialog/CMakeLists.txt @@ -30,6 +30,6 @@ ELSE(WIN32) ADD_EXECUTABLE(creaImageIOApp MACOSX_BUNDLE main) ENDIF(WIN32) -TARGET_LINK_LIBRARIES( creaImageIOApp creaImageIO ) +TARGET_LINK_LIBRARIES( creaImageIOApp creaImageIO ${ITK_LIBRARIES} ) INSTALL_TARGETS(/bin/ creaImageIOApp ) diff --git a/bbtk/src/bbcreaImageIOItkImagesChooserDialogBox.cxx b/bbtk/src/bbcreaImageIOItkImagesChooserDialogBox.cxx index b3b8552..9c77a1d 100644 --- a/bbtk/src/bbcreaImageIOItkImagesChooserDialogBox.cxx +++ b/bbtk/src/bbcreaImageIOItkImagesChooserDialogBox.cxx @@ -1,28 +1,28 @@ /* - # --------------------------------------------------------------------- - # - # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image - # pour la Santé) - # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton - # Previous Authors : Laurent Guigues, Jean-Pierre Roux - # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil - # - # This software is governed by the CeCILL-B license under French law and - # abiding by the rules of distribution of free software. You can use, - # modify and/ or redistribute the software under the terms of the CeCILL-B - # license as circulated by CEA, CNRS and INRIA at the following URL - # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - # or in the file LICENSE.txt. - # - # As a counterpart to the access to the source code and rights to copy, - # modify and redistribute granted by the license, users are provided only - # with a limited warranty and the software's author, the holder of the - # economic rights, and the successive licensors have only limited - # liability. - # - # The fact that you are presently reading this means that you have had - # knowledge of the CeCILL-B license and that you accept its terms. - # ------------------------------------------------------------------------ + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la Santé) + # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton + # Previous Authors : Laurent Guigues, Jean-Pierre Roux + # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil + # + # This software is governed by the CeCILL-B license under French law and + # abiding by the rules of distribution of free software. You can use, + # modify and/ or redistribute the software under the terms of the CeCILL-B + # license as circulated by CEA, CNRS and INRIA at the following URL + # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + # or in the file LICENSE.txt. + # + # As a counterpart to the access to the source code and rights to copy, + # modify and redistribute granted by the license, users are provided only + # with a limited warranty and the software's author, the holder of the + # economic rights, and the successive licensors have only limited + # liability. + # + # The fact that you are presently reading this means that you have had + # knowledge of the CeCILL-B license and that you accept its terms. + # ------------------------------------------------------------------------ */ //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) @@ -31,6 +31,16 @@ #include "bbcreaImageIOItkImagesChooserDialogBox.h" #include "bbcreaImageIOPackage.h" +// ------------------------------------------------------------------------- +// LFV: avoid itk::Concept check on 4d or superior images +#define BBCREAIMAGEIO_ChooserDlg_Template( t, ty, di ) \ + if( t == typeid( itk::Image< ty, di > ) ) \ + { \ + this->Export< itk::Image< ty, di > >( ); \ + this->ExportVTK< itk::Image< ty, di > >( ); \ + } +// ------------------------------------------------------------------------- + namespace bbcreaImageIO { @@ -46,8 +56,43 @@ void ItkImagesChooserDialogBox::Process() dlg->ShowModal(); bbtk::TypeInfo typ = bbitk::GetITKImagePtrTypeInfoFromPixelTypeInfoAndDimension(*dlg->getTypes().front(), dlg->getDims().front()); - BBTK_TEMPLATE_ITK_IMAGE_SWITCH(typ, Export); - BBTK_TEMPLATE_ITK_IMAGE_SWITCH(typ, ExportVTK); + + BBCREAIMAGEIO_ChooserDlg_Template( typ, char, 1 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, short, 1 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, int, 1 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, long, 1 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, float, 1 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, double, 1 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, unsigned char, 1 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, unsigned short, 1 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, unsigned int, 1 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, unsigned long, 1 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, char, 2 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, short, 2 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, int, 2 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, long, 2 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, float, 2 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, double, 2 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, unsigned char, 2 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, unsigned short, 2 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, unsigned int, 2 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, unsigned long, 2 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, char, 3 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, short, 3 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, int, 3 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, long, 3 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, float, 3 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, double, 3 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, unsigned char, 3 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, unsigned short, 3 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, unsigned int, 3 ) + else BBCREAIMAGEIO_ChooserDlg_Template( typ, unsigned long, 3 ); + + + /* Deprecated + BBTK_TEMPLATE_ITK_IMAGE_SWITCH(typ, Export); + BBTK_TEMPLATE_ITK_IMAGE_SWITCH(typ, ExportVTK); + */ delete dlg; } diff --git a/src/creaImageIOWxAnySimpleDlg.cpp b/src/creaImageIOWxAnySimpleDlg.cpp index 926e118..58b7d95 100644 --- a/src/creaImageIOWxAnySimpleDlg.cpp +++ b/src/creaImageIOWxAnySimpleDlg.cpp @@ -29,13 +29,19 @@ #include "creaImageIOWxAnySimpleDlg.h" #include "creaImageIOWxGimmickReaderDialog.h" -#include + +#if ITK_VERSION_MAJOR < 4 // : WARNING: deprecated in ITK 4.0 +# include +# include +#else // ITK_VERSION_MAJOR < 4 +# include +#endif // ITK_VERSION_MAJOR < 4 + #include #include #include #include #include -#include #include #include #include @@ -513,7 +519,11 @@ namespace creaImageIO { typedef itk::Image TImage; typedef itk::GDCMImageIO GDCMType; +#if ITK_VERSION_MAJOR < 4 typedef itk::DICOMSeriesFileNames dicnames; +#else // ITK_VERSION_MAJOR < 4 + typedef itk::GDCMSeriesFileNames dicnames; +#endif // ITK_VERSION_MAJOR < 4 GDCMType::Pointer gdcmIO = GDCMType::New(); dicnames::Pointer generator = dicnames::New(); -- 2.47.1