I am trying to understand the “new” way how selections are handled and can be combined with logical operators using “expressions”: looks great! However, once I have a vtkSelection in some filter class, containing whatever the user has chosen to select, combine etc., maybe also using the “selection editor”, I need to obtain a simple list of cell ids for further operation of the filter.
What I found so far: With vtkConvertSelection::GetSelectedCells I can generate a list of all selected cell ids from all the selection nodes. Far from useful because the expression is not evaluated.
I can generate lists of cell ids for every selection node, by always generating a new vtkSelection, add that single node and again apply vtkConvertSelection::GetSelectedCells. Already better: I have now the lists and I can get the expression from vtkSelection::GetExpression, so I have the pieces in my hand. With this I could now write a parser and evaluator and finally get the desired result!
But then I see that there is a number of vtkSelection::Evaluate(...) functions with different parameter sets - and I get the strong feeling that with the above I would re-invent some wheel…
The only problem is: I am simply too stupid to understand what parameters I would have to pass to the different Evaluate functions! And after a lot of struggling and trying I start to believe that I would be faster if indeed I would re-invent that specific wheel, even if it is not a trivial one.
If there is not any helpful person giving me some helpful hint, point me to a usage example or some little tutorial or introduction!
I found now a solution that works perfectly, but somehow feels like solving the problem through the backdoor: using the vtkPVExtractSelection filter! With this, a new geometric object is generated with only the previously selected cells.
This new geometry object has a cell data attribute with the name vtkOriginalCellIds: There you can find the list of selected cell ids that I initially asked for! If generating a new object from the selected cells was never the intention, this object is for the garbage once the “original cell ids” are extracted.
The latter is why I am calling this solution a “solution throuth the back door”, because we do far more than what we initially asked for, only in order to generate some desired side effect. But ok, if the object is not extremely large we do not care too much about the inefficiency…
Note also a side effect of my research: You can do almost the same also with the vtkExtractSelection filter, with (according to my finding) one difference: QUERY selections (as defined with the Find Data panel) are not handled, but ignored with a warning message.
Remark: After understanding the above it would of course be a possibility to now dive into the source code of these extraction filters, in order to find out how the initial problem can be solved which is: given an arbitrary number of selections what are combined with an “expression”, find the resulting list of selected cell ids. However, it looks like there is not one single piece of code doing this job, so it is easier to simply let these filters do their job - somehow -…