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

Function TestTableToArray

Infovis/Core/Testing/Cxx/TestTableToArray.cxx:29–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27 } while (false)
28
29int TestTableToArray(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
30{
31 try
32 {
33 VTK_CREATE(vtkTable, table);
34
35 VTK_CREATE(vtkIntArray, int_array);
36 int_array->SetName("A");
37 int_array->InsertNextValue(1);
38 int_array->InsertNextValue(2);
39 int_array->InsertNextValue(3);
40 int_array->InsertNextValue(4);
41 table->AddColumn(int_array);
42
43 VTK_CREATE(vtkDoubleArray, double_array);
44 double_array->SetName("B");
45 double_array->InsertNextValue(1.1);
46 double_array->InsertNextValue(1.2);
47 double_array->InsertNextValue(1.3);
48 double_array->InsertNextValue(1.4);
49 table->AddColumn(double_array);
50
51 VTK_CREATE(vtkStringArray, string_array);
52 string_array->SetName("C");
53 string_array->InsertNextValue("11");
54 string_array->InsertNextValue("12");
55 string_array->InsertNextValue("13");
56 string_array->InsertNextValue("14");
57 table->AddColumn(string_array);
58
59 VTK_CREATE(vtkTableToArray, table_to_array);
60 table_to_array->SetInputData(0, table);
61 table_to_array->AddColumn("C");
62 table_to_array->AddColumn(1);
63 table_to_array->AddColumn(static_cast<vtkIdType>(0));
64 table_to_array->AddAllColumns();
65
66 table_to_array->Update();
67 test_expression(table_to_array->GetOutput());
68 test_expression(1 == table_to_array->GetOutput()->GetNumberOfArrays());
69 vtkDenseArray<double>* const array =
70 vtkDenseArray<double>::SafeDownCast(table_to_array->GetOutput()->GetArray(0));
71 test_expression(array);
72 test_expression(2 == array->GetDimensions());
73 test_expression(4 == array->GetExtent(0).GetSize());
74 test_expression(6 == array->GetExtent(1).GetSize());
75 test_expression(11 == array->GetValue(0, 0));
76 test_expression(1.1 == array->GetValue(0, 1));
77 test_expression(1 == array->GetValue(0, 2));
78 test_expression(1 == array->GetValue(0, 3));
79 test_expression(1.1 == array->GetValue(0, 4));
80 test_expression(11 == array->GetValue(0, 5));
81 test_expression(14 == array->GetValue(3, 0));
82
83 vtkPrintMatrixFormat(std::cout, array);
84
85 return 0;
86 }

Callers

nothing calls this directly

Calls 15

test_expressionFunction · 0.85
AddAllColumnsMethod · 0.80
SetNameMethod · 0.45
InsertNextValueMethod · 0.45
AddColumnMethod · 0.45
SetInputDataMethod · 0.45
UpdateMethod · 0.45
GetOutputMethod · 0.45
GetNumberOfArraysMethod · 0.45
GetArrayMethod · 0.45
GetDimensionsMethod · 0.45
GetSizeMethod · 0.45

Tested by

no test coverage detected