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 "vtkObject.h"
32 
34 {
35 public:
36  static vtkTensor *New();
37  vtkTypeMacro(vtkTensor,vtkObject);
38  void PrintSelf(ostream& os, vtkIndent indent);
39 
41  void Initialize();
42 
44  double GetComponent(int i, int j) {return this->T[i+3*j];};
45 
47 
48  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;};
50 
52 
53  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;};
55 
57 
59  double *GetColumn(int j) { if (j > 2) {vtkErrorMacro("trying to get tensor column j > 2: j = " << j); return NULL;}; return this->T + 3*j;};
61 
63  void DeepCopy(vtkTensor *t);
64 
66  operator double*() {return this->T;};
67 
69  double *T;
70 
71 protected:
72  vtkTensor();
73  ~vtkTensor() {};
74 
75  double Storage[9];
76 private:
77  vtkTensor(const vtkTensor&); // Not implemented.
78  void operator=(const vtkTensor&); // Not implemented.
79 };
80 
81 //----------------------------------------------------------------------------
82 inline void vtkTensor::Initialize()
83 {
84  for (int j=0; j<3; j++)
85  {
86  for (int i=0; i<3; i++)
87  {
88  this->T[i+j*3] = 0.0;
89  }
90  }
91 }
92 
93 //----------------------------------------------------------------------------
95 {
96  for (int j=0; j < 3; j++)
97  {
98  for (int i=0; i < 3; i++)
99  {
100  this->T[i+3*j] = t->T[i+3*j];
101  }
102  }
103 }
104 
105 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:60
double * GetColumn(int j)
Definition: vtkTensor.h:59
void DeepCopy(vtkTensor *t)
Definition: vtkTensor.h:94
double * T
Definition: vtkTensor.h:66
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:37
void AddComponent(int i, int j, double v)
Definition: vtkTensor.h:53
#define VTK_COMMON_EXPORT
void Initialize()
Definition: vtkTensor.h:82
~vtkTensor()
Definition: vtkTensor.h:73
supporting class to enable assignment and referencing of tensors
Definition: vtkTensor.h:33
static vtkObject * New()
void SetComponent(int i, int j, double v)
Definition: vtkTensor.h:48
double GetComponent(int i, int j)
Definition: vtkTensor.h:44