VTK  9.3.20240425
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
32VTK_ABI_NAMESPACE_BEGIN
33class vtkDoubleArray;
35
36class VTKCOMMONDATAMODEL_EXPORT vtkUniformHyperTreeGrid : public vtkHyperTreeGrid
37{
38public:
41 void PrintSelf(ostream& os, vtkIndent indent) override;
42
47
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;
94
96
101 void SetYCoordinates(vtkDataArray* YCoordinates) override;
104
106
111 void SetZCoordinates(vtkDataArray* ZCoordinates) 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
154protected:
159
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 {
190 return std::numeric_limits<unsigned int>::max();
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 mutable std::shared_ptr<vtkHyperTreeGridScales> Scales;
214
215private:
217 void operator=(const vtkUniformHyperTreeGrid&) = delete;
218};
219
220VTK_ABI_NAMESPACE_END
221#endif
abstract superclass for arrays of numeric data
general representation of visualization data
dynamic, self-adjusting array of double
A specifalized type of vtkHyperTreeGrid for the case when root cells have uniform sizes in each direc...
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
const unsigned int * GetDimensions() const
Get dimensions of this rectilinear grid dataset.
A data object structured as a tree.
a simple class to control print indentation
Definition vtkIndent.h:108
A specifalized type of vtkHyperTreeGrid for the case when root cells have uniform sizes in each direc...
static vtkUniformHyperTreeGrid * New()
void Initialize() override
Restore data object to initial state.
bool ComputedXCoordinates
Keep track of whether coordinates have been explicitly computed.
vtkDataArray * GetYCoordinates() override
Set/Get the grid coordinates in the y-direction.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double *, double *) override
Convert the global index of a root to its Spatial coordinates origin and size.
void SetXCoordinates(vtkDataArray *XCoordinates) override
Set/Get the grid coordinates in the x-direction.
void CopyCoordinates(const vtkHyperTreeGrid *output) override
Augented services on Coordinates.
void SetGridScale(double, double, double)
Set/Get scale of root cells along each direction.
std::shared_ptr< vtkHyperTreeGridScales > Scales
Storage of pre-computed per-level cell scales.
void DeepCopy(vtkDataObject *) override
Create deep copy of hyper tree grid.
bool ComputedZCoordinates
Keep track of whether coordinates have been explicitly computed.
vtkUniformHyperTreeGrid()
Constructor.
bool ComputedYCoordinates
Keep track of whether coordinates have been explicitly computed.
vtkDataArray * GetXCoordinates() override
Set/Get the grid coordinates in the x-direction.
void SetGridScale(double *)
Set/Get scale of root cells along each direction.
void SetGridScale(double)
Set all scales at once when root cells are d-cubes.
unsigned long GetActualMemorySizeBytes() override
Return the actual size of the data bytes.
void GetGridBounds(double bounds[6]) override
Return a pointer to the grid bounding box in the form (xmin,xmax, ymin,ymax, zmin,...
unsigned int FindDichotomic(double value, unsigned char dim, double tol) const
void ShallowCopy(vtkDataObject *) override
Create shallow copy of hyper tree grid.
vtkHyperTree * GetTree(vtkIdType, bool create=false) override
Return tree located at given index of hyper tree grid NB: This will construct a new HyperTree if grid...
vtkDataArray * GetZCoordinates() override
Set/Get the grid coordinates in the z-direction.
void SetYCoordinates(vtkDataArray *YCoordinates) override
Set/Get the grid coordinates in the y-direction.
void SetZCoordinates(vtkDataArray *ZCoordinates) override
Set/Get the grid coordinates in the z-direction.
unsigned int FindDichotomicY(double value, double tolerance=0.0) const override
~vtkUniformHyperTreeGrid() override
Destructor.
void GetLevelZeroOriginFromIndex(vtkIdType, double *) override
Convert the global index of a root to its Spatial coordinates origin and size.
int GetDataObjectType() override
Return what type of dataset this is.
unsigned int FindDichotomicX(double value, double tolerance=0.0) const override
void SetFixedCoordinates(unsigned int axis, double value) override
Augented services on Coordinates.
unsigned int FindDichotomicZ(double value, double tolerance=0.0) const override
void CopyStructure(vtkDataObject *) override
Copy the internal geometric and topological structure of a vtkUniformHyperTreeGrid object.
#define VTK_UNIFORM_HYPER_TREE_GRID
Definition vtkType.h:104
int vtkIdType
Definition vtkType.h:315