Files
hm 751c4bbd3a
Build & Test / build-and-test (push) Canceled after 0s
VDE Build & Test / build-and-test (push) Canceled after 0s
Build & Test / python-bindings (push) Canceled after 0s
feat(tools): sweep 增加 -Mesh 网格口径往返跑批开关 (VDE-1193 9.11.32)
sweep_worker.ps1 / sweep_corpus.ps1 新增 -Mesh,展开为
--mesh-only --roundtrip,用于产出 rt_mesh_area_rel/rt_mesh_vol_rel
等与参数化、裁剪域、原点无关的往返几何保真判据(解析档 rt_*_rel
不可作门禁)。冒烟 4 件端到端验证:trj10 area_rel=0.000000
vol_rel=0.000000(逐位相同)、trj2 0.002805/0.000539、bug29564
0.002126/0.014978(体积超 1% 但因两侧未全水密不参与门禁),
聚合 rt_mesh_files=3 rt_mesh_fail=0。
2026-09-19 07:38:51 +08:00

79 lines
3.6 KiB
PowerShell

# sweep_worker.ps1 - one sweep worker over an explicit file-list file.
# Usage: powershell -File tools\sweep_worker.ps1 -Probe <exe> -OutDir <dir> -ListFile <txt> [-Heal] [-Roundtrip]
# Writes batch_NNN.json into OutDir and done.flag when finished.
# Keep ASCII-only (PS5.1 reads BOM-less ps1 as ANSI/GBK).
param(
[Parameter(Mandatory=$true)][string]$Probe,
[Parameter(Mandatory=$true)][string]$OutDir,
[Parameter(Mandatory=$true)][string]$ListFile,
[switch]$Heal,
[switch]$Roundtrip,
[switch]$Analytic,
[switch]$Mesh
)
$ErrorActionPreference = "Continue"
New-Item -ItemType Directory -Force -Path $OutDir | Out-Null
$files = Get-Content $ListFile -Encoding UTF8 | Where-Object { $_ -ne "" }
"worker files: $($files.Count)"
$batchSize = 20
$mode = "--diag-only"
if ($Heal) { $mode = "--diag-only --heal" }
if ($Roundtrip) {
# RT gate (topology tier, same semantics as the 9/9 smoke baseline):
# export -> reimport -> V/E/F/bodies conservation + degraded-export check.
# rt_vol_rel stays -1 under diag-only; the analytic (volume/area) tier
# runs on a representative subset with --analytic-only --roundtrip,
# because analytic measure is SSI-heavy and too slow corpus-wide.
$mode = "--diag-only --roundtrip"
if ($Heal) { $mode += " --heal" }
}
if ($Analytic) {
# Analytic geometry tier: integral volume/area conservation, no meshing
# (SSI-heavy; 28-file subset only, see rt_analytic_subset.txt).
$mode = "--analytic-only --roundtrip"
if ($Heal) { $mode += " --heal" }
}
if ($Mesh) {
# Mesh geometry tier (VDE-1193 9.11.32): mesh area/volume are independent of
# surface parameterization, trim-domain construction and origin, so
# rt_mesh_area_rel/rt_mesh_vol_rel are the trustworthy "did export preserve
# geometry" numbers. Still emits the topology RT fields (rt_ok/rt_*_eq).
# NB: the analytic tier's rt_vol_rel/rt_area_rel must not be used as a gate
# (measured 1%~93% deviation on files whose mesh geometry is bit-identical).
$mode = "--mesh-only --roundtrip"
if ($Heal) { $mode += " --heal" }
}
$nBatches = [Math]::Floor(($files.Count + $batchSize - 1) / $batchSize)
for ($b = 0; $b -lt $nBatches; $b++) {
$lo = $b * $batchSize
$hi = $lo + $batchSize - 1
if ($hi -ge $files.Count) { $hi = $files.Count - 1 }
$batch = @()
for ($k = $lo; $k -le $hi; $k++) { $batch += $files[$k] }
$outJson = Join-Path $OutDir ("batch_{0:d3}.json" -f $b)
if (Test-Path $outJson) {
# Resume support: skip finished batches ONLY if the json holds every
# file of this batch. The probe writes the json incrementally, so a
# crashed/killed run leaves a PARTIAL json; treating it as complete
# silently loses the unprocessed files (2026-09-14 heal sweep lost
# ~99/642 files this way). Reprocessing is safe: the probe rebuilds
# the json from scratch (overwrite, not append).
$expected = $hi - $lo + 1
$have = 0
try {
$txt = Get-Content $outJson -Raw -Encoding UTF8
if ($txt) { $have = ([regex]::Matches($txt, '"file":')).Count }
} catch { $have = 0 }
if ($have -ge $expected) { continue }
"batch $b partial ($have/$expected) -> reprocessing"
}
$pargs = @($outJson) + $mode.Split(" ")
foreach ($f in $batch) { $pargs += $f }
$sw = [Diagnostics.Stopwatch]::StartNew()
& $Probe @pargs 2>> (Join-Path $OutDir "sweep.log") | Out-Null
$sw.Stop()
"batch $b : $($batch.Count) files, $([int]$sw.Elapsed.TotalSeconds)s"
}
"worker done" | Out-File (Join-Path $OutDir "done.flag") -Encoding ascii