MCPcopy Create free account
hub / github.com/Kitware/VTK / operator()

Method operator()

Common/DataModel/vtkCellArray.cxx:175–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
215template <typename T>

Callers

nothing calls this directly

Calls 7

adjacent_findFunction · 0.85
GetRangeFunction · 0.50
GetNumberOfComponentsMethod · 0.45
sizeMethod · 0.45
cbeginMethod · 0.45
cendMethod · 0.45
GetNumberOfValuesMethod · 0.45

Tested by

no test coverage detected