VTK  9.2.6
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 <algorithm> // std::min/std::max
39 #include <cmath> // std::round
40 #include <memory> // std::shared_ptr
41 
42 #include "vtkCommonDataModelModule.h" // For export macro
43 #include "vtkHyperTreeGrid.h"
44 
45 class vtkDoubleArray;
47 
48 class VTKCOMMONDATAMODEL_EXPORT vtkUniformHyperTreeGrid : public vtkHyperTreeGrid
49 {
50 public:
51  static vtkUniformHyperTreeGrid* New();
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
59 
64  void CopyStructure(vtkDataObject*) override;
65 
66  void Initialize() override;
67 
69 
72  vtkSetVector3Macro(Origin, double);
73  vtkGetVector3Macro(Origin, double);
75 
77 
80  void SetGridScale(double, double, double);
81  void SetGridScale(double*);
82  vtkGetVector3Macro(GridScale, double);
84 
88  void SetGridScale(double);
89 
95  double* GetBounds() VTK_SIZEHINT(6) override;
96 
98 
103  void SetXCoordinates(vtkDataArray* XCoordinates) override;
104  vtkDataArray* GetXCoordinates() override;
105  /* JB A faire pour les Get !
106  const vtkDataArray* GetXCoordinates() const override {
107  throw std::domain_error("Cannot use GetZCoordinates on UniformHyperTreeGrid");
108  }
109  */
111 
113 
118  void SetYCoordinates(vtkDataArray* YCoordinates) override;
119  vtkDataArray* GetYCoordinates() override;
120  /* JB A faire pour les Get !
121  const vtkDataArray* GetYCoordinates() const override {
122  throw std::domain_error("Cannot use GetZCoordinates on UniformHyperTreeGrid");
123  }
124  */
126 
128 
133  void SetZCoordinates(vtkDataArray* ZCoordinates) override;
134  vtkDataArray* GetZCoordinates() override;
135  /* JB A faire pour les Get !
136  const vtkDataArray* GetZCoordinates() const override {
137  throw std::domain_error("Cannot use GetZCoordinates on UniformHyperTreeGrid");
138  }
139  */
140  // JB A faire pour les autre Get !
142 
144 
147  void CopyCoordinates(const vtkHyperTreeGrid* output) override;
148  void SetFixedCoordinates(unsigned int axis, double value) override;
150 
154  void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double*, double*) override;
155 
159  void GetLevelZeroOriginFromIndex(vtkIdType, double*) override;
160 
164  void ShallowCopy(vtkDataObject*) override;
165 
169  void DeepCopy(vtkDataObject*) override;
170 
174  unsigned long GetActualMemorySizeBytes() override;
175 
180  vtkHyperTree* GetTree(vtkIdType, bool create = false) override;
181 
182 protected:
187 
191  ~vtkUniformHyperTreeGrid() override;
192 
196  double Origin[3];
197 
201  double GridScale[3];
202 
204 
207  bool ComputedXCoordinates;
208  bool ComputedYCoordinates;
209  bool ComputedZCoordinates;
211 
212  unsigned int FindDichotomicX(double value) const override
213  {
214  if (value < this->Origin[0] ||
215  value > this->Origin[0] + this->GridScale[0] * (this->GetDimensions()[0] - 1))
216  {
217  return UINT_MAX;
218  }
219  return std::round((value - this->Origin[0]) / this->GridScale[0]);
220  }
221  unsigned int FindDichotomicY(double value) const override
222  {
223  if (value < this->Origin[1] ||
224  value > this->Origin[1] + this->GridScale[1] * (this->GetDimensions()[1] - 1))
225  {
226  return UINT_MAX;
227  }
228  return std::round((value - this->Origin[1]) / this->GridScale[1]);
229  }
230  unsigned int FindDichotomicZ(double value) const override
231  {
232  if (value < this->Origin[2] ||
233  value > this->Origin[2] + this->GridScale[2] * (this->GetDimensions()[2] - 1))
234  {
235  return UINT_MAX;
236  }
237  return std::round((value - this->Origin[2]) / this->GridScale[2]);
238  }
239 
243  mutable std::shared_ptr<vtkHyperTreeGridScales> Scales;
244 
245 private:
247  void operator=(const vtkUniformHyperTreeGrid&) = delete;
248 };
249 
250 #endif
void Initialize() override
Restore data object to initial state.
virtual double * GetBounds()
Return a pointer to the geometry bounding box in the form (xmin,xmax, ymin,ymax, zmin,zmax).
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
unsigned int FindDichotomicY(double value) const override
int vtkIdType
Definition: vtkType.h:332
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
std::shared_ptr< vtkHyperTreeGridScales > Scales
JB Storage of pre-computed per-level cell scales.
dynamic, self-adjusting array of double
A specifalized type of vtkHyperTreeGrid for the case when root cells have uniform sizes in each direc...
static vtkHyperTreeGrid * New()
a simple class to control print indentation
Definition: vtkIndent.h:39
#define VTK_UNIFORM_HYPER_TREE_GRID
Definition: vtkType.h:116
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
int GetDataObjectType() override
Return what type of dataset this is.
const unsigned int * GetDimensions() const
Get dimensions of this rectilinear grid dataset.
#define VTK_SIZEHINT(...)
virtual void CopyStructure(vtkDataObject *)
Copy the internal geometric and topological structure of a vtkHyperTreeGrid object.
A data object structured as a tree.
Definition: vtkHyperTree.h:179
A specifalized type of vtkHyperTreeGrid for the case when root cells have uniform sizes in each direc...
general representation of visualization data
Definition: vtkDataObject.h:65
unsigned int FindDichotomicZ(double value) const override