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

Method FindOrCreateNodeAtPath

Common/DataModel/vtkDataAssembly.cxx:712–761  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

710
711//------------------------------------------------------------------------------
712int vtkDataAssembly::FindOrCreateNodeAtPath(const char* path, int parent)
713{
714 if (!path || !path[0])
715 {
716 // An empty/invalid path returns the "root" node.
717 return parent;
718 }
719
720 auto it = this->Internals->NodeMap.find(parent);
721 if (it == this->Internals->NodeMap.end())
722 {
723 return -1;
724 }
725
726 // The parent node exists.
727 int node = parent;
728 auto pathNames = vtksys::SystemTools::SplitString(path, '/');
729 for (std::size_t ii = 0; ii < pathNames.size(); ++ii)
730 {
731 std::string childName = pathNames[ii];
732 auto children = this->GetChildNodes(node, /*traverse_subtree*/ false, /*traversal_order*/ 0);
733 bool foundChild = false;
734 for (const auto& child : children)
735 {
736 it = this->Internals->NodeMap.find(child);
737 if (it == this->Internals->NodeMap.end())
738 {
739 // Inconsistent node map!
740 return -1;
741 }
742 if (it->second.name() == childName)
743 {
744 node = child;
745 foundChild = true;
746 break;
747 }
748 }
749 if (!foundChild)
750 {
751 // Create all remaining entries
752 for (; ii < pathNames.size(); ++ii)
753 {
754 childName = pathNames[ii];
755 node = this->AddNode(childName.c_str(), node);
756 }
757 return node;
758 }
759 }
760 return node;
761}
762
763//------------------------------------------------------------------------------
764bool vtkDataAssembly::AddDataSetIndex(int id, unsigned int dataset_index)

Callers

nothing calls this directly

Calls 8

GetChildNodesMethod · 0.95
AddNodeMethod · 0.95
SplitStringFunction · 0.85
findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
nameMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected