Medical Imaging Interaction Toolkit  2025.12.02
Medical Imaging Interaction Toolkit
mitkTestDICOMLoading.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 #ifndef mitkTestDICOMLoading_h
13 #define mitkTestDICOMLoading_h
14 
15 #include "mitkDICOMFileReader.h"
16 #include "mitkPropertyKeyPath.h"
17 
18 #include "MitkDICOMTestingExports.h"
19 
20 namespace mitk
21 {
22 
23 class MITKDICOMTESTING_EXPORT TestDICOMLoading
24 {
25  public:
26 
27  typedef std::list<Image::Pointer> ImageList;
28 
30 
31  ImageList
32  LoadFiles( const StringList & files );
33 
36 
39 
44  std::string
45  DumpImageInformation( const Image* image );
46 
52  bool
53  CompareImageInformationDumps( const std::string& reference,
54  const std::string& test );
55 
56  private:
57 
58  typedef std::map<std::string,std::string> KeyValueMap;
59 
60  DICOMFileReader::Pointer
61  BuildDICOMReader();
62 
63  void SetDefaultLocale();
64 
65  void ResetUserLocale();
66 
67  std::string ComponentTypeToString( itk::IOComponentEnum type );
68 
69  KeyValueMap ParseDump( const std::string& dump );
70 
71  bool CompareSpacedValueFields( const std::string& reference,
72  const std::string& test,
73  double eps = mitk::eps );
74 
75  bool CompareJSON( const std::string& reference,
76  const std::string& test );
77 
84  std::string reduce(const std::string& pString,
85  const std::string& pFill = " ",
86  const std::string& pWhitespace = " \t");
87 
93  std::string trim(const std::string& pString,
94  const std::string& pWhitespace = " \t");
95 
96  template<typename T>
97  bool StringToNumber(const std::string& s, T& value)
98  {
99  std::stringstream stream(s);
100  stream >> value;
101  return (!stream.fail()) && (std::abs(value) <= std::numeric_limits<T>::max());
102  }
103 
104  static void AddPropertyToDump(const mitk::PropertyKeyPath& key, const mitk::Image* image, std::stringstream& result);
105 
106  const char* m_PreviousCLocale;
107  std::locale m_PreviousCppLocale;
108 
109 };
110 
111 }
112 
113 #endif
Image class for storing images.
Definition: mitkImage.h:70
Class that can be used to specify nested or wild carded property keys. E.g. for the use in context of...
std::string DumpImageInformation(const Image *image)
Dump relevant image information for later comparison.
bool CompareImageInformationDumps(const std::string &reference, const std::string &test)
Compare two image information dumps.
Image::Pointer DecorateVerifyCachedImage(const StringList &files, mitk::Image::Pointer cachedImage)
Image::Pointer DecorateVerifyCachedImage(const StringList &files, DICOMTagCache *, mitk::Image::Pointer cachedImage)
ImageList LoadFiles(const StringList &files)
std::list< Image::Pointer > ImageList
Find image slices visible on a given plane.
MITKCORE_EXPORT const ScalarType eps
std::vector< std::string > StringList