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 
83  // After _internalData the voxel value of the page is stored; it,
84  // however, has a size depending on the voxel type and is
86  // < PageVoxelType > onePageVoxel.
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
Global and OS specific declarations for the MLImageFormatBase project.
A base class for abstract read/write access of the MLImageFileFormat.
Internal and private index table for the MLImageFormat, not to be used, because it is subject to chan...
void reset()
Destroys the internally allocated table and resets everything to construction state.
MLImageFormatIdxTable()
Constructor.
MLint getNumImagePageIds() const
Return number of whole page ids of image even if not allocated.
MLint getAllocatedTableSizeInBytes() const
Return size of entire allocated page id table in bytes, maybe < 0 in case of non allocated table data...
PageIdxType * getEntry(MLint pageId)
Get 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
Get pointer to constant entry with number pageId if available or NULL otherwise.
void toggleEndianess()
Toggle all endian dependent entries of the index table if table data is available,...
MLint getNumAllocatedPageIds() const
Return 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)
Create/allocate the page index table or a subset of it and fill all allocated memory with 0 bytes.
MLErrorCode save(MLImageFormatAbstractFileHandle *fileHandle, MLuint idxTabBasePos)
Write allocated section of index table to correct position in file if idxTabBasePos is position of en...
MLErrorCode setEntry(MLint pageId, MLint pageDataStartPosInFile, MLint pageDataEndPosInFile, bool isCompressed, MLuint32 checkSum, bool isPartial, const MLTypeData *defaultVoxelData)
Set values of entry pageId of index table.
MLint getWholeTableSizeInBytes() const
Return size of whole page id table in bytes even if not all entries are allocated.
const MLTypeData * getConstEntryVoxelData(MLint pageId) const
Get pointer to constant voxel data stored after entry if available or NULL otherwise.
MLTypeData * getEntryVoxelData(MLint pageId)
Get pointer to voxel data stored after entry if available or NULL otherwise.
void setTableData(void *newTable)
Set new table data content, previous content will be freed with MLFree().
A internal structure containing information about an opened file, not to be used, because it is subje...
MLint32 MLDataType
MLDataType.
Definition: mlTypeDefs.h:684
MLint32 MLErrorCode
Type of an ML Error code.
Definition: mlTypeDefs.h:818
unsigned int MLuint32
Definition: mlTypeDefs.h:191
unsigned char MLuint8
Definition: mlTypeDefs.h:115
MLuint64 MLuint
An unsigned ML integer type with at least 64 bits used for index calculations on very large images ev...
Definition: mlTypeDefs.h:594
unsigned char MLTypeData
This is the pointer type used to point to the data of MLType data instances.
Definition: mlTypeDefs.h:1436
INT64 MLint64
Include 64 bit integer support for Windows or Unix.
Definition: mlTypeDefs.h:500
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:578
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
added explicitly. Thus it is not part of this struct.
MLuint8 checkSumHigh
Highest 8 bit of 24 bit checksum of page data. May be 0 for some file which do not store check sums.
MLint64 endFilePos
Position of last data byte of page in file or -1 if page is not stored and has only one value.
MLuint8 flagByte
Flag byte containing status information about the stored page.
MLint64 startFilePos
Position of first data byte of page in file or -1 if page is not stored.
MLuint8 checkSumMed
Middle 8 bit of 24 bit checksum of page data. May be 0 for some file which do not store check sums.
bool getPartialFlag() const
Returns true if page is stored only partially, otherwise false.
void setFlagByte(MLuint8 newVal)
Set flag byte to the passed value.
MLuint8 isCompressed
1 if page is compressed with compression scheme define in tag ML_COMPRESSION, 0 otherwise.
void setCheckSum(MLuint32 sum)
Returns the checkSum stored in checkSumLow, checkSumMed, and checkSumHigh.
MLuint8 checkSumLow
Lowest 8 bit of 24 bit checksum of page data. May be 0 for some file which do not store check sums.
void setPartialFlag(bool isPartialPage)
Set partial flag for a page, i.e. the page data is stored only as a fragment.