Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

E1Cast.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Array_Element_E1Cast_h
00002 #define Impala_Core_Array_Element_E1Cast_h
00003 
00004 #include "Core/Array/Element/ArithTypes.h"
00005 
00006 namespace Impala
00007 {
00008 namespace Core
00009 {
00010 namespace Array
00011 {
00012 namespace Element
00013 {
00014 
00015 
00016 /*
00017 template <class DstArrayT, class SrcArrayT>
00018 inline typename DstArrayT::ArithType
00019 E1Cast(typename SrcArrayT::ArithType v)
00020 {
00021     return static_cast<typename DstArrayT::ArithType>(v);
00022 }
00023 */
00024 
00025 /* MSVC doesn't support overloading on return type only
00026 template <class DstArithT, class SrcArithT>
00027 inline DstArithT
00028 E1Cast(const SrcArithT& v)
00029 {
00030     return static_cast<DstArithT>(v);
00031 }
00032 */
00033 
00034 template <class DstArithT, class SrcArithT>
00035 inline DstArithT
00036 E1Cast(const SrcArithT& v, DstArithT)
00037 {
00038     return static_cast<DstArithT>(v);
00039 }
00040 
00041 
00042 // template specializations for DstArithT == Int32
00043 
00044 /* VC6.0 doesn't handle this one
00045 template <>
00046 inline Int32
00047 E1Cast<Int32,Vec3Real64>(Vec3Real64 v)
00048 {
00049     return v.X();
00050 }
00051 */
00052 
00053 template <>
00054 inline Int32
00055 E1Cast<Int32,Vec3Int32>(const Vec3Int32& v, Int32)
00056 {
00057     return v.X();
00058 }
00059 
00060 template <>
00061 inline Int32
00062 E1Cast<Int32,Vec3Real64>(const Vec3Real64& v, Int32)
00063 {
00064     return static_cast<Int32>(v.X());
00065 }
00066 
00067 template <>
00068 inline Int32
00069 E1Cast<Int32,Complex64>(const Complex64& v, Int32)
00070 {
00071     return static_cast<Int32>(v.X());
00072 }
00073 
00074 
00075 // template specializations for DstArithT == Real64
00076 
00077 template <>
00078 inline Real64
00079 E1Cast<Real64,Vec3Int32>(const Vec3Int32& v, Real64)
00080 {
00081     return v.X();
00082 }
00083 
00084 template <>
00085 inline Real64
00086 E1Cast<Real64,Vec3Real64>(const Vec3Real64& v, Real64)
00087 {
00088     return v.X();
00089 }
00090 
00091 template <>
00092 inline Real64
00093 E1Cast<Real64,Complex64>(const Complex64& v, Real64)
00094 {
00095     return v.X();
00096 }
00097 
00098 /*
00099 template <>
00100 inline Real64
00101 E1Cast<Real64,VecN<Real64,5> >(const VecN<Real64,5>& v, Real64)
00102 {
00103     return v[0];
00104 }
00105 */
00106 
00107 
00108 // template specializations for DstArithT == Vec3Int32
00109 
00110 /* VC6.0 doesn't handle this one
00111 template <>
00112 inline Vec3Int32
00113 E1Cast<Vec3Int32,Real64>(Real64 v)
00114 {
00115     return Vec3Int32(v, v, v);
00116 }
00117 */
00118 
00119 template <>
00120 inline Vec3Int32
00121 E1Cast<Vec3Int32,Int32>(const Int32& v, Vec3Int32)
00122 {
00123     return Vec3Int32(v, v, v);
00124 }
00125 
00126 template <>
00127 inline Vec3Int32
00128 E1Cast<Vec3Int32,Vec3Real64>(const Vec3Real64& v, Vec3Int32)
00129 {
00130     return Vec3Int32(static_cast<Int32>(v.X()), static_cast<Int32>(v.Y()), static_cast<Int32>(v.Z()));
00131 }
00132 
00133 template <>
00134 inline Vec3Int32
00135 E1Cast<Vec3Int32,Real64>(const Real64& v, Vec3Int32)
00136 {
00137     return Vec3Int32(static_cast<Int32>(v), static_cast<Int32>(v), static_cast<Int32>(v));
00138 }
00139 
00140 
00141 // template specializations for DstArithT == Vec3Real64
00142 
00143 /* VC6.0 doesn't handle this one
00144 template <>
00145 inline Vec3Real64
00146 E1Cast<Vec3Real64,Int32>(Int32 v)
00147 {
00148     return Vec3Real64(v, v, v);
00149 }
00150 */
00151 
00152 template <>
00153 inline Vec3Real64
00154 E1Cast<Vec3Real64,Int32>(const Int32& v, Vec3Real64)
00155 {
00156     return Vec3Real64(v, v, v);
00157 }
00158 
00159 template <>
00160 inline Vec3Real64
00161 E1Cast<Vec3Real64,Real64>(const Real64& v, Vec3Real64)
00162 {
00163     return Vec3Real64(v, v, v);
00164 }
00165 
00166 template <>
00167 inline Vec3Real64
00168 E1Cast<Vec3Real64,Vec3Int32>(const Vec3Int32& v, Vec3Real64)
00169 {
00170     return Vec3Real64(v.X(), v.Y(), v.Z());
00171 }
00172 
00173 
00174 // template specializations for DstArithT == Complex64
00175 
00176 template <>
00177 inline Complex64
00178 E1Cast<Complex64,Int32>(const Int32& v, Complex64)
00179 {
00180     return Complex64(v, v);
00181 }
00182 
00183 template <>
00184 inline Complex64
00185 E1Cast<Complex64,Real64>(const Real64& v, Complex64)
00186 {
00187     return Complex64(v, v);
00188 }
00189 
00190 // template specializations for DstArithT == VecN<Real64,5>
00191 
00192 /*
00193 template <>
00194 inline VecN<Real64,5>
00195 E1Cast<VecN<Real64,5>,Vec3Int32>(const Vec3Int32& v, VecN<Real64,5>)
00196 {
00197     return VecN<Real64,5>(v.X(), v.Y(), v.Z());
00198 }
00199 */
00200 
00201 } // namespace Element
00202 } // namespace Array
00203 } // namespace Core
00204 } // namespace Impala
00205 
00206 #endif

Generated on Fri Mar 19 09:30:45 2010 for ImpalaSrc by  doxygen 1.5.1