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

Function ArrayTableToSparseArray

Infovis/Core/Testing/Cxx/ArrayTableToSparseArray.cxx:24–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22 } while (false)
23
24int ArrayTableToSparseArray(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
25{
26 try
27 {
28 // Generate an input table ...
29 vtkSmartPointer<vtkIdTypeArray> i = vtkSmartPointer<vtkIdTypeArray>::New();
30 i->SetName("i");
31
32 vtkSmartPointer<vtkIdTypeArray> j = vtkSmartPointer<vtkIdTypeArray>::New();
33 j->SetName("j");
34
35 vtkSmartPointer<vtkIdTypeArray> k = vtkSmartPointer<vtkIdTypeArray>::New();
36 k->SetName("k");
37
38 vtkSmartPointer<vtkDoubleArray> value = vtkSmartPointer<vtkDoubleArray>::New();
39 value->SetName("value");
40
41 vtkSmartPointer<vtkTable> table = vtkSmartPointer<vtkTable>::New();
42 table->AddColumn(i);
43 table->AddColumn(j);
44 table->AddColumn(k);
45 table->AddColumn(value);
46
47 table->InsertNextBlankRow();
48 table->SetValue(0, 0, 0);
49 table->SetValue(0, 1, 0);
50 table->SetValue(0, 2, 0);
51 table->SetValue(0, 3, 1);
52
53 table->InsertNextBlankRow();
54 table->SetValue(1, 0, 1);
55 table->SetValue(1, 1, 2);
56 table->SetValue(1, 2, 3);
57 table->SetValue(1, 3, 2);
58
59 table->InsertNextBlankRow();
60 table->SetValue(2, 0, 4);
61 table->SetValue(2, 1, 5);
62 table->SetValue(2, 2, 6);
63 table->SetValue(2, 3, 3);
64
65 // Run it through vtkTableToSparseArray ...
66 vtkSmartPointer<vtkTableToSparseArray> source = vtkSmartPointer<vtkTableToSparseArray>::New();
67 source->SetInputData(table);
68 source->AddCoordinateColumn("i");
69 source->AddCoordinateColumn("j");
70 source->AddCoordinateColumn("k");
71 source->SetValueColumn("value");
72 source->Update();
73 {
74 vtkSparseArray<double>* const sparse_array = vtkSparseArray<double>::SafeDownCast(
75 source->GetOutput()->GetArray(static_cast<vtkIdType>(0)));
76 test_expression(sparse_array);
77
78 sparse_array->Print(std::cerr);
79
80 test_expression(sparse_array->GetExtent(0) == vtkArrayRange(0, 5));
81 test_expression(sparse_array->GetExtent(1) == vtkArrayRange(0, 6));

Callers

nothing calls this directly

Calls 15

test_expressionFunction · 0.85
InsertNextBlankRowMethod · 0.80
AddCoordinateColumnMethod · 0.80
SetValueColumnMethod · 0.80
SetOutputExtentsMethod · 0.80
NewFunction · 0.50
SetNameMethod · 0.45
AddColumnMethod · 0.45
SetValueMethod · 0.45
SetInputDataMethod · 0.45
UpdateMethod · 0.45
GetArrayMethod · 0.45

Tested by

no test coverage detected