ParaView
vtkSpyPlotBlock.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: Visualization Toolkit
4 Module: vtkSpyPlotBlock.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 vtkSpyPlotBlock_h
29 #define vtkSpyPlotBlock_h
30 
31 #include "vtkPVVTKExtensionsDefaultModule.h" //needed for exports
32 #include "vtkSystemIncludes.h"
33 
34 class vtkCellData;
35 class vtkDoubleArray;
36 class vtkDataArray;
37 class vtkFloatArray;
38 class vtkSpyPlotIStream;
39 class vtkBoundingBox;
40 class vtkUnsignedCharArray;
41 
42 class VTKPVVTKEXTENSIONSDEFAULT_EXPORT vtkSpyPlotBlock
43 {
44 public:
46  ~vtkSpyPlotBlock();
48 
51  int GetLevel() const;
52  void GetDimensions(int dims[3]) const;
53  int GetDimension(int i) const;
54  void GetBounds(double bounds[6]) const;
55  void GetSpacing(double spacing[3]) const;
56  void GetVectors(vtkDataArray* coordinates[3]) const;
57  void GetVectors(vtkFloatArray* coordinates[3]) const;
58  vtkFloatArray* GetVectors(int i) const;
59  void GetExtents(int extents[6]) const;
60  int IsAllocated() const;
61  int IsFixed() const;
62  int IsActive() const;
63  int IsAMR() const;
64  void MarkedAsFixed();
65  void GetRealBounds(double realBounds[6]) const;
66  int GetAMRInformation(const vtkBoundingBox& globalBounds, int* level, double spacing[3],
67  double origin[3], int extents[6], int realExtents[6], int realDimensions[3]) const;
68  // Read reads in the actual block's information
69  int Read(int isAMR, int fileVersion, vtkSpyPlotIStream* stream);
70  // Advances the stream to be after the block, information w/r
71  // whether the block is allocated in the time step is returned
72  // as an arguement
73  static int Scan(vtkSpyPlotIStream* stream, unsigned char* isAllocated, int fileVersion);
75 
76  int SetGeometry(int dir, const unsigned char* encodedInfo, int infoSize);
77  int GetTotalSize() const;
78  int FixInformation(const vtkBoundingBox& globalBounds, int extents[6], int realExtents[6],
79  int realDims[3], vtkDataArray* ca[3]);
80  // Dummy functions so we can use vtk macros
81  void SetDebug(unsigned char i);
82  unsigned char GetDebug() const;
83  const char* GetClassName() const;
84  int HasObserver(const char*) const;
85  int InvokeEvent(const char*, void*) const;
86 
87  void SetCoordinateSystem(const int& coordinateSystem);
88 
89  void ComputeDerivedVariables(vtkCellData* data, const int& numberOfMaterials,
90  vtkDataArray** materialMasses, vtkDataArray** materialVolumeFractions,
91  const int& downConvertVolumeFraction) const;
92 
93 protected:
94  // will return a negative volume if you requst a the volume of a cell
95  // that is outside the demensions of the block
96  double GetCellVolume(int i, int j, int k) const;
97  void ComputeMaterialDensity(vtkIdType position, vtkDataArray* materialMasses,
98  vtkUnsignedCharArray* materialFraction, vtkDoubleArray* volumes,
99  vtkDoubleArray* materialdensity, double* material_mass, double* material_volume) const;
100  void ComputeMaterialDensity(vtkIdType position, vtkDataArray* materialMasses,
101  vtkFloatArray* materialFraction, vtkDoubleArray* volumes, vtkDoubleArray* materialdensity,
102  double* material_mass, double* material_volume) const;
103 
104  int Dimensions[3];
106  {
107 #ifndef __WRAP__
108  unsigned Active : 1;
109  unsigned Allocated : 1;
110  unsigned AMR : 1;
111  unsigned Fixed : 1;
112  unsigned Debug : 1;
113 #endif
114  };
116  int Level;
117  vtkFloatArray* XYZArrays[3];
118 
119  // for restoring structured once external ghost cells are removed
120  int SavedExtents[6];
121  int SavedRealExtents[6];
122  int SavedRealDims[3];
123 
124 private:
125  enum CoordinateSystem
126  {
127  Cylinder1D = 11,
128  Sphere1D = 12,
129  Cartesian2D = 20,
130  Cylinder2D = 21,
131  Cartesian3D = 30
132  };
133  CoordinateSystem CoordSystem;
134 };
135 
136 inline int vtkSpyPlotBlock::GetLevel() const
137 {
138  return this->Level;
139 }
140 
141 inline void vtkSpyPlotBlock::GetDimensions(int dims[3]) const
142 {
143  dims[0] = this->Dimensions[0];
144  dims[1] = this->Dimensions[1];
145  dims[2] = this->Dimensions[2];
146 }
147 
148 inline int vtkSpyPlotBlock::IsActive() const
149 {
150  return this->Status.Active;
151 }
152 
154 {
155  return this->Status.Allocated;
156 }
157 
158 inline int vtkSpyPlotBlock::IsAMR() const
159 {
160  return this->Status.AMR;
161 }
162 
163 inline int vtkSpyPlotBlock::IsFixed() const
164 {
165  return this->Status.Fixed;
166 }
167 
169 {
170  this->Status.Fixed = 1;
171 }
172 
173 inline int vtkSpyPlotBlock::GetDimension(int i) const
174 {
175  return this->Dimensions[i];
176 }
177 
178 inline void vtkSpyPlotBlock::GetVectors(vtkFloatArray* fa[3]) const
179 {
180  fa[0] = this->XYZArrays[0];
181  fa[1] = this->XYZArrays[1];
182  fa[2] = this->XYZArrays[2];
183 }
184 
185 inline vtkFloatArray* vtkSpyPlotBlock::GetVectors(int i) const
186 {
187  return this->XYZArrays[i];
188 }
189 
190 inline void vtkSpyPlotBlock::GetExtents(int extents[6]) const
191 {
192  extents[0] = extents[2] = extents[4] = 0;
193  extents[1] = (this->Dimensions[0] == 1) ? 0 : this->Dimensions[0];
194  extents[3] = (this->Dimensions[1] == 1) ? 0 : this->Dimensions[1];
195  extents[5] = (this->Dimensions[2] == 1) ? 0 : this->Dimensions[2];
196 }
197 
199 {
200  return (this->Dimensions[0] * this->Dimensions[1] * this->Dimensions[2]);
201 }
202 
203 #endif
204 
205 // VTK-HeaderTest-Exclude: vtkSpyPlotBlock.h
int GetDimension(int i) const
int IsAllocated() const
int IsActive() const
int IsAMR() const
int GetLevel() const
int IsFixed() const
void GetExtents(int extents[6]) const
void GetVectors(vtkDataArray *coordinates[3]) const
void GetDimensions(int dims[3]) const
vtkSpyPlotIStream represents input functionality required by the vtkSpyPlotReader and vtkSpyPlotUniRe...
BlockStatusType Status
int GetTotalSize() const
Represents a SpyPlot Block Grid.