itom 2.0.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 #include <assert.h>     /* assert */
00033 
00035 #define MAKEHELPERFUNCLIST(FuncName) static t##FuncName fList##FuncName[] = \
00036 {                                                                           \
00037    FuncName<int8>,                                                          \
00038    FuncName<uint8>,                                                         \
00039    FuncName<int16>,                                                         \
00040    FuncName<uint16>,                                                        \
00041    FuncName<int32>,                                                         \
00042    FuncName<uint32>,                                                        \
00043    FuncName<ito::float32>,                                                  \
00044    FuncName<ito::float64>,                                                  \
00045    FuncName<ito::complex64>,                                                \
00046    FuncName<ito::complex128>,                                               \
00047    FuncName<ito::Rgba32>                                                    \
00048 };
00049 
00051 #define MAKEHELPERFUNCLIST_CMPLX_TO_REAL(FuncName) static t##FuncName fList##FuncName[] = \
00052 {                                                                                         \
00053     FuncName<ito::complex64,float32>,                                                     \
00054     FuncName<ito::complex128,float64>                                                     \
00055 };
00056 
00057 namespace ito 
00058 {
00059 namespace dObjHelper
00060 {
00061     enum CmplxSelectionFlags
00062     {
00063         CMPLX_ABS_VALUE         = 0,
00064         CMPLX_IMAGINARY_VALUE   = 1,
00065         CMPLX_REAL_VALUE        = 2,
00066         CMPLX_ARGUMENT_VALUE    = 3
00067     };
00068 
00069     // Invert the unitString
00070     inline std::string invertUnit(const std::string &oldUnit)
00071     {
00072         if(oldUnit.empty())
00073             return oldUnit;
00074 
00075         int found = (int)oldUnit.find('/');
00076 
00077         if(found!=std::string::npos)
00078         {
00079             if(found == 0)
00080             {
00081                 return oldUnit.substr(1, oldUnit.length() - 1);
00082             }
00083             else if(oldUnit[0] == '1' && found == 1)
00084             {
00085                 return oldUnit.substr(2, oldUnit.length() - 2);
00086             }
00087             else
00088             {
00089                 std::string newString;
00090                 newString.reserve(oldUnit.length());
00091                 newString.append(oldUnit.substr(found + 1, oldUnit.length()- (found + 1)));
00092                 newString.append("/");
00093                 newString.append(oldUnit.substr(0, found));
00094             }
00095         }
00096         else
00097         {
00098             std::string newString;
00099             newString.reserve(oldUnit.length()+2);
00100             newString.append("1/");
00101             newString.append(oldUnit);
00102             return newString;    
00103         }
00104         return "";
00105     }
00106 
00107     //----------------------------------------------------------------------------------------------------------------------------------
00114     inline int itomType2cvType(const int type)
00115     {
00116         switch(type)
00117         {
00118         case ito::tUInt8:
00119             return CV_8U;
00120         case ito::tUInt16:
00121             return CV_16U;
00122         case ito::tInt8:
00123             return CV_8S;
00124         case ito::tInt16:
00125             return CV_16S;
00126         case ito::tInt32:
00127             return CV_32S;
00128         case ito::tFloat32:
00129             return CV_32F;
00130         case ito::tFloat64:
00131             return CV_64F;
00132         default:    //ito::tUInt32 and complextype
00133             return -1;
00134         }
00135     }
00136     //----------------------------------------------------------------------------------------------------------------------------------
00143     inline int cvType2itomType(const int type)
00144     {
00145         switch(type)
00146         {
00147         case CV_8U:
00148             return ito::tUInt8;
00149         case CV_16U:
00150             return ito::tUInt16;
00151         case CV_8S:
00152             return ito::tInt8;
00153         case CV_16S:
00154             return ito::tInt16;
00155         case CV_32S:
00156             return ito::tInt32;
00157         case CV_32F:
00158             return ito::tFloat32;
00159         case CV_64F:
00160             return ito::tFloat64;
00161         default:
00162             return -1;
00163         }
00164     }
00165 
00167     template<typename _Tp> void GetHLineL(const cv::Mat *srcPlane, const int x0, const int y, const int length, int32 * pData);
00168 
00170     template<typename _Tp> void GetHLineD(const cv::Mat *srcPlane, const int x0, const int y, const int length, float64 * pData);
00171 
00173     template<typename _Tp> void GetHLineC(const cv::Mat *srcPlane, const int x0, const int y, const int length, complex128 * pData);
00174 
00176     template<typename _Tp> void SetHLineL(cv::Mat *destPlane, const int x0, const int y, const int length, const int32 * pData);
00177 
00179     template<typename _Tp> void SetHLineD(cv::Mat *destPlane, const int x0, const int y, const int length, const float64 * pData);
00180 
00181 //-----------------------------------------------------------------------------------------------
00193     template<typename _Tp> inline void GetHLineL(const cv::Mat *srcPlane, const int x0, const int y, const int length, int32 * pData)
00194     {
00195         _Tp* resRowPtr;
00196         resRowPtr = (_Tp*)(srcPlane->ptr(y));
00197 
00198         int x = x0;
00199         for(int i = 0; i < length; i++, x++)
00200         {
00201             pData[i] = (int32)(resRowPtr[x]);
00202         }
00203     }
00204 
00205     //-----------------------------------------------------------------------------------------------
00216     template<> inline void GetHLineL<int32>(const cv::Mat *srcPlane, const int x0, const int y, const int length, int32 * pData)
00217     {
00218         int32* resRowPtr;
00219         resRowPtr = (int32*)(srcPlane->ptr(y));
00220         memcpy(pData, &resRowPtr[x0], length *sizeof(int32));
00221     }
00222 
00223     //-----------------------------------------------------------------------------------------------
00235     template<typename _Tp> inline void GetHLineD(const cv::Mat *srcPlane, const int x0, const int y, const int length, float64 * pData)
00236     {
00237         _Tp* resRowPtr;
00238         resRowPtr = (_Tp*)(srcPlane->ptr(y));
00239 
00240         int x = x0;
00241         for(int i = 0; i < length; i++, x++)
00242         {
00243             pData[i] = cv::saturate_cast<ito::float64>(resRowPtr[x]);
00244         }
00245     }
00246 
00247     //-----------------------------------------------------------------------------------------------
00258     template<> inline void GetHLineD<ito::float64>(const cv::Mat *srcPlane, const int x0, const int y, const int length, float64 * pData)
00259     {
00260         float64* resRowPtr;
00261         resRowPtr = (float64*)(srcPlane->ptr(y));
00262         memcpy(pData, &resRowPtr[x0], length *sizeof(float64));
00263     }
00264 
00265         //-----------------------------------------------------------------------------------------------
00277     template<typename _Tp> inline void GetHLineC(const cv::Mat *srcPlane, const int x0, const int y, const int length, complex128 * pData)
00278     {
00279         const _Tp* resRowPtr = srcPlane->ptr<_Tp>(y);
00280 
00281         int x = x0;
00282         for(int i = 0; i < length; i++, x++)
00283         {
00284             pData[i] = complex128(cv::saturate_cast<ito::float64>(resRowPtr[x]), 0.0);
00285         }
00286     }
00287 
00288     //-----------------------------------------------------------------------------------------------
00299     template<> inline void GetHLineC<complex64>(const cv::Mat *srcPlane, const int x0, const int y, const int length, complex128 * pData)
00300     {
00301         const complex64* resRowPtr = srcPlane->ptr<complex64>(y);
00302 
00303         int x = x0;
00304         for(int i = 0; i < length; i++, x++)
00305         {
00306             pData[i] = complex128(resRowPtr[x].real(), resRowPtr[x].imag());
00307         }
00308     }
00309 
00310     //-----------------------------------------------------------------------------------------------
00321     template<> inline void GetHLineC<complex128>(const cv::Mat *srcPlane, const int x0, const int y, const int length, complex128 * pData)
00322     {
00323         const complex128* resRowPtr = srcPlane->ptr<complex128>(y);
00324         memcpy(pData, &resRowPtr[x0], length *sizeof(complex128));
00325     }
00326 
00327     //-----------------------------------------------------------------------------------------------
00339     template<typename _Tp> inline void SetHLineL(cv::Mat *destPlane, const int x0, const int y, const int length, const int32 * pData)
00340     {
00341         _Tp* resRowPtr;
00342         resRowPtr = (_Tp*)(destPlane->ptr(y));
00343 
00344         int x = x0;
00345         for(int i = 0; i < length; i++, x++)
00346         {
00347             resRowPtr[x] = (_Tp)(pData[i]);
00348         }
00349     }
00350 
00351     //-----------------------------------------------------------------------------------------------
00363     template<> inline void SetHLineL<int32>(cv::Mat *destPlane, const int x0, const int y, const int length, const int32 * pData)
00364     {
00365         int32* resRowPtr;
00366         resRowPtr = (int32*)(destPlane->ptr(y));
00367         memcpy(&resRowPtr[x0], pData, length *sizeof(int32));
00368     }
00369 
00370     //-----------------------------------------------------------------------------------------------
00382     template<typename _Tp> inline void SetHLineD(cv::Mat *destPlane, const int x0, const int y, const int length, const float64 * pData)
00383     {
00384         _Tp* resRowPtr;
00385         resRowPtr = (_Tp*)destPlane->ptr(y);
00386 
00387         int x = x0;
00388         for(int i = 0; i < length; i++, x++)
00389         {
00390             resRowPtr[x] = cv::saturate_cast<_Tp>(pData[i]);
00391         }
00392     }
00393 
00394     //-----------------------------------------------------------------------------------------------
00406     template<> inline void SetHLineD<ito::float64>(cv::Mat *destPlane, const int x0, const int y, const int length, const float64 * pData)
00407     {
00408         float64* resRowPtr;
00409         resRowPtr = (float64*)(destPlane->ptr(y));
00410         memcpy(&resRowPtr[x0], pData, length *sizeof(float64));
00411     }
00412 
00414     template<typename _Tp> inline bool isNotZero(_Tp value)
00415     {
00416         if(value == 0)
00417             return false;
00418         else
00419             return true;
00420     }
00421 
00423     template<> inline bool isNotZero<float32>(float32 value)
00424     {
00425         float32 lowVal = std::numeric_limits<float32>::epsilon();
00426         if(fabs(value) < lowVal)
00427             return false;
00428         else
00429             return true;
00430     }
00431 
00433     template<> inline bool isNotZero<float64>(float64 value)
00434     {
00435         float64 lowVal = std::numeric_limits<float64>::epsilon();
00436         if(fabs(value) < lowVal)
00437             return false;
00438         else
00439             return true;
00440     }
00441 
00443     template<typename _Tp> inline bool isFinite(_Tp /*value*/)
00444     {
00445         return true;
00446     }
00447 
00449     template<> inline bool isFinite<float32>(float32 value)
00450     {
00451         uchar *ch = (uchar *)&value;
00452         return (ch[3] & 0x7f) != 0x7f || (ch[2] & 0x80) != 0x80;
00453     }
00454 
00456     template<> inline bool isFinite<float64>(float64 value)
00457     {
00458         uchar *ch = (uchar *)&value;
00459         return (ch[7] & 0x7f) != 0x7f || (ch[6] & 0xf0) != 0xf0;
00460     }
00461 
00463     template<> inline bool isFinite<complex64>(complex64 value)
00464     {
00465         float32 realVal = value.real();
00466         float32 imagVal = value.real();
00467         uchar *chreal = (uchar *)&realVal;
00468         uchar *chimag = (uchar *)&imagVal;
00469         return ((chreal[3] & 0x7f) != 0x7f || (chreal[2] & 0x80) != 0x80) && ((chimag[3] & 0x7f) != 0x7f || (chimag[2] & 0x80) != 0x80);
00470     }
00471 
00473     template<> inline bool isFinite<complex128>(complex128 value)
00474     {
00475         float64 realVal = value.real();
00476         float64 imagVal = value.real();
00477         uchar *chreal = (uchar *)&realVal;
00478         uchar *chimag = (uchar *)&imagVal;
00479         return ((chreal[7] & 0x7f) != 0x7f || (chreal[6] & 0xf0) != 0xf0) && ((chimag[7] & 0x7f) != 0x7f || (chimag[6] & 0xf0) != 0xf0);
00480     }
00481 
00483     template<typename _Tp> inline bool isNaN(_Tp value)
00484     {
00485         return false;
00486     }
00487 
00489     template<> inline bool isNaN<float32>(float32 value)
00490     {
00491         uchar *ch = (uchar *)&value;
00492         return (ch[3] & 0x7f) == 0x7f && ch[2] > 0x80;
00493     }
00495     template<> inline bool isNaN<float64>(float64 value)
00496     {
00497         uchar *ch = (uchar *)&value;
00498         return (ch[7] & 0x7f) == 0x7f && ch[6] > 0xf0;
00499     }
00500 
00502     template<> inline bool isNaN<complex64>(complex64 value)
00503     {
00504         float32 realVal = value.real();
00505         float32 imagVal = value.real();
00506         uchar *chreal = (uchar *)&realVal;
00507         uchar *chimag = (uchar *)&imagVal;
00508         return ((chreal[3] & 0x7f) == 0x7f && chreal[2] > 0x80) || ((chimag[3] & 0x7f) == 0x7f && chimag[2] > 0x80);
00509     }
00510 
00512     template<> inline bool isNaN<complex128>(complex128 value)
00513     {
00514         float64 realVal = value.real();
00515         float64 imagVal = value.real();
00516         uchar *chreal = (uchar *)&realVal;
00517         uchar *chimag = (uchar *)&imagVal;
00518         return ((chreal[7] & 0x7f) == 0x7f && chreal[6] > 0xf0) || ((chimag[7] & 0x7f) == 0x7f && chimag[6] > 0xf0);
00519     }
00520 
00522     template<typename _Tp> inline bool isInf(_Tp /*value*/)
00523     {
00524         return false;
00525     }
00526 
00528     template<> inline bool isInf<float32>(float32 value)
00529     {
00530         uchar *ch = (uchar *)&value;
00531         return (ch[3] & 0x7f) == 0x7f && ch[2] == 0x80;
00532     }
00533 
00535     template<> inline bool isInf<float64>(float64 value)
00536     {
00537         uchar *ch = (uchar *)&value;
00538         return (ch[7] & 0x7f) == 0x7f && ch[6] == 0xf0;
00539     }
00540 
00542     template<> inline bool isInf<complex64>(complex64 value)
00543     {
00544         float32 realVal = value.real();
00545         float32 imagVal = value.real();
00546         uchar *chreal = (uchar *)&realVal;
00547         uchar *chimag = (uchar *)&imagVal;
00548         return ((chreal[3] & 0x7f) == 0x7f && chreal[2] == 0x80) || ((chimag[3] & 0x7f) == 0x7f && chimag[2] == 0x80);
00549     }
00550 
00552     template<> inline bool isInf<complex128>(complex128 value)
00553     {
00554         float64 realVal = value.real();
00555         float64 imagVal = value.real();
00556         uchar *chreal = (uchar *)&realVal;
00557         uchar *chimag = (uchar *)&imagVal;
00558         return ((chreal[7] & 0x7f) == 0x7f && chreal[6] == 0xf0) || ((chimag[7] & 0x7f) == 0x7f && chimag[6] == 0xf0);
00559     }
00560 
00562     template<typename _Tp> RetVal minValueFunc(const DataObject *dObj, float64 &minValue, uint32 *firstLocation, bool ignoreInf = true);
00563     
00565     RetVal DATAOBJ_EXPORT minValue(const DataObject *dObj, float64 &minValue, uint32 *firstLocation, bool ignoreInf = true);
00566        
00568     template<typename _Tp> RetVal maxValueFunc(const DataObject *dObj, float64 &maxValue, uint32 *firstLocation, bool ignoreInf = true);
00569 
00571     RetVal DATAOBJ_EXPORT maxValue(const DataObject *dObj, float64 &maxValue, uint32 *firstLocation, bool ignoreInf = true);
00572         
00574     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);
00575     
00577     RetVal DATAOBJ_EXPORT minMaxValue(const DataObject *dObj, float64 &minValue, uint32 *firstMinLocation, float64 &maxValue, uint32 *firstMaxLocation, bool ignoreInf = true, const int specialDataTypeFlags = CMPLX_ABS_VALUE);
00578 
00579     template<typename _Tp, typename _BufTp> RetVal meanValueFunc(const DataObject *dObj, float64 &meanResult, bool ignoreNaN = true);
00580     RetVal DATAOBJ_EXPORT meanValue(const DataObject *dObj, float64 &meanResult, bool ignoreNaN = true);
00581 
00582     template<typename _Tp, typename _BufTp> RetVal devValueFunc(const ito::DataObject *dObj, const int devTypFlag, float64 &meanResult, float64 &devResult, bool ignoreNaN = true);
00583     RetVal DATAOBJ_EXPORT devValue(const DataObject *dObj, const int devTypFlag, float64 &meanResult, float64 &devResult, bool ignoreNaN = true);
00584 
00585     RetVal DATAOBJ_EXPORT calcCVDFT(DataObject *dObjIO, const bool inverse, const bool inverseAsReal, const bool lineWise);
00586 
00588     ito::RetVal DATAOBJ_EXPORT verifyDataObjectType(const ito::DataObject* dObj, const char* name, uint8 numberOfAllowedTypes, ...); //append allowed data types, e.g. ito::tUint8, ito::tInt8... (order does not care)
00589     
00591     ito::RetVal DATAOBJ_EXPORT 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)
00592     
00594     //ito::RetVal DATAOBJ_EXPORT verify1PlaneDObject(const ito::DataObject* dObj, const char* name, int &yIdx, int sizeYMin, int sizeYMax, int &xIdx, int sizeXMin, int sizeXMax, uint8 numberOfAllowedTypes, ...); //append allowed data types, e.g. ito::tUint8, ito::tInt8... (order does not care)
00595     
00597     ito::RetVal DATAOBJ_EXPORT 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)
00598     
00599     ito::RetVal DATAOBJ_EXPORT verifySize(int size, int minSize, int maxSize, const char *axisName, const char* dObjName);
00600 
00602     ito::DataObject DATAOBJ_EXPORT squeezeConvertCheck2DDataObject(const ito::DataObject *dObj, const char* name, const ito::Range &sizeY, const ito::Range &sizeX, ito::RetVal &retval, int convertToType, uint8 numberOfAllowedTypes, ...);
00603     
00604     //-----------------------------------------------------------------------------------------------
00617     template<typename _Tp> ito::RetVal freeRowPointer(_Tp *** &pointer)
00618     {
00619         if(pointer == NULL)
00620         {
00621             return ito::RetVal::format(ito::retError, 0, "Delete rowpointer failed, pointer was not allocated freeRowPointer(...)");
00622         }
00623 
00624         int i = 0;
00625 
00626         while(pointer[i] != 0)
00627         {
00628             free(pointer[i]);
00629             i++;
00630             // end of pointer is marked by a NULL-Pointer
00631         }
00632 
00633         free(pointer);
00634         pointer = NULL;
00635 
00636         return ito::retOk;
00637     }
00638 
00654     template<typename _Tp> ito::RetVal getRowPointer(ito::DataObject* dObj, _Tp *** &pointer)  
00655     {
00656 
00657         if(!dObj)
00658         {
00659             return ito::RetVal::format(ito::retError, 0, "DataObject was a NULL pointer in function getRowPointer(...)");               
00660         }
00661 
00662         if(dObj->getType() != ito::getDataType2<_Tp*>())
00663         {
00664             return ito::RetVal::format(ito::retError, 0, "DataObject and template Type differed in function getRowPointer(...)");               
00665         }
00666 
00667         if(dObj->getDims() < 2)
00668         {
00669             return ito::RetVal::format(ito::retError, 0, "DataObject was not initialized in function getRowPointer(...)");   
00670         }
00671 
00672         pointer = (_Tp***)calloc(dObj->getNumPlanes() + 1, sizeof(_Tp**));
00673 
00674         if(pointer == NULL)
00675         {
00676             return ito::RetVal::format(ito::retError, 0, "Allocate plane-pointer failed in function getRowPointer(...)");
00677         }
00678 
00679         ito::RetVal retVal(ito::retOk);
00680         int sizeY = dObj->getSize(dObj->getDims() - 2);
00681 
00682         cv::Mat** mdata = dObj->get_mdata();
00683         int numMats = dObj->getNumPlanes();
00684         for(int i = 0; i < dObj->getNumPlanes(); i++)
00685         {
00686             pointer[i] = (_Tp**)calloc(sizeY, sizeof(_Tp*));
00687             if(pointer[i])
00688             {
00689                 for(int y = 0; y < sizeY; y++)
00690                 {
00691                     pointer[i][y] = mdata[dObj->seekMat(i, numMats)]->ptr<_Tp>(y);
00692                 }
00693             }
00694             else
00695             {
00696                 retVal += ito::RetVal::format(ito::retError, 0, "Allocate row-pointer failed in function getRowPointer(...)");
00697                 break;
00698             }
00699         }
00700 
00701         if(retVal.containsError())
00702         {
00703             freeRowPointer(pointer);
00704         }
00705         return retVal;
00706     } 
00707  
00708     //-----------------------------------------------------------------------------------------------
00717     inline bool isIntType(const int type, int *size)
00718     {
00719         if((type == ito::tInt8)||(type == ito::tUInt8))
00720         {
00721             *size = 1;
00722             return true;
00723         }
00724         else if((type == ito::tInt16)||(type == ito::tUInt16))
00725         {
00726             *size = 2;
00727             return true;
00728         }
00729         else if((type == ito::tInt32)||(type == ito::tUInt32))
00730         {
00731             *size = 4;
00732             return true;
00733         }
00734         else
00735         {
00736             *size = -1;
00737             return false;
00738         }
00739     }
00740 
00741     //-----------------------------------------------------------------------------------------------
00750     inline bool isFPType(const int type, int *size)
00751     {
00752         if((type == ito::tFloat32))
00753         {
00754             *size = 4;
00755             return true;
00756         }
00757         else if((type == ito::tFloat64))
00758         {
00759             *size = 8;
00760             return true;
00761         }
00762         else
00763         {
00764             *size = -1;
00765             return false;
00766         }
00767     }
00768 
00769     //-----------------------------------------------------------------------------------------------
00778     inline bool isCplxType(const int type, int *size)
00779     {
00780         if((type == ito::tComplex64))
00781         {
00782             *size = 8;
00783             return true;
00784         }
00785         else if((type == ito::tComplex128))
00786         {
00787             *size = 16;
00788             return true;
00789         }
00790         else
00791         {
00792             *size = -1;
00793             return false;
00794         }
00795     }
00796 
00797     //-----------------------------------------------------------------------------------------------
00810     inline bool dObjareEqualDetail(const ito::DataObject *dObj1, const ito::DataObject *dObj2, bool &typeFlag, bool &dimsFlag, bool &last2DimsFlag)
00811     {
00812         assert(dObj1 && dObj2);
00813 
00814         bool sizeEqual;
00815 
00816         last2DimsFlag = true;
00817 
00818         int d1 = dObj1->getDims();
00819         int d2 = dObj2->getDims();
00820         dimsFlag = (d1 == d2);
00821         typeFlag = (dObj1->getType() == dObj2->getType());
00822 
00823         if(d1 != d2)
00824         {
00825             sizeEqual = false;
00826 
00827             if (d1 >= 2 && d2 >= 2)
00828             {
00829                 if(dObj1->getSize(dObj1->getDims() - 2) != dObj2->getSize(dObj2->getDims() - 2))
00830                 {
00831                     last2DimsFlag = false;
00832                 }
00833                 else if(dObj1->getSize(dObj1->getDims() - 1) != dObj2->getSize(dObj2->getDims() - 1))
00834                 {
00835                     last2DimsFlag = false;
00836                 }
00837             }
00838             else
00839             {
00840                 last2DimsFlag = false;
00841             }
00842         }
00843         else
00844         {
00845             sizeEqual = (dObj1->getSize() == dObj2->getSize());
00846 
00847             if (d1 >= 2)
00848             {
00849                 if(dObj1->getSize(dObj1->getDims() - 2) != dObj2->getSize(dObj2->getDims() - 2))
00850                 {
00851                     last2DimsFlag = false;
00852                 }
00853                 else if(dObj1->getSize(dObj1->getDims() - 1) != dObj2->getSize(dObj2->getDims() - 1))
00854                 {
00855                     last2DimsFlag = false;
00856                 }
00857             }
00858             else
00859             {
00860                 last2DimsFlag = false;
00861             }
00862         }
00863         return typeFlag && dimsFlag && last2DimsFlag && sizeEqual;
00864     }
00865 
00866     //-----------------------------------------------------------------------------------------------
00876     inline bool dObjareEqualShort(const ito::DataObject *obj1, const ito::DataObject *obj2)
00877     {
00878         assert(obj1 && obj2);
00879 
00880         return (obj1->getType() == obj2->getType()) && (obj1->getSize() == obj2->getSize());
00881     }
00882 
00884     ito::RetVal DATAOBJ_EXPORT dObjCopyLastNAxisTags(const ito::DataObject &DataObjectIn, ito::DataObject &DataObjectOut, const int copyLastNDims, const bool includeValueTags = true, const bool includeRotationMatrix = true);
00885 
00886     ito::RetVal DATAOBJ_EXPORT dObjSetScaleRectangle(ito::DataObject &DataObjectInOut, const double &x0, const double &x1, const double &y0, const double &y1);
00887 } //end namespace dObjHelper
00888 } //end namespace ito
00889 
00890 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends