VTK  9.7.20260709
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
18#ifndef vtkHyperTreeGridScales_h
19#define vtkHyperTreeGridScales_h
20
21#include "vtkABINamespace.h"
22
23#include <cstring> // For memcpy
24#include <vector> // For std::vector
25
26VTK_ABI_NAMESPACE_BEGIN
28{
29public:
33 vtkHyperTreeGridScales(double branchfactor, const double scale[3])
34 : BranchFactor(branchfactor)
35 , CurrentFailLevel(1)
36 , CellScales(scale, scale + 3)
37 {
38 }
39
41
42 double GetBranchFactor() const { return this->BranchFactor; }
43
44 double* ComputeScale(unsigned int level)
45 {
46 this->Update(level);
47 return this->CellScales.data() + 3 * level;
48 }
49
50 double ComputeScaleX(unsigned int level)
51 {
52 this->Update(level);
53 return this->CellScales[3 * level + 0];
54 }
55
56 double ComputeScaleY(unsigned int level)
57 {
58 this->Update(level);
59 return this->CellScales[3 * level + 1];
60 }
61
62 double ComputeScaleZ(unsigned int level)
63 {
64 this->Update(level);
65 return this->CellScales[3 * level + 2];
66 }
67
71 void ComputeScale(unsigned int level, double scale[3])
72 {
73 this->Update(level);
74 memcpy(scale, this->CellScales.data() + 3 * level, 3 * sizeof(double));
75 }
76
77 unsigned int GetCurrentFailLevel() const { return this->CurrentFailLevel; }
78
79private:
81 vtkHyperTreeGridScales& operator=(const vtkHyperTreeGridScales&) = delete;
82
86 void Update(unsigned int level)
87 {
88 if (level < this->CurrentFailLevel)
89 {
90 return;
91 }
92 this->CurrentFailLevel = level + 1;
93 this->CellScales.resize(3 * this->CurrentFailLevel);
94 auto current = this->CellScales.begin() + 3 * (this->CurrentFailLevel - 1);
95 auto previous = current - 3;
96 auto end = this->CellScales.end();
97 for (; current != end; ++current, ++previous)
98 {
99 *current = *previous / this->BranchFactor;
100 }
101 }
102
106 const double BranchFactor;
107
111 unsigned int CurrentFailLevel;
112 std::vector<double> CellScales;
113};
114
115VTK_ABI_NAMESPACE_END
116#endif
117// VTK-HeaderTest-Exclude: vtkHyperTreeGridScales.h
Dynamic generation of scales for vtkHyperTree.
double ComputeScaleZ(unsigned int level)
vtkHyperTreeGridScales(double branchfactor, const double scale[3])
Build this class from the original scale mesh and subdivision factor.
double ComputeScaleX(unsigned int level)
double * ComputeScale(unsigned int level)
~vtkHyperTreeGridScales()=default
double ComputeScaleY(unsigned int level)
unsigned int GetCurrentFailLevel() const
void ComputeScale(unsigned int level, double scale[3])
Return the mesh scale at the given level.
@ level
Definition vtkX3D.h:396
@ previous
Definition vtkX3D.h:450