14 #ifndef vtkDICOMValue_h
15 #define vtkDICOMValue_h
17 #include "vtkSystemIncludes.h"
18 #include "vtkDICOMModule.h"
19 #include "vtkDICOMVR.h"
20 #include "vtkDICOMTag.h"
21 #include "vtkDICOMCharacterSet.h"
22 #include "vtkDICOMReferenceCount.h"
27 #define VTK_DICOM_TAG 13
28 #define VTK_DICOM_ITEM 14
29 #define VTK_DICOM_VALUE 15
35 #if defined(__x86_64__) || defined(__ia64__) || defined(_M_X64)
36 #define VTK_DICOM_USE_OVERFLOW_BYTE
58 unsigned char CharacterSet;
59 unsigned char Overflow;
62 unsigned int NumberOfValues;
64 Value() : ReferenceCount(1) {}
74 static bool Compare(
const Value *a,
const Value *b);
75 static bool CompareEach(
const Value *a,
const Value *b);
120 const std::string& v);
122 const char *data,
size_t l);
131 if (this->V) { ++(this->V->ReferenceCount); } }
167 if (this->V && --(this->V->ReferenceCount) == 0) {
168 this->FreeValue(this->V); }
172 bool IsValid()
const {
return (this->V !=
nullptr); }
180 unsigned int GetVL()
const {
return (this->V ? this->V->VL : 0); }
191 return (this->V ? this->V->CharacterSet : 0); }
208 return (this->V ? this->V->NumberOfValues
209 #ifdef VTK_DICOM_USE_OVERFLOW_BYTE
210 + (
static_cast<size_t>(this->V->Overflow) << 32)
223 void GetValues(std::string *vb,
size_t n,
size_t i=0)
const;
224 void GetValues(
unsigned char *vb,
size_t n,
size_t i=0)
const;
225 void GetValues(
short *vb,
size_t n,
size_t i=0)
const;
226 void GetValues(
unsigned short *vb,
size_t n,
size_t i=0)
const;
227 void GetValues(
int *vb,
size_t n,
size_t i=0)
const;
228 void GetValues(
unsigned int *vb,
size_t n,
size_t i=0)
const;
229 void GetValues(
long long *vb,
size_t n,
size_t i=0)
const;
230 void GetValues(
unsigned long long *vb,
size_t n,
size_t i=0)
const;
231 void GetValues(
float *vb,
size_t n,
size_t i=0)
const;
232 void GetValues(
double *vb,
size_t n,
size_t i=0)
const;
233 void GetValues(
vtkDICOMTag *vb,
size_t n,
size_t i=0)
const;
246 std::string GetString(
size_t i)
const;
247 unsigned char GetUnsignedChar(
size_t i)
const;
248 short GetShort(
size_t i)
const;
249 unsigned short GetUnsignedShort(
size_t i)
const;
250 int GetInt(
size_t i)
const;
251 unsigned int GetUnsignedInt(
size_t i)
const;
252 long long GetInt64(
size_t i)
const;
253 unsigned long long GetUnsignedInt64(
size_t i)
const;
254 float GetFloat(
size_t i)
const;
255 double GetDouble(
size_t i)
const;
270 std::string AsString()
const;
271 unsigned char AsUnsignedChar()
const;
272 short AsShort()
const;
273 unsigned short AsUnsignedShort()
const;
275 unsigned int AsUnsignedInt()
const;
276 long long AsInt64()
const;
277 unsigned long long AsUnsignedInt64()
const;
278 float AsFloat()
const;
279 double AsDouble()
const;
300 const unsigned char *GetUnsignedCharData()
const;
301 const short *GetShortData()
const;
302 const unsigned short *GetUnsignedShortData()
const;
303 const int *GetIntData()
const;
304 const unsigned int *GetUnsignedIntData()
const;
305 const long long *GetInt64Data()
const;
306 const unsigned long long *GetUnsignedInt64Data()
const;
307 const float *GetFloatData()
const;
308 const double *GetDoubleData()
const;
324 char *AllocateCharData(
326 unsigned char *AllocateUnsignedCharData(
vtkDICOMVR vr,
size_t vn);
327 short *AllocateShortData(
vtkDICOMVR vr,
size_t vn);
328 unsigned short *AllocateUnsignedShortData(
vtkDICOMVR vr,
size_t vn);
329 int *AllocateIntData(
vtkDICOMVR vr,
size_t vn);
330 unsigned int *AllocateUnsignedIntData(
vtkDICOMVR vr,
size_t vn);
331 long long *AllocateInt64Data(
vtkDICOMVR vr,
size_t vn);
332 unsigned long long *AllocateUnsignedInt64Data(
vtkDICOMVR vr,
size_t vn);
333 float *AllocateFloatData(
vtkDICOMVR vr,
size_t vn);
334 double *AllocateDoubleData(
vtkDICOMVR vr,
size_t vn);
423 if (this->V != o.V) {
424 if (o.V) { ++(o.V->ReferenceCount); }
426 if (--(this->V->ReferenceCount) == 0) { this->FreeValue(this->V); } }
437 bool operator!=(
const vtkDICOMValue& o)
const {
return !(*
this == o); }
446 static void FreeValue(Value *v);
450 void GetValuesT(OT *v,
size_t count,
size_t s)
const;
454 void CreateValue(
vtkDICOMVR vr,
const T *data,
size_t count);
462 void AppendValue(
const T &item);
466 void SetValue(
size_t i,
const T &item);
472 void Substring(
size_t i,
const char *&start,
const char *&end)
const;
475 void CreateValueWithSpecificCharacterSet(
486 size_t CreateValueFromUTF8(
490 static bool PatternMatches(
491 const char *pattern,
const char *pe,
const char *val,
const char *ve);
494 static bool PatternMatchesMulti(
495 const char *pattern,
const char *val,
vtkDICOMVR vr);
503 static size_t NormalizeDateTime(
504 const char *input,
char output[22],
vtkDICOMVR vr);
513 static bool PatternMatchesPersonName(
const char *pattern,
const char *val);
522 static void NormalizePersonName(
523 const char *input,
char output[256],
bool isquery=
false);
535 friend class vtkDICOMValueFriendMetaData;
541 class vtkDICOMValueFriendMetaData
544 return v->GetMultiplex(); }
550 VTKDICOM_EXPORT ostream& operator<<(ostream& os,
const vtkDICOMValue& v);
Character sets.
Definition: vtkDICOMCharacterSet.h:55
An item in a DICOM sequence (type SQ).
Definition: vtkDICOMItem.h:34
An object for holding an atomic reference count.
Definition: vtkDICOMReferenceCount.h:27
A sequence of items according to the SQ representation.
Definition: vtkDICOMSequence.h:32
A (group,element) identifier tag for DICOM attributes.
Definition: vtkDICOMTag.h:23
VRs (Value Representations)
Definition: vtkDICOMVR.h:22
A class to store attribute values for DICOM metadata.
Definition: vtkDICOMValue.h:51
bool IsValid() const
Check whether this value is valid, i.e. contains data.
Definition: vtkDICOMValue.h:172
size_t GetNumberOfValues() const
Get the value multiplicity.
Definition: vtkDICOMValue.h:207
vtkDICOMValue(vtkDICOMVR vr, vtkDICOMCharacterSet cs, const std::string &v)
Construct a string value with a specific character set.
std::string GetUTF8String(size_t i) const
Get one scalar, string, tag or item from the value.
vtkDICOMValue(const vtkDICOMSequence &v)
Construct from a sequence.
char * AllocateCharData(vtkDICOMVR vr, size_t vn)
Allocate space within a value object.
static vtkDICOMValue FromUTF8String(vtkDICOMVR vr, vtkDICOMCharacterSet cs, const std::string &v)
Create a value from a UTF8-encoded string.
bool Matches(double v) const
Check if the value is the specified numeric value.
void ComputeNumberOfValuesForCharData()
Compute the number of backslash-separated string values.
vtkDICOMValue(vtkDICOMTag v)
Construct from a tag.
void AppendValueToSafeUTF8String(std::string &str, size_t i) const
Append value "i" to the supplied UTF8 string for safe printing.
const char * GetCharData() const
Get a pointer to the internal data array.
void AppendValueToString(std::string &str, size_t i) const
Append value "i" to the supplied string.
vtkDICOMValue & operator=(const vtkDICOMSequence &o)
Assign a value from a sequence object.
vtkDICOMValue(const vtkDICOMValue &v)
Copy constructor.
Definition: vtkDICOMValue.h:130
vtkDICOMValue(const vtkDICOMItem &v)
Construct from an item.
vtkDICOMCharacterSet GetCharacterSet() const
Get the character set for a text value.
Definition: vtkDICOMValue.h:190
void GetValues(std::string *vb, size_t n, size_t i=0) const
Copy "n" values into vb, starting at value "i".
vtkDICOMValue(vtkDICOMVR vr, double v)
Construct a new value from the data that is provided.
bool Matches(const std::string &v) const
Check if the value is equal to the specified string.
void AppendValueToUTF8String(std::string &str, size_t i) const
Append value "i" to the supplied UTF8 string.
std::string AsUTF8String() const
Get the value as a scalar, string, tag, or item.
unsigned char * ReallocateUnsignedCharData(size_t vn)
Reallocate data of type OB or UN.
unsigned int GetVL() const
Get the VL, the length of the data in bytes (will always be even).
Definition: vtkDICOMValue.h:180
~vtkDICOMValue()
Destructor releases the internal data array.
Definition: vtkDICOMValue.h:148
bool Matches(const vtkDICOMValue &value) const
Check if the value matches the specified find query value.