Read dimensions set (always ASCII). The leading '[' has already been removed before calling. - can be integer or floating point - user-generated files may have only the first five dimensions. Note - may even have "human-readable" values such as [kg m^-1 s^-2] but they are very rare and we silently skip these
| 4058 | // - may even have "human-readable" values such as [kg m^-1 s^-2] but they are very rare |
| 4059 | // and we silently skip these |
| 4060 | void vtkFoamEntryValue::ReadDimensionSet(vtkFoamIOobject& io) |
| 4061 | { |
| 4062 | constexpr int nDimensions = 7; // There are 7 base dimensions |
| 4063 | this->MakeScalarList(nDimensions, 0.0); |
| 4064 | vtkFloatArray& dims = *(this->Superclass::ScalarListPtr); |
| 4065 | |
| 4066 | // Read using tokenizer to handle scalar/label, variable lengths, and ignore human-readable |
| 4067 | vtkFoamToken tok; |
| 4068 | char expectEnding = ']'; |
| 4069 | bool goodInput = true; |
| 4070 | |
| 4071 | for (int ndims = 0; ndims < nDimensions && goodInput && expectEnding; ++ndims) |
| 4072 | { |
| 4073 | if (!io.Read(tok)) |
| 4074 | { |
| 4075 | goodInput = false; |
| 4076 | } |
| 4077 | else if (tok.IsNumeric()) |
| 4078 | { |
| 4079 | dims.SetValue(ndims, tok.ToFloat()); |
| 4080 | } |
| 4081 | else if (tok.IsPunctuation()) |
| 4082 | { |
| 4083 | if (tok == expectEnding) |
| 4084 | { |
| 4085 | expectEnding = '\0'; // Already got the closing ']' |
| 4086 | } |
| 4087 | else |
| 4088 | { |
| 4089 | goodInput = false; |
| 4090 | } |
| 4091 | } |
| 4092 | else |
| 4093 | { |
| 4094 | // Some unknown token type (eg, encountered human-readable units) |
| 4095 | // - skip until ']' |
| 4096 | while ((goodInput = io.Read(tok))) |
| 4097 | { |
| 4098 | if (tok.IsPunctuation() && (tok == expectEnding)) |
| 4099 | { |
| 4100 | expectEnding = '\0'; // Already got the closing ']' |
| 4101 | break; |
| 4102 | } |
| 4103 | } |
| 4104 | break; |
| 4105 | } |
| 4106 | } |
| 4107 | |
| 4108 | if (!goodInput) |
| 4109 | { |
| 4110 | io.ThrowStackTrace("Unexpected input while parsing dimensions array"); |
| 4111 | } |
| 4112 | else if (expectEnding) |
| 4113 | { |
| 4114 | io.ReadExpecting(expectEnding); |
| 4115 | } |
| 4116 | } |
| 4117 |
no test coverage detected