| 15 | #include <iostream> |
| 16 | |
| 17 | int TestThreadedCopy(int ac, char* av[]) |
| 18 | { |
| 19 | double GB = 0.01; |
| 20 | bool write = false; |
| 21 | |
| 22 | for (int i = 0; i < ac; ++i) |
| 23 | { |
| 24 | if (i < ac - 1 && !strcmp(av[i], "--numThreads")) |
| 25 | { |
| 26 | int numThreads; |
| 27 | VTK_FROM_CHARS_IF_ERROR_RETURN(av[i + 1], numThreads, EXIT_FAILURE); |
| 28 | vtkSMPTools::Initialize(numThreads); |
| 29 | } |
| 30 | if (i < ac - 1 && !strcmp(av[i], "--GB")) |
| 31 | { |
| 32 | VTK_FROM_CHARS_IF_ERROR_RETURN(av[i + 1], GB, EXIT_FAILURE); |
| 33 | } |
| 34 | if (!strcmp(av[i], "--write")) |
| 35 | { |
| 36 | write = true; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | vtkImageData* hugeImage = vtkImageData::New(); |
| 41 | int edge = static_cast<int>(pow((1024l * 1024 * 1024 * GB) / (3 * VTK_SIZEOF_INT), 1 / 3.)); |
| 42 | hugeImage->SetDimensions(edge, edge, edge); |
| 43 | hugeImage->AllocateScalars(VTK_INT, 3); |
| 44 | |
| 45 | if (write) |
| 46 | { |
| 47 | std::cout << "Populate it." << std::endl; |
| 48 | int* ptr = static_cast<int*>(hugeImage->GetScalarPointer()); |
| 49 | for (int k = 0; k < edge; ++k) |
| 50 | { |
| 51 | double z = (double)k / edge - 0.5; |
| 52 | if (k % (edge / 10) == 0) |
| 53 | { |
| 54 | std::cout << (z + 0.5) * 100 << "% done" << std::endl; |
| 55 | } |
| 56 | for (int j = 0; j < edge; ++j) |
| 57 | { |
| 58 | double y = (double)j / edge - 0.5; |
| 59 | for (int i = 0; i < edge; ++i) |
| 60 | { |
| 61 | double x = (double)i / edge - 0.5; |
| 62 | *ptr = 42; |
| 63 | ++ptr; |
| 64 | *ptr = (int)((x * y * z + 0.125) * 4.0 * VTK_INT_MAX); |
| 65 | ++ptr; |
| 66 | *ptr = (int)x; |
| 67 | ++ptr; |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | vtkImageData* d = vtkImageData::New(); |
| 74 | d->DeepCopy(hugeImage); |
nothing calls this directly
no test coverage detected