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?