00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef AMROC_VECTOR_GRIDDATA_OPS_H
00010 #define AMROC_VECTOR_GRIDDATA_OPS_H
00011
00019 #define Scalar_Vector_GridData_Functions(NameFrom,ope) \
00020 template <class DataType, class VectorType> \
00021 void NameFrom (GridData<DataType,1> &target, const BBox &to, \
00022 GridData<VectorType,1> const &source, const BBox &from, \
00023 const int comp) { \
00024 \
00025 const Coords toshift = from.lower() - to.lower(); \
00026 BBox newfrom = source.bbox() * from * shiftabs(target.bbox() * to, toshift); \
00027 if (!newfrom.empty()) { \
00028 BBox newto = shiftabs(newfrom, -toshift); \
00029 \
00030 const int dk = newfrom.lower(0)-newto.lower(0); \
00031 \
00032 BeginFastIndex1(src, source.bbox(), source.data(), const VectorType); \
00033 BeginFastIndex1(tgt, target.bbox(), target.data(), DataType); \
00034 \
00035 for_1 (k, newto, newto.stepsize()) \
00036 FastIndex1(tgt, k) ope FastIndex1(src, k+dk)(comp); \
00037 end_for \
00038 \
00039 EndFastIndex1(src); \
00040 EndFastIndex1(tgt); \
00041 } \
00042 } \
00043 \
00044 template <class DataType, class VectorType> \
00045 void NameFrom (GridData<DataType,1> &target, \
00046 GridData<VectorType,1> const &source, \
00047 const int comp) { \
00048 NameFrom (target, target.bbox(), source, source.bbox(), comp); \
00049 }
00050
00051 Scalar_Vector_GridData_Functions(equals_from,=)
00052 Scalar_Vector_GridData_Functions(plus_from,+=)
00053 Scalar_Vector_GridData_Functions(minus_from,-=)
00054 Scalar_Vector_GridData_Functions(multiply_from,*=)
00055 Scalar_Vector_GridData_Functions(divide_from,/=)
00056 #undef Scalar_Vector_GridData_Functions
00057
00058
00059 #define Vector_Scalar_GridData_Functions(NameTo,ope) \
00060 template <class VectorType, class DataType> \
00061 void NameTo (GridData<VectorType,1> &target, const BBox &to, \
00062 GridData<DataType,1> const &source, const BBox &from, \
00063 const int comp) { \
00064 \
00065 const Coords toshift = from.lower() - to.lower(); \
00066 BBox newfrom = source.bbox() * from * shiftabs(target.bbox() * to, toshift); \
00067 if (!newfrom.empty()) { \
00068 BBox newto = shiftabs(newfrom, -toshift); \
00069 \
00070 const int dk = newfrom.lower(0)-newto.lower(0); \
00071 \
00072 BeginFastIndex1(src, source.bbox(), source.data(), const DataType); \
00073 BeginFastIndex1(tgt, target.bbox(), target.data(), VectorType); \
00074 \
00075 for_1 (k, newto, newto.stepsize()) \
00076 FastIndex1(tgt, k)(comp) ope FastIndex1(src, k+dk); \
00077 end_for \
00078 \
00079 EndFastIndex1(src); \
00080 EndFastIndex1(tgt); \
00081 } \
00082 } \
00083 \
00084 template <class VectorType, class DataType> \
00085 void NameTo (GridData<VectorType,1> &target, \
00086 GridData<DataType,1> const &source, \
00087 const int comp) { \
00088 NameTo (target, target.bbox(), source, source.bbox(), comp); \
00089 }
00090
00091 Vector_Scalar_GridData_Functions(equals_to,=)
00092 Vector_Scalar_GridData_Functions(plus_to,+=)
00093 Vector_Scalar_GridData_Functions(minus_to,-=)
00094 Vector_Scalar_GridData_Functions(multiply_to,*=)
00095 Vector_Scalar_GridData_Functions(divide_to,/=)
00096 #undef Vector_Scalar_GridData_Functions
00097
00098
00099 #define Scalar_Vector_GridData_Functions(NameFrom,ope) \
00100 template <class DataType, class VectorType> \
00101 void NameFrom (GridData<DataType,2> &target, const BBox &to, \
00102 GridData<VectorType,2> const &source, const BBox &from, \
00103 const int comp) { \
00104 \
00105 const Coords toshift = from.lower() - to.lower(); \
00106 BBox newfrom = source.bbox() * from * shiftabs(target.bbox() * to, toshift); \
00107 if (!newfrom.empty()) { \
00108 BBox newto = shiftabs(newfrom, -toshift); \
00109 \
00110 const int dk = newfrom.lower(0)-newto.lower(0); \
00111 const int dl = newfrom.lower(1)-newto.lower(1); \
00112 \
00113 BeginFastIndex2(src, source.bbox(), source.data(), const VectorType); \
00114 BeginFastIndex2(tgt, target.bbox(), target.data(), DataType); \
00115 \
00116 for_2 (k, l, newto, newto.stepsize()) \
00117 FastIndex2(tgt, k, l) ope FastIndex2(src, k+dk, l+dl)(comp); \
00118 end_for \
00119 \
00120 EndFastIndex2(src); \
00121 EndFastIndex2(tgt); \
00122 } \
00123 } \
00124 \
00125 template <class DataType, class VectorType> \
00126 void NameFrom (GridData<DataType,2> &target, \
00127 GridData<VectorType,2> const &source, \
00128 const int comp) { \
00129 NameFrom (target, target.bbox(), source, source.bbox(), comp); \
00130 }
00131
00132 Scalar_Vector_GridData_Functions(equals_from,=)
00133 Scalar_Vector_GridData_Functions(plus_from,+=)
00134 Scalar_Vector_GridData_Functions(minus_from,-=)
00135 Scalar_Vector_GridData_Functions(multiply_from,*=)
00136 Scalar_Vector_GridData_Functions(divide_from,/=)
00137 #undef Scalar_Vector_GridData_Functions
00138
00139
00140 #define Vector_Scalar_GridData_Functions(NameTo,ope) \
00141 template <class VectorType, class DataType> \
00142 void NameTo (GridData<VectorType,2> &target, const BBox &to, \
00143 GridData<DataType,2> const &source, const BBox &from, \
00144 const int comp) { \
00145 \
00146 const Coords toshift = from.lower() - to.lower(); \
00147 BBox newfrom = source.bbox() * from * shiftabs(target.bbox() * to, toshift); \
00148 if (!newfrom.empty()) { \
00149 BBox newto = shiftabs(newfrom, -toshift); \
00150 \
00151 const int dk = newfrom.lower(0)-newto.lower(0); \
00152 const int dl = newfrom.lower(1)-newto.lower(1); \
00153 \
00154 BeginFastIndex2(src, source.bbox(), source.data(), const DataType); \
00155 BeginFastIndex2(tgt, target.bbox(), target.data(), VectorType); \
00156 \
00157 for_2 (k, l, newto, newto.stepsize()) \
00158 FastIndex2(tgt, k, l)(comp) ope FastIndex2(src, k+dk, l+dl); \
00159 end_for \
00160 \
00161 EndFastIndex2(src); \
00162 EndFastIndex2(tgt); \
00163 } \
00164 } \
00165 \
00166 template <class VectorType, class DataType> \
00167 void NameTo (GridData<VectorType,2> &target, \
00168 GridData<DataType,2> const &source, \
00169 const int comp) { \
00170 NameTo (target, target.bbox(), source, source.bbox(), comp); \
00171 }
00172
00173 Vector_Scalar_GridData_Functions(equals_to,=)
00174 Vector_Scalar_GridData_Functions(plus_to,+=)
00175 Vector_Scalar_GridData_Functions(minus_to,-=)
00176 Vector_Scalar_GridData_Functions(multiply_to,*=)
00177 Vector_Scalar_GridData_Functions(divide_to,/=)
00178 #undef Vector_Scalar_GridData_Functions
00179
00180
00181 #define Scalar_Vector_GridData_Functions(NameFrom,ope) \
00182 template <class DataType, class VectorType> \
00183 void NameFrom (GridData<DataType,3> &target, const BBox &to, \
00184 GridData<VectorType,3> const &source, const BBox &from, \
00185 const int comp) { \
00186 \
00187 const Coords toshift = from.lower() - to.lower(); \
00188 BBox newfrom = source.bbox() * from * shiftabs(target.bbox() * to, toshift); \
00189 if (!newfrom.empty()) { \
00190 BBox newto = shiftabs(newfrom, -toshift); \
00191 \
00192 const int dk = newfrom.lower(0)-newto.lower(0); \
00193 const int dl = newfrom.lower(1)-newto.lower(1); \
00194 const int dm = newfrom.lower(2)-newto.lower(2); \
00195 \
00196 BeginFastIndex3(src, source.bbox(), source.data(), const VectorType); \
00197 BeginFastIndex3(tgt, target.bbox(), target.data(), DataType); \
00198 \
00199 for_3 (k, l, m, newto, newto.stepsize()) \
00200 FastIndex3(tgt, k, l, m) ope FastIndex3(src, k+dk, l+dl, m+dm)(comp); \
00201 end_for \
00202 \
00203 EndFastIndex3(src); \
00204 EndFastIndex3(tgt); \
00205 } \
00206 } \
00207 \
00208 template <class DataType, class VectorType> \
00209 void NameFrom (GridData<DataType,3> &target, \
00210 GridData<VectorType,3> const &source, \
00211 const int comp) { \
00212 NameFrom (target, target.bbox(), source, source.bbox(), comp); \
00213 }
00214
00215 Scalar_Vector_GridData_Functions(equals_from,=)
00216 Scalar_Vector_GridData_Functions(plus_from,+=)
00217 Scalar_Vector_GridData_Functions(minus_from,-=)
00218 Scalar_Vector_GridData_Functions(multiply_from,*=)
00219 Scalar_Vector_GridData_Functions(divide_from,/=)
00220 #undef Scalar_Vector_GridData_Functions
00221
00222
00223 #define Vector_Scalar_GridData_Functions(NameTo,ope) \
00224 template <class VectorType, class DataType> \
00225 void NameTo (GridData<VectorType,3> &target, const BBox &to, \
00226 GridData<DataType,3> const &source, const BBox &from, \
00227 const int comp) { \
00228 \
00229 const Coords toshift = from.lower() - to.lower(); \
00230 BBox newfrom = source.bbox() * from * shiftabs(target.bbox() * to, toshift); \
00231 if (!newfrom.empty()) { \
00232 BBox newto = shiftabs(newfrom, -toshift); \
00233 \
00234 const int dk = newfrom.lower(0)-newto.lower(0); \
00235 const int dl = newfrom.lower(1)-newto.lower(1); \
00236 const int dm = newfrom.lower(2)-newto.lower(2); \
00237 \
00238 BeginFastIndex3(src, source.bbox(), source.data(), const DataType); \
00239 BeginFastIndex3(tgt, target.bbox(), target.data(), VectorType); \
00240 \
00241 for_3 (k, l, m, newto, newto.stepsize()) \
00242 FastIndex3(tgt, k, l, m)(comp) ope FastIndex3(src, k+dk, l+dl, m+dm); \
00243 end_for \
00244 \
00245 EndFastIndex3(src); \
00246 EndFastIndex3(tgt); \
00247 } \
00248 } \
00249 \
00250 template <class VectorType, class DataType> \
00251 void NameTo (GridData<VectorType,3> &target, \
00252 GridData<DataType,3> const &source, \
00253 const int comp) { \
00254 NameTo (target, target.bbox(), source, source.bbox(), comp); \
00255 }
00256
00257 Vector_Scalar_GridData_Functions(equals_to,=)
00258 Vector_Scalar_GridData_Functions(plus_to,+=)
00259 Vector_Scalar_GridData_Functions(minus_to,-=)
00260 Vector_Scalar_GridData_Functions(multiply_to,*=)
00261 Vector_Scalar_GridData_Functions(divide_to,/=)
00262 #undef Vector_Scalar_GridData_Functions
00263
00264
00265 #endif