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

Method AllocateArrays

Common/DataModel/vtkFieldData.cxx:372–421  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Set the number of arrays used to define the field.

Source from the content-addressed store, hash-verified

370//------------------------------------------------------------------------------
371// Set the number of arrays used to define the field.
372void 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.

Callers 4

CopyStructureMethod · 0.95
SetArrayMethod · 0.95
ShallowCopyMethod · 0.95
PassDataMethod · 0.95

Calls 5

InitializeMethod · 0.95
maxFunction · 0.50
UnRegisterMethod · 0.45
resizeMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected