VTK  9.1.0
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{
36public:
41 vtkHyperTreeGridScales(double branchfactor, const double scale[3])
42 : BranchFactor(branchfactor)
43 , CurrentFailLevel(1)
44 , CellScales(scale, scale + 3)
45 {
46 }
47
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
105private:
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
A specifalized type of vtkHyperTreeGrid for the case when root cells have uniform sizes in each direc...
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...
~vtkHyperTreeGridScales()=default
double GetBranchFactor() const
JB Retourne le scale des mailles du niveau demande.
double GetScaleY(unsigned int level) const
JB.
double * GetScale(unsigned int level) const
JB Retourne le scale des mailles du niveau demande.
unsigned int GetCurrentFailLevel() const
JB.
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.
@ level
Definition: vtkX3D.h:401
@ previous
Definition: vtkX3D.h:455
@ scale
Definition: vtkX3D.h:235