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

Method ReadVariableArray

IO/EnSight/vtkEnSightGoldBinaryReader.cxx:1575–1691  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1573
1574//------------------------------------------------------------------------------
1575bool 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 }

Callers 8

ReadScalarsPerNodeMethod · 0.95
ReadVectorsPerNodeMethod · 0.95
ReadTensorsPerNodeMethod · 0.95
ReadScalarsPerElementMethod · 0.95
ReadVectorsPerElementMethod · 0.95
ReadTensorsPerElementMethod · 0.95

Calls 15

ReadLineMethod · 0.95
ReadPartIdMethod · 0.95
InsertNewPartIdMethod · 0.80
GetDataSetFromBlockMethod · 0.80
IsIdMethod · 0.80
SetNumberOfIdsMethod · 0.80
SetScalarsMethod · 0.80
SetVectorsMethod · 0.80
advanceFunction · 0.50
NewFunction · 0.50
assertFunction · 0.50
peekMethod · 0.45

Tested by

no test coverage detected