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

Function TestCompressible

Filters/Reduction/Testing/Cxx/TestToImplicitArrayFilter.cxx:18–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16namespace
17{
18int TestCompressible()
19{
20 vtkNew<vtkSphereSource> sphere;
21 sphere->Update();
22
23 vtkPolyData* output = vtkPolyData::SafeDownCast(sphere->GetOutput());
24
25 auto pointData = output->GetPointData();
26
27 vtkNew<vtkIntArray> constArr;
28 constArr->SetNumberOfComponents(2);
29 constArr->SetNumberOfTuples(output->GetNumberOfPoints());
30 constArr->Fill(42);
31 constArr->SetName("Constant");
32 pointData->AddArray(constArr);
33
34 vtkNew<vtkToImplicitArrayFilter> toImpArr;
35 vtkNew<vtkToConstantArrayStrategy> strat;
36 toImpArr->SetStrategy(strat);
37 toImpArr->SetInputConnection(sphere->GetOutputPort());
38 auto select = toImpArr->GetPointDataArraySelection();
39 select->EnableArray("Constant");
40 toImpArr->Update();
41
42 output = vtkPolyData::SafeDownCast(toImpArr->GetOutput());
43 if (!output)
44 {
45 std::cout << "Output of filter is not poly data" << std::endl;
46 return EXIT_FAILURE;
47 }
48
49 pointData = output->GetPointData();
50
51 vtkConstantArray<int>* arr =
52 vtkArrayDownCast<vtkConstantArray<int>>(pointData->GetArray("Constant"));
53 if (!arr)
54 {
55 std::cout << "Does not have constant array in output" << std::endl;
56 return EXIT_FAILURE;
57 }
58
59 if (arr->GetNumberOfComponents() != constArr->GetNumberOfComponents())
60 {
61 std::cout << "Resulting compressed array does not have correct number of components"
62 << std::endl;
63 return EXIT_FAILURE;
64 }
65
66 if (arr->GetNumberOfTuples() != constArr->GetNumberOfTuples())
67 {
68 std::cout << "Resulting compressed array does not have correct number of tuples" << std::endl;
69 return EXIT_FAILURE;
70 }
71
72 for (int iV = 0; iV < output->GetNumberOfPoints() * 2; ++iV)
73 {
74 if (constArr->GetValue(iV) != arr->GetValue(iV))
75 {

Callers 1

Calls 15

EnableArrayMethod · 0.80
UpdateMethod · 0.45
GetOutputMethod · 0.45
GetPointDataMethod · 0.45
SetNumberOfComponentsMethod · 0.45
SetNumberOfTuplesMethod · 0.45
GetNumberOfPointsMethod · 0.45
FillMethod · 0.45
SetNameMethod · 0.45
AddArrayMethod · 0.45
SetStrategyMethod · 0.45
SetInputConnectionMethod · 0.45

Tested by

no test coverage detected