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

Method SetArray

Common/DataModel/vtkFieldData.cxx:425–482  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Set an array to define the field.

Source from the content-addressed store, hash-verified

423//------------------------------------------------------------------------------
424// Set an array to define the field.
425void vtkFieldData::SetArray(int i, vtkAbstractArray* data)
426{
427 if (!data || (i > this->NumberOfActiveArrays))
428 {
429 vtkWarningMacro("Can not set array " << i << " to " << data << endl);
430 return;
431 }
432
433 if (i < 0)
434 {
435 vtkWarningMacro("Array index should be >= 0");
436 return;
437 }
438 else if (i >= this->NumberOfArrays)
439 {
440 this->AllocateArrays(i + 1);
441 this->NumberOfActiveArrays = i + 1;
442 }
443
444 const char* name = data->GetName();
445 if (name && strcmp(name, vtkFieldData::GhostArrayName()) == 0)
446 {
447 this->GhostArray = vtkArrayDownCast<vtkUnsignedCharArray>(data);
448 }
449
450 if (this->Data[i] != data)
451 {
452 if (this->Data[i] != nullptr)
453 {
454 this->Data[i]->UnRegister(this);
455 }
456 this->Data[i] = data;
457 if (this->Data[i] != nullptr)
458 {
459 // range[0] -> cached range for comp == -1
460 // range[1] -> cached range for comp in [0, number of components - 1]
461 // std::get<0> -> cached array MTime
462 // std::get<1> -> cached ghost array MTime
463 // std::get<2> -> cached range buffer
464 auto& finiteRange = this->FiniteRanges[i];
465 std::get<0>(finiteRange[0]) = 0;
466 std::get<1>(finiteRange[0]) = 0;
467 std::get<2>(finiteRange[0]).resize(2);
468 std::get<0>(finiteRange[1]) = 0;
469 std::get<1>(finiteRange[1]) = 0;
470 std::get<2>(finiteRange[1]).resize(2 * data->GetNumberOfComponents());
471 auto& range = this->Ranges[i];
472 std::get<0>(range[0]) = 0;
473 std::get<1>(range[0]) = 0;
474 std::get<2>(range[0]).resize(2);
475 std::get<0>(range[1]) = 0;
476 std::get<1>(range[1]) = 0;
477 std::get<2>(range[1]).resize(2 * data->GetNumberOfComponents());
478 this->Data[i]->Register(this);
479 }
480 this->Modified();
481 }
482}

Callers 15

CopyStructureMethod · 0.95
ShallowCopyMethod · 0.95
AddArrayMethod · 0.95
PassDataMethod · 0.95
operator()Method · 0.45
operator()Method · 0.45
Deserialize_vtkFieldDataFunction · 0.45
testImportExportMethod · 0.45
MakeCubeFunction · 0.45
MakeDodecahedronFunction · 0.45
MakePolyhedron1Function · 0.45
MakePolyhedron2Function · 0.45

Calls 8

AllocateArraysMethod · 0.95
GhostArrayNameFunction · 0.85
GetNameMethod · 0.45
UnRegisterMethod · 0.45
resizeMethod · 0.45
GetNumberOfComponentsMethod · 0.45
RegisterMethod · 0.45
ModifiedMethod · 0.45

Tested by 9

testImportExportMethod · 0.36
MakeCubeFunction · 0.36
MakeDodecahedronFunction · 0.36
MakePolyhedron1Function · 0.36
MakePolyhedron2Function · 0.36
TestPolyhedronContouringFunction · 0.36
MakeDodecahedronFunction · 0.36
MakeConcavePolyhedronFunction · 0.36