VTK  9.1.0
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 =========================================================================*/
30 #ifndef vtkUniformHyperTreeGrid_h
31 #define vtkUniformHyperTreeGrid_h
32 
33 #include "limits.h" // UINT_MAX
34 
35 #include <cmath> // std::round
36 #include <memory> // std::shared_ptr
37 
38 #include "vtkCommonDataModelModule.h" // For export macro
39 #include "vtkHyperTreeGrid.h"
40 
41 class vtkDoubleArray;
43 
44 class VTKCOMMONDATAMODEL_EXPORT vtkUniformHyperTreeGrid : public vtkHyperTreeGrid
45 {
46 public:
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
55 
60  void CopyStructure(vtkDataObject*) override;
61 
62  void Initialize() override;
63 
65 
68  vtkSetVector3Macro(Origin, double);
69  vtkGetVector3Macro(Origin, double);
71 
73 
76  void SetGridScale(double, double, double);
77  void SetGridScale(double*);
78  vtkGetVector3Macro(GridScale, double);
80 
84  void SetGridScale(double);
85 
91  double* GetBounds() VTK_SIZEHINT(6) override;
92 
94 
99  void SetXCoordinates(vtkDataArray* XCoordinates) override;
100  vtkDataArray* GetXCoordinates() override;
101  /* JB A faire pour les Get !
102  const vtkDataArray* GetXCoordinates() const override {
103  throw std::domain_error("Cannot use GetZCoordinates on UniformHyperTreeGrid");
104  }
105  */
107 
109 
114  void SetYCoordinates(vtkDataArray* YCoordinates) override;
115  vtkDataArray* GetYCoordinates() override;
116  /* JB A faire pour les Get !
117  const vtkDataArray* GetYCoordinates() const override {
118  throw std::domain_error("Cannot use GetZCoordinates on UniformHyperTreeGrid");
119  }
120  */
122 
124 
129  void SetZCoordinates(vtkDataArray* ZCoordinates) override;
130  vtkDataArray* GetZCoordinates() override;
131  /* JB A faire pour les Get !
132  const vtkDataArray* GetZCoordinates() const override {
133  throw std::domain_error("Cannot use GetZCoordinates on UniformHyperTreeGrid");
134  }
135  */
136  // JB A faire pour les autre Get !
138 
140 
143  void CopyCoordinates(const vtkHyperTreeGrid* output) override;
144  void SetFixedCoordinates(unsigned int axis, double value) override;
146 
150  void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double*, double*) override;
151 
155  void GetLevelZeroOriginFromIndex(vtkIdType, double*) override;
156 
160  void ShallowCopy(vtkDataObject*) override;
161 
165  void DeepCopy(vtkDataObject*) override;
166 
170  unsigned long GetActualMemorySizeBytes() override;
171 
176  vtkHyperTree* GetTree(vtkIdType, bool create = false) override;
177 
178 protected:
183 
188 
192  double Origin[3];
193 
197  double GridScale[3];
198 
200 
203  bool ComputedXCoordinates;
204  bool ComputedYCoordinates;
205  bool ComputedZCoordinates;
207 
208  unsigned int FindDichotomicX(double value) const override
209  {
210  if (value < this->Origin[0] ||
211  value > this->Origin[0] + this->GridScale[0] * (this->GetDimensions()[0] - 1))
212  {
213  return UINT_MAX;
214  }
215  return std::round((value - this->Origin[0]) / this->GridScale[0]);
216  }
217  unsigned int FindDichotomicY(double value) const override
218  {
219  if (value < this->Origin[1] ||
220  value > this->Origin[1] + this->GridScale[1] * (this->GetDimensions()[1] - 1))
221  {
222  return UINT_MAX;
223  }
224  return std::round((value - this->Origin[1]) / this->GridScale[1]);
225  }
226  unsigned int FindDichotomicZ(double value) const override
227  {
228  if (value < this->Origin[2] ||
229  value > this->Origin[2] + this->GridScale[2] * (this->GetDimensions()[2] - 1))
230  {
231  return UINT_MAX;
232  }
233  return std::round((value - this->Origin[2]) / this->GridScale[2]);
234  }
235 
239  mutable std::shared_ptr<vtkHyperTreeGridScales> Scales;
240 
241 private:
243  void operator=(const vtkUniformHyperTreeGrid&) = delete;
244 };
245 
246 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
general representation of visualization data
Definition: vtkDataObject.h:60
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:177
a simple class to control print indentation
Definition: vtkIndent.h:34
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(...)