MCPcopy Create free account
hub / github.com/Kitware/VTK / UpdateCache

Method UpdateCache

IO/Image/vtkOMETIFFReader.cxx:75–176  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

73
74//------------------------------------------------------------------------------
75void 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 =

Callers 3

ReadGeometryMethod · 0.45
UpdateGeometryIfRequiredFunction · 0.45

Calls 15

vtkVector2dClass · 0.85
GetIncrementsMethod · 0.80
GetScalarPointerMethod · 0.80
GetArrayPointerMethod · 0.80
GetScalarSizeMethod · 0.80
DeleteMethod · 0.65
assertFunction · 0.50
CreateDataArrayFunction · 0.50
vtkVector3iClass · 0.50
copyFunction · 0.50
minFunction · 0.50
maxFunction · 0.50

Tested by

no test coverage detected