VTK  9.0.20200918
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:
107  vtkHyperTreeGridScales& operator=(const vtkHyperTreeGridScales&) = delete;
108 
114  void Update(unsigned int level) const
115  {
116  if (level < this->CurrentFailLevel)
117  {
118  return;
119  }
120  this->CurrentFailLevel = level + 1;
121  this->CellScales.resize(3 * this->CurrentFailLevel);
122  auto current = this->CellScales.begin() + 3 * (this->CurrentFailLevel - 1);
123  auto previous = current - 3;
124  auto end = this->CellScales.end();
125  for (; current != end; ++current, ++previous)
126  {
127  *current = *previous / this->BranchFactor;
128  }
129  }
130 
134  const double BranchFactor;
135 
139  mutable unsigned int CurrentFailLevel;
140  mutable std::vector<double> CellScales;
141 };
142 
143 #endif
144 // VTK-HeaderTest-Exclude: vtkHyperTreeGridScales.h
vtkX3D::scale
Definition: vtkX3D.h:235
vtkHyperTreeGridScales::GetCurrentFailLevel
unsigned int GetCurrentFailLevel() const
JB.
Definition: vtkHyperTreeGridScales.h:103
vtkHyperTreeGridScales::GetBranchFactor
double GetBranchFactor() const
JB Retourne le scale des mailles du niveau demande.
Definition: vtkHyperTreeGridScales.h:53
vtkHyperTreeGridScales
A specifalized type of vtkHyperTreeGrid for the case when root cells have uniform sizes in each direc...
Definition: vtkHyperTreeGridScales.h:34
vtkX3D::level
Definition: vtkX3D.h:401
vtkHyperTreeGridScales::GetScaleX
double GetScaleX(unsigned int level) const
JB.
Definition: vtkHyperTreeGridScales.h:67
vtkHyperTreeGridScales::vtkHyperTreeGridScales
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...
Definition: vtkHyperTreeGridScales.h:41
vtkHyperTreeGridScales::GetScale
void GetScale(unsigned int level, double scale[3]) const
JB Retourne le scale des mailles du niveau demande.
Definition: vtkHyperTreeGridScales.h:94
vtkHyperTreeGridScales::~vtkHyperTreeGridScales
~vtkHyperTreeGridScales()=default
vtkHyperTreeGridScales::GetScaleZ
double GetScaleZ(unsigned int level) const
JB.
Definition: vtkHyperTreeGridScales.h:85
vtkX3D::previous
Definition: vtkX3D.h:455
vtkHyperTreeGridScales::GetScaleY
double GetScaleY(unsigned int level) const
JB.
Definition: vtkHyperTreeGridScales.h:76
vtkHyperTreeGridScales::GetScale
double * GetScale(unsigned int level) const
JB Retourne le scale des mailles du niveau demande.
Definition: vtkHyperTreeGridScales.h:58