libSourceOperations.h
Go to the documentation of this file.00001 #ifndef __LIBSOURCEOPERATIONS_H__
00002 #define __LIBSOURCEOPERATIONS_H__
00003
00004 #include "Image.h"
00005 #include "libRefCount.h"
00006 #include "SourceTransform.h"
00007
00008
00009
00010 template<class SOURCE_IN, int DIMENSIONALITY, class DATA_OUT>
00011 void CopyInto(SourceMemoryOf<DATA_OUT, DIMENSIONALITY>& srcOut, const SOURCE_IN &srcIn, bool bPrepared =
00012 false)
00013 {
00014 if (!bPrepared)
00015 {
00016 srcIn.PrepareForAccess();
00017 }
00018 DATA_OUT *vdata = srcOut.WriteData();
00019 typedef PointOf<DIMENSIONALITY, int> POINT;
00020
00021
00022 int n = 0;
00023 forpoint(POINT,pt,0,srcOut.Size())
00024 {
00025 GetPoint(srcIn,vdata[n],pt);
00026 n++;
00027 }
00028 }
00029
00030
00031
00032 template<class SOURCE_IN, int DIMENSIONALITY, class DATA_OUT>
00033 void AllocatedCopy(SourceMemoryOf<DATA_OUT, DIMENSIONALITY>& srcOut, const SOURCE_IN& srcIn)
00034 {
00035 srcIn.PrepareForAccess();
00036 srcOut.Allocate(srcIn.Size());
00037 CopyInto(srcOut, srcIn, false);
00038 }
00039
00040
00041
00042 template<class SOURCE_IN, int DIMENSIONALITY, class DATA_OUT>
00043 void AllocatedCopy(SourceMemoryOf<DATA_OUT, DIMENSIONALITY>& srcOut, SOURCE_IN* psrcIn)
00044 {
00045 ClaimPointer(psrcIn);
00046 psrcIn->PrepareForAccess();
00047 srcOut.Allocate(psrcIn->Size());
00048
00049 typedef PointOf<DIMENSIONALITY, int> POINT;
00050
00051 forpoint(POINT,pt,0,srcOut.Size())
00052 {
00053 TypeOfData(SOURCE_IN) dataIn;
00054 DATA_OUT dataOut;
00055
00056 GetPoint(*psrcIn,dataIn,pt);
00057 dataOut=dataIn;
00058 SetPoint(srcOut,pt,dataOut);
00059 }
00060 ReleasePointer(psrcIn);
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 }
00079
00080
00081 template<class SOURCE_IN, class SOURCE_OUT>
00082 void CopyInto(SOURCE_OUT *psrcOut, SOURCE_IN *psrcIn, bool bPrepared = false)
00083 {
00084 ClaimPointer(psrcIn);
00085 ClaimPointer(psrcOut);
00086 if (!bPrepared)
00087 {
00088 psrcIn->PrepareForAccess();
00089 psrcOut->PrepareForAccess();
00090 }
00091 typedef typename SOURCE_OUT::type_point POINT;
00092 typedef typename SOURCE_IN::type_data DATA_IN;
00093 typedef typename SOURCE_OUT::type_data DATA_OUT;
00094
00095 forpoint(POINT,pt,0,psrcOut->Size())
00096 {
00097 DATA_IN dataIn;
00098 DATA_OUT dataOut;
00099
00100 GetPoint(*psrcIn,dataIn,pt);
00101 dataOut=dataIn;
00102 SetPoint(*psrcOut,pt,dataOut);
00103 }
00104 ReleasePointer(psrcIn);
00105 ReleasePointer(psrcOut);
00106 }
00107
00108 #endif //__LIBSOURCEOPERATIONS_H__