| 41 | } // end anon namespace |
| 42 | |
| 43 | VTK_ABI_NAMESPACE_BEGIN |
| 44 | //------------------------------------------------------------------------------ |
| 45 | void vtkDataArray::InsertTuples(vtkIdList* dstIds, vtkIdList* srcIds, vtkAbstractArray* src) |
| 46 | { |
| 47 | if (dstIds->GetNumberOfIds() == 0) |
| 48 | { |
| 49 | return; |
| 50 | } |
| 51 | if (dstIds->GetNumberOfIds() != srcIds->GetNumberOfIds()) |
| 52 | { |
| 53 | vtkErrorMacro("Mismatched number of tuples ids. Source: " |
| 54 | << srcIds->GetNumberOfIds() << " Dest: " << dstIds->GetNumberOfIds()); |
| 55 | return; |
| 56 | } |
| 57 | if (src->GetNumberOfComponents() != this->GetNumberOfComponents()) |
| 58 | { |
| 59 | vtkErrorMacro("Number of components do not match: Source: " |
| 60 | << src->GetNumberOfComponents() << " Dest: " << this->GetNumberOfComponents()); |
| 61 | return; |
| 62 | } |
| 63 | vtkDataArray* srcDA = vtkDataArray::FastDownCast(src); |
| 64 | if (!srcDA) |
| 65 | { |
| 66 | vtkErrorMacro("Source array must be a subclass of vtkDataArray. Got: " << src->GetClassName()); |
| 67 | return; |
| 68 | } |
| 69 | |
| 70 | vtkIdType maxSrcTupleId = srcIds->GetId(0); |
| 71 | vtkIdType maxDstTupleId = dstIds->GetId(0); |
| 72 | for (vtkIdType i = 1; i < dstIds->GetNumberOfIds(); ++i) |
| 73 | { |
| 74 | maxSrcTupleId = std::max(maxSrcTupleId, srcIds->GetId(i)); |
| 75 | maxDstTupleId = std::max(maxDstTupleId, dstIds->GetId(i)); |
| 76 | } |
| 77 | |
| 78 | if (maxSrcTupleId >= src->GetNumberOfTuples()) |
| 79 | { |
| 80 | vtkErrorMacro("Source array too small, requested tuple at index " |
| 81 | << maxSrcTupleId << ", but there are only " << src->GetNumberOfTuples() |
| 82 | << " tuples in the array."); |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | vtkIdType newSize = (maxDstTupleId + 1) * this->NumberOfComponents; |
| 87 | if (this->Size < newSize) |
| 88 | { |
| 89 | if (!this->Resize(maxDstTupleId + 1)) |
| 90 | { |
| 91 | vtkErrorMacro("Resize failed."); |
| 92 | return; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | this->MaxId = std::max(this->MaxId, newSize - 1); |
| 97 | |
| 98 | SetTuplesIdListWorker worker(srcIds, dstIds); |
| 99 | if (!vtkArrayDispatch::Dispatch2::Execute(srcDA, this, worker)) |
| 100 | { |
nothing calls this directly
no test coverage detected