------------------------------------------------------------------------------
| 73 | |
| 74 | //------------------------------------------------------------------------------ |
| 75 | void vtkOMETIFFReader::vtkOMEInternals::UpdateCache(vtkImageData* source) |
| 76 | { |
| 77 | if (!this->IsValid) |
| 78 | { |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | int dims[3]; |
| 83 | source->GetDimensions(dims); |
| 84 | assert(dims[0] <= this->SizeX && dims[1] <= this->SizeY && |
| 85 | dims[2] == this->SizeZ * this->SizeT * this->SizeC); |
| 86 | |
| 87 | int ext[6]; |
| 88 | source->GetExtent(ext); |
| 89 | |
| 90 | vtkIdType inIncrements[3]; |
| 91 | source->GetIncrements(inIncrements); |
| 92 | |
| 93 | std::vector<vtkVector2d> channel_ranges; |
| 94 | channel_ranges.resize(this->SizeC, vtkVector2d(VTK_DOUBLE_MAX, VTK_DOUBLE_MIN)); |
| 95 | |
| 96 | for (int t = 0; t < this->SizeT; ++t) |
| 97 | { |
| 98 | vtkNew<vtkImageData> img; |
| 99 | img->SetExtent(ext[0], ext[1], ext[2], ext[3], 0, this->SizeZ - 1); |
| 100 | img->AllocateScalars(source->GetScalarType(), source->GetNumberOfScalarComponents()); |
| 101 | this->Cache.emplace_back(img); |
| 102 | |
| 103 | auto pd = img->GetPointData(); |
| 104 | std::vector<vtkDataArray*> scalar_arrays; |
| 105 | scalar_arrays.push_back(pd->GetScalars()); |
| 106 | for (int c = 1; c < this->SizeC; ++c) |
| 107 | { |
| 108 | auto array = vtkDataArray::CreateDataArray(source->GetScalarType()); |
| 109 | array->SetNumberOfComponents(source->GetNumberOfScalarComponents()); |
| 110 | array->SetNumberOfTuples(img->GetNumberOfPoints()); |
| 111 | pd->AddArray(array); |
| 112 | scalar_arrays.push_back(array); |
| 113 | array->Delete(); |
| 114 | } |
| 115 | |
| 116 | // rename arrays. |
| 117 | for (size_t c = 0; c < scalar_arrays.size(); ++c) |
| 118 | { |
| 119 | std::ostringstream str; |
| 120 | str << "Channel_" << (c + 1); // channel names start with 1. |
| 121 | scalar_arrays[c]->SetName(str.str().c_str()); |
| 122 | } |
| 123 | |
| 124 | for (int c = 0; c < this->SizeC; ++c) |
| 125 | { |
| 126 | int outpageIdx = 0; |
| 127 | for (int z = 0; z < this->SizeZ; ++z) |
| 128 | { |
| 129 | auto iter = this->IFDMap.find(vtkVector3i(c, t, z)); |
| 130 | assert(iter != this->IFDMap.end()); |
| 131 | |
| 132 | auto srcptr = |
no test coverage detected