Common/vtkTensor.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00028 #ifndef __vtkTensor_h
00029 #define __vtkTensor_h
00030
00031 #include "vtkObject.h"
00032
00033 class VTK_COMMON_EXPORT vtkTensor : public vtkObject
00034 {
00035 public:
00036 static vtkTensor *New();
00037 vtkTypeRevisionMacro(vtkTensor,vtkObject);
00038
00040 void Initialize();
00041
00043 double GetComponent(int i, int j) {return this->T[i+3*j];};
00044
00046
00047 void SetComponent(int i, int j, double v) {if (i > 2 || j > 2) {vtkErrorMacro("trying to set tensor component i or j > 2: i = " << i << ", j = " << j); return;}; this->T[i+3*j] = v;};
00049
00051
00052 void AddComponent(int i, int j, double v) { if (i > 2 || j > 2) {vtkErrorMacro("trying to add tensor component i or j > 2: i = " << i << ", j = " << j); return;}; this->T[i+3*j] += v;};
00054
00056
00058 double *GetColumn(int j) { if (j > 2) {vtkErrorMacro("trying to get tensor column j > 2: j = " << j); return NULL;}; return this->T + 3*j;};
00060
00062 void DeepCopy(vtkTensor *t);
00063
00065 operator double*() {return this->T;};
00066
00068 double *T;
00069
00070 protected:
00071 vtkTensor();
00072 ~vtkTensor() {};
00073
00074 double Storage[9];
00075 private:
00076 vtkTensor(const vtkTensor&);
00077 void operator=(const vtkTensor&);
00078 };
00079
00080 inline void vtkTensor::Initialize()
00081 {
00082 for (int j=0; j<3; j++)
00083 {
00084 for (int i=0; i<3; i++)
00085 {
00086 this->T[i+j*3] = 0.0;
00087 }
00088 }
00089 }
00090
00091 inline void vtkTensor::DeepCopy(vtkTensor *t)
00092 {
00093 for (int j=0; j < 3; j++)
00094 {
00095 for (int i=0; i < 3; i++)
00096 {
00097 this->T[i+3*j] = t->T[i+3*j];
00098 }
00099 }
00100 }
00101
00102 #endif