------------------------------------------------------------------------------ Allocates point data for point-by-point (or cell-by-cell) copy operation. If sze=0, then use the input DataSetAttributes to create (i.e., find initial size of) new objects; otherwise use the sze variable.
| 657 | // If sze=0, then use the input DataSetAttributes to create (i.e., find |
| 658 | // initial size of) new objects; otherwise use the sze variable. |
| 659 | void vtkDataSetAttributes::InternalCopyAllocate(vtkDataSetAttributes* pd, int ctype, vtkIdType sze, |
| 660 | vtkIdType ext, int shallowCopyArrays, bool createNewArrays) |
| 661 | { |
| 662 | // Create various point data depending upon input |
| 663 | // |
| 664 | if (!pd) |
| 665 | { |
| 666 | return; |
| 667 | } |
| 668 | |
| 669 | if ((ctype < COPYTUPLE) || (ctype > PASSDATA)) |
| 670 | { |
| 671 | return; |
| 672 | } |
| 673 | |
| 674 | this->RequiredArrays = this->ComputeRequiredArrays(pd, ctype); |
| 675 | if (this->RequiredArrays.GetListSize() == 0) |
| 676 | { |
| 677 | return; |
| 678 | } |
| 679 | delete[] this->TargetIndices; |
| 680 | this->TargetIndices = new int[pd->GetNumberOfArrays()]; |
| 681 | for (int i = 0; i < pd->GetNumberOfArrays(); ++i) |
| 682 | { |
| 683 | this->TargetIndices[i] = -1; |
| 684 | } |
| 685 | |
| 686 | vtkAbstractArray* aa = nullptr; |
| 687 | int attributeType; |
| 688 | |
| 689 | // If we are not copying on self |
| 690 | if ((pd != this) && createNewArrays) |
| 691 | { |
| 692 | for (const auto& i : this->RequiredArrays) |
| 693 | { |
| 694 | // Create all required arrays |
| 695 | aa = pd->GetAbstractArray(i); |
| 696 | vtkAbstractArray* newAA; |
| 697 | if (shallowCopyArrays) |
| 698 | { |
| 699 | newAA = aa; |
| 700 | } |
| 701 | else |
| 702 | { |
| 703 | newAA = aa->NewInstance(); |
| 704 | newAA->SetNumberOfComponents(aa->GetNumberOfComponents()); |
| 705 | newAA->CopyComponentNames(aa); |
| 706 | newAA->SetName(aa->GetName()); |
| 707 | if (aa->HasInformation()) |
| 708 | { |
| 709 | newAA->CopyInformation(aa->GetInformation(), /*deep=*/1); |
| 710 | } |
| 711 | if (sze > 0) |
| 712 | { |
| 713 | newAA->Allocate(sze * aa->GetNumberOfComponents(), ext); |
| 714 | } |
| 715 | else |
| 716 | { |
no test coverage detected