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