------------------------------------------------------------------------------ Interpolate array value from other array value given the indices and associated interpolation weights. This method assumes that the two arrays are of the same time.
| 292 | // indices and associated interpolation weights. |
| 293 | // This method assumes that the two arrays are of the same time. |
| 294 | void vtkStringArray::InterpolateTuple( |
| 295 | vtkIdType i, vtkIdList* ptIndices, vtkAbstractArray* source, double* weights) |
| 296 | { |
| 297 | if (this->GetDataType() != source->GetDataType()) |
| 298 | { |
| 299 | vtkErrorMacro("Cannot CopyValue from array of type " << source->GetDataTypeAsString()); |
| 300 | return; |
| 301 | } |
| 302 | |
| 303 | if (ptIndices->GetNumberOfIds() == 0) |
| 304 | { |
| 305 | // nothing to do. |
| 306 | return; |
| 307 | } |
| 308 | |
| 309 | // We use nearest neighbour for interpolating strings. |
| 310 | // First determine which is the nearest neighbour using the weights- |
| 311 | // it's the index with maximum weight. |
| 312 | vtkIdType nearest = ptIndices->GetId(0); |
| 313 | double max_weight = weights[0]; |
| 314 | for (int k = 1; k < ptIndices->GetNumberOfIds(); k++) |
| 315 | { |
| 316 | if (weights[k] > max_weight) |
| 317 | { |
| 318 | nearest = ptIndices->GetId(k); |
| 319 | max_weight = weights[k]; |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | this->InsertTuple(i, nearest, source); |
| 324 | } |
| 325 | |
| 326 | //------------------------------------------------------------------------------ |
| 327 | // Interpolate value from the two values, p1 and p2, and an |