vtk-dicom  0.8.17
vtkDICOMVR.h
1 /*=========================================================================
2 
3  Program: DICOM for VTK
4 
5  Copyright (c) 2012-2024 David Gobbi
6  All rights reserved.
7  See Copyright.txt or http://dgobbi.github.io/bsd3.txt 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 #ifndef vtkDICOMVR_h
15 #define vtkDICOMVR_h
16 
17 #include "vtkSystemIncludes.h"
18 #include "vtkDICOMModule.h" // For export macro
19 
21 class VTKDICOM_EXPORT vtkDICOMVR
22 {
23 public:
25 
28  enum EnumType
29  {
30  XX = 0x00,
31  AE = 0x01,
32  AS = 0x02,
33  AT = 0x03,
34  CS = 0x04,
35  DA = 0x05,
36  DS = 0x06,
37  DT = 0x07,
38  FD = 0x08,
39  FL = 0x09,
40  IS = 0x0a,
41  LO = 0x0b,
42  LT = 0x0c,
43  OB = 0x0d,
44  OD = 0x0e,
45  OF = 0x0f,
46  OL = 0x10,
47  OW = 0x11,
48  PN = 0x12,
49  SH = 0x13,
50  SL = 0x14,
51  SQ = 0x15,
52  SS = 0x16,
53  ST = 0x17,
54  TM = 0x18,
55  UC = 0x19,
56  UI = 0x1a,
57  UL = 0x1b,
58  UN = 0x1c,
59  UR = 0x1d,
60  US = 0x1e,
61  UT = 0x1f,
62  OX = 0x20,
63  XS = 0x21,
64  OV = 0x22,
65  SV = 0x23,
66  UV = 0x24,
67  };
68 
70  vtkDICOMVR() : Key(0) {}
72 
74  vtkDICOMVR(EnumType vr) : Key(static_cast<unsigned char>(vr)) {}
75 
77  vtkDICOMVR(const char *vr) : Key(VRTable[static_cast<unsigned char>(vr[0])]
78  [static_cast<unsigned char>(vr[1])]) {}
79 
81  vtkDICOMVR(const unsigned char vr[2]) : Key(VRTable[vr[0]][vr[1]]) {}
83 
85  bool IsValid() const { return (this->Key != 0); }
87 
89  int GetType() const { return TypeTable[this->Key]; }
90 
92  const char *GetText() const { return TextTable[this->Key]; }
94 
96  bool HasLongVL() const {
98  return (((1ull << this->Key) & 0x1cb223e001ull) != 0); }
99 
101  bool HasSpecificCharacterSet() const {
102  return (((1ull << this->Key) & 0x828c1800ull) != 0); }
103 
105  bool HasTextValue() const {
106  return (((1ull << this->Key) & 0xa78c1cf6ull) != 0); }
107 
109 
113  bool HasNumericValue() const {
114  return (((1ull << this->Key) & 0x1848500740ull) != 0); }
115 
117 
122  bool HasSingleValue() const {
123  return (((1ull << this->Key) & 0x80801000ull) != 0); }
125 
127  bool operator==(vtkDICOMVR a) const { return (this->Key == a.Key); }
128  bool operator!=(vtkDICOMVR a) const { return (this->Key != a.Key); }
129  bool operator<=(vtkDICOMVR a) const { return (this->Key <= a.Key); }
130  bool operator>=(vtkDICOMVR a) const { return (this->Key >= a.Key); }
131  bool operator<(vtkDICOMVR a) const { return (this->Key < a.Key); }
132  bool operator>(vtkDICOMVR a) const { return (this->Key > a.Key); }
134 
135 private:
136  unsigned char Key;
137 
138  static const unsigned char *VRTable[256];
139  static const unsigned char TypeTable[37];
140  static const char TextTable[37][4];
141 };
142 
143 VTKDICOM_EXPORT ostream& operator<<(ostream& o, const vtkDICOMVR& a);
144 
145 #endif /* vtkDICOMVR_h */
146 // VTK-HeaderTest-Exclude: vtkDICOMVR.h
VRs (Value Representations)
Definition: vtkDICOMVR.h:22
vtkDICOMVR(EnumType vr)
Construct a VR from a VR enum constant.
Definition: vtkDICOMVR.h:74
bool HasSingleValue() const
The VRs ST, LT, and UT carry only one value.
Definition: vtkDICOMVR.h:122
EnumType
The VR enum constants.
Definition: vtkDICOMVR.h:29
vtkDICOMVR(const unsigned char vr[2])
Attempt to construct a VR from a two unsigned bytes.
Definition: vtkDICOMVR.h:81
bool HasSpecificCharacterSet() const
The VRs SH, LO, PN, ST, LT, UC, and UT use SpecificCharacterSet.
Definition: vtkDICOMVR.h:101
int GetType() const
Get the data type for this VR.
Definition: vtkDICOMVR.h:89
const char * GetText() const
Get the two-character text for this VR.
Definition: vtkDICOMVR.h:92
bool HasNumericValue() const
This is true for for all VRs that store numbers.
Definition: vtkDICOMVR.h:113
vtkDICOMVR(const char *vr)
Attempt to construct a VR from a two-byte string.
Definition: vtkDICOMVR.h:77
bool HasTextValue() const
This is true for all VRs whose value is stored as text.
Definition: vtkDICOMVR.h:105