VTK  9.3.0
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
25VTK_ABI_NAMESPACE_BEGIN
27{
28public:
33 vtkHyperTreeGridScales(double branchfactor, const double scale[3])
34 : BranchFactor(branchfactor)
35 , CurrentFailLevel(1)
36 , CellScales(scale, scale + 3)
37 {
38 }
39
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
97private:
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
135VTK_ABI_NAMESPACE_END
136#endif
137// 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:395
@ previous
Definition vtkX3D.h:449