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

Function merge

Filters/ParallelDIY2/vtkAdaptiveResampleToImage.cxx:96–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96bool merge(vtkImageData* target, std::vector<vtkSmartPointer<vtkImageData>>& sources)
97{
98 if (sources.empty())
99 {
100 return false;
101 }
102
103 if (sources.size() == 1)
104 {
105 target->ShallowCopy(sources[0]);
106 return true;
107 }
108
109 vtkDataSetAttributesFieldList ptList;
110 vtkDataSetAttributesFieldList cellList;
111 for (auto& image : sources)
112 {
113 ptList.IntersectFieldList(image->GetPointData());
114 cellList.IntersectFieldList(image->GetCellData());
115 }
116
117 target->Initialize();
118 target->CopyStructure(sources[0]);
119
120 auto opd = target->GetPointData();
121 opd->CopyAllOn();
122 opd->CopyAllocate(ptList, target->GetNumberOfPoints());
123 opd->SetNumberOfTuples(target->GetNumberOfPoints());
124 opd->CopyData(ptList, sources[0]->GetPointData(), 0, 0, target->GetNumberOfPoints(), 0);
125
126 auto ocd = target->GetCellData();
127 ocd->CopyAllOn();
128 ocd->CopyAllocate(cellList, target->GetNumberOfCells());
129 ocd->SetNumberOfTuples(target->GetNumberOfCells());
130 ocd->CopyData(cellList, sources[0]->GetCellData(), 0, 0, target->GetNumberOfCells(), 0);
131
132 for (int idx = 1; idx < static_cast<int>(sources.size()); ++idx)
133 {
134 auto inPD = sources[idx]->GetPointData();
135 if (auto ptids = get_ids(inPD, vtkDataSetAttributes::HIDDENPOINT))
136 {
137 ptList.TransformData(idx, inPD, opd,
138 [&ptids](vtkAbstractArray* in, vtkAbstractArray* out)
139 { out->InsertTuples(ptids, ptids, in); });
140 }
141
142 auto inCD = sources[idx]->GetCellData();
143 if (auto cellids = get_ids(inCD, vtkDataSetAttributes::HIDDENCELL))
144 {
145 cellList.TransformData(idx, inCD, ocd,
146 [&cellids](vtkAbstractArray* in, vtkAbstractArray* out)
147 { out->InsertTuples(cellids, cellids, in); });
148 }
149 }
150 return true;
151}
152VTK_ABI_NAMESPACE_END
153}

Callers 3

build_reverse_map_nlFunction · 0.85
MergePointsMethod · 0.85
RequestDataMethod · 0.85

Calls 15

get_idsFunction · 0.85
IntersectFieldListMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
ShallowCopyMethod · 0.45
GetPointDataMethod · 0.45
GetCellDataMethod · 0.45
InitializeMethod · 0.45
CopyStructureMethod · 0.45
CopyAllOnMethod · 0.45
CopyAllocateMethod · 0.45
GetNumberOfPointsMethod · 0.45

Tested by

no test coverage detected