How to determine if vtkPolyData has lines?

I’ve just noticed that now vtkPolyData::GetLines() and similar methods always return a valid vtkCellArray. If SetLines has not been called on the object before then some shared dummy array is returned. If this dummy array is modified then it it causes application crash or other issues.

I understand why the dummy object was added (to avoid nullptr-checks when iterating through items) but now there is no way of knowing if the polydata has a Lines member that can be modified or I must create and set a new cell array.

A few potential solutions:

  • add extra methods that would not return a dummy pointer when there is no array created
  • expose the dummy pointer on the public interface of vtkPolyData so that I can compare the returned pointer to the dummy pointer
  • create empty arrays that are readily usable and not some shared dummies

If the dummy array concept is kept then a special “vtkEmptyCellArray” subclass must be created for that purpose, which logs an error message if someone tries to modify it (to prevent accidental modification of the shared dummy array).

Which would be the most preferred solution?