------------------------------------------------------------------------------
| 415 | |
| 416 | //------------------------------------------------------------------------------ |
| 417 | void vtkExtractStructuredGridHelper::CopyCellData( |
| 418 | int inExt[6], int outExt[6], vtkCellData* cd, vtkCellData* outCD) |
| 419 | { |
| 420 | assert("pre: nullptr input cell-data!" && (cd != nullptr)); |
| 421 | assert("pre: nullptr output cell-data!" && (outCD != nullptr)); |
| 422 | |
| 423 | // short-circuit |
| 424 | if (cd->GetNumberOfArrays() == 0) |
| 425 | { |
| 426 | // nothing to copy |
| 427 | return; |
| 428 | } |
| 429 | |
| 430 | // Get the size of the output & allocate output |
| 431 | vtkIdType inSize = vtkStructuredData::GetNumberOfCells(inExt); |
| 432 | vtkIdType outSize = vtkStructuredData::GetNumberOfCells(outExt); |
| 433 | (void)inSize; // Prevent warnings, this is only used in debug builds. |
| 434 | outCD->CopyAllocate(cd, outSize, outSize); |
| 435 | |
| 436 | // Check if we can use some optimizations: |
| 437 | bool canCopyRange = I(this->SampleRate) == 1; |
| 438 | bool useMapping = |
| 439 | !(I(this->SampleRate) == 1 && J(this->SampleRate) == 1 && K(this->SampleRate) == 1); |
| 440 | |
| 441 | int inpCellExt[6]; |
| 442 | vtkStructuredData::GetCellExtentFromPointExtent(inExt, inpCellExt); |
| 443 | |
| 444 | int outCellExt[6]; |
| 445 | vtkStructuredData::GetCellExtentFromPointExtent(outExt, outCellExt); |
| 446 | |
| 447 | // clamp outCellExt using inpCellExt. This is needed for the case where outExt |
| 448 | // is the outer face of the dataset along any of the dimensions. |
| 449 | for (int dim = 0; dim < 3; ++dim) |
| 450 | { |
| 451 | EMIN(outCellExt, dim) = std::min(EMAX(inpCellExt, dim), EMIN(outCellExt, dim)); |
| 452 | EMAX(outCellExt, dim) = std::min(EMAX(inpCellExt, dim), EMAX(outCellExt, dim)); |
| 453 | } |
| 454 | |
| 455 | // Lists for batching copy operations: |
| 456 | vtkNew<vtkIdList> srcIds; |
| 457 | vtkNew<vtkIdList> dstIds; |
| 458 | if (!canCopyRange) |
| 459 | { |
| 460 | vtkIdType bufferSize = IMAX(outCellExt) - IMIN(outCellExt) + 1; |
| 461 | srcIds->Allocate(bufferSize); |
| 462 | dstIds->Allocate(bufferSize); |
| 463 | } |
| 464 | |
| 465 | int ijk[3]; |
| 466 | int src_ijk[3]; |
| 467 | for (K(ijk) = KMIN(outCellExt); K(ijk) <= KMAX(outCellExt); ++K(ijk)) |
| 468 | { |
| 469 | K(src_ijk) = useMapping ? this->GetMappedExtentValue(2, K(ijk)) : K(ijk); |
| 470 | if (K(src_ijk) == KMAX(this->InputWholeExtent) && |
| 471 | KMIN(this->InputWholeExtent) != KMAX(this->InputWholeExtent)) |
| 472 | { |
| 473 | --K(src_ijk); |
| 474 | } |
nothing calls this directly
no test coverage detected