MeVisLab Toolbox Reference
mlMultiFileVolumeList.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
14#include <mlTypeDefs.h>
15#include <FMEThirdPartyWarningsDisable.h>
16#include <list>
17#include <map>
18#include <set>
19#include <string>
20#include <vector>
21#include <FMEThirdPartyWarningsRestore.h>
25
26ML_START_NAMESPACE
27
28// Forwards internally used types.
29class DicomMessageCollector;
30class MultiFileVolume;
31class ProgressLogger;
32namespace DICOMTagTools{
33 class ZTUIndex;
34};
35
36//----------------------------------------------------------------------------------
39//----------------------------------------------------------------------------------
40typedef std::multimap<unsigned int, std::string> TSearchTerm;
41
42//----------------------------------------------------------------------------------
46//----------------------------------------------------------------------------------
47class MLMULTI_FILE_VOLUME_EXPORT MultiFileVolumeList : public std::vector<MultiFileVolume*> {
48 public:
49
52 typedef void ProgressCB(void *usrData,
53 const std::string &info,
54 float state);
55
59 typedef void RemoveUserFileCB(const size_t volumeIndex,
60 const std::string& validCacheDir,
61 const std::string& validCacheFileName);
62
63 // Default constructor, deletes all MultiFileVolumes in its list.
65
68
71
74
76 void setUpIssues(const DicomMessageCollector *dcmMsgCollector = nullptr);
77
79 std::string getIssues(const DicomMessageCollector *dcmMsgCollector = nullptr) const;
80
83
85 bool equals(const MultiFileVolumeList &obj) const;
86
89 bool sortUpwards,
90 MLint rawTagId,
91 bool useNumericTagStringValueSorting);
92
94 MultiFileVolume* findVolumeByInstanceUID(std::string sopClassUID,
95 std::string sopInstanceUID) const;
96
100 std::vector<MLuint32>& outVolumeIds,
102 bool searchAnyValue) const;
103
115 MLErrorCode appendToCache(const std::string &cacheDirPath,
116 std::string &currCacheState,
117 bool useRelativePaths,
118 const std::string &optionalFilePrefix="") const;
119
145 MLErrorCode setFromString(const std::string &state,
146 const std::string &cacheDirPath,
147 ProgressCB progressCB = nullptr,
148 void *userData = nullptr,
149 const float startPercentage = 0.0f,
150 const float percentageRange = 1.0f,
151 std::list<std::string> *cacheFileList = nullptr,
152 DicomMessageCollector *dcmMsgCollector = nullptr);
153
154 //--------------------------------------------------
156 //--------------------------------------------------
158
167 static std::string getResultCacheFileName(const std::string &fileNameInput,
168 const std::string &cachePathInput,
169 std::string &fileName,
170 std::string &cacheDirPath,
171 const MLint fileIndex=-1);
172
183 static MLErrorCode clearResultCacheFiles(const std::string &fileNameInput,
184 const std::string &cachePathInput,
185 ProgressLogger *progressLogger = nullptr,
186 RemoveUserFileCB userFileDeleter = nullptr);
187
204 MLErrorCode loadResultCache(const std::string &fileNameInput,
205 const std::string &cachePathInput,
206 ProgressLogger *progressLogger,
207 bool &volumeListChanged,
208 ProgressCB progressCallback,
209 void *userData);
210
221 MLErrorCode writeResultCache(const std::string &fileNameInput,
222 const std::string &cachePathInput,
223 const bool useRelativePaths,
224 const bool writeSingleVolumeCaches,
225 ProgressLogger *progressLogger) const;
226
261 MLErrorCode loadResultCacheIntoVolumeList(const std::string &sourceFileName,
262 const std::string &cacheDirPath,
263 bool *volumeListChanged = nullptr,
264 ProgressCB progressCB = nullptr,
265 void *userData = nullptr,
266 const float startPercentage = 0.0f,
267 const float percentageRange = 1.0f,
268 std::list<std::string> *cacheFileList = nullptr,
269 DicomMessageCollector *dcmMsgCollector = nullptr);
270
274 MLErrorCode loadMultiFileVolumeListCache(const std::string &fileName,
275 bool *volumeListChanged = nullptr,
276 ProgressCB progressCB = nullptr,
277 void *userData = nullptr,
278 const float startPercentage = 0.0f,
279 const float percentageRange = 1.0f,
280 std::list<std::string> *cacheFileList = nullptr);
281
287 MLErrorCode clearResultFiles(ProgressLogger *progressLogger = nullptr) const;
289
290
308 bool searchFrameWithSOPInstanceUID(const std::string &sopInstanceUID,
309 DICOMCachedIOFileHandle &foundHandle,
310 DICOMTagTools::ZTUIndex &ztuPosition,
311 MultiFileVolumeList::const_iterator &volumeIt,
312 bool forceSearchInEnhancedHandles,
313 bool alsoSearchInSMFTrees,
314 DicomMessageCollector &dcmMsgCollector) const;
315
334 bool searchFrameWithValueInTag(unsigned int tagId,
335 const std::string &tagValue,
336 DICOMCachedIOFileHandle &foundHandle,
337 DICOMTagTools::ZTUIndex &ztuPosition,
338 MultiFileVolumeList::const_iterator &volumeIt,
339 bool forceSearchInEnhancedHandles,
340 bool alsoSearchInSMFTrees,
341 DicomMessageCollector &dcmMsgCollector) const;
342
354 std::vector<MultiFileVolumeList::const_iterator> searchVolumesWithFramesWithValueInTag(unsigned int tagId,
355 const std::string &tagValue,
356 bool forceSearchInEnhancedHandles,
357 bool alsoSearchInSMFTrees,
358 DicomMessageCollector &dcmMsgCollector) const;
359
371 std::set<size_t> searchVolumeIndexesWithValueInTag(unsigned int tagId,
372 const std::string &tagValue,
373 bool forceSearchInEnhancedHandles,
374 bool alsoSearchInSMFTrees,
375 DicomMessageCollector &dcmMsgCollector) const;
376
377 protected:
406 MLErrorCode _setFromMultiCacheFile(const std::string &state,
407 const std::string &cacheDirPath,
408 ProgressCB progressCB ,
409 void *userData ,
410 const float startPercentage ,
411 const float percentageRange ,
412 std::list<std::string> *cacheFileList ,
413 size_t &readPos,
414 DicomMessageCollector *dcmMsgCollector);
415};
416
419
420ML_END_NAMESPACE
Project global and OS specific declarations.
#define MLMULTI_FILE_VOLUME_EXPORT
Only for diagnostic purposes.
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.
BooleanOperation
An enumeration to define the boolean op to be performed on the results of all search items.
SortModes
Possible modes how to reorder the volumes.
Class managing a list of MultiFileVolume instances for the DirectDicomImport module; taking ownership...
MLErrorCode appendToCache(const std::string &cacheDirPath, std::string &currCacheState, bool useRelativePaths, const std::string &optionalFilePrefix="") const
Converts the current state of this to a string.
void setUpIssues(const DicomMessageCollector *dcmMsgCollector=nullptr)
Sets up the 'issues' members of all volumes; see MultiFileVolume::setUpIssues() for details.
bool equals(const MultiFileVolumeList &obj) const
Returns true if basic properties of *this and obj are identical, otherwise false.
MLErrorCode _setFromMultiCacheFile(const std::string &state, const std::string &cacheDirPath, ProgressCB progressCB, void *userData, const float startPercentage, const float percentageRange, std::list< std::string > *cacheFileList, size_t &readPos, DicomMessageCollector *dcmMsgCollector)
Helper function for setFromString: Reads the state of this from the string state; returns ML_RESULT_O...
void ProgressCB(void *usrData, const std::string &info, float state)
Progress callback which can be passed to some functions for progress bar updates in DirectDicomImport...
bool findVolumesByCriteria(TSearchTerm searchTerm, std::vector< MLuint32 > &outVolumeIds, MultiFileVolumeListFind::BooleanOperation booleanOperation, bool searchAnyValue) const
Find volumes in *this using given searchTerm (containing e.g.
std::set< size_t > searchVolumeIndexesWithValueInTag(unsigned int tagId, const std::string &tagValue, bool forceSearchInEnhancedHandles, bool alsoSearchInSMFTrees, DicomMessageCollector &dcmMsgCollector) const
Returns a set of indexes to volumes which contain a frame with a tag with id tagId with value tagValu...
MultiFileVolume * findVolumeByInstanceUID(std::string sopClassUID, std::string sopInstanceUID) const
Find a volume in *this using given SOPClassUID and SOPInstanceUID; see MultiFileVolumeListFind for de...
void freeAllVolumes()
Deletes all volumes and reduce vector size to 0.
std::vector< MultiFileVolumeList::const_iterator > searchVolumesWithFramesWithValueInTag(unsigned int tagId, const std::string &tagValue, bool forceSearchInEnhancedHandles, bool alsoSearchInSMFTrees, DicomMessageCollector &dcmMsgCollector) const
Returns a vector of iterators to volumes which contain a frame with a tag with id tagId with value ta...
MLErrorCode clearResultFiles(ProgressLogger *progressLogger=nullptr) const
Clear all stored SMF-Tree files for the MultiFileVolumeList instance; cache files are not removed.
bool searchFrameWithSOPInstanceUID(const std::string &sopInstanceUID, DICOMCachedIOFileHandle &foundHandle, DICOMTagTools::ZTUIndex &ztuPosition, MultiFileVolumeList::const_iterator &volumeIt, bool forceSearchInEnhancedHandles, bool alsoSearchInSMFTrees, DicomMessageCollector &dcmMsgCollector) const
Returns position and file handle of the first frame in the first volume with the given SOPInstanceUID...
virtual ~MultiFileVolumeList()
Destructor.
MLErrorCode writeResultCache(const std::string &fileNameInput, const std::string &cachePathInput, const bool useRelativePaths, const bool writeSingleVolumeCaches, ProgressLogger *progressLogger) const
Writes all information into the cache file in the cache file directory.
MultiFileVolumeList(const MultiFileVolumeList &ref)
Copy constructor.
MLErrorCode setFromString(const std::string &state, const std::string &cacheDirPath, ProgressCB progressCB=nullptr, void *userData=nullptr, const float startPercentage=0.0f, const float percentageRange=1.0f, std::list< std::string > *cacheFileList=nullptr, DicomMessageCollector *dcmMsgCollector=nullptr)
Reads the state of this from the string state; returns ML_RESULT_OK on successful load and false on f...
MultiFileVolumeList & operator=(const MultiFileVolumeList &ref)
Assignment operator *creating copied duplicates from ref).
MLErrorCode loadResultCacheIntoVolumeList(const std::string &sourceFileName, const std::string &cacheDirPath, bool *volumeListChanged=nullptr, ProgressCB progressCB=nullptr, void *userData=nullptr, const float startPercentage=0.0f, const float percentageRange=1.0f, std::list< std::string > *cacheFileList=nullptr, DicomMessageCollector *dcmMsgCollector=nullptr)
Reload all information from the cache file in the cache file directory into *this.
void sortVolumes(MultiFileVolumeListSort::SortModes sortMode, bool sortUpwards, MLint rawTagId, bool useNumericTagStringValueSorting)
Sorts the volume list according the given sort criteria sortMode; see MultiFileVolumeListSort for det...
static std::string getResultCacheFileName(const std::string &fileNameInput, const std::string &cachePathInput, std::string &fileName, std::string &cacheDirPath, const MLint fileIndex=-1)
Returns the full name path of the result cache file.
bool searchFrameWithValueInTag(unsigned int tagId, const std::string &tagValue, DICOMCachedIOFileHandle &foundHandle, DICOMTagTools::ZTUIndex &ztuPosition, MultiFileVolumeList::const_iterator &volumeIt, bool forceSearchInEnhancedHandles, bool alsoSearchInSMFTrees, DicomMessageCollector &dcmMsgCollector) const
Returns file handle and position of the first frame in the first volume with tagValue in a tag with i...
std::string getIssues(const DicomMessageCollector *dcmMsgCollector=nullptr) const
Returns a collected string with all issues; requires that issues have been set up before.
MLErrorCode loadResultCache(const std::string &fileNameInput, const std::string &cachePathInput, ProgressLogger *progressLogger, bool &volumeListChanged, ProgressCB progressCallback, void *userData)
Reload all information from the cache file in the cache file directory into the internal volume list ...
static MLErrorCode clearResultCacheFiles(const std::string &fileNameInput, const std::string &cachePathInput, ProgressLogger *progressLogger=nullptr, RemoveUserFileCB userFileDeleter=nullptr)
Clear all files from the cache containing result volume files in the cache file directory.
MLErrorCode loadMultiFileVolumeListCache(const std::string &fileName, bool *volumeListChanged=nullptr, ProgressCB progressCB=nullptr, void *userData=nullptr, const float startPercentage=0.0f, const float percentageRange=1.0f, std::list< std::string > *cacheFileList=nullptr)
Alternative load routine for a MultiFileVolume(List) from a cache file which first splits fileName to...
void RemoveUserFileCB(const size_t volumeIndex, const std::string &validCacheDir, const std::string &validCacheFileName)
A function callback which removes a user added cache file related to a volume which is stored in the ...
Management class used by DirectDicomImport to create, represent and describe volumes composed of mult...
Configurable logger and progress handler class which can be used as base class for logging,...
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:715
Header of FileHandle class which should be used in DICOM importing modules to resolve the filename fo...
Class implementing some search functionality on MultiFileVolumeLists.
Tool class to sort MultiFileVolumeLists according to specific properties.
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition mlTypeDefs.h:489
std::multimap< unsigned int, std::string > TSearchTerm
Typedef to define filter criteria to filter the list of volume references e.g.