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

Method AddTestArray

Filters/Hybrid/vtkTemporalFractal.cxx:957–1018  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

955
956//------------------------------------------------------------------------------
957void vtkTemporalFractal::AddTestArray(vtkOverlappingAMR* output)
958{
959 double* origin = this->GetTopLevelOrigin();
960
961 int levels = output->GetNumberOfLevels();
962 int level = 0;
963 while (level < levels)
964 {
965 int blocks = output->GetNumberOfBlocks(level);
966 int block = 0;
967 while (block < blocks)
968 {
969 vtkUniformGrid* grid;
970 grid = vtkUniformGrid::SafeDownCast(output->GetDataSetAsCartesianGrid(level, block));
971 assert("check: grid_exists" && grid != nullptr);
972
973 vtkDoubleArray* array = vtkDoubleArray::New();
974 int numCells = grid->GetNumberOfCells();
975 array->Allocate(numCells);
976 array->SetNumberOfTuples(numCells);
977 double* arrayPtr = static_cast<double*>(array->GetPointer(0));
978 double spacing[3];
979 grid->GetSpacing(spacing);
980 int x, y, z;
981 int ext[6];
982 grid->GetExtent(ext);
983 // we need cell extents but we just get point extents
984 if (ext[5] > 0)
985 {
986 --ext[5];
987 }
988 if (ext[3] > 0)
989 {
990 --ext[3];
991 }
992 if (ext[1] > 0)
993 {
994 --ext[1];
995 }
996 int debugcounter = 0;
997 for (z = ext[4]; z <= ext[5]; ++z)
998 {
999 for (y = ext[2]; y <= ext[3]; ++y)
1000 {
1001 for (x = ext[0]; x <= ext[1]; ++x)
1002 {
1003 *arrayPtr++ = origin[0] + spacing[0] * (static_cast<double>(x) + 0.5) + origin[1] +
1004 spacing[1] * (static_cast<double>(y) + 0.5);
1005 ++debugcounter;
1006 }
1007 }
1008 }
1009 assert("check: valid_debugcounter" && debugcounter == numCells);
1010 (void)debugcounter;
1011 array->SetName("TestX");
1012 grid->GetCellData()->AddArray(array);
1013 array->Delete();
1014 ++block;

Callers 1

RequestOneTimeStepMethod · 0.80

Calls 15

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

Tested by

no test coverage detected