| 62 | }; |
| 63 | |
| 64 | static 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 | |
| 87 | struct Swizzler |
| 88 | { |
no test coverage detected