ML Reference
MeVis/Foundation/Sources/ML/include/mlDataTypes.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //---------------------------------------------------------------------------------------------
00016 //---------------------------------------------------------------------------------------------
00017 
00018 #ifndef __mlDataTypes_H
00019 #define __mlDataTypes_H
00020 
00021 #ifndef __mlInitSystemML_H
00022 #include "mlInitSystemML.h"
00023 #endif
00024 
00025 // Include error handling and notify stuff from mlUtils.
00026 #ifndef __mlUtilsAPI_H
00027 #include "mlUtilsAPI.h"
00028 #endif
00029 
00030 // Compile with C-Link interface.
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034 
00035 // Include error handling and notify stuff from mlUtils.
00036 #ifndef __mlTypeDefs_H
00037 #include "mlTypeDefs.h"
00038 #endif
00039 
00040 //--------------------------------------------------------------------------------------------------
00042 
00043 //--------------------------------------------------------------------------------------------------
00045 MLEXPORT MLint32             MLAreTypesInitialized() ML_RETURN_VALUE_SHOULD_BE_USED;
00046 
00049 MLEXPORT MLint32             MLInitializeTypes();
00050 
00052 MLEXPORT void                MLDestroyTypes();
00054 
00055 
00056 
00057 
00058 //--------------------------------------------------------------------------------------------------
00060 
00061 
00062 
00063 //--------------------------------------------------------------------------------------------------
00067 MLEXPORT const char **       MLDataTypeNames();
00068 
00071 MLEXPORT size_t              MLNumDataTypes();
00072 
00076 MLEXPORT const char *        MLNameFromDataType(MLDataType dataType);
00077 
00081 MLEXPORT MLDataType          MLDataTypeFromName(const char* const name);
00082 
00085 MLEXPORT MLdouble            MLDataTypeMax(MLDataType dataType);
00086 
00089 MLEXPORT MLdouble            MLDataTypeMin(MLDataType dataType);
00090 
00094 MLEXPORT size_t              MLSizeOf(MLDataType dataType);
00095 
00097 MLEXPORT size_t              MLSizeOfRegisteredType(MLDataType dataType);
00098 
00108 MLEXPORT MLint32             MLRangeOrder(MLDataType dataType);
00109 
00112 MLEXPORT MLint32             MLIsValidType(MLDataType dataType);
00113 
00116 MLEXPORT MLint32             MLIsSigned(MLDataType dataType);
00117 
00120 MLEXPORT MLint32             MLIsIntType(MLDataType dataType);
00121 
00124 MLEXPORT MLint32             MLIsFloatType(MLDataType dataType);
00125 
00128 MLEXPORT MLint32             MLIsStandardType(MLDataType dataType);
00129 
00133 MLEXPORT MLint32             MLIsDefaultExtendedType(MLDataType dataType);
00134 
00137 MLEXPORT MLTypeGroup         MLGetTypeGroup(MLDataType dataType);
00138 
00161 MLEXPORT MLDataType MLGetPromotedTypeWithRange(const MLDataType* inputTypes, size_t numTypes,
00162                                                double rangeMin, double rangeMax);
00163 
00165 MLEXPORT MLDataType MLGetPromotedTypeWithRange1Input (MLDataType inputType1,
00166                                                       double rangeMin, double rangeMax);
00167 
00169 MLEXPORT MLDataType MLGetPromotedTypeWithRange2Inputs(MLDataType inputType1, MLDataType inputType2,
00170                                                       double rangeMin, double rangeMax);
00171 
00173 MLEXPORT MLDataType MLGetPromotedTypeWithRange3Inputs(MLDataType inputType1, MLDataType inputType2, MLDataType inputType3,
00174                                                       double rangeMin, double rangeMax);
00175 
00180 MLEXPORT MLint32             MLHolds(MLDataType datatype1, MLDataType datatype2);
00181 
00189 MLEXPORT MLDataType          MLGetPromotedType(MLDataType datatype1, MLDataType datatype2);
00190   
00191 #ifdef ML_DEPRECATED
00192 
00193 
00194 
00195 
00196 MLEXPORT ML_DEPRECATED MLDataType MLPromotedType(MLDataType datatype1, MLDataType datatype2);
00198 #endif // ML_DEPRECATED
00199   
00200 
00220 MLEXPORT MLDataType           MLGetDataTypeForRange(MLdouble *min,
00221                                                     MLdouble *max,
00222                                                     MLint32 preferUnsigned);
00223 
00229 MLEXPORT MLDataType           MLGetDataTypeForUncorrectedRange(MLdouble min,
00230                                                                MLdouble max,
00231                                                                MLint32 preferUnsigned);
00232 
00238 MLEXPORT MLDataType           MLGetRangeAndPrecisionEquivalent(MLDataType dataType);
00239 
00246 MLEXPORT MLDataType           MLGetPromotedPrecision(MLDataType datatype1, MLDataType datatype2);
00247   
00248 #ifdef ML_DEPRECATED
00249 
00250 
00251 
00252 
00253 #define MLPromotedPrecision MLGetPromotedPrecision
00254 
00255 
00256 #if defined(WIN32) && defined(ML_WARN_DEPRECATED)
00257 #pragma deprecated("MLPromotedPrecision")
00258 #endif
00259 
00260 #endif // ML_DEPRECATED
00261   
00262 
00265 MLEXPORT size_t               MLTypeGetNumComponents(MLDataType dataType);
00266 
00270 MLEXPORT const char *         MLTypeGetStructInfoString(MLDataType dataType);
00271 
00289 MLEXPORT MLDataType           MLTypeGetBestScalarTypeForTypeComponentChars(const char *charCodes, 
00290                                                                            int suppressML64BitInts,
00291                                                                            int suppressMLldouble);
00307 MLEXPORT MLDataType           MLTypeGetBestScalarTypeForTypeComponents(MLDataType dataType, 
00308                                                                        int suppressML64BitInts,
00309                                                                        int suppressMLldouble);
00311 
00312 
00313 
00314 
00315 
00316 //---------------------------------------------------------------------------------------------
00317 //
00318 //
00319 //                                REGISTERED TYPE SUPPORT
00320 //
00321 //
00322 //---------------------------------------------------------------------------------------------
00323 
00324 
00325 //--------------------------------------------------------------------------------------------------
00327 
00328 //--------------------------------------------------------------------------------------------------
00329 extern MLEXPORT const MLTypePropertyBits MLTypeHasNoProperties          ; 
00330 
00331 extern MLEXPORT const MLTypePropertyBits MLTypeHasGetStringValue        ; 
00332 extern MLEXPORT const MLTypePropertyBits MLTypeHasSetStringValue        ; 
00333 
00334 extern MLEXPORT const MLTypePropertyBits MLTypeIsDefaultType            ; 
00335 extern MLEXPORT const MLTypePropertyBits MLTypeIsSignedType             ; 
00336 extern MLEXPORT const MLTypePropertyBits MLTypeIsFloatingPointType      ; 
00337 extern MLEXPORT const MLTypePropertyBits MLTypeIsIntegerType            ; 
00338 extern MLEXPORT const MLTypePropertyBits MLTypeIsStandardType           ; 
00339 
00340 extern MLEXPORT const MLTypePropertyBits MLTypeHasSetToMinimum          ; 
00341 extern MLEXPORT const MLTypePropertyBits MLTypeHasSetToMaximum          ; 
00342 extern MLEXPORT const MLTypePropertyBits MLTypeHasSetToDefault          ; 
00343 extern MLEXPORT const MLTypePropertyBits MLTypeHasCopy                  ; 
00344 
00345 extern MLEXPORT const MLTypePropertyBits MLTypeHasCastToBool            ; 
00346 extern MLEXPORT const MLTypePropertyBits MLTypeHasCastToInt             ; 
00347 extern MLEXPORT const MLTypePropertyBits MLTypeHasCastToDouble          ; 
00348 extern MLEXPORT const MLTypePropertyBits MLTypeHasCastToOtherType       ; 
00349 
00350 extern MLEXPORT const MLTypePropertyBits MLTypeHasCastFromInt           ; 
00351 extern MLEXPORT const MLTypePropertyBits MLTypeHasCastFromDouble        ; 
00352 extern MLEXPORT const MLTypePropertyBits MLTypeHasCastFromOtherType     ; 
00353 
00354 extern MLEXPORT const MLTypePropertyBits MLTypeHasNegate                ; 
00355 extern MLEXPORT const MLTypePropertyBits MLTypeHasNormalize             ; 
00356 
00357 extern MLEXPORT const MLTypePropertyBits MLTypeHasIsEqualToType         ; 
00358 
00359 extern MLEXPORT const MLTypePropertyBits MLTypeHasMultWithInt           ; 
00360 extern MLEXPORT const MLTypePropertyBits MLTypeHasMultWithDouble        ; 
00361 extern MLEXPORT const MLTypePropertyBits MLTypeHasMultWithType          ; 
00362 extern MLEXPORT const MLTypePropertyBits MLTypeHasMultWithOtherType     ; 
00363 
00364 extern MLEXPORT const MLTypePropertyBits MLTypeHasPlusInt               ; 
00365 extern MLEXPORT const MLTypePropertyBits MLTypeHasPlusDouble            ; 
00366 extern MLEXPORT const MLTypePropertyBits MLTypeHasPlusType              ; 
00367 
00368 
00369 //--------------------------------------------------------------------------------------------------
00371 
00372 //--------------------------------------------------------------------------------------------------
00373 extern MLEXPORT const MLTypePropertyBits MLTypeScalarType               ; 
00374 
00375 
00376 
00377 //--------------------------------------------------------------------------------------------------
00379 
00380 //--------------------------------------------------------------------------------------------------
00382 MLEXPORT MLint32        MLTypePropBitsTest(MLTypePropertyBits propertyBits, MLTypePropertyBits mask);
00383 
00385 MLEXPORT MLTypePropertyBits MLTypePropBitsAnd(MLTypePropertyBits propertyBits, MLTypePropertyBits mask);
00386 
00388 MLEXPORT MLTypePropertyBits MLTypePropBitsOr(MLTypePropertyBits propertyBits, MLTypePropertyBits mask);
00389 
00391 MLEXPORT MLTypePropertyBits MLTypePropBitsXor(MLTypePropertyBits propertyBits, MLTypePropertyBits mask);
00393 
00394 
00395 
00396 
00397 #ifdef ML_DEPRECATED
00398 //--------------------------------------------------------------------------------------------------
00400 
00401 //--------------------------------------------------------------------------------------------------
00404 MLEXPORT size_t      MLSizeOfPhysicalType(MLDataType physicalDataType);
00405 
00408 MLEXPORT MLDataType  MLGetPhysicalDataType(MLDataType dataType);
00410 
00411 #if defined(WIN32) && defined(ML_WARN_DEPRECATED)
00412 #pragma deprecated("MLSizeOfPhysicalType")
00413 #pragma deprecated("MLGetPhysicalDataType")
00414 #endif
00415 
00416 #endif // ML_DEPRECATED
00417 
00418 
00419 //--------------------------------------------------------------------------------------------------
00421 
00422 //--------------------------------------------------------------------------------------------------
00429 MLEXPORT MLint32      MLRegisterTypeInfos(MLTypeInfos *infos) ML_RETURN_VALUE_SHOULD_BE_USED;
00430 
00432 MLEXPORT MLint32      MLRegisterStaticTypeInfos(MLTypeInfos *infos, MLDataType dt);
00433 
00435 MLEXPORT MLint32      MLIsRegisteredTypeInfos(const MLTypeInfos *infos);
00436 
00438 MLEXPORT size_t       MLGetNumRegisteredTypeInfos();
00439 
00441 MLEXPORT MLTypeInfos* MLGetTypeInfosAtIndex(size_t index);
00442   
00443 #ifdef ML_DEPRECATED
00444 
00445 
00446 
00447 
00448 #define MLTypeInfosAtIdx MLGetTypeInfosAtIndex
00449 
00450 
00451 #if defined(WIN32) && defined(ML_WARN_DEPRECATED)
00452 #pragma deprecated("MLSizeOfRegisteredType")
00453 #pragma deprecated("MLSizeOfPhysicalType")
00454 #pragma deprecated("MLGetPhysicalDataType")
00455 #pragma deprecated("MLTypeInfosAtIdx")
00456 #endif
00457 
00458 
00459 #endif // ML_DEPRECATED
00460 
00463 MLEXPORT MLTypeInfos* MLGetTypeInfosForDataType(MLDataType dataType);
00465 
00466 
00467 
00468 #ifdef ML_DEPRECATED
00469 
00470 //--------------------------------------------------------------------------------------------------
00472 
00473 //--------------------------------------------------------------------------------------------------
00474 
00475 typedef MLint32 MLTypePushSingleInfo;
00476 
00478 MLEXPORT MLTypePushSingleInfo MLTypeInfosPushAndSetInput(MLDataType dataType);
00479 
00481 MLEXPORT MLTypePushSingleInfo MLTypeInfosPushAndSetOutput(MLDataType dataType);
00482 
00484 MLEXPORT void MLTypeInfoPop(MLTypePushSingleInfo pushInfo);
00485 
00486 
00487 typedef MLint32 MLTypePushDoubleInfo;
00488 
00490 MLEXPORT MLTypePushDoubleInfo MLTypeInfosPushAndSetBoth(MLDataType dataType);
00491 
00493 MLEXPORT MLTypePushDoubleInfo MLTypeInfosPushAndSetTypes(MLDataType datatype1, MLint32 isDT1AnInputType,
00494                                                          MLDataType datatype2, MLint32 isDT2AnInputType);
00495 
00497 MLEXPORT void MLTypeInfosPop(MLTypePushDoubleInfo infos);
00498 
00499 #if defined(WIN32) && defined(ML_WARN_DEPRECATED)
00500 #pragma deprecated("MLTypePushSingleInfo")
00501 #pragma deprecated("MLTypeInfosPushAndSetInput")
00502 #pragma deprecated("MLTypeInfosPushAndSetOutput")
00503 #pragma deprecated("MLTypeInfoPop")
00504 #pragma deprecated("MLTypePushDoubleInfo")
00505 #pragma deprecated("MLTypeInfosPushAndSetBoth")
00506 #pragma deprecated("MLTypeInfosPushAndSetTypes")
00507 #pragma deprecated("MLTypeInfosPop")
00508 #endif
00509 
00511 
00512 #endif // ML_DEPRECATED
00513 
00514 
00515 //--------------------------------------------------------------------------------------------------
00517 
00518 //--------------------------------------------------------------------------------------------------
00599 //---------------------------------------------------------------------
00600 MLEXPORT MLint32 MLTypeInfosInit(MLTypeInfos       *infos,
00601                                  size_t             typeSize,
00602                                  const char        *name,
00603                                  MLdouble           dblMin,
00604                                  MLdouble           dblMax,
00605                                  const MLTypeData  *typeMinPtr,
00606                                  const MLTypeData  *typeMaxPtr,
00607                                  const MLTypeData  *typeDefaultPtr,
00608                                  const char        *typeStructInfo,
00609                                  MLint32            isScalarType,
00610                                  MLTypeGroup        typeGroup,
00611                                  MLDataType         rangeAndPrecisionEquiv,
00612                                  void             **componentAddresses,
00613                                  size_t             numGoodCastTos,
00614                                  const char       **goodCastTos);
00615 
00617 MLEXPORT MLTypeData *MLTypeInfosCreateBuffer(const MLTypeInfos* infos) ML_RETURN_VALUE_SHOULD_BE_USED;
00618 
00620 MLEXPORT void MLTypeInfosRemoveBuffer(MLTypeData* buffer);
00621 
00626 MLEXPORT void MLTypeCorrectPropertyBits(MLTypeInfos* infos);
00627 
00630 MLEXPORT void MLTypeSetDefaultFunctionPointers(MLTypeInfos* infos);
00631 
00640 MLEXPORT void MLTypeToggleEndianType(const MLTypeInfos *infos, 
00641                                      const MLTypeData *sourceBufferPointer, MLTypeData *targetBufferPointer,
00642                                      size_t numInstances);
00643 
00652 MLEXPORT void MLTypeConvertToLittleEndian(const MLTypeInfos *infos, 
00653                                           const MLTypeData *sourceBufferPointer, MLTypeData *targetBufferPointer,
00654                                           size_t numInstances);
00655 
00664 MLEXPORT void MLTypeConvertToBigEndian(const MLTypeInfos *infos, 
00665                                        const MLTypeData *sourceBufferPointer, MLTypeData *targetBufferPointer,
00666                                        size_t numInstances);
00668 
00669 
00670 
00671 
00672 //--------------------------------------------------------------------------------------------------
00674 
00675 //--------------------------------------------------------------------------------------------------
00678 MLEXPORT const char *MLGetCDataTypeNameForCharCode(char code);
00679 
00683 MLEXPORT const char *MLGetMLDataTypeNameForCharCode(char code);
00684 
00687 MLEXPORT MLDataType  MLGetMLDataTypeForCharCode(char code);
00688 
00703 MLEXPORT MLint32  MLTypeGetComponentProperties(char code,
00704                                                MLint32 *isSigned,
00705                                                MLint32 *isIntegerType,
00706                                                MLint32 *isFloatingPointType,
00707                                                MLint32 *isLongType);
00708 
00715 MLEXPORT size_t   MLTypeComponentSize(char component);
00716 
00721 MLEXPORT void     MLTypeSetDoubleComponent(char component, MLdouble value, MLTypeData* targetPointer);
00722 
00724 MLEXPORT void     MLTypeSetIntComponent   (char component, MLint value, MLTypeData* targetPointer);
00725 
00729 MLEXPORT void     MLTypeSetAllDoubleComponents(const MLTypeInfos* infos, MLdouble value, MLTypeData* targetPointer);
00730 
00732 MLEXPORT void     MLTypeSetAllIntComponent    (const MLTypeInfos *infos, MLint value, MLTypeData* targetPointer);
00733 
00737 MLEXPORT MLdouble MLTypeGetDoubleComponent(char component, const MLTypeData* targetPointer);
00738 
00740 MLEXPORT MLint    MLTypeGetIntComponent   (char component, const MLTypeData* targetPointer);
00741 
00752 MLEXPORT MLErrorCode MLTypeGetMinMaxRangeOfComponents(const MLTypeInfos *infos, 
00753                                                       const MLTypeData *srcPtr,
00754                                                       MLdouble *retMin, 
00755                                                       MLdouble *retMax);
00756 
00758 
00759 
00760 
00761 //--------------------------------------------------------------------------------------------------
00763 
00764 //--------------------------------------------------------------------------------------------------
00770 MLEXPORT MLTypeData *MLAllocateVoxelBuffer(MLDataType dataType, size_t numVoxels, const MLTypeData* voxelDefaultValue) ML_RETURN_VALUE_SHOULD_BE_USED;
00771 
00778 MLEXPORT char       *MLGetVoxelValueAsString(const MLTypeData* data, MLDataType dataType, MLErrorCode* errorCode) ML_RETURN_VALUE_SHOULD_BE_USED;
00779 
00788 MLEXPORT char       *MLGetVoxelValueAsStringLimited(const MLTypeData* data, MLDataType dataType, MLErrorCode* errorCode, int maxPrecision) ML_RETURN_VALUE_SHOULD_BE_USED;
00789 
00796 MLEXPORT char       *MLTypeComponentsToString(const MLTypeInfos* infos, const MLTypeData* data) ML_RETURN_VALUE_SHOULD_BE_USED;
00797 
00806 MLEXPORT char       *MLTypeComponentsToStringLimited(const MLTypeInfos* infos, const MLTypeData* data, int maxPrecision) ML_RETURN_VALUE_SHOULD_BE_USED;
00807 
00816 MLEXPORT MLint32     MLTypeComponentsFromString(const MLTypeInfos* infos, const char* stringData, const MLTypeData* defaultValue, MLTypeData* data) ML_RETURN_VALUE_SHOULD_BE_USED;
00817 
00825 MLEXPORT MLTypeData *MLTypeGetDataValuesFromString(MLDataType dataType, const char* voxelValue, const MLTypeData *defaultValue, size_t numInstances) ML_RETURN_VALUE_SHOULD_BE_USED;
00826 
00835 MLEXPORT MLint32     MLTypeComponentsFromStream(void *iStr,    void *iStrStream,
00836                                                 void *stdiStr, void *stdiStrStream,
00837                                                 const MLTypeInfos *infos, MLTypeData *data);
00838 
00843 MLEXPORT MLdouble    MLGetVoxelValueAsDouble(const void* data, MLDataType dataType, MLErrorCode* errorCode);
00844 
00846 MLEXPORT bool        MLTypeCastToBool     (const MLTypeInfos* infos, const MLTypeData* data);
00847 
00849 MLEXPORT MLint       MLTypeCastToInt      (const MLTypeInfos* infos, const MLTypeData* data);
00850 
00852 MLEXPORT MLdouble    MLTypeCastToDouble   (const MLTypeInfos* infos, const MLTypeData* data);
00853 
00856 MLEXPORT void        MLTypeCastFromBool   (const MLTypeInfos* infos, bool boolValue, MLTypeData* data);
00857 
00859 MLEXPORT void        MLTypeCastFromInt    (const MLTypeInfos *infos, MLint intValue, MLTypeData* data);
00860 
00862 MLEXPORT void        MLTypeCastFromDouble (const MLTypeInfos* infos, MLdouble doubleValue, MLTypeData* data);
00863 
00869 MLEXPORT void        MLTypeShiftComponentsLeft(const MLTypeInfos *infos, const MLTypeData* sourceData, MLint shiftLeft, MLTypeData* targetData);
00870 
00871 
00883 MLEXPORT void      MLTypeCastToOtherType(const MLTypeInfos* otherInfos, const MLTypeData* otherData,
00884                                          const MLTypeInfos* myInfos,    MLTypeData*       myData);
00885 
00888 MLEXPORT void      MLTypeCastFromOtherType(const MLTypeInfos* otherInfos, const MLTypeData* otherData,
00889                                            const MLTypeInfos* myInfos,    MLTypeData*       myData);
00890 
00895 MLEXPORT void      MLTypeMultWithOtherType(const MLTypeInfos* myInfos,    const MLTypeData* myData,
00896                                            const MLTypeInfos* otherInfos, const MLTypeData* otherData,
00897                                            MLTypeData* targetData);
00899 
00900 // C-Link interface off.
00901 #ifdef __cplusplus
00902 }
00903 #endif
00904 
00905 #endif //of __mlDataTypes_H
00906 
00907