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

Method GetAttributeTypeForArray

Common/DataModel/vtkCellGrid.cxx:227–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225}
226
227int vtkCellGrid::GetAttributeTypeForArray(vtkAbstractArray* arr)
228{
229 // First, see if the array is marked with a group for fast lookup.
230 if (arr->HasInformation())
231 {
232 auto* info = arr->GetInformation();
233 if (info->Has(ARRAY_GROUP_IDS()))
234 {
235 int numGroups = info->Length(vtkCellGrid::ARRAY_GROUP_IDS());
236 int* groupIds = info->Get(vtkCellGrid::ARRAY_GROUP_IDS());
237 for (int gg = 0; gg < numGroups; ++gg)
238 {
239 if (auto* group = this->FindAttributes(groupIds[gg]))
240 {
241 if (auto* array = group->GetAbstractArray(arr->GetName()))
242 {
243 if (array != arr)
244 {
245 // NB: We might update info by rewriting ARRAY_GROUP_IDS to
246 // exclude groupIds[gg], but it is possible – because
247 // arrays are shallow-copied – that they may end up in
248 // multiple groups across multiple instances of
249 // vtkCellGrid and we do not necessarily want to de-index
250 // arr across all cell-grids.
251 continue;
252 }
253 return groupIds[gg];
254 }
255 }
256 }
257 }
258 }
259
260 // Next, search through DOF arrays:
261 for (auto it = this->ArrayGroups.begin(); it != this->ArrayGroups.end(); ++it)
262 {
263 for (int ii = 0; ii < it->second->GetNumberOfArrays(); ++ii)
264 {
265 if (it->second->GetAbstractArray(ii) == arr)
266 {
267 // Accelerate next lookup by adding the result.
268 arr->GetInformation()->Append(ARRAY_GROUP_IDS(), it->first);
269 return it->first;
270 }
271 }
272 }
273
274 // If not a DOF array, perhaps it is field data:
275 for (int ii = 0; ii < this->FieldData->GetNumberOfArrays(); ++ii)
276 {
277 if (this->FieldData->GetAbstractArray(ii) == arr)
278 {
279 return FIELD;
280 }
281 }
282 // No such array is owned by this vtkCellGrid:
283 return -1;
284}

Callers 3

RequestDataMethod · 0.45
CopyAttributeArraysMethod · 0.45
CopySpecMethod · 0.45

Calls 11

FindAttributesMethod · 0.95
GetAbstractArrayMethod · 0.80
GetInformationMethod · 0.45
HasMethod · 0.45
LengthMethod · 0.45
GetMethod · 0.45
GetNameMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetNumberOfArraysMethod · 0.45
AppendMethod · 0.45

Tested by

no test coverage detected