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

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 =========================================================================*/
00040 #ifndef __vtkTensor_h
00041 #define __vtkTensor_h
00042 
00043 #include "vtkObject.h"
00044 
00045 class VTK_COMMON_EXPORT vtkTensor : public vtkObject
00046 {
00047 public:
00048   static vtkTensor *New();
00049   vtkTypeRevisionMacro(vtkTensor,vtkObject);
00050   void PrintSelf(ostream& os, vtkIndent indent);
00051 
00053   void Initialize();
00054 
00056   double GetComponent(int i, int j) {return this->T[i+3*j];};
00057 
00059 
00060   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;};
00062 
00064 
00065   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;};
00067 
00069 
00071   double *GetColumn(int j) { if (j > 2) {vtkErrorMacro("trying to get tensor column j > 2: j = " << j); return NULL;}; return this->T + 3*j;};
00073 
00075   void DeepCopy(vtkTensor *t);
00076 
00078   operator double*() {return this->T;};
00079 
00081   double *T;
00082   
00083 protected: 
00084   vtkTensor();
00085   ~vtkTensor() {};
00086 
00087   double Storage[9];
00088 private:
00089   vtkTensor(const vtkTensor&);  // Not implemented.
00090   void operator=(const vtkTensor&);  // Not implemented.
00091 };
00092 
00093 //----------------------------------------------------------------------------
00094 inline void vtkTensor::Initialize()
00095 {
00096   for (int j=0; j<3; j++)
00097     {
00098     for (int i=0; i<3; i++)
00099       {
00100       this->T[i+j*3] = 0.0;
00101       }
00102     }
00103 }
00104 
00105 //----------------------------------------------------------------------------
00106 inline void vtkTensor::DeepCopy(vtkTensor *t)
00107 {
00108   for (int j=0; j < 3; j++)
00109     {
00110     for (int i=0; i < 3; i++)
00111       {
00112       this->T[i+3*j] = t->T[i+3*j];
00113       }
00114     }
00115 }
00116 
00117 #endif