00001 #ifndef Impala_Core_Array_Element_Vec3Int32_h
00002 #define Impala_Core_Array_Element_Vec3Int32_h
00003
00004 #include <iostream>
00005 #include "Util/Math.h"
00006 #include "Basis/NativeTypes.h"
00007
00008 namespace Impala
00009 {
00010 namespace Core
00011 {
00012 namespace Array
00013 {
00014 namespace Element
00015 {
00016
00017
00020 class Vec3Int32 {
00021 public:
00022
00024 Vec3Int32()
00025 {
00026 }
00027
00029 Vec3Int32(Int32 x, Int32 y, Int32 z)
00030 {
00031 mValues[0] = x;
00032 mValues[1] = y;
00033 mValues[2] = z;
00034 }
00035
00036 Vec3Int32(Int32 i)
00037 {
00038 mValues[0] = i;
00039 mValues[1] = i;
00040 mValues[2] = i;
00041 }
00042
00044 Vec3Int32(const Vec3Int32& v)
00045 {
00046 mValues[0] = v.mValues[0];
00047 mValues[1] = v.mValues[1];
00048 mValues[2] = v.mValues[2];
00049 }
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00061 Int32
00062 X() const
00063 {
00064 return mValues[0];
00065 }
00066
00068 Int32
00069 Y() const
00070 {
00071 return mValues[1];
00072 }
00073
00075 Int32
00076 Z() const
00077 {
00078 return mValues[2];
00079 }
00080
00082 Int32
00083 getValue(int dimension) const
00084 {
00085 return mValues[dimension - 1];
00086 }
00087
00089 int
00090 operator==(const Vec3Int32& v) const
00091 {
00092 return (mValues[0] == v.mValues[0]) && (mValues[1] == v.mValues[1]) &&
00093 (mValues[2] == v.mValues[2]);
00094 }
00095
00097 int
00098 operator<(const Vec3Int32& v) const
00099 {
00100 return (std::abs(mValues[0]) + std::abs(mValues[1]) + std::abs(mValues[2])) <
00101 (std::abs(v.mValues[0]) + std::abs(v.mValues[1]) + std::abs(v.mValues[2]));
00102 }
00103
00105 int
00106 operator<=(const Vec3Int32& v) const
00107 {
00108 return (std::abs(mValues[0]) + std::abs(mValues[1]) + std::abs(mValues[2])) <=
00109 (std::abs(v.mValues[0]) + std::abs(v.mValues[1]) + std::abs(v.mValues[2]));
00110 }
00111
00113 int
00114 operator> (const Vec3Int32& v) const
00115 {
00116 return (std::abs(mValues[0]) + std::abs(mValues[1]) + std::abs(mValues[2])) >
00117 (std::abs(v.mValues[0]) + std::abs(v.mValues[1]) + std::abs(v.mValues[2]));
00118 }
00119
00121 int
00122 operator>=(const Vec3Int32& v) const
00123 {
00124 return (std::abs(mValues[0]) + std::abs(mValues[1]) + std::abs(mValues[2])) >=
00125 (std::abs(v.mValues[0]) + std::abs(v.mValues[1]) + std::abs(v.mValues[2]));
00126 }
00127
00129 Vec3Int32&
00130 operator+=(const Vec3Int32& v)
00131 {
00132 mValues[0] += v.mValues[0];
00133 mValues[1] += v.mValues[1];
00134 mValues[2] += v.mValues[2];
00135 return *this;
00136 }
00137
00138
00139 private:
00140 Int32 mValues[3];
00141 };
00142
00143 inline std::ostream&
00144 operator<<(std::ostream& os, const Vec3Int32& v)
00145 {
00146 return os << "(" << v.X() << "," << v.Y() << "," << v.Z() << ")";
00147 }
00148
00149 inline Vec3Int32
00150 operator+(const Vec3Int32& v1, const Vec3Int32& v2)
00151 {
00152 return Vec3Int32(v1.X() + v2.X(), v1.Y() + v2.Y(), v1.Z() + v2.Z());
00153 }
00154
00155 inline Vec3Int32
00156 operator-(const Vec3Int32& v1, const Vec3Int32& v2)
00157 {
00158 return Vec3Int32(v1.X() - v2.X(), v1.Y() - v2.Y(), v1.Z() - v2.Z());
00159 }
00160
00161 inline Vec3Int32
00162 operator*(const Vec3Int32& v1, const Vec3Int32& v2)
00163 {
00164 return Vec3Int32(v1.X() * v2.X(), v1.Y() * v2.Y(), v1.Z() * v2.Z());
00165 }
00166
00167 inline Vec3Int32
00168 operator/(const Vec3Int32& v1, const Vec3Int32& v2)
00169 {
00170 return Vec3Int32(v1.X() / v2.X(), v1.Y() / v2.Y(), v1.Z() / v2.Z());
00171 }
00172
00173 }
00174 }
00175 }
00176 }
00177
00178 #endif