MCPcopy Create free account
hub / github.com/Kitware/VTK / ToChild

Method ToChild

Common/DataModel/vtkHyperTreeGridGeometryUnlimitedLevelEntry.cxx:141–238  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

139
140//------------------------------------------------------------------------------
141void vtkHyperTreeGridGeometryUnlimitedLevelEntry::ToChild(
142 const vtkHyperTreeGrid* grid, unsigned char ichild)
143{
144 assert("pre: not_tree" && this->Tree);
145 assert(
146 "pre: depth_limiter" && this->Level <= const_cast<vtkHyperTreeGrid*>(grid)->GetDepthLimiter());
147 assert("pre: is_masked" && !this->IsMasked(grid));
148
149 const double* sizeChild = this->Tree->GetScales()->ComputeScale(this->Level + 1);
150
151 size_t indexMax = 0;
152 this->Tree->GetElderChildIndexArray(indexMax);
153 if (this->Index >= 0 && this->Index < static_cast<vtkIdType>(indexMax))
154 {
155 const vtkIdType elder = this->Tree->GetElderChildIndex(this->Index);
156 if (elder != static_cast<vtkIdType>(std::numeric_limits<unsigned int>::max()))
157 {
158 this->Index = elder + ichild;
159 this->LastRealIndex = this->Index;
160 this->LastRealLevel = this->Level + 1;
161 }
162 else
163 {
164 // first virtual cell
165 this->Index = vtkHyperTreeGrid::InvalidIndex;
166 }
167 }
168 else
169 {
170 // cell already virtual
171 this->Index = vtkHyperTreeGrid::InvalidIndex;
172 }
173
174 // Divide cell size and translate origin per template parameter
175 switch (this->Tree->GetNumberOfChildren())
176 {
177 case 2: // dimension = 1, branch factor = 2
178 {
179 unsigned int axis = grid->GetOrientation();
180 this->Origin[axis] += (ichild & 1) * sizeChild[axis];
181 break;
182 }
183 case 3: // dimension = 1, branch factor = 3
184 {
185 unsigned int axis = grid->GetOrientation();
186 this->Origin[axis] += (ichild % 3) * sizeChild[axis];
187 break;
188 }
189 case 4: // dimension = 2, branch factor = 2
190 {
191 unsigned int axis1 = 0;
192 unsigned int axis2 = 1;
193 switch (grid->GetOrientation())
194 {
195 case 0:
196 axis1 = 1;
197 [[fallthrough]];
198 case 1:

Callers

nothing calls this directly

Calls 8

IsMaskedMethod · 0.95
GetScalesMethod · 0.80
GetElderChildIndexMethod · 0.80
assertFunction · 0.50
maxFunction · 0.50
GetNumberOfChildrenMethod · 0.45
GetOrientationMethod · 0.45

Tested by

no test coverage detected