------------------------------------------------------------------------------
| 326 | |
| 327 | //------------------------------------------------------------------------------ |
| 328 | int vtkEnzoReaderInternal::GetBlockAttribute( |
| 329 | const char* attribute, int blockIdx, vtkDataSet* pDataSet) |
| 330 | { |
| 331 | |
| 332 | // this function must be called by GetBlock( ... ) |
| 333 | this->ReadMetaData(); |
| 334 | |
| 335 | if (attribute == nullptr || blockIdx < 0 || pDataSet == nullptr || |
| 336 | blockIdx >= this->NumberOfBlocks) |
| 337 | { |
| 338 | return 0; |
| 339 | } |
| 340 | |
| 341 | // try obtaining the attribute and attaching it to the grid as a cell data |
| 342 | // NOTE: the 'equal' comparison below is MUST because in some cases (such |
| 343 | // as cosmological datasets) not all rectilinear blocks contain an assumably |
| 344 | // common block attribute. This is the case where such a block attribute |
| 345 | // may result from a particles-to-cells interpolation process. Thus those |
| 346 | // blocks with particles (e.g., the reference one with the fewest cells) |
| 347 | // contain it as a block attribute, whereas others without particles just |
| 348 | // do not contain this block attribute. |
| 349 | int succeeded = 0; |
| 350 | if (this->LoadAttribute(attribute, blockIdx) && |
| 351 | (pDataSet->GetNumberOfCells() == this->DataArray->GetNumberOfTuples())) |
| 352 | { |
| 353 | succeeded = 1; |
| 354 | pDataSet->GetCellData()->AddArray(this->DataArray); |
| 355 | this->ReleaseDataArray(); |
| 356 | } |
| 357 | |
| 358 | return succeeded; |
| 359 | } |
| 360 | |
| 361 | //------------------------------------------------------------------------------ |
| 362 | int vtkEnzoReaderInternal::LoadAttribute(const char* attribute, int blockIdx) |
no test coverage detected