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 "vtkPVVTKExtensionsIOSPCTHModule.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;
41 
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 argument
73  static int Scan(vtkSpyPlotIStream* stream, unsigned char* isAllocated, int fileVersion);
74  // For performance reasons, lets do 16 at a time.
75  static int Scan16(vtkSpyPlotIStream* stream, unsigned char* isAllocated, int fileVersion);
77 
78  int SetGeometry(int dir, const unsigned char* encodedInfo, int infoSize);
79  int GetTotalSize() const;
80  int FixInformation(const vtkBoundingBox& globalBounds, int extents[6], int realExtents[6],
81  int realDims[3], vtkDataArray* ca[3]);
82  // Dummy functions so we can use vtk macros
83  void SetDebug(unsigned char i);
84  unsigned char GetDebug() const;
85 
86  void SetCoordinateSystem(const int& coordinateSystem);
87 
88  void ComputeDerivedVariables(vtkCellData* data, const int& numberOfMaterials,
89  vtkDataArray** materialMasses, vtkDataArray** materialVolumeFractions,
90  const int& downConvertVolumeFraction) const;
91 
92 protected:
93  // will return a negative volume if you request the volume of a cell
94  // that is outside the dimensions of the block
95  double GetCellVolume(int i, int j, int k) const;
96  void ComputeMaterialDensity(vtkIdType position, vtkDataArray* materialMasses,
97  vtkUnsignedCharArray* materialFraction, vtkDoubleArray* volumes,
98  vtkDoubleArray* materialdensity, double* material_mass, double* material_volume) const;
99  void ComputeMaterialDensity(vtkIdType position, vtkDataArray* materialMasses,
100  vtkFloatArray* materialFraction, vtkDoubleArray* volumes, vtkDoubleArray* materialdensity,
101  double* material_mass, double* material_volume) const;
102 
103  int Dimensions[3];
105  {
106 #ifndef __WRAP__
107  unsigned Active : 1;
108  unsigned Allocated : 1;
109  unsigned AMR : 1;
110  unsigned Fixed : 1;
111  unsigned Debug : 1;
112 #endif
113  };
115  int Level;
116  vtkFloatArray* XYZArrays[3];
117 
118  // for restoring structured once external ghost cells are removed
119  int SavedExtents[6];
120  int SavedRealExtents[6];
121  int SavedRealDims[3];
122 
123 private:
124  enum CoordinateSystem
125  {
126  Cylinder1D = 11,
127  Sphere1D = 12,
128  Cartesian2D = 20,
129  Cylinder2D = 21,
130  Cartesian3D = 30
131  };
132  CoordinateSystem CoordSystem;
133 };
134 
135 inline int vtkSpyPlotBlock::GetLevel() const
136 {
137  return this->Level;
138 }
139 
140 inline void vtkSpyPlotBlock::GetDimensions(int dims[3]) const
141 {
142  dims[0] = this->Dimensions[0];
143  dims[1] = this->Dimensions[1];
144  dims[2] = this->Dimensions[2];
145 }
146 
147 inline int vtkSpyPlotBlock::IsActive() const
148 {
149  return this->Status.Active;
150 }
151 
153 {
154  return this->Status.Allocated;
155 }
156 
157 inline int vtkSpyPlotBlock::IsAMR() const
158 {
159  return this->Status.AMR;
160 }
161 
162 inline int vtkSpyPlotBlock::IsFixed() const
163 {
164  return this->Status.Fixed;
165 }
166 
168 {
169  this->Status.Fixed = 1;
170 }
171 
172 inline int vtkSpyPlotBlock::GetDimension(int i) const
173 {
174  return this->Dimensions[i];
175 }
176 
178 {
179  fa[0] = this->XYZArrays[0];
180  fa[1] = this->XYZArrays[1];
181  fa[2] = this->XYZArrays[2];
182 }
183 
185 {
186  return this->XYZArrays[i];
187 }
188 
189 inline void vtkSpyPlotBlock::GetExtents(int extents[6]) const
190 {
191  extents[0] = extents[2] = extents[4] = 0;
192  extents[1] = (this->Dimensions[0] == 1) ? 0 : this->Dimensions[0];
193  extents[3] = (this->Dimensions[1] == 1) ? 0 : this->Dimensions[1];
194  extents[5] = (this->Dimensions[2] == 1) ? 0 : this->Dimensions[2];
195 }
196 
198 {
199  return (this->Dimensions[0] * this->Dimensions[1] * this->Dimensions[2]);
200 }
201 
202 #endif
203 
204 // VTK-HeaderTest-Exclude: vtkSpyPlotBlock.h
data
int GetDimension(int i) const
int IsAllocated() const
level
int IsActive() const
int vtkIdType
int IsAMR() const
int GetLevel() const
int IsFixed() const
void GetExtents(int extents[6]) const
void GetVectors(vtkDataArray *coordinates[3]) const
dir
void GetDimensions(int dims[3]) const
vtkSpyPlotIStream represents input functionality required by the vtkSpyPlotReader and vtkSpyPlotUniRe...
BlockStatusType Status
int GetTotalSize() const
spacing
#define VTKPVVTKEXTENSIONSIOSPCTH_EXPORT
Represents a SpyPlot Block Grid.
coordinateSystem
position