Specifing vtkDataSet::GetScalarRange()

Current Implementation:

  • .vtk UnstrucredGrid file of 2D mesh that contains multiple point and cell scalar fields
  • Example Fields: material (cell), grid function solution (point)


  • Set the scalar range of a mapper’s lookup table only using my solution scalar

Current Attempt:



  • I do not understand how to specify what scalar to use when getting the scalar range, or how to get the information of a specified scalar in general.

Convenience method to get the range of the first component (and only the first component) of any scalars in the data set.
If the data has both point data and cell data, it returns the (min/max) range of combined point and cell data

  • Does the above mean that I cannot specify which scalar to use?

You can try unGridReader->GetOutput()->[ GetPointData() or GetCellData() ]->GetScalars()->GetRange( integer ). See doc here: https://vtk.org/doc/nightly/html/classvtkDataArray.html#a825000e3c1a9d8c1177ec1df549f347f . vtkAbstractArray::GetNumberOfComponents() can return the number of scalars per data/cell. The number you pass to GetRange() should be between 0 and vtkAbstractArray::GetNumberOfComponents()-1.