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

Method RequestData

Filters/ParallelDIY2/vtkAdaptiveResampleToImage.cxx:182–302  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

180
181//------------------------------------------------------------------------------
182int vtkAdaptiveResampleToImage::RequestData(
183 vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
184{
185 auto inputDO = vtkDataObject::GetData(inputVector[0], 0);
186
187 // get resampling bounds.
188 auto controller = this->GetController();
189 const int num_partitions = (controller && this->GetNumberOfImages() == 0)
190 ? controller->GetNumberOfProcesses()
191 : this->GetNumberOfImages();
192
193 vtkLogStartScope(TRACE, "generate-kdtree");
194 auto boxes = vtkDIYKdTreeUtilities::GenerateCuts(
195 inputDO, std::max(1, num_partitions), /*use_cell_centers=*/false, controller);
196 vtkLogEndScope("generate-kdtree");
197 // vtkLogF(TRACE, "num-boxes: %d", (int)(boxes.size()));
198 // for (const auto& box : boxes)
199 // {
200 // double bds[6];
201 // box.GetBounds(bds);
202 // vtkLogF(TRACE, "box: {%f:%f, %f:%f, %f:%f}", bds[0], bds[1], bds[2], bds[3], bds[4], bds[5]);
203 // }
204
205 diy::mpi::communicator comm = vtkDIYUtilities::GetCommunicator(this->Controller);
206 diy::Master master(
207 comm, 1, -1, []() { return static_cast<void*>(vtkImageData::New()); },
208 [](void* b) { reinterpret_cast<vtkImageData*>(b)->Delete(); });
209
210 auto assigner = vtkDIYKdTreeUtilities::CreateAssigner(comm, static_cast<int>(boxes.size()));
211 diy::RegularDecomposer<diy::DiscreteBounds> decomposer(
212 /*dim*/ 1, diy::interval(0, assigner.nblocks() - 1), assigner.nblocks());
213 decomposer.decompose(comm.rank(), assigner, master);
214
215 std::vector<std::vector<vtkSmartPointer<vtkImageData>>> resamples(boxes.size());
216 vtkLogStartScope(TRACE, "local resample");
217
218 const auto localBounds = vtkDIYUtilities::GetLocalBounds(inputDO);
219 std::transform(boxes.begin(), boxes.end(), resamples.begin(),
220 [&inputDO, &localBounds, this](const vtkBoundingBox& bbox)
221 {
222 std::vector<vtkSmartPointer<vtkImageData>> retval;
223 vtkSmartPointer<vtkImageData> img =
224 localBounds.Intersects(bbox) ? impl::resample(bbox, inputDO, this) : nullptr;
225 if (img)
226 {
227 retval.push_back(img);
228 }
229 return retval;
230 });
231 vtkLogEndScope("local resample");
232
233 vtkLogStartScope(TRACE, "global exchange");
234 diy::all_to_all(master, assigner,
235 [&resamples, &comm](vtkImageData*, const diy::ReduceProxy& rp)
236 {
237 if (rp.in_link().size() == 0)
238 {
239 // 1. enqueue

Callers

nothing calls this directly

Calls 15

intervalFunction · 0.85
resampleFunction · 0.85
mergeFunction · 0.85
GetNumberOfProcessesMethod · 0.80
targetMethod · 0.80
foreachMethod · 0.80
DeleteMethod · 0.65
GetDataFunction · 0.50
maxFunction · 0.50
NewFunction · 0.50
transformFunction · 0.50
all_to_allFunction · 0.50

Tested by

no test coverage detected