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

Method InternalCopyAllocate

Common/DataModel/vtkDataSetAttributes.cxx:659–762  ·  view source on GitHub ↗

------------------------------------------------------------------------------ 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.

Source from the content-addressed store, hash-verified

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.
659void 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 {

Callers 3

SetupForCopyMethod · 0.95
CopyAllocateMethod · 0.95
InterpolateAllocateMethod · 0.95

Calls 15

ComputeRequiredArraysMethod · 0.95
SetActiveAttributeMethod · 0.95
GetListSizeMethod · 0.80
GetAbstractArrayMethod · 0.80
CopyComponentNamesMethod · 0.80
IsArrayAnAttributeMethod · 0.80
DeleteMethod · 0.65
GetNumberOfArraysMethod · 0.45
NewInstanceMethod · 0.45
SetNumberOfComponentsMethod · 0.45
GetNumberOfComponentsMethod · 0.45
SetNameMethod · 0.45

Tested by

no test coverage detected