From 8626571c00b0f4a35cf396ffad10c500b5c007c1 Mon Sep 17 00:00:00 2001 From: jpr Date: Wed, 30 Mar 2011 14:50:44 +0000 Subject: [PATCH] add a test --- vtk/test4DSplitter.cxx | 132 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 vtk/test4DSplitter.cxx diff --git a/vtk/test4DSplitter.cxx b/vtk/test4DSplitter.cxx new file mode 100644 index 00000000..249c4ce5 --- /dev/null +++ b/vtk/test4DSplitter.cxx @@ -0,0 +1,132 @@ +/*========================================================================= + + Program: gdcm + Module: $RCSfile: test4DSplitter.cxx,v $ + Language: C++ + Date: $Date: 2011/03/30 14:50:44 $ + Version: $Revision: 1.1 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +/* Raisons ne pas utiliser itkImageSeriesReader: + +On Wed, Feb 16, 2011 at 11:51 AM, Roger Bramon Feixas + Hi, + I'm developing with ITK 3.20 + GDCM 2.0.17 + VTK 5.6 and I've noticed + itkImageSeriesReader is ~2x slower than vtkGDCMImageReader (from GDCM2). + I compared both codes and I think the difference is the extra copy which + itkImageSeriesReader makes from ImageFileReader's output to its own output + (ImageSeriesReader::GenerateData() line 393). I've commented it just to test + the time needed without making the copy and now both readers take more or less + the same time. +*/ + +//#include "gdcmDocEntry.h" +//#include "gdcmDicomDir.h" +//#include "gdcmDicomDirPatient.h" +#include "gdcmFile.h" +#include "gdcmFileHelper.h" +//#include "gdcmDirList.h" +//#include "gdcmDebug.h" +//#include "gdcmArgMgr.h" +#include "gdcmUtil.h" +#include "gdcmSerieHelper.h" +#include +#include +#include "vtkGdcmReader.h" + +#include +#include "vtkGdcm4DSplitter.h" + +/** + * \brief + */ + +typedef std::map SortedFiles; + +// Due to a deep C++ trouble in 'SortOnTag', we use 'SortOnUserFunction' +bool myCompareFunction(GDCM_NAME_SPACE::File *file1, GDCM_NAME_SPACE::File *file2) + { + return atof(file1->GetEntryString(0x0018,0x1060).c_str()) < atof(file2->GetEntryString(0x0018,0x1060).c_str()); + } + +int main(int argc, char *argv[]) +{ + + + std::cout << "... inside " << argv[0] << std::endl; + + + +std::string strDirName("/home/jpr/Desktop/Patients_Emilie/Patient.3T/AUB Jos/AUBERTIN JOSEPH/PROSTATE - 305629373/DYN7INJDYN6_901"); + + + // ----- Begin Processing ----- + + unsigned short int grSplit; + unsigned short int elSplit; + + unsigned short int grSort; + unsigned short int elSort; + +// Pour un directory '4D' +// en sortie, chaque vtkImageData contiendra une coupe au cours du temps +// n * 2D+T + +std::vector *output; + + if (1) { + vtkGdcm4DSplitter *spl = new vtkGdcm4DSplitter(); + spl->setDirName(strDirName); + spl->setRecursive(false); + spl->setSplitOnPosition(); + + // Time triger : 0018|1060 + grSort=0x0018; + elSort=0x1060; + + // ==> Big troubles with SortOnTag + //spl->setSortOnTag(grSort, elSort); + //spl->setSortConvertToFloat(true); + + // ==> use SortOnUserFunction ! + spl->setSortOnUserFunction(myCompareFunction); + + std::cout << "Everything set" << std::endl; + bool res=spl->Go(); + + std::cout << "GO() done, status " << res << std::endl; + if(!res) + { + std::cout << "plantage!" << std::endl; + } + + output = spl->GetImageDataVector(); +} + +std::cout << "--------------------------------" << std::endl; +std::cout << "Vector size " << output->size() << std::endl; +std::cout << "--------------------------------" << std::endl; + +std::vector::iterator it; +// Print the first one (why not?) +it=output->begin(); +(*it)->PrintSelf(std::cout, vtkIndent(2)); + + +// Pour un directory '4D' +// en sortie, chaque vtkImageData contiendra un volume au cours du temps. +// 3D + T + +} + + + -- 2.45.0