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
81 DCMTree::MFPixelTag::pixel_cont_t getCachedPixFrameData(const ML_NAMESPACE::DICOMCachedIOFileHandle &fileName,
82 size_t frameIdx,
84 size_t numFrames);
85
88 void addPixFrameData(const std::string &fileName,
89 size_t frameIdx,
91 size_t numFrames);
92
95 const ML_NAMESPACE::DICOMCachedIOFileHandle &fileNamePath,
96 size_t &numFoundFrames,
97 std::string &warnDesc,
98 std::string &errDesc);
99
102
106
108 bool hasPixFrameDataCache(const std::string &fileName, size_t numFrames) const;
109
111 void removeAssociatedEntries(const std::string &fileName);
112
114 void clear();
115
116protected:
117
120 const ML_NAMESPACE::DICOMCachedIOFileHandle &fileNamePath,
121 size_t &numFoundFrames,
122 std::string &errDesc);
125 const ML_NAMESPACE::DICOMCachedIOFileHandle &fileNamePath,
126 const boost::uint32_t numFrames,
127 std::string &warnDesc,
128 std::string &errDesc);
129
130 // For frame data caching:
133
135 MLMFPixDataFramesCacheEntry* _pixelFrameCaches[MaxPixFrameDataCacheEntries];
136};
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.
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.
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...
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
boost::shared_ptr< const Tree > Const_TreePtr
Definition DCMTree_Lib.h:73