MeVisLab Toolbox Reference
mlZTUFileNameSet.h
Go to the documentation of this file.
1 // Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2 // **InsertLicense** code
3 //----------------------------------------------------------------------------------
6 
11 //----------------------------------------------------------------------------------
12 
13 #pragma once
14 
15 #include "MLMLToDicomToolsSystem.h"
17 #include <mlDICOMCachedIOProxies.h>
18 #include <mlZTUIndex.h>
19 #include <mlTypeDefs.h>
20 #include <DCMTree_Tree.h>
21 
22 #include <ThirdPartyWarningsDisable.h>
23 #include <map>
24 #include <string>
25 #include <vector>
26 #include <ThirdPartyWarningsRestore.h>
27 
28 ML_START_NAMESPACE
29 
30 class DicomMessageCollector;
31 
35  public:
38 
40  ZTUFileNameSet(const ZTUFileNameSet &otherObject);
41 
44 
48  typedef std::vector< std::vector< std::vector<DICOMCachedIOFileHandle > > > FileNameSet;
49 
51  inline ZTUFileNameSet &operator=(const ZTUFileNameSet &otherObj)
52  {
53  if (&otherObj != this){
54  // Do not/cannot assign cacheProxies!
55  _pageFileNames = otherObj._pageFileNames;
56  }
57  return *this;
58  }
59 
61  inline bool operator==(const ZTUFileNameSet &otherObj) const
62  {
63  return _pageFileNames == otherObj._pageFileNames;
64  }
65 
67  inline bool operator!=(const ZTUFileNameSet &otherObj) const
68  {
69  return !operator==(otherObj);
70  }
71 
73  bool hasEmptyPagesFileName() const;
74 
76  bool hasMultiFrameHandle() const;
77 
80  bool hasNormalFrameHandle() const;
81 
87  bool allHandlesExistAsFile(bool allowEmpty) const;
88 
92  void resizePageFileNamesToVolumeSize(size_t newZExt, size_t newTExt, size_t newUExt);
93 
95  inline void clearPageFileNames() {
96  _pageFileNames.clear();
97  }
98 
100  inline const FileNameSet &getConstPageFileNameSet() const {
101  return _pageFileNames;
102  };
103 
106  return _pageFileNames;
107  };
108 
110  inline void setPageFileNames(const FileNameSet& pFNames) {
111  _pageFileNames = pFNames;
112  }
113 
115  size_t getZExtent() const;
116 
119  size_t getTExtentAt(size_t z = 0) const;
120 
122  size_t getTExtent() const;
123 
126  size_t getUExtentAt(size_t z = 0, size_t t = 0) const;
127 
129  size_t getUExtent() const;
130 
132  size_t getNumFrames() const;
133 
136  bool isValidPosition(size_t z, size_t t, size_t u) const;
137 
140  const DICOMCachedIOFileHandle &getPageFileName(size_t z, size_t t, size_t u=0) const;
141 
145  void setPageFileName(size_t z, size_t t, size_t u, const std::string fName);
146 
150  void appendFileName(const std::string& fileName, bool appendToZ);
151 
153  void appendFileNameToZ(const std::string& fileName);
154 
156  void appendFileNameToT(const std::string& fileName);
157 
159  void appendFileNameToU(const std::string& fileName);
160 
166  std::string getFileNameSetAsInfoString(bool fileNamesOnly = false) const;
167 
171 
175 
179  std::vector<DICOMCachedIOFileHandle> getAllFileHandles(const DICOMTagTools::ZTUVector &suppressedHandles =
180  DICOMTagTools::ZTUVector()) const;
181 
191  std::string getStateAsString(const std::string& lineEndStr,
192  const std::string& cacheFileRootDirPath,
193  bool useRelativePaths) const;
194 
206  MLErrorCode setStateFromString(const std::string & state,
207  size_t tExt,
208  size_t uExt,
209  const std::string& cacheDirPath,
210  size_t& readPos);
211 
224  bool searchFrameWithSOPInstanceUID(const std::string &sopInstanceUID,
225  DICOMCachedIOFileHandle &foundHandle,
226  DICOMTagTools::ZTUIndex &ztuPosition,
227  bool forceSearchInEnhancedHandles,
228  DicomMessageCollector &dcmMsgCollector) const;
229 
243  bool searchFrameWithValueInTag(unsigned int tagId,
244  const std::string &tagValue,
245  DICOMCachedIOFileHandle &foundHandle,
246  DICOMTagTools::ZTUIndex &ztuPosition,
247  bool forceSearchInEnhancedHandles,
248  DicomMessageCollector &dcmMsgCollector) const;
249 
251  typedef std::map<DICOMTagTools::ZTUIndex, DCMTree::Const_TagPtr> TagsWithPositionMap;
252 
271  bool forceSearchInEnhancedHandles,
272  bool doStringToValue,
273  DicomMessageCollector &dcmMsgCollector,
274  bool createNullTagEntries=false,
275  const std::string &nullEntryTagValue="",
276  bool createNotConvertibleTagEntries=false,
277  const std::string &nonConvertibleTagValue="") const;
278 
289  bool needsNewSOPInstanceUID(bool allowOneToOneEnhancedFrameRecomposition,
290  DicomMessageCollector &dcmMsgCollector) const;
291 
292  private:
301  DCMTree::Const_TagPtr _getTagFromHandle(const DICOMCachedIOFileHandle &frameHandle,
302  unsigned int tagId,
303  bool forceSearchInEnhancedHandles,
304  DicomMessageCollector &dcmMsgCollector) const;
305 
307  MLDICOMCachedIOProxies _cacheProxies;
308 
311  FileNameSet _pageFileNames;
312 };
313 
316 
317 ML_END_NAMESPACE
Project global and OS specific declarations.
#define ML_MLToDicomTools_EXPORT
Only for diagnostic purposes.
An instance of this class creates singleton proxies for DICOMCachedIO cache classes such that all cac...
Class managing a multi-frame Z, T, and U-dimension plus a string value.
Definition: mlZTUIndex.h:26
Class to collect messages and errors related to a given frame handle.
Class to manage a 3D set of handles describing frames or volumes to be composed to a higher dimension...
bool hasMultiFrameHandle() const
Returns true if any page file name is an enhanced multi-frame handle, otherwise false.
MLErrorCode setStateFromString(const std::string &state, size_t tExt, size_t uExt, const std::string &cacheDirPath, size_t &readPos)
Set the object content from the passed state string; the state string is reduced by the parsed conten...
void clearPageFileNames()
Resets the file name set to extent 0 in all dimensions.
~ZTUFileNameSet()
Destructor.
void setPageFileNames(const FileNameSet &pFNames)
Set entire set of file names at once.
FileNameSet & getModifiablePageFileNameSet()
Returns the entire set of file names as modifiable object.
DICOMCachedIOFileHandle getOriginalFrameHandle() const
Returns an empty string if there are two handles which have not the same original file,...
size_t getUExtentAt(size_t z=0, size_t t=0) const
Returns the extent of the file set in T-dimension at the position (z,t) if it exists,...
bool searchFrameWithSOPInstanceUID(const std::string &sopInstanceUID, DICOMCachedIOFileHandle &foundHandle, DICOMTagTools::ZTUIndex &ztuPosition, bool forceSearchInEnhancedHandles, DicomMessageCollector &dcmMsgCollector) const
Returns position and file handle of the first frame with the given SOPInstanceUID.
std::map< DICOMTagTools::ZTUIndex, DCMTree::Const_TagPtr > TagsWithPositionMap
Map of pairs of ZTU frame position with associated tag pointer.
ZTUFileNameSet(const ZTUFileNameSet &otherObject)
Copy constructor.
TagsWithPositionMap getTagFromAllFrames(unsigned int tagId, bool forceSearchInEnhancedHandles, bool doStringToValue, DicomMessageCollector &dcmMsgCollector, bool createNullTagEntries=false, const std::string &nullEntryTagValue="", bool createNotConvertibleTagEntries=false, const std::string &nonConvertibleTagValue="") const
Returns a map with pairs with (DICOMTagTools::ZTUIndex, DCMTree::Const_TagPtr) pairs of first tags in...
const DICOMCachedIOFileHandle & getPageFileName(size_t z, size_t t, size_t u=0) const
Returns a reference to the file name fName for the DICOM frame at position (z,t).
bool allHandlesExistAsFile(bool allowEmpty) const
Returns true if all handles can be found as files on disk, otherwise false; Multi-frame handles are h...
bool operator!=(const ZTUFileNameSet &otherObj) const
Returns false if the passed FileNameSets equals this, otherwise true.
std::vector< std::vector< std::vector< DICOMCachedIOFileHandle > > > FileNameSet
Vector array to manage a 3D set of (frame) file names the volume is composed of.
size_t getNumFrames() const
Returns the entire number of file names in set.
bool operator==(const ZTUFileNameSet &otherObj) const
Returns true if the passed FileNameSets equals this, otherwise false.
size_t getTExtent() const
Returns the maximum extent of the file set in T-dimension in all z entries.
size_t getZExtent() const
Returns the extent of the file set in Z-dimension.
void appendFileName(const std::string &fileName, bool appendToZ)
Append a file name to the z-dimension if appendToZ is true (there the extents in t and u are set to 1...
void appendFileNameToU(const std::string &fileName)
Append a file name to the u-dimension at z/t-position 0.
const FileNameSet & getConstPageFileNameSet() const
Returns the entire set of file names as constant.
std::vector< DICOMCachedIOFileHandle > getAllFileHandles(const DICOMTagTools::ZTUVector &suppressedHandles=DICOMTagTools::ZTUVector()) const
Get all non-empty file handles as a one dimensional vector of files.
void appendFileNameToT(const std::string &fileName)
Append the file name to the t dimension at z-position 0.
bool searchFrameWithValueInTag(unsigned int tagId, const std::string &tagValue, DICOMCachedIOFileHandle &foundHandle, DICOMTagTools::ZTUIndex &ztuPosition, bool forceSearchInEnhancedHandles, DicomMessageCollector &dcmMsgCollector) const
Returns file handle and position of the first frame with a given tagValue in a tag with id tagId.
ZTUFileNameSet & operator=(const ZTUFileNameSet &otherObj)
Assign members without cacheProxies.
DICOMCachedIOFileHandle getFirstNonEmptyFileName() const
Returns the first non empty file name when scanning from [0][0][0] starting with u=0,...
bool needsNewSOPInstanceUID(bool allowOneToOneEnhancedFrameRecomposition, DicomMessageCollector &dcmMsgCollector) const
Checks all frame handles in fileNameSet whether a new SOPInstanceUID should be generated.
size_t getUExtent() const
Returns the maximum extent of the file set in U-dimension in all z and u entries.
void appendFileNameToZ(const std::string &fileName)
Append a file name to the z-dimension (there the extents in t and u are set to 1).
void setPageFileName(size_t z, size_t t, size_t u, const std::string fName)
Set the file name fName for the DICOM frame at position (z,t,u) as pageFileName.
bool isValidPosition(size_t z, size_t t, size_t u) const
Returns true if (z,t,u) addresses an existing (perhaps empty) entry in the ZTUFileNameSet,...
ZTUFileNameSet()
Constructor.
bool hasEmptyPagesFileName() const
Returns true if any page file name is an empty string, otherwise false..
size_t getTExtentAt(size_t z=0) const
Returns the extent of the file set in T-dimension at the position z if it exists, otherwise 0 is retu...
bool hasNormalFrameHandle() const
Returns true if any page file name is non-enhanced-multi-frame handle, otherwise false.
std::string getStateAsString(const std::string &lineEndStr, const std::string &cacheFileRootDirPath, bool useRelativePaths) const
Return current content of class as string whose lines are separated by lineEndStr.
std::string getFileNameSetAsInfoString(bool fileNamesOnly=false) const
Returns all z and time positions and the corresponding file names as string.
void resizePageFileNamesToVolumeSize(size_t newZExt, size_t newTExt, size_t newUExt)
Assures that array of pageFileNames has sufficient extent for the current frames the volume is compos...
MLint32 MLErrorCode
Type of an ML Error code.
Definition: mlTypeDefs.h:818
Header of FileHandle class which should be used in DICOM importing modules to resolve the filename fo...
An instance of this class creates singleton proxies for DICOMCachedIO cache classes such that all cac...
Header file of class ZTUIndex managing a multi-frame Z, T, and U-dimension plus a string value.
boost::shared_ptr< const Tag > Const_TagPtr
Definition: DCMTree_Lib.h:63
std::vector< ZTUIndex > ZTUVector
A std::vector typedef of ZTUIndexes to describe indexes of handles in the multi-frame Z,...
Definition: mlZTUIndex.h:70
ZTUFileNameSet DirectDicomImportPageFileNameSet
For backward compatibility to DirectDicomImport applications:
bool operator==(const Tmat2< DT > &a, const Tmat2< DT > &b)
a == b ? Return true if yes.
Definition: mlMatrix2.h:425