MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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
29class MLImageFormatTagList;
30
32class MLImageFormatInfos;
33class MLImageFormatAbstractFileHandle;
34
35//--------------------------------------------------------------------------------
38//--------------------------------------------------------------------------------
40{
41
42public:
43 //--------------------------------------------------------------------------------
50 //--------------------------------------------------------------------------------
52 {
53
58
62
66
69
72
75
80
82 MLuint8 _internalData[11];
83
88
90 inline MLuint32 getCheckSum() const
91 {
92 return ((static_cast<MLuint32>(checkSumLow)) | (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
151 bool setTable = true);
152
160
164
166 void reset();
167
190
193
196
199
202
205
208
212
215
223
234
235private:
237 MLint _firstEntry;
238
240 MLint _lastEntry;
241
243 MLint _numAllocatedTableEntries;
244
246 MLint _numImagePageIds;
247
249 MLint _sizeOfOneVoxel;
250
252 MLDataType _voxelType;
253
255 MLint _idxTabEntrySize;
256
259 void* _tablePtr;
260
261private:
264 {}
265
267 inline MLImageFormatIdxTable& operator=(const MLImageFormatIdxTable&)
268 {
269 return *this;
270 }
271};
272
274
275#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:592
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:772
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:505
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:411
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
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.