Can flat indices from CompositeDataSetIterators be used to recover nodes from vtkDataAssembly?

Hello!!!

I’m uinsg VTK 9.2, Python 3.11.6 and I’ll be grateful for any help with this…

I have a vtkPartitionedDataSetCollection and associated vtkDataAssembly representing a hierarchial Part/Assembly structure. I have carefully added attributes to the vtkDataAssembly nodes that are important to my application.

When I iterate over the vtkPartitionedDataSetCollection, I call iter.GetCurrentFlatIndex() and pass the value into my assembly, expecting to get the nodePath, nodeName etc of the assembly node that the dataset is associated with - which I can then use to retrieve the attributes from the node

But I’m finding that I’m getting the wrong/unexpected assembly node back - it doesn’t match the node that the dataset is associated with.

So my questions are,

  1. Is this the recommended approach to link datasets with assembly nodes?
  2. If not, what is the recommended approach?
  3. If so, why is not working…

Here is a minimal code example and I’ve attached a test file

# coding: utf-8
    
from vtkmodules.vtkIOXML import vtkXMLPartitionedDataSetCollectionReader    

# Read the vtkPatitionedDataSetCollection
reader=vtkXMLPartitionedDataSetCollectionReader()
reader.SetFileName('E:/DEV/test_to_vtk.vtpc')
reader.Update()
pdsc=reader.GetOutputDataObject(0)

# Get hte vtkDataAssembly
assy=pdsc.GetDataAssembly()

# Iterate over the collection
iter=pdsc.NewIterator()
#iter.VisitOnlyLeavesOff()
#iter.SkipEmptyNodesOff()
iter.InitTraversal()
iter.GoToFirstItem()

mesh_bodies_referencing_node=[]
while iter.IsDoneWithTraversal()==0:
    dset=iter.GetCurrentDataObject()

    # Get the flat index and use it to recover the assembly node info
    nodepath=assy.GetNodePath(iter.GetCurrentFlatIndex())
    nodename=assy.GetNodeName(iter.GetCurrentFlatIndex())
    print(iter.GetCurrentFlatIndex(), nodepath, nodename, type(dset), dset.GetNumberOfPoints())
    if assy.HasAttribute(iter.GetCurrentFlatIndex(), 'entityType'):
        print(assy.GetAttributeOrDefault(iter.GetCurrentFlatIndex(), 'entityType', 'Unknown'))
    else:
        print('No entityType attribute found for node with id {}'.format(iter.GetCurrentFlatIndex()))
    iter.GoToNextItem()  

exit()

test_to_vtk.vtpc (4.1 KB)
test_to_vtk.zip (11.6 KB)

Added the actual files that the .vtpc references…