VTK: Common/DataModel/vtkHyperTreeGridScales.h Source File

| VTK 9.3.1

vtkHyperTreeGridScales.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
17 #ifndef vtkHyperTreeGridScales_h
18 #define vtkHyperTreeGridScales_h
19
20 #include "vtkABINamespace.h"
21
22 #include <cstring> // For memcpy
23 #include <vector> // For std::vector
24
25 VTK_ABI_NAMESPACE_BEGIN
26 class vtkHyperTreeGridScales
27 {
28 public:
33 vtkHyperTreeGridScales(double branchfactor, const double scale[3])
34 : BranchFactor(branchfactor)
35 , CurrentFailLevel(1)
36 , CellScales(scale, scale + 3)
37 {
38 }
39
40 ~vtkHyperTreeGridScales() = default;
41
45 double GetBranchFactor() const { return this->BranchFactor; }
46
50 double* GetScale(unsigned int level) const
51 {
52 this->Update(level);
53 return this->CellScales.data() + 3 * level;
54 }
55
59 double GetScaleX(unsigned int level) const
60 {
61 this->Update(level);
62 return this->CellScales[3 * level + 0];
63 }
64
68 double GetScaleY(unsigned int level) const
69 {
70 this->Update(level);
71 return this->CellScales[3 * level + 1];
72 }
73
77 double GetScaleZ(unsigned int level) const
78 {
79 this->Update(level);
80 return this->CellScales[3 * level + 2];
81 }
82
86 void GetScale(unsigned int level, double scale[3]) const
87 {
88 this->Update(level);
89 memcpy(scale, this->CellScales.data() + 3 * level, 3 * sizeof(double));
90 }
91
95 unsigned int GetCurrentFailLevel() const { return this->CurrentFailLevel; }
96
97 private:
98 vtkHyperTreeGridScales(const vtkHyperTreeGridScales&) = delete;
99 vtkHyperTreeGridScales& operator=(const vtkHyperTreeGridScales&) = delete;
100
106 void Update(unsigned int level) const
107 {
108 if (level < this->CurrentFailLevel)
109 {
110 return;
111 }
112 this->CurrentFailLevel = level + 1;
113 this->CellScales.resize(3 * this->CurrentFailLevel);
114 auto current = this->CellScales.begin() + 3 * (this->CurrentFailLevel - 1);
115 auto previous = current - 3;
116 auto end = this->CellScales.end();
117 for (; current != end; ++current, ++previous)
118 {
119 *current = *previous / this->BranchFactor;
120 }
121 }
122
126 const double BranchFactor;
127
131 mutable unsigned int CurrentFailLevel;
132 mutable std::vector<double> CellScales;
133 };
134
135 VTK_ABI_NAMESPACE_END
136 #endif
137 // VTK-HeaderTest-Exclude: vtkHyperTreeGridScales.h
vtkHyperTreeGridScales
A specifalized type of vtkHyperTreeGrid for the case when root cells have uniform sizes in each direc...
Definition: vtkHyperTreeGridScales.h:27
vtkHyperTreeGridScales::GetScaleX
double GetScaleX(unsigned int level) const
JB.
Definition: vtkHyperTreeGridScales.h:59
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:33
vtkHyperTreeGridScales::~vtkHyperTreeGridScales
~vtkHyperTreeGridScales()=default
vtkHyperTreeGridScales::GetBranchFactor
double GetBranchFactor() const
JB Retourne le scale des mailles du niveau demande.
Definition: vtkHyperTreeGridScales.h:45
vtkHyperTreeGridScales::GetScaleY
double GetScaleY(unsigned int level) const
JB.
Definition: vtkHyperTreeGridScales.h:68
vtkHyperTreeGridScales::GetScale
double * GetScale(unsigned int level) const
JB Retourne le scale des mailles du niveau demande.
Definition: vtkHyperTreeGridScales.h:50
vtkHyperTreeGridScales::GetCurrentFailLevel
unsigned int GetCurrentFailLevel() const
JB.
Definition: vtkHyperTreeGridScales.h:95
vtkHyperTreeGridScales::GetScale
void GetScale(unsigned int level, double scale[3]) const
JB Retourne le scale des mailles du niveau demande.
Definition: vtkHyperTreeGridScales.h:86
vtkHyperTreeGridScales::GetScaleZ
double GetScaleZ(unsigned int level) const
JB.
Definition: vtkHyperTreeGridScales.h:77
vtkX3D::level
@ level
Definition: vtkX3D.h:395
vtkX3D::previous
@ previous
Definition: vtkX3D.h:449
vtkX3D::scale
@ scale
Definition: vtkX3D.h:229