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

Method Broadcast

Filters/ParallelStatistics/vtkPOrderStatistics.cxx:429–484  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

427
428//------------------------------------------------------------------------------
429bool vtkPOrderStatistics::Broadcast(std::map<vtkStdString, vtkIdType>& histogram,
430 vtkIdTypeArray* card, vtkStringArray* sVals, vtkIdType rProc)
431{
432 vtkCommunicator* com = this->Controller->GetCommunicator();
433
434 // Concatenate string keys of histogram into single string and put values into resized array
435 std::string sPack;
436 StringHistoToBuffers(histogram, sPack, card);
437
438 // Broadcast size of string buffer
439 vtkIdType nc = static_cast<vtkIdType>(sPack.size());
440 if (!com->Broadcast(&nc, 1, rProc))
441 {
442 vtkErrorMacro(
443 "Process " << com->GetLocalProcessId() << " could not broadcast size of string buffer.");
444
445 return true;
446 }
447
448 // Resize string so it can receive the broadcasted string buffer
449 sPack.resize(nc);
450
451 // Broadcast histogram values
452 if (!com->Broadcast(&(*sPack.begin()), nc, rProc))
453 {
454 vtkErrorMacro(
455 "Process " << com->GetLocalProcessId() << " could not broadcast histogram string values.");
456
457 return true;
458 }
459
460 // Unpack the packet of strings
461 std::vector<std::string> sVect;
462 StringBufferToStringVector(sPack, sVect);
463
464 // Broadcast histogram cardinalities
465 if (!com->Broadcast(card, rProc))
466 {
467 vtkErrorMacro(
468 "Process " << com->GetLocalProcessId() << " could not broadcast histogram cardinalities.");
469
470 return true;
471 }
472
473 // Now resize global histogram arrays to reduced size
474 sVals->SetNumberOfValues(static_cast<vtkIdType>(sVect.size()));
475
476 // Then store reduced histogram into array
477 vtkIdType r = 0;
478 for (std::vector<std::string>::iterator vit = sVect.begin(); vit != sVect.end(); ++vit, ++r)
479 {
480 sVals->SetValue(r, *vit);
481 }
482
483 return false;
484}
485VTK_ABI_NAMESPACE_END

Callers 15

LearnMethod · 0.95
IsPointDataValidMethod · 0.45
RequestDataMethod · 0.45
ExchangeHTGMetadataMethod · 0.45
RequestDataMethod · 0.45
InternalBroadcastMethod · 0.45
ExchangeHTGMetadataMethod · 0.45
ReorganizeDataMethod · 0.45
RequestInformationMethod · 0.45

Calls 10

StringHistoToBuffersFunction · 0.85
GetCommunicatorMethod · 0.45
sizeMethod · 0.45
GetLocalProcessIdMethod · 0.45
resizeMethod · 0.45
beginMethod · 0.45
SetNumberOfValuesMethod · 0.45
endMethod · 0.45
SetValueMethod · 0.45