| 599 | // templated to handle different data types. |
| 600 | template <class OT> |
| 601 | void vtkImageReader2Update(vtkImageReader2* self, vtkImageData* data, OT* outPtr) |
| 602 | { |
| 603 | vtkIdType outIncr[3]; |
| 604 | OT *outPtr1, *outPtr2; |
| 605 | long streamRead; |
| 606 | int idx1, idx2, nComponents; |
| 607 | int outExtent[6]; |
| 608 | unsigned long count = 0; |
| 609 | unsigned long target; |
| 610 | |
| 611 | // Get the requested extents and increments |
| 612 | data->GetExtent(outExtent); |
| 613 | data->GetIncrements(outIncr); |
| 614 | nComponents = data->GetNumberOfScalarComponents(); |
| 615 | |
| 616 | // length of a row, num pixels read at a time |
| 617 | int pixelRead = outExtent[1] - outExtent[0] + 1; |
| 618 | streamRead = (long)(pixelRead * nComponents * sizeof(OT)); |
| 619 | |
| 620 | // create a buffer to hold a row of the data |
| 621 | target = |
| 622 | (unsigned long)((outExtent[5] - outExtent[4] + 1) * (outExtent[3] - outExtent[2] + 1) / 50.0); |
| 623 | target++; |
| 624 | |
| 625 | // read the data row by row |
| 626 | if (self->GetFileDimensionality() == 3) |
| 627 | { |
| 628 | self->ComputeInternalFileName(0); |
| 629 | if (!self->OpenFile()) |
| 630 | { |
| 631 | return; |
| 632 | } |
| 633 | } |
| 634 | outPtr2 = outPtr; |
| 635 | for (idx2 = outExtent[4]; idx2 <= outExtent[5]; ++idx2) |
| 636 | { |
| 637 | if (self->GetFileDimensionality() == 2) |
| 638 | { |
| 639 | self->ComputeInternalFileName(idx2); |
| 640 | if (!self->OpenFile()) |
| 641 | { |
| 642 | return; |
| 643 | } |
| 644 | } |
| 645 | outPtr1 = outPtr2; |
| 646 | for (idx1 = outExtent[2]; !self->AbortExecute && idx1 <= outExtent[3]; ++idx1) |
| 647 | { |
| 648 | if (!(count % target)) |
| 649 | { |
| 650 | self->UpdateProgress(count / (50.0 * target)); |
| 651 | } |
| 652 | count++; |
| 653 | |
| 654 | // seek to the correct row |
| 655 | self->SeekFile(outExtent[0], idx1, idx2); |
| 656 | // read the row. |
| 657 | if (!self->GetFile()->read((char*)outPtr1, streamRead)) |
| 658 | { |
no test coverage detected