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

Function ChangeComponents

IO/IOSS/vtkIOSSCellGridUtilities.cxx:64–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62};
63
64static vtkSmartPointer<vtkDataArray> ChangeComponents(vtkDataArray* array, int num_components)
65{
66 if (array == nullptr || (array->GetNumberOfComponents() == num_components))
67 {
68 return array;
69 }
70
71 vtkSmartPointer<vtkDataArray> result;
72 result.TakeReference(array->NewInstance());
73 result->SetName(array->GetName());
74 result->SetNumberOfComponents(num_components);
75 result->SetNumberOfTuples(array->GetNumberOfTuples());
76
77 ChangeComponentsImpl worker{ array };
78 using SupportedArrays = vtkIOSSUtilities::ArrayList;
79 using Dispatch = vtkArrayDispatch::DispatchByArray<SupportedArrays>;
80 if (!Dispatch::Execute(result, worker))
81 {
82 throw std::runtime_error("Failed to strip extra components from array!");
83 }
84 return result;
85}
86
87struct Swizzler
88{

Callers 1

GetShapeFunction · 0.70

Calls 9

ExecuteFunction · 0.50
GetNumberOfComponentsMethod · 0.45
TakeReferenceMethod · 0.45
NewInstanceMethod · 0.45
SetNameMethod · 0.45
GetNameMethod · 0.45
SetNumberOfComponentsMethod · 0.45
SetNumberOfTuplesMethod · 0.45
GetNumberOfTuplesMethod · 0.45

Tested by

no test coverage detected