VTK  9.2.5
vtkUniformHyperTreeGrid.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkUniformHyperTreeGrid.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 =========================================================================*/
33 #ifndef vtkUniformHyperTreeGrid_h
34 #define vtkUniformHyperTreeGrid_h
35 
36 #include "limits.h" // UINT_MAX
37 
38 #include <cmath> // std::round
39 #include <memory> // std::shared_ptr
40 
41 #include "vtkCommonDataModelModule.h" // For export macro
42 #include "vtkHyperTreeGrid.h"
43 
44 class vtkDoubleArray;
46 
47 class VTKCOMMONDATAMODEL_EXPORT vtkUniformHyperTreeGrid : public vtkHyperTreeGrid
48 {
49 public:
52  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
58 
63  void CopyStructure(vtkDataObject*) override;
64 
65  void Initialize() override;
66 
68 
71  vtkSetVector3Macro(Origin, double);
72  vtkGetVector3Macro(Origin, double);
74 
76 
79  void SetGridScale(double, double, double);
80  void SetGridScale(double*);
81  vtkGetVector3Macro(GridScale, double);
83 
87  void SetGridScale(double);
88 
94  double* GetBounds() VTK_SIZEHINT(6) override;
95 
97 
102  void SetXCoordinates(vtkDataArray* XCoordinates) override;
103  vtkDataArray* GetXCoordinates() override;
104  /* JB A faire pour les Get !
105  const vtkDataArray* GetXCoordinates() const override {
106  throw std::domain_error("Cannot use GetZCoordinates on UniformHyperTreeGrid");
107  }
108  */
110 
112 
117  void SetYCoordinates(vtkDataArray* YCoordinates) override;
118  vtkDataArray* GetYCoordinates() override;
119  /* JB A faire pour les Get !
120  const vtkDataArray* GetYCoordinates() const override {
121  throw std::domain_error("Cannot use GetZCoordinates on UniformHyperTreeGrid");
122  }
123  */
125 
127 
132  void SetZCoordinates(vtkDataArray* ZCoordinates) override;
133  vtkDataArray* GetZCoordinates() override;
134  /* JB A faire pour les Get !
135  const vtkDataArray* GetZCoordinates() const override {
136  throw std::domain_error("Cannot use GetZCoordinates on UniformHyperTreeGrid");
137  }
138  */
139  // JB A faire pour les autre Get !
141 
143 
146  void CopyCoordinates(const vtkHyperTreeGrid* output) override;
147  void SetFixedCoordinates(unsigned int axis, double value) override;
149 
153  void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double*, double*) override;
154 
158  void GetLevelZeroOriginFromIndex(vtkIdType, double*) override;
159 
163  void ShallowCopy(vtkDataObject*) override;
164 
168  void DeepCopy(vtkDataObject*) override;
169 
173  unsigned long GetActualMemorySizeBytes() override;
174 
179  vtkHyperTree* GetTree(vtkIdType, bool create = false) override;
180 
181 protected:
186 
191 
195  double Origin[3];
196 
200  double GridScale[3];
201 
203 
206  bool ComputedXCoordinates;
207  bool ComputedYCoordinates;
208  bool ComputedZCoordinates;
210 
211  unsigned int FindDichotomicX(double value) const override
212  {
213  if (value < this->Origin[0] ||
214  value > this->Origin[0] + this->GridScale[0] * (this->GetDimensions()[0] - 1))
215  {
216  return UINT_MAX;
217  }
218  return std::round((value - this->Origin[0]) / this->GridScale[0]);
219  }
220  unsigned int FindDichotomicY(double value) const override
221  {
222  if (value < this->Origin[1] ||
223  value > this->Origin[1] + this->GridScale[1] * (this->GetDimensions()[1] - 1))
224  {
225  return UINT_MAX;
226  }
227  return std::round((value - this->Origin[1]) / this->GridScale[1]);
228  }
229  unsigned int FindDichotomicZ(double value) const override
230  {
231  if (value < this->Origin[2] ||
232  value > this->Origin[2] + this->GridScale[2] * (this->GetDimensions()[2] - 1))
233  {
234  return UINT_MAX;
235  }
236  return std::round((value - this->Origin[2]) / this->GridScale[2]);
237  }
238 
242  mutable std::shared_ptr<vtkHyperTreeGridScales> Scales;
243 
244 private:
246  void operator=(const vtkUniformHyperTreeGrid&) = delete;
247 };
248 
249 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:165
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.
Definition: vtkHyperTree.h:180
a simple class to control print indentation
Definition: vtkIndent.h:119
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) const override
unsigned int FindDichotomicZ(double value) const override
int GetDataObjectType() override
Return what type of dataset this is.
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:226
#define VTK_UNIFORM_HYPER_TREE_GRID
Definition: vtkType.h:116
int vtkIdType
Definition: vtkType.h:332
#define VTK_SIZEHINT(...)