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 vtkTypeMacro(vtkTensor,vtkObject);
00038 void PrintSelf(ostream& os, vtkIndent indent);
00039
00041 void Initialize();
00042
00044 double GetComponent(int i, int j) {return this->T[i+3*j];};
00045
00047
00048 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;};
00050
00052
00053 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;};
00055
00057
00059 double *GetColumn(int j) { if (j > 2) {vtkErrorMacro("trying to get tensor column j > 2: j = " << j); return NULL;}; return this->T + 3*j;};
00061
00063 void DeepCopy(vtkTensor *t);
00064
00066 operator double*() {return this->T;};
00067
00069 double *T;
00070
00071 protected:
00072 vtkTensor();
00073 ~vtkTensor() {};
00074
00075 double Storage[9];
00076 private:
00077 vtkTensor(const vtkTensor&);
00078 void operator=(const vtkTensor&);
00079 };
00080
00081
00082 inline void vtkTensor::Initialize()
00083 {
00084 for (int j=0; j<3; j++)
00085 {
00086 for (int i=0; i<3; i++)
00087 {
00088 this->T[i+j*3] = 0.0;
00089 }
00090 }
00091 }
00092
00093
00094 inline void vtkTensor::DeepCopy(vtkTensor *t)
00095 {
00096 for (int j=0; j < 3; j++)
00097 {
00098 for (int i=0; i < 3; i++)
00099 {
00100 this->T[i+3*j] = t->T[i+3*j];
00101 }
00102 }
00103 }
00104
00105 #endif