Thanks to visit codestin.com
Credit goes to vtk.org

VTK  9.5.20251001
vtkOverlappingAMRMetaData.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
24#ifndef vtkOverlappingAMRMetaData_h
25#define vtkOverlappingAMRMetaData_h
26
27#include "vtkAMRBox.h" //for storing AMR Boxes
28#include "vtkAMRMetaData.h"
29#include "vtkBoundingBox.h" //for storing AMR Bounding boxes
30#include "vtkCommonDataModelModule.h" // For export macro
31#include "vtkSmartPointer.h" //for ivars
32
33VTK_ABI_NAMESPACE_BEGIN
34class vtkIntArray;
35class vtkDoubleArray;
36class VTKCOMMONDATAMODEL_EXPORT vtkOverlappingAMRMetaData : public vtkAMRMetaData
37{
38public:
41
42 void PrintSelf(ostream& os, vtkIndent indent) override;
43 bool operator==(const vtkOverlappingAMRMetaData& other) const;
44 bool operator!=(const vtkOverlappingAMRMetaData& other) const { return !(*this == other); }
45
46 // VTK_DEPRECATED_IN_9_6_0
47 // Remove once the deprecated Initialize method in parent class is removed
49
54 void Initialize(const std::vector<unsigned int>& blocksPerLevel) override;
55
57
61 void GetOrigin(double origin[3]);
62 [[nodiscard]] double* GetOrigin();
63 void SetOrigin(const double* origin);
65
69 [[nodiscard]] const double* GetBounds();
70
76 void GetBounds(unsigned int level, unsigned int id, double* bb);
77
83 void SetBounds(unsigned int level, unsigned int id, double* bb);
84
90 bool GetOrigin(unsigned int level, unsigned int id, double* origin);
91
96 void GetSpacing(unsigned int level, double spacing[3]);
97
101 [[nodiscard]] bool HasSpacing(unsigned int level) const;
102
106 [[nodiscard]] bool HasSpacing() const;
107
111 [[nodiscard]] bool HasBlockBounds(unsigned int index) const;
112
116 [[nodiscard]] bool HasBlockBounds() const;
117
119
122 void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox& box);
123 [[nodiscard]] const vtkAMRBox& GetAMRBox(unsigned int level, unsigned int id) const;
124 bool GetAMRBox(unsigned int level, unsigned int id, vtkAMRBox& box) const;
126
132 bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox& box);
133
135
139 [[nodiscard]] int GetAMRBlockSourceIndex(int index);
140 void SetAMRBlockSourceIndex(int index, int sourceId);
142
155
161 [[nodiscard]] bool HasRefinementRatio() const;
162
167 void SetRefinementRatio(unsigned int level, int ratio);
168
174 [[nodiscard]] int GetRefinementRatio(unsigned int level) const;
175
179 void SetSpacing(unsigned int level, const double* h);
180
184 [[nodiscard]] bool HasChildrenInformation() const;
185
191 unsigned int* GetParents(unsigned int level, unsigned int index, unsigned int& numParents);
192
198 unsigned int* GetChildren(unsigned int level, unsigned int index, unsigned int& numChildren);
199
203 void PrintParentChildInfo(unsigned int level, unsigned int index);
204
213
217 [[nodiscard]] bool CheckValidity();
218
225 bool FindCell(double q[3], unsigned int level, unsigned int index, int& cellIdx);
226
230 bool FindGrid(double q[3], int level, unsigned int& gridId);
231
235 bool FindGrid(double q[3], unsigned int& level, unsigned int& gridId);
236
241 [[nodiscard]] std::vector<std::vector<unsigned int>>& GetChildrenAtLevel(unsigned int i)
242 {
243 return this->AllChildren[i];
244 }
245
247
250 [[nodiscard]] vtkGetMacro(GridType, unsigned int);
251 vtkSetMacro(GridType, unsigned int);
253
258 void DeepCopy(vtkAMRMetaData* other) override;
259
260protected:
263
264private:
266 void operator=(const vtkOverlappingAMRMetaData&) = delete;
267
268 bool HasValidOrigin() const;
269 bool HasValidBounds() const;
270 void UpdateBounds(int level, int id);
271 void AllocateBoxes(unsigned int n);
272 void AllocateBlockBounds(unsigned int n);
273 void CalculateParentChildRelationShip(unsigned int level,
274 std::vector<std::vector<unsigned int>>& children,
275 std::vector<std::vector<unsigned int>>& parents);
276
277 //-------------------------------------------------------------------------
278 // Essential information that determines an AMR structure. Must be copied
279 //-------------------------------------------------------------------------
280 unsigned int GridType = VTK_DATA_SET;
281
282 // the origin of the whole data set
283 double Origin[3] = { VTK_DOUBLE_MAX, VTK_DOUBLE_MAX, VTK_DOUBLE_MAX };
284
285 // vtkAMRBoxes, one per block
286 std::vector<vtkAMRBox> Boxes;
287
288 // BoundingBoxes, one per block if used
289 std::vector<vtkBoundingBox> BlockBounds;
290
291 // Typically, this maps to a file block index used by the reader
293
294 // The grid spacing for all levels
296
297 // the bounds of the entire domain
300
301 //-------------------------------------------------------------------------
302 // Auxiliary information that be computed
303 //-------------------------------------------------------------------------
304
305 // refinement ratio between two adjacent levels
306 vtkNew<vtkIntArray> Refinement;
307
308 // parent child information
309 std::vector<std::vector<std::vector<unsigned int>>> AllChildren;
310 std::vector<std::vector<std::vector<unsigned int>>> AllParents;
311};
312
313VTK_ABI_NAMESPACE_END
314#endif
Encloses a rectangular region of voxel like cells.
Definition vtkAMRBox.h:69
Meta data that describes the structure of a generic AMR data set.
virtual void Initialize(const std::vector< unsigned int > &blocksPerLevel)
Initialize the meta information blocksPerLevel is the number of blocks for each levels.
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition vtkIndent.h:108
dynamic, self-adjusting array of int
Allocate and hold a VTK object.
Definition vtkNew.h:167
Meta data that describes the structure of an overlapping AMR data set.
void SetAMRBlockSourceIndex(int index, int sourceId)
Get/Set the SourceIndex of a block.
const double * GetBounds()
Returns the bounds of the entire domain as a 6 sized array.
int GetRefinementRatio(unsigned int level) const
Returns the refinement of a given level.
bool HasChildrenInformation() const
Return whether parent child information has been generated.
void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox &box)
Methods to set and get the AMR box at a given position.
bool HasRefinementRatio() const
Returns whether refinement ratio has been set (either by calling GenerateRefinementRatio() or by call...
bool HasSpacing() const
Return if all levels have spacing.
bool CheckValidity()
Checks whether the meta data is internally consistent.
void SetSpacing(unsigned int level, const double *h)
Set the spacing at a given level.
bool FindGrid(double q[3], int level, unsigned int &gridId)
find the grid that contains the point q at the specified level
unsigned int * GetParents(unsigned int level, unsigned int index, unsigned int &numParents)
Generate parent/children information if needed then return a pointer to Parents of a block.
void PrintParentChildInfo(unsigned int level, unsigned int index)
Generate if needed and prints the parents and children of a requested block (Debug Routine)
void Initialize(const std::vector< unsigned int > &blocksPerLevel) override
Initialize the meta information blocksPerLevels is the number of blocks for each level.
void GetOrigin(double origin[3])
Get the AMR block origin as a 3 sized array The origin is essentially the minimum of all the grids.
unsigned int * GetChildren(unsigned int level, unsigned int index, unsigned int &numChildren)
Generate parent/children information if needed then return a pointer to Children of a block.
void SetRefinementRatio(unsigned int level, int ratio)
Set the refinement ratio at a level.
double * GetOrigin()
Get the AMR block origin as a 3 sized array The origin is essentially the minimum of all the grids.
bool HasBlockBounds(unsigned int index) const
Return true if a specific block bounds have been set.
bool FindGrid(double q[3], unsigned int &level, unsigned int &gridId)
Given a point q, find the highest level grid that contains it.
static vtkOverlappingAMRMetaData * New()
bool HasBlockBounds() const
Return true if block bounds have been set on all blocks.
bool operator==(const vtkOverlappingAMRMetaData &other) const
bool operator!=(const vtkOverlappingAMRMetaData &other) const
bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox &box)
Fill the provided box coarsened to the previous level Requite spacing/refinement ratio.
void GetSpacing(unsigned int level, double spacing[3])
Return the spacing at the given level Should only be called if HasSpacing() is true.
void DeepCopy(vtkAMRMetaData *other) override
Check it is an vtkOverlappingAMRMetaData and copy internal fields from other into this.
bool FindCell(double q[3], unsigned int level, unsigned int index, int &cellIdx)
Given a point q, find whether q is bounded by the data set at (level,index).
void PrintSelf(ostream &os, vtkIndent indent) override
Print members.
void GetBounds(unsigned int level, unsigned int id, double *bb)
Returns the bounding box of a given box Rely on the BlockBounds if available or compute them on the f...
bool HasSpacing(unsigned int level) const
Return if a specific level has spacing.
void GenerateParentChildInformation()
Generate the parent/child relationships - needed to be called before GetParents or GetChildren can be...
const vtkAMRBox & GetAMRBox(unsigned int level, unsigned int id) const
Methods to set and get the AMR box at a given position.
~vtkOverlappingAMRMetaData() override
std::vector< std::vector< unsigned int > > & GetChildrenAtLevel(unsigned int i)
Get children at a specific level HasChildrenInformation is NOT checked by this method.
bool GenerateRefinementRatio()
This method computes the refinement ratio at each level.
bool GetOrigin(unsigned int level, unsigned int id, double *origin)
Recover the origin of the grid at (level,id).
bool GetAMRBox(unsigned int level, unsigned int id, vtkAMRBox &box) const
Methods to set and get the AMR box at a given position.
int GetAMRBlockSourceIndex(int index)
Get/Set the SourceIndex of a block.
void SetBounds(unsigned int level, unsigned int id, double *bb)
Set the Bounds of a specific AMR block This is usually called when using vtkRectilinearGrid in an Ove...
void SetOrigin(const double *origin)
Get the AMR block origin as a 3 sized array The origin is essentially the minimum of all the grids.
Computes the portion of a dataset which is inside a selection.
Hold a reference to a vtkObjectBase instance.
#define VTK_DOUBLE_MIN
Definition vtkType.h:172
#define VTK_DOUBLE_MAX
Definition vtkType.h:173
@ VTK_DATA_SET
Definition vtkType.h:84