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

Function FillCellArrays

Filters/FlowPaths/vtkParticlePathFilter.cxx:21–55  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

19
20//------------------------------------------------------------------------------
21void FillCellArrays(vtkCellArray* verts, vtkCellArray* lines,
22 const std::map<vtkIdType, std::vector<vtkIdType>>& paths)
23{
24 using ArrayType64 = vtkCellArray::AOSArray64;
25 vtkNew<ArrayType64> vertsConnectivity, vertsOffsets, linesConnectivity, linesOffsets;
26 vertsOffsets->InsertNextValue(0);
27 linesOffsets->InsertNextValue(0);
28 vtkIdType nverts = 0, nlines = 0;
29
30 for (const auto& pair : paths)
31 {
32 const auto& path = pair.second;
33 auto insertNextCell = [&path](ArrayType64* connectivity, ArrayType64* offsets, vtkIdType& n)
34 {
35 for (vtkIdType id = n; id < n + static_cast<vtkIdType>(path.size()); ++id)
36 {
37 connectivity->InsertNextValue(id);
38 }
39 n += path.size();
40 offsets->InsertNextValue(n);
41 };
42
43 if (path.size() == 1)
44 {
45 insertNextCell(vertsConnectivity, vertsOffsets, nverts);
46 }
47 else
48 {
49 insertNextCell(linesConnectivity, linesOffsets, nlines);
50 }
51 }
52
53 verts->SetData(vertsOffsets, vertsConnectivity);
54 lines->SetData(linesOffsets, linesConnectivity);
55}
56} // anonymous namespace
57
58//------------------------------------------------------------------------------

Callers 1

FinalizeMethod · 0.70

Calls 3

InsertNextValueMethod · 0.45
sizeMethod · 0.45
SetDataMethod · 0.45

Tested by

no test coverage detected