00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _ARRAY_3D_SHAPE_
00022 #define _ARRAY_3D_SHAPE_
00023
00024 #include <TinyVector.hpp>
00025 #include <StreamCenter.hpp>
00026
00035 class Array3DShape
00036 {
00037 private:
00039 TinyVector<3,size_t> __shape;
00040
00041 public:
00042 friend std::ostream& operator << (std::ostream& os, const Array3DShape& a)
00043 {
00044 os << a.__shape;
00045 return os;
00046 }
00047
00048 bool operator==(const Array3DShape& s) const
00049 {
00050 return (__shape==s.__shape);
00051 }
00052
00055 inline size_t operator()(const size_t& i,
00056 const size_t& j,
00057 const size_t& k) const
00058 {
00059 return (i*__shape[1]*__shape[2] + j*__shape[2] + k);
00060 }
00061
00062 inline size_t operator()(const TinyVector<3,size_t>& index) const
00063 {
00064 return (*this)(index[0],index[1],index[2]);
00065 }
00066
00067
00069 inline const size_t& nx() const
00070 {
00071 return __shape[0];
00072 }
00073
00075 inline const size_t& ny() const
00076 {
00077 return __shape[1];
00078 }
00079
00081 inline const size_t& nz() const
00082 {
00083 return __shape[2];
00084 }
00085
00086 inline const size_t& operator[](const size_t& i) const
00087 {
00088 ASSERT(i<3);
00089 return __shape[i];
00090 }
00091
00093 inline size_t size() const
00094 {
00095 return __shape[0]*__shape[1]*__shape[2];
00096 }
00097
00101 inline Array3DShape operator-(size_t i) const
00102 {
00103 ASSERT ((i<__shape[0])&&(i<__shape[1])&&(i<__shape[2]));
00104 return Array3DShape(__shape[0]-i, __shape[1]-i, __shape[2]-i);
00105 }
00106
00110 inline Array3DShape& operator=(const Array3DShape& s)
00111 {
00112 __shape = s.__shape;
00113 return *this;
00114 }
00115
00117 Array3DShape(const size_t& i,
00118 const size_t& j,
00119 const size_t& k)
00120 {
00121 __shape[0]=i;
00122 __shape[1]=j;
00123 __shape[2]=k;
00124 }
00125
00131 Array3DShape(const TinyVector<3,size_t>& shape)
00132 : __shape(shape)
00133 {
00134 ;
00135 }
00136
00138 Array3DShape(const Array3DShape& s)
00139 : __shape(s.__shape)
00140 {
00141 ;
00142 }
00143
00145 Array3DShape()
00146 {
00147 ;
00148 }
00149
00150 ~Array3DShape()
00151 {
00152 ;
00153 }
00154 };
00155
00156 #endif // _STUCTURED_3D_MESH_SHAPE_HPP_
00157