| 3716 | { |
| 3717 | template <class T, int NumberOfComponents> |
| 3718 | vtkSmartPointer<T> vtkComputeDifference(T* aArray, T* bArray) |
| 3719 | { |
| 3720 | if (aArray == nullptr || bArray == nullptr) |
| 3721 | { |
| 3722 | return nullptr; |
| 3723 | } |
| 3724 | |
| 3725 | const vtkIdType numTuples = aArray->GetNumberOfTuples(); |
| 3726 | const int numComps = aArray->GetNumberOfComponents(); |
| 3727 | if (bArray->GetNumberOfTuples() != numTuples || bArray->GetNumberOfComponents() != numComps || |
| 3728 | numComps != NumberOfComponents) |
| 3729 | { |
| 3730 | return nullptr; |
| 3731 | } |
| 3732 | |
| 3733 | vtkVector<typename T::ValueType, NumberOfComponents> tupleA, tupleB; |
| 3734 | vtkSmartPointer<T> result = vtkSmartPointer<T>::New(); |
| 3735 | result->SetNumberOfComponents(NumberOfComponents); |
| 3736 | result->SetNumberOfTuples(numTuples); |
| 3737 | for (vtkIdType cc = 0, max = numTuples; cc < max; ++cc) |
| 3738 | { |
| 3739 | aArray->GetTypedTuple(cc, tupleA.GetData()); |
| 3740 | bArray->GetTypedTuple(cc, tupleB.GetData()); |
| 3741 | result->SetTypedTuple(cc, (tupleA - tupleB).GetData()); |
| 3742 | } |
| 3743 | return result; |
| 3744 | } |
| 3745 | } |
| 3746 | |
| 3747 | //------------------------------------------------------------------------------ |
nothing calls this directly
no test coverage detected