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

Method AddVectorArray

Filters/Hybrid/vtkTemporalFractal.cxx:1021–1081  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1019
1020//------------------------------------------------------------------------------
1021void vtkTemporalFractal::AddVectorArray(vtkOverlappingAMR* output)
1022{
1023 double* origin = this->GetTopLevelOrigin();
1024
1025 int levels = output->GetNumberOfLevels();
1026 int level = 0;
1027 while (level < levels)
1028 {
1029 int blocks = output->GetNumberOfBlocks(level);
1030 int block = 0;
1031 while (block < blocks)
1032 {
1033 vtkUniformGrid* grid;
1034 grid = vtkUniformGrid::SafeDownCast(output->GetDataSetAsCartesianGrid(level, block));
1035 assert("check: grid_exists" && grid != nullptr);
1036
1037 vtkDoubleArray* array = vtkDoubleArray::New();
1038 array->SetNumberOfComponents(3);
1039 int numCells = grid->GetNumberOfCells();
1040 array->Allocate(numCells);
1041 array->SetNumberOfTuples(numCells);
1042 double* arrayPtr = static_cast<double*>(array->GetPointer(0));
1043 double spacing[3];
1044 grid->GetSpacing(spacing);
1045 int x, y, z;
1046 int ext[6];
1047 grid->GetExtent(ext);
1048 // we need cell extents but we just get point extents
1049 if (ext[5] > 0)
1050 {
1051 --ext[5];
1052 }
1053 if (ext[3] > 0)
1054 {
1055 --ext[3];
1056 }
1057 if (ext[1] > 0)
1058 {
1059 --ext[1];
1060 }
1061
1062 for (z = ext[4]; z <= ext[5]; ++z)
1063 {
1064 for (y = ext[2]; y <= ext[3]; ++y)
1065 {
1066 for (x = ext[0]; x <= ext[1]; ++x)
1067 {
1068 *arrayPtr++ = origin[0] + spacing[0] * (static_cast<double>(x) + 0.5);
1069 *arrayPtr++ = origin[1] + spacing[1] * (static_cast<double>(y) + 0.5);
1070 *arrayPtr++ = origin[2] + spacing[2] * (static_cast<double>(z) + 0.5);
1071 }
1072 }
1073 }
1074 array->SetName("VectorXYZ");
1075 grid->GetCellData()->AddArray(array);
1076 array->Delete();
1077 ++block;
1078 }

Callers 1

RequestOneTimeStepMethod · 0.80

Calls 15

DeleteMethod · 0.65
assertFunction · 0.50
NewFunction · 0.50
GetNumberOfLevelsMethod · 0.45
GetNumberOfBlocksMethod · 0.45
SetNumberOfComponentsMethod · 0.45
GetNumberOfCellsMethod · 0.45
AllocateMethod · 0.45
SetNumberOfTuplesMethod · 0.45
GetPointerMethod · 0.45
GetSpacingMethod · 0.45

Tested by

no test coverage detected