From 6656de0300157ef642706aa185a45b3a87b04751 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Tue, 29 Oct 2013 14:27:00 +0100 Subject: [PATCH] 2163 2163 BBTK DAVILA Eduardo Bug New High vtk package concatImage box not support 3D input images --- packages/vtk/src/bbvtkConcatImages.cxx | 92 ++++++++++++++++++-------- 1 file changed, 65 insertions(+), 27 deletions(-) diff --git a/packages/vtk/src/bbvtkConcatImages.cxx b/packages/vtk/src/bbvtkConcatImages.cxx index 35f7605..04d3e8f 100644 --- a/packages/vtk/src/bbvtkConcatImages.cxx +++ b/packages/vtk/src/bbvtkConcatImages.cxx @@ -92,25 +92,25 @@ namespace bbvtk void ConcatImages::Process() { int dim[3]; + int curDim[3]; int nbComponents; int scalarType; int nb = (unsigned int)bbGetInputIn().size(); - int consistentNb(nb); +// int consistentNb(nb); + int newSizeZ; 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 + if ( nb == 1) // dim[2] > 1 : Hopeless for vtk : the first file contains already a 3D object // nb == 1 : only one image, nothing to do. { mConcat->Delete(); mConcat = bbGetInputIn()[0]; //mConcat->PrintSelf(std::cout, vtkIndent(2)); - } - else - { + } else { // We suppose *all* the images within the directory are consistent (same sizeS, same pixel Type?...) vtkImageData * firstImage = bbGetInputIn()[0]; @@ -126,41 +126,73 @@ namespace bbvtk mConcat->SetSpacing(firstImage->GetSpacing()); - firstImage->GetDimensions(dim); + firstImage->GetDimensions(dim); + newSizeZ=0; // 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; iGetDimensions(curDim); + newSizeZ = newSizeZ + curDim[2]; + } // if + + } // for + + dim[2]=newSizeZ; + + mConcat->SetDimensions(dim); mConcat->SetExtent(0, dim[0]-1, 0, dim[1]-1, 0, dim[2]-1); mConcat->AllocateScalars(); mConcat->Update(); - int index_image, index_lignes, index_colonnes, index_components; - + int index_image; + + int blocksize; + int scalarSize=bbGetInputIn()[0]->GetScalarSize(); + void *pImage = mConcat->GetScalarPointer(); + void *sourcePointer; + +//EED int index_lignes, index_colonnes, index_components; + + for(index_image=0; index_imageSetScalarComponentFromDouble(index_lignes, index_colonnes, index_image, index_components,(bbGetInputIn()[index_image])->GetScalarComponentAsDouble(index_colonnes,index_lignes,0,index_components)); - } - } - } - } - } + { + continue; // discard unconsistent image ! + } + bbGetInputIn()[index_image]->GetDimensions(curDim); + blocksize = curDim[0]*curDim[1]*curDim[2]*nbComponents*scalarSize; + sourcePointer = bbGetInputIn()[index_image]->GetScalarPointer(); + memcpy(pImage, sourcePointer,blocksize); + pImage = pImage+blocksize; + +//EED 2013 oct 29 +//EED for(index_lignes=0; index_lignesSetScalarComponentFromDouble(index_lignes, index_colonnes, index_image, index_components,(bbGetInputIn()[index_image])->GetScalarComponentAsDouble(index_colonnes,index_lignes,0,index_components)); +//EED } // components +//EED } // colonnes +//EED } // lignes + + + } // if CheckConsistency + } /// for index_image + // Devrait etre dans bbUserFinalizeProcessing() ? On n'y entre jamais // JPR bbSetOutputOut(mConcat); } @@ -170,15 +202,21 @@ bool ConcatImages::CheckConsistency( vtkImageData *curImage, int dim[], int nbCo assert (curImage); if (scalarType != curImage->GetScalarType( ) ) + { 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; } -- 2.47.1