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

Method AddNodes

Common/DataModel/vtkDataAssembly.cxx:592–626  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

590
591//------------------------------------------------------------------------------
592std::vector<int> vtkDataAssembly::AddNodes(const std::vector<std::string>& names, int parent)
593{
594 auto& internals = (*this->Internals);
595 auto pnode = internals.FindNode(parent);
596 if (!pnode)
597 {
598 vtkErrorMacro("Parent node with id=" << parent << " not found.");
599 return std::vector<int>{};
600 }
601
602 // validate names first to avoid partial additions.
603 for (const auto& name : names)
604 {
605 if (!vtkDataAssembly::IsNodeNameValid(name.c_str()))
606 {
607 vtkErrorMacro("Invalid name specified '" << name << "'.");
608 return std::vector<int>{};
609 }
610 }
611
612 std::vector<int> ids;
613 for (const auto& name : names)
614 {
615 auto child = ++internals.MaxUniqueId;
616 auto cnode = pnode.append_child(name.c_str());
617 cnode.append_attribute("id") = child;
618 internals.NodeMap[child] = cnode;
619 ids.push_back(child);
620 }
621 if (!ids.empty())
622 {
623 this->Modified();
624 }
625 return ids;
626}
627
628//------------------------------------------------------------------------------
629bool vtkDataAssembly::RemoveNode(int id)

Callers 4

RequestInformationMethod · 0.80
TraverseStageMethod · 0.80
TestDataAssemblyFunction · 0.80
TestPDCFunction · 0.80

Calls 7

FindNodeMethod · 0.80
append_childMethod · 0.80
append_attributeMethod · 0.80
c_strMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45
ModifiedMethod · 0.45

Tested by 2

TestDataAssemblyFunction · 0.64
TestPDCFunction · 0.64