------------------------------------------------------------------------------
| 310 | |
| 311 | //------------------------------------------------------------------------------ |
| 312 | void vtkExtractStructuredGridHelper::CopyPointsAndPointData(int inExt[6], int outExt[6], |
| 313 | vtkPointData* pd, vtkPoints* inpnts, vtkPointData* outPD, vtkPoints* outpnts) |
| 314 | { |
| 315 | assert("pre: nullptr input point-data!" && (pd != nullptr)); |
| 316 | assert("pre: nullptr output point-data!" && (outPD != nullptr)); |
| 317 | |
| 318 | // short-circuit |
| 319 | if ((pd->GetNumberOfArrays() == 0) && (inpnts == nullptr)) |
| 320 | { |
| 321 | // nothing to copy |
| 322 | return; |
| 323 | } |
| 324 | |
| 325 | // Get the size of the input and output |
| 326 | vtkIdType inSize = vtkStructuredData::GetNumberOfPoints(inExt); |
| 327 | vtkIdType outSize = vtkStructuredData::GetNumberOfPoints(outExt); |
| 328 | (void)inSize; // Prevent warnings, this is only used in debug builds. |
| 329 | |
| 330 | // Check if we can use some optimizations: |
| 331 | bool canCopyRange = I(this->SampleRate) == 1; |
| 332 | bool useMapping = |
| 333 | !(I(this->SampleRate) == 1 && J(this->SampleRate) == 1 && K(this->SampleRate) == 1); |
| 334 | |
| 335 | if (inpnts != nullptr) |
| 336 | { |
| 337 | assert("pre: output points data-structure is nullptr!" && (outpnts != nullptr)); |
| 338 | outpnts->SetDataType(inpnts->GetDataType()); |
| 339 | outpnts->SetNumberOfPoints(outSize); |
| 340 | } |
| 341 | outPD->CopyAllocate(pd, outSize, outSize); |
| 342 | |
| 343 | // Lists for batching copy operations: |
| 344 | vtkNew<vtkIdList> srcIds; |
| 345 | vtkNew<vtkIdList> dstIds; |
| 346 | if (!canCopyRange) |
| 347 | { |
| 348 | vtkIdType bufferSize = IMAX(outExt) - IMIN(outExt) + 1; |
| 349 | srcIds->Allocate(bufferSize); |
| 350 | dstIds->Allocate(bufferSize); |
| 351 | } |
| 352 | |
| 353 | int ijk[3]; |
| 354 | int src_ijk[3]; |
| 355 | for (K(ijk) = KMIN(outExt); K(ijk) <= KMAX(outExt); ++K(ijk)) |
| 356 | { |
| 357 | K(src_ijk) = useMapping ? this->GetMappedExtentValue(2, K(ijk)) : K(ijk); |
| 358 | |
| 359 | for (J(ijk) = JMIN(outExt); J(ijk) <= JMAX(outExt); ++J(ijk)) |
| 360 | { |
| 361 | J(src_ijk) = useMapping ? this->GetMappedExtentValue(1, J(ijk)) : J(ijk); |
| 362 | |
| 363 | if (canCopyRange) |
| 364 | { |
| 365 | // Find the first point id: |
| 366 | I(ijk) = IMIN(outExt); |
| 367 | I(src_ijk) = I(ijk); |
| 368 | |
| 369 | vtkIdType srcStart = vtkStructuredData::ComputePointIdForExtent(inExt, src_ijk); |
no test coverage detected