------------------------------------------------------------------------------
| 312 | |
| 313 | //------------------------------------------------------------------------------ |
| 314 | int vtkPDataSetWriter::WriteImageMetaData( |
| 315 | vtkImageData* input, char* root, char* str, size_t strSize, ostream* fptr) |
| 316 | { |
| 317 | int* pi; |
| 318 | double* pf; |
| 319 | vtkInformation* inInfo = this->GetInputInformation(); |
| 320 | |
| 321 | // We should indicate the type of data that is being saved. |
| 322 | *fptr << " dataType=\"" << input->GetClassName() << "\"" << endl; |
| 323 | // Image data has a buch of meta data. |
| 324 | *fptr << " scalarType=\"" << input->GetScalarType() << "\"" << endl; |
| 325 | pf = inInfo->Get(vtkDataObject::ORIGIN()); |
| 326 | *fptr << " origin=\"" << pf[0] << " " << pf[1] << " " << pf[2] << "\"" << endl; |
| 327 | pf = inInfo->Get(vtkDataObject::SPACING()); |
| 328 | *fptr << " spacing=\"" << pf[0] << " " << pf[1] << " " << pf[2] << "\"" << endl; |
| 329 | pi = vtkStreamingDemandDrivenPipeline::GetWholeExtent(inInfo); |
| 330 | *fptr << " wholeExtent=\"" << pi[0] << " " << pi[1] << " " << pi[2] << " " << pi[3] << " " |
| 331 | << pi[4] << " " << pi[5] << "\"" << endl; |
| 332 | |
| 333 | // This is making the assumption that all the files will be written out by |
| 334 | // some processes. |
| 335 | *fptr << " numberOfPieces=\"" << this->NumberOfPieces << "\" >" << endl; |
| 336 | |
| 337 | // The code below gathers extens from all processes to write in the |
| 338 | // meta-file. Note that the extent of each piece was already stored by |
| 339 | // each writer. This is gathering it all to root node. |
| 340 | if (this->Controller) |
| 341 | { |
| 342 | // Even though the logic is pretty straightforward, we need to |
| 343 | // do a fair amount of work to use GatherV. Each rank simply |
| 344 | // serializes its extents to 7 int blocks - piece number and 6 |
| 345 | // extent values. Then we gather this all to root. |
| 346 | int rank = this->Controller->GetLocalProcessId(); |
| 347 | int nRanks = this->Controller->GetNumberOfProcesses(); |
| 348 | |
| 349 | int nPiecesTotal = 0; |
| 350 | vtkIdType nPieces = static_cast<vtkIdType>(this->Extents.size()); |
| 351 | |
| 352 | std::vector<vtkIdType> offsets; |
| 353 | std::vector<vtkIdType> nPiecesAll; |
| 354 | std::vector<vtkIdType> recvLengths; |
| 355 | if (rank == 0) |
| 356 | { |
| 357 | offsets.resize(nRanks); |
| 358 | nPiecesAll.resize(nRanks); |
| 359 | recvLengths.resize(nRanks); |
| 360 | } |
| 361 | this->Controller->Gather(&nPieces, nPiecesAll.data(), 1, 0); |
| 362 | if (rank == 0) |
| 363 | { |
| 364 | for (int i = 0; i < nRanks; i++) |
| 365 | { |
| 366 | offsets[i] = nPiecesTotal * 7; |
| 367 | nPiecesTotal += nPiecesAll[i]; |
| 368 | recvLengths[i] = nPiecesAll[i] * 7; |
| 369 | } |
| 370 | } |
| 371 | std::vector<int> sendBuffer; |
no test coverage detected