ML Reference
mlDataTypes.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_DATA_TYPES_H
14#define ML_DATA_TYPES_H
15
24
25#include "mlInitSystemML.h"
26
27#include "mlUtilsAPI.h"
28
29// Compile with C-Link interface.
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#include "mlTypeDefs.h"
35
36//--------------------------------------------------------------------------------------------------
39//--------------------------------------------------------------------------------------------------
41[[nodiscard]]
43
47
51
52
53
54
55//--------------------------------------------------------------------------------------------------
60//--------------------------------------------------------------------------------------------------
64MLEXPORT const char * const * MLDataTypeNames();
65
69
73MLEXPORT const char * MLNameFromDataType(MLDataType dataType);
74
78MLEXPORT MLDataType MLDataTypeFromName(const char* const name);
79
83
87
91MLEXPORT size_t MLSizeOf(MLDataType dataType);
92
95
106
110
114
118
122
129
134
138
161MLEXPORT MLDataType MLGetPromotedTypeWithRange(const MLDataType* inputTypes, size_t numTypes,
162 double rangeMin, double rangeMax);
163
166 double rangeMin, double rangeMax);
167
170 double rangeMin, double rangeMax);
171
174 double rangeMin, double rangeMax);
175
181
190
191
194MLEXPORT MLDataType MLGetIntegerDataTypeForRange(double rangeMin, double rangeMax);
195
221 MLdouble *max,
222 MLint32 preferUnsigned);
223
230 MLdouble max,
231 MLint32 preferUnsigned);
232
239
247
253MLEXPORT MLErrorCode MLClampIntervalToDataTypeRange(double intervalMin, double intervalMax, MLDataType dataType, double* resultIntervalMin, double* resultIntervalMax);
254
258
263
282 int suppressML64BitInts,
283 int suppressMLldouble);
300 int suppressML64BitInts,
301 int suppressMLldouble);
303
304
305
306
307
308//---------------------------------------------------------------------------------------------
309//
310//
311// REGISTERED TYPE SUPPORT
312//
313//
314//---------------------------------------------------------------------------------------------
315
316
317//--------------------------------------------------------------------------------------------------
320//--------------------------------------------------------------------------------------------------
322
325
331
336
341
345
348
350
355
360
361//--------------------------------------------------------------------------------------------------
364//--------------------------------------------------------------------------------------------------
367
368
369//--------------------------------------------------------------------------------------------------
372//--------------------------------------------------------------------------------------------------
375
378
381
385
386
387//--------------------------------------------------------------------------------------------------
390//--------------------------------------------------------------------------------------------------
397[[nodiscard]]
399
402
405
408
411
416
417
418//--------------------------------------------------------------------------------------------------
421//--------------------------------------------------------------------------------------------------
502//---------------------------------------------------------------------
504 size_t typeSize,
505 const char *name,
506 MLdouble dblMin,
507 MLdouble dblMax,
508 const MLTypeData *typeMinPtr,
509 const MLTypeData *typeMaxPtr,
510 const MLTypeData *typeDefaultPtr,
511 const char *typeStructInfo,
512 MLint32 isScalarType,
513 MLTypeGroup typeGroup,
514 MLDataType rangeAndPrecisionEquiv,
515 void **componentAddresses,
516 size_t numGoodCastTos,
517 const char **goodCastTos);
518
520[[nodiscard]]
522
525
531
535
545 const MLTypeData *sourceBufferPointer, MLTypeData *targetBufferPointer,
546 size_t numInstances);
547
557 const MLTypeData *sourceBufferPointer, MLTypeData *targetBufferPointer,
558 size_t numInstances);
559
569 const MLTypeData *sourceBufferPointer, MLTypeData *targetBufferPointer,
570 size_t numInstances);
572
573
574
575
576//--------------------------------------------------------------------------------------------------
579//--------------------------------------------------------------------------------------------------
583
588
592
606 MLint32 *isSigned,
607 MLint32 *isIntegerType,
608 MLint32 *isFloatingPointType,
609 MLint32 *isLongType);
610
617MLEXPORT size_t MLTypeComponentSize(char component);
618
623MLEXPORT void MLTypeSetDoubleComponent(char component, MLdouble value, MLTypeData* targetPointer);
624
626MLEXPORT void MLTypeSetIntComponent (char component, MLint value, MLTypeData* targetPointer);
627
631MLEXPORT void MLTypeSetAllDoubleComponents(const MLTypeInfos* infos, MLdouble value, MLTypeData* targetPointer);
632
634MLEXPORT void MLTypeSetAllIntComponent (const MLTypeInfos *infos, MLint value, MLTypeData* targetPointer);
635
639MLEXPORT MLdouble MLTypeGetDoubleComponent(char component, const MLTypeData* targetPointer);
640
642MLEXPORT MLint MLTypeGetIntComponent (char component, const MLTypeData* targetPointer);
643
655 const MLTypeData *srcPtr,
656 MLdouble *retMin,
657 MLdouble *retMax);
658
660
661
662
663//--------------------------------------------------------------------------------------------------
666//--------------------------------------------------------------------------------------------------
672[[nodiscard]]
673MLEXPORT MLTypeData *MLAllocateVoxelBuffer(MLDataType dataType, size_t numVoxels, const MLTypeData* voxelDefaultValue);
674
681[[nodiscard]]
682MLEXPORT char *MLGetVoxelValueAsString(const MLTypeData* data, MLDataType dataType, MLErrorCode* errorCode);
683
692[[nodiscard]]
693MLEXPORT char *MLGetVoxelValueAsStringLimited(const MLTypeData* data, MLDataType dataType, MLErrorCode* errorCode, int maxPrecision);
694
701[[nodiscard]]
703
712[[nodiscard]]
713MLEXPORT char *MLTypeComponentsToStringLimited(const MLTypeInfos* infos, const MLTypeData* data, int maxPrecision);
714
723[[nodiscard]]
724MLEXPORT MLint32 MLTypeComponentsFromString(const MLTypeInfos* infos, const char* stringData, const MLTypeData* defaultValue, MLTypeData* data);
725
733[[nodiscard]]
734MLEXPORT MLTypeData *MLTypeGetDataValuesFromString(MLDataType dataType, const char* voxelValue, const MLTypeData *defaultValue, size_t numInstances);
735
744MLEXPORT MLint32 MLTypeComponentsFromStream(void *iStr, void *iStrStream,
745 void *stdiStr, void *stdiStrStream,
746 const MLTypeInfos *infos, MLTypeData *data);
747
752MLEXPORT MLdouble MLGetVoxelValueAsDouble(const void* data, MLDataType dataType, MLErrorCode* errorCode);
753
755MLEXPORT bool MLTypeCastToBool (const MLTypeInfos* infos, const MLTypeData* data);
756
759
762
765MLEXPORT void MLTypeCastFromBool (const MLTypeInfos* infos, bool boolValue, MLTypeData* data);
766
768MLEXPORT void MLTypeCastFromInt (const MLTypeInfos *infos, MLint intValue, MLTypeData* data);
769
771MLEXPORT void MLTypeCastFromDouble (const MLTypeInfos* infos, MLdouble doubleValue, MLTypeData* data);
772
778MLEXPORT void MLTypeShiftComponentsLeft(const MLTypeInfos *infos, const MLTypeData* sourceData, MLint shiftLeft, MLTypeData* targetData);
779
780
792MLEXPORT void MLTypeCastToOtherType(const MLTypeInfos* otherInfos, const MLTypeData* otherData,
793 const MLTypeInfos* myInfos, MLTypeData* myData);
794
797MLEXPORT void MLTypeCastFromOtherType(const MLTypeInfos* otherInfos, const MLTypeData* otherData,
798 const MLTypeInfos* myInfos, MLTypeData* myData);
799
804MLEXPORT void MLTypeMultWithOtherType(const MLTypeInfos* myInfos, const MLTypeData* myData,
805 const MLTypeInfos* otherInfos, const MLTypeData* otherData,
806 MLTypeData* targetData);
808
809// C-Link interface off.
810#ifdef __cplusplus
811}
812#endif
813
814#endif //of __mlDataTypes_H
MLEXPORT MLDataType MLGetDataTypeForUncorrectedRange(MLdouble min, MLdouble max, MLint32 preferUnsigned)
MLEXPORT size_t MLSizeOf(MLDataType dataType)
MLEXPORT MLint32 MLIsValidType(MLDataType dataType)
MLEXPORT MLDataType MLTypeGetBestScalarTypeForTypeComponentChars(const char *charCodes, int suppressML64BitInts, int suppressMLldouble)
MLEXPORT MLDataType MLGetIntegerDataTypeForRange(double rangeMin, double rangeMax)
MLEXPORT MLTypeGroup MLGetTypeGroup(MLDataType dataType)
MLEXPORT MLint32 MLHolds(MLDataType datatype1, MLDataType datatype2)
MLEXPORT const char * MLTypeGetStructInfoString(MLDataType dataType)
MLint32 MLDataType
Definition mlTypeDefs.h:595
MLEXPORT MLint32 MLRangeOrder(MLDataType dataType)
MLEXPORT MLint32 MLIsStandardType(MLDataType dataType)
MLEXPORT size_t MLSizeOfRegisteredType(MLDataType dataType)
Compatibility function - obsolete, use MLSizeOf instead!
MLEXPORT MLDataType MLGetPromotedPrecision(MLDataType datatype1, MLDataType datatype2)
MLEXPORT MLdouble MLDataTypeMin(MLDataType dataType)
MLEXPORT size_t MLNumDataTypes()
MLEXPORT MLDataType MLGetDataTypeForRange(MLdouble *min, MLdouble *max, MLint32 preferUnsigned)
MLEXPORT MLDataType MLGetPromotedTypeWithRange2Inputs(MLDataType inputType1, MLDataType inputType2, double rangeMin, double rangeMax)
Convenience function for MLGetPromotedTypeWithRange with two inputs.
MLEXPORT MLint32 MLIsDefaultExtendedType(MLDataType dataType)
MLEXPORT MLint32 MLIsIntType(MLDataType dataType)
MLEXPORT MLDataType MLDataTypeFromName(const char *const name)
MLEXPORT MLDataType MLGetPromotedTypeWithRange(const MLDataType *inputTypes, size_t numTypes, double rangeMin, double rangeMax)
MLEXPORT MLint32 MLIsScalarType(MLDataType dataType)
MLEXPORT MLDataType MLGetPromotedTypeWithRange1Input(MLDataType inputType1, double rangeMin, double rangeMax)
Convenience function for MLGetPromotedTypeWithRange with one input.
MLEXPORT MLDataType MLGetPromotedTypeWithRange3Inputs(MLDataType inputType1, MLDataType inputType2, MLDataType inputType3, double rangeMin, double rangeMax)
Convenience function for MLGetPromotedTypeWithRange with three inputs.
MLEXPORT MLdouble MLDataTypeMax(MLDataType dataType)
MLEXPORT MLint32 MLIsSigned(MLDataType dataType)
MLEXPORT MLDataType MLTypeGetBestScalarTypeForTypeComponents(MLDataType dataType, int suppressML64BitInts, int suppressMLldouble)
MLEXPORT MLint32 MLIsFloatType(MLDataType dataType)
MLEXPORT const char * MLNameFromDataType(MLDataType dataType)
MLEXPORT MLErrorCode MLClampIntervalToDataTypeRange(double intervalMin, double intervalMax, MLDataType dataType, double *resultIntervalMin, double *resultIntervalMax)
MLEXPORT size_t MLTypeGetNumComponents(MLDataType dataType)
MLEXPORT MLDataType MLGetRangeAndPrecisionEquivalent(MLDataType dataType)
MLEXPORT MLDataType MLGetPromotedType(MLDataType datatype1, MLDataType datatype2)
MLEXPORT const char *const * MLDataTypeNames()
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:715
MLEXPORT const MLTypePropertyBits MLTypeHasNormalize
A data type instance can be normalized.
MLEXPORT MLdouble MLGetVoxelValueAsDouble(const void *data, MLDataType dataType, MLErrorCode *errorCode)
MLEXPORT MLint32 MLTypeComponentsFromString(const MLTypeInfos *infos, const char *stringData, const MLTypeData *defaultValue, MLTypeData *data)
MLEXPORT const MLTypePropertyBits MLTypeHasSetToMinimum
The setToMinimum function is implemented. (Note: This function must be implemented....
MLEXPORT void MLTypeToggleEndianType(const MLTypeInfos *infos, const MLTypeData *sourceBufferPointer, MLTypeData *targetBufferPointer, size_t numInstances)
MLEXPORT void MLTypeMultWithOtherType(const MLTypeInfos *myInfos, const MLTypeData *myData, const MLTypeInfos *otherInfos, const MLTypeData *otherData, MLTypeData *targetData)
MLEXPORT size_t MLGetNumRegisteredTypeInfos()
Returns the number of registered type operations.
MLEXPORT const MLTypePropertyBits MLTypeHasPlusType
Two data type instances can be added.
MLEXPORT void MLTypeCastFromOtherType(const MLTypeInfos *otherInfos, const MLTypeData *otherData, const MLTypeInfos *myInfos, MLTypeData *myData)
MLEXPORT const MLTypePropertyBits MLTypeHasIsEqualToType
An equality relation between two type instances can be calculated. (Note: This function must be imple...
MLEXPORT void MLTypeCastFromDouble(const MLTypeInfos *infos, MLdouble doubleValue, MLTypeData *data)
The value doubleValue is cast to the types of the components and then written to them.
MLEXPORT MLint32 MLInitializeTypes()
MLEXPORT const MLTypePropertyBits MLTypeHasPlusInt
A data type instance and an integer can be added.
MLEXPORT const MLTypePropertyBits MLTypeScalarType
A data type has all standard properties of a scalar type.
MLEXPORT const MLTypePropertyBits MLTypeHasCastToInt
A data type instance can be cast to integer.
MLEXPORT const MLTypePropertyBits MLTypeHasMultWithDouble
Data type instance can be multiplied with double.
MLEXPORT const MLTypePropertyBits MLTypeIsSignedType
The data type is signed.
MLEXPORT MLdouble MLTypeCastToDouble(const MLTypeInfos *infos, const MLTypeData *data)
The first component of the data type is converted to double and returned.
MLEXPORT void MLTypeCastToOtherType(const MLTypeInfos *otherInfos, const MLTypeData *otherData, const MLTypeInfos *myInfos, MLTypeData *myData)
MLEXPORT bool MLTypeCastToBool(const MLTypeInfos *infos, const MLTypeData *data)
If data is identical to default element false (= 0) is returned, otherwise true (= 1).
MLEXPORT MLDataType MLGetMLDataTypeForCharCode(char code)
MLEXPORT MLTypeData * MLTypeInfosCreateBuffer(const MLTypeInfos *infos)
Returns a buffer of the size of one data element. NULL is returned on failure.
MLEXPORT const MLTypePropertyBits MLTypeHasMultWithInt
Data type instance can be multiplied with integer.
MLEXPORT const char * MLGetMLDataTypeNameForCharCode(char code)
MLEXPORT void MLTypeShiftComponentsLeft(const MLTypeInfos *infos, const MLTypeData *sourceData, MLint shiftLeft, MLTypeData *targetData)
MLEXPORT const MLTypePropertyBits MLTypeHasSetToDefault
The setToDefault function is implemented. (Note: This function must be implemented....
MLEXPORT void MLTypeSetIntComponent(char component, MLint value, MLTypeData *targetPointer)
Like MLTypeSetDoubleComponent, only components are set to integer values.
MLEXPORT char * MLTypeComponentsToString(const MLTypeInfos *infos, const MLTypeData *data)
MLEXPORT void MLTypeSetAllIntComponent(const MLTypeInfos *infos, MLint value, MLTypeData *targetPointer)
Like MLTypeSetAllDoubleComponents, only components are set to integer values.
MLEXPORT const MLTypePropertyBits MLTypeHasSetToMaximum
The setToMaximum function is implemented. (Note: This function must be implemented....
MLEXPORT const MLTypePropertyBits MLTypeIsIntegerType
The data type is an integer type. False otherwise.
MLEXPORT const MLTypePropertyBits MLTypeHasCastFromDouble
A double can be cast to a data type instance.
MLEXPORT MLint32 MLRegisterStaticTypeInfos(MLTypeInfos *infos, MLDataType dt)
Version of the method that allows to specify a pre-defined data type value.
MLEXPORT MLTypeData * MLTypeGetDataValuesFromString(MLDataType dataType, const char *voxelValue, const MLTypeData *defaultValue, size_t numInstances)
MLEXPORT MLErrorCode MLTypeGetMinMaxRangeOfComponents(const MLTypeInfos *infos, const MLTypeData *srcPtr, MLdouble *retMin, MLdouble *retMax)
MLEXPORT const MLTypePropertyBits MLTypeHasSetStringValue
The function setStringValue is implemented. (Note: This function must be implemented....
MLEXPORT size_t MLTypeComponentSize(char component)
MLEXPORT const MLTypePropertyBits MLTypeHasCastToDouble
A data type instance can be cast to double.
MLEXPORT MLTypePropertyBits MLTypePropBitsXor(MLTypePropertyBits propertyBits, MLTypePropertyBits mask)
Inverts all set bits from propertyBits that are set in mask.
MLEXPORT const MLTypePropertyBits MLTypeHasGetStringValue
The function getStringValue is implemented. (Note: This function must be implemented....
MLEXPORT void MLTypeConvertToLittleEndian(const MLTypeInfos *infos, const MLTypeData *sourceBufferPointer, MLTypeData *targetBufferPointer, size_t numInstances)
MLEXPORT MLint32 MLRegisterTypeInfos(MLTypeInfos *infos)
MLEXPORT char * MLGetVoxelValueAsString(const MLTypeData *data, MLDataType dataType, MLErrorCode *errorCode)
MLEXPORT const char * MLGetCDataTypeNameForCharCode(char code)
MLEXPORT void MLTypeCastFromInt(const MLTypeInfos *infos, MLint intValue, MLTypeData *data)
The integer value of intValue is cast to the types of the components and then written to them.
MLEXPORT MLint32 MLTypeGetComponentProperties(char code, MLint32 *isSigned, MLint32 *isIntegerType, MLint32 *isFloatingPointType, MLint32 *isLongType)
MLEXPORT MLint MLTypeCastToInt(const MLTypeInfos *infos, const MLTypeData *data)
The first component of the data type is converted to integer and returned.
MLEXPORT void MLTypeCorrectPropertyBits(MLTypeInfos *infos)
MLEXPORT const MLTypePropertyBits MLTypeIsStandardType
The data type is standard scalar data type(intUL, floatUL, charUL, ...).
MLEXPORT const MLTypePropertyBits MLTypeHasMultWithType
Two data type instances can be multiplied.
MLEXPORT MLTypeData * MLAllocateVoxelBuffer(MLDataType dataType, size_t numVoxels, const MLTypeData *voxelDefaultValue)
MLEXPORT const MLTypePropertyBits MLTypeHasCastFromOtherType
Any data type instance can be cast a data type instance.
MLEXPORT const MLTypePropertyBits MLTypeHasCastToBool
A data type instance can be cast to bool.
MLEXPORT const MLTypePropertyBits MLTypeHasCopy
Copies parameter one to parameter two. (Note: This function must be implemented.).
MLEXPORT const MLTypePropertyBits MLTypeHasNegate
The negative value of a data type instance can be calculated.
MLEXPORT const MLTypePropertyBits MLTypeIsFloatingPointType
The data type is a floating point type. False otherwise.
MLEXPORT char * MLGetVoxelValueAsStringLimited(const MLTypeData *data, MLDataType dataType, MLErrorCode *errorCode, int maxPrecision)
MLEXPORT void MLTypeInfosRemoveBuffer(MLTypeData *buffer)
Removes a buffer created with MLTypeInfosCreateBuffer.
MLEXPORT void MLTypeCastFromBool(const MLTypeInfos *infos, bool boolValue, MLTypeData *data)
MLEXPORT const MLTypePropertyBits MLTypeIsDefaultType
The data type is one of the default types (standard scalar or default extended).
MLEXPORT MLint32 MLAreTypesInitialized()
Returns 1 (=true) if type table is initialized, otherwise 0 (=false).
MLEXPORT const MLTypePropertyBits MLTypeHasNoProperties
The data type has no standard properties.
MLEXPORT void MLDestroyTypes()
Destroy ML type management.
MLEXPORT void MLTypeConvertToBigEndian(const MLTypeInfos *infos, const MLTypeData *sourceBufferPointer, MLTypeData *targetBufferPointer, size_t numInstances)
MLEXPORT MLint32 MLIsRegisteredTypeInfos(const MLTypeInfos *infos)
Returns 1 (=true) if the data type is already registered. Otherwise, 0 (=false) is returned.
MLEXPORT char * MLTypeComponentsToStringLimited(const MLTypeInfos *infos, const MLTypeData *data, int maxPrecision)
MLEXPORT void MLTypeSetAllDoubleComponents(const MLTypeInfos *infos, MLdouble value, MLTypeData *targetPointer)
MLEXPORT const MLTypePropertyBits MLTypeHasCastFromInt
An integer can be cast to a data type instance.
MLEXPORT MLdouble MLTypeGetDoubleComponent(char component, const MLTypeData *targetPointer)
MLEXPORT const MLTypePropertyBits MLTypeHasMultWithOtherType
A data type instances can be multiplied with the one of another type.
MLEXPORT MLTypePropertyBits MLTypePropBitsAnd(MLTypePropertyBits propertyBits, MLTypePropertyBits mask)
AND operation of all bits in mask and those in propertyBits.
MLEXPORT MLint32 MLTypeInfosInit(MLTypeInfos *infos, size_t typeSize, const char *name, MLdouble dblMin, MLdouble dblMax, const MLTypeData *typeMinPtr, const MLTypeData *typeMaxPtr, const MLTypeData *typeDefaultPtr, const char *typeStructInfo, MLint32 isScalarType, MLTypeGroup typeGroup, MLDataType rangeAndPrecisionEquiv, void **componentAddresses, size_t numGoodCastTos, const char **goodCastTos)
MLEXPORT void MLTypeSetDoubleComponent(char component, MLdouble value, MLTypeData *targetPointer)
MLEXPORT MLint MLTypeGetIntComponent(char component, const MLTypeData *targetPointer)
Like MLTypeGetComponent, only that the components is returned as integer values.
MLEXPORT MLTypeInfos * MLGetTypeInfosForDataType(MLDataType dataType)
MLEXPORT MLint32 MLTypePropBitsTest(MLTypePropertyBits propertyBits, MLTypePropertyBits mask)
Returns true (=1) if bit mask mask is part of propertyBits; otherwise, it return false (=0).
MLEXPORT const MLTypePropertyBits MLTypeHasCastToOtherType
A data type instance can be cast to another type.
MLEXPORT MLint32 MLTypeComponentsFromStream(void *iStr, void *iStrStream, void *stdiStr, void *stdiStrStream, const MLTypeInfos *infos, MLTypeData *data)
MLEXPORT MLTypePropertyBits MLTypePropBitsOr(MLTypePropertyBits propertyBits, MLTypePropertyBits mask)
Adds all set bits in mask to those in propertyBits.
MLEXPORT const MLTypePropertyBits MLTypeHasPlusDouble
A data type instance and a double can be added.
MLEXPORT void MLTypeSetDefaultFunctionPointers(MLTypeInfos *infos)
MLEXPORT MLTypeInfos * MLGetTypeInfosAtIndex(size_t index)
Returns the index th registered type operation, NULL on invalid index.
#define MLEXPORT
Code it as import symbol if compiled elsewhere.
MLuint64 MLTypePropertyBits
Structure to define a bit mask that identifies all implemented functions for a data type.
double MLdouble
Definition mlTypeDefs.h:216
unsigned char MLTypeData
This is the pointer type used to point to the data of MLType data instances.
MLint64 MLint
Definition mlTypeDefs.h:489
signed int MLint32
Definition mlTypeDefs.h:160
MLint32 MLTypeGroup