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

Function JoinArrays

IO/IOSS/vtkIOSSReaderCommunication.h:76–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76vtkSmartPointer<vtkAbstractArray> JoinArrays(
77 const std::vector<vtkSmartPointer<vtkAbstractArray>>& arrays)
78{
79 if (arrays.empty())
80 {
81 return nullptr;
82 }
83 else if (arrays.size() == 1)
84 {
85 return arrays[0];
86 }
87
88 vtkIdType numTuples = 0;
89 for (auto& array : arrays)
90 {
91 numTuples += array->GetNumberOfTuples();
92 }
93
94 vtkSmartPointer<vtkAbstractArray> result;
95 result.TakeReference(arrays[0]->NewInstance());
96 result->CopyInformation(arrays[0]->GetInformation());
97 result->SetName(arrays[0]->GetName());
98 result->SetNumberOfComponents(arrays[0]->GetNumberOfComponents());
99 result->SetNumberOfTuples(numTuples);
100 vtkIdType offset = 0;
101 for (auto& array : arrays)
102 {
103 const auto count = array->GetNumberOfTuples();
104 result->InsertTuples(offset, count, 0, array);
105 offset += count;
106 }
107 result->Modified();
108 assert(offset == numTuples);
109 return result;
110}
111
112} // end of namespace {}
113VTK_ABI_NAMESPACE_END

Callers 1

GetFieldMethod · 0.85

Calls 15

assertFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
GetNumberOfTuplesMethod · 0.45
TakeReferenceMethod · 0.45
NewInstanceMethod · 0.45
CopyInformationMethod · 0.45
GetInformationMethod · 0.45
SetNameMethod · 0.45
GetNameMethod · 0.45
SetNumberOfComponentsMethod · 0.45
GetNumberOfComponentsMethod · 0.45

Tested by

no test coverage detected