# AC28 original-file audit and explorer

Open http://localhost:8743/ for the updated local explorer. The source page is `datas_2/viewer/explorer.html`; the prior page is preserved as `previous_viewer.html`. Original STEP, PLY, XLS and CSV files were not changed.

The key result is a handedness mismatch: 16:00 matches the supplied CAD much better under a determinant −1 transform than under the 24 tested proper-rotation starting frames. This is a diagnostic hypothesis, not a validated physical pose. Resolve scanner axis conventions and part left/right identity before accepting deformation targets. See `datas_2/viewer/analysis_report.html` for results and recommendations.

## Reproduce

Use Python 3.12 and the packages recorded in `requirements.txt` in a dedicated virtual environment. No temporary scratchpad is needed. Run from the workspace root:

```sh
python analysis/ac28_audit.py
python analysis/register_ac28.py
python analysis/prepare_design.py
python analysis/export_explorer.py
python analysis/cad_curvature.py
python analysis/finalize_analysis.py
python analysis/prepare_viewer_annotations.py
python -m http.server 8743 --bind 127.0.0.1 --directory datas_2/viewer
```

If the server already runs on 8743, keep the existing server. Original cloud loading is large; the first audit caches each sensor's 2 mm voxel cloud. The scripts write only derived artifacts under `analysis/results` and `datas_2/viewer/explorer_data`. Preserve the run order: curvature enrichment must follow the basic design/graph export. `baseline_transforms.json` records the old poses; 18:01 remains unchanged. Source dimensions are mm, confirmed by the STEP SI unit entity.

## Numerical conventions

- Coarse registration: 6 mm scan and 4 mm CAD voxel samples; 48 signed/permuted PCA frames. Physical-rotation and reflected candidates are ranked separately. No scale fitting or nonrigid deformation.
- Fine fitting: closest CAD triangle correspondences with a 12 mm gate, rigid incremental updates within each determinant class.
- Evaluation: all points in each merged 2 mm voxel sample, no distance exclusions. Median, P90, P95 and threshold fractions are unsigned Euclidean point-to-triangle distances. Region definitions are explicit CAD Z bands.
- Display: every twelfth raw PLY point, then the first original representative of each 0.8 mm voxel. Display and evaluation samples differ; charts explicitly describe the display sample.
- Local plane RMS: 20 nearest evaluation points; invalid if furthest neighbor exceeds 8 mm. Not a calibrated Ra statistic.
- CAD field distances: fine 0.15 mm / 0.15 rad tessellation. Display and graph: quadric-decimated 24,000 triangles. Mesh connectivity should be reviewed before FE or narrow-feature modeling.
- CAD principal curvatures: original BRep derivatives at sampled UV triangle centroids. Values map to the graph within 3 mm and absolute normal dot >0.8. Invalid mappings stay masked. Parametric-normal signs have not been made consistently outward.
- Proximity coverage is not a visibility test. Nearest distance is not a tracked displacement vector. All training-valid masks remain false.

## Outputs

- `datas_2/viewer/explorer_data/metadata.json`: final transforms, all-point metrics, regional and sensor diagnostics.
- `process.json`: 50 channels per original workbook, with row numbers, units, times and nulls for blanks.
- `cad_graph.npz`: topology, geometric features and curvature masks.
- `*_graph_observations.npz`: per-pose distances, proximity mask and training validity mask.
- `cad_surface_curvature.npz`: 265,538 original-CAD derivative samples with face IDs.
- `source_manifest.json`: original STEP/PLY/XLS/CSV SHA-256 hashes.
- `dataset_schema.json`: field meanings and missing prerequisites.
- `graph_prepared.json`: browser-readable arrays exported directly from the graph/observation NPZs. The 3D GNN tab uses the same node order and topology, with whole-graph and 1-/2-hop inspection.
- `dent_annotations.json`: viewer-only inferred raster-to-PLY anchors, raw vertex IDs, mapping equations, and height-validation statistics. Uses `x=min(PLY.x)+0.1*u`, `y=max(PLY.y)-0.1*v`, and merged TIFF height, then snaps to a measured PLY vertex. 48,234 / 61,700 sampled PLY points map to valid height pixels; median height discrepancy is 0.0076 / 0 mm for 16:00 / 18:01. The CSV top-left pixel origin still needs confirmation. Anchors are transformed with the active scan pose, not written into GNN labels.
- `analysis/results/numerical_validation.json` and `ui_validation.json`: checks performed.

`node analysis/verify_annotations_graph.cjs` checks dent projection, visibility/clipping, both batch images, under-viewer layout, graph node/edge counts, actual distinct rendered preparation stages, neighborhood selection, hidden layers and mobile layout. Screenshots and results are saved in `analysis/results`. `verify_layers.cjs` separately regression-tests the main viewer's actual WebGL pixel changes.

`verify_explorer.cjs` uses Playwright from the machine's Codex runtime and an installed Chromium. Its two absolute runtime paths are machine-specific. The application itself uses local Three.js r128 and OrbitControls assets and makes no external network requests.
