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

Method XdmfToVTKAttributes

IO/Xdmf3/vtkXdmf3DataSet.cxx:349–520  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

347
348//------------------------------------------------------------------------------
349void vtkXdmf3DataSet::XdmfToVTKAttributes(vtkXdmf3ArraySelection* fselection,
350 vtkXdmf3ArraySelection* cselection, vtkXdmf3ArraySelection* pselection, XdmfGrid* grid,
351 vtkDataObject* dObject, vtkXdmf3ArrayKeeper* keeper)
352{
353 vtkDataSet* dataSet = vtkDataSet::SafeDownCast(dObject);
354 if (!dataSet)
355 {
356 return;
357 }
358 unsigned int numCells = dataSet->GetNumberOfCells();
359 unsigned int numPoints = dataSet->GetNumberOfPoints();
360 unsigned int numAttributes = grid->getNumberAttributes();
361 for (unsigned int cc = 0; cc < numAttributes; cc++)
362 {
363 shared_ptr<XdmfAttribute> xmfAttribute = grid->getAttribute(cc);
364 std::string attrName = xmfAttribute->getName();
365 if (attrName.empty())
366 {
367 std::cerr << "Skipping unnamed array." << endl;
368 continue;
369 }
370
371 // figure out how many components in this array
372 std::vector<unsigned int> dims = xmfAttribute->getDimensions();
373 unsigned int ndims = static_cast<unsigned int>(dims.size());
374 unsigned int nvals = 1;
375 for (unsigned int i = 0; i < dims.size(); i++)
376 {
377 nvals = nvals * dims[i];
378 }
379
380 unsigned int ncomp = 1;
381
382 vtkFieldData* fieldData = nullptr;
383
384 shared_ptr<const XdmfAttributeCenter> attrCenter = xmfAttribute->getCenter();
385 if (attrCenter == XdmfAttributeCenter::Grid())
386 {
387 if (!fselection->ArrayIsEnabled(attrName.c_str()))
388 {
389 continue;
390 }
391 fieldData = dataSet->GetFieldData();
392 ncomp = dims[ndims - 1];
393 }
394 else if (attrCenter == XdmfAttributeCenter::Cell())
395 {
396 if (!cselection->ArrayIsEnabled(attrName.c_str()))
397 {
398 continue;
399 }
400 if (numCells == 0)
401 {
402 continue;
403 }
404 fieldData = dataSet->GetCellData();
405 ncomp = nvals / numCells;
406 }

Callers

nothing calls this directly

Calls 15

VectorFunction · 0.85
getCenterMethod · 0.80
getItemTypeMethod · 0.80
SetScalarsMethod · 0.80
SetVectorsMethod · 0.80
SetTensorsMethod · 0.80
GetGlobalIdsMethod · 0.80
SetGlobalIdsMethod · 0.80
DeleteMethod · 0.65
GridClass · 0.50
CellClass · 0.50
NodeClass · 0.50

Tested by

no test coverage detected