------------------------------------------------------------------------------
| 1573 | |
| 1574 | //------------------------------------------------------------------------------ |
| 1575 | bool vtkEnSightGoldBinaryReader::ReadVariableArray(const char* description, |
| 1576 | vtkMultiBlockDataSet* compositeOutput, int attributeType, int numComponents, |
| 1577 | int component /*=-1*/) |
| 1578 | { |
| 1579 | char line[80]; |
| 1580 | |
| 1581 | // read description. |
| 1582 | this->ReadLine(line); |
| 1583 | |
| 1584 | auto advance = [&line, this]() |
| 1585 | { |
| 1586 | this->GoldIFile->peek(); |
| 1587 | return this->GoldIFile->eof() ? 0 : this->ReadLine(line); |
| 1588 | }; |
| 1589 | |
| 1590 | int lineRead = this->ReadLine(line); // "part". |
| 1591 | while (lineRead && strncmp(line, "part", 4) == 0) |
| 1592 | { |
| 1593 | int partId; |
| 1594 | this->ReadPartId(&partId); |
| 1595 | partId--; // EnSight starts #ing with 1. |
| 1596 | const int realId = this->InsertNewPartId(partId); |
| 1597 | auto output = this->GetDataSetFromBlock(compositeOutput, realId); |
| 1598 | |
| 1599 | // "part" line can be followed by section identifier "block" or |
| 1600 | // "coordinates" (for nodal data) or "element" (for element data). |
| 1601 | // If the part has zero elements, it may or may not be followed by this section |
| 1602 | // identifier. |
| 1603 | const auto numElements = output->GetNumberOfElements(attributeType); |
| 1604 | |
| 1605 | lineRead = this->ReadLine(line); // "coordinates", "block", "element" or next "part" |
| 1606 | if (lineRead && strncmp(line, "part", 4) == 0) |
| 1607 | { |
| 1608 | // Part number was not followed by "coordinates" or "block"; we are |
| 1609 | // at the start of another part, skip to next iteration/part to avoid |
| 1610 | // reading anything more. |
| 1611 | continue; |
| 1612 | } |
| 1613 | |
| 1614 | if (numElements <= 0) |
| 1615 | { |
| 1616 | lineRead = advance(); |
| 1617 | continue; |
| 1618 | } |
| 1619 | |
| 1620 | auto dsa = output->GetAttributes(attributeType); |
| 1621 | vtkSmartPointer<vtkFloatArray> array; |
| 1622 | |
| 1623 | // For element data (aka cell-data), "part" may be followed by "[element |
| 1624 | // type]" in which case the data is read in chunks rather than a whole. |
| 1625 | if (attributeType != vtkDataObject::CELL || strncmp(line, "block", 5) == 0) |
| 1626 | { |
| 1627 | // read full data. |
| 1628 | array = vtkUtilities::ReadVariableFloats( |
| 1629 | line, this, description, dsa, numElements, numComponents, component); |
| 1630 | |
| 1631 | lineRead = advance(); |
| 1632 | } |
no test coverage detected