VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkTensor.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00028 #ifndef __vtkTensor_h 00029 #define __vtkTensor_h 00030 00031 #include "vtkCommonDataModelModule.h" // For export macro 00032 #include "vtkObject.h" 00033 00034 class VTKCOMMONDATAMODEL_EXPORT vtkTensor : public vtkObject 00035 { 00036 public: 00037 static vtkTensor *New(); 00038 vtkTypeMacro(vtkTensor,vtkObject); 00039 void PrintSelf(ostream& os, vtkIndent indent); 00040 00042 void Initialize(); 00043 00045 double GetComponent(int i, int j) {return this->T[i+3*j];}; 00046 00048 00049 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;}; 00051 00053 00054 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;}; 00056 00058 00060 double *GetColumn(int j) { if (j > 2) {vtkErrorMacro("trying to get tensor column j > 2: j = " << j); return NULL;}; return this->T + 3*j;}; 00062 00064 void DeepCopy(vtkTensor *t); 00065 00067 operator double*() {return this->T;}; 00068 00070 double *T; 00071 00072 protected: 00073 vtkTensor(); 00074 ~vtkTensor() {}; 00075 00076 double Storage[9]; 00077 private: 00078 vtkTensor(const vtkTensor&); // Not implemented. 00079 void operator=(const vtkTensor&); // Not implemented. 00080 }; 00081 00082 //---------------------------------------------------------------------------- 00083 inline void vtkTensor::Initialize() 00084 { 00085 for (int j=0; j<3; j++) 00086 { 00087 for (int i=0; i<3; i++) 00088 { 00089 this->T[i+j*3] = 0.0; 00090 } 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