Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages
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
00045 #ifndef __vtkTensor_h
00046 #define __vtkTensor_h
00047
00048 #include "vtkObject.h"
00049
00050 class VTK_COMMON_EXPORT vtkTensor : public vtkObject
00051 {
00052 public:
00053 static vtkTensor *New();
00054 vtkTypeRevisionMacro(vtkTensor,vtkObject);
00055
00057 void Initialize();
00058
00060 float GetComponent(int i, int j) {return this->T[i+3*j];};
00061
00063
00064 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;};
00066
00068
00069 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;};
00071
00073
00075 float *GetColumn(int j) { if (j > 2) {vtkErrorMacro("trying to get tensor column j > 2: j = " << j); return NULL;}; return this->T + 3*j;};
00077
00079 void DeepCopy(vtkTensor *t);
00080
00082 operator float*() {return this->T;};
00083
00085 float *T;
00086
00087 protected:
00088 vtkTensor();
00089 ~vtkTensor() {};
00090
00091 float Storage[9];
00092 private:
00093 vtkTensor(const vtkTensor&);
00094 void operator=(const vtkTensor&);
00095 };
00096
00097 inline void vtkTensor::Initialize()
00098 {
00099 for (int j=0; j<3; j++)
00100 {
00101 for (int i=0; i<3; i++)
00102 {
00103 this->T[i+j*3] = 0.0;
00104 }
00105 }
00106 }
00107
00108 inline void vtkTensor::DeepCopy(vtkTensor *t)
00109 {
00110 for (int j=0; j < 3; j++)
00111 {
00112 for (int i=0; i < 3; i++)
00113 {
00114 this->T[i+3*j] = t->T[i+3*j];
00115 }
00116 }
00117 }
00118
00119 #endif