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

Method IntersectFieldList

Common/DataModel/vtkDataSetAttributesFieldList.cxx:415–484  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

413
414//------------------------------------------------------------------------------
415void vtkDataSetAttributesFieldList::IntersectFieldList(vtkDataSetAttributes* dsa)
416{
417 auto& internals = *this->Internals;
418 if (internals.NumberOfInputs == 0)
419 {
420 // called without calling InitializeFieldList, just call it.
421 this->InitializeFieldList(dsa);
422 internals.Mode = vtkInternals::INTERSECTION;
423 return;
424 }
425
426 if (internals.Mode == vtkInternals::UNION)
427 {
428 vtkGenericWarningMacro("Mixing of `IntersectFieldList` and `UnionFieldList` "
429 "calls is not supported!");
430 return;
431 }
432 internals.Mode = vtkInternals::INTERSECTION;
433 internals.NumberOfTuples += dsa->GetNumberOfTuples();
434
435 const auto curfields = detail::GetFields(dsa);
436 auto& accfields = internals.Fields;
437
438 // first, find the array names in the intersection set.
439 // we build set of keys for the accumulated fields (accfields) and current
440 // fields (curfields).
441 std::set<std::string> acckeys;
442 for (const auto& pair : accfields)
443 {
444 acckeys.insert(pair.first);
445 }
446
447 std::set<std::string> curkeys;
448 for (const auto& pair : curfields)
449 {
450 curkeys.insert(pair.first);
451 }
452
453 std::set<std::string> rkeys;
454 std::set_intersection(acckeys.begin(), acckeys.end(), curkeys.begin(), curkeys.end(),
455 std::inserter(rkeys, rkeys.end()));
456
457 // second, remove fields from accumulate collection with names not in the
458 // intersection set.
459 detail::remove_if(accfields, accfields.begin(), accfields.end(),
460 [&](const std::pair<std::string, detail::FieldInfo>& pair)
461 { return rkeys.find(pair.first) == rkeys.end(); });
462
463 // now, since multiple fields can have same name (including empty names),
464 // we do second intersection for fields with same names (or no names).
465 for (const auto& fname : rkeys)
466 {
467 decltype(accfields.begin()) acciter, accend;
468 std::tie(acciter, accend) = accfields.equal_range(fname);
469
470 decltype(curfields.begin()) niter, nend;
471 std::tie(niter, nend) = curfields.equal_range(fname);
472

Callers 11

GetFieldsFunction · 0.80
StructuredGridExecuteMethod · 0.80
TestFieldListFunction · 0.80
RequestDataMethod · 0.80
MergeDataSetMethod · 0.80
SetupOutputMethod · 0.80
RequestDataMethod · 0.80
mergeFunction · 0.80
BuildFieldListMethod · 0.80
ExecuteAppendMethod · 0.80
AppendArraysMethod · 0.80

Calls 10

InitializeFieldListMethod · 0.95
remove_ifFunction · 0.85
GetFieldsFunction · 0.70
GetNumberOfTuplesMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
findMethod · 0.45
equal_rangeMethod · 0.45
eraseMethod · 0.45

Tested by 1

TestFieldListFunction · 0.64