VTK  9.5.20250709
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
18#ifndef vtkHyperTreeGridScales_h
19#define vtkHyperTreeGridScales_h
20
21#include "vtkABINamespace.h"
22#include "vtkDeprecation.h" // VTK_DEPRECATED_IN_9_6_0
23
24#include <cstring> // For memcpy
25#include <vector> // For std::vector
26
27VTK_ABI_NAMESPACE_BEGIN
29{
30public:
34 vtkHyperTreeGridScales(double branchfactor, const double scale[3])
35 : BranchFactor(branchfactor)
36 , CurrentFailLevel(1)
37 , CellScales(scale, scale + 3)
38 {
39 }
40
42
43 double GetBranchFactor() const { return this->BranchFactor; }
44
45 VTK_DEPRECATED_IN_9_6_0("This function is deprecated, Use ComputeScale instead")
46 double* GetScale(unsigned int level) { return ComputeScale(level); };
47
48 double* ComputeScale(unsigned int level)
49 {
50 this->Update(level);
51 return this->CellScales.data() + 3 * level;
52 }
53
54 VTK_DEPRECATED_IN_9_6_0("This function is deprecated, Use ComputeScaleX instead")
55 double GetScaleX(unsigned int level) { return ComputeScaleX(level); };
56
57 double ComputeScaleX(unsigned int level)
58 {
59 this->Update(level);
60 return this->CellScales[3 * level + 0];
61 }
62
63 VTK_DEPRECATED_IN_9_6_0("This function is deprecated, Use ComputeScaleY instead")
64 double GetScaleY(unsigned int level) { return ComputeScaleY(level); };
65
66 double ComputeScaleY(unsigned int level)
67 {
68 this->Update(level);
69 return this->CellScales[3 * level + 1];
70 }
71
72 VTK_DEPRECATED_IN_9_6_0("This function is deprecated, Use ComputeScaleZ instead")
73 double GetScaleZ(unsigned int level) { return ComputeScaleZ(level); };
74
75 double ComputeScaleZ(unsigned int level)
76 {
77 this->Update(level);
78 return this->CellScales[3 * level + 2];
79 }
80
81 VTK_DEPRECATED_IN_9_6_0("This function is deprecated, Use ComputeScale instead")
82 void GetScale(unsigned int level, double scale[3]) { ComputeScale(level, scale); };
83
87 void ComputeScale(unsigned int level, double scale[3])
88 {
89 this->Update(level);
90 memcpy(scale, this->CellScales.data() + 3 * level, 3 * sizeof(double));
91 }
92
93 unsigned int GetCurrentFailLevel() const { return this->CurrentFailLevel; }
94
95private:
97 vtkHyperTreeGridScales& operator=(const vtkHyperTreeGridScales&) = delete;
98
102 void Update(unsigned int level)
103 {
104 if (level < this->CurrentFailLevel)
105 {
106 return;
107 }
108 this->CurrentFailLevel = level + 1;
109 this->CellScales.resize(3 * this->CurrentFailLevel);
110 auto current = this->CellScales.begin() + 3 * (this->CurrentFailLevel - 1);
111 auto previous = current - 3;
112 auto end = this->CellScales.end();
113 for (; current != end; ++current, ++previous)
114 {
115 *current = *previous / this->BranchFactor;
116 }
117 }
118
122 const double BranchFactor;
123
127 unsigned int CurrentFailLevel;
128 std::vector<double> CellScales;
129};
130
131VTK_ABI_NAMESPACE_END
132#endif
133// 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)
double GetScaleZ(unsigned int level)
~vtkHyperTreeGridScales()=default
double ComputeScaleY(unsigned int level)
double * GetScale(unsigned int level)
double GetScaleX(unsigned int level)
unsigned int GetCurrentFailLevel() const
void ComputeScale(unsigned int level, double scale[3])
Return the mesh scale at the given level.
double GetScaleY(unsigned int level)
@ level
Definition vtkX3D.h:395
@ previous
Definition vtkX3D.h:449
#define VTK_DEPRECATED_IN_9_6_0(reason)