VTK  9.0.1
vtkAMRInformation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkAMRInformation.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 =========================================================================*/
31 #ifndef vtkAMRInformation_h
32 #define vtkAMRInformation_h
33 
34 #include "vtkAMRBox.h" //for storing AMR Boxes
35 #include "vtkCommonDataModelModule.h" // For export macro
36 #include "vtkObject.h"
37 #include "vtkSmartPointer.h" //for ivars
38 #include <vector> //for storing AMR Boxes
39 
40 typedef std::vector<vtkAMRBox> vtkAMRBoxList;
41 
43 class vtkIntArray;
44 class vtkDoubleArray;
45 class vtkAMRIndexIterator;
46 
47 class VTKCOMMONDATAMODEL_EXPORT vtkAMRInformation : public vtkObject
48 {
49 public:
50  static vtkAMRInformation* New();
51  vtkTypeMacro(vtkAMRInformation, vtkObject);
52 
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
55  bool operator==(const vtkAMRInformation& other);
56 
62  void Initialize(int numLevels, const int* blocksPerLevel);
63 
65 
68  vtkGetMacro(GridDescription, int);
69  void SetGridDescription(int description);
71 
73 
77  void GetOrigin(double origin[3]);
78  double* GetOrigin();
79  void SetOrigin(const double* origin);
81 
85  unsigned int GetNumberOfLevels() const
86  {
87  return static_cast<unsigned int>(this->NumBlocks.size() - 1);
88  }
89 
93  unsigned int GetNumberOfDataSets(unsigned int level) const;
94 
98  unsigned int GetTotalNumberOfBlocks() { return this->NumBlocks.back(); }
99 
103  int GetIndex(unsigned int level, unsigned int id) const { return this->NumBlocks[level] + id; }
104 
108  void ComputeIndexPair(unsigned int index, unsigned int& level, unsigned int& id);
109 
113  const double* GetBounds();
114 
118  void GetBounds(unsigned int level, unsigned int id, double* bb);
119 
123  bool GetOrigin(unsigned int level, unsigned int id, double* origin);
124 
128  void GetSpacing(unsigned int level, double spacing[3]);
129 
130  bool HasSpacing(unsigned int level);
131 
133 
136  void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox& box);
137  const vtkAMRBox& GetAMRBox(unsigned int level, unsigned int id) const;
139 
143  bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox& box) const;
144 
146 
150  int GetAMRBlockSourceIndex(int index);
151  void SetAMRBlockSourceIndex(int index, int sourceId);
153 
164  void GenerateRefinementRatio();
165 
170  bool HasRefinementRatio();
171 
176  void SetRefinementRatio(unsigned int level, int ratio);
177 
181  int GetRefinementRatio(unsigned int level) const;
182 
186  void SetSpacing(unsigned int level, const double* h);
187 
191  bool HasChildrenInformation();
192 
198  unsigned int* GetParents(unsigned int level, unsigned int index, unsigned int& numParents);
199 
205  unsigned int* GetChildren(unsigned int level, unsigned int index, unsigned int& numChildren);
206 
210  void PrintParentChildInfo(unsigned int level, unsigned int index);
211 
216  void GenerateParentChildInformation();
217 
221  bool Audit();
222 
228  bool FindCell(double q[3], unsigned int level, unsigned int index, int& cellIdx);
229 
233  bool FindGrid(double q[3], int level, unsigned int& gridId);
234 
238  bool FindGrid(double q[3], unsigned int& level, unsigned int& gridId);
239 
243  const std::vector<int>& GetNumBlocks() const { return this->NumBlocks; }
244 
245  std::vector<std::vector<unsigned int> >& GetChildrenAtLevel(unsigned int i)
246  {
247  return this->AllChildren[i];
248  }
249 
250  void DeepCopy(vtkAMRInformation* other);
251 
252 private:
254  ~vtkAMRInformation() override;
255  vtkAMRInformation(const vtkAMRInformation&) = delete;
256  void operator=(const vtkAMRInformation&) = delete;
257 
258  bool HasValidOrigin();
259  bool HasValidBounds();
260  void UpdateBounds(const int level, const int id);
261  void AllocateBoxes(unsigned int n);
262  void GenerateBlockLevel();
263  void CalculateParentChildRelationShip(unsigned int level,
264  std::vector<std::vector<unsigned int> >& children,
265  std::vector<std::vector<unsigned int> >& parents);
266 
267  //-------------------------------------------------------------------------
268  // Essential information that determines an AMR structure. Must be copied
269  //-------------------------------------------------------------------------
270  int GridDescription; // example: VTK_XYZ_GRID
271  double Origin[3]; // the origin of the whole data set
272  vtkAMRBoxList Boxes; // vtkAMRBoxes, one per data set
273  std::vector<int>
274  NumBlocks; // NumBlocks[i] stores the total number of blocks from level 0 to level i-1
275 
277  SourceIndex; // Typically, this maps to a file block index used by the reader
278  vtkSmartPointer<vtkDoubleArray> Spacing; // The grid spacing for all levels
279  double Bounds[6]; // the bounds of the entire domain
280 
281  //-------------------------------------------------------------------------
282  // Auxiliary information that be computed
283  //-------------------------------------------------------------------------
284  vtkSmartPointer<vtkIntArray> Refinement; // refinement ratio between two adjacent levels
285  vtkSmartPointer<vtkUnsignedIntArray> BlockLevel; // only necessary if need to call
286  // ComputeIndexPair
287 
288  // parent child information
289  std::vector<std::vector<std::vector<unsigned int> > > AllChildren;
290  std::vector<std::vector<std::vector<unsigned int> > > AllParents;
291 };
292 
293 #endif
vtkAMRBox
Encloses a rectangular region of voxel like cells.
Definition: vtkAMRBox.h:33
vtkX3D::vector
@ vector
Definition: vtkX3D.h:243
vtkUnsignedIntArray
dynamic, self-adjusting array of unsigned int
Definition: vtkUnsignedIntArray.h:39
vtkAMRInformation
Meta data that describes the structure of an AMR data set.
Definition: vtkAMRInformation.h:47
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkAMRInformation::GetChildrenAtLevel
std::vector< std::vector< unsigned int > > & GetChildrenAtLevel(unsigned int i)
Definition: vtkAMRInformation.h:245
vtkSmartPointer< vtkIntArray >
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkAMRInformation::GetNumberOfLevels
unsigned int GetNumberOfLevels() const
Return the number of levels.
Definition: vtkAMRInformation.h:85
vtkAMRBoxList
std::vector< vtkAMRBox > vtkAMRBoxList
Definition: vtkAMRInformation.h:40
vtkX3D::level
@ level
Definition: vtkX3D.h:401
vtkAMRInformation::GetNumBlocks
const std::vector< int > & GetNumBlocks() const
Returns internal arrays.
Definition: vtkAMRInformation.h:243
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
vtkSmartPointer.h
vtkAMRInformation::GetTotalNumberOfBlocks
unsigned int GetTotalNumberOfBlocks()
Returns total number of datasets.
Definition: vtkAMRInformation.h:98
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
operator==
VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
vtkObject.h
vtkAMRInformation::GetIndex
int GetIndex(unsigned int level, unsigned int id) const
Returns the single index from a pair of indices.
Definition: vtkAMRInformation.h:103
vtkX3D::spacing
@ spacing
Definition: vtkX3D.h:487
vtkAMRBox.h
vtkX3D::description
@ description
Definition: vtkX3D.h:328
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:35
vtkX3D::index
@ index
Definition: vtkX3D.h:252
h