MeVisLab Toolbox Reference
mlDICOMSetAddTagTools.h
Go to the documentation of this file.
1 // Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2 // **InsertLicense** code
3 //----------------------------------------------------------------------------------
5 
10 //----------------------------------------------------------------------------------
11 #pragma once
12 
13 #include "MLDICOMTagsSystem.h"
14 
15 #include <ThirdPartyWarningsDisable.h>
16 #include <string>
17 #include <ThirdPartyWarningsRestore.h>
18 
19 #include <mlLinearAlgebra.h>
20 
21 // DICOM Tree prototypes.
22 #include <DCMTree_Lib.h>
23 
24 ML_START_NAMESPACE
25 
26 // Forwards
27 class DicomMessageCollector;
28 
29 //----------------------------------------------------------------------------------
31 //----------------------------------------------------------------------------------
32 namespace DICOMTagTools {
33 
43  const DCMTree::TagId &tagId,
44  unsigned int numValues=1,
45  const DCMTree::Vr *vr=nullptr,
46  unsigned int numSQValues=1);
47 
53 MLDICOMTags_EXPORT void setTagValue(DCMTree::TagPtr tag, unsigned int v0, unsigned int v1, unsigned int v2);
54 
60 MLDICOMTags_EXPORT void setTagValue(DCMTree::TagPtr tag, double v0, double v1, double v2);
61 
66 MLDICOMTags_EXPORT void setTagStringValue(DCMTree::TagPtr tag, const std::string &str);
67 
73 
79 
85 
103 MLDICOMTags_EXPORT std::string toDblStrLimited(double val,
104  signed char maxSize);
105 
111 
117  const std::string &str);
118 
127  const std::string &str,
128  bool ,
129  signed char );
130 
143  double v0,
144  double v1,
145  bool doMultValueAdd,
146  signed char maxSize=-1);
147 
157  MLint v0,
158  MLint v1,
159  MLint v2,
160  bool doMultValueAdd);
161 
172  const ImageVector &vec,
173  bool doMultValueAdd);
174 
187  const Vector2 &vec,
188  bool doMultValueAdd,
189  signed char maxSize=-1);
190 
203  const Vector3 &vec,
204  bool doMultValueAdd,
205  signed char maxSize=-1);
206 
219  const Vector6 &vec,
220  bool doMultValueAdd,
221  signed char maxSize=-1);
222 
235  const Matrix4 &mat,
236  bool doMultValueAdd,
237  signed char maxSize=-1);
238 
248 template <typename TAG_VAL_TYPE>
250  const DCMTree::TagId &tagId,
251  const TAG_VAL_TYPE &vec,
252  bool doMultValueAdd,
253  signed char maxSize=-1)
254 {
255  DCMTree::TagPtr retTag;
256  if (dcmTree){
257  retTag = addTagToTree(dcmTree, tagId);
258  setTagStringValue(retTag, vec, doMultValueAdd, maxSize);
259  }
260  return retTag;
261 }
262 
266 template <typename TAG_VAL_TYPE>
268  const DCMTree::TagId &tagId,
269  const TAG_VAL_TYPE &vec)
270 {
271  DCMTree::TagPtr retTag;
272  if (dcmTree){
273  retTag = addTagToTree(dcmTree, tagId);
274  setTagStringValue(retTag, vec);
275  }
276  return retTag;
277 }
278 
287 template <typename TAG_VAL_TYPE>
289  const DCMTree::TagId &tagId,
290  TAG_VAL_TYPE val0,
291  TAG_VAL_TYPE val1,
292  TAG_VAL_TYPE val2)
293 {
294  DCMTree::TagPtr retTag = addTagToTree(dcmTree, tagId);
295  setTagValue(retTag, val0, val1, val2);
296  return retTag;
297 }
298 
315  std::string *errStr,
316  DCMTree::TagId tagId,
317  const std::string &tagStrValue,
318  bool setValue,
319  MLuint32 numVals=1,
320  const DCMTree::Vr *vr=nullptr,
321  bool splitValue=false);
322 
323 
329  Append
330 };
331 
334 
337 
348  std::string *errStr,
349  DCMTree::TagId tagId,
350  const std::string &tagStrValue,
351  const ValueModifyModes modMode,
352  bool splitValue=false);
353 
374  const std::string &privateCreatorString,
375  MLuint16 privateGroupId,
376  MLuint8 privateElementGroupId,
377  MLuint8 privateTagIdLowerByte,
378  const std::string &privateTagValue,
379  DCMTree::Vr privateVR,
380  bool splitValue);
381 
387  MLint numEntries,
388  std::string &errStr);
389 
394  MLint posIdx,
395  std::string &errStr);
396 
397 }
398 
399 ML_END_NAMESPACE
Project global and OS specific declarations.
#define MLDICOMTags_EXPORT
If included by external modules, exported symbols are declared as import symbols.
Class to wrap a tag-id.
Definition: DCMTree_TagId.h:40
unsigned int MLuint32
Definition: mlTypeDefs.h:191
unsigned char MLuint8
Definition: mlTypeDefs.h:115
unsigned short MLuint16
Definition: mlTypeDefs.h:148
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:578
Vr
DICOM VR.
Definition: DCMTree_Lib.h:208
boost::shared_ptr< Tag > TagPtr
shared-pointer to tag
Definition: DCMTree_Lib.h:59
boost::shared_ptr< Tree > TreePtr
shared pointer to a DCMTree::Tree
Definition: DCMTree_Lib.h:70
DCMTree::TagPtr addTagToTree(DCMTree::TreePtr dcmTree, const DCMTree::TagId &tagId, TAG_VAL_TYPE val0, TAG_VAL_TYPE val1, TAG_VAL_TYPE val2)
A template function which adds a new tag with id tagId to dcmTree.
MLDICOMTags_EXPORT void setTagValue(DCMTree::TreePtr dcmTree, std::string *errStr, DCMTree::TagId tagId, const std::string &tagStrValue, const ValueModifyModes modMode, bool splitValue=false)
Sets the value of the tag with id tagId in dcmTree with the new value tagStrValue.
MLDICOMTags_EXPORT const char *const ValueModifyModesStrings[NumValueModifyModes]
String versions for ModificationModes.
MLDICOMTags_EXPORT void appendSequenceEntries(DCMTree::TagPtr tag, MLint numEntries, std::string &errStr)
Append a number of entries to the sequence in tag and initialize it with an empty DCMTree; the number...
MLDICOMTags_EXPORT void setTagStringValue(DCMTree::TagPtr tag, const Matrix4 &mat, bool doMultValueAdd, signed char maxSize=-1)
Set the value of tag as string whose sixteen matrix components are separated by backslashes if doMult...
ValueModifyModes
Ways how to modify a tag with with _modificationStringValue.
@ Prepend
The new value is inserted at begin of the value of the DICOM tag.
@ Append
The new value is appended to the end of the value of the DICOM tag.
@ Replace
The value of the DICOM tag is replaced by a new one.
@ DoNotModify
The value of the DICOM tag is not modified.
MLDICOMTags_EXPORT void setSplitTagStringValue(DCMTree::TagPtr tag, const std::string &str)
If str contains "\\" then it is split at those positions such that multiple values are created.
DCMTree::TagPtr addStringTagToTree(DCMTree::TreePtr dcmTree, const DCMTree::TagId &tagId, const TAG_VAL_TYPE &vec)
Same as addStringTagToTree(DCMTree::TreePtr, DCMTree::TagId, const TAG_VAL_TYPE &,...
MLDICOMTags_EXPORT DCMTree::TagPtr addTag(DCMTree::TreePtr dcmTree, std::string *errStr, DCMTree::TagId tagId, const std::string &tagStrValue, bool setValue, MLuint32 numVals=1, const DCMTree::Vr *vr=nullptr, bool splitValue=false)
Add the tag with ID _tagId to tree dcmTree and value _modificationStringValue; requires a valid non n...
MLDICOMTags_EXPORT std::string setOrAddCreatorAndTag(DCMTree::TreePtr dcmTree, const std::string &privateCreatorString, MLuint16 privateGroupId, MLuint8 privateElementGroupId, MLuint8 privateTagIdLowerByte, const std::string &privateTagValue, DCMTree::Vr privateVR, bool splitValue)
Add and/or replace the private creator and add/replace the private tags in dcmTree.
MLDICOMTags_EXPORT std::string toDblStrLimited(double val, signed char maxSize)
Printing double values can lead to the annoying problem that the fully printed double value does not ...
MLDICOMTags_EXPORT void insertOneSequenceEntry(DCMTree::TagPtr tag, MLint posIdx, std::string &errStr)
Inserts one entry in the sequence in tag at the position given in modificationValue; any error will b...