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
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
106 {
107 flagByte = newVal;
108 }
109
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
154 void *newTableData=nullptr,
155 bool setTable=true);
156
164
168
170 void reset();
171
195 bool isCompressed,
197 bool isPartial,
199
202
205
208
211
214
217
221
224
233
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
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.
const MLTypeData * getConstEntryVoxelData(MLint pageId) const
Returns pointer to constant voxel data stored after entry if available or NULL otherwise.
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...
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.
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.
MLTypeData * getEntryVoxelData(MLint pageId)
Returns pointer to voxel data stored after entry if available or NULL otherwise.
MLint getWholeTableSizeInBytes() const
Returns size of whole page ID table in bytes even if not all entries are allocated.
const PageIdxType * getConstEntry(MLint pageId) const
Returns pointer to constant entry with number pageId if available or NULL otherwise.
void setTableData(void *newTable)
Sets new table data content, previous content will be freed with MLFree().
PageIdxType * getEntry(MLint pageId)
Returns pointer to entry with number pageId if available or NULL otherwise.
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
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
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.
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
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.