FIXME this could be greatly optimized
| 172 | |
| 173 | // FIXME this could be greatly optimized |
| 174 | void vtkBezierInterpolation::DeCasteljauSimplex( |
| 175 | int dim, int deg, const double pcoords[3], double* weights) |
| 176 | { |
| 177 | const int basis_func_n = NumberOfSimplexFunctions(dim, deg); |
| 178 | |
| 179 | const std::array<double, 4> linear_basis = (dim == 2) |
| 180 | ? std::array<double, 4>{ 1 - pcoords[0] - pcoords[1], pcoords[0], pcoords[1], 0 } |
| 181 | : std::array<double, 4>{ 1 - pcoords[0] - pcoords[1] - pcoords[2], pcoords[0], pcoords[1], |
| 182 | pcoords[2] }; |
| 183 | constexpr int lin_degree = 1; |
| 184 | const int sub_degree_length_max = NumberOfSimplexFunctions(dim, deg - 1); |
| 185 | const int shape_func_length = NumberOfSimplexFunctions(dim, lin_degree); |
| 186 | |
| 187 | std::vector<double> coeffs(basis_func_n); |
| 188 | std::vector<double> sub_coeffs(sub_degree_length_max); |
| 189 | std::vector<double> shape_funcs(shape_func_length); |
| 190 | |
| 191 | for (int bi = 0; bi < basis_func_n; ++bi) |
| 192 | { |
| 193 | std::fill(coeffs.begin(), coeffs.end(), 0.0); |
| 194 | coeffs[bi] = 1.0; |
| 195 | |
| 196 | for (int d = deg; d > 0; --d) |
| 197 | { |
| 198 | const int sub_degree = d - 1; |
| 199 | const int sub_degree_length = NumberOfSimplexFunctions(dim, sub_degree); |
| 200 | iterateSimplex(dim, sub_degree, |
| 201 | [&](vtkVector3i sub_degree_coord, int sub_index) |
| 202 | { |
| 203 | iterateSimplex(dim, lin_degree, |
| 204 | [&](vtkVector3i lin_degree_coord, int lin_index) |
| 205 | { |
| 206 | const vtkVector3i one_higher_coord = { sub_degree_coord[0] + lin_degree_coord[0], |
| 207 | sub_degree_coord[1] + lin_degree_coord[1], |
| 208 | sub_degree_coord[2] + lin_degree_coord[2] }; |
| 209 | const int idx = FlattenSimplex(dim, sub_degree + 1, one_higher_coord); |
| 210 | shape_funcs[lin_index] = coeffs[idx] * linear_basis[lin_index]; |
| 211 | }); |
| 212 | sub_coeffs[sub_index] = std::accumulate(shape_funcs.begin(), shape_funcs.end(), 0.); |
| 213 | }); |
| 214 | for (int i = 0; i < sub_degree_length; ++i) |
| 215 | { |
| 216 | coeffs[i] = sub_coeffs[i]; |
| 217 | } |
| 218 | } |
| 219 | weights[bi] = coeffs[0]; |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | void vtkBezierInterpolation::DeCasteljauSimplexDeriv( |
| 224 | int dim, int deg, const double pcoords[3], double* weights) |
nothing calls this directly
no test coverage detected