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

Method ReadVariableConstantCase

IO/EnSight/core/EnSightDataSet.cxx:2086–2126  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2084
2085//------------------------------------------------------------------------------
2086void 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//------------------------------------------------------------------------------
2129void EnSightDataSet::CreateUniformGridOutput(const GridOptions& opts, vtkUniformGrid* output)

Callers 1

ReadVariablesMethod · 0.95

Calls 11

readFileValuesFunction · 0.85
GetTimeSetInfoMethod · 0.80
emptyMethod · 0.45
OpenFileMethod · 0.45
sizeMethod · 0.45
SetNameMethod · 0.45
c_strMethod · 0.45
SetNumberOfTuplesMethod · 0.45
SetValueMethod · 0.45
AddArrayMethod · 0.45
GetFieldDataMethod · 0.45

Tested by

no test coverage detected