| 57 | } // end anon namespace |
| 58 | |
| 59 | VTK_ABI_NAMESPACE_BEGIN |
| 60 | //------------------------------------------------------------------------------ |
| 61 | // Interpolate array value from other array value given the |
| 62 | // indices and associated interpolation weights. |
| 63 | // This method assumes that the two arrays are of the same time. |
| 64 | void vtkDataArray::InterpolateTuple( |
| 65 | vtkIdType dstTupleIdx, vtkIdList* tupleIds, vtkAbstractArray* source, double* weights) |
| 66 | { |
| 67 | if (!vtkDataTypesCompare(this->GetDataType(), source->GetDataType())) |
| 68 | { |
| 69 | vtkErrorMacro("Cannot interpolate arrays of different type."); |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | vtkDataArray* da = vtkDataArray::FastDownCast(source); |
| 74 | if (!da) |
| 75 | { |
| 76 | vtkErrorMacro(<< "Source array is not a vtkDataArray."); |
| 77 | return; |
| 78 | } |
| 79 | |
| 80 | int numComps = this->GetNumberOfComponents(); |
| 81 | if (da->GetNumberOfComponents() != numComps) |
| 82 | { |
| 83 | vtkErrorMacro("Number of components do not match: Source: " |
| 84 | << source->GetNumberOfComponents() << " Dest: " << this->GetNumberOfComponents()); |
| 85 | return; |
| 86 | } |
| 87 | |
| 88 | vtkIdType numIds = tupleIds->GetNumberOfIds(); |
| 89 | vtkIdType* ids = tupleIds->GetPointer(0); |
| 90 | |
| 91 | bool fallback = da->GetDataType() == VTK_BIT || this->GetDataType() == VTK_BIT; |
| 92 | |
| 93 | if (!fallback) |
| 94 | { |
| 95 | InterpolateMultiTupleWorker worker(dstTupleIdx, ids, numIds, weights); |
| 96 | // Use fallback if dispatch fails. |
| 97 | fallback = !vtkArrayDispatch::Dispatch2SameValueType::Execute(da, this, worker); |
| 98 | } |
| 99 | |
| 100 | // Fallback to a separate implementation that checks vtkDataArray::GetDataType |
| 101 | // rather than relying on API types, since we'll need to round differently |
| 102 | // depending on type, and the API type for vtkDataArray is always double. |
| 103 | if (fallback) |
| 104 | { |
| 105 | bool doRound = !(this->GetDataType() == VTK_FLOAT || this->GetDataType() == VTK_DOUBLE); |
| 106 | double typeMin = this->GetDataTypeMin(); |
| 107 | double typeMax = this->GetDataTypeMax(); |
| 108 | |
| 109 | for (int c = 0; c < numComps; ++c) |
| 110 | { |
| 111 | double val = 0.; |
| 112 | for (vtkIdType j = 0; j < numIds; ++j) |
| 113 | { |
| 114 | val += weights[j] * da->GetComponent(ids[j], c); |
| 115 | } |
| 116 |
nothing calls this directly
no test coverage detected