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

Function TestArrayDataWriter

IO/Core/Testing/Cxx/TestArrayDataWriter.cxx:13–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11#include <iostream>
12
13int TestArrayDataWriter(int, char*[])
14{
15 std::cerr << "Testing dense first..." << std::endl;
16
17 vtkNew<vtkDenseArray<double>> da;
18 da->Resize(10, 10);
19 da->SetName("dense");
20 vtkNew<vtkSparseArray<double>> sa;
21 sa->Resize(10, 10);
22 sa->SetName("sparse");
23 for (int i = 0; i < 10; ++i)
24 {
25 sa->SetValue(i, 0, i);
26 for (int j = 0; j < 10; ++j)
27 {
28 da->SetValue(i, j, i * j);
29 }
30 }
31
32 vtkNew<vtkArrayData> d;
33 d->AddArray(da);
34 d->AddArray(sa);
35
36 vtkNew<vtkArrayDataWriter> w;
37 w->SetInputData(d);
38 w->WriteToOutputStringOn();
39 w->Write();
40 std::string s = w->GetOutputString();
41
42 vtkNew<vtkArrayDataReader> r;
43 r->ReadFromInputStringOn();
44 r->SetInputString(s);
45 r->Update();
46 vtkArrayData* d_out = r->GetOutput();
47
48 if (d_out->GetNumberOfArrays() != 2)
49 {
50 std::cerr << "Wrong number of arrays" << std::endl;
51 return 1;
52 }
53
54 vtkArray* da_out = d_out->GetArray(0);
55 if (da_out->GetDimensions() != 2)
56 {
57 std::cerr << "da wrong number of dimensions" << std::endl;
58 return 1;
59 }
60 if (!da_out->IsDense())
61 {
62 std::cerr << "da wrong array type" << std::endl;
63 return 1;
64 }
65 if (da_out->GetSize() != 100)
66 {
67 std::cerr << "da wrong array size" << std::endl;
68 return 1;
69 }
70

Callers

nothing calls this directly

Calls 14

ResizeMethod · 0.45
SetNameMethod · 0.45
SetValueMethod · 0.45
AddArrayMethod · 0.45
SetInputDataMethod · 0.45
WriteMethod · 0.45
SetInputStringMethod · 0.45
UpdateMethod · 0.45
GetOutputMethod · 0.45
GetNumberOfArraysMethod · 0.45
GetArrayMethod · 0.45
GetDimensionsMethod · 0.45

Tested by

no test coverage detected