------------------------------------------------------------------------------ Set the number of arrays used to define the field.
| 370 | //------------------------------------------------------------------------------ |
| 371 | // Set the number of arrays used to define the field. |
| 372 | void vtkFieldData::AllocateArrays(int num) |
| 373 | { |
| 374 | num = std::max(num, 0); |
| 375 | |
| 376 | if (num == this->NumberOfArrays) |
| 377 | { |
| 378 | return; |
| 379 | } |
| 380 | |
| 381 | if (num == 0) |
| 382 | { |
| 383 | this->Initialize(); |
| 384 | } |
| 385 | else if (num < this->NumberOfArrays) |
| 386 | { |
| 387 | for (int i = num; i < this->NumberOfArrays; ++i) |
| 388 | { |
| 389 | if (this->Data[i]) |
| 390 | { |
| 391 | this->Data[i]->UnRegister(this); |
| 392 | } |
| 393 | } |
| 394 | this->NumberOfArrays = num; |
| 395 | } |
| 396 | else // num > this->NumberOfArrays |
| 397 | { |
| 398 | vtkAbstractArray** data = new vtkAbstractArray*[num]; |
| 399 | this->Ranges.resize(num); |
| 400 | this->FiniteRanges.resize(num); |
| 401 | // copy the original data |
| 402 | for (int i = 0; i < this->NumberOfArrays; ++i) |
| 403 | { |
| 404 | data[i] = this->Data[i]; |
| 405 | } |
| 406 | |
| 407 | // initialize the new arrays |
| 408 | for (int i = this->NumberOfArrays; i < num; ++i) |
| 409 | { |
| 410 | data[i] = nullptr; |
| 411 | } |
| 412 | |
| 413 | // get rid of the old data |
| 414 | delete[] this->Data; |
| 415 | |
| 416 | // update object |
| 417 | this->Data = data; |
| 418 | this->NumberOfArrays = num; |
| 419 | } |
| 420 | this->Modified(); |
| 421 | } |
| 422 | |
| 423 | //------------------------------------------------------------------------------ |
| 424 | // Set an array to define the field. |
no test coverage detected