Medical Imaging Interaction Toolkit  2018.4.99-eed36131
Medical Imaging Interaction Toolkit
mitkDICOMProperty.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkDICOMProperty_h
14 #define mitkDICOMProperty_h
15 
18 #include "mitkDICOMTagPath.h"
19 
20 #include "MitkDICOMExports.h"
21 
22 namespace mitk
23 {
24 
26 
29 
30 
31  class PropertyList;
32  class BaseData;
33 
36  MITKDICOM_EXPORT std::map< std::string, BaseProperty::Pointer> GetPropertyByDICOMTagPath(const PropertyList* list, const DICOMTagPath& path);
39  MITKDICOM_EXPORT std::map< std::string, BaseProperty::Pointer> GetPropertyByDICOMTagPath(const BaseData* data, const DICOMTagPath& path);
40 
48  template<typename TNumericReturnType>
49  TNumericReturnType ConvertDICOMStrToValue(const std::string& dcmValueString)
50  {
51  std::istringstream iss(dcmValueString);
52  iss.imbue(std::locale("C"));
53  TNumericReturnType d;
54  if (!(iss >> d) || !(iss.eof()))
55  {
56  mitkThrow() << "Cannot convert string to value type. Type: " << typeid(TNumericReturnType).name() << "; String: " << dcmValueString;
57  }
58 
59  return d;
60  };
61 
66  template<typename TNumericType>
67  std::string ConvertValueToDICOMStr(const TNumericType value)
68  {
69  std::ostringstream oss;
70  oss.imbue(std::locale("C"));
71  if (!(oss << value))
72  {
73  mitkThrow() << "Cannot convert value type to dicom string. Type: " << typeid(TNumericType).name() << "; value: " << value;
74  }
75 
76  return oss.str();
77  };
78 
79 
80 }
81 
82 #endif
Class is used to identify (nested) attributes in a DICOM dataset. In contrast to the class DICOMTag...
Base of all data objects.
Definition: mitkBaseData.h:42
DataCollection - Class to facilitate loading/accessing structured data.
Key-value list holding instances of BaseProperty.
MITKDICOM_EXPORT mitk::BaseProperty::Pointer GetDICOMPropertyForDICOMValuesFunctor(const DICOMCachedValueLookupTable &cacheLookupTable)
#define mitkThrow()
TemporoSpatialStringProperty DICOMProperty
#define MITKDICOM_EXPORT
std::string ConvertValueToDICOMStr(const TNumericType value)
TNumericReturnType ConvertDICOMStrToValue(const std::string &dcmValueString)
MITKDICOM_EXPORT std::map< std::string, BaseProperty::Pointer > GetPropertyByDICOMTagPath(const PropertyList *list, const DICOMTagPath &path)
Property for time and space resolved string values.