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

Method BuildAssembly

IO/IOSS/vtkIOSSReaderInternal.cxx:674–742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

672}
673
674bool vtkIOSSReaderInternal::BuildAssembly(
675 Ioss::Region* region, vtkDataAssembly* assembly, int root, bool add_leaves)
676{
677 if (region == nullptr || assembly == nullptr)
678 {
679 return false;
680 }
681
682 // assemblies in Ioss are simply stored as a vector. we need to build graph
683 // from that vector of assemblies.
684 std::set<const Ioss::GroupingEntity*> root_assemblies;
685 for (auto& ioss_assembly : region->get_assemblies())
686 {
687 assert(ioss_assembly != nullptr);
688 root_assemblies.insert(ioss_assembly);
689
690 for (auto child : ioss_assembly->get_members())
691 {
692 // a child cannot be a root, so remove it.
693 root_assemblies.erase(child);
694 }
695 }
696
697 if (root_assemblies.empty())
698 {
699 return false;
700 }
701
702 std::function<void(const Ioss::Assembly*, int)> processAssembly;
703 processAssembly = [&assembly, &processAssembly, &add_leaves, this](
704 const Ioss::Assembly* ioss_assembly, int parent)
705 {
706 auto node = assembly->AddNode(
707 vtkDataAssembly::MakeValidNodeName(ioss_assembly->name().c_str()).c_str(), parent);
708 assembly->SetAttribute(node, "label", ioss_assembly->name().c_str());
709 if (ioss_assembly->get_member_type() == Ioss::ASSEMBLY)
710 {
711 for (auto& child : ioss_assembly->get_members())
712 {
713 processAssembly(dynamic_cast<const Ioss::Assembly*>(child), node);
714 }
715 }
716 else
717 {
718 for (auto& child : ioss_assembly->get_members())
719 {
720 int dsnode = node;
721 if (add_leaves)
722 {
723 dsnode = assembly->AddNode(
724 vtkDataAssembly::MakeValidNodeName(child->name().c_str()).c_str(), node);
725 assembly->SetAttribute(dsnode, "label", child->name().c_str());
726 }
727 assembly->AddDataSetIndex(dsnode, this->GetDataSetIndexForEntity(child));
728 }
729 }
730 };
731

Callers 2

UpdateAssemblyMethod · 0.95
ReadAssembliesMethod · 0.95

Calls 12

AddDataSetIndexMethod · 0.80
assertFunction · 0.50
insertMethod · 0.45
eraseMethod · 0.45
emptyMethod · 0.45
AddNodeMethod · 0.45
c_strMethod · 0.45
nameMethod · 0.45
SetAttributeMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected