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 #ifndef ARRAY_WRAP_3_h
00037 #define ARRAY_WRAP_3_h
00038
00039 #include <../arrayGutz/arrayBase.h>
00040 #include <assert.h>
00041 #include "arrayWrap2.h"
00042
00043 namespace gutz {
00044
00045
00046 template <class T> class arrayWrap4;
00047
00048
00049
00050
00051 template <class T>
00052 class arrayWrap3 : public arrayBase<T>
00053 {
00054 public:
00055 friend class arrayWrap4<T>;
00056
00057
00058 arrayWrap3();
00059 arrayWrap3( int d0, int d1, int d2, T* v );
00060 arrayWrap3( const arrayWrap3<T>& a );
00061 arrayWrap3<T>& operator=( const arrayWrap3<T>& a );
00062
00063 virtual ~arrayWrap3();
00064
00065
00066 inline arrayWrap2<T>& operator[] (int i);
00067 inline const arrayWrap2<T>& operator[] (int i) const;
00068
00069
00070 inline T& operator() (int i, int j, int k);
00071 inline const T& operator() (int i, int j, int k) const;
00072
00073 protected:
00074
00075
00076
00077 mutable arrayWrap2<T> mSlice;
00078
00079 private:
00080 inline void setSlice( int i ) const;
00081 inline int address( int i, int j, int k ) const;
00082 inline void setData( T* d ) { mData = d; }
00083 };
00084
00085
00086
00087
00088
00089
00090 template <class T>
00091 arrayWrap3<T>::arrayWrap3 ()
00092 :arrayBase<T>(), mSlice(arrayWrap2<T>())
00093 {}
00094
00095
00096 template <class T>
00097 arrayWrap3<T>::arrayWrap3 (int d0, int d1, int d2, T* v)
00098 :arrayBase<T>(d0, d1, d2, v), mSlice(arrayWrap2<T>(d1,d2,v))
00099 {}
00100
00101
00102 template <class T>
00103 arrayWrap3<T>::arrayWrap3<T>( const arrayWrap3<T>& a ) : arrayBase<T>(a)
00104 {
00105 mSlice = a.mSlice;
00106 }
00107
00108
00109 template <class T>
00110 arrayWrap3<T>& arrayWrap3<T>::operator=(const arrayWrap3<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 arrayWrap3<T>::~arrayWrap3()
00122 {}
00123
00124
00125 template <class T>
00126 inline arrayWrap2<T>& arrayWrap3<T>::operator[] (int i)
00127 {
00128 setSlice(i);
00129 return mSlice;
00130 }
00131
00132 template <class T>
00133 inline const arrayWrap2<T>& arrayWrap3<T>::operator[] (int i) const
00134 {
00135 setSlice(i);
00136 return mSlice;
00137 }
00138
00139
00140 template <class T>
00141 inline void arrayWrap3<T>::setSlice( int i ) const
00142 {
00143
00144 int a = i * mAxisStride[0];
00145 assert( a < mSize );
00146 mSlice.setData( mData + a );
00147 }
00148
00149
00150 template <class T>
00151 inline T& arrayWrap3<T>::operator() (int i, int j, int k)
00152 {
00153 return mData[ address(i,j,k) ];
00154 }
00155
00156 template <class T>
00157 inline const T& arrayWrap3<T>::operator() (int i, int j, int k) const
00158 {
00159 return mData[ address(i,j,k) ];
00160 }
00161
00162 template <class T>
00163 inline int arrayWrap3<T>::address( int i, int j, int k) const
00164 {
00165
00166 return i*mAxisStride[0]+ j*mAxisStride[1] + k;
00167 }
00168
00169
00170
00171
00172
00173 typedef arrayWrap3<char> arrayw3c;
00174 typedef arrayWrap3<uchar> arrayw3uc;
00175 typedef arrayWrap3<char> arrayw3b;
00176 typedef arrayWrap3<uchar> arrayw3ub;
00177 typedef arrayWrap3<short> arrayw3s;
00178 typedef arrayWrap3<ushort> arrayw3us;
00179 typedef arrayWrap3<int> arrayw3i;
00180 typedef arrayWrap3<uint> arrayw3ui;
00181 typedef arrayWrap3<long> arrayw3l;
00182 typedef arrayWrap3<ulong> arrayw3ul;
00183 typedef arrayWrap3<llong> arrayw3ll;
00184 typedef arrayWrap3<ullong> arrayw3ull;
00185 typedef arrayWrap3<float> arrayw3f;
00186 typedef arrayWrap3<double> arrayw3d;
00187
00188 #ifdef USING_MATHGUTZ
00189 typedef arrayWrap3<vec2ub> arrayw3v2ub;
00190 typedef arrayWrap3<vec2i> arrayw3v2i;
00191 typedef arrayWrap3<vec2ui> arrayw3v2ui;
00192 typedef arrayWrap3<vec2f> arrayw3v2f;
00193
00194 typedef arrayWrap3<vec3ub> arrayw3v3ub;
00195 typedef arrayWrap3<vec3i> arrayw3v3i;
00196 typedef arrayWrap3<vec3ui> arrayw3v3ui;
00197 typedef arrayWrap3<vec3f> arrayw3v3f;
00198
00199 typedef arrayWrap3<vec4ub> arrayw3v4ub;
00200 typedef arrayWrap3<vec4i> arrayw3v4i;
00201 typedef arrayWrap3<vec4ui> arrayw3v4ui;
00202 typedef arrayWrap3<vec4f> arrayw3v4f;
00203
00204 typedef arrayWrap3<mat2ub> arrayw3m2ub;
00205 typedef arrayWrap3<mat2i> arrayw3m2i;
00206 typedef arrayWrap3<mat2ui> arrayw3m2ui;
00207 typedef arrayWrap3<mat2f> arrayw3m2f;
00208
00209 typedef arrayWrap3<mat3ub> arrayw3m3ub;
00210 typedef arrayWrap3<mat3i> arrayw3m3i;
00211 typedef arrayWrap3<mat3ui> arrayw3m3ui;
00212 typedef arrayWrap3<mat3f> arrayw3m3f;
00213
00214 typedef arrayWrap3<mat4ub> arrayw3m4ub;
00215 typedef arrayWrap3<mat4i> arrayw3m4i;
00216 typedef arrayWrap3<mat4ui> arrayw3m4ui;
00217 typedef arrayWrap3<mat4f> arrayw3m4f;
00218 #endif
00219
00220 }
00221
00222 #endif // arrayWrap3_h