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

Method CorrespondingArray

Common/DataModel/vtkCellGrid.cxx:757–826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

755}
756
757vtkDataArray* vtkCellGrid::CorrespondingArray(
758 vtkCellGrid* gridA, vtkDataArray* arrayA, vtkCellGrid* gridB)
759{
760 vtkDataArray* arrayB = nullptr;
761 if (!gridA || !gridB || !arrayA || !arrayA->GetName() || !arrayA->GetName()[0])
762 {
763 return arrayB;
764 }
765
766 const char* arrayName = arrayA->GetName();
767
768 // If we have ARRAY_GROUP_IDS, look there first.
769 auto* infoA = arrayA->HasInformation() ? arrayA->GetInformation() : nullptr;
770 if (infoA && infoA->Has(ARRAY_GROUP_IDS()))
771 {
772 int numGroups = infoA->Length(vtkCellGrid::ARRAY_GROUP_IDS());
773 int* groupIds = infoA->Get(vtkCellGrid::ARRAY_GROUP_IDS());
774 for (int gg = 0; gg < numGroups; ++gg)
775 {
776 if (auto* groupA = gridA->FindAttributes(groupIds[gg]))
777 {
778 if (auto* array = groupA->GetArray(arrayName))
779 {
780 if (array != arrayA)
781 {
782 continue;
783 }
784 if (auto* groupB = gridB->FindAttributes(groupIds[gg]))
785 {
786 arrayB = groupB->GetArray(arrayName);
787 if (arrayB)
788 {
789 return arrayB;
790 }
791 }
792 }
793 }
794 }
795 }
796
797 // We don't currently index arrays by their parent group.
798 // Just iterate groups until we find a match.
799 for (const auto& groupEntry : gridA->ArrayGroups)
800 {
801 auto* array = groupEntry.second->GetArray(arrayName);
802 if (array != arrayA)
803 {
804 continue;
805 }
806 // The input array was not marked with a group but was present in a group; add it:
807 arrayA->GetInformation()->Append(ARRAY_GROUP_IDS(), groupEntry.first);
808 auto* groupB = gridB->FindAttributes(groupEntry.first);
809 if (!groupB)
810 {
811 return arrayB;
812 }
813 arrayB = groupB->GetArray(arrayName);
814 if (arrayB)

Callers

nothing calls this directly

Calls 8

FindAttributesMethod · 0.80
GetNameMethod · 0.45
GetInformationMethod · 0.45
HasMethod · 0.45
LengthMethod · 0.45
GetMethod · 0.45
GetArrayMethod · 0.45
AppendMethod · 0.45

Tested by

no test coverage detected