| 372 | } |
| 373 | |
| 374 | void WeightAttributes(vtkPointData* inPD, vtkPointData* outPD, vtkDoubleArray* weights, |
| 375 | const std::vector<vtkIdType>& ptMap) |
| 376 | { |
| 377 | // better here to use a Dispatch2BySameArrayType, but that doesn't exist |
| 378 | using Dispatcher = vtkArrayDispatch::Dispatch2BySameValueType<vtkArrayDispatch::AllTypes>; |
| 379 | WeighingWorklet worker; |
| 380 | for (vtkIdType iArr = 0; iArr < inPD->GetNumberOfArrays(); ++iArr) |
| 381 | { |
| 382 | auto inArr = inPD->GetArray(iArr); |
| 383 | // if not data array check for abstract |
| 384 | if (!inArr) |
| 385 | { |
| 386 | auto inAbsArr = inPD->GetAbstractArray(iArr); |
| 387 | if (!inAbsArr) |
| 388 | { |
| 389 | vtkGenericWarningMacro("One of the arrays in the point data is nullptr."); |
| 390 | continue; |
| 391 | } |
| 392 | auto outAbsArr = outPD->GetAbstractArray(inAbsArr->GetName()); |
| 393 | if (!outAbsArr) |
| 394 | { |
| 395 | vtkGenericWarningMacro("Output array " << inAbsArr->GetName() << " is nullptr."); |
| 396 | continue; |
| 397 | } |
| 398 | // if string array go to dedicated path |
| 399 | auto inStrArr = vtkStringArray::SafeDownCast(inAbsArr); |
| 400 | if (inStrArr) |
| 401 | { |
| 402 | auto outStrArr = vtkStringArray::SafeDownCast(outAbsArr); |
| 403 | if (!outStrArr) |
| 404 | { |
| 405 | vtkGenericWarningMacro("Output array " << inStrArr->GetName() |
| 406 | << " is not the same type as input string array."); |
| 407 | continue; |
| 408 | } |
| 409 | worker(inStrArr, outStrArr, weights, ptMap); |
| 410 | continue; |
| 411 | } |
| 412 | worker(inAbsArr, outAbsArr, weights, ptMap); |
| 413 | continue; |
| 414 | } |
| 415 | auto outArr = outPD->GetArray(inArr->GetName()); |
| 416 | if (!outArr) |
| 417 | { |
| 418 | vtkGenericWarningMacro( |
| 419 | "Output array " << inArr->GetName() << " is nullptr or not a vtkDataArray."); |
| 420 | continue; |
| 421 | } |
| 422 | if (!Dispatcher::Execute(inArr, outArr, worker, weights, ptMap)) |
| 423 | { |
| 424 | auto inBitArr = vtkBitArray::SafeDownCast(inArr); |
| 425 | auto outBitArr = vtkBitArray::SafeDownCast(outArr); |
| 426 | if (inBitArr && outBitArr) |
| 427 | { |
| 428 | worker(inBitArr, outBitArr, weights, ptMap); |
| 429 | } |
| 430 | worker(inArr, outArr, weights, ptMap); |
| 431 | } |
no test coverage detected