File: TestScanner2_2.cxx

package info (click to toggle)
gdcm 3.0.24-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 27,560 kB
  • sloc: cpp: 203,722; ansic: 76,471; xml: 48,131; python: 3,473; cs: 2,308; java: 1,629; lex: 1,290; sh: 334; php: 128; makefile: 97
file content (69 lines) | stat: -rw-r--r-- 1,996 bytes parent folder | download | duplicates (3)
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 "gdcmScanner2.h"
#include "gdcmDirectory.h"
#include "gdcmSystem.h"
#include "gdcmTesting.h"
#include "gdcmTrace.h"

int TestScanner2_2(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::Scanner2 s;
  const gdcm::Tag t2(0x0020,0x000e); // Series Instance UID
  s.AddPublicTag( t2 );
  bool b = s.Scan( d.GetFilenames() );
  if( !b )
    {
    std::cerr << "Scanner2 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.GetAllFilenamesFromPublicTagToValue(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.GetAllFilenamesFromPublicTagToValue(t2, str2);

  if( !fns.empty() ) return 1;

  return 0;
}