Common/vtkTensor.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00032 #ifndef __vtkTensor_h
00033 #define __vtkTensor_h
00034
00035 #include "vtkObject.h"
00036
00037 class VTK_COMMON_EXPORT vtkTensor : public vtkObject
00038 {
00039 public:
00040 static vtkTensor *New();
00041 vtkTypeRevisionMacro(vtkTensor,vtkObject);
00042
00044 void Initialize();
00045
00047 float GetComponent(int i, int j) {return this->T[i+3*j];};
00048
00050
00051 void SetComponent(int i, int j, float 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;};
00053
00055
00056 void AddComponent(int i, int j, float 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;};
00058
00060
00062 float *GetColumn(int j) { if (j > 2) {vtkErrorMacro("trying to get tensor column j > 2: j = " << j); return NULL;}; return this->T + 3*j;};
00064
00066 void DeepCopy(vtkTensor *t);
00067
00069 operator float*() {return this->T;};
00070
00072 float *T;
00073
00074 protected:
00075 vtkTensor();
00076 ~vtkTensor() {};
00077
00078 float Storage[9];
00079 private:
00080 vtkTensor(const vtkTensor&);
00081 void operator=(const vtkTensor&);
00082 };
00083
00084 inline void vtkTensor::Initialize()
00085 {
00086 for (int j=0; j<3; j++)
00087 {
00088 for (int i=0; i<3; i++)
00089 {
00090 this->T[i+j*3] = 0.0;
00091 }
00092 }
00093 }
00094
00095 inline void vtkTensor::DeepCopy(vtkTensor *t)
00096 {
00097 for (int j=0; j < 3; j++)
00098 {
00099 for (int i=0; i < 3; i++)
00100 {
00101 this->T[i+3*j] = t->T[i+3*j];
00102 }
00103 }
00104 }
00105
00106 #endif