VTK  9.0.1
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 <vector> // For std::vector
33 
35 {
36 public:
41  vtkHyperTreeGridScales(double branchfactor, const double scale[3])
42  : BranchFactor(branchfactor)
43  , CurrentFailLevel(1)
44  , CellScales(scale, scale + 3)
45  {
46  }
47 
48  ~vtkHyperTreeGridScales() = default;
49 
53  double GetBranchFactor() const { return this->BranchFactor; }
54 
58  double* GetScale(unsigned int level) const
59  {
60  this->Update(level);
61  return this->CellScales.data() + 3 * level;
62  }
63 
67  double GetScaleX(unsigned int level) const
68  {
69  this->Update(level);
70  return this->CellScales[3 * level + 0];
71  }
72 
76  double GetScaleY(unsigned int level) const
77  {
78  this->Update(level);
79  return this->CellScales[3 * level + 1];
80  }
81 
85  double GetScaleZ(unsigned int level) const
86  {
87  this->Update(level);
88  return this->CellScales[3 * level + 2];
89  }
90 
94  void GetScale(unsigned int level, double scale[3]) const
95  {
96  this->Update(level);
97  memcpy(scale, this->CellScales.data() + 3 * level, 3 * sizeof(double));
98  }
99 
103  unsigned int GetCurrentFailLevel() const { return this->CurrentFailLevel; }
104 
105 private:
111  void Update(unsigned int level) const
112  {
113  if (level < this->CurrentFailLevel)
114  {
115  return;
116  }
117  this->CurrentFailLevel = level + 1;
118  this->CellScales.resize(3 * this->CurrentFailLevel);
119  auto current = this->CellScales.begin() + 3 * (this->CurrentFailLevel - 1);
120  auto previous = current - 3;
121  auto end = this->CellScales.end();
122  for (; current != end; ++current, ++previous)
123  {
124  *current = *previous / this->BranchFactor;
125  }
126  }
127 
131  const double BranchFactor;
132 
136  mutable unsigned int CurrentFailLevel;
137  mutable std::vector<double> CellScales;
138 };
139 
140 #endif
141 // VTK-HeaderTest-Exclude: vtkHyperTreeGridScales.h
unsigned int GetCurrentFailLevel() const
JB.
double GetScaleX(unsigned int level) const
JB.
~vtkHyperTreeGridScales()=default
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 GetBranchFactor() 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.
double GetScaleZ(unsigned int level) const
JB.
A specifalized type of vtkHyperTreeGrid for the case when root cells have uniform sizes in each direc...
double * GetScale(unsigned int level) const
JB Retourne le scale des mailles du niveau demande.
double GetScaleY(unsigned int level) const
JB.