vtkSpyPlotBlock.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
3 // SPDX-License-Identifier: BSD-3-Clause
17 #ifndef vtkSpyPlotBlock_h
18 #define vtkSpyPlotBlock_h
19 
20 #include "vtkPVVTKExtensionsIOSPCTHModule.h" //needed for exports
21 #include "vtkType.h" // for vtkIdType
22 
23 class vtkCellData;
24 class vtkDoubleArray;
25 class vtkDataArray;
26 class vtkFloatArray;
27 class vtkSpyPlotIStream;
28 class vtkBoundingBox;
30 
32 {
33 public:
35  ~vtkSpyPlotBlock();
37 
40  int GetLevel() const;
41  void GetDimensions(int dims[3]) const;
42  int GetDimension(int i) const;
43  void GetBounds(double bounds[6]) const;
44  void GetSpacing(double spacing[3]) const;
45  void GetVectors(vtkDataArray* coordinates[3]) const;
46  void GetVectors(vtkFloatArray* coordinates[3]) const;
47  vtkFloatArray* GetVectors(int i) const;
48  void GetExtents(int extents[6]) const;
49  int IsAllocated() const;
50  int IsFixed() const;
51  int IsActive() const;
52  int IsAMR() const;
53  void MarkedAsFixed();
54  void GetRealBounds(double realBounds[6]) const;
55  int GetAMRInformation(const vtkBoundingBox& globalBounds, int* level, double spacing[3],
56  double origin[3], int extents[6], int realExtents[6], int realDimensions[3]) const;
57  // Read reads in the actual block's information
58  int Read(int isAMR, int fileVersion, vtkSpyPlotIStream* stream);
59  // Advances the stream to be after the block, information w/r
60  // whether the block is allocated in the time step is returned
61  // as an argument
62  static int Scan(vtkSpyPlotIStream* stream, unsigned char* isAllocated, int fileVersion);
63  // For performance reasons, lets do 16 at a time.
64  static int Scan16(vtkSpyPlotIStream* stream, unsigned char* isAllocated, int fileVersion);
66 
67  int SetGeometry(int dir, const unsigned char* encodedInfo, int infoSize);
68  int GetTotalSize() const;
69  int FixInformation(const vtkBoundingBox& globalBounds, int extents[6], int realExtents[6],
70  int realDims[3], vtkDataArray* ca[3]);
71  // Dummy functions so we can use vtk macros
72  void SetDebug(unsigned char i);
73  unsigned char GetDebug() const;
74 
75  void SetCoordinateSystem(const int& coordinateSystem);
76 
77  void ComputeDerivedVariables(vtkCellData* data, const int& numberOfMaterials,
78  vtkDataArray** materialMasses, vtkDataArray** materialVolumeFractions,
79  const int& downConvertVolumeFraction) const;
80 
81 protected:
82  // will return a negative volume if you request the volume of a cell
83  // that is outside the dimensions of the block
84  double GetCellVolume(int i, int j, int k) const;
85  void ComputeMaterialDensity(vtkIdType position, vtkDataArray* materialMasses,
86  vtkUnsignedCharArray* materialFraction, vtkDoubleArray* volumes,
87  vtkDoubleArray* materialdensity, double* material_mass, double* material_volume) const;
88  void ComputeMaterialDensity(vtkIdType position, vtkDataArray* materialMasses,
89  vtkFloatArray* materialFraction, vtkDoubleArray* volumes, vtkDoubleArray* materialdensity,
90  double* material_mass, double* material_volume) const;
91 
92  int Dimensions[3];
94  {
95 #ifndef __WRAP__
96  unsigned Active : 1;
97  unsigned Allocated : 1;
98  unsigned AMR : 1;
99  unsigned Fixed : 1;
100  unsigned Debug : 1;
101 #endif
102  };
104  int Level;
105  vtkFloatArray* XYZArrays[3];
106 
107  // for restoring structured once external ghost cells are removed
108  int SavedExtents[6];
109  int SavedRealExtents[6];
110  int SavedRealDims[3];
111 
112 private:
113  enum CoordinateSystem
114  {
115  Cylinder1D = 11,
116  Sphere1D = 12,
117  Cartesian2D = 20,
118  Cylinder2D = 21,
119  Cartesian3D = 30
120  };
121  CoordinateSystem CoordSystem;
122 };
123 
124 inline int vtkSpyPlotBlock::GetLevel() const
125 {
126  return this->Level;
127 }
128 
129 inline void vtkSpyPlotBlock::GetDimensions(int dims[3]) const
130 {
131  dims[0] = this->Dimensions[0];
132  dims[1] = this->Dimensions[1];
133  dims[2] = this->Dimensions[2];
134 }
135 
136 inline int vtkSpyPlotBlock::IsActive() const
137 {
138  return this->Status.Active;
139 }
140 
142 {
143  return this->Status.Allocated;
144 }
145 
146 inline int vtkSpyPlotBlock::IsAMR() const
147 {
148  return this->Status.AMR;
149 }
150 
151 inline int vtkSpyPlotBlock::IsFixed() const
152 {
153  return this->Status.Fixed;
154 }
155 
157 {
158  this->Status.Fixed = 1;
159 }
160 
161 inline int vtkSpyPlotBlock::GetDimension(int i) const
162 {
163  return this->Dimensions[i];
164 }
165 
167 {
168  fa[0] = this->XYZArrays[0];
169  fa[1] = this->XYZArrays[1];
170  fa[2] = this->XYZArrays[2];
171 }
172 
174 {
175  return this->XYZArrays[i];
176 }
177 
178 inline void vtkSpyPlotBlock::GetExtents(int extents[6]) const
179 {
180  extents[0] = extents[2] = extents[4] = 0;
181  extents[1] = (this->Dimensions[0] == 1) ? 0 : this->Dimensions[0];
182  extents[3] = (this->Dimensions[1] == 1) ? 0 : this->Dimensions[1];
183  extents[5] = (this->Dimensions[2] == 1) ? 0 : this->Dimensions[2];
184 }
185 
187 {
188  return (this->Dimensions[0] * this->Dimensions[1] * this->Dimensions[2]);
189 }
190 
191 #endif
192 
193 // 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