itom 1.1.0
D:/git-itom/sources/itom/DataObject/dataObjectFuncs.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2013, Institut für Technische Optik (ITO),
00005     Universität Stuttgart, Germany
00006 
00007     This file is part of itom and its software development toolkit (SDK).
00008 
00009     itom is free software; you can redistribute it and/or modify it
00010     under the terms of the GNU Library General Public Licence as published by
00011     the Free Software Foundation; either version 2 of the Licence, or (at
00012     your option) any later version.
00013    
00014     In addition, as a special exception, the Institut für Technische
00015     Optik (ITO) gives you certain additional rights.
00016     These rights are described in the ITO LGPL Exception version 1.0,
00017     which can be found in the file LGPL_EXCEPTION.txt in this package.
00018 
00019     itom is distributed in the hope that it will be useful, but
00020     WITHOUT ANY WARRANTY; without even the implied warranty of
00021     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
00022     General Public Licence for more details.
00023 
00024     You should have received a copy of the GNU Library General Public License
00025     along with itom. If not, see <http://www.gnu.org/licenses/>.
00026 *********************************************************************** */
00027 
00028 #ifndef __DATAOBJFUNCH
00029 #define __DATAOBJFUNCH
00030 
00031 #include "dataobj.h"
00032 
00034 #define MAKEHELPERFUNCLIST(FuncName) static t##FuncName fList##FuncName[] =   \
00035 {                                                                       \
00036    FuncName<int8>,                                                      \
00037    FuncName<uint8>,                                                     \
00038    FuncName<int16>,                                                     \
00039    FuncName<uint16>,                                                    \
00040    FuncName<int32>,                                                     \
00041    FuncName<uint32>,                                                    \
00042    FuncName<ito::float32>,                                                   \
00043    FuncName<ito::float64>,                                                   \
00044    FuncName<ito::complex64>,                                                 \
00045    FuncName<ito::complex128>,                                                 \
00046    FuncName<ito::Rgba32>                                                 \
00047 };
00048 
00050 #define MAKEHELPERFUNCLIST_CMPLX_TO_REAL(FuncName) static t##FuncName fList##FuncName[] =     \
00051 {                                                                                       \
00052     FuncName<ito::complex64,float32>,                                                        \
00053     FuncName<ito::complex128,float64>                                                        \
00054 };
00055 
00056 namespace ito 
00057 {
00058 namespace dObjHelper
00059 {
00060     enum CmplxSelectionFlags
00061     {
00062         CMPLX_ABS_VALUE         = 0,
00063         CMPLX_IMAGINARY_VALUE   = 1,
00064         CMPLX_REAL_VALUE        = 2,
00065         CMPLX_ARGUMENT_VALUE    = 3
00066     };
00067 
00068     // Invert the unitString
00069     inline std::string invertUnit(const std::string &oldUnit)
00070     {
00071         if(oldUnit.empty())
00072             return oldUnit;
00073 
00074         int found = (int)oldUnit.find('/');
00075 
00076         if(found!=std::string::npos)
00077         {
00078             if(found == 0)
00079             {
00080                 return oldUnit.substr(1, oldUnit.length() - 1);
00081             }
00082             else if(oldUnit[0] == '1' && found == 1)
00083             {
00084                 return oldUnit.substr(2, oldUnit.length() - 2);
00085             }
00086             else
00087             {
00088                 std::string newString;
00089                 newString.reserve(oldUnit.length());
00090                 newString.append(oldUnit.substr(found + 1, oldUnit.length()- (found + 1)));
00091                 newString.append("/");
00092                 newString.append(oldUnit.substr(0, found));
00093             }
00094         }
00095         else
00096         {
00097             std::string newString;
00098             newString.reserve(oldUnit.length()+2);
00099             newString.append("1/");
00100             newString.append(oldUnit);
00101             return newString;    
00102         }
00103         return "";
00104     }
00105 
00106     //----------------------------------------------------------------------------------------------------------------------------------
00113     inline int itomType2cvType(const int type)
00114     {
00115         switch(type)
00116         {
00117         case ito::tUInt8:
00118             return CV_8U;
00119         case ito::tUInt16:
00120             return CV_16U;
00121         case ito::tInt8:
00122             return CV_8S;
00123         case ito::tInt16:
00124             return CV_16S;
00125         case ito::tInt32:
00126             return CV_32S;
00127         case ito::tFloat32:
00128             return CV_32F;
00129         case ito::tFloat64:
00130             return CV_64F;
00131         default:    //ito::tUInt32 and complextype
00132             return -1;
00133         }
00134     }
00135     //----------------------------------------------------------------------------------------------------------------------------------
00142     inline int cvType2itomType(const int type)
00143     {
00144         switch(type)
00145         {
00146         case CV_8U:
00147             return ito::tUInt8;
00148         case CV_16U:
00149             return ito::tUInt16;
00150         case CV_8S:
00151             return ito::tInt8;
00152         case CV_16S:
00153             return ito::tInt16;
00154         case CV_32S:
00155             return ito::tInt32;
00156         case CV_32F:
00157             return ito::tFloat32;
00158         case CV_64F:
00159             return ito::tFloat64;
00160         default:
00161             return -1;
00162         }
00163     }
00164 
00166     template<typename _Tp> void GetHLineL(const cv::Mat *srcPlane, const int x0, const int y, const int length, int32 * pData);
00167 
00169     template<typename _Tp> void GetHLineD(const cv::Mat *srcPlane, const int x0, const int y, const int length, float64 * pData);
00170 
00172     template<typename _Tp> void GetHLineC(const cv::Mat *srcPlane, const int x0, const int y, const int length, complex128 * pData);
00173 
00175     template<typename _Tp> void SetHLineL(cv::Mat *destPlane, const int x0, const int y, const int length, const int32 * pData);
00176 
00178     template<typename _Tp> void SetHLineD(cv::Mat *destPlane, const int x0, const int y, const int length, const float64 * pData);
00179 
00180 //-----------------------------------------------------------------------------------------------
00192     template<typename _Tp> inline void GetHLineL(const cv::Mat *srcPlane, const int x0, const int y, const int length, int32 * pData)
00193     {
00194         _Tp* resRowPtr;
00195         resRowPtr = (_Tp*)(srcPlane->ptr(y));
00196 
00197         int x = x0;
00198         for(int i = 0; i < length; i++, x++)
00199         {
00200             pData[i] = (int32)(resRowPtr[x]);
00201         }
00202     }
00203 
00204     //-----------------------------------------------------------------------------------------------
00215     template<> inline void GetHLineL<int32>(const cv::Mat *srcPlane, const int x0, const int y, const int length, int32 * pData)
00216     {
00217         int32* resRowPtr;
00218         resRowPtr = (int32*)(srcPlane->ptr(y));
00219         memcpy(pData, &resRowPtr[x0], length *sizeof(int32));
00220     }
00221 
00222     //-----------------------------------------------------------------------------------------------
00234     template<typename _Tp> inline void GetHLineD(const cv::Mat *srcPlane, const int x0, const int y, const int length, float64 * pData)
00235     {
00236         _Tp* resRowPtr;
00237         resRowPtr = (_Tp*)(srcPlane->ptr(y));
00238 
00239         int x = x0;
00240         for(int i = 0; i < length; i++, x++)
00241         {
00242             pData[i] = cv::saturate_cast<ito::float64>(resRowPtr[x]);
00243         }
00244     }
00245 
00246     //-----------------------------------------------------------------------------------------------
00257     template<> inline void GetHLineD<ito::float64>(const cv::Mat *srcPlane, const int x0, const int y, const int length, float64 * pData)
00258     {
00259         float64* resRowPtr;
00260         resRowPtr = (float64*)(srcPlane->ptr(y));
00261         memcpy(pData, &resRowPtr[x0], length *sizeof(float64));
00262     }
00263 
00264         //-----------------------------------------------------------------------------------------------
00276     template<typename _Tp> inline void GetHLineC(const cv::Mat *srcPlane, const int x0, const int y, const int length, complex128 * pData)
00277     {
00278         const _Tp* resRowPtr = srcPlane->ptr<_Tp>(y);
00279 
00280         int x = x0;
00281         for(int i = 0; i < length; i++, x++)
00282         {
00283             pData[i] = complex128(cv::saturate_cast<ito::float64>(resRowPtr[x]), 0.0);
00284         }
00285     }
00286 
00287     //-----------------------------------------------------------------------------------------------
00298     template<> inline void GetHLineC<complex64>(const cv::Mat *srcPlane, const int x0, const int y, const int length, complex128 * pData)
00299     {
00300         const complex64* resRowPtr = srcPlane->ptr<complex64>(y);
00301 
00302         int x = x0;
00303         for(int i = 0; i < length; i++, x++)
00304         {
00305             pData[i] = complex128(resRowPtr[x].real(), resRowPtr[x].imag());
00306         }
00307     }
00308 
00309     //-----------------------------------------------------------------------------------------------
00320     template<> inline void GetHLineC<complex128>(const cv::Mat *srcPlane, const int x0, const int y, const int length, complex128 * pData)
00321     {
00322         const complex128* resRowPtr = srcPlane->ptr<complex128>(y);
00323         memcpy(pData, &resRowPtr[x0], length *sizeof(complex128));
00324     }
00325 
00326     //-----------------------------------------------------------------------------------------------
00338     template<typename _Tp> inline void SetHLineL(cv::Mat *destPlane, const int x0, const int y, const int length, const int32 * pData)
00339     {
00340         _Tp* resRowPtr;
00341         resRowPtr = (_Tp*)(destPlane->ptr(y));
00342 
00343         int x = x0;
00344         for(int i = 0; i < length; i++, x++)
00345         {
00346             resRowPtr[x] = (_Tp)(pData[i]);
00347         }
00348     }
00349 
00350     //-----------------------------------------------------------------------------------------------
00362     template<> inline void SetHLineL<int32>(cv::Mat *destPlane, const int x0, const int y, const int length, const int32 * pData)
00363     {
00364         int32* resRowPtr;
00365         resRowPtr = (int32*)(destPlane->ptr(y));
00366         memcpy(&resRowPtr[x0], pData, length *sizeof(int32));
00367     }
00368 
00369     //-----------------------------------------------------------------------------------------------
00381     template<typename _Tp> inline void SetHLineD(cv::Mat *destPlane, const int x0, const int y, const int length, const float64 * pData)
00382     {
00383         _Tp* resRowPtr;
00384         resRowPtr = (_Tp*)destPlane->ptr(y);
00385 
00386         int x = x0;
00387         for(int i = 0; i < length; i++, x++)
00388         {
00389             resRowPtr[x] = cv::saturate_cast<_Tp>(pData[i]);
00390         }
00391     }
00392 
00393     //-----------------------------------------------------------------------------------------------
00405     template<> inline void SetHLineD<ito::float64>(cv::Mat *destPlane, const int x0, const int y, const int length, const float64 * pData)
00406     {
00407         float64* resRowPtr;
00408         resRowPtr = (float64*)(destPlane->ptr(y));
00409         memcpy(&resRowPtr[x0], pData, length *sizeof(float64));
00410     }
00411 
00413     template<typename _Tp> inline bool isNotZero(_Tp value)
00414     {
00415         if(value == 0)
00416             return false;
00417         else
00418             return true;
00419     }
00420 
00422     template<> inline bool isNotZero<float32>(float32 value)
00423     {
00424         float32 lowVal = std::numeric_limits<float32>::epsilon();
00425         if(fabs(value) < lowVal)
00426             return false;
00427         else
00428             return true;
00429     }
00430 
00432     template<> inline bool isNotZero<float64>(float64 value)
00433     {
00434         float64 lowVal = std::numeric_limits<float64>::epsilon();
00435         if(fabs(value) < lowVal)
00436             return false;
00437         else
00438             return true;
00439     }
00440 
00442     template<typename _Tp> inline bool isFinite(_Tp /*value*/)
00443     {
00444         return true;
00445     }
00446 
00448     template<> inline bool isFinite<float32>(float32 value)
00449     {
00450         uchar *ch = (uchar *)&value;
00451         return (ch[3] & 0x7f) != 0x7f || (ch[2] & 0x80) != 0x80;
00452     }
00453 
00455     template<> inline bool isFinite<float64>(float64 value)
00456     {
00457         uchar *ch = (uchar *)&value;
00458         return (ch[7] & 0x7f) != 0x7f || (ch[6] & 0xf0) != 0xf0;
00459     }
00460 
00462     template<> inline bool isFinite<complex64>(complex64 value)
00463     {
00464         float32 realVal = value.real();
00465         float32 imagVal = value.real();
00466         uchar *chreal = (uchar *)&realVal;
00467         uchar *chimag = (uchar *)&imagVal;
00468         return ((chreal[3] & 0x7f) != 0x7f || (chreal[2] & 0x80) != 0x80) && ((chimag[3] & 0x7f) != 0x7f || (chimag[2] & 0x80) != 0x80);
00469     }
00470 
00472     template<> inline bool isFinite<complex128>(complex128 value)
00473     {
00474         float64 realVal = value.real();
00475         float64 imagVal = value.real();
00476         uchar *chreal = (uchar *)&realVal;
00477         uchar *chimag = (uchar *)&imagVal;
00478         return ((chreal[7] & 0x7f) != 0x7f || (chreal[6] & 0xf0) != 0xf0) && ((chimag[7] & 0x7f) != 0x7f || (chimag[6] & 0xf0) != 0xf0);
00479     }
00480 
00482     template<typename _Tp> inline bool isNaN(_Tp value)
00483     {
00484         return false;
00485     }
00486 
00488     template<> inline bool isNaN<float32>(float32 value)
00489     {
00490         uchar *ch = (uchar *)&value;
00491         return (ch[3] & 0x7f) == 0x7f && ch[2] > 0x80;
00492     }
00494     template<> inline bool isNaN<float64>(float64 value)
00495     {
00496         uchar *ch = (uchar *)&value;
00497         return (ch[7] & 0x7f) == 0x7f && ch[6] > 0xf0;
00498     }
00499 
00501     template<> inline bool isNaN<complex64>(complex64 value)
00502     {
00503         float32 realVal = value.real();
00504         float32 imagVal = value.real();
00505         uchar *chreal = (uchar *)&realVal;
00506         uchar *chimag = (uchar *)&imagVal;
00507         return ((chreal[3] & 0x7f) == 0x7f && chreal[2] > 0x80) || ((chimag[3] & 0x7f) == 0x7f && chimag[2] > 0x80);
00508     }
00509 
00511     template<> inline bool isNaN<complex128>(complex128 value)
00512     {
00513         float64 realVal = value.real();
00514         float64 imagVal = value.real();
00515         uchar *chreal = (uchar *)&realVal;
00516         uchar *chimag = (uchar *)&imagVal;
00517         return ((chreal[7] & 0x7f) == 0x7f && chreal[6] > 0xf0) || ((chimag[7] & 0x7f) == 0x7f && chimag[6] > 0xf0);
00518     }
00519 
00521     template<typename _Tp> inline bool isInf(_Tp /*value*/)
00522     {
00523         return false;
00524     }
00525 
00527     template<> inline bool isInf<float32>(float32 value)
00528     {
00529         uchar *ch = (uchar *)&value;
00530         return (ch[3] & 0x7f) == 0x7f && ch[2] == 0x80;
00531     }
00532 
00534     template<> inline bool isInf<float64>(float64 value)
00535     {
00536         uchar *ch = (uchar *)&value;
00537         return (ch[7] & 0x7f) == 0x7f && ch[6] == 0xf0;
00538     }
00539 
00541     template<> inline bool isInf<complex64>(complex64 value)
00542     {
00543         float32 realVal = value.real();
00544         float32 imagVal = value.real();
00545         uchar *chreal = (uchar *)&realVal;
00546         uchar *chimag = (uchar *)&imagVal;
00547         return ((chreal[3] & 0x7f) == 0x7f && chreal[2] == 0x80) || ((chimag[3] & 0x7f) == 0x7f && chimag[2] == 0x80);
00548     }
00549 
00551     template<> inline bool isInf<complex128>(complex128 value)
00552     {
00553         float64 realVal = value.real();
00554         float64 imagVal = value.real();
00555         uchar *chreal = (uchar *)&realVal;
00556         uchar *chimag = (uchar *)&imagVal;
00557         return ((chreal[7] & 0x7f) == 0x7f && chreal[6] == 0xf0) || ((chimag[7] & 0x7f) == 0x7f && chimag[6] == 0xf0);
00558     }
00559 
00561     template<typename _Tp> RetVal minValueFunc(const DataObject *dObj, float64 &minValue, uint32 *firstLocation, bool ignoreInf = true);
00562     
00564     RetVal minValue(const DataObject *dObj, float64 &minValue, uint32 *firstLocation, bool ignoreInf = true);
00565        
00567     template<typename _Tp> RetVal maxValueFunc(const DataObject *dObj, float64 &maxValue, uint32 *firstLocation, bool ignoreInf = true);
00568 
00570     RetVal maxValue(const DataObject *dObj, float64 &maxValue, uint32 *firstLocation, bool ignoreInf = true);
00571         
00573     template<typename _Tp> RetVal minMaxValueFunc(const DataObject *dObj, float64 &minValue, uint32 *firstMinLocation, float64 &maxValue, uint32 *firstMaxLocation, bool ignoreInf = true, const int specialDataTypeFlags = CMPLX_ABS_VALUE);
00574     
00576     RetVal minMaxValue(const DataObject *dObj, float64 &minValue, uint32 *firstMinLocation, float64 &maxValue, uint32 *firstMaxLocation, bool ignoreInf = true, const int specialDataTypeFlags = CMPLX_ABS_VALUE);
00577 
00578     template<typename _Tp, typename _BufTp> RetVal meanValueFunc(const DataObject *dObj, float64 &meanResult, bool ignoreNaN = true);
00579     RetVal meanValue(const DataObject *dObj, float64 &meanResult, bool ignoreNaN = true);
00580 
00581     template<typename _Tp, typename _BufTp> RetVal devValueFunc(const ito::DataObject *dObj, const int devTypFlag, float64 &meanResult, float64 &devResult, bool ignoreNaN = true);
00582     RetVal devValue(const DataObject *dObj, const int devTypFlag, float64 &meanResult, float64 &devResult, bool ignoreNaN = true);
00583 
00584     RetVal calcCVDFT(DataObject *dObjIO, const bool inverse, const bool inverseAsReal, const bool lineWise);
00585 
00586     ito::RetVal verifyDataObjectType(const ito::DataObject* dObj, const char* name, uint8 numberOfAllowedTypes, ...); //append allowed data types, e.g. ito::tUint8, ito::tInt8... (order does not care)
00587     ito::RetVal verify2DDataObject(const ito::DataObject* dObj, const char* name, int sizeYMin, int sizeYMax, int sizeXMin, int sizeXMax, uint8 numberOfAllowedTypes, ...); //append allowed data types, e.g. ito::tUint8, ito::tInt8... (order does not care)
00588     ito::RetVal verify3DDataObject(const ito::DataObject* dObj, const char* name, int sizeZMin, int sizeZMax, int sizeYMin, int sizeYMax, int sizeXMin, int sizeXMax, uint8 numberOfAllowedTypes, ...); //append allowed data types, e.g. ito::tUint8, ito::tInt8... (order does not care)
00589     ito::RetVal verifySize(int size, int minSize, int maxSize, const char *axisName, const char* dObjName);
00590     
00591     //-----------------------------------------------------------------------------------------------
00604     template<typename _Tp> ito::RetVal freeRowPointer(_Tp *** &pointer)
00605     {
00606         if(pointer == NULL)
00607         {
00608             return ito::RetVal::format(ito::retError, 0, "Delete rowpointer failed, pointer was not allocated freeRowPointer(...)");
00609         }
00610 
00611         int i = 0;
00612 
00613         while(pointer[i] != 0)
00614         {
00615             free(pointer[i]);
00616             i++;
00617             // end of pointer is marked by a NULL-Pointer
00618         }
00619 
00620         free(pointer);
00621         pointer = NULL;
00622 
00623         return ito::retOk;
00624     }
00625 
00641     template<typename _Tp> ito::RetVal getRowPointer(ito::DataObject* dObj, _Tp *** &pointer)  
00642     {
00643 
00644         if(!dObj)
00645         {
00646             return ito::RetVal::format(ito::retError, 0, "DataObject was a NULL pointer in function getRowPointer(...)");               
00647         }
00648 
00649         if(dObj->getType() != ito::getDataType2<_Tp*>())
00650         {
00651             return ito::RetVal::format(ito::retError, 0, "DataObject and template Type differed in function getRowPointer(...)");               
00652         }
00653 
00654         if(dObj->getDims() < 2)
00655         {
00656             return ito::RetVal::format(ito::retError, 0, "DataObject was not initialized in function getRowPointer(...)");   
00657         }
00658 
00659         pointer = (_Tp***)calloc(dObj->calcNumMats() + 1, sizeof(_Tp**));
00660 
00661         if(pointer == NULL)
00662         {
00663             return ito::RetVal::format(ito::retError, 0, "Allocate plane-pointer failed in function getRowPointer(...)");
00664         }
00665 
00666         ito::RetVal retVal(ito::retOk);
00667         int sizeY = dObj->getSize(dObj->getDims() - 2);
00668 
00669         uchar** mdata = dObj->get_mdata();
00670         for(int i = 0; i < dObj->calcNumMats(); i++)
00671         {
00672             pointer[i] = (_Tp**)calloc(sizeY, sizeof(_Tp*));
00673             if(pointer[i])
00674             {
00675                 for(int y = 0; y < sizeY; y++)
00676                 {
00677                     pointer[i][y] = ((cv::Mat*)(mdata[dObj->seekMat(i)]))->ptr<_Tp>(y);
00678                 }
00679             }
00680             else
00681             {
00682                 retVal += ito::RetVal::format(ito::retError, 0, "Allocate row-pointer failed in function getRowPointer(...)");
00683                 break;
00684             }
00685         }
00686 
00687         if(retVal.containsError())
00688         {
00689             freeRowPointer(pointer);
00690         }
00691         return retVal;
00692     } 
00693     
00694     //template<typename _Tp> void minMaxValueHelper(ito::DataObject *dObj, float64 *min, float64 *max, int matNumber);
00695 
00696     //-----------------------------------------------------------------------------------------------
00714     /*
00715     inline ito::RetVal checkITOMType(ito::DataObject *dObj, bool allow_int8, bool allow_uint8, bool allow_int16, bool allow_uint16, bool allow_int32, bool allow_uint32, bool allow_float32, bool allow_float64, bool allow_complex64, bool allow_complex128)
00716     {
00717         int type = dObj->getType();
00718         switch(type)
00719         {
00720         case ito::tUInt8:
00721             if(allow_uint8)
00722                 return ito::retOk;
00723             else return ito::RetVal(ito::retError, 0, "UInt8 not allowed");
00724         case ito::tUInt16:
00725             if(allow_uint16)
00726                 return ito::retOk;
00727             else return ito::RetVal(ito::retError, 0, "UInt16 not allowed");
00728         case ito::tUInt32:
00729             if(allow_uint32)
00730                 return ito::retOk;
00731             else return ito::RetVal(ito::retError, 0, "UInt32 not allowed");
00732         case ito::tInt8:
00733             if(allow_int8)
00734                 return ito::retOk;
00735             else return ito::RetVal(ito::retError, 0, "Int8 not allowed");
00736         case ito::tInt16:
00737             if(allow_int16)
00738                 return ito::retOk;
00739             else return ito::RetVal(ito::retError, 0, "Int16 not allowed");
00740         case ito::tInt32:
00741             if(allow_int32)
00742                 return ito::retOk;
00743             else return ito::RetVal(ito::retError, 0, "Int32 not allowed");
00744         case ito::tFloat32:
00745             if(allow_float32)
00746                 return ito::retOk;
00747             else return ito::RetVal(ito::retError, 0, "Float32 not allowed");
00748         case ito::tFloat64:
00749             if(allow_float64)
00750                 return 0;
00751             else return ito::RetVal(ito::retError, 0, "Float64 not allowed");
00752         case ito::tComplex64:
00753             if(allow_complex64)
00754                 return ito::retOk;
00755             else return ito::RetVal(ito::retError, 0, "Complex64 not allowed");
00756         case ito::tComplex128:
00757             if(allow_complex128)
00758                 return 0;
00759             else return ito::RetVal(ito::retError, 0, "Complex128 not allowed");
00760         default:
00761             return ito::RetVal(ito::retError, 0, "Unknown type or type not implemented");
00762         }
00763     }
00764     */
00765  
00766     //-----------------------------------------------------------------------------------------------
00775     inline bool isIntType(const int type, int *size)
00776     {
00777         if((type == ito::tInt8)||(type == ito::tUInt8))
00778         {
00779             *size = 1;
00780             return true;
00781         }
00782         else if((type == ito::tInt16)||(type == ito::tUInt16))
00783         {
00784             *size = 2;
00785             return true;
00786         }
00787         else if((type == ito::tInt32)||(type == ito::tUInt32))
00788         {
00789             *size = 4;
00790             return true;
00791         }
00792         else
00793         {
00794             *size = -1;
00795             return false;
00796         }
00797     }
00798 
00799     //-----------------------------------------------------------------------------------------------
00808     inline bool isFPType(const int type, int *size)
00809     {
00810         if((type == ito::tFloat32))
00811         {
00812             *size = 4;
00813             return true;
00814         }
00815         else if((type == ito::tFloat64))
00816         {
00817             *size = 8;
00818             return true;
00819         }
00820         else
00821         {
00822             *size = -1;
00823             return false;
00824         }
00825     }
00826 
00827     //-----------------------------------------------------------------------------------------------
00836     inline bool isCplxType(const int type, int *size)
00837     {
00838         if((type == ito::tComplex64))
00839         {
00840             *size = 8;
00841             return true;
00842         }
00843         else if((type == ito::tComplex128))
00844         {
00845             *size = 16;
00846             return true;
00847         }
00848         else
00849         {
00850             *size = -1;
00851             return false;
00852         }
00853     }
00854 
00855     //-----------------------------------------------------------------------------------------------
00868     inline bool dObjareEqualDetail(ito::DataObject *dObj1, ito::DataObject *dObj2, bool &typeFlag, bool &dimsFlag, bool &last2DimsFlag)
00869     {
00870         bool retVal = true;
00871         typeFlag = true;
00872         dimsFlag = true;
00873         last2DimsFlag = true;
00874         //transFlag = true;
00875 
00876         if(dObj1->getType() != dObj2->getType())
00877         {
00878             retVal = false;
00879             typeFlag = false;
00880         }
00881         /*if(dObj1->isT() != dObj2->isT())
00882         {
00883             retVal = false;
00884             transFlag = false;        
00885         }*/
00886 
00887         if(dObj1->getDims() != dObj2->getDims())
00888         {
00889             retVal = false;
00890             dimsFlag = false;
00891             if(dObj1->getSize(dObj1->getDims() - 2) != dObj2->getSize(dObj2->getDims() - 2))
00892             {
00893                 last2DimsFlag = false;
00894             }
00895             if(dObj1->getSize(dObj1->getDims() - 1) != dObj2->getSize(dObj2->getDims() - 1))
00896             {
00897                 last2DimsFlag = false;
00898             }
00899         }
00900         else
00901         {
00902             for(int i = 0; i < dObj1->getDims()-2; i++)
00903             {
00904                 if(dObj1->getSize(i) != dObj2->getSize(i))
00905                 {
00906                     retVal = false;
00907                 }
00908             }
00909             if(dObj1->getSize(dObj1->getDims() - 2) != dObj2->getSize(dObj2->getDims() - 2))
00910             {
00911                 last2DimsFlag = false;
00912                 retVal = false;
00913             }
00914             if(dObj1->getSize(dObj1->getDims() - 1) != dObj2->getSize(dObj2->getDims() - 1))
00915             {
00916                 last2DimsFlag = false;
00917                 retVal = false;
00918             }
00919         }
00920         return retVal;
00921     }
00922 
00923     //-----------------------------------------------------------------------------------------------
00933     inline bool dObjareEqualShort(ito::DataObject *obj1, ito::DataObject *obj2)
00934     {
00935         if(obj1->getDims() == obj2->getDims() && obj1->getType() == obj2->getType() /*&& obj1->isT() == obj2->isT()*/)
00936         {
00937             for(int i = 0; i < obj1->getDims(); i++)
00938             {
00939                 if(obj1->getSize(i) != obj2->getSize(i))
00940                 {
00941                     return false;
00942                 }
00943             }
00944             return true;
00945         }
00946         else
00947             return false;
00948     }
00949 
00951     ito::RetVal dObjCopyLastNAxisTags(const ito::DataObject &DataObjectIn, ito::DataObject &DataObjectOut, const int copyLastNDims, const bool includeValueTags = true, const bool includeRotationMatrix = true);
00952 
00953     ito::RetVal dObjSetScaleRectangle(ito::DataObject &DataObjectInOut, const double &x0, const double &x1, const double &y0, const double &y1);
00954 }
00955 }
00956 
00957 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends