VTK
vtkTensor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkTensor.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
28 #ifndef vtkTensor_h
29 #define vtkTensor_h
30 
31 #include "vtkCommonDataModelModule.h" // For export macro
32 #include "vtkObject.h"
33 
35 {
36 public:
37  static vtkTensor *New();
38  vtkTypeMacro(vtkTensor,vtkObject);
39  void PrintSelf(ostream& os, vtkIndent indent);
40 
42  void Initialize();
43 
45  double GetComponent(int i, int j) {return this->T[i+3*j];};
46 
48 
49  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;};
51 
53 
54  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;};
56 
58 
60  double *GetColumn(int j) { if (j > 2) {vtkErrorMacro("trying to get tensor column j > 2: j = " << j); return NULL;}; return this->T + 3*j;};
62 
64  void DeepCopy(vtkTensor *t);
65 
67  operator double*() {return this->T;};
68 
70  double *T;
71 
72 protected:
73  vtkTensor();
75 
76  double Storage[9];
77 private:
78  vtkTensor(const vtkTensor&); // Not implemented.
79  void operator=(const vtkTensor&); // Not implemented.
80 };
81 
82 //----------------------------------------------------------------------------
83 inline void vtkTensor::Initialize()
84 {
85  for (int j=0; j<3; j++)
86  {
87  for (int i=0; i<3; i++)
88  {
89  this->T[i+j*3] = 0.0;
90  }
91  }
92 }
93 
94 //----------------------------------------------------------------------------
96 {
97  for (int j=0; j < 3; j++)
98  {
99  for (int i=0; i < 3; i++)
100  {
101  this->T[i+3*j] = t->T[i+3*j];
102  }
103  }
104 }
105 
106 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:61
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
double * GetColumn(int j)
Definition: vtkTensor.h:60
void DeepCopy(vtkTensor *t)
Definition: vtkTensor.h:95
double * T
Definition: vtkTensor.h:67
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
void AddComponent(int i, int j, double v)
Definition: vtkTensor.h:54
void Initialize()
Definition: vtkTensor.h:83
~vtkTensor()
Definition: vtkTensor.h:74
supporting class to enable assignment and referencing of tensors
Definition: vtkTensor.h:34
static vtkObject * New()
#define VTKCOMMONDATAMODEL_EXPORT
void SetComponent(int i, int j, double v)
Definition: vtkTensor.h:49
double GetComponent(int i, int j)
Definition: vtkTensor.h:45