MCPcopy Create free account
hub / github.com/Kitware/VTK / MoveRowData

Method MoveRowData

Common/DataModel/vtkTable.cxx:232–288  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

230
231//------------------------------------------------------------------------------
232void vtkTable::MoveRowData(vtkIdType first, vtkIdType last, vtkIdType delta)
233{
234 if ((first < 0) || (last < 0) || (first > last) || (delta == 0))
235 {
236 return;
237 }
238
239 // determine the move direction
240 // if delta is positive then we need to start at the back of the source segment
241 // and work forwards, else at the beginning of the source segment and backwards
242 vtkIdType start = first;
243 vtkIdType stop = last;
244 vtkIdType step = +1;
245 if (delta > 0)
246 {
247 start = last;
248 stop = first;
249 step = -1;
250 }
251
252 vtkIdType ncol = this->GetNumberOfColumns();
253 for (vtkIdType i = 0; i < ncol; i++)
254 {
255 vtkAbstractArray* arr = this->GetColumn(i);
256 int comps = arr->GetNumberOfComponents();
257 if (vtkArrayDownCast<vtkDataArray>(arr))
258 {
259 vtkDataArray* data = vtkArrayDownCast<vtkDataArray>(arr);
260 for (vtkIdType row = start; row * step <= stop * step; row += step)
261 {
262 data->SetTuple(row + delta, row, data);
263 }
264 }
265 else if (vtkArrayDownCast<vtkStringArray>(arr))
266 {
267 vtkStringArray* data = vtkArrayDownCast<vtkStringArray>(arr);
268 for (vtkIdType row = start; row * step <= stop * step; row += step)
269 {
270 for (int j = 0; j < comps; j++)
271 {
272 data->SetValue((row + delta) * comps + j, data->GetValue(row * comps + j));
273 }
274 }
275 }
276 else if (vtkArrayDownCast<vtkVariantArray>(arr))
277 {
278 vtkVariantArray* data = vtkArrayDownCast<vtkVariantArray>(arr);
279 for (vtkIdType row = start; row * step <= stop * step; row += step)
280 {
281 for (int j = 0; j < comps; j++)
282 {
283 data->SetValue((row + delta) * comps + j, data->GetValue(row * comps + j));
284 }
285 }
286 }
287 }
288}
289

Callers 2

InsertRowsMethod · 0.95
RemoveRowsMethod · 0.95

Calls 6

GetNumberOfColumnsMethod · 0.95
GetColumnMethod · 0.95
GetNumberOfComponentsMethod · 0.45
SetTupleMethod · 0.45
SetValueMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected