ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkScancoDataManipulation.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkScancoDataManipulation_h
19#define itkScancoDataManipulation_h
20#include "itkMacro.h"
21#include <cstddef>
22#include <array>
23
25{
26 int m_Dimensions[3]; // Dimensions of the pixel data
27 float m_Origin[3]; // Origin of the pixel data in physical space
28 double m_Spacing[3]; // Spacing between pixels in physical space
29 int m_ComponentType; // Data Type (e.g., unsigned char, short, float)
31};
32
33// Scanco header fixed-width fields. The on-disk format stores each text field
34// at a fixed binary width (no NUL terminator); the in-memory buffer is two
35// bytes wider so that decoded strings are always NUL-terminated.
37{
38inline constexpr std::size_t VersionDiskWidth = 16;
39inline constexpr std::size_t VersionBufferSize = VersionDiskWidth + 2;
40
41inline constexpr std::size_t PatientNameDiskWidth = 40;
42inline constexpr std::size_t PatientNameBufferSize = PatientNameDiskWidth + 2;
43
44inline constexpr std::size_t RescaleUnitsDiskWidth = 16;
45inline constexpr std::size_t RescaleUnitsBufferSize = RescaleUnitsDiskWidth + 2;
46
47inline constexpr std::size_t CalibrationDataDiskWidth = 64;
48inline constexpr std::size_t CalibrationDataBufferSize = CalibrationDataDiskWidth + 2;
49
50// ISQ stores creation/modification timestamps as an 8-byte binary date; in
51// memory both ends decode to a 32-byte human-readable date string.
52inline constexpr std::size_t EncodedDateDiskWidth = 8;
53inline constexpr std::size_t DateStringBufferSize = 32;
54} // namespace ScancoHeaderField
55
93
94#define ScancoGetConstMacro(name, type) \
95 virtual type Get##name() const { return this->m_HeaderData.m_##name; } \
96 ITK_MACROEND_NOOP_STATEMENT
97
98#define ScancoSetMacro(name, type) \
99 virtual void Set##name(type _arg) \
100 { \
101 itkDebugMacro("setting " #name " to " << _arg); \
102 ITK_GCC_PRAGMA_PUSH \
103 ITK_GCC_SUPPRESS_Wfloat_equal \
104 if (this->m_HeaderData.m_##name != _arg) \
105 { \
106 this->m_HeaderData.m_##name = std::move(_arg); \
107 this->Modified(); \
108 } \
109 ITK_GCC_PRAGMA_POP \
110 } \
111 ITK_MACROEND_NOOP_STATEMENT
112
113constexpr int ScancoHeaderBlockSize = 512;
114
121int
123
129int
130DecodeInt(const void * data);
131
137int64_t
138DecodeInt64(const void * data);
139
145void
146EncodeInt(int data, void * target);
147
153void
154EncodeInt64(int64_t data, void * target);
155
161float
162DecodeFloat(const void * data);
163
169void
170EncodeFloat(float data, void * target);
171
177double
178DecodeDouble(const void * data);
179
180void
181EncodeDouble(double data, void * target);
182
194void
195DecodeDate(const void * data, int & year, int & month, int & day, int & hour, int & minute, int & second, int & millis);
196
207void
208DateToString(const void * target, int year, int month, int day, int hour, int minute, int second, int millis);
209
213void
214GetCurrentDateString(void * target);
215
220void
221EncodeCurrentDate(void * target);
222
228void
230
238void
239StripString(char * dest, const char * source, size_t length);
240
248void
249PadString(char * dest, const char * source, size_t length);
250
251#endif // itkScancoDataManipulation_h
void PadString(char *dest, const char *source, vcl_size_t length)
void EncodeInt64(int64_t data, void *target)
void DateToString(const void *target, int year, int month, int day, int hour, int minute, int second, int millis)
constexpr int ScancoHeaderBlockSize
void EncodeDateFromString(void *target, const char dateString[ScancoHeaderField::DateStringBufferSize])
void EncodeCurrentDate(void *target)
void StripString(char *dest, const char *source, vcl_size_t length)
void EncodeFloat(float data, void *target)
int CheckVersion(const char header[ScancoHeaderField::VersionDiskWidth])
void DecodeDate(const void *data, int &year, int &month, int &day, int &hour, int &minute, int &second, int &millis)
void EncodeDouble(double data, void *target)
int DecodeInt(const void *data)
double DecodeDouble(const void *data)
void GetCurrentDateString(void *target)
void EncodeInt(int data, void *target)
float DecodeFloat(const void *data)
int64_t DecodeInt64(const void *data)
constexpr std::vcl_size_t VersionBufferSize
constexpr std::vcl_size_t RescaleUnitsBufferSize
constexpr std::vcl_size_t EncodedDateDiskWidth
constexpr std::vcl_size_t PatientNameBufferSize
constexpr std::vcl_size_t VersionDiskWidth
constexpr std::vcl_size_t CalibrationDataBufferSize
constexpr std::vcl_size_t RescaleUnitsDiskWidth
constexpr std::vcl_size_t DateStringBufferSize
constexpr std::vcl_size_t CalibrationDataDiskWidth
constexpr std::vcl_size_t PatientNameDiskWidth
char m_CalibrationData[ScancoHeaderField::CalibrationDataBufferSize]
char m_CreationDate[ScancoHeaderField::DateStringBufferSize]
char m_ModificationDate[ScancoHeaderField::DateStringBufferSize]
char m_RescaleUnits[ScancoHeaderField::RescaleUnitsBufferSize]
char m_Version[ScancoHeaderField::VersionBufferSize]
char m_PatientName[ScancoHeaderField::PatientNameBufferSize]
std::array< double, 2 > m_DataRange