| 173 | { |
| 174 | template <class OffsetsT, class ConnectivityT> |
| 175 | void operator()(OffsetsT* offsets, ConnectivityT* conn, bool& isValid) const |
| 176 | { |
| 177 | using ValueType = GetAPIType<OffsetsT>; |
| 178 | |
| 179 | // Both arrays must be single component |
| 180 | if (offsets->GetNumberOfComponents() != 1 || conn->GetNumberOfComponents() != 1) |
| 181 | { |
| 182 | isValid = false; |
| 183 | return; |
| 184 | } |
| 185 | |
| 186 | auto offsetsRange = GetRange(offsets); |
| 187 | |
| 188 | // Offsets must have at least one value, and the first value must be zero |
| 189 | if (offsetsRange.size() == 0 || *offsetsRange.cbegin() != 0) |
| 190 | { |
| 191 | isValid = false; |
| 192 | return; |
| 193 | } |
| 194 | |
| 195 | // Values in offsets must not decrease |
| 196 | auto it = std::adjacent_find(offsetsRange.cbegin(), offsetsRange.cend(), |
| 197 | [](const ValueType a, const ValueType b) -> bool { return a > b; }); |
| 198 | if (it != offsetsRange.cend()) |
| 199 | { |
| 200 | isValid = false; |
| 201 | return; |
| 202 | } |
| 203 | |
| 204 | // The last value in offsets must be the size of the connectivity array. |
| 205 | if (conn->GetNumberOfValues() != static_cast<vtkIdType>(*(offsetsRange.cend() - 1))) |
| 206 | { |
| 207 | isValid = false; |
| 208 | return; |
| 209 | } |
| 210 | |
| 211 | isValid = true; |
| 212 | } |
| 213 | }; |
| 214 | |
| 215 | template <typename T> |
nothing calls this directly
no test coverage detected