Trying to write a DXF reader that generates output data of a type that depends on the data it was reading from the file.
So far I am having a DXF reader that is ported from the ParaViewGeo project. It reads DXF data files nicely and always generates a “multi block dataset” as an output, with each “layer” of the DXF file producing one “block” in the multi block dataset.
Now I see that customers are regularly confused if they have a DXF that is for example just one single triangulated surface: they read it and wonder why they cannot save it as a vtp, only as vtm. And then I have to explain them that they first need to apply another filter (also from the ParaView Geo project) that extracts single geometry items from a multi block dataset.
In order to make life easier I thought that I could do that last step just automatically in cases where the mbds contains just one single data item (polydata normally) - but that is more difficult than I expected! Because it looks like I need to specify the output data type “latest” in the RequestDataObject() function - which is called before the file is even read.
So far I see three possible “solutions” - if they can be realized:
I tried to somehow change the datatype within the RequestData() function, but it looks like that change does not “arrive” where it should - but maybe there is still a way that I am not aware of?
Another possibility would be to simply do the actual reading already in the RequestDataObject() function - which would be before the user even presses the Apply button. This would be feasible because there are no option properties to choose anyway; only the user would have to wait a bit longer before he sees the Apply button at all - and afterwards things would be much faster than normal…
Simply write two readers: one that generates a polydata item - and if there are more than one layer, just pick the first and emit a warning. And a second reader that works like it does now: read everything available and put it into a multi block dataset.
Realizing solution 3) is easy, but I would actually prefer something like solution 1) - if possible!