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 "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&); // Not implemented. 00078 void operator=(const vtkTensor&); // Not implemented. 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