------------------------------------------------------------------------------
| 2084 | |
| 2085 | //------------------------------------------------------------------------------ |
| 2086 | void EnSightDataSet::ReadVariableConstantCase( |
| 2087 | VariableOptions& var, vtkPartitionedDataSetCollection* output) |
| 2088 | { |
| 2089 | // in this case we may have already read the values, since they're in the case file |
| 2090 | // but they may also be in a separate file, in which case we'll read them in here |
| 2091 | // this is one value for the dataset per time step |
| 2092 | if (var.Type == VariableType::ConstantPerCaseFile && var.Constants.empty()) |
| 2093 | { |
| 2094 | // we'll read these in the first time we call this, and just keep it cached |
| 2095 | var.File.OpenFile(true); |
| 2096 | readFileValues(var.File, var.Constants); |
| 2097 | } |
| 2098 | |
| 2099 | if (var.Constants.empty()) |
| 2100 | { |
| 2101 | vtkGenericWarningMacro( |
| 2102 | "Variable " << var.Name << " is a constant per case, but no values were found"); |
| 2103 | return; |
| 2104 | } |
| 2105 | |
| 2106 | int idx = 0; |
| 2107 | if (var.File.TimeSet != -1) |
| 2108 | { |
| 2109 | auto info = var.File.GetTimeSetInfo(); |
| 2110 | double timeVal = info->TimeValues[0]; |
| 2111 | for (size_t i = 1; i < info->TimeValues.size(); ++i) |
| 2112 | { |
| 2113 | double newTime = info->TimeValues[i]; |
| 2114 | if (newTime <= this->ActualTimeValue && newTime > timeVal) |
| 2115 | { |
| 2116 | timeVal = newTime; |
| 2117 | idx++; |
| 2118 | } |
| 2119 | } |
| 2120 | } |
| 2121 | vtkNew<vtkFloatArray> array; |
| 2122 | array->SetName(var.Name.c_str()); |
| 2123 | array->SetNumberOfTuples(1); |
| 2124 | array->SetValue(0, var.Constants[idx]); |
| 2125 | output->GetFieldData()->AddArray(array); |
| 2126 | } |
| 2127 | |
| 2128 | //------------------------------------------------------------------------------ |
| 2129 | void EnSightDataSet::CreateUniformGridOutput(const GridOptions& opts, vtkUniformGrid* output) |
no test coverage detected