VTK  9.3.0
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:
41  void PrintSelf(ostream& os, vtkIndent indent) override;
42 
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  double* GetBounds() VTK_SIZEHINT(6) override;
84 
86 
91  void SetXCoordinates(vtkDataArray* XCoordinates) override;
92  vtkDataArray* GetXCoordinates() override;
93  /* JB A faire pour les Get !
94  const vtkDataArray* GetXCoordinates() const override {
95  throw std::domain_error("Cannot use GetZCoordinates on UniformHyperTreeGrid");
96  }
97  */
99 
101 
106  void SetYCoordinates(vtkDataArray* YCoordinates) override;
107  vtkDataArray* GetYCoordinates() override;
108  /* JB A faire pour les Get !
109  const vtkDataArray* GetYCoordinates() const override {
110  throw std::domain_error("Cannot use GetZCoordinates on UniformHyperTreeGrid");
111  }
112  */
114 
116 
121  void SetZCoordinates(vtkDataArray* ZCoordinates) override;
122  vtkDataArray* GetZCoordinates() override;
123  /* JB A faire pour les Get !
124  const vtkDataArray* GetZCoordinates() const override {
125  throw std::domain_error("Cannot use GetZCoordinates on UniformHyperTreeGrid");
126  }
127  */
128  // JB A faire pour les autre Get !
130 
132 
135  void CopyCoordinates(const vtkHyperTreeGrid* output) override;
136  void SetFixedCoordinates(unsigned int axis, double value) override;
138 
142  void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double*, double*) override;
143 
147  void GetLevelZeroOriginFromIndex(vtkIdType, double*) override;
148 
152  void ShallowCopy(vtkDataObject*) override;
153 
157  void DeepCopy(vtkDataObject*) override;
158 
162  unsigned long GetActualMemorySizeBytes() override;
163 
168  vtkHyperTree* GetTree(vtkIdType, bool create = false) override;
169 
170 protected:
175 
180 
184  double Origin[3];
185 
189  double GridScale[3];
190 
192 
195  bool ComputedXCoordinates;
196  bool ComputedYCoordinates;
197  bool ComputedZCoordinates;
199 
200  unsigned int FindDichotomic(double value, unsigned char dim, double tol) const
201  {
202  unsigned int maxIdx = this->GetDimensions()[dim] - 1;
203  if (value < (this->Origin[dim] - tol) ||
204  value > (this->Origin[dim] + tol + this->GridScale[dim] * maxIdx))
205  {
207  }
208 
209  long idx = std::round((value - this->Origin[dim]) / this->GridScale[dim]);
210  return std::min(std::max(idx, 0l), static_cast<long>(maxIdx));
211  }
212 
213  unsigned int FindDichotomicX(double value, double tolerance = 0.0) const override
214  {
215  return this->FindDichotomic(value, 0, tolerance);
216  }
217  unsigned int FindDichotomicY(double value, double tolerance = 0.0) const override
218  {
219  return this->FindDichotomic(value, 1, tolerance);
220  }
221  unsigned int FindDichotomicZ(double value, double tolerance = 0.0) const override
222  {
223  return this->FindDichotomic(value, 2, tolerance);
224  }
225 
229  mutable std::shared_ptr<vtkHyperTreeGridScales> Scales;
230 
231 private:
233  void operator=(const vtkUniformHyperTreeGrid&) = delete;
234 };
235 
236 VTK_ABI_NAMESPACE_END
237 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:45
general representation of visualization data
Definition: vtkDataObject.h:55
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.
Definition: vtkHyperTree.h:169
a simple class to control print indentation
Definition: vtkIndent.h:29
A specifalized type of vtkHyperTreeGrid for the case when root cells have uniform sizes in each direc...
void Initialize() override
Restore data object to initial state.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetGridScale(double, double, double)
Set/Get scale of root cells along each direction.
std::shared_ptr< vtkHyperTreeGridScales > Scales
JB Storage of pre-computed per-level cell scales.
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 int FindDichotomicY(double value, double tolerance=0.0) const override
int GetDataObjectType() override
Return what type of dataset this is.
unsigned int FindDichotomicX(double value, double tolerance=0.0) const override
unsigned int FindDichotomicZ(double value, double tolerance=0.0) const override
double * GetBounds() override
Return a pointer to the geometry bounding box in the form (xmin,xmax, ymin,ymax, zmin,...
void CopyStructure(vtkDataObject *) override
Copy the internal geometric and topological structure of a vtkUniformHyperTreeGrid object.
static vtkUniformHyperTreeGrid * New()
@ value
Definition: vtkX3D.h:220
#define VTK_UNIFORM_HYPER_TREE_GRID
Definition: vtkType.h:104
int vtkIdType
Definition: vtkType.h:315
#define VTK_SIZEHINT(...)
#define max(a, b)