MeVisLab Toolbox Reference
mlDICOMCachedIOTools.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// Local includes
15#include "mlTypeDefs.h"
16
17#include <FMEThirdPartyWarningsDisable.h>
18#include <string>
19#include <sstream>
20#include <FMEThirdPartyWarningsRestore.h>
21
22#include <DCMTree_Lib.h>
23
24ML_START_NAMESPACE
25
26class Base;
27class DicomMessageCollector;
28class PagedImage;
29
31template<typename CT> class DICOMCachedIOFileHandleBase;
32
34
36typedef DICOMCachedIOFileHandleBase<char> DICOMCachedIOFileHandle;
38
39namespace DICOMCachedIOTools {
40
46
56 const std::string &callersMessage,
57 size_t outStrMaxSize = std::string::npos,
58 bool addClampInfo = true);
59
69MLDICOMCachedIO_EXPORT void redirectStream(std::ostream &outputStream,
70 std::streambuf *&tempBuf,
71 std::stringbuf *&stringBuffer);
72
88MLDICOMCachedIO_EXPORT std::string unRedirectStream(std::ostream &outputStream,
89 std::streambuf *&tmpBuf,
90 std::stringbuf *&stringBuffer,
91 size_t outStrMaxSize = std::string::npos,
92 bool addClampInfo = true);
93
94
100
128MLDICOMCachedIO_EXPORT void logFileCheckInfos(const std::string &fileName,
129 DicomMessageCollector &dcmMsgCollector,
130 bool pedantic = true,
131 bool doWarnEmpty = false,
132 bool doWarnFullPathLonger254 = false,
133 bool doWarnSpaces = false,
134 bool doWarnUntypicalChars = false,
135 bool warnBaseNamesLonger31 = false);
136
140MLDICOMCachedIO_EXPORT std::string logFileCheckInfosIntoString(const std::string &fileName,
141 const std::string &prependMessage = " ",
142 bool pedantic = true,
143 bool doWarnEmpty = false,
144 bool doWarnFullPathLonger254 = false,
145 bool doWarnSpaces = false,
146 bool doWarnUntypicalChars = false,
147 bool warnBaseNamesLonger31 = false);
148
161 DicomMessageCollector &dcmMsgCollector,
162 bool loadPixelData=false);
163
172 DCMTree::Const_TreePtr &treePtr,
173 size_t &numVols,
174 DicomMessageCollector &dcmMsgCollector);
175
187 DCMTree::Const_TreePtr &treePtr,
188 size_t &numVols,
189 DicomMessageCollector &dcmMsgCollector);
190
196 DCMTree::Const_TreePtr &treePtr,
197 size_t &numVols);
198
205 DCMTree::Const_TreePtr &treePtr,
206 size_t &numVols);
207
210
212MLDICOMCachedIO_EXPORT extern const char * const LosslessTransferSyntaxUIDs[NumLosslessTransferSyntaxes];
213
215MLDICOMCachedIO_EXPORT extern const char * const LosslessTransferSyntaxNames[NumLosslessTransferSyntaxes];
216
218MLDICOMCachedIO_EXPORT extern DCMTree::TransferSyntax LosslessTransferSyntaxCodes[NumLosslessTransferSyntaxes];
219
223
226MLDICOMCachedIO_EXPORT DCMTree::Const_TagPtr getPrivateTag(const std::string &privateCreatorString,
227 unsigned short groupId,
228 DCMTree::RawTagId lowerEightBitOfElementId,
229 DCMTree::Const_TreePtr dcmTree);
230
234 MLint *spatialExtent=nullptr);
235
241 unsigned int *fromTagOnly=nullptr);
242
253 size_t *valSizeInBytes,
254 DicomMessageCollector &dcmMsgCollector);
255
258
261
262} // namespace DICOMCachedIOTools
263
264ML_END_NAMESPACE
Project global and OS specific declarations.
#define MLDICOMCachedIO_EXPORT
If included by external modules, exported symbols are declared as import symbols.
Class representing general ML objects that support import/export via strings (setPersistentState() an...
Definition mlBase.h:59
Class to collect messages and errors related to a given frame handle.
The class PagedImage, representing a fragmented image that manages properties and data of an image lo...
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:715
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
boost::shared_ptr< const Tag > Const_TagPtr
Definition DCMTree_Lib.h:57
boost::shared_ptr< const Tree > Const_TreePtr
Definition DCMTree_Lib.h:67
TransferSyntax
DICOM transfer syntaxes.
boost::shared_ptr< Tree > TreePtr
Shared pointer to a DCMTree::Tree.
Definition DCMTree_Lib.h:66
unsigned int RawTagId
MLDICOMCachedIO_EXPORT bool isPhilips3D(DCMTree::Const_TreePtr dcmTree, MLint *spatialExtent=nullptr)
Looks for Philips3D format and if there is an extra spatial extent then it is returned in spatialExte...
MLDICOMCachedIO_EXPORT MLErrorCode getDCMTreeFromDCMTiffFilePair(const std::string &dcmTiffFileName, DCMTree::Const_TreePtr &treePtr, size_t &numVols, DicomMessageCollector &dcmMsgCollector)
Loads a Const_TreePtr from a any of both filename components of DCM/TIFF file pair if possible.
MLDICOMCachedIO_EXPORT unsigned int getNumberOfFrames(DCMTree::Const_TreePtr dcmTree, unsigned int *fromTagOnly=nullptr)
Returns the number of real frames in the data set from Number of Frames tag if possible including a p...
MLDICOMCachedIO_EXPORT MLErrorCode getDCMTreeFromDICOMFile(const std::string &dcmFileName, DCMTree::Const_TreePtr &treePtr, size_t &numVols, DicomMessageCollector &dcmMsgCollector)
Loads a Const_TreePtr from a valid DICOM given by the absolute file path fileName if possible.
MLDICOMCachedIO_EXPORT DCMTree::PixelData getPixelDataPtrFromTree(DCMTree::Const_TreePtr treePtr, size_t *valSizeInBytes, DicomMessageCollector &dcmMsgCollector)
Returns the pointer to the pixel data tag value.
MLDICOMCachedIO_EXPORT DCMTree::TreePtr getDirectDCMTree(const std::string &fName, DicomMessageCollector &dcmMsgCollector, bool loadPixelData=false)
Tries to open a file directly by reading it with the DCMTree interfaces and returns a non constant Tr...
MLDICOMCachedIO_EXPORT void getDCMTreeFromDicomTreeBasePtr(Base *basePtr, DCMTree::Const_TreePtr &treePtr, size_t &numVols)
Returns a Const_TreePtr from a DicomTree pointer given as Base pointer if possible.
MLDICOMCachedIO_EXPORT void pushMessageCollecting()
Takes current message handles of DCMTree library and uses redirectStream() to push current handler an...
MLDICOMCachedIO_EXPORT void redirectStream(std::ostream &outputStream, std::streambuf *&tempBuf, std::stringbuf *&stringBuffer)
Redirect outputs to outputStream into the temporary buffer tmpBuf.
MLDICOMCachedIO_EXPORT void clearDICOMCaches()
Clears all cached DICOM date including tags, trees, pixel frames and decomposed multi-frame trees.
MLDICOMCachedIO_EXPORT DCMTree::TransferSyntax getLosslessStorageTransferSyntax(DCMTree::Const_TreePtr dcmTree)
If dcmTree has a TransferSyntaxUID tag matching one form LosslessTransferSyntaxUIDs then the correspo...
MLDICOMCachedIO_EXPORT void removeAssociatedCacheEntries(const DICOMCachedIOFileHandle &fileHandle)
Flush all cached entries related to the given file handle.
MLDICOMCachedIO_EXPORT void logFileCheckInfos(const std::string &fileName, DicomMessageCollector &dcmMsgCollector, bool pedantic=true, bool doWarnEmpty=false, bool doWarnFullPathLonger254=false, bool doWarnSpaces=false, bool doWarnUntypicalChars=false, bool warnBaseNamesLonger31=false)
Logs nothing into dcmMsgCollector if fileName is okay according to selected checks,...
MLDICOMCachedIO_EXPORT void makeWarningsWarningsAndErrorsErrors(std::string &messageString)
Some messages for example from DCMTree(_OFFIS) are not marked with "error" or "warnings" and cannot b...
MLDICOMCachedIO_EXPORT DCMTree::Const_TagPtr getPrivateTag(const std::string &privateCreatorString, unsigned short groupId, DCMTree::RawTagId lowerEightBitOfElementId, DCMTree::Const_TreePtr dcmTree)
If a private creator tag with value privateCreatorString in a private slot with groupId and a tag wit...
MLDICOMCachedIO_EXPORT void getDCMTreeFromPagedImage(PagedImage *inImg, DCMTree::Const_TreePtr &treePtr, size_t &numVols)
Returns a Const_TreePtr from the given PagedImage if possible.
MLDICOMCachedIO_EXPORT void popMessageCollecting(DicomMessageCollector &dcmMsgCollector, const std::string &callersMessage, size_t outStrMaxSize=std::string::npos, bool addClampInfo=true)
Restores states which must have been saved before with pushMessageCollecting() and sends collected (a...
MLDICOMCachedIO_EXPORT std::string logFileCheckInfosIntoString(const std::string &fileName, const std::string &prependMessage=" ", bool pedantic=true, bool doWarnEmpty=false, bool doWarnFullPathLonger254=false, bool doWarnSpaces=false, bool doWarnUntypicalChars=false, bool warnBaseNamesLonger31=false)
Same as DICOMCachedIO::logFileCheckInfos() but it return the result information as std::string.
MLDICOMCachedIO_EXPORT std::string unRedirectStream(std::ostream &outputStream, std::streambuf *&tmpBuf, std::stringbuf *&stringBuffer, size_t outStrMaxSize=std::string::npos, bool addClampInfo=true)
Undo the redirected output of outputStream into the temporary buffer tmpBuf.
DICOMCachedIOFileHandleBase< char > DICOMCachedIOFileHandle
"Forward" to DICOMCachedIOFileHandle.
Contains pixel data that is either shared/ref-counted or a direct pointer.
Definition DCMTree_Lib.h:99