VTK  9.7.1
vtkUniformHyperTreeGrid.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
21 #ifndef vtkUniformHyperTreeGrid_h
22 #define vtkUniformHyperTreeGrid_h
23 
24 #include <algorithm> // std::min/std::max
25 #include <cmath> // std::round
26 #include <limits> // std::numeric_limits
27 #include <memory> // std::shared_ptr
28 
29 #include "vtkCommonDataModelModule.h" // For export macro
30 #include "vtkHyperTreeGrid.h"
31 
32 VTK_ABI_NAMESPACE_BEGIN
33 class vtkDoubleArray;
35 
36 class VTKCOMMONDATAMODEL_EXPORT vtkUniformHyperTreeGrid : public vtkHyperTreeGrid
37 {
38 public:
39  static vtkUniformHyperTreeGrid* New();
41  void PrintSelf(ostream& os, vtkIndent indent) override;
42 
46  int GetDataObjectType() VTK_FUTURE_CONST override { return VTK_UNIFORM_HYPER_TREE_GRID; }
47 
52  void CopyStructure(vtkDataObject*) override;
53 
54  void Initialize() override;
55 
57 
60  vtkSetVector3Macro(Origin, double);
61  vtkGetVector3Macro(Origin, double);
63 
65 
68  void SetGridScale(double, double, double);
69  void SetGridScale(double*);
70  vtkGetVector3Macro(GridScale, double);
72 
76  void SetGridScale(double);
77 
83  void GetGridBounds(double bounds[6]) override;
84 
86 
91  void SetXCoordinates(vtkDataArray* XCoordinates) override;
92  vtkDataArray* GetXCoordinates() override;
94 
96 
101  void SetYCoordinates(vtkDataArray* YCoordinates) override;
102  vtkDataArray* GetYCoordinates() override;
104 
106 
111  void SetZCoordinates(vtkDataArray* ZCoordinates) override;
112  vtkDataArray* GetZCoordinates() override;
114 
116 
119  void CopyCoordinates(const vtkHyperTreeGrid* output) override;
120  void SetFixedCoordinates(unsigned int axis, double value) override;
122 
126  void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double*, double*) override;
127 
131  void GetLevelZeroOriginFromIndex(vtkIdType, double*) override;
132 
136  void ShallowCopy(vtkDataObject*) override;
137 
141  void DeepCopy(vtkDataObject*) override;
142 
146  unsigned long GetActualMemorySizeBytes() override;
147 
152  vtkHyperTree* GetTree(vtkIdType, bool create = false) override;
153 
154 protected:
159 
163  ~vtkUniformHyperTreeGrid() override;
164 
168  double Origin[3];
169 
173  double GridScale[3];
174 
176 
183 
184  unsigned int FindDichotomic(double value, unsigned char dim, double tol) const
185  {
186  unsigned int maxIdx = this->GetDimensions()[dim] - 1;
187  if (value < (this->Origin[dim] - tol) ||
188  value > (this->Origin[dim] + tol + this->GridScale[dim] * maxIdx))
189  {
191  }
192 
193  long idx = std::round((value - this->Origin[dim]) / this->GridScale[dim]);
194  return std::min(std::max(idx, 0l), static_cast<long>(maxIdx));
195  }
196 
197  unsigned int FindDichotomicX(double value, double tolerance = 0.0) const override
198  {
199  return this->FindDichotomic(value, 0, tolerance);
200  }
201  unsigned int FindDichotomicY(double value, double tolerance = 0.0) const override
202  {
203  return this->FindDichotomic(value, 1, tolerance);
204  }
205  unsigned int FindDichotomicZ(double value, double tolerance = 0.0) const override
206  {
207  return this->FindDichotomic(value, 2, tolerance);
208  }
209 
213  std::shared_ptr<vtkHyperTreeGridScales> Scales;
214 
215 private:
217  void operator=(const vtkUniformHyperTreeGrid&) = delete;
218 };
219 
220 VTK_ABI_NAMESPACE_END
221 #endif
virtual vtkDataArray * GetXCoordinates()
Set/Get the grid coordinates in the x-direction.
virtual unsigned long GetActualMemorySizeBytes()
Return the actual size of the data in bytes.
void Initialize() override
Restore data object to initial state.
virtual void SetZCoordinates(vtkDataArray *)
Set/Get the grid coordinates in the z-direction.
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
int GetDataObjectType() VTK_FUTURE_CONST override
Return what type of dataset this is.
virtual void CopyCoordinates(const vtkHyperTreeGrid *output)
Utility methods to set coordinates.
virtual void SetXCoordinates(vtkDataArray *)
Set/Get the grid coordinates in the x-direction.
virtual void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double *, double *)
Convert the global index of a root to its Spatial coordinates origin and size.
virtual vtkDataArray * GetYCoordinates()
Set/Get the grid coordinates in the y-direction.
int vtkIdType
Definition: vtkType.h:363
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
std::shared_ptr< vtkHyperTreeGridScales > Scales
Storage of pre-computed per-level cell scales.
unsigned int FindDichotomicX(double value, double tolerance=0.0) const override
unsigned int FindDichotomic(double value, unsigned char dim, double tol) const
dynamic, self-adjusting array of double
unsigned int FindDichotomicY(double value, double tolerance=0.0) const override
virtual void SetYCoordinates(vtkDataArray *)
Set/Get the grid coordinates in the y-direction.
A specifalized type of vtkHyperTreeGrid for the case when root cells have uniform sizes in each direc...
virtual void SetFixedCoordinates(unsigned int axis, double value)
Utility methods to set coordinates.
static vtkHyperTreeGrid * New()
a simple class to control print indentation
Definition: vtkIndent.h:28
void ShallowCopy(vtkDataObject *) override
Create shallow copy of hyper tree grid.
virtual void GetGridBounds(double bounds[6])
Return a pointer to the grid bounding box in the form (xmin,xmax, ymin,ymax, zmin,zmax).
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
void DeepCopy(vtkDataObject *) override
Create deep copy of hyper tree grid.
const unsigned int * GetDimensions() const
Get dimensions of this rectilinear grid dataset.
bool ComputedYCoordinates
Keep track of whether coordinates have been explicitly computed.
bool ComputedZCoordinates
Keep track of whether coordinates have been explicitly computed.
bool ComputedXCoordinates
Keep track of whether coordinates have been explicitly computed.
virtual void CopyStructure(vtkDataObject *)
Copy the internal geometric and topological structure of a vtkHyperTreeGrid object.
virtual vtkDataArray * GetZCoordinates()
Set/Get the grid coordinates in the z-direction.
A data object structured as a tree.
Definition: vtkHyperTree.h:170
virtual vtkHyperTree * GetTree(vtkIdType index, bool create=false)
Return tree located at given index of hyper tree grid NB: This will construct a new HyperTree if grid...
Dynamic generation of scales for vtkHyperTree.
virtual void GetLevelZeroOriginFromIndex(vtkIdType, double *)
Convert the global index of a root to its Spatial coordinates origin and size.
unsigned int FindDichotomicZ(double value, double tolerance=0.0) const override
general representation of visualization data
Definition: vtkDataObject.h:55
#define max(a, b)