| 218 | |
| 219 | |
| 220 | bool BpfHeader::readDimensions(ILeStream& stream, BpfDimensionList& dims, bool fixNames) |
| 221 | { |
| 222 | size_t staticCnt = m_staticDims.size(); |
| 223 | |
| 224 | dims.resize(m_numDim); |
| 225 | |
| 226 | if (static_cast<std::size_t>(m_numDim) < staticCnt) |
| 227 | { |
| 228 | m_log->get(LogLevel::Error) << "BPF dimension range looks bad.\n"; |
| 229 | m_log->get(LogLevel::Error) << |
| 230 | "BPF: num dims: " << m_numDim << "\n" << |
| 231 | "BPF: static count: " << staticCnt << "\n"; |
| 232 | |
| 233 | m_log->get(LogLevel::Error) << "Dims:\n"; |
| 234 | for (auto d : dims) |
| 235 | m_log->get(LogLevel::Error) << "\t" << d.m_label << "\n"; |
| 236 | |
| 237 | m_log->get(LogLevel::Error) << "Static:\n"; |
| 238 | for (auto d : m_staticDims) |
| 239 | m_log->get(LogLevel::Error) << "\t" << d.m_label << "\n"; |
| 240 | } |
| 241 | |
| 242 | for (size_t d = 0; d < staticCnt; d++) |
| 243 | dims.at(d) = m_staticDims[d]; |
| 244 | if (!BpfDimension::read(stream, dims, staticCnt)) |
| 245 | return false; |
| 246 | |
| 247 | // Verify that we have an X, Y and Z, so that we don't have to worry |
| 248 | // about it later. |
| 249 | bool x = false; |
| 250 | bool y = false; |
| 251 | bool z = false; |
| 252 | for (auto& d : dims) |
| 253 | { |
| 254 | if (d.m_label == "X") |
| 255 | x = true; |
| 256 | if (d.m_label == "Y") |
| 257 | y = true; |
| 258 | if (d.m_label == "Z") |
| 259 | z = true; |
| 260 | |
| 261 | if (fixNames) |
| 262 | d.m_label = Dimension::fixName(d.m_label); |
| 263 | } |
| 264 | if (!x || !y || !z) |
| 265 | throw error("BPF file missing at least one of X, Y or Z dimensions."); |
| 266 | return true; |
| 267 | } |
| 268 | |
| 269 | |
| 270 | // This just exists for symmetry. |