#include "io/gpr/IprbReader.hpp" #include #include #include namespace geopro::io::gpr { BScan readIprb(const std::string& path, const IprHeader& h) { std::ifstream f(path, std::ios::binary | std::ios::ate); if (!f) { throw std::runtime_error("readIprb: 无法打开文件: " + path); } const std::streamsize fileSize = f.tellg(); const std::int64_t traces = static_cast(h.lastTrace) + 1; const std::int64_t count = static_cast(h.samples) * traces; const std::int64_t expected = count * 2; if (fileSize != expected) { throw std::runtime_error("readIprb: 文件大小与 samples*traces*2 不符: " + path); } BScan b; b.samples = h.samples; b.traces = traces; b.data.resize(static_cast(h.samples) * traces); f.seekg(0, std::ios::beg); f.read(reinterpret_cast(b.data.data()), static_cast(expected)); if (!f) { throw std::runtime_error("readIprb: 读取数据失败: " + path); } return b; } } // namespace geopro::io::gpr