Common/vtkTensor.h Source File

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   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkTensor.h,v $
    00005   Language:  C++
    00006
    00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    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&);  // Not implemented.
    00094   void operator=(const vtkTensor&);  // Not implemented.
    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