1 /*============================================================================ 2 MetaIO 3 Copyright 2000-2010 Insight Software Consortium 4 5 Distributed under the OSI-approved BSD License (the "License"); 6 see accompanying file Copyright.txt for details. 7 8 This software is distributed WITHOUT ANY WARRANTY; without even the 9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 See the License for more information. 11 ============================================================================*/ 12 #include "localMetaConfiguration.h" 13 #if !defined(_MSC_VER) || (_MSC_VER > 1500) // do not include this file for Visual Studio 2008 14 # include <cstdint> 15 #endif 16 17 #ifndef ITKMetaIO_METATYPES_H 18 # define ITKMetaIO_METATYPES_H 19 20 /*! 21 * File: 22 * MetaTypes (.h and .cpp) 23 * 24 * Description: 25 * This file provides the definition of the enumerated types used by 26 * metaObjects as well as the record structured used to describe the 27 * fields to be read and written by MetaObjects. 28 * 29 * 30 * \author Stephen R. Aylward 31 * \date August 29, 1999 32 * 33 */ 34 # if (METAIO_USE_NAMESPACE) 35 namespace METAIO_NAMESPACE 36 { 37 # endif 38 39 constexpr size_t METAIO_MAX_WORD_SIZE=80; 40 41 typedef char MET_ASCII_CHAR_TYPE; 42 typedef int8_t MET_CHAR_TYPE; 43 typedef uint8_t MET_UCHAR_TYPE; 44 typedef int16_t MET_SHORT_TYPE; 45 typedef uint16_t MET_USHORT_TYPE; 46 typedef int32_t MET_INT_TYPE; 47 typedef uint32_t MET_UINT_TYPE; 48 typedef int32_t MET_LONG_TYPE; 49 typedef uint32_t MET_ULONG_TYPE; 50 typedef int64_t MET_LONG_LONG_TYPE; 51 typedef uint64_t MET_ULONG_LONG_TYPE; 52 typedef float MET_FLOAT_TYPE; 53 typedef double MET_DOUBLE_TYPE; 54 typedef char * MET_STRING_TYPE; 55 56 57 // Value types for the variables in a metaFile 58 // Format for variables defined in a metaFile is 59 // <variable> = <value> 60 // where <variable> is a designated fieldname/keyword (e.g., NDims) 61 // and value is an instance of that fieldname's associated valueType 62 constexpr size_t MET_NUM_VALUE_TYPES = 29; 63 64 typedef enum 65 { 66 MET_NONE = 0, 67 MET_ASCII_CHAR, 68 MET_CHAR, 69 MET_UCHAR, 70 MET_SHORT, 71 MET_USHORT, 72 MET_INT, 73 MET_UINT, 74 MET_LONG, 75 MET_ULONG, 76 MET_LONG_LONG, 77 MET_ULONG_LONG, 78 MET_FLOAT, 79 MET_DOUBLE, 80 MET_STRING, 81 MET_CHAR_ARRAY, 82 MET_UCHAR_ARRAY, 83 MET_SHORT_ARRAY, 84 MET_USHORT_ARRAY, 85 MET_INT_ARRAY, 86 MET_UINT_ARRAY, 87 MET_LONG_ARRAY, 88 MET_ULONG_ARRAY, 89 MET_LONG_LONG_ARRAY, 90 MET_ULONG_LONG_ARRAY, 91 MET_FLOAT_ARRAY, 92 MET_DOUBLE_ARRAY, 93 MET_FLOAT_MATRIX, 94 MET_OTHER 95 } MET_ValueEnumType; 96 97 98 constexpr unsigned char MET_ValueTypeSize[MET_NUM_VALUE_TYPES] = { 0, 1, 1, 1, 2, 2, 4, 4, 4, 4, 8, 8, 4, 8, 1, 99 1, 1, 2, 2, 4, 4, 4, 4, 8, 8, 4, 8, 4, 0 }; 100 101 static_assert((MET_OTHER + 1) == MET_NUM_VALUE_TYPES, "ERROR: Number of types defined is incorrect."); 102 103 constexpr char MET_ValueTypeName[MET_NUM_VALUE_TYPES][21] = { 104 { 'M', 'E', 'T', '_', 'N', 'O', 'N', 'E', '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, 105 { 'M', 'E', 'T', '_', 'A', 'S', 'C', 'I', 'I', '_', 'C', 'H', 'A', 'R', '\0', ' ', ' ', ' ', ' ', ' ', ' ' }, 106 { 'M', 'E', 'T', '_', 'C', 'H', 'A', 'R', '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, 107 { 'M', 'E', 'T', '_', 'U', 'C', 'H', 'A', 'R', '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, 108 { 'M', 'E', 'T', '_', 'S', 'H', 'O', 'R', 'T', '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, 109 { 'M', 'E', 'T', '_', 'U', 'S', 'H', 'O', 'R', 'T', '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, 110 { 'M', 'E', 'T', '_', 'I', 'N', 'T', '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, 111 { 'M', 'E', 'T', '_', 'U', 'I', 'N', 'T', '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, 112 { 'M', 'E', 'T', '_', 'L', 'O', 'N', 'G', '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, 113 { 'M', 'E', 'T', '_', 'U', 'L', 'O', 'N', 'G', '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, 114 { 'M', 'E', 'T', '_', 'L', 'O', 'N', 'G', '_', 'L', 'O', 'N', 'G', '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, 115 { 'M', 'E', 'T', '_', 'U', 'L', 'O', 'N', 'G', '_', 'L', 'O', 'N', 'G', '\0', ' ', ' ', ' ', ' ', ' ', ' ' }, 116 { 'M', 'E', 'T', '_', 'F', 'L', 'O', 'A', 'T', '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, 117 { 'M', 'E', 'T', '_', 'D', 'O', 'U', 'B', 'L', 'E', '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, 118 { 'M', 'E', 'T', '_', 'S', 'T', 'R', 'I', 'N', 'G', '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, 119 { 'M', 'E', 'T', '_', 'C', 'H', 'A', 'R', '_', 'A', 'R', 'R', 'A', 'Y', '\0', ' ', ' ', ' ', ' ', ' ', ' ' }, 120 { 'M', 'E', 'T', '_', 'U', 'C', 'H', 'A', 'R', '_', 'A', 'R', 'R', 'A', 'Y', '\0', ' ', ' ', ' ', ' ', ' ' }, 121 { 'M', 'E', 'T', '_', 'S', 'H', 'O', 'R', 'T', '_', 'A', 'R', 'R', 'A', 'Y', '\0', ' ', ' ', ' ', ' ', ' ' }, 122 { 'M', 'E', 'T', '_', 'U', 'S', 'H', 'O', 'R', 'T', '_', 'A', 'R', 'R', 'A', 'Y', '\0', ' ', ' ', ' ', ' ' }, 123 { 'M', 'E', 'T', '_', 'I', 'N', 'T', '_', 'A', 'R', 'R', 'A', 'Y', '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, 124 { 'M', 'E', 'T', '_', 'U', 'I', 'N', 'T', '_', 'A', 'R', 'R', 'A', 'Y', '\0', ' ', ' ', ' ', ' ', ' ', ' ' }, 125 { 'M', 'E', 'T', '_', 'L', 'O', 'N', 'G', '_', 'A', 'R', 'R', 'A', 'Y', '\0', ' ', ' ', ' ', ' ', ' ', ' ' }, 126 { 'M', 'E', 'T', '_', 'U', 'L', 'O', 'N', 'G', '_', 'A', 'R', 'R', 'A', 'Y', '\0', ' ', ' ', ' ', ' ', ' ' }, 127 { 'M', 'E', 'T', '_', 'L', 'O', 'N', 'G', '_', 'L', 'O', 'N', 'G', '_', 'A', 'R', 'R', 'A', 'Y', '\0', ' ' }, 128 { 'M', 'E', 'T', '_', 'U', 'L', 'O', 'N', 'G', '_', 'L', 'O', 'N', 'G', '_', 'A', 'R', 'R', 'A', 'Y', '\0' }, 129 { 'M', 'E', 'T', '_', 'F', 'L', 'O', 'A', 'T', '_', 'A', 'R', 'R', 'A', 'Y', '\0', ' ', ' ', ' ', ' ', ' ' }, 130 { 'M', 'E', 'T', '_', 'D', 'O', 'U', 'B', 'L', 'E', '_', 'A', 'R', 'R', 'A', 'Y', '\0', ' ', ' ', ' ', ' ' }, 131 { 'M', 'E', 'T', '_', 'F', 'L', 'O', 'A', 'T', '_', 'M', 'A', 'T', 'R', 'I', 'X', '\0', ' ', ' ', ' ', ' ' }, 132 { 'M', 'E', 'T', '_', 'O', 'T', 'H', 'E', 'R', '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } 133 }; 134 135 136 constexpr size_t MET_NUM_ORIENTATION_TYPES = 7; 137 138 typedef enum 139 { 140 MET_ORIENTATION_RL, 141 MET_ORIENTATION_LR, 142 MET_ORIENTATION_AP, 143 MET_ORIENTATION_PA, 144 MET_ORIENTATION_SI, 145 MET_ORIENTATION_IS, 146 MET_ORIENTATION_UNKNOWN 147 } MET_OrientationEnumType; 148 149 static_assert((MET_ORIENTATION_UNKNOWN + 1) == MET_NUM_ORIENTATION_TYPES, "ERROR: Incorrect number of items."); 150 151 constexpr char MET_OrientationTypeName[MET_NUM_ORIENTATION_TYPES][3] = { { 'R', 'L', '\0' }, { 'L', 'R', '\0' }, 152 { 'A', 'P', '\0' }, { 'P', 'A', '\0' }, 153 { 'S', 'I', '\0' }, { 'I', 'S', '\0' }, 154 { '?', '?', '\0' } }; 155 156 constexpr size_t MET_NUM_DISTANCE_UNITS_TYPES = 4; 157 158 typedef enum 159 { 160 MET_DISTANCE_UNITS_UNKNOWN, 161 MET_DISTANCE_UNITS_UM, 162 MET_DISTANCE_UNITS_MM, 163 MET_DISTANCE_UNITS_CM 164 } MET_DistanceUnitsEnumType; 165 166 static_assert((MET_DISTANCE_UNITS_CM + 1) == MET_NUM_DISTANCE_UNITS_TYPES, "ERROR: Structure mismatch in size."); 167 168 constexpr char MET_DistanceUnitsTypeName[MET_NUM_DISTANCE_UNITS_TYPES][3] = { { '?', '\0', '\0' }, 169 { 'u', 'm', '\0' }, 170 { 'm', 'm', '\0' }, 171 { 'c', 'm', '\0' } }; 172 173 constexpr size_t MET_NUM_INTERPOLATION_TYPES = 4; 174 175 typedef enum 176 { 177 MET_NO_INTERPOLATION, 178 MET_EXPLICIT_INTERPOLATION, 179 MET_BEZIER_INTERPOLATION, 180 MET_LINEAR_INTERPOLATION 181 } MET_InterpolationEnumType; 182 static_assert((MET_LINEAR_INTERPOLATION + 1) == MET_NUM_INTERPOLATION_TYPES, "ERROR: Structure mismatch in size."); 183 184 constexpr char MET_InterpolationTypeName[MET_NUM_INTERPOLATION_TYPES][17] = { 185 { 'M', 'E', 'T', '_', 'N', 'O', 'N', 'E', '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, 186 { 'M', 'E', 'T', '_', 'E', 'X', 'P', 'L', 'I', 'C', 'I', 'T', '\0', ' ', ' ', ' ', ' ' }, 187 { 'M', 'E', 'T', '_', 'B', 'E', 'Z', 'I', 'E', 'R', '\0', ' ', ' ', ' ', ' ', ' ', ' ' }, 188 { 'M', 'E', 'T', '_', 'L', 'I', 'N', 'E', 'A', 'R', '\0', ' ', ' ', ' ', ' ', ' ', ' ' } 189 }; 190 191 192 constexpr size_t MET_MAX_NUMBER_OF_FIELD_VALUES = 4096; 193 constexpr size_t MET_MAX_NAME_SIZE = 255; 194 195 // Structure used to define a field 196 // (variable = value definition) in a MetaFile 197 typedef struct 198 { 199 char name[MET_MAX_NAME_SIZE]; // Fieldname / keyword to designate a variable 200 MET_ValueEnumType type; // Expected value type of the field 201 bool required; // Is this field a required field in a metaFile 202 int dependsOn; // If value type is an array, the size of this 203 // array can be defined by a different field 204 // (e.g., DimSize array depends on NDims) 205 bool defined; // Has this field already been defined in the 206 // MetaFile being parsed 207 int length; // Actual/expect length of an array 208 double value[MET_MAX_NUMBER_OF_FIELD_VALUES]; 209 // Memory and pointers for the field's value(s). 210 bool terminateRead; // Set to true if field indicates end of 211 // meta data 212 } MET_FieldRecordType; 213 214 215 # if (METAIO_USE_NAMESPACE) 216 }; 217 # endif 218 219 220 #endif 221