VTK  9.2.6
vtkHyperTreeGridScales.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkHyperTreeGridScales.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 =========================================================================*/
29 #ifndef vtkHyperTreeGridScales_h
30 #define vtkHyperTreeGridScales_h
31 
32 #include <cstring> // For memcpy
33 #include <vector> // For std::vector
34 
36 {
37 public:
42  vtkHyperTreeGridScales(double branchfactor, const double scale[3])
43  : BranchFactor(branchfactor)
44  , CurrentFailLevel(1)
45  , CellScales(scale, scale + 3)
46  {
47  }
48 
49  ~vtkHyperTreeGridScales() = default;
50 
54  double GetBranchFactor() const { return this->BranchFactor; }
55 
59  double* GetScale(unsigned int level) const
60  {
61  this->Update(level);
62  return this->CellScales.data() + 3 * level;
63  }
64 
68  double GetScaleX(unsigned int level) const
69  {
70  this->Update(level);
71  return this->CellScales[3 * level + 0];
72  }
73 
77  double GetScaleY(unsigned int level) const
78  {
79  this->Update(level);
80  return this->CellScales[3 * level + 1];
81  }
82 
86  double GetScaleZ(unsigned int level) const
87  {
88  this->Update(level);
89  return this->CellScales[3 * level + 2];
90  }
91 
95  void GetScale(unsigned int level, double scale[3]) const
96  {
97  this->Update(level);
98  memcpy(scale, this->CellScales.data() + 3 * level, 3 * sizeof(double));
99  }
100 
104  unsigned int GetCurrentFailLevel() const { return this->CurrentFailLevel; }
105 
106 private:
108  vtkHyperTreeGridScales& operator=(const vtkHyperTreeGridScales&) = delete;
109 
115  void Update(unsigned int level) const
116  {
117  if (level < this->CurrentFailLevel)
118  {
119  return;
120  }
121  this->CurrentFailLevel = level + 1;
122  this->CellScales.resize(3 * this->CurrentFailLevel);
123  auto current = this->CellScales.begin() + 3 * (this->CurrentFailLevel - 1);
124  auto previous = current - 3;
125  auto end = this->CellScales.end();
126  for (; current != end; ++current, ++previous)
127  {
128  *current = *previous / this->BranchFactor;
129  }
130  }
131 
135  const double BranchFactor;
136 
140  mutable unsigned int CurrentFailLevel;
141  mutable std::vector<double> CellScales;
142 };
143 
144 #endif
145 // VTK-HeaderTest-Exclude: vtkHyperTreeGridScales.h
double GetScaleY(unsigned int level) const
JB.
double GetScaleZ(unsigned int level) const
JB.
~vtkHyperTreeGridScales()=default
double GetBranchFactor() const
JB Retourne le scale des mailles du niveau demande.
double GetScaleX(unsigned int level) const
JB.
vtkHyperTreeGridScales(double branchfactor, const double scale[3])
JB Construit cette classe a partir du scale de la maille d'origine d'un HyperTree et du subdivision f...
double * GetScale(unsigned int level) const
JB Retourne le scale des mailles du niveau demande.
void GetScale(unsigned int level, double scale[3]) const
JB Retourne le scale des mailles du niveau demande.
A specifalized type of vtkHyperTreeGrid for the case when root cells have uniform sizes in each direc...
unsigned int GetCurrentFailLevel() const
JB.