00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00030 #ifndef __vtkVector_h
00031 #define __vtkVector_h
00032
00033 template<typename T, int Size>
00034 class vtkVector
00035 {
00036 public:
00037 vtkVector()
00038 {
00039 for (int i = 0; i < Size; ++i)
00040 {
00041 Data[i] = 0;
00042 }
00043 }
00044
00046 int GetSize() const { return Size; }
00047
00049
00050 T* GetData() { return this->Data; }
00051 const T* GetData() const { return this->Data; }
00053
00055
00057 T& operator[](int i) { return this->Data[i]; }
00058 const T& operator[](int i) const { return this->Data[i]; }
00060
00063 T operator()(int i) const { return this->Data[i]; }
00064
00065 protected:
00067 T Data[Size];
00068 };
00069
00070
00071
00072 template<typename T>
00073 class vtkVector2 : public vtkVector<T, 2>
00074 {
00075 public:
00076 vtkVector2(const T& x = 0.0, const T& y = 0.0)
00077 {
00078 this->Data[0] = x;
00079 this->Data[1] = y;
00080 }
00081
00083
00084 void Set(const T& x, const T& y)
00085 {
00086 this->Data[0] = x;
00087 this->Data[1] = y;
00088 }
00090
00092 void SetX(const T& x) { this->Data[0] = x; }
00093
00095
00096 const T& GetX() const { return this->Data[0]; }
00097 const T& X() const { return this->Data[0]; }
00099
00101 void SetY(const T& y) { this->Data[1] = y; }
00102
00104
00105 const T& GetY() const { return this->Data[1]; }
00106 const T& Y() const { return this->Data[1]; }
00108 };
00109
00110
00111
00112 template<typename T>
00113 class vtkVector3 : public vtkVector<T, 3>
00114 {
00115 public:
00116 vtkVector3(const T& x = 0.0, const T& y = 0.0, const T& z = 0.0)
00117 {
00118 this->Data[0] = x;
00119 this->Data[1] = y;
00120 this->Data[2] = z;
00121 }
00122
00124
00125 void Set(const T& x, const T& y, const T& z)
00126 {
00127 this->Data[0] = x;
00128 this->Data[1] = y;
00129 this->Data[2] = z;
00130 }
00132
00134 void SetX(const T& x) { this->Data[0] = x; }
00135
00137
00138 const T& GetX() const { return this->Data[0]; }
00139 const T& X() const { return this->Data[0]; }
00141
00143 void SetY(const T& y) { this->Data[1] = y; }
00144
00146
00147 const T& GetY() const { return this->Data[1]; }
00148 const T& Y() const { return this->Data[1]; }
00150
00152 void SetZ(const T& z) { this->Data[2] = z; }
00153
00155
00156 const T& GetZ() const { return this->Data[2]; }
00157 const T& Z() const { return this->Data[2]; }
00159
00160 };
00161
00162
00163
00164 template<typename T>
00165 class vtkRect : public vtkVector<T, 4>
00166 {
00167 public:
00168 vtkRect(const T& x = 0.0, const T& y = 0.0, const T width = 0.0,
00169 const T& height = 0.0 )
00170 {
00171 this->Data[0] = x;
00172 this->Data[1] = y;
00173 this->Data[2] = width;
00174 this->Data[3] = height;
00175 }
00176
00178
00179 void Set(const T& x, const T& y, const T& width, const T& height)
00180 {
00181 this->Data[0] = x;
00182 this->Data[1] = y;
00183 this->Data[2] = width;
00184 this->Data[3] = height;
00185 }
00187
00189 void SetX(const T& x) { this->Data[0] = x; }
00190
00192
00193 const T& GetX() const { return this->Data[0]; }
00194 const T& X() const { return this->Data[0]; }
00196
00198 void SetY(const T& y) { this->Data[1] = y; }
00199
00201
00202 const T& GetY() const { return this->Data[1]; }
00203 const T& Y() const { return this->Data[1]; }
00205
00207 void SetWidth(const T& width) { this->Data[2] = width; }
00208
00210
00211 const T& GetWidth() const { return this->Data[2]; }
00212 const T& Width() const { return this->Data[2]; }
00214
00216 void SetHeight(const T& height) { this->Data[3] = height; }
00217
00219
00220 const T& GetHeight() const { return this->Data[3]; }
00221 const T& Height() const { return this->Data[3]; }
00223
00224 };
00225
00227 class vtkVector2i : public vtkVector2<int>
00228 {
00229 public:
00230 vtkVector2i(int x = 0, int y = 0) : vtkVector2<int>(x, y) {}
00231 };
00232
00233 class vtkVector2f : public vtkVector2<float>
00234 {
00235 public:
00236 vtkVector2f(float x = 0.0, float y = 0.0) : vtkVector2<float>(x, y) {}
00237 };
00238
00239 class vtkVector2d : public vtkVector2<double>
00240 {
00241 public:
00242 vtkVector2d(double x = 0.0, double y = 0.0) : vtkVector2<double>(x, y) {}
00243 };
00244
00245 class vtkVector3i : public vtkVector3<int>
00246 {
00247 public:
00248 vtkVector3i(int x = 0, int y = 0, int z = 0) : vtkVector3<int>(x, y, z) {}
00249 };
00250
00251 class vtkVector3f : public vtkVector3<float>
00252 {
00253 public:
00254 vtkVector3f(float x = 0.0, float y = 0.0, float z = 0.0)
00255 : vtkVector3<float>(x, y, z) {}
00256 };
00257
00258 class vtkVector3d : public vtkVector3<double>
00259 {
00260 public:
00261 vtkVector3d(double x = 0.0, double y = 0.0, double z = 0.0)
00262 : vtkVector3<double>(x, y, z) {}
00263 };
00264
00265 class vtkRecti : public vtkRect<int>
00266 {
00267 public:
00268 vtkRecti(int x = 0, int y = 0, int width = 0, int height = 0)
00269 : vtkRect<int>(x, y, width, height) {}
00270 };
00271
00272 class vtkRectf : public vtkRect<float>
00273 {
00274 public:
00275 vtkRectf(float x = 0.0, float y = 0.0, float width = 0.0, float height = 0.0)
00276 : vtkRect<float>(x, y, width, height) {}
00277 };
00278
00279 class vtkRectd : public vtkRect<double>
00280 {
00281 public:
00282 vtkRectd(double x = 0.0, double y = 0.0, double width = 0.0,
00283 double height = 0.0)
00284 : vtkRect<double>(x, y, width, height) {}
00285 };
00286
00287 #endif // __vtkVector_h