------------------------------------------------------------------------------
| 1523 | |
| 1524 | //------------------------------------------------------------------------------ |
| 1525 | vtkDataArray* vtkExodusIIReaderPrivate::GetCacheOrRead(vtkExodusIICacheKey key) |
| 1526 | { |
| 1527 | vtkDataArray* arr; |
| 1528 | // Never cache points deflected for a mode shape animation... doubles don't make good keys. |
| 1529 | if (this->HasModeShapes && key.ObjectType == vtkExodusIIReader::NODAL_COORDS) |
| 1530 | { |
| 1531 | arr = nullptr; |
| 1532 | } |
| 1533 | else |
| 1534 | { |
| 1535 | arr = this->Cache->Find(key); |
| 1536 | } |
| 1537 | |
| 1538 | if (arr) |
| 1539 | { |
| 1540 | // |
| 1541 | return arr; |
| 1542 | } |
| 1543 | |
| 1544 | int exoid = this->Exoid; |
| 1545 | int maxNameLength = this->Parent->GetMaxNameLength(); |
| 1546 | |
| 1547 | // If array is nullptr, try reading it from file. |
| 1548 | if (key.ObjectType == vtkExodusIIReader::GLOBAL) |
| 1549 | { |
| 1550 | // need to assemble result array from smaller ones. |
| 1551 | // call GetCacheOrRead() for each smaller array |
| 1552 | // pay attention to SqueezePoints |
| 1553 | |
| 1554 | // ArrayInfoType* ainfop = &this->ArrayInfo[vtkExodusIIReader::GLOBAL][key.ArrayId]; |
| 1555 | auto doubleArray = vtkDoubleArray::New(); |
| 1556 | arr = doubleArray; |
| 1557 | arr->SetName(vtkExodusIIReaderPrivate::GetGlobalVariableValuesArrayName()); |
| 1558 | arr->SetNumberOfComponents(1); |
| 1559 | arr->SetNumberOfTuples( |
| 1560 | static_cast<vtkIdType>(this->ArrayInfo[vtkExodusIIReader::GLOBAL].size())); |
| 1561 | |
| 1562 | if (ex_get_glob_vars( |
| 1563 | exoid, key.Time + 1, arr->GetNumberOfTuples(), doubleArray->GetPointer(0)) < 0) |
| 1564 | { |
| 1565 | vtkErrorMacro( |
| 1566 | "Could not read global variable " << this->GetGlobalVariableValuesArrayName() << "."); |
| 1567 | arr->Delete(); |
| 1568 | arr = nullptr; |
| 1569 | } |
| 1570 | auto info = arr->GetInformation(); |
| 1571 | // add the `GLOBAL_VARIABLE` key so filters may use it. |
| 1572 | info->Set(vtkExodusIIReader::GLOBAL_VARIABLE(), 1); |
| 1573 | } |
| 1574 | else if (key.ObjectType == vtkExodusIIReader::NODAL) |
| 1575 | { |
| 1576 | // read nodal array |
| 1577 | ArrayInfoType* ainfop = &this->ArrayInfo[vtkExodusIIReader::NODAL][key.ArrayId]; |
| 1578 | int ncomps = |
| 1579 | (this->ModelParameters.num_dim == 2 && ainfop->Components == 2) ? 3 : ainfop->Components; |
| 1580 | arr = vtkDataArray::CreateDataArray(ainfop->StorageType); |
| 1581 | assert(arr->HasStandardMemoryLayout() && "Array must have standard memory layout"); |
| 1582 | arr->SetName(ainfop->Name.c_str()); |
no test coverage detected