X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestAllVM.cxx;h=8c28b66125e1994500524979aca1e165f4aa6302;hb=f540ed5835e7b89478e6048a577d494c0e156f2a;hp=e50656fcc5916774ba7091969a39b015aa075690;hpb=a6a06d52cee2703647f43af1b0a61aa68ee7106a;p=gdcm.git diff --git a/Testing/TestAllVM.cxx b/Testing/TestAllVM.cxx index e50656fc..8c28b661 100644 --- a/Testing/TestAllVM.cxx +++ b/Testing/TestAllVM.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestAllVM.cxx,v $ Language: C++ - Date: $Date: 2005/10/21 15:01:28 $ - Version: $Revision: 1.3 $ + Date: $Date: 2006/03/25 17:02:11 $ + Version: $Revision: 1.12 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -22,47 +22,80 @@ //Generated file: #include "gdcmDataImages.h" -int TestAllVM(int, char *[]) +int DoTheVMTest(std::string const &filename) +{ + gdcm::File *file = gdcm::File::New(); + // - Do not test unknow VM in shadow groups (if element 0x0000 is present) + // - Skip Sequences (if they are 'True Length'); loading will be quicker + // (anyway, Sequences are skipped at processing time ...) + file->SetLoadMode( gdcm::LD_NOSHADOW | gdcm::LD_NOSEQ ); + + file->SetFileName( filename ); + if( !file->Load() ) //would be really bad... + return 1; + + gdcm::DocEntry *d = file->GetFirstEntry(); + std::cerr << "Testing file : " << filename << std::endl; + while(d) + { + if ( gdcm::DataEntry *de = dynamic_cast(d) ) + { + if ( !(de->GetGroup() % 2) ) // Don't check shadow elements. Righ now, + // Private Dictionnary are not dealt with + { + // We know OB and OW VM is always 1, whatever the actual + // found value is. + + if (de->GetVR() != "OB" && de->GetVR() != "OW" ) + if( !de->IsValueCountValid() ) + { + std::cerr << "Element: " << de->GetKey() << + " (" << de->GetName() << ") " << + "Contains a wrong VM: " << de->GetValueCount() + << " should be: " << de->GetVM() << std::endl;; + } + } + } + else + { + // We skip pb of SQ recursive exploration + } + d = file->GetNextEntry(); + } + file->Delete(); + + return 0; +} + +int TestAllVM(int argc, char *argv[]) { int i = 0; + if( argc >= 2 ) + { + const char *filename = argv[1]; + if( DoTheVMTest( filename ) ) + return 1; + return 0; + } + // else while( gdcmDataImages[i] != 0 ) { std::string filename = GDCM_DATA_ROOT; filename += "/"; filename += gdcmDataImages[i]; + + if (!strcmp(gdcmDataImages[i],"00191113.dcm")) // Track bug on Darwin + gdcm::Debug::DebugOn(); + else + gdcm::Debug::DebugOff(); - gdcm::File file; - file.SetLoadMode( gdcm::LD_NOSHADOW ); - file.SetFileName( filename ); - if( !file.Load() ) //would be really bad... + if( DoTheVMTest( filename ) ) return 1; - - gdcm::DocEntry *d = file.GetFirstEntry(); - std::cerr << "Testing file : " << filename << std::endl; - while(d) - { - if ( gdcm::DataEntry *de = dynamic_cast(d) ) - { - if( !de->IsValueCountValid() ) - { - std::cerr << "Element: " << de->GetKey() << - " (" << de->GetName() << ") " << - "Contains a wrong VM: " << de->GetValueCount() - << " should be: " << de->GetVM() << std::endl;; - } - } - else - { - // We skip pb of SQ recursive exploration - } - - d = file.GetNextEntry(); - std::cerr << std::endl; // skip a line after each file - } - i++; + std::cerr << std::endl; // skip a line after each file } + return 0; }