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

Method ReadVariableNodes

IO/EnSight/core/EnSightDataSet.cxx:1609–1710  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1607
1608//------------------------------------------------------------------------------
1609void EnSightDataSet::ReadVariableNodes(EnSightFile& file, const std::string& arrayName,
1610 int numComponents, vtkPartitionedDataSetCollection* output, vtkDataArraySelection* selection,
1611 bool isComplex /*=false*/, bool isReal /*=true*/)
1612{
1613 if (!file.SetTimeStepToRead(this->ActualTimeValue))
1614 {
1615 vtkGenericWarningMacro("couldn't correctly set time step to read. Aborting");
1616 return;
1617 }
1618 file.CheckForBeginTimeStepLine();
1619
1620 // skip description line
1621 file.SkipNLines(1);
1622 auto result = file.ReadNextLine();
1623 while (result.first && result.second.find("part") != std::string::npos)
1624 {
1625 int partId = this->ReadPartId(file);
1626 partId--;
1627
1628 // next line should be either coordinates or block
1629 // however it may or may not be there if there is an empty part.
1630 // we'll test for it and if it doesn't say coordinates or block, we'll assume
1631 // it's an empty part and move on
1632 result = file.ReadNextLine();
1633 auto sectionHeader = result.second;
1634 if (sectionHeader.find("coordinates") == std::string::npos &&
1635 sectionHeader.find("block") == std::string::npos)
1636 {
1637 continue;
1638 }
1639
1640 auto it = this->PartInfoMap.find(partId);
1641 if (it == this->PartInfoMap.end())
1642 {
1643 vtkGenericWarningMacro("Part Id " << partId << " could not be found in PartInfoMap");
1644 return;
1645 }
1646 auto& partInfo = it->second;
1647 bool readPart = false;
1648 if (selection->ArrayIsEnabled(partInfo.Name.c_str()))
1649 {
1650 readPart = true;
1651 }
1652
1653 if (readPart)
1654 {
1655 vtkPartitionedDataSet* pds = output->GetPartitionedDataSet(partInfo.PDCIndex);
1656 vtkDataSet* ds = pds->GetPartition(0);
1657 auto numPts = ds->GetNumberOfPoints();
1658 if (numPts > 0)
1659 {
1660 // Because the old reader puts the real and imaginary components into a single array
1661 // with 2 components in the case of scalars, we will copy that functionality here, so
1662 // users of the old reader can expect to have the same variable names with this reader.
1663 // When numComponents > 1, the real and imaginary components are always put into their
1664 // own vtkDataArray.
1665 if (isComplex && numComponents == 1)
1666 {

Callers 1

ReadVariablesMethod · 0.95

Calls 15

ReadPartIdMethod · 0.95
ReadVariableArrayMethod · 0.95
SetTimeStepToReadMethod · 0.80
SkipNLinesMethod · 0.80
ReadNextLineMethod · 0.80
GetPartitionedDataSetMethod · 0.80
GetAbstractArrayMethod · 0.80
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected