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

Method ToChild

Common/DataModel/vtkHyperTreeGridGeometryEntry.cxx:131–205  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

129
130//------------------------------------------------------------------------------
131void vtkHyperTreeGridGeometryEntry::ToChild(const vtkHyperTreeGrid* grid, const vtkHyperTree* tree,
132 unsigned int level, const double* sizeChild, unsigned char ichild)
133{
134 (void)level;
135 assert("pre: not_tree" && tree);
136 assert("pre: not_leaf" && !this->IsLeaf(grid, tree, level));
137 assert("pre: not_valid_child" && ichild < tree->GetNumberOfChildren());
138 assert("pre: depth_limiter" && level <= const_cast<vtkHyperTreeGrid*>(grid)->GetDepthLimiter());
139 assert("pre: is_masked" && !IsMasked(grid, tree));
140
141 this->Index = tree->GetElderChildIndex(this->Index) + ichild;
142
143 // Divide cell size and translate origin per template parameter
144 switch (tree->GetNumberOfChildren())
145 {
146 case 2: // dimension = 1, branch factor = 2
147 {
148 unsigned int axis = grid->GetOrientation();
149 this->Origin[axis] += (ichild & 1) * sizeChild[axis];
150 break;
151 }
152 case 3: // dimension = 1, branch factor = 3
153 {
154 unsigned int axis = grid->GetOrientation();
155 this->Origin[axis] += (ichild % 3) * sizeChild[axis];
156 break;
157 }
158 case 4: // dimension = 2, branch factor = 2
159 {
160 unsigned int axis1 = 0;
161 unsigned int axis2 = 1;
162 switch (grid->GetOrientation())
163 {
164 case 0:
165 axis1 = 1;
166 [[fallthrough]];
167 case 1:
168 axis2 = 2;
169 }
170 this->Origin[axis1] += (ichild & 1) * sizeChild[axis1];
171 this->Origin[axis2] += ((ichild & 2) >> 1) * sizeChild[axis2];
172 break;
173 }
174 case 9: // dimension = 2, branch factor = 3
175 {
176 unsigned int axis1 = 0;
177 unsigned int axis2 = 1;
178 switch (grid->GetOrientation())
179 {
180 case 0:
181 axis1 = 1;
182 [[fallthrough]];
183 case 1:
184 axis2 = 2;
185 }
186 this->Origin[axis1] += (ichild % 3) * sizeChild[axis1];
187 this->Origin[axis2] += ((ichild % 9) / 3) * sizeChild[axis2];
188 break;

Callers

nothing calls this directly

Calls 5

IsLeafMethod · 0.95
GetElderChildIndexMethod · 0.80
assertFunction · 0.50
GetNumberOfChildrenMethod · 0.45
GetOrientationMethod · 0.45

Tested by

no test coverage detected