// gpr3dv-smoke —— vendored 3DGPRViewer 数据生成链冒烟入口。 // // 验证目标(任务 P1 验收): // ① 读一条多通道测线 → GPRDataModel(traces) // ② GPRDataModel::buildVolumeData → 立方体 volumeData[ch][trace][sample] // ③ RadarProcessor::runPipeline(默认流水线) → 处理后 GPRDataModel // 打印:立方体维度 / 处理前后统计量(证明处理生效)/ 通道数(读自数据)。 // // 用法: // gpr3dv-smoke // 例: gpr3dv-smoke "D:/Downloads/明星路" "明星路_001" // // 算法零改动:本文件只调用 vendored 原版静态 API,不触碰任何算法体。 #include #include #include #include #include "GPRDataModel.h" #include "IprhParser.h" #include "RadarProcessor.h" // 全体 traces 的平均绝对幅值——朴素的"处理是否生效"标量证据。 // RadarProcessor 流水线在 model.traces 上做原位变换(非 volumeData),故统计取自 traces。 static double meanAbsAmplitude(const GPRDataModel &model, qint64 *sampleCountOut = nullptr) { long double sum = 0.0L; qint64 count = 0; for (const RadarTrace &tr : model.traces) { for (short v : tr.amplitudes) { sum += static_cast(v < 0 ? -v : v); ++count; } } if (sampleCountOut) { *sampleCountOut = count; } return count > 0 ? static_cast(sum / count) : 0.0; } int main(int argc, char **argv) { if (argc < 3) { std::fprintf(stderr, "用法: gpr3dv-smoke \n" "例: gpr3dv-smoke \"D:/Downloads/明星路\" \"明星路_001\"\n"); return 2; } const QString lineDir = QString::fromLocal8Bit(argv[1]); const QString linePrefix = QString::fromLocal8Bit(argv[2]); std::printf("[gpr3dv-smoke] lineDir=%s linePrefix=%s\n", lineDir.toLocal8Bit().constData(), linePrefix.toLocal8Bit().constData()); // ---- ① 读多通道测线(通道数读自数据,不写死)---- GPRDataModel model; if (!IprhParser::loadImpulseMultiChannel(lineDir, linePrefix, model)) { std::fprintf(stderr, "[gpr3dv-smoke] 错误: loadImpulseMultiChannel 失败\n"); return 1; } const int channels = model.header.numberOfChannels; // 读自 .iprh CHANNELS / _A 文件数 const int tracesPerChannel = model.getTracesPerChannel(); const int samplesPerTrace = model.header.samplesPerTrace; std::printf("[gpr3dv-smoke] 加载完成: 通道数=%d 每通道道数=%d 每道样本数=%d 总道数=%lld\n", channels, tracesPerChannel, samplesPerTrace, static_cast(model.traces.size())); // ---- ② 建三维立方体 volumeData[ch][trace][sample] ---- model.buildVolumeData(); const int volCh = model.volumeData.size(); const int volTr = (volCh > 0) ? model.volumeData[0].size() : 0; const int volSm = (volCh > 0 && volTr > 0) ? model.volumeData[0][0].size() : 0; std::printf("[gpr3dv-smoke] 立方体维度 [通道 x 道 x 样本] = %d x %d x %d\n", volCh, volTr, volSm); short gMin = 0, gMax = 0; model.getGlobalMinMax(gMin, gMax); std::printf("[gpr3dv-smoke] 立方体全局幅值范围: min=%d max=%d\n", static_cast(gMin), static_cast(gMax)); // ---- 处理前统计 ---- qint64 nBefore = 0; const double meanBefore = meanAbsAmplitude(model, &nBefore); std::printf("[gpr3dv-smoke] 处理前 平均绝对幅值=%.4f (样本数=%lld)\n", meanBefore, static_cast(nBefore)); // ---- ③ RadarProcessor 默认流水线 ---- RadarProcessor::ProcPipeline pipeline; pipeline.setDefaultFlow(); std::printf("[gpr3dv-smoke] 运行默认流水线(步骤数=%lld)...\n", static_cast(pipeline.steps.size())); const GPRDataModel processed = RadarProcessor::runPipeline(model, pipeline); qint64 nAfter = 0; const double meanAfter = meanAbsAmplitude(processed, &nAfter); std::printf("[gpr3dv-smoke] 处理后 平均绝对幅值=%.4f (样本数=%lld 道数=%lld 样本/道=%d)\n", meanAfter, static_cast(nAfter), static_cast(processed.traces.size()), processed.header.samplesPerTrace); const double delta = meanAfter - meanBefore; std::printf("[gpr3dv-smoke] 处理前后差值=%.4f —— %s\n", delta, (qAbs(delta) > 1e-9 ? "处理已生效(统计量变化)" : "警告:统计量未变化")); std::printf("[gpr3dv-smoke] OK\n"); return 0; }