# Moltex POC experiments

This workspace implements the representations and compact model baselines from the [POC page](https://onepredict.atlassian.net/wiki/spaces/TD1/pages/3275522074/POC). Start here for reproducible commands; see [DESIGN_NOTES.md](DESIGN_NOTES.md) for CAD-change generalization, geometric image channels, stress interpretation and the validation plan.

## Directories

```text
전처리/                 Preprocessing CLIs, experiment launcher, tests, design notes
data_processed/
  graphs/               CAD graphs at seven requested node budgets and diagnostics index
  brep/                 Trimmed B-Rep face UV samples and topological face adjacency
  images/               Six-view multi-channel CAD rasters with pixel-to-surface mapping
  voxels/               Sparse surface-sample voxels and bounded dense tensors
  points/               CAD points and separately marked post-process scan points
  tabular/              Process conditions, missing masks and CAD summaries
  paired/               STEP/XLS ↔ fused-PLY targets, heater overlays and weak defect areas
models/                 Compact neural architectures, adapters, training utilities and runner
results/
  graphs/               Graph comparison figure and interactive viewer
  brep/                 B-Rep plots/diagnostics
  representations/      Image, voxel and point previews
  models/               Execution report and explicitly synthetic checks/checkpoints
  delegation/           GPT-5.6 Terra/high CLI prompts, logs and review notes
```

Original `datas`, `datas_2` and `analysis` inputs are retained. Existing derived CAD/scan caches are reused; rebuilding the original registration is outside this experiment. New preprocessing products are written under `data_processed`, with figures/reports in `results`.

## Environment

Run from the workspace root. A Python 3.12 `.venv` is already installed on this Mac.

```sh
python3 -m venv .venv
.venv/bin/python -m pip install -r 전처리/requirements-lock.txt
```

The lock records the tested local environment. Open3D and OCP/VTK are substantial native dependencies. PyTorch execution uses CPU for portability. Optional sparse-convolution backends have separate platform requirements; consult the model report for their availability.

## Run

```sh
# Regenerate all representations, then run model and synthetic checks.
.venv/bin/python 전처리/run_experiments.py --all

# Run model execution checks using existing processed artifacts.
.venv/bin/python 전처리/run_experiments.py --smoke

# Rebuild previews and galleries for every existing processed NPZ.
.venv/bin/python 전처리/run_experiments.py --visualize

# Rebuild CAD/PLY matching, 2×17 heater overlays and weak target areas.
.venv/bin/python 전처리/run_experiments.py --match-targets

# Prepare individual representation families.
.venv/bin/python 전처리/cad_graphs.py
.venv/bin/python 전처리/brep.py
.venv/bin/python 전처리/representations.py
.venv/bin/python 전처리/audit_ply_fusion.py --sample 350000 --out data_processed/ply_audit

# Numerical/regression checks.
.venv/bin/python -m unittest discover -s 전처리/tests -v
```

Use each CLI's `--help` for output paths, graph budgets, image resolutions or B-Rep grid size. Default graph targets are **12,000 / 6,000 / 3,000 / 1,500 / 750 / 300 / 100 nodes**. The index and viewer report actual achieved counts separately.

For another mesh, provide `cad_graphs.py --mesh /path/to/new_mesh.stl --out /path/to/new_graphs --results /path/to/new_results`. Provide `--curvature` only for derivative samples belonging to that mesh. For another STEP, provide `brep.py --step /path/to/new_design.step --out /path/to/new_brep`. Changing the input file and successfully executing a model does not establish predictive transfer.

## Read results

- [Processed-data gallery](../data_processed/index.html): all 20 NPZ artifacts have a PNG in their family's `visualizations/` directory, with raw-array, metadata and schema links. Each family also has its own `index.html`.
- [CAD–PLY and heater overlays](../data_processed/paired/index.html): two run-level matched artifacts using `all_merge_pointcloud_full` as the fused outcome. T1/T2/TOP component scans are retained for registration/coverage QA.
- [Fused PLY audit](../data_processed/ply_audit/index.html): full-file integrity and bounds, production-time orientation, and component-sensor overlay checks for every `all_merge_pointcloud_full.ply` variant.
- `data_processed/graphs/index.json`: actual graph size, physical shape error, connectivity and curvature coverage.
- `results/graphs/viewer.html`: interactive graph-resolution inspection (serve the workspace over HTTP).
- `results/representations/`: six-view depth/curvature, feature channels, voxel-resolution and point-cloud figures.
- `results/models/report.json`: architecture execution, parameters, timing, numerical checks and explicitly labeled synthetic demonstrations.
- `models/README.md`: architecture scope, training interface and limitations.

To serve the experiment artifacts locally:

```sh
.venv/bin/python -m http.server 8765 --bind 127.0.0.1
```

Then open `http://localhost:8765/data_processed/index.html` for all previews or `http://localhost:8765/results/graphs/viewer.html` to rotate and compare CAD graphs. The prior AC28 application remains available separately on port 8743 when its server is running.

## Interpretation

The real data has one CAD design, two production runs, unvalidated spatial labels and no supplied thermal/strain/stress fields. `training_valid` remains false. Real-input forward passes are execution checks; synthetic learning or optimization is labeled separately. No real defect accuracy or production process recommendation is claimed.

Use feature-validity masks: absent curvature is not flatness; unobserved material thickness or temperature is not zero. CAD-only inputs support pre-process modeling. Post-process scan inputs are diagnostic/inspection data and must not leak into a pre-process prediction experiment. Split future labeled data by independent part/run and hold out entire CAD revisions for design-transfer claims.
