Counter-intuitive results for min/max spatial dimension of a data set

I tried using the new GetMinSpatialDimension/GetMaxSpatialDimension members from VTK 9.5, but it returns results that seem counter-intuitive. E.g. for datasets without cells, the following prints (3, 0) as the min/max spatial dimensions respectively, but I would have expected the opposite, i.e. (0, 3) as the min/max, where min <= max.

import vtk

# Try PointSet
ps = vtk.vtkPointSet()
print(ps.GetMinSpatialDimension())  # 3
print(ps.GetMaxSpatialDimension())  # 0

# Try PolyData with no cells
poly = vtk.vtkPolyData()
points = vtk.vtkPoints()
points.InsertNextPoint(0.0, 0.0, 0.0)
poly.SetPoints(points)
print(poly.GetMinSpatialDimension())  # 3
print(poly.GetMaxSpatialDimension())  # 0

# Try PolyData with vertex cell
verts = vtk.vtkCellArray()
verts.InsertNextCell(1)
verts.InsertCellPoint(0)
poly.SetVerts(verts)
print(poly.GetMinSpatialDimension())  # 0
print(poly.GetMaxSpatialDimension())  # 0

Also, I understand that the implementation may just iterate over cells and return the spatial dimensions of these cells, but this can result in misleading dimensions if multiple 2D cells span 3 dimensions. E.g. a 3D cube is reported to have spatial dimensions of 2:

import vtk
source = vtk.vtkCubeSource()
source.Update()
poly = source.GetOutput()

print(poly.GetMinSpatialDimension())  # 2
print(poly.GetMaxSpatialDimension())  # 2
print(poly.GetBounds())  # (-0.5, 0.5, -0.5, 0.5, -0.5, 0.5)

Since PolyData cannot have 3D cells, this seems to suggest that PolyData will never have max spatial dimensions > 2, even if the PolyData geometry itself spans three dimensions? Is this the expected output from this method? And, if this is the case, shouldn’t PointSet always return min/max dimensions of 0, since all the points are effectively like 0D vertex cells?

I’m wondering why these methods weren’t called GetMinCellDimensionality() and GetMaxCellDimensionality(), which would have made the meaning much clearer.

As for the min=3 and max=0, I’m sure that’s just how “min” and “max” computations were implemented, i.e. how they were initialized before the loop through the cells. I agree that it’s a counterintuitive result.

@spyridon97

i wanted the exact same names as you but an internal poll resulted in these names. we should have made the poll public.

Polls in general aren’t a great way to decide things in software engineering, better to argue things out so that everyone understands the reasoning behind the available choices. Then hopefully one choice becomes clear to everyone, and if it does end up having to go to a vote, people have at least properly considered each option.