Skip to content

Tweak EXPECTS for array Get/SetComponent()

David Gobbi requested to merge dgobbi/vtk:tweak-expects into master

Since array size is dictated by NumberOfValues, via MaxId, it is possible to have an incomplete tuple at the end of the array. This can occur, for example, when building a multi-component array one value at a time, rather than building the array one tuple at a time. Even though they are rare and should only be present in intermediate results, we still want to allow access to these partial tuples from wrapper languages.

Example of new EXPECTS for vtkDataArray::SetComponent():

  void SetComponent(vtkIdType tupleIdx, int compIdx, ValueType value)
    VTK_EXPECTS(0 <= tupleIdx && GetNumberOfComponents() * tupleIdx + compIdx < this->GetNumberOfValues())
    VTK_EXPECTS(0 <= compIdx && compIdx < GetNumberOfComponents());

As long as (numberOfComponents * tupleIdx) + compIdx < numberOfValues, it isn't out-of-bounds.

Edited by David Gobbi

Merge request reports

Loading