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_4_h
00038 #define ARRAY_WRAP_4_h
00039
00040 #include <../arrayGutz/arrayBase.h>
00041 #include <assert.h>
00042 #include "arrayWrap2.h"
00043
00044 namespace gutz {
00045
00046
00047 template <class T> class arrayWrap5;
00048
00049
00050
00051
00052 template <class T>
00053 class arrayWrap4 : public arrayBase<T>
00054 {
00055 public:
00056 friend class arrayWrap5<T>;
00057
00058
00059 arrayWrap4();
00060 arrayWrap4( int d0, int d1, int d2, int d3, T* v );
00061 arrayWrap4( const arrayWrap4<T>& a );
00062 arrayWrap4<T>& operator=( const arrayWrap4<T>& a );
00063
00064 virtual ~arrayWrap4();
00065
00066
00067 inline arrayWrap3<T>& operator[] (int i);
00068 inline const arrayWrap3<T>& operator[] (int i) const;
00069
00070
00071 inline T& operator() (int i, int j, int k, int m);
00072 inline const T& operator() (int i, int j, int k, int m) const;
00073
00074 protected:
00075
00076
00077
00078 mutable arrayWrap3<T> mSlice;
00079
00080 private:
00081 inline void setSlice( int i ) const;
00082 inline int address( int i, int j, int k, int m ) const;
00083 inline void setData( T* d ) { mData = d; }
00084 };
00085
00086
00087
00088
00089
00090
00091 template <class T>
00092 arrayWrap4<T>::arrayWrap4 ()
00093 :arrayBase<T>(), mSlice(arrayWrap3<T>())
00094 {}
00095
00096 template <class T>
00097 arrayWrap4<T>::arrayWrap4 (int d0, int d1, int d2, int d3, T* v)
00098 :arrayBase<T>(d0,d1,d2,d3,v), mSlice(arrayWrap3<T>(d1,d2,d3,v))
00099 {}
00100
00101
00102 template <class T>
00103 arrayWrap4<T>::arrayWrap4<T>( const arrayWrap4<T>& a ) : arrayBase<T>(a)
00104 {
00105 mSlice = a.mSlice;
00106 }
00107
00108
00109 template <class T>
00110 arrayWrap4<T>& arrayWrap4<T>::operator=(const arrayWrap4<T>& a)
00111 {
00112 if( this != &a ) {
00113 arrayBase<T>::operator=(a);
00114 mSlice = a.mSlice;
00115 }
00116 return *this;
00117 }
00118
00119
00120 template <class T>
00121 arrayWrap4<T>::~arrayWrap4()
00122 {}
00123
00124
00125 template <class T>
00126 inline arrayWrap3<T>& arrayWrap4<T>::operator[] (int i)
00127 {
00128 setSlice(i);
00129 return mSlice;
00130 }
00131
00132 template <class T>
00133 inline const arrayWrap3<T>& arrayWrap4<T>::operator[] (int i) const
00134 {
00135 setSlice(i);
00136 return mSlice;
00137 }
00138
00139 template <class T>
00140 inline T& arrayWrap4<T>::operator() (int i, int j, int k, int m)
00141 {
00142 return mData[ address(i,j,k,m) ];
00143 }
00144
00145 template <class T>
00146 inline const T& arrayWrap4<T>::operator() (int i, int j, int k, int m) const
00147 {
00148 return mData[ address(i,j,k,m) ];
00149 }
00150
00151 template <class T>
00152 inline int arrayWrap4<T>::address( int i, int j, int k, int m) const
00153 {
00154
00155 return i*mAxisStride[0] + j*mAxisStride[1] + k*mAxisStride[2] + m;
00156 }
00157
00158
00159 template <class T>
00160 inline void arrayWrap4<T>::setSlice( int i ) const
00161 {
00162
00163 int a = i * mAxisStride[0];
00164 assert( a < mSize );
00165 mSlice.setData( mData + a );
00166 }
00167
00168
00169
00170
00171
00172 typedef arrayWrap4<char> arrayw4c;
00173 typedef arrayWrap4<uchar> arrayw4uc;
00174 typedef arrayWrap4<char> arrayw4b;
00175 typedef arrayWrap4<uchar> arrayw4ub;
00176 typedef arrayWrap4<short> arrayw4s;
00177 typedef arrayWrap4<ushort> arrayw4us;
00178 typedef arrayWrap4<int> arrayw4i;
00179 typedef arrayWrap4<uint> arrayw4ui;
00180 typedef arrayWrap4<long> arrayw4l;
00181 typedef arrayWrap4<ulong> arrayw4ul;
00182 typedef arrayWrap4<llong> arrayw4ll;
00183 typedef arrayWrap4<ullong> arrayw4ull;
00184 typedef arrayWrap4<float> arrayw4f;
00185 typedef arrayWrap4<double> arrayw4d;
00186
00187 #ifdef USING_MATHGUTZ
00188 typedef arrayWrap4<vec2ub> arrayw4v2ub;
00189 typedef arrayWrap4<vec2i> arrayw4v2i;
00190 typedef arrayWrap4<vec2ui> arrayw4v2ui;
00191 typedef arrayWrap4<vec2f> arrayw4v2f;
00192
00193 typedef arrayWrap4<vec3ub> arrayw4v3ub;
00194 typedef arrayWrap4<vec3i> arrayw4v3i;
00195 typedef arrayWrap4<vec3ui> arrayw4v3ui;
00196 typedef arrayWrap4<vec3f> arrayw4v3f;
00197
00198 typedef arrayWrap4<vec4ub> arrayw4v4ub;
00199 typedef arrayWrap4<vec4i> arrayw4v4i;
00200 typedef arrayWrap4<vec4ui> arrayw4v4ui;
00201 typedef arrayWrap4<vec4f> arrayw4v4f;
00202
00203 typedef arrayWrap4<mat2ub> arrayw4m2ub;
00204 typedef arrayWrap4<mat2i> arrayw4m2i;
00205 typedef arrayWrap4<mat2ui> arrayw4m2ui;
00206 typedef arrayWrap4<mat2f> arrayw4m2f;
00207
00208 typedef arrayWrap4<mat3ub> arrayw4m3ub;
00209 typedef arrayWrap4<mat3i> arrayw4m3i;
00210 typedef arrayWrap4<mat3ui> arrayw4m3ui;
00211 typedef arrayWrap4<mat3f> arrayw4m3f;
00212
00213 typedef arrayWrap4<mat4ub> arrayw4m4ub;
00214 typedef arrayWrap4<mat4i> arrayw4m4i;
00215 typedef arrayWrap4<mat4ui> arrayw4m4ui;
00216 typedef arrayWrap4<mat4f> arrayw4m4f;
00217 #endif
00218
00219 }
00220
00221 #endif // arrayWrap4_h