Potential bug in vtkDataAssembly?

I’m using Python 3.9 and vtk 9.1.0 on Windows.

vtkDataAssembly.SelectNodes() selects nodes in the vtkDataAssembly using a ‘/’ sperated path of the node names.

This method is supposed to return an empty vector/tuple if no nodes match the path,
however I find that the method always returns the root node if the supplied path has a ‘/’ in it.

In the snippet below I create a data asssembly and then call SelectNodes using two different paths. Since the data assembly is empty, I expect both calls to return an empty tuple.

In fact the first call, using the path ‘test’ does return an empty tuple but the second one returns the index of the root node. Any path that includes a leading ‘/’ returns the root node.

Am I missing something, or is this a bug?

data_assembly = vtk.vtkDataAssembly()
print('test', data_assembly.SelectNodes('test'))
print('/test', data_assembly.SelectNodes('/test'))

Output :

test ()
/test (0,)

Thanks,

Doug

If I use the GetFirstNodeByPath() method instead of SelectNodes() I get the behavior I expect, so I’m not blocked.

But I’m now more certain this is a bug…

data_assembly = vtk.vtkDataAssembly()
print('SelectNodes')
print('test', data_assembly.SelectNodes('test'))
print('/test', data_assembly.SelectNodes('/test'))
print('/', data_assembly.SelectNodes('/'))

print('\nGetFirstNodeByPath')
print('test', data_assembly.GetFirstNodeByPath('test'))
print('/test', data_assembly.GetFirstNodeByPath('/test'))
print('/', data_assembly.GetFirstNodeByPath('/'))

Output

SelectNodes
test ()
/test (0,)
/ (0,)

GetFirstNodeByPath
test -1
/test -1
/ 0

@utkarshayachit ?

Hello everyone. I think this bug is still relevant (vtk 9.3.0)
It seems that the XPath are not searched

print('SelectNodes')
print('/', data_assembly.SelectNodes('/'))
print('//test/subtest', data_assembly.SelectNodes('//test/subtest'))
print('//test/subtest/Element4', data_assembly.SelectNodes('//test/subtest/Element4'))

print('\nGetFirstNodeByPath')
print(' /', data_assembly.GetFirstNodeByPath('/'))
print('//test/subtest ', data_assembly.GetFirstNodeByPath('//test/subtest'))
print('//test/subtest/Element4 ', data_assembly.GetFirstNodeByPath('//test/subtest/Element4'))

That prints out:

SelectNodes
/ (0,)
//test/subtest (0,)
//test/subtest/Element4  (0,)

GetFirstNodeByPath
/  0
//test/subtest  2
//test/subtest/Element4  7

@Charles_Gueunet Could you point me someone able to take a look ?

Hello @untereiner ,

The person who designed those classes intially is @utkarshayachit . He does not works at Kitware anymore so I am not sure he will be able to get the time to dive on this unfortunately