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

Method DeepCopy

Common/Core/vtkVariantArray.cxx:504–550  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

502
503//------------------------------------------------------------------------------
504void vtkVariantArray::DeepCopy(vtkAbstractArray* aa)
505{
506 // Do nothing on a nullptr input.
507 if (!aa)
508 {
509 return;
510 }
511
512 // Avoid self-copy.
513 if (this == aa)
514 {
515 return;
516 }
517
518 // If data type does not match, we can't copy.
519 if (aa->GetDataType() != this->GetDataType())
520 {
521 vtkErrorMacro(<< "Incompatible types: tried to copy an array of type "
522 << aa->GetDataTypeAsString() << " into a variant array ");
523 return;
524 }
525
526 vtkVariantArray* va = vtkArrayDownCast<vtkVariantArray>(aa);
527 if (va == nullptr)
528 {
529 vtkErrorMacro(<< "Shouldn't Happen: Couldn't downcast array into a vtkVariantArray.");
530 return;
531 }
532
533 // Free our previous memory.
534 if (this->DeleteFunction)
535 {
536 this->DeleteFunction(this->Array);
537 }
538
539 // Copy the given array into new memory.
540 this->MaxId = va->GetMaxId();
541 this->Size = va->GetSize();
542 this->DeleteFunction = DefaultDeleteFunction;
543 this->Array = new ValueType[this->Size];
544
545 for (int i = 0; i < (this->MaxId + 1); ++i)
546 {
547 this->Array[i] = va->Array[i];
548 }
549 this->DataChanged();
550}
551
552//------------------------------------------------------------------------------
553void vtkVariantArray::InterpolateTuple(

Callers 1

UpdateLookupMethod · 0.45

Calls 3

GetDataTypeMethod · 0.95
DataChangedMethod · 0.95
GetSizeMethod · 0.45

Tested by

no test coverage detected