00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef ARRAY_WRAP_5_h
00038 #define ARRAY_WRAP_5_h
00039
00040 #include <../arrayGutz/arrayBase.h>
00041 #include <assert.h>
00042 #include "arrayWrap2.h"
00043
00044 namespace gutz {
00045
00046
00047
00048
00049 template <class T>
00050 class arrayWrap5 : public arrayBase<T>
00051 {
00052 public:
00053
00054 arrayWrap5();
00055 arrayWrap5( int d0, int d1, int d2, int d3, int d4, T* v );
00056 arrayWrap5( const arrayWrap5<T>& a );
00057 arrayWrap5<T>& operator=( const arrayWrap5<T>& a );
00058
00059 virtual ~arrayWrap5();
00060
00061
00062 inline arrayWrap4<T>& operator[] (int i);
00063 inline const arrayWrap4<T>& operator[] (int i) const;
00064
00065
00066 inline T& operator() (int i, int j, int k, int m, int n);
00067 inline const T& operator() (int i, int j, int k, int m, int n) const;
00068
00069 protected:
00070
00071
00072
00073 mutable arrayWrap4<T> mSlice;
00074
00075 private:
00076 inline void setSlice( int i ) const;
00077 inline int address( int i, int j, int k, int m, int n) const;
00078 inline void setData( T* d ) { mData = d; }
00079 };
00080
00081
00082
00083
00084
00085
00086 template <class T>
00087 arrayWrap5<T>::arrayWrap5 ()
00088 :arrayBase<T>(), mSlice(arrayWrap4<T>())
00089 {}
00090
00091 template <class T>
00092 arrayWrap5<T>::arrayWrap5 (int d0, int d1, int d2, int d3, int d4, T* v)
00093 :arrayBase<T>(d0,d1,d2,d3,d4,v), mSlice(arrayWrap4<T>(d1,d2,d3,d4,v))
00094 {}
00095
00096
00097 template <class T>
00098 arrayWrap5<T>::arrayWrap5<T>( const arrayWrap5<T>& a ) : arrayBase<T>(a)
00099 {
00100 mSlice = a.mSlice;
00101 }
00102
00103
00104 template <class T>
00105 arrayWrap5<T>& arrayWrap5<T>::operator=(const arrayWrap5<T>& a)
00106 {
00107 if( this != &a ) {
00108 arrayBase<T>::operator=(a);
00109 mSlice = a.mSlice;
00110 }
00111 return *this;
00112 }
00113
00114
00115 template <class T>
00116 arrayWrap5<T>::~arrayWrap5()
00117 {}
00118
00119
00120 template <class T>
00121 inline arrayWrap4<T>& arrayWrap5<T>::operator[] (int i)
00122 {
00123 setSlice(i);
00124 return mSlice;
00125 }
00126
00127 template <class T>
00128 inline const arrayWrap4<T>& arrayWrap5<T>::operator[] (int i) const
00129 {
00130 setSlice(i);
00131 return mSlice;
00132 }
00133
00134 template <class T>
00135 inline T& arrayWrap5<T>::operator() (int i, int j, int k, int m, int n)
00136 {
00137 return mData[ address(i,j,k,m,n) ];
00138 }
00139
00140 template <class T>
00141 inline const T& arrayWrap5<T>::operator() (int i, int j, int k, int m, int n) const
00142 {
00143 return mData[ address(i,j,k,m,n) ];
00144 }
00145
00146 template <class T>
00147 inline int arrayWrap5<T>::address( int i, int j, int k, int m, int n) const
00148 {
00149
00150 return i*mAxisStride[0] + j*mAxisStride[1] + k*mAxisStride[2] + m*mAxisStride[3] + n;
00151 }
00152
00153
00154 template <class T>
00155 inline void arrayWrap5<T>::setSlice( int i ) const
00156 {
00157
00158 int a = i * mAxisStride[0];
00159 assert( a < mSize );
00160 mSlice.setData( mData + a );
00161 }
00162
00163
00164
00165
00166
00167 typedef arrayWrap5<char> arrayw5c;
00168 typedef arrayWrap5<uchar> arrayw5uc;
00169 typedef arrayWrap5<char> arrayw5b;
00170 typedef arrayWrap5<uchar> arrayw5ub;
00171 typedef arrayWrap5<short> arrayw5s;
00172 typedef arrayWrap5<ushort> arrayw5us;
00173 typedef arrayWrap5<int> arrayw5i;
00174 typedef arrayWrap5<uint> arrayw5ui;
00175 typedef arrayWrap5<long> arrayw5l;
00176 typedef arrayWrap5<ulong> arrayw5ul;
00177 typedef arrayWrap5<llong> arrayw5ll;
00178 typedef arrayWrap5<ullong> arrayw5ull;
00179 typedef arrayWrap5<float> arrayw5f;
00180 typedef arrayWrap5<double> arrayw5d;
00181
00182 #ifdef USING_MATHGUTZ
00183 typedef arrayWrap5<vec2ub> arrayw5v2ub;
00184 typedef arrayWrap5<vec2i> arrayw5v2i;
00185 typedef arrayWrap5<vec2ui> arrayw5v2ui;
00186 typedef arrayWrap5<vec2f> arrayw5v2f;
00187
00188 typedef arrayWrap5<vec3ub> arrayw5v3ub;
00189 typedef arrayWrap5<vec3i> arrayw5v3i;
00190 typedef arrayWrap5<vec3ui> arrayw5v3ui;
00191 typedef arrayWrap5<vec3f> arrayw5v3f;
00192
00193 typedef arrayWrap5<vec4ub> arrayw5v4ub;
00194 typedef arrayWrap5<vec4i> arrayw5v4i;
00195 typedef arrayWrap5<vec4ui> arrayw5v4ui;
00196 typedef arrayWrap5<vec4f> arrayw5v4f;
00197
00198 typedef arrayWrap5<mat2ub> arrayw5m2ub;
00199 typedef arrayWrap5<mat2i> arrayw5m2i;
00200 typedef arrayWrap5<mat2ui> arrayw5m2ui;
00201 typedef arrayWrap5<mat2f> arrayw5m2f;
00202
00203 typedef arrayWrap5<mat3ub> arrayw5m3ub;
00204 typedef arrayWrap5<mat3i> arrayw5m3i;
00205 typedef arrayWrap5<mat3ui> arrayw5m3ui;
00206 typedef arrayWrap5<mat3f> arrayw5m3f;
00207
00208 typedef arrayWrap5<mat4ub> arrayw5m4ub;
00209 typedef arrayWrap5<mat4i> arrayw5m4i;
00210 typedef arrayWrap5<mat4ui> arrayw5m4ui;
00211 typedef arrayWrap5<mat4f> arrayw5m4f;
00212 #endif
00213
00214 }
00215
00216 #endif // arrayWrap5_h