MeVisLab Toolbox Reference
mlImageFormatIdxTable.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_IMAGE_FORMAT_IDX_TABLE_H
14 #define ML_IMAGE_FORMAT_IDX_TABLE_H
15 
19 
20 // Resolve platform independencies.
22 
23 #include "mlModuleIncludes.h"
24 
25 ML_START_NAMESPACE
26 
27 
29  class MLImageFormatTagList;
30 
32  class MLImageFormatInfos;
33  class MLImageFormatAbstractFileHandle;
34 
35  //--------------------------------------------------------------------------------
38  //--------------------------------------------------------------------------------
40 
41  public:
42 
43  //--------------------------------------------------------------------------------
50  //--------------------------------------------------------------------------------
51  struct PageIdxType {
52 
57 
61 
65 
68 
71 
74 
79 
81  MLuint8 _internalData[11];
82 
87 
89  inline MLuint32 getCheckSum() const
90  {
91  return ((static_cast<MLuint32>(checkSumLow ) ) |
92  (static_cast<MLuint32>(checkSumMed ) << 8 ) |
93  (static_cast<MLuint32>(checkSumHigh) << 16));
94  }
95 
97  inline void setCheckSum(MLuint32 sum)
98  {
99  checkSumLow = (sum ) & 0xff;
100  checkSumMed = (sum >> 8) & 0xff;
101  checkSumHigh = (sum >> 16) & 0xff;
102  }
103 
105  inline void setFlagByte(MLuint8 newVal)
106  {
107  flagByte = newVal;
108  }
109 
111  inline void setPartialFlag(bool isPartialPage)
112  {
113  flagByte = static_cast<MLuint8>(flagByte | (isPartialPage ? 1u : 0u));
114  }
115 
117  inline bool getPartialFlag() const
118  {
119  return (flagByte & 1) ? true : false;
120  }
121  };
122 
123  //--------------------------------------------------------------------------------
124  //--------------------------------------------------------------------------------
125 
128 
131 
151  MLint endIdx,
152  MLint numAllPageIds,
153  MLDataType dType,
154  void *newTableData=nullptr,
155  bool setTable=true);
156 
163  void setTableData(void *newTable);
164 
168 
170  void reset();
171 
193  MLint pageDataStartPosInFile,
194  MLint pageDataEndPosInFile,
195  bool isCompressed,
196  MLuint32 checkSum,
197  bool isPartial,
198  const MLTypeData *defaultVoxelData);
199 
201  const PageIdxType *getConstEntry(MLint pageId) const;
202 
205 
208 
211 
214 
217 
221 
224 
232  MLint numWholePageIds);
233 
244  MLuint idxTabBasePos);
245 
246  private:
247 
249  MLint _firstEntry;
250 
252  MLint _lastEntry;
253 
255  MLint _numAllocatedTableEntries;
256 
258  MLint _numImagePageIds;
259 
261  MLint _sizeOfOneVoxel;
262 
264  MLDataType _voxelType;
265 
267  MLint _idxTabEntrySize;
268 
271  void *_tablePtr;
272 
273  private:
274 
277 
279  inline MLImageFormatIdxTable &operator=(const MLImageFormatIdxTable &){ return *this; }
280 
281  };
282 
283 ML_END_NAMESPACE
284 
285 #endif // __mlImageFormatIdxTable_H
#define MLIMAGEFORMATBASE_EXPORT
A base class for abstract read/write access of the MLImageFileFormat.
Internal and private index table for the MLImageFormat.
void reset()
Destroys the internally allocated table and resets everything to construction state.
MLImageFormatIdxTable()
Constructor.
MLint getNumImagePageIds() const
Returns number of whole page IDs of image even if not allocated.
MLint getAllocatedTableSizeInBytes() const
Returns size of entire allocated page ID table in bytes, may be < 0 in case of non allocated table da...
PageIdxType * getEntry(MLint pageId)
Returns pointer to entry with number pageId if available or NULL otherwise.
MLErrorCode load(const MLImageFormatInfos &infos, MLint numWholePageIds)
Loads the index table containing all position and storage information of the pages in the file and st...
~MLImageFormatIdxTable()
Destructor.
const PageIdxType * getConstEntry(MLint pageId) const
Returns pointer to constant entry with number pageId if available or NULL otherwise.
void toggleEndianess()
Toggles all endian-dependent entries of the index table if table data is available; otherwise,...
MLint getNumAllocatedPageIds() const
Returns number of allocated entries or 0 if still not created.
MLErrorCode create(MLint startIdx, MLint endIdx, MLint numAllPageIds, MLDataType dType, void *newTableData=nullptr, bool setTable=true)
Creates/allocates the page index table or a subset of it and fills all allocated memory with 0 bytes.
MLErrorCode save(MLImageFormatAbstractFileHandle *fileHandle, MLuint idxTabBasePos)
Writes allocated section of index table to correct position in file if idxTabBasePos is position of e...
MLErrorCode setEntry(MLint pageId, MLint pageDataStartPosInFile, MLint pageDataEndPosInFile, bool isCompressed, MLuint32 checkSum, bool isPartial, const MLTypeData *defaultVoxelData)
Sets values of entry pageId of index table.
MLint getWholeTableSizeInBytes() const
Returns size of whole page ID table in bytes even if not all entries are allocated.
const MLTypeData * getConstEntryVoxelData(MLint pageId) const
Returns pointer to constant voxel data stored after entry if available or NULL otherwise.
MLTypeData * getEntryVoxelData(MLint pageId)
Returns pointer to voxel data stored after entry if available or NULL otherwise.
void setTableData(void *newTable)
Sets new table data content, previous content will be freed with MLFree().
A internal structure containing information about an opened file.
MLint32 MLDataType
MLDataType.
Definition: mlTypeDefs.h:596
MLint32 MLErrorCode
Type of an ML Error code.
Definition: mlTypeDefs.h:716
unsigned int MLuint32
Definition: mlTypeDefs.h:185
unsigned char MLuint8
Definition: mlTypeDefs.h:109
MLuint64 MLuint
An unsigned ML integer type with at least 64 bits used for index calculations on very large images ev...
Definition: mlTypeDefs.h:506
unsigned char MLTypeData
This is the pointer type used to point to the data of MLType data instances.
Definition: mlTypeDefs.h:1300
INT64 MLint64
Include 64-bit integer support for Windows or Unix.
Definition: mlTypeDefs.h:412
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:490
MLDICOMTags_EXPORT bool isCompressed(DCMTree::Const_TreePtr treePtr)
Returns true if the DICOM tree has a transfer syntax UID which indicates compression,...
MLuint32 getCheckSum() const
After _internalData, the voxel value of the page is stored.
MLuint8 checkSumHigh
Highest 8 bit of 24 bit checksum of the page data. May be 0 for some file that does not store checksu...
MLint64 endFilePos
Position of the last data byte of the page in the file or -1 if the page is not stored and has only o...
MLuint8 flagByte
Flag byte containing status information about the stored page.
MLint64 startFilePos
Position of the first data byte of the page in the file or -1 if the page is not stored.
MLuint8 checkSumMed
Middle 8 bit of 24 bit checksum of the page data. May be 0 for some file that does not store checksum...
bool getPartialFlag() const
Returns true if page is stored only partially; otherwise, it returns false.
void setFlagByte(MLuint8 newVal)
Sets flag byte to the passed value.
MLuint8 isCompressed
1 if the page is compressed with the compression scheme define in the tag ML_COMPRESSION,...
void setCheckSum(MLuint32 sum)
Returns the checksum stored in checkSumLow, checkSumMed, and checkSumHigh.
MLuint8 checkSumLow
Lowest 8 bit of 24 bit checksum of the page data. May be 0 for some file that does not store checksum...
void setPartialFlag(bool isPartialPage)
Sets partial flag for a page, i.e., the page data is stored only as a fragment.