File: TestPrivateTag.cxx

package info (click to toggle)
gdcm 3.0.24-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,856 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 (144 lines) | stat: -rw-r--r-- 3,671 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*=========================================================================

  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 "gdcmPrivateTag.h"
#include "gdcmDataSet.h"

int TestPrivateTag(int , char * [])
{
  gdcm::PrivateTag pt(0x29,0x1018,"SIEMENS CSA HEADER");
  if( pt != gdcm::Tag(0x0029,0x18) )
    {
    std::cerr << pt << std::endl;
    return 1;
    }
  if( pt.GetOwner() != std::string("SIEMENS CSA HEADER") )
    {
    std::cerr << "[" << pt.GetOwner() << "]" << std::endl;
    return 1;
    }
  gdcm::PrivateTag pt2(0x29,0x1018,"SIEMENS CSA HEADER");
  if( pt != pt2 )
    return 1;
  gdcm::PrivateTag pt3(0x29,0x1018,"SIEMENS CXA HEADER");
  if( pt == pt3 )
    return 1;
  if( pt3 < pt )
    return 1;

  const char str[] = "0029,1019,SIEMENS CSA HEADER";

  if( !pt.ReadFromCommaSeparatedString( str ) ) return 1;

  if( pt != gdcm::Tag(0x0029,0x19) )
    {
    std::cerr << pt << std::endl;
    return 1;
    }
  if( pt.GetOwner() != std::string("SIEMENS CSA HEADER") )
    {
    std::cerr << "[" << pt.GetOwner() << "]" << std::endl;
    return 1;
    }

  const char strc[] = "4453,0d,DR Systems, Inc.";
  if( !pt.ReadFromCommaSeparatedString( strc ) ) return 1;

  if( pt != gdcm::Tag(0x4453,0x0d) )
    {
    std::cerr << pt << std::endl;
    return 1;
    }
  if( pt.GetOwner() != std::string("DR Systems, Inc.") )
    {
    std::cerr << "[" << pt.GetOwner() << "]" << std::endl;
    return 1;
    }


  const gdcm::PrivateTag pt1(0x1,0x2,"BLA");
  const char str0[] = "";
  const char str1[] = "1,2,BLA";
  const char str2[] = "1,65536,BLU";
  const char str3[] = "65536,2,BLU";
  const char str4[] = "65536,2";
  const char str5[] = "0028,1019,SIEMENS CSA HEADER";
  const char str6[] = "0029,1019,SIEMENS\\CSA HEADER";
  const char str7[] = "0029,1019,SIEMENS\"CSA HEADER";
  if( pt.ReadFromCommaSeparatedString( nullptr ) )
    {
    return 1;
    }
  if( pt.ReadFromCommaSeparatedString( str0 ) )
    {
    return 1;
    }
  if( !pt.ReadFromCommaSeparatedString( str1 ) )
    {
    return 1;
    }
  if( pt != pt1 )
    {
    return 1;
    }
  if( pt.ReadFromCommaSeparatedString( str2 ) )
    {
    return 1;
    }
  if( pt.ReadFromCommaSeparatedString( str3 ) )
    {
    return 1;
    }
  if( pt.ReadFromCommaSeparatedString( str4 ) )
    {
    return 1;
    }
  if( pt.ReadFromCommaSeparatedString( str5 ) )
    {
    return 1;
    }
  if( pt.ReadFromCommaSeparatedString( str6 ) )
    {
    return 1;
    }
  if( !pt.ReadFromCommaSeparatedString( str7 ) )
    {
    return 1;
    }

  gdcm::PrivateTag null(0x0,0x0,nullptr);
  if( null.GetOwner() == nullptr )
    {
    return 1;
    }

  const gdcm::PrivateTag nospaces(0x12,0x34,"Philips MR Imaging DD 001");
  gdcm::PrivateTag spaces(0x12,0x34," Philips MR Imaging DD 001 ");
  if( nospaces != spaces ) return 1;
  spaces.SetOwner("    Philips MR Imaging DD 001    ");
  if( nospaces != spaces ) return 1;

    {
    // hand-craft Dataset fragment
    gdcm::DataSet ds;
    gdcm::DataElement de(gdcm::Tag(0x0029,0x0011), 0,gdcm::VR::LO);
    ds.Insert(de);
    // get private tag
    gdcm::PrivateTag pt0(0x0029, 0x0023, "Titi");
    if(ds.FindDataElement(pt0))
      return 1;
    auto de0 = ds.GetDataElement(pt0);
    }

  return 0;
}