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

Method InterpolateTuple

Common/Core/vtkDataArray_InterpolateTuple_weights.cxx:59–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57} // end anon namespace
58
59VTK_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.
64void 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

Callers

nothing calls this directly

Calls 13

GetDataTypeMinMethod · 0.95
GetDataTypeMaxMethod · 0.95
InsertComponentMethod · 0.95
FastDownCastFunction · 0.70
ExecuteFunction · 0.50
maxFunction · 0.50
minFunction · 0.50
floorFunction · 0.50
GetDataTypeMethod · 0.45
GetNumberOfComponentsMethod · 0.45
GetNumberOfIdsMethod · 0.45
GetPointerMethod · 0.45

Tested by

no test coverage detected