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

Function MatchArrayTypes

IO/XML/vtkXMLUnstructuredDataReader.cxx:36–56  ·  view source on GitHub ↗

Ensures that array1 and array2 are of the same type. Returns a pair with array type selected as follows: if both arrays have different element bytesize, the one with the larger size is chosen if both arrays have different element types, then the type for the second argument is chosen

Source from the content-addressed store, hash-verified

34// * if both arrays have different element types, then the type for the second
35// argument is chosen
36std::pair<vtkSmartPointer<vtkDataArray>, vtkSmartPointer<vtkDataArray>> MatchArrayTypes(
37 vtkSmartPointer<vtkDataArray> array1, vtkSmartPointer<vtkDataArray> array2)
38{
39 if (array1->GetElementComponentSize() > array2->GetElementComponentSize())
40 {
41 auto new2 = vtk::TakeSmartPointer(array1->NewInstance());
42 new2->DeepCopy(array2);
43 return std::make_pair(array1, new2);
44 }
45 else if (array2->GetElementComponentSize() > array1->GetElementComponentSize() ||
46 array1->GetDataType() != array2->GetDataType())
47 {
48 auto new1 = vtk::TakeSmartPointer(array2->NewInstance());
49 new1->DeepCopy(array1);
50 return std::make_pair(new1, array2);
51 }
52 else
53 {
54 return std::make_pair(array1, array2);
55 }
56}
57
58}
59

Callers 2

ReadCellArrayMethod · 0.85

Calls 4

NewInstanceMethod · 0.45
DeepCopyMethod · 0.45
GetDataTypeMethod · 0.45

Tested by

no test coverage detected