Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Common/vtkTensor.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkTensor.h,v $
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   vtkTypeRevisionMacro(vtkTensor,vtkObject);
00038 
00040   void Initialize();
00041 
00043   double GetComponent(int i, int j) {return this->T[i+3*j];};
00044 
00046 
00047   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;};
00049 
00051 
00052   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;};
00054 
00056 
00058   double *GetColumn(int j) { if (j > 2) {vtkErrorMacro("trying to get tensor column j > 2: j = " << j); return NULL;}; return this->T + 3*j;};
00060 
00062   void DeepCopy(vtkTensor *t);
00063 
00065   operator double*() {return this->T;};
00066 
00068   double *T;
00069   
00070 protected: 
00071   vtkTensor();
00072   ~vtkTensor() {};
00073 
00074   double Storage[9];
00075 private:
00076   vtkTensor(const vtkTensor&);  // Not implemented.
00077   void operator=(const vtkTensor&);  // Not implemented.
00078 };
00079 
00080 inline void vtkTensor::Initialize()
00081 {
00082   for (int j=0; j<3; j++)
00083     {
00084     for (int i=0; i<3; i++)
00085       {
00086       this->T[i+j*3] = 0.0;
00087       }
00088     }
00089 }
00090 
00091 inline void vtkTensor::DeepCopy(vtkTensor *t)
00092 {
00093   for (int j=0; j < 3; j++)
00094     {
00095     for (int i=0; i < 3; i++)
00096       {
00097       this->T[i+3*j] = t->T[i+3*j];
00098       }
00099     }
00100 }
00101 
00102 #endif