X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=packages%2Fvtk%2Fsrc%2FbbvtkConcatImages.cxx;h=35f76059abc2985e37c2569c2e20f4e606cce55f;hb=2b1ebe5f1c885888b35d860a8c083e5abdc53678;hp=301614fce13cd8adc25b0ca1725a4c5db1f0e187;hpb=de73736400ac194137c8dce8fdfb423ca1ad9808;p=bbtk.git diff --git a/packages/vtk/src/bbvtkConcatImages.cxx b/packages/vtk/src/bbvtkConcatImages.cxx index 301614f..35f7605 100644 --- a/packages/vtk/src/bbvtkConcatImages.cxx +++ b/packages/vtk/src/bbvtkConcatImages.cxx @@ -1,33 +1,38 @@ -/*========================================================================= +/* + # --------------------------------------------------------------------- + # + # 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. + # ------------------------------------------------------------------------ */ + + +/*========================================================================= Program: bbtk Module: $RCSfile: bbvtkConcatImages.cxx,v $ Language: C++ - Date: $Date: 2010/04/08 14:39:45 $ - Version: $Revision: 1.1 $ + Date: $Date: 2012/11/16 08:51:58 $ + Version: $Revision: 1.3 $ =========================================================================*/ -/* --------------------------------------------------------------------- - -* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) -* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux -* -* 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. -* ------------------------------------------------------------------------ */ - /** * \file * \brief @@ -87,8 +92,14 @@ namespace bbvtk void ConcatImages::Process() { int dim[3]; + int nbComponents; + int scalarType; int nb = (unsigned int)bbGetInputIn().size(); - if (nb == 0) {} // ??? JPR + int consistentNb(nb); + + if (nb == 0) { + // ??? JPR + } bbGetInputIn()[0]->GetDimensions(dim); if (dim[2] > 1 || nb == 1) // dim[2] > 1 : Hopeless for vtk : the first file contains already a 3D object @@ -106,15 +117,29 @@ namespace bbvtk //std::cout << "--------PrintSelf firstImage " << std::endl; // firstImage->PrintSelf(std::cout, vtkIndent(2)); - int nbComponents = firstImage->GetNumberOfScalarComponents(); + nbComponents = firstImage->GetNumberOfScalarComponents(); mConcat->SetNumberOfScalarComponents(nbComponents); - mConcat->SetScalarType(firstImage->GetScalarType( )); - firstImage->GetDimensions(dim); - dim[2]=nb; - mConcat->SetDimensions(dim); - mConcat->SetExtent(0, dim[0]-1, 0, dim[1]-1, 0, dim[2]-1); + + mConcat->SetScalarType(firstImage->GetScalarType( )); + scalarType = firstImage->GetScalarType( ); + mConcat->SetScalarType(scalarType); + mConcat->SetSpacing(firstImage->GetSpacing()); + firstImage->GetDimensions(dim); + // brute way to perform an ultra-mini consistency check : + // First image is supposed to be the reference image, + // any unconsistent image is just discarted... + for(int i=0; iSetDimensions(dim); + mConcat->SetExtent(0, dim[0]-1, 0, dim[1]-1, 0, dim[2]-1); + mConcat->AllocateScalars(); mConcat->Update(); @@ -122,6 +147,8 @@ namespace bbvtk for(index_image=0; index_imageGetScalarType( ) ) + return false; + + if (nbComponents != curImage->GetNumberOfScalarComponents() ) + return false; + + int curDim[3]; + curImage->GetDimensions(curDim); + if ( (curDim[0] =! dim[0]) || (curDim[1] =! dim[1]) ) + return false; + + return true; +} + + }//namespace bbtk #endif // _USE_VTK_