------------------------------------------------------------------------------
| 1869 | |
| 1870 | //------------------------------------------------------------------------------ |
| 1871 | void EnSightDataSet::ReadVariableElements(EnSightFile& file, const std::string& arrayName, |
| 1872 | int numComponents, vtkPartitionedDataSetCollection* output, vtkDataArraySelection* selection, |
| 1873 | bool isComplex /*=false*/, bool isReal /*=true*/) |
| 1874 | { |
| 1875 | if (!file.SetTimeStepToRead(this->ActualTimeValue)) |
| 1876 | { |
| 1877 | vtkGenericWarningMacro("couldn't correctly set time step to read. Aborting"); |
| 1878 | return; |
| 1879 | } |
| 1880 | file.CheckForBeginTimeStepLine(); |
| 1881 | |
| 1882 | // skip description line |
| 1883 | file.SkipNLines(1); |
| 1884 | auto result = file.ReadNextLine(); |
| 1885 | bool continueReading = result.first; |
| 1886 | while (continueReading && result.second.find("part") != std::string::npos) |
| 1887 | { |
| 1888 | int partId = this->ReadPartId(file); |
| 1889 | partId--; |
| 1890 | |
| 1891 | auto it = this->PartInfoMap.find(partId); |
| 1892 | if (it == this->PartInfoMap.end()) |
| 1893 | { |
| 1894 | vtkGenericWarningMacro("Part Id " << partId << " could not be found in PartInfoMap"); |
| 1895 | return; |
| 1896 | } |
| 1897 | auto& partInfo = it->second; |
| 1898 | bool readPart = false; |
| 1899 | if (selection->ArrayIsEnabled(partInfo.Name.c_str())) |
| 1900 | { |
| 1901 | readPart = true; |
| 1902 | } |
| 1903 | |
| 1904 | // next line either says block or has an element type |
| 1905 | result = file.ReadNextLine(); |
| 1906 | continueReading = result.first; |
| 1907 | while (continueReading && isValidCellSectionHeader(result.second)) |
| 1908 | { |
| 1909 | if (result.second.find("block") != std::string::npos) |
| 1910 | { |
| 1911 | if (readPart) |
| 1912 | { |
| 1913 | vtkPartitionedDataSet* pds = output->GetPartitionedDataSet(partInfo.PDCIndex); |
| 1914 | vtkDataSet* ds = pds->GetPartition(0); |
| 1915 | auto numCells = ds->GetNumberOfCells(); |
| 1916 | // Because the old reader puts the real and imaginary components into a single array |
| 1917 | // with 2 components in the case of scalars, we will copy that functionality here, so |
| 1918 | // users of the old reader can expect to have the same variable names with this reader. |
| 1919 | // When numComponents > 1, the real and imaginary components are always put into their |
| 1920 | // own vtkDataArray. |
| 1921 | if (isComplex && numComponents == 1) |
| 1922 | { |
| 1923 | auto tmpArray = this->ReadVariableArray(file, result.second, numCells, numComponents); |
| 1924 | if (isReal) |
| 1925 | { |
| 1926 | vtkNew<vtkFloatArray> array; |
| 1927 | array->SetNumberOfComponents(2); |
| 1928 | array->SetNumberOfTuples(numCells); |
no test coverage detected