vtk-dicom  0.8.17
vtkDICOMTag.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 vtkDICOMTag_h
15 #define vtkDICOMTag_h
16 
17 #include "vtkSystemIncludes.h"
18 #include "vtkDICOMModule.h" // For export macro
19 #include "vtkDICOMDictHash.h"
20 
22 class VTKDICOM_EXPORT vtkDICOMTag
23 {
24 public:
26  struct StaticTag
27  {
28  unsigned int Key;
29  };
30 
32  vtkDICOMTag() : Key(0) {}
33 
35  vtkDICOMTag(int group, int element) : Key((group << 16) | element) {}
36 
38  vtkDICOMTag(DC::EnumType tag) : Key(tag) {}
39 
41  vtkDICOMTag(StaticTag tag) : Key(tag.Key) {}
43 
45  unsigned short GetGroup() const {
47  return static_cast<unsigned short>(this->Key >> 16); }
48 
50  unsigned short GetElement() const {
51  return static_cast<unsigned short>(this->Key); }
53 
55  unsigned int GetKey() const {
57  return this->Key; }
58 
60  unsigned int ComputeHash() const {
61  unsigned int h = (this->Key >> 15) + this->Key;
62  return h + (h >> 6) + (h >> 12); }
64 
66  bool operator==(const vtkDICOMTag& b) const {
67  return (this->Key == b.Key); }
68 
69  bool operator!=(const vtkDICOMTag& b) const {
70  return (this->Key != b.Key); }
71 
72  bool operator<=(const vtkDICOMTag& b) const {
73  return (this->Key <= b.Key); }
74 
75  bool operator>=(const vtkDICOMTag& b) const {
76  return (this->Key >= b.Key); }
77 
78  bool operator<(const vtkDICOMTag& b) const {
79  return (this->Key < b.Key); }
80 
81  bool operator>(const vtkDICOMTag& b) const {
82  return (this->Key > b.Key); }
84 
85 private:
86  unsigned int Key;
87 };
88 
89 VTKDICOM_EXPORT ostream& operator<<(ostream& o, const vtkDICOMTag& a);
90 
91 #endif /* vtkDICOMTag_h */
92 // VTK-HeaderTest-Exclude: vtkDICOMTag.h
A (group,element) identifier tag for DICOM attributes.
Definition: vtkDICOMTag.h:23
vtkDICOMTag(int group, int element)
Construct a tag from group, element numbers.
Definition: vtkDICOMTag.h:35
unsigned int ComputeHash() const
Compute a hash value, used for accelerating lookups.
Definition: vtkDICOMTag.h:60
vtkDICOMTag(DC::EnumType tag)
Construct a tag from an identifier from the DICOM dictionary.
Definition: vtkDICOMTag.h:38
vtkDICOMTag(StaticTag tag)
Construct a tag object from a static tag.
Definition: vtkDICOMTag.h:41
unsigned short GetElement() const
Get the 16-bit element identifier.
Definition: vtkDICOMTag.h:50
A struct that provides static storage for a DICOM tag.
Definition: vtkDICOMTag.h:27