MeVisLab Toolbox Reference
mlDICOMCachedIOPixelFrameCacheContainer.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
16#include <FMEThirdPartyWarningsDisable.h>
17#include <string>
18#include <vector>
19#include <boost/unordered_map.hpp>
20#include <FMEThirdPartyWarningsRestore.h>
21
22#include <mlConstantString.h>
23#include <mlSubImage.h>
25
26#include <DCMTree_Lib.h>
27#include <DCMTree_MFPixelTag.h>
28
29namespace ML_NAMESPACE {
30 class IntField;
31};
32
33//----------------------------------------------------------------------------------
35//----------------------------------------------------------------------------------
37public:
39 inline MLMFPixDataFramesCacheEntry(const std::string &fileName, size_t numFrames) :
40 _fileName(fileName),
41 _pixDatas(),
42 _frameSubImages(),
43 _subImagesFlipped(false)
44 {
45 _pixDatas.resize(numFrames);
46 }
47
49 std::string _fileName;
50
52 std::vector<DCMTree::MFPixelTag::pixel_cont_t> _pixDatas;
53
55 std::vector<ML_NAMESPACE::SubImage> _frameSubImages;
56
59};
60
61//----------------------------------------------------------------------------------
65//----------------------------------------------------------------------------------
67
68public:
69 //----------------------------------------------------------------------------------
71 //----------------------------------------------------------------------------------
72 enum { MaxPixFrameDataCacheEntries = 3 };
73
76
79
82
85
87 DCMTree::MFPixelTag::pixel_cont_t getCachedPixFrameData(const ML_NAMESPACE::DICOMCachedIOFileHandle &fileName,
88 size_t frameIdx,
90 size_t numFrames);
91
94 void addPixFrameData(const std::string &fileName,
95 size_t frameIdx,
97 size_t numFrames);
98
101 const ML_NAMESPACE::DICOMCachedIOFileHandle &fileNamePath,
102 size_t &numFoundFrames,
103 std::string &warnDesc,
104 std::string &errDesc);
105
107 DCMTree::MFPixelTag::pixel_cont_t getPixFrameData(const std::string &fileName, size_t frameIdx, size_t numFrames);
108
112
114 bool hasPixFrameDataCache(const std::string &fileName, size_t numFrames) const;
115
117 void removeAssociatedEntries(const std::string &fileName);
118
120 void clear();
121
122protected:
123
126 const ML_NAMESPACE::DICOMCachedIOFileHandle &fileNamePath,
127 size_t &numFoundFrames,
128 std::string &errDesc);
131 const ML_NAMESPACE::DICOMCachedIOFileHandle &fileNamePath,
132 const boost::uint32_t numFrames,
133 std::string &warnDesc,
134 std::string &errDesc);
135
136 // For frame data caching:
139
141 MLMFPixDataFramesCacheEntry* _pixelFrameCaches[MaxPixFrameDataCacheEntries];
142};
Project global and OS specific declarations.
#define MLDICOMCachedIO_EXPORT
If included by external modules, exported symbols are declared as import symbols.
DCMTree::pixel_cont_t pixel_cont_t
Structure containing a container for pixel frames and an index of the most recently used one.
void removeAssociatedEntries(const std::string &fileName)
Clears the entrie(s) of the MLDICOMCachedIOPixelFrameCacheContainer which belong to fileName.
void clear()
Clears the MLDICOMCachedIOPixelFrameCacheContainer, the pixel frame caches, and resets all counters.
size_t _recentMFPixTagCacheIdx
Index to the recently created MFPixTagCache object.
void _fillMFCacheWithFloatData(DCMTree::Const_TreePtr mfTree, const ml::DICOMCachedIOFileHandle &fileNamePath, const boost::uint32_t numFrames, std::string &warnDesc, std::string &errDesc)
Helper function.
MLDICOMCachedIOPixelFrameCacheContainer()
Constructor; it is initialized with 25 MB of cache for DICOM tree tag data.
MLDICOMCachedIOPixelFrameCacheContainer & operator=(const MLDICOMCachedIOPixelFrameCacheContainer &)=delete
Delete assignment operator to prevent usage.
bool hasPixFrameDataCache(const std::string &fileName, size_t numFrames) const
If there is a pixel data cache for file name with numFrames then it returns true, otherwise false.
void _fillMFCacheFromMFPixelTag(const DCMTree::MFPixelTag &mfPixelDataTag, const ml::DICOMCachedIOFileHandle &fileNamePath, size_t &numFoundFrames, std::string &errDesc)
Helper function.
~MLDICOMCachedIOPixelFrameCacheContainer()
Destructor, cleaning up internal objects.
MLDICOMCachedIOPixelFrameCacheContainer(const MLDICOMCachedIOPixelFrameCacheContainer &)=delete
Delete copy constructor to prevent usage.
void loadMultiFramesInCache(DCMTree::Const_TreePtr mfTree, const ml::DICOMCachedIOFileHandle &fileNamePath, size_t &numFoundFrames, std::string &warnDesc, std::string &errDesc)
See MLDICOMCachedIOPixelFrameCache::loadMultiFramesInCache().
DCMTree::MFPixelTag::pixel_cont_t getPixFrameData(const std::string &fileName, size_t frameIdx, size_t numFrames)
If there is a pixel data cache for a file name then return a cache reference, otherwise nullptr is re...
DCMTree::MFPixelTag::pixel_cont_t getCachedPixFrameData(const ml::DICOMCachedIOFileHandle &fileName, size_t frameIdx, DCMTree::MFPixelTag::pixel_cont_t pixFrameData, size_t numFrames)
See MLDICOMCachedIOPixelFrameCache::getCachedPixFrameData().
MLMFPixDataFramesCacheEntry * getPixFrameCacheEntry(const std::string &fileName)
Return the vector of subimages associated with with pixel frame data; it depends by the application w...
void addPixFrameData(const std::string &fileName, size_t frameIdx, DCMTree::MFPixelTag::pixel_cont_t pixFrameData, size_t numFrames)
Add DICOM pixel data frame to the cache under the fileName as key; addPixFrameData requests with an e...
Small helper class to manage a list of data frames related to a filename.
std::vector< ml::SubImage > _frameSubImages
Array of fully constructed subimages containing the frames.
bool _subImagesFlipped
Indicates that subimages have been flipped, for example to compensate a negative slice spacing.
MLMFPixDataFramesCacheEntry(const std::string &fileName, size_t numFrames)
Constructor to store the filename and to set the size of the array for its data frames.
std::string _fileName
Name of the file from which the frames come.
std::vector< DCMTree::MFPixelTag::pixel_cont_t > _pixDatas
Array of raw frame data pointers.
Header of FileHandle class which should be used in DICOM importing modules to resolve the filename fo...
boost::shared_ptr< const Tree > Const_TreePtr
Definition DCMTree_Lib.h:67