| 374 | */ |
| 375 | template <typename T> |
| 376 | void FillRegion(T* pArray, const vtkAMRBox& arrayRegion, const vtkAMRBox& destRegion, T fillValue) |
| 377 | { |
| 378 | // Convert regions to array index space. VTK arrays |
| 379 | // always start with 0,0,0. |
| 380 | int ofs[3]; |
| 381 | ofs[0] = -arrayRegion.GetLoCorner()[0]; |
| 382 | ofs[1] = -arrayRegion.GetLoCorner()[1]; |
| 383 | ofs[2] = -arrayRegion.GetLoCorner()[2]; |
| 384 | vtkAMRBox arrayDims(arrayRegion); |
| 385 | arrayDims.Shift(ofs); |
| 386 | vtkAMRBox destDims(destRegion); |
| 387 | destDims.Shift(ofs); |
| 388 | // Quick sanity check. |
| 389 | if (!arrayRegion.Contains(destRegion)) |
| 390 | { |
| 391 | vtkGenericWarningMacro(<< "ERROR: Array must enclose the destination region. " |
| 392 | << "Aborting the fill."); |
| 393 | } |
| 394 | // Get the bounds of the indices we fill. |
| 395 | const int* destLo = destDims.GetLoCorner(); |
| 396 | int destHi[3]; |
| 397 | destDims.GetValidHiCorner(destHi); |
| 398 | // Get the array dimensions. |
| 399 | int arrayHi[3]; |
| 400 | arrayDims.GetNumberOfCells(arrayHi); |
| 401 | // Fill. |
| 402 | for (int k = destLo[2]; k <= destHi[2]; ++k) |
| 403 | { |
| 404 | vtkIdType kOfs = k * arrayHi[0] * arrayHi[1]; |
| 405 | for (int j = destLo[1]; j <= destHi[1]; ++j) |
| 406 | { |
| 407 | vtkIdType idx = kOfs + j * arrayHi[0] + destLo[0]; |
| 408 | for (int i = destLo[0]; i <= destHi[0]; ++i) |
| 409 | { |
| 410 | pArray[idx] = fillValue; |
| 411 | ++idx; |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | ///@} |
| 416 | } |
| 417 | |
| 418 | VTK_ABI_NAMESPACE_END |
| 419 | #endif |
no test coverage detected