MeVisLab Toolbox Reference
|
Go to the source code of this file.
Functions | |
TYPE SYSTEM INITIALIZATION. | |
Defines basic datatypes, constants, and macros for MeVis projects. This file also contains code that is used to implement new datatypes for the ML. There are also many convenience functions to simplify that. To register a new data type, it is required to implement a set of type operations as static functions. Pointers to those functions are stored in a single MLTypeInfos structure and then registered in the ML with the command MLRegisterTypeInfos. | |
MLEXPORT MLint32 | MLAreTypesInitialized () |
Returns 1 (=true) if type table is initialized, otherwise 0 (=false). More... | |
MLEXPORT MLint32 | MLInitializeTypes () |
Initialize all ML type management. More... | |
MLEXPORT void | MLDestroyTypes () |
Destroy ML type management. More... | |
DATA TYPE MANAGEMENT. | |
Thread-safety: These functions are thread-safe, as long as no new datatypes are registered after startup. | |
MLEXPORT const char *const * | MLDataTypeNames () |
Function that returns the table of C-strings of all scalar and registered datatypes. More... | |
MLEXPORT size_t | MLNumDataTypes () |
Returns the current number of ML datatypes. More... | |
MLEXPORT const char * | MLNameFromDataType (MLDataType dataType) |
Function that returns the NULL-terminated string name for data type dataType or "" in case of error or for an invalid data type. More... | |
MLEXPORT MLDataType | MLDataTypeFromName (const char *const name) |
Returns the ID of the data type with name name. More... | |
MLEXPORT MLdouble | MLDataTypeMax (MLDataType dataType) |
Returns the maximum value of data type dataType or 0 if dataType is invalid. More... | |
MLEXPORT MLdouble | MLDataTypeMin (MLDataType dataType) |
Returns the minimum value of data type dataType or 0 if dataType is invalid. More... | |
MLEXPORT size_t | MLSizeOf (MLDataType dataType) |
Returns the size of the data type dataType in bytes. More... | |
MLEXPORT size_t | MLSizeOfRegisteredType (MLDataType dataType) |
Compatibility function - obsolete, use MLSizeOf instead! More... | |
MLEXPORT MLint32 | MLRangeOrder (MLDataType dataType) |
Returns the order value for a data type ranges. More... | |
MLEXPORT MLint32 | MLIsValidType (MLDataType dataType) |
Returns true (=1) if data type dataType seems to be valid, otherwise 0 (=false). More... | |
MLEXPORT MLint32 | MLIsSigned (MLDataType dataType) |
Returns true (=1) if data type dataType is signed, otherwise 0 (=false). More... | |
MLEXPORT MLint32 | MLIsIntType (MLDataType dataType) |
Returns true (=1) if data type dataType is an integer data type, otherwise false (=0). More... | |
MLEXPORT MLint32 | MLIsFloatType (MLDataType dataType) |
Returns true (=1) if data type dataType is a floating point data type, otherwise false (=0). More... | |
MLEXPORT MLint32 | MLIsStandardType (MLDataType dataType) |
Returns true (=1) if data type dataType is a standard (scalar) type, otherwise return false (=0). More... | |
MLEXPORT MLint32 | MLIsScalarType (MLDataType dataType) |
Alternative name for MLIsStandardType. More... | |
MLEXPORT MLint32 | MLIsDefaultExtendedType (MLDataType dataType) |
Returns true (=1) if data type dataType is one of the extended types that should be support out of the box; otherwise. More... | |
MLEXPORT MLTypeGroup | MLGetTypeGroup (MLDataType dataType) |
Get the type group to which the given type belongs. More... | |
MLEXPORT MLDataType | MLGetPromotedTypeWithRange (const MLDataType *inputTypes, size_t numTypes, double rangeMin, double rangeMax) |
Routine for type promotion that takes a list of input types and the target value range to find a resulting data type. More... | |
MLEXPORT MLDataType | MLGetPromotedTypeWithRange1Input (MLDataType inputType1, double rangeMin, double rangeMax) |
Convenience function for MLGetPromotedTypeWithRange with one input. More... | |
MLEXPORT MLDataType | MLGetPromotedTypeWithRange2Inputs (MLDataType inputType1, MLDataType inputType2, double rangeMin, double rangeMax) |
Convenience function for MLGetPromotedTypeWithRange with two inputs. More... | |
MLEXPORT MLDataType | MLGetPromotedTypeWithRange3Inputs (MLDataType inputType1, MLDataType inputType2, MLDataType inputType3, double rangeMin, double rangeMax) |
Convenience function for MLGetPromotedTypeWithRange with three inputs. More... | |
MLEXPORT MLint32 | MLHolds (MLDataType datatype1, MLDataType datatype2) |
Returns true (=1) if data type \ datatype1 can hold data type datatype2 without precision or sign loss. More... | |
MLEXPORT MLDataType | MLGetPromotedType (MLDataType datatype1, MLDataType datatype2) |
Returns a data type that can hold the value ranges from datatype1 and datatype2 (including both). More... | |
MLEXPORT MLDataType | MLGetIntegerDataTypeForRange (double rangeMin, double rangeMax) |
Returns the minimal integer type that can hold the given range. More... | |
MLEXPORT MLDataType | MLGetDataTypeForRange (MLdouble *min, MLdouble *max, MLint32 preferUnsigned) |
Corrects the order of *min and *max and returns an adequate standard data type. More... | |
MLEXPORT MLDataType | MLGetDataTypeForUncorrectedRange (MLdouble min, MLdouble max, MLint32 preferUnsigned) |
Like getMLDataTypeForRange with the following differences: More... | |
MLEXPORT MLDataType | MLGetRangeAndPrecisionEquivalent (MLDataType dataType) |
Returns a standard data type for dataType that has comparable precision and range behavior. More... | |
MLEXPORT MLDataType | MLGetPromotedPrecision (MLDataType datatype1, MLDataType datatype2) |
Returns one of datatype1 and datatype2 that has higher precision. More... | |
MLEXPORT MLErrorCode | MLClampIntervalToDataTypeRange (double intervalMin, double intervalMax, MLDataType dataType, double *resultIntervalMin, double *resultIntervalMax) |
Clamps the given lower/upper interval to the data type's range and checks whether the interval is completely outside of data type's range. More... | |
MLEXPORT size_t | MLTypeGetNumComponents (MLDataType dataType) |
Returns the number of components of the data type data type or 0 in case of an invalid data type. More... | |
MLEXPORT const char * | MLTypeGetStructInfoString (MLDataType dataType) |
Returns the components codes of the data type dataType or "" in case of an invalid data type. More... | |
MLEXPORT MLDataType | MLTypeGetBestScalarTypeForTypeComponentChars (const char *charCodes, int suppressML64BitInts, int suppressMLldouble) |
Returns a standard data type that is able to hold the precisions of each of the type component characters passed as charCodes . More... | |
MLEXPORT MLDataType | MLTypeGetBestScalarTypeForTypeComponents (MLDataType dataType, int suppressML64BitInts, int suppressMLldouble) |
Returns a standard data type that is able to hold the precisions of each of the components of the type dataType . More... | |
MLTypePropertyBits handling. | |
MLEXPORT MLint32 | MLTypePropBitsTest (MLTypePropertyBits propertyBits, MLTypePropertyBits mask) |
Returns true (=1) if bit mask mask is part of propertyBits ; otherwise, it return false (=0). More... | |
MLEXPORT MLTypePropertyBits | MLTypePropBitsAnd (MLTypePropertyBits propertyBits, MLTypePropertyBits mask) |
AND operation of all bits in mask and those in propertyBits . More... | |
MLEXPORT MLTypePropertyBits | MLTypePropBitsOr (MLTypePropertyBits propertyBits, MLTypePropertyBits mask) |
Adds all set bits in mask to those in propertyBits . More... | |
MLEXPORT MLTypePropertyBits | MLTypePropBitsXor (MLTypePropertyBits propertyBits, MLTypePropertyBits mask) |
Inverts all set bits from propertyBits that are set in mask . More... | |
REGISTRATION OF NEW DATA TYPES. | |
MLEXPORT MLint32 | MLRegisterTypeInfos (MLTypeInfos *infos) |
Adds the data type class information to the list of registered datatypes. More... | |
MLEXPORT MLint32 | MLRegisterStaticTypeInfos (MLTypeInfos *infos, MLDataType dt) |
Version of the method that allows to specify a pre-defined data type value. More... | |
MLEXPORT MLint32 | MLIsRegisteredTypeInfos (const MLTypeInfos *infos) |
Returns 1 (=true) if the data type is already registered. Otherwise, 0 (=false) is returned. More... | |
MLEXPORT size_t | MLGetNumRegisteredTypeInfos () |
Returns the number of registered type operations. More... | |
MLEXPORT MLTypeInfos * | MLGetTypeInfosAtIndex (size_t index) |
Returns the index th registered type operation, NULL on invalid index. More... | |
MLEXPORT MLTypeInfos * | MLGetTypeInfosForDataType (MLDataType dataType) |
Returns the MLTypeInfos for the data type dataType , or NULL on non-registered or invalid type. More... | |
MLType support. | |
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) |
Initialization of the main properties of MLTypeInfos. More... | |
MLEXPORT MLTypeData * | MLTypeInfosCreateBuffer (const MLTypeInfos *infos) |
Returns a buffer of the size of one data element. NULL is returned on failure. More... | |
MLEXPORT void | MLTypeInfosRemoveBuffer (MLTypeData *buffer) |
Removes a buffer created with MLTypeInfosCreateBuffer. More... | |
MLEXPORT void | MLTypeCorrectPropertyBits (MLTypeInfos *infos) |
Corrects all property bits except for the basic properties [MLTypeIsSignedType, MLTypeIsFloatingPointType, MLTypeIsIntegerType, MLIsBasicType]. More... | |
MLEXPORT void | MLTypeSetDefaultFunctionPointers (MLTypeInfos *infos) |
Sets all function pointers to default values that perform error handling when called. More... | |
MLEXPORT void | MLTypeToggleEndianType (const MLTypeInfos *infos, const MLTypeData *sourceBufferPointer, MLTypeData *targetBufferPointer, size_t numInstances) |
Converts data type instances from little endian to big endian or vice versa. More... | |
MLEXPORT void | MLTypeConvertToLittleEndian (const MLTypeInfos *infos, const MLTypeData *sourceBufferPointer, MLTypeData *targetBufferPointer, size_t numInstances) |
Converts data type instances from big endian to little endian. More... | |
MLEXPORT void | MLTypeConvertToBigEndian (const MLTypeInfos *infos, const MLTypeData *sourceBufferPointer, MLTypeData *targetBufferPointer, size_t numInstances) |
Converts data type instances from little endian to big endian. More... | |
MLType components. | |
MLEXPORT const char * | MLGetCDataTypeNameForCharCode (char code) |
Returns the basic C/C++ data type name corresponding to a character representing it. More... | |
MLEXPORT const char * | MLGetMLDataTypeNameForCharCode (char code) |
Returns an ML type name type name compatible to a character representing it. More... | |
MLEXPORT MLDataType | MLGetMLDataTypeForCharCode (char code) |
Returns an ML data type compatible to a character representing it. More... | |
MLEXPORT MLint32 | MLTypeGetComponentProperties (char code, MLint32 *isSigned, MLint32 *isIntegerType, MLint32 *isFloatingPointType, MLint32 *isLongType) |
Returns true (=1) in *isSigned , *isIntegerType , *isFloatingPointType , and *isLongType if the component type represented by code has this features; otherwise, set that flag to false (=0). More... | |
MLEXPORT size_t | MLTypeComponentSize (char component) |
Returns the sizeof of a MLTypeComponent component denoted by a character code. More... | |
MLEXPORT void | MLTypeSetDoubleComponent (char component, MLdouble value, MLTypeData *targetPointer) |
Interprets the data referenced by *targetPointer as data of the type component and sets its value from the passed double value by casting the value to it. More... | |
MLEXPORT void | MLTypeSetIntComponent (char component, MLint value, MLTypeData *targetPointer) |
Like MLTypeSetDoubleComponent, only components are set to integer values. More... | |
MLEXPORT void | MLTypeSetAllDoubleComponents (const MLTypeInfos *infos, MLdouble value, MLTypeData *targetPointer) |
All components of the data referenced by *targetPointer are set to their values cast from the double value . More... | |
MLEXPORT void | MLTypeSetAllIntComponent (const MLTypeInfos *infos, MLint value, MLTypeData *targetPointer) |
Like MLTypeSetAllDoubleComponents, only components are set to integer values. More... | |
MLEXPORT MLdouble | MLTypeGetDoubleComponent (char component, const MLTypeData *targetPointer) |
Interprets the data referenced by *targetPointer as data of the type component and returns it as double value. More... | |
MLEXPORT MLint | MLTypeGetIntComponent (char component, const MLTypeData *targetPointer) |
Like MLTypeGetComponent, only that the components is returned as integer values. More... | |
MLEXPORT MLErrorCode | MLTypeGetMinMaxRangeOfComponents (const MLTypeInfos *infos, const MLTypeData *srcPtr, MLdouble *retMin, MLdouble *retMax) |
Returns the minimum/maximum range of all components of an arbitrary registered voxel. More... | |
Convenience implementations and helpers for implementation of new datatypes. | |
MLEXPORT MLTypeData * | MLAllocateVoxelBuffer (MLDataType dataType, size_t numVoxels, const MLTypeData *voxelDefaultValue) |
Returns a buffer of numVoxels voxels of data type dataType . More... | |
MLEXPORT char * | MLGetVoxelValueAsString (const MLTypeData *data, MLDataType dataType, MLErrorCode *errorCode) |
Interprets the data given by data as a value of type dataType and returns its value as string. More... | |
MLEXPORT char * | MLGetVoxelValueAsStringLimited (const MLTypeData *data, MLDataType dataType, MLErrorCode *errorCode, int maxPrecision) |
Interprets the data given by data as a value of type dataType and returns its value as string. More... | |
MLEXPORT char * | MLTypeComponentsToString (const MLTypeInfos *infos, const MLTypeData *data) |
Converts a data type instance to a string. More... | |
MLEXPORT char * | MLTypeComponentsToStringLimited (const MLTypeInfos *infos, const MLTypeData *data, int maxPrecision) |
Converts a data type instance to a string. More... | |
MLEXPORT MLint32 | MLTypeComponentsFromString (const MLTypeInfos *infos, const char *stringData, const MLTypeData *defaultValue, MLTypeData *data) |
Converts a string of a data type instance to instance data, i.e., similar to sscanf. More... | |
MLEXPORT MLTypeData * | MLTypeGetDataValuesFromString (MLDataType dataType, const char *voxelValue, const MLTypeData *defaultValue, size_t numInstances) |
Allocates a buffer for numInstances of data type dataType and fills it with the data type value converted from the NULL-terminated string voxValue . More... | |
MLEXPORT MLint32 | MLTypeComponentsFromStream (void *iStr, void *iStrStream, void *stdiStr, void *stdiStrStream, const MLTypeInfos *infos, MLTypeData *data) |
Reads data type components into different stream versions (istream and istrstream within and outside the standard namespace). More... | |
MLEXPORT MLdouble | MLGetVoxelValueAsDouble (const void *data, MLDataType dataType, MLErrorCode *errorCode) |
Interprets the data given by data as a value of type dataType and returns its value cast to double. More... | |
MLEXPORT bool | MLTypeCastToBool (const MLTypeInfos *infos, const MLTypeData *data) |
If data is identical to default element false (= 0) is returned, otherwise true (= 1). More... | |
MLEXPORT MLint | MLTypeCastToInt (const MLTypeInfos *infos, const MLTypeData *data) |
The first component of the data type is converted to integer and returned. More... | |
MLEXPORT MLdouble | MLTypeCastToDouble (const MLTypeInfos *infos, const MLTypeData *data) |
The first component of the data type is converted to double and returned. More... | |
MLEXPORT void | MLTypeCastFromBool (const MLTypeInfos *infos, bool boolValue, MLTypeData *data) |
If boolValue == 0, data is set to the type default value given by infos . More... | |
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. More... | |
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. More... | |
MLEXPORT void | MLTypeShiftComponentsLeft (const MLTypeInfos *infos, const MLTypeData *sourceData, MLint shiftLeft, MLTypeData *targetData) |
Takes one data type component after another and shifts each component left shiftLeft times if it is an integer component. More... | |
MLEXPORT void | MLTypeCastToOtherType (const MLTypeInfos *otherInfos, const MLTypeData *otherData, const MLTypeInfos *myInfos, MLTypeData *myData) |
Converts a data instance referenced by otherData of a type specified by otherInfos to another data instance referenced by *myData of a type specified by myInfos . More... | |
MLEXPORT void | MLTypeCastFromOtherType (const MLTypeInfos *otherInfos, const MLTypeData *otherData, const MLTypeInfos *myInfos, MLTypeData *myData) |
Casts another data element otherData with attributes given by otherInfos to myData of a type given by myInfos . More... | |
MLEXPORT void | MLTypeMultWithOtherType (const MLTypeInfos *myInfos, const MLTypeData *myData, const MLTypeInfos *otherInfos, const MLTypeData *otherData, MLTypeData *targetData) |
Casts another data element otherData with attributes given by otherInfos to a local buffer of a type given by myInfos . More... | |
Variables | |
Property bits that describe functions eventually implemented in MLTypeOperatorFunctions. | |
MLEXPORT const MLTypePropertyBits | MLTypeHasNoProperties |
The data type has no standard properties. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasGetStringValue |
The function getStringValue is implemented. (Note: This function must be implemented.) More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasSetStringValue |
The function setStringValue is implemented. (Note: This function must be implemented.) More... | |
MLEXPORT const MLTypePropertyBits | MLTypeIsDefaultType |
The data type is one of the default types (standard scalar or default extended). More... | |
MLEXPORT const MLTypePropertyBits | MLTypeIsSignedType |
The data type is signed. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeIsFloatingPointType |
The data type is a floating point type. False otherwise. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeIsIntegerType |
The data type is an integer type. False otherwise. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeIsStandardType |
The data type is standard scalar data type(intUL, floatUL, charUL, ...). More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasSetToMinimum |
The setToMinimum function is implemented. (Note: This function must be implemented.) More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasSetToMaximum |
The setToMaximum function is implemented. (Note: This function must be implemented.) More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasSetToDefault |
The setToDefault function is implemented. (Note: This function must be implemented.) More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasCopy |
Copies parameter one to parameter two. (Note: This function must be implemented.) More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasCastToBool |
A data type instance can be cast to bool. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasCastToInt |
A data type instance can be cast to integer. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasCastToDouble |
A data type instance can be cast to double. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasCastToOtherType |
A data type instance can be cast to another type. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasCastFromInt |
An integer can be cast to a data type instance. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasCastFromDouble |
A double can be cast to a data type instance. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasCastFromOtherType |
Any data type instance can be cast a data type instance. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasNegate |
The negative value of a data type instance can be calculated. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasNormalize |
A data type instance can be normalized. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasIsEqualToType |
An equality relation between two type instances can be calculated. (Note: This function must be implemented.) More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasMultWithInt |
Data type instance can be multiplied with integer. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasMultWithDouble |
Data type instance can be multiplied with double. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasMultWithType |
Two data type instances can be multiplied. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasMultWithOtherType |
A data type instances can be multiplied with the one of another type. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasPlusInt |
A data type instance and an integer can be added. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasPlusDouble |
A data type instance and a double can be added. More... | |
MLEXPORT const MLTypePropertyBits | MLTypeHasPlusType |
Two data type instances can be added. More... | |
Bit masks specifying general properties of a data type. | |
MLEXPORT const MLTypePropertyBits | MLTypeScalarType |
A data type has all standard properties of a scalar type. More... | |
MLEXPORT MLTypeData* MLAllocateVoxelBuffer | ( | MLDataType | dataType, |
size_t | numVoxels, | ||
const MLTypeData * | voxelDefaultValue | ||
) |
Returns a buffer of numVoxels
voxels of data type dataType
.
On failure, NULL is returned. If voxelDefaultValue
is NULL, the allocated memory is left undefined; otherwise, all voxels are filled with the the default value pointed to by voxelDefaultValue
. The allocated buffer must be removed with MLFree().
Returns 1 (=true) if type table is initialized, otherwise 0 (=false).
MLEXPORT void MLDestroyTypes | ( | ) |
Destroy ML type management.
MLEXPORT const char* MLGetCDataTypeNameForCharCode | ( | char | code | ) |
Returns the basic C/C++ data type name corresponding to a character representing it.
On an invalid code
, "" is returned.
MLEXPORT MLDataType MLGetMLDataTypeForCharCode | ( | char | code | ) |
Returns an ML data type compatible to a character representing it.
On an invalid code
, ML_INVALID_DATA_TYPE is returned.
MLEXPORT const char* MLGetMLDataTypeNameForCharCode | ( | char | code | ) |
Returns an ML type name type name compatible to a character representing it.
On an invalid code
, "" is returned. The return value matches for function calls to MLDataTypeFromName().
MLEXPORT size_t MLGetNumRegisteredTypeInfos | ( | ) |
Returns the number of registered type operations.
MLEXPORT MLTypeInfos* MLGetTypeInfosAtIndex | ( | size_t | index | ) |
Returns the index
th registered type operation, NULL on invalid index.
MLEXPORT MLTypeInfos* MLGetTypeInfosForDataType | ( | MLDataType | dataType | ) |
Returns the MLTypeInfos for the data type dataType
, or NULL on non-registered or invalid type.
Referenced by ml::SubImage::getDataTypeInfos().
MLEXPORT MLdouble MLGetVoxelValueAsDouble | ( | const void * | data, |
MLDataType | dataType, | ||
MLErrorCode * | errorCode | ||
) |
Interprets the data given by data
as a value of type dataType
and returns its value cast to double.
If something fails, 0 is returned. errorCode
may be passed as NULL. If errorCode
is not NULL, *errorCode
is set to the error code on failures; otherwise it is set to ML_RESULT_OK.
MLEXPORT char* MLGetVoxelValueAsString | ( | const MLTypeData * | data, |
MLDataType | dataType, | ||
MLErrorCode * | errorCode | ||
) |
Interprets the data given by data
as a value of type dataType
and returns its value as string.
If something fails, "" is returned. errorCode
may be passed as NULL. If errorCode
is not NULL, *errorCode
is set to the error code on failures; otherwise, it is set to ML_RESULT_OK. Floating point values are normally printed with maximum precision. The returned pointer must be freed with MLFree().
MLEXPORT char* MLGetVoxelValueAsStringLimited | ( | const MLTypeData * | data, |
MLDataType | dataType, | ||
MLErrorCode * | errorCode, | ||
int | maxPrecision | ||
) |
Interprets the data given by data
as a value of type dataType
and returns its value as string.
If something fails, "" is returned. errorCode
may be passed as NULL. If errorCode
is not NULL, *errorCode
is set to the error code on failures; otherwise, it is set to ML_RESULT_OK. If maxPrecision
is passed with values smaller than 0, then maximum precision of floating point numbers is printed. If passed >= 0, then the number of digits is limited to maxPrecision
. It will be not larger than the maximum default precision even if specified so. The returned pointer must be freed with MLFree().
Initialize all ML type management.
0 (=false) is returned on failure, 1 (=true) on success. This function must be called before using any ML* function.
MLEXPORT MLint32 MLIsRegisteredTypeInfos | ( | const MLTypeInfos * | infos | ) |
Returns 1 (=true) if the data type is already registered. Otherwise, 0 (=false) is returned.
MLEXPORT MLint32 MLRegisterStaticTypeInfos | ( | MLTypeInfos * | infos, |
MLDataType | dt | ||
) |
Version of the method that allows to specify a pre-defined data type value.
MLEXPORT MLint32 MLRegisterTypeInfos | ( | MLTypeInfos * | infos | ) |
Adds the data type class information to the list of registered datatypes.
Returns 1 (=true) on success, 0 (=false) on failure (e.g., out of memory, table not initialized, type exists). Registration of infos
sets infos->dataTypeId. Note that the number of datatypes is limited to 2^32-1 even on 64-bit systems in order to have the option to cast to MLDataType enum/integer.
MLEXPORT void MLTypeCastFromBool | ( | const MLTypeInfos * | infos, |
bool | boolValue, | ||
MLTypeData * | data | ||
) |
If boolValue
== 0, data
is set to the type default value given by infos
.
If boolValue
!= 0, all components of the type are cast to their values cast from 1.
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 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 void MLTypeCastFromOtherType | ( | const MLTypeInfos * | otherInfos, |
const MLTypeData * | otherData, | ||
const MLTypeInfos * | myInfos, | ||
MLTypeData * | myData | ||
) |
Casts another data element otherData
with attributes given by otherInfos
to myData
of a type given by myInfos
.
See MLTypeCastToOtherType for more information.
MLEXPORT bool MLTypeCastToBool | ( | const MLTypeInfos * | infos, |
const MLTypeData * | data | ||
) |
If data
is identical to default element false
(= 0) is returned, otherwise true
(= 1).
MLEXPORT MLdouble MLTypeCastToDouble | ( | const MLTypeInfos * | infos, |
const MLTypeData * | data | ||
) |
The first component of the data type is converted to double and returned.
MLEXPORT MLint MLTypeCastToInt | ( | const MLTypeInfos * | infos, |
const MLTypeData * | data | ||
) |
The first component of the data type is converted to integer and returned.
MLEXPORT void MLTypeCastToOtherType | ( | const MLTypeInfos * | otherInfos, |
const MLTypeData * | otherData, | ||
const MLTypeInfos * | myInfos, | ||
MLTypeData * | myData | ||
) |
Converts a data instance referenced by otherData
of a type specified by otherInfos
to another data instance referenced by *myData
of a type specified by myInfos
.
As long as components of any data type in the source exist, the myData
components are set to the same values. Components that do not have a counterpart in the otherData are filled with the counterparts from its default value given by the myInfos. For example: If an (int, char, double) data type (represented by "ICd") is cast to a four component float vector (represented by "ffff"), then the first three components are set from an int cast to double, from an char cast to double, and from an double cast to double. The fourth component is copied from the fourth component of the type default value given in the MLTypeInfo otherInfos
.
Referenced by ml::MLTStdTypeInfos< VTYP >::MLTYPE_castFromOtherType(), and ml::MLTStdTypeInfos< VTYP >::MLTYPE_castToOtherType().
MLEXPORT MLint32 MLTypeComponentsFromStream | ( | void * | iStr, |
void * | iStrStream, | ||
void * | stdiStr, | ||
void * | stdiStrStream, | ||
const MLTypeInfos * | infos, | ||
MLTypeData * | data | ||
) |
Reads data type components into different stream versions (istream and istrstream within and outside the standard namespace).
Since we have a C-interface here, we need to pass the pointers to the streams as void* addresses. So be careful to which of the first parameters the stream is passed. All other can be set to NULL. On any error, *data is correctly set as far as possible, and all unreadable values are set to the default value. On bad parameters, failures, or not completely readable values, 0 is returned, otherwise 1.
MLEXPORT MLint32 MLTypeComponentsFromString | ( | const MLTypeInfos * | infos, |
const char * | stringData, | ||
const MLTypeData * | defaultValue, | ||
MLTypeData * | data | ||
) |
Converts a string of a data type instance to instance data, i.e., similar to sscanf.
infos
points to the type information and data
points to the data of the type instance to be filled with data scanned from stringData
. The return value is 1 if the string could be scanned successfully. On scan failures or invalid parameters, 0 is returned. If a default value is passed in defaultValue
, components that could not be scanned correctly are copied from their corresponding positions in defaultValue
. If defaultValue
is passed as NULL, those components are left unchanged.
Referenced by ml::MLTStdTypeInfos< VTYP >::MLTYPE_setStringValue().
MLEXPORT size_t MLTypeComponentSize | ( | char | component | ) |
Returns the sizeof of a MLTypeComponent component
denoted by a character code.
On invalid character codes 0 is returned. Valid codes are 'b' = bool , 'c' = unsigned char , 'C' = char , 's' = unsigned short 'S' = short , 'i' = unsigned int , 'I' = int , 'l' = unsigned long 'L' = long , '6' = MLint64 , 'f' = float , 'd' = double 'D' = long double, '9' = MLuint64
MLEXPORT char* MLTypeComponentsToString | ( | const MLTypeInfos * | infos, |
const MLTypeData * | data | ||
) |
Converts a data type instance to a string.
infos
points to the type information and data
points to the data of the type instance. The return value is a string containing the type components converted to string values separated by spaces. It must be freed with MLFree(). Floating point values are normally printed with maximum precision. On failures (e.g., infos==NULL or data==NULL), an empty string is returned that also must be freed.
Referenced by ml::MLTStdTypeInfos< VTYP >::MLTYPE_getStringValue().
MLEXPORT char* MLTypeComponentsToStringLimited | ( | const MLTypeInfos * | infos, |
const MLTypeData * | data, | ||
int | maxPrecision | ||
) |
Converts a data type instance to a string.
infos
points to the type information and data
points to the data of the type instance. The return value is a string containing the type components converted to string values separated by spaces. It must be freed with MLFree(). If maxPrecision
is passed with values smaller than 0, then maximum precision of floating point numbers is printed. If passed >= 0, then the number of digits is limited to maxPrecision
. It will be not larger than the maximum default precision even if specified so. On failures (e.g., infos==NULL or data==NULL), an empty string is returned that also must be freed.
MLEXPORT void MLTypeConvertToBigEndian | ( | const MLTypeInfos * | infos, |
const MLTypeData * | sourceBufferPointer, | ||
MLTypeData * | targetBufferPointer, | ||
size_t | numInstances | ||
) |
Converts data type instances from little endian to big endian.
infos | The TypeInfos data structure describing the data type. |
sourceBufferPointer | Points to the first instance to be converted. |
targetBufferPointer | Points to the memory area where the converted instances shall be stored. Identical srcBufPtr and targetBufPtr will be handled correctly. |
numInstances | The number of instances to be converted. The call will be ignored if any parameter pointer is NULL or numInstances is 0. |
MLEXPORT void MLTypeConvertToLittleEndian | ( | const MLTypeInfos * | infos, |
const MLTypeData * | sourceBufferPointer, | ||
MLTypeData * | targetBufferPointer, | ||
size_t | numInstances | ||
) |
Converts data type instances from big endian to little endian.
infos | The TypeInfos data structure describing the data type. |
sourceBufferPointer | Points to the first instance to be converted. |
targetBufferPointer | Points to the memory area where the converted instances shall be stored. Identical srcBufPtr and targetBufPtr will be handled correctly. |
numInstances | The number of instances to be converted. The call will be ignored if any parameter pointer is NULL or numInstances is 0. |
MLEXPORT void MLTypeCorrectPropertyBits | ( | MLTypeInfos * | infos | ) |
Corrects all property bits except for the basic properties [MLTypeIsSignedType, MLTypeIsFloatingPointType, MLTypeIsIntegerType, MLIsBasicType].
Must be called after initialization and setting function pointers. infos
must be a pointer to a valid MLTypeOperatorFunctions struct.
MLEXPORT MLint32 MLTypeGetComponentProperties | ( | char | code, |
MLint32 * | isSigned, | ||
MLint32 * | isIntegerType, | ||
MLint32 * | isFloatingPointType, | ||
MLint32 * | isLongType | ||
) |
Returns true (=1) in *isSigned
, *isIntegerType
, *isFloatingPointType
, and *isLongType
if the component type represented by code has this features; otherwise, set that flag to false (=0).
Note that long types are MLldouble ('D'), MLint64 ('6'), and MLuint64 ('9'). long and unsigned long ('l' and 'L') are not considered as long types since they are in most cases also 32-bit types. Invalid code
values return false (=0) in all parameters. It is explicitly permitted to pass NULL as isSigned, isIntegerType, isFloatingPointType, or isLongType. Then, these pointers are simply ignored.
MLEXPORT MLTypeData* MLTypeGetDataValuesFromString | ( | MLDataType | dataType, |
const char * | voxelValue, | ||
const MLTypeData * | defaultValue, | ||
size_t | numInstances | ||
) |
Allocates a buffer for numInstances
of data type dataType
and fills it with the data type value converted from the NULL-terminated string voxValue
.
All type components that cannot be converted correctly are filled with the corresponding components from defaultValue
, or if defaultValue
is NULL, from the type specific component defaults. On success, a pointer to the allocated data is returned, otherwise NULL. The returned value must be freed by the calling application with MLFree().
MLEXPORT MLdouble MLTypeGetDoubleComponent | ( | char | component, |
const MLTypeData * | targetPointer | ||
) |
Interprets the data referenced by *targetPointer
as data of the type component
and returns it as double value.
Invalid character codes are ignored and change nothing, and the return value is 0.
MLEXPORT MLint MLTypeGetIntComponent | ( | char | component, |
const MLTypeData * | targetPointer | ||
) |
Like MLTypeGetComponent, only that the components is returned as integer values.
MLEXPORT MLErrorCode MLTypeGetMinMaxRangeOfComponents | ( | const MLTypeInfos * | infos, |
const MLTypeData * | srcPtr, | ||
MLdouble * | retMin, | ||
MLdouble * | retMax | ||
) |
Returns the minimum/maximum range of all components of an arbitrary registered voxel.
infos | Type information describing the data type of the voxel passed in srcPtr. |
srcPtr | A pointer to one voxel of the data type described in infos. |
retMin | Ignored if NULL, otherwise *retMin is set to the lowest value found in all components of the voxel. |
retMax | Ignored if NULL, otherwise *retMax is set to the highest value found in all components of the voxel. |
MLEXPORT MLTypeData* MLTypeInfosCreateBuffer | ( | const MLTypeInfos * | infos | ) |
Returns a buffer of the size of one data element. NULL is returned on failure.
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 | ||
) |
Initialization of the main properties of MLTypeInfos.
Returns 1 (=true) on success, 0 (=false) on failure.
infos | The MLTypeInfos structure to be initialized. |
registeredTypeSize | The sizeof of the real data type (not the size of the carrying byte type) |
name | NULL-terminated string name of data type. Only alphanumeric characters without spaces, braces, etc., names should be used. |
ldblMin | Set minimum and maximum double values.
|
ldblMax | See lbdblMin. |
typeMinPtr | Set pointers to a permanent instances of the the data type minimum and maximum value. Try to select the minimum and maximum value so that they match the minimum and maximum double value after casting them to double. However, this is desirable but not necessary. |
typeMaxPtr | See typeMinPtr. |
typeDefaultPtr | Pointer to a permanent instance of the data type default value.
|
typeStructInfo | Set pointer to a permanent NULL-terminated string describing the type configuration. It is needed for most default implementations of the type, e.g., correct big endian/little endian conversions when storing loading this data, for automatic casts to other type. It must exactly describe the types' configuration. Use
|
isScalarType | Pass true if it is a scalar type, i.e., one of the following: (unsigned) char, (unsigned) short, (unsigned) int, (unsigned) long, float, double, long double, or MLint64. |
rangeAndPrecisionEquiv | Pass a standard data type that has comparable range and precision behavior. |
componentAddresses | Is an array of pointers to the components of an example data instance. This way, gaps between components can be evaluated. It must contain exactly as many pointers as the length of typeStructInfo. |
numGoodCastTos | Return types and number of them to which this type can be cast without information loss. |
goodCastTos | An array to the string names of those datatypes to which this type can be cast without information loss. It must have exactly the number of entries given by numGoodCastTos. |
Referenced by ml::MLTStdTypeInfos< VTYP >::MLTStdTypeInfos().
MLEXPORT void MLTypeInfosRemoveBuffer | ( | MLTypeData * | buffer | ) |
Removes a buffer
created with MLTypeInfosCreateBuffer.
MLEXPORT void MLTypeMultWithOtherType | ( | const MLTypeInfos * | myInfos, |
const MLTypeData * | myData, | ||
const MLTypeInfos * | otherInfos, | ||
const MLTypeData * | otherData, | ||
MLTypeData * | targetData | ||
) |
Casts another data element otherData
with attributes given by otherInfos
to a local buffer of a type given by myInfos
.
That buffer is multiplied with myData
and written into targetData
. For the multiplication, myInfos->multWithType is used.
Referenced by ml::MLTStdTypeInfos< VTYP >::MLTYPE_multWithOtherType().
MLEXPORT MLTypePropertyBits MLTypePropBitsAnd | ( | MLTypePropertyBits | propertyBits, |
MLTypePropertyBits | mask | ||
) |
AND operation of all bits in mask
and those in propertyBits
.
MLEXPORT MLTypePropertyBits MLTypePropBitsOr | ( | MLTypePropertyBits | propertyBits, |
MLTypePropertyBits | mask | ||
) |
Adds all set bits in mask
to those in propertyBits
.
MLEXPORT MLint32 MLTypePropBitsTest | ( | MLTypePropertyBits | propertyBits, |
MLTypePropertyBits | mask | ||
) |
Returns true (=1) if bit mask mask
is part of propertyBits
; otherwise, it return false (=0).
MLEXPORT MLTypePropertyBits MLTypePropBitsXor | ( | MLTypePropertyBits | propertyBits, |
MLTypePropertyBits | mask | ||
) |
Inverts all set bits from propertyBits
that are set in mask
.
MLEXPORT void MLTypeSetAllDoubleComponents | ( | const MLTypeInfos * | infos, |
MLdouble | value, | ||
MLTypeData * | targetPointer | ||
) |
All components of the data referenced by *targetPointer
are set to their values cast from the double value
.
Casting is performed by the MLTypeSetComponent function.
MLEXPORT void MLTypeSetAllIntComponent | ( | const MLTypeInfos * | infos, |
MLint | value, | ||
MLTypeData * | targetPointer | ||
) |
Like MLTypeSetAllDoubleComponents, only components are set to integer values.
MLEXPORT void MLTypeSetDefaultFunctionPointers | ( | MLTypeInfos * | infos | ) |
Sets all function pointers to default values that perform error handling when called.
infos
must be a pointer to a valid MLTypeOperatorFunctions struct.
MLEXPORT void MLTypeSetDoubleComponent | ( | char | component, |
MLdouble | value, | ||
MLTypeData * | targetPointer | ||
) |
Interprets the data referenced by *targetPointer
as data of the type component
and sets its value from the passed double value by casting the value
to it.
Invalid character codes are ignored and change nothing.
MLEXPORT void MLTypeSetIntComponent | ( | char | component, |
MLint | value, | ||
MLTypeData * | targetPointer | ||
) |
Like MLTypeSetDoubleComponent, only components are set to integer values.
MLEXPORT void MLTypeShiftComponentsLeft | ( | const MLTypeInfos * | infos, |
const MLTypeData * | sourceData, | ||
MLint | shiftLeft, | ||
MLTypeData * | targetData | ||
) |
Takes one data type component after another and shifts each component left shiftLeft
times if it is an integer component.
Floating point components are multiplied with 2^shiftLeft. Negative values for shiftLeft are interpreted as shift right operations or divisions by 2^shiftLeft, respectively. Boolean components become false on all shiftLeft != 0. Zero shiftLeft does not change any component.
MLEXPORT void MLTypeToggleEndianType | ( | const MLTypeInfos * | infos, |
const MLTypeData * | sourceBufferPointer, | ||
MLTypeData * | targetBufferPointer, | ||
size_t | numInstances | ||
) |
Converts data type instances from little endian to big endian or vice versa.
infos | The TypeInfos data structure describing the data type. |
sourceBufferPointer | Points to the first instance to be converted. |
targetBufferPointer | Points to the memory area where the converted instances shall be stored. Identical srcBufPtr and targetBufPtr will be handled correctly. |
numInstances | The number of instances to be converted. The call will be ignored if any parameter pointer is NULL or numInstances is 0. |
|
extern |
A double can be cast to a data type instance.
|
extern |
An integer can be cast to a data type instance.
|
extern |
Any data type instance can be cast a data type instance.
|
extern |
A data type instance can be cast to bool.
|
extern |
A data type instance can be cast to double.
|
extern |
A data type instance can be cast to integer.
|
extern |
A data type instance can be cast to another type.
|
extern |
Copies parameter one to parameter two. (Note: This function must be implemented.)
|
extern |
The function getStringValue is implemented. (Note: This function must be implemented.)
|
extern |
An equality relation between two type instances can be calculated. (Note: This function must be implemented.)
|
extern |
Data type instance can be multiplied with double.
|
extern |
Data type instance can be multiplied with integer.
|
extern |
A data type instances can be multiplied with the one of another type.
|
extern |
Two data type instances can be multiplied.
|
extern |
The negative value of a data type instance can be calculated.
|
extern |
The data type has no standard properties.
|
extern |
A data type instance can be normalized.
|
extern |
A data type instance and a double can be added.
|
extern |
A data type instance and an integer can be added.
|
extern |
Two data type instances can be added.
|
extern |
The function setStringValue is implemented. (Note: This function must be implemented.)
|
extern |
The setToDefault function is implemented. (Note: This function must be implemented.)
|
extern |
The setToMaximum function is implemented. (Note: This function must be implemented.)
|
extern |
The setToMinimum function is implemented. (Note: This function must be implemented.)
|
extern |
The data type is one of the default types (standard scalar or default extended).
|
extern |
The data type is a floating point type. False otherwise.
|
extern |
The data type is an integer type. False otherwise.
|
extern |
The data type is signed.
|
extern |
The data type is standard scalar data type(intUL, floatUL, charUL, ...).
|
extern |
A data type has all standard properties of a scalar type.