1 /*========================================================================= 2 3 Program: GDCM (Grassroots DICOM). A DICOM library 4 5 Copyright (c) 2006-2011 Mathieu Malaterre 6 All rights reserved. 7 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details. 8 9 This software is distributed WITHOUT ANY WARRANTY; without even 10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 11 PURPOSE. See the above copyright notice for more information. 12 13 =========================================================================*/ 14 #include "gdcmStrictScanner.h" 15 #include "gdcmDirectory.h" 16 #include "gdcmSystem.h" 17 #include "gdcmTesting.h" 18 #include "gdcmTrace.h" 19 TestStrictScanner2(int argc,char * argv[])20int TestStrictScanner2(int argc, char *argv[]) 21 { 22 gdcm::Trace::WarningOff(); 23 gdcm::Trace::ErrorOff(); 24 const char *directory = gdcm::Testing::GetDataRoot(); 25 std::string tmpdir = gdcm::Testing::GetTempDirectory( "TestWriter" ); 26 directory = tmpdir.c_str(); 27 if( argc == 2 ) 28 { 29 directory = argv[1]; 30 } 31 32 if( !gdcm::System::FileIsDirectory(directory) ) 33 { 34 std::cerr << "No such directory: " << directory << std::endl; 35 return 1; 36 } 37 38 gdcm::Directory d; 39 unsigned int nfiles = d.Load( directory ); // no recursion 40 std::cout << "done retrieving file list. " << nfiles << " files found." << std::endl; 41 42 gdcm::StrictScanner s; 43 const gdcm::Tag t2(0x0020,0x000e); // Series Instance UID 44 s.AddTag( t2 ); 45 bool b = s.Scan( d.GetFilenames() ); 46 if( !b ) 47 { 48 std::cerr << "Scanner failed" << std::endl; 49 return 1; 50 } 51 52 gdcm::Directory::FilenamesType const & files = s.GetFilenames(); 53 if( files != d.GetFilenames() ) 54 { 55 return 1; 56 } 57 58 const char str1[] = "1.3.12.2.1107.5.2.4.7630.20010301125744000008"; 59 gdcm::Directory::FilenamesType fns = s.GetAllFilenamesFromTagToValue(t2, str1); 60 61 // all SIEMENS_MAGNETOM-12-MONO2-FileSeq*.dcm: 62 if( fns.size() != 4 ) return 1; 63 64 const char str2[] = "1.3.12.2.1107.5.2.4.7630.2001030112574400000"; 65 fns = s.GetAllFilenamesFromTagToValue(t2, str2); 66 67 if( !fns.empty() ) return 1; 68 69 return 0; 70 } 71