@rig-c/parts 2.49.0 → 2.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/cli.ts +129 -6
- package/docs/AUTHORING.md +192 -21
- package/docs/STABILITY.md +68 -9
- package/package.json +1 -1
- package/src/behindseams.ts +164 -11
- package/src/build.ts +27 -14
- package/src/bustlandmarks.ts +600 -0
- package/src/check.ts +255 -30
- package/src/configwrite.ts +64 -3
- package/src/setuppainting.ts +44 -1
package/docs/STABILITY.md
CHANGED
|
@@ -532,8 +532,9 @@ and do not certify visibility. See the
|
|
|
532
532
|
| `assemble` | `--propose-plan` with `--source`, `--full`, `--config`, optional `--head`, `--write-config` (must name `--config` itself, issue #356); or `--source`, `--full`, `--config`, `--out`, optional `--head` (without it, one run: issue #359), `--seam` (near-white, silhouette), `--project` (core, visible), `--alt` (repeatable `<name>=<source>:<full>[:<head>]`, issue #454), `--requirements` (source-bound cut-material evidence only when the file declares `cut_material`, issue #888); or `--emit-fill-masks` (a directory) with `--source`, `--full`, `--config`, optional `--head` (each cut's hidden-band mask on the painting grid, issue #1230); or `--help` (`-h`) |
|
|
533
533
|
| `head-crop-preflight` | `--full`, `--canvas`, `--head-box` (JSON coordinate array); optional `--help` (`-h`); read-only advice before the head run, original alpha > 8 samples (issue #1082) |
|
|
534
534
|
| `propose` | `--head-box` with `--full`, `--canvas`; optional `--no-back-hair`, `--write-config` (existing config, issue #356), `--help` (`-h`) |
|
|
535
|
-
| `propose` | `--parts`, `--source`, `--out`; optional `--compare` or `--from-config` (one of them), `--keypoints`, `--person` and `--wrist-snap` (each with `--keypoints`), `--full`, `--head` (the turn control's depths; not with `--from-config`), `--grid-rule` (`figure` or `part`, the drafted lattice's spacing; not with `--from-config`), `--cloth` (a config whose `cloth` block is the recipe, issue #364; not with `--from-config`), `--write-config` (existing config for an ordinary proposal, issue #356; a new file with `--cloth`, issue #537; not with `--from-config` — additive: without it nothing `propose` writes changes), `--from` (the config the recipe is changed from, only with `--write-config`, issue #571 — additive: without it nothing `--write-config` writes changes), `--only-missing` (only with `--parts` and `--write-config`, not with `--cloth` or `--from-config`, issue #671 — additive: without it nothing `--write-config` writes changes) `--bust-landmarks` (rig-pixel apex_r/apex_l and optional cleavage), or `--no-bust` (non-blank omission reason), one required when drafting a chest-holding torso, both incompatible with `--from-config`, `--help` (`-h`) |
|
|
535
|
+
| `propose` | `--parts`, `--source`, `--out`; optional `--compare` or `--from-config` (one of them), `--keypoints`, `--person` and `--wrist-snap` (each with `--keypoints`), `--full`, `--head` (the turn control's depths; not with `--from-config`), `--grid-rule` (`figure` or `part`, the drafted lattice's spacing; not with `--from-config`), `--cloth` (a config whose `cloth` block is the recipe, issue #364; not with `--from-config`), `--write-config` (existing config for an ordinary proposal, issue #356; a new file with `--cloth`, issue #537; not with `--from-config` — additive: without it nothing `propose` writes changes), `--from` (the config the recipe is changed from, only with `--write-config`, issue #571 — additive: without it nothing `--write-config` writes changes), `--only-missing` (only with `--parts` and `--write-config`, not with `--cloth` or `--from-config`, issue #671 — additive: without it nothing `--write-config` writes changes) `--bust-landmarks` (rig-pixel apex_r/apex_l and optional cleavage; a `<file>.provenance.json` beside it is read and checked, and its pending shape needs `--write-config`, issue #1382), or `--no-bust` (non-blank omission reason), one required when drafting a chest-holding torso, both incompatible with `--from-config`, `--help` (`-h`) |
|
|
536
536
|
| `propose` | `--parts`, `--source`, `--out`, `--full`, `--head`, `--write-config` together: the [neck draft](AUTHORING.md#a-neck-that-moves-on-its-own) for an existing config with `turn.body` and one neck plan row; reassembles under `<out>/rig`, preserves the sampled turn and drafts a rigid neck unit (issue #826) |
|
|
537
|
+
| `bust-landmarks` | `--from-act`, `--parts`, `--config`, `--out`; optional `--write-config` (takes the act's `alpha`, `clearance`, `spacing`, `bone_r` and `bone_l` into the config's existing `meshes.<part>.contour.bust`, a field the act omits removed; the config is untouched when none differs — additive: without it nothing the command writes changes), `--help` (`-h`) (issue #1382; one `rig-review/act@9` chest row to the landmarks file `propose` reads, with `<out>.provenance.json` beside it) |
|
|
537
538
|
| `compare` | `--left`, `--right`; optional `--map`, `--help` (`-h`) |
|
|
538
539
|
| `rig` | `--config`, `--parts`, `--out`; optional `--idle-keys` (ctl, direct), `--page-edges` (pot, free), `--pack-shape` (rect, polygon), `--page-size`, `--help` (`-h`) |
|
|
539
540
|
| `check-parts` | `--parts`, `--out`; optional `--json`, `--help` (`-h`) |
|
|
@@ -557,6 +558,27 @@ command's flag union; `comfy paint` and `comfy seethrough` are checked separatel
|
|
|
557
558
|
Required combinations within a mode remain the CLI's; the `cli` suite's controls
|
|
558
559
|
read them from the help.
|
|
559
560
|
|
|
561
|
+
`bust-landmarks` (issue #1382) arrives in a minor version and is stable like every
|
|
562
|
+
command in the table. This page does not separate provisional commands. The
|
|
563
|
+
promise covers its command line and flags, and its refusal codes:
|
|
564
|
+
`BUST_LANDMARKS_ACT`, `BUST_LANDMARKS_ROW`, `BUST_LANDMARKS_SLOT`,
|
|
565
|
+
`BUST_LANDMARKS_PART_ROWS`, `BUST_LANDMARKS_ROWS`, `BUST_LANDMARKS_FRAME`,
|
|
566
|
+
`BUST_LANDMARKS_SHAPE` and `BUST_LANDMARKS_OUT`. It also covers the landmarks
|
|
567
|
+
file it writes, which holds the three keys `propose` reads, in rig px. And it
|
|
568
|
+
covers the provenance record: its spec id `rig-parts-bust-landmarks-provenance/1`,
|
|
569
|
+
its keys and their order: `spec`, `act` (`schema`, `act_id`, `file_sha256`),
|
|
570
|
+
`row_sha256`, `slot`, `source` (`hash`, `frame`), `landmarks_sha256`, and, only
|
|
571
|
+
when the config declared no `contour.bust` and the act's shape differs from the
|
|
572
|
+
defaults, `shape` (`status`, `pending` or `applied`, and `fields`, in the
|
|
573
|
+
shorthand's key order). `propose --bust-landmarks` reads that record when it
|
|
574
|
+
sits beside the landmarks file, writes a pending shape with `--write-config` and
|
|
575
|
+
marks it applied, and refuses by name `PROPOSE_BUST_SIDECAR`,
|
|
576
|
+
`PROPOSE_BUST_SIDECAR_DIGEST`, `PROPOSE_BUST_SIDECAR_PART` and
|
|
577
|
+
`PROPOSE_BUST_PENDING`; with no record beside the file it reads the file as
|
|
578
|
+
before. The row digest rule (the sha256 of the row's `edit` with object keys sorted recursively, recomputed and refused on a mismatch) is a copy of review's request digest. The act's grammar is review's. This package reads
|
|
579
|
+
`rig-review/act@9` only, and refuses another act version by name until a later
|
|
580
|
+
minor version reads it.
|
|
581
|
+
|
|
560
582
|
The [command reference](AUTHORING.md#command-reference) describes each mode;
|
|
561
583
|
[writing proposed config fields](AUTHORING.md#writing-proposed-config-fields)
|
|
562
584
|
records the existing-file and fresh-file destinations and byte-preservation rules.
|
|
@@ -1539,7 +1561,12 @@ Busy-ground visible assembly validates config.requirements and its flag correspo
|
|
|
1539
1561
|
The optional `setup_painting` key in `spine-parts-requirements/1` adds a
|
|
1540
1562
|
`SETUP_MATCHES_PAINTING` measurement when declared. It requires authored
|
|
1541
1563
|
`rgb_tolerance` and named native-stage boxes. Each optional `max_pixels` is
|
|
1542
|
-
that whole region's limit; omission is SKIP, never PASS.
|
|
1564
|
+
that whole region's limit; omission is SKIP, never PASS. With neither
|
|
1565
|
+
`figure_mask` nor `backdrop` declared, a region whose `(uncovered)` slot row is
|
|
1566
|
+
more than half its `pixel_count` adds one console line,
|
|
1567
|
+
`SETUP_PAINTING_MOSTLY_UNCOVERED` (issue #1421, a warning and not a bar), and
|
|
1568
|
+
the summary line names it; no exit code, problem or `check.json` byte moves.
|
|
1569
|
+
The optional boolean
|
|
1543
1570
|
`setup_painting.required` (issue #943, additive) is the author's declaration
|
|
1544
1571
|
that the check may not SKIP: with `true`, an absent `rgb_tolerance`, `regions`
|
|
1545
1572
|
or region `max_pixels` is refused by name as `SETUP_PAINTING_REQUIRED_LIMIT`
|
|
@@ -1666,16 +1693,18 @@ PASS. Existing render/sidecar refusals remain refusals. The standing
|
|
|
1666
1693
|
bracketed-run definition does not certify curved or diagonal openings.
|
|
1667
1694
|
|
|
1668
1695
|
Per-cell samples are a bounded diagnostic sample; the counts are the
|
|
1669
|
-
measurement (
|
|
1696
|
+
measurement (issues #1403, #1406). Each measured `samples[]` list (setup standing, idle
|
|
1670
1697
|
`motion_opened` on every idle frame, and turn `motion_opened` on every turn
|
|
1671
1698
|
pose; idle and turn `standing` are never measured and their `samples[]` are
|
|
1672
|
-
always `[]`) holds at most 64 rows.
|
|
1673
|
-
A list that measured more holds 64 and gains `samples_omitted
|
|
1699
|
+
always `[]`) and each `unread_corridors[].cells` list holds at most 64 rows.
|
|
1700
|
+
A list that measured more holds 64 and gains `samples_omitted` (or
|
|
1701
|
+
`cells_omitted` on an unread corridor), the number of
|
|
1674
1702
|
rows left out; a list of 64 or fewer has no such field and is written as before.
|
|
1675
1703
|
Standing keeps its 64 worst rows: counted first, then the larger of the two
|
|
1676
|
-
distances' minimum, then the earlier measured row. Motion-opened rows
|
|
1704
|
+
distances' minimum, then the earlier measured row. Motion-opened rows and
|
|
1705
|
+
unread-corridor cells carry no
|
|
1677
1706
|
distance and keep rows floor(j · n / 64), j = 0 … 63, of the n measured. Kept
|
|
1678
|
-
rows stay in measured order. Every count, `px`, `box`, hit, span, run and status
|
|
1707
|
+
rows stay in measured order. Every count (`cell_count`, `unread_cells`), `px`, `box`, hit, span, run and status
|
|
1679
1708
|
is computed from all cells.
|
|
1680
1709
|
|
|
1681
1710
|
Issue #1323 adds `behind_seams.turn: true` as an explicit opt-in. It references
|
|
@@ -1722,6 +1751,35 @@ one pair is optional SKIP even when another pair has a required override.
|
|
|
1722
1751
|
An unavailable poser or source is a HOLE. Other animations, between-sample turns and alternate
|
|
1723
1752
|
skins remain unmeasured.
|
|
1724
1753
|
|
|
1754
|
+
Issue #1409 reads `motion_opened` on a contact-only pair: one with no setup
|
|
1755
|
+
overlap band (no cell drawn at 128/255 or more by both members at setup) whose
|
|
1756
|
+
stock transported support is otherwise complete. Such a pair's idle and turn
|
|
1757
|
+
readings may change from unmeasured (`SKIP` with a `HOLE`) to `PASS` or `FAIL`.
|
|
1758
|
+
The reading carries a setup contact edge (a cell drawn only by A beside a cell
|
|
1759
|
+
drawn only by B) to the frame through both members' meshes and counts the swept
|
|
1760
|
+
cells, drawn by neither member there, that either map carries back onto that
|
|
1761
|
+
member's setup material. Pairs with a band never enter this reading and their
|
|
1762
|
+
`check.json` bytes are unchanged, `limitations` included. New optional fields,
|
|
1763
|
+
each present only on a pair read this way:
|
|
1764
|
+
|
|
1765
|
+
| Field | Stable meaning |
|
|
1766
|
+
| --- | --- |
|
|
1767
|
+
| `pairs[].motion_support`, `pairs[].frames[].motion_support`, `turn.pairs[].motion_support`, `turn.pairs[].frames[].motion_support` | `"setup-contact"`: the motion reading came from transported setup contact edges, not an overlap band. |
|
|
1768
|
+
| `pairs[].frames[].motion_opened.lower_bound_cells`, `turn.pairs[].frames[].motion_opened.lower_bound_cells` | Present only when positive: swept cells that pass the hidden/full/rear tests but that neither member's map carries back onto setup material. They are not counted, so this row's count is a lower bound. |
|
|
1769
|
+
| `pairs[].motion_opened.lower_bound_frames`, `turn.pairs[].motion_opened.lower_bound_poses` | Present only when positive: the number of frame or pose rows that carry `lower_bound_cells`. |
|
|
1770
|
+
|
|
1771
|
+
A line with at least one such pair appends one clause to `limitations`, and a
|
|
1772
|
+
turn block with one appends it to `turn.limitations`. Two limits hold. A count on a row with `lower_bound_cells` is a lower bound: a
|
|
1773
|
+
member that separates from its partner by about its own width or more sweeps
|
|
1774
|
+
cells that no map carries back. A member that draws more than one fragment at
|
|
1775
|
+
setup or on a frame is not read: that frame is a named `HOLE` in
|
|
1776
|
+
`unmeasured[]` (`CHECK_BEHIND_PART_SEAMS_UNMEASURED` with an authored T), and so
|
|
1777
|
+
is a frame where a clip cuts either member at setup or on that frame, because a
|
|
1778
|
+
clipped drawing is not its attachment's and cannot be carried through it. A
|
|
1779
|
+
pair whose members overlap only below 128/255 and share no contact edge keeps a
|
|
1780
|
+
named `HOLE` that says so; a pair with neither band nor contact keeps the
|
|
1781
|
+
existing `HOLE` text.
|
|
1782
|
+
|
|
1725
1783
|
Issue #1325 adds the following optional evidence fields to
|
|
1726
1784
|
`BEHIND_PART_SEAMS.pairs[].setup.standing` (idle `frames[].standing` and turn
|
|
1727
1785
|
`turn.pairs[].frames[].standing` are never measured). Paths in
|
|
@@ -1733,8 +1791,9 @@ the table are relative to that standing record.
|
|
|
1733
1791
|
| `unread_corridors` | Nonempty array of ambiguous-endpoint runs (at setup, those with at least one cell where `dRecomposite > T`), horizontal rows before vertical columns, each in native scan order. |
|
|
1734
1792
|
| `unread_corridors[].axis` | `horizontal` or `vertical`. |
|
|
1735
1793
|
| `unread_corridors[].endpoints` | Two `[grid_x, grid_y, world_x, world_y, owner]` tuples in left/right or top/bottom order. Grid indices are zero-based, x right and y down; world coordinates are cell centres, y up. Owner codes are 0 for neither A/B reaching half alpha, 1 for A only, 2 for B only and 3 for both; no owner is inferred. |
|
|
1736
|
-
| `unread_corridors[].cells` | Interior world-centre `[x, y]` tuples in run order, excluding endpoints. On a corridor whose endpoint owner is ambiguous (`0` or `3`) at setup, cells within T of the parts' recomposite (`dRecomposite <= T`) are left out of the unread population; the remaining interior cells are reported without a rear-colour or endpoint-contrast filter; intersections may repeat across corridors. |
|
|
1737
|
-
| `unread_corridors[].cell_count` | The
|
|
1794
|
+
| `unread_corridors[].cells` | Interior world-centre `[x, y]` tuples in run order, excluding endpoints, capped at 64 evenly spaced entries (`floor(j · cell_count / 64)`, `j = 0 … 63`, when `cell_count > 64`; all `cell_count` entries when `cell_count <= 64`). On a corridor whose endpoint owner is ambiguous (`0` or `3`) at setup, cells within T of the parts' recomposite (`dRecomposite <= T`) are left out of the unread population; the remaining interior cells are reported without a rear-colour or endpoint-contrast filter; intersections may repeat across corridors. |
|
|
1795
|
+
| `unread_corridors[].cell_count` | The corridor's full count of unread interior cells (at setup, leaving out cells within T of the recomposite), equal to `cells.length + (cells_omitted ?? 0)`. |
|
|
1796
|
+
| `unread_corridors[].cells_omitted` | Optional positive integer, present only when `cell_count > 64`: the unread interior cells left out of `cells` (`cell_count - cells.length`). |
|
|
1738
1797
|
| `unread_corridors[].row_scope` | `pair`. |
|
|
1739
1798
|
| `unread_corridors[].row_kind` | `evidence`. |
|
|
1740
1799
|
| `unread_corridors[].row_subjects` | The two selected part names in producer A/B order. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rig-c/parts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.50.0",
|
|
4
4
|
"description": "AI-authored 2D character parts from one anime painting and its See-through layer decomposition: measured parts, weighted-mesh rig specs, verified through rig-c before anything is written. A CLI for agents that cannot see the image.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
package/src/behindseams.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { createHash } from 'node:crypto';
|
|
|
3
3
|
import { isAbsolute, join, relative, resolve } from 'node:path';
|
|
4
4
|
import { Plate } from '@rig-c/core/plate';
|
|
5
5
|
import type { AttachmentRest, Frame } from '@rig-c/core/render-shared';
|
|
6
|
-
import { seamGridOf, seamsOf, setupCellReader, type SeamCell, type SeamGrid } from '@rig-c/core/seam';
|
|
7
|
-
import { DRAWN_ALPHA } from '@rig-c/core/passthrough';
|
|
6
|
+
import { carry, seamGridOf, seamsOf, setupCellReader, type SeamCell, type SeamGrid } from '@rig-c/core/seam';
|
|
7
|
+
import { DRAWN_ALPHA, drawnCells, drawsAt } from '@rig-c/core/passthrough';
|
|
8
8
|
import { checkRow } from './checkrow.ts';
|
|
9
9
|
import { seamSourceAttachment, type MotionSeamPair } from './check.ts';
|
|
10
10
|
import type { Problem } from './errors.ts';
|
|
@@ -19,6 +19,9 @@ export const IDLE_STANDING_MOTION_READ_REASON = 'not applicable: motion_opened r
|
|
|
19
19
|
export const IDLE_STANDING_NO_ORACLE_REASON = "idle standing is not measured: idle frames have no recomposite oracle, and the pair's idle reading is motion_opened";
|
|
20
20
|
export const TURN_STANDING_MOTION_READ_REASON = IDLE_STANDING_MOTION_READ_REASON;
|
|
21
21
|
export const TURN_STANDING_NO_ORACLE_REASON = "turn standing is not measured: turn poses have no recomposite oracle, and the pair's turn reading is motion_opened";
|
|
22
|
+
/** Issue #1409: the marker on a pair, frame or turn row whose motion_opened is read from transported setup contact edges. */
|
|
23
|
+
export const CONTACT_MOTION_SUPPORT = 'setup-contact';
|
|
24
|
+
export const CONTACT_LIMITATIONS = '; contact-only pairs (no setup overlap band) read motion from transported setup contact edges, and a frame or pose with lower_bound_cells counts a lower bound';
|
|
22
25
|
|
|
23
26
|
export interface BehindSeams {
|
|
24
27
|
/** Opt in to the rig's declared ranges; never supplies or guesses a range. */
|
|
@@ -54,6 +57,8 @@ export interface BehindSeamsFramesInput {
|
|
|
54
57
|
plantMeasureIdleStanding?: true;
|
|
55
58
|
/** Issue #1412 plant only: measure standing on turn poses without an oracle; production never sets it. */
|
|
56
59
|
plantMeasureTurnStanding?: true;
|
|
60
|
+
/** Issue #1409 plant only: withhold transported setup contact-edge support; production never sets it. */
|
|
61
|
+
plantNoContact?: true;
|
|
57
62
|
}
|
|
58
63
|
export interface BehindSeamsTurnPose {
|
|
59
64
|
name: string;
|
|
@@ -80,8 +85,10 @@ export interface BehindSeamsTurnPair {
|
|
|
80
85
|
sampled_poses: number;
|
|
81
86
|
read_poses: number;
|
|
82
87
|
unmeasured_poses: number;
|
|
83
|
-
motion_opened: { status: BehindSeamsCount['status']; max_px: number };
|
|
88
|
+
motion_opened: { status: BehindSeamsCount['status']; max_px: number; lower_bound_poses?: number };
|
|
84
89
|
standing: { status: BehindSeamsCount['status']; reason?: string; max_px: number };
|
|
90
|
+
/** Issue #1409: present only when motion_opened is read from transported setup contact edges. */
|
|
91
|
+
motion_support?: typeof CONTACT_MOTION_SUPPORT;
|
|
85
92
|
}
|
|
86
93
|
export interface BehindSeamsTurnMeasured {
|
|
87
94
|
status: BehindSeamsCount['status'];
|
|
@@ -110,6 +117,10 @@ export interface BehindSeamsCount {
|
|
|
110
117
|
samples: BehindSeamsSample[];
|
|
111
118
|
/** Issue #1403: present only when the list held more than {@link BEHIND_SAMPLE_CAP} rows; the rows left out. */
|
|
112
119
|
samples_omitted?: number;
|
|
120
|
+
/** Issue #1409, contact-edge motion only: rear-visible cells inside a transported contact-edge sweep, drawn by neither
|
|
121
|
+
* member, that neither member's map carries back onto setup material of the pair. Present only when positive; px is
|
|
122
|
+
* then a lower bound. */
|
|
123
|
+
lower_bound_cells?: number;
|
|
113
124
|
}
|
|
114
125
|
export type BehindSeamsEndpoint = [grid_x: number, grid_y: number, world_x: number, world_y: number, owner: number];
|
|
115
126
|
export interface BehindSeamsUnreadCorridor {
|
|
@@ -118,6 +129,8 @@ export interface BehindSeamsUnreadCorridor {
|
|
|
118
129
|
endpoints: [BehindSeamsEndpoint, BehindSeamsEndpoint];
|
|
119
130
|
cells: Array<[number, number]>;
|
|
120
131
|
cell_count: number;
|
|
132
|
+
/** Issue #1406: present only when the corridor held more than {@link BEHIND_SAMPLE_CAP} cells; the cells left out. */
|
|
133
|
+
cells_omitted?: number;
|
|
121
134
|
}
|
|
122
135
|
export interface BehindSeamsStanding extends BehindSeamsCount {
|
|
123
136
|
/** Present when standing is SKIP: at setup without --parts, or on every idle frame and turn pose. */
|
|
@@ -139,6 +152,8 @@ export interface BehindSeamsFrame {
|
|
|
139
152
|
grid: SeamGrid | null;
|
|
140
153
|
motion_opened: BehindSeamsCount;
|
|
141
154
|
standing: BehindSeamsStanding;
|
|
155
|
+
/** Issue #1409: present only when this frame's motion_opened is read from transported setup contact edges. */
|
|
156
|
+
motion_support?: typeof CONTACT_MOTION_SUPPORT;
|
|
142
157
|
}
|
|
143
158
|
export interface BehindSeamsHit {
|
|
144
159
|
index: number;
|
|
@@ -160,6 +175,8 @@ export interface BehindSeamsReading {
|
|
|
160
175
|
max_run: { frames: number; seconds: number };
|
|
161
176
|
max_spatial_run_cells: number;
|
|
162
177
|
max_spatial_run_world: number;
|
|
178
|
+
/** Issue #1409, motion_opened of a contact-edge pair only: frames whose count is a lower bound; present only when positive. */
|
|
179
|
+
lower_bound_frames?: number;
|
|
163
180
|
}
|
|
164
181
|
export interface BehindSeamsPair {
|
|
165
182
|
animation: 'idle';
|
|
@@ -176,6 +193,8 @@ export interface BehindSeamsPair {
|
|
|
176
193
|
sampled_frames?: number;
|
|
177
194
|
read_frames?: number;
|
|
178
195
|
unmeasured_frames?: number;
|
|
196
|
+
/** Issue #1409: present only when motion_opened is read from transported setup contact edges. */
|
|
197
|
+
motion_support?: typeof CONTACT_MOTION_SUPPORT;
|
|
179
198
|
}
|
|
180
199
|
export interface BehindSeamsMeasured {
|
|
181
200
|
status: 'PASS' | 'FAIL' | 'SKIP';
|
|
@@ -362,6 +381,112 @@ function overWhite(data: Uint8Array, q: number, c: number): number {
|
|
|
362
381
|
return Math.round((data[q + c] * data[q + 3]) / 255 + 255 * (1 - data[q + 3] / 255));
|
|
363
382
|
}
|
|
364
383
|
|
|
384
|
+
type Point = [number, number];
|
|
385
|
+
type ContactSupport = { cells: Set<number>; uncounted: Set<number> } | { hole: string } | null;
|
|
386
|
+
|
|
387
|
+
/** The convex hull of `points`, counter-clockwise, collinear points dropped (core's own rule in its seam module). */
|
|
388
|
+
function hullOf(points: Point[]): Point[] {
|
|
389
|
+
const sorted = [...points].sort((p, q) => p[0] - q[0] || p[1] - q[1]);
|
|
390
|
+
const turn = (o: Point, a: Point, b: Point): number => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
|
|
391
|
+
const half = (list: Point[]): Point[] => {
|
|
392
|
+
const out: Point[] = [];
|
|
393
|
+
for (const p of list) {
|
|
394
|
+
while (out.length >= 2 && turn(out[out.length - 2], out[out.length - 1], p) <= 0) out.pop();
|
|
395
|
+
out.push(p);
|
|
396
|
+
}
|
|
397
|
+
return out;
|
|
398
|
+
};
|
|
399
|
+
if (sorted.length <= 1) return sorted;
|
|
400
|
+
return [...half(sorted).slice(0, -1), ...half([...sorted].reverse()).slice(0, -1)];
|
|
401
|
+
}
|
|
402
|
+
/** Whether (qx, qy) lies in the hull, boundary included; a two-point hull is its segment. */
|
|
403
|
+
function inHull(h: readonly Point[], qx: number, qy: number): boolean {
|
|
404
|
+
if (h.length === 0) return false;
|
|
405
|
+
if (h.length === 1) return h[0][0] === qx && h[0][1] === qy;
|
|
406
|
+
if (h.length === 2) {
|
|
407
|
+
const [[x0, y0], [x1, y1]] = h;
|
|
408
|
+
if ((x1 - x0) * (qy - y0) - (qx - x0) * (y1 - y0) !== 0) return false;
|
|
409
|
+
return qx >= Math.min(x0, x1) && qx <= Math.max(x0, x1) && qy >= Math.min(y0, y1) && qy <= Math.max(y0, y1);
|
|
410
|
+
}
|
|
411
|
+
for (let i = 0; i < h.length; i++) {
|
|
412
|
+
const [x0, y0] = h[i], [x1, y1] = h[(i + 1) % h.length];
|
|
413
|
+
if ((x1 - x0) * (qy - y0) - (qx - x0) * (y1 - y0) < 0) return false;
|
|
414
|
+
}
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Issue #1409: motion support for a pair whose two drawings share no cell at half opacity at setup (no overlap band).
|
|
420
|
+
* A setup contact edge is the shared edge between a cell only `a` draws and a cell only `b` draws at 128/255 or more
|
|
421
|
+
* (core's `drawnCells`). Each edge's two corners are carried to the frame through BOTH members' attachment maps (core's
|
|
422
|
+
* `carry`); the hull of the four images is that edge's sweep. A frame cell is support when its centre lies in a sweep,
|
|
423
|
+
* neither member draws it, and either member's map carries it back onto setup material of `a` or `b` (core's `drawsAt`,
|
|
424
|
+
* the same either-view rule as core's gap). A sweep cell drawn by neither and carried back by neither is `uncounted`:
|
|
425
|
+
* where it shows rear, the count is a lower bound. Null when there is no contact edge and no faint overlap; a named
|
|
426
|
+
* `hole` when a member draws more than one fragment, a clip cuts a member, or the members overlap only below 128/255.
|
|
427
|
+
*/
|
|
428
|
+
function contactSupport(api: BehindSeamsApi, pair: MotionSeamPair, setup: Frame, frame: Frame, input: BehindSeamsFramesInput, grid: SeamGrid, label: string): ContactSupport {
|
|
429
|
+
for (const [where, f] of [['at setup', setup], [`on ${label}`, frame]] as const) for (const slot of [pair.a, pair.b]) {
|
|
430
|
+
const n = f.pieces.filter(p => p.slot === slot).length;
|
|
431
|
+
if (n !== 1) return { hole: `setup contact support requires one drawn fragment per pair member: pair "${pair.pair}" member "${slot}" draws ${n} fragments ${where}; 1 is required; motion-opened is not measured` };
|
|
432
|
+
}
|
|
433
|
+
const piece = (f: Frame, slot: string) => f.pieces.find(p => p.slot === slot)!;
|
|
434
|
+
// A clipped piece's `world` is the clipper's cut, not its attachment's vertices, so the rest triangles cannot index it
|
|
435
|
+
// (core's stock seam refuses the same drawing by name). Checked here, not left to a refusal upstream.
|
|
436
|
+
for (const [where, f] of [['at setup', setup], [`on ${label}`, frame]] as const) for (const slot of [pair.a, pair.b]) {
|
|
437
|
+
const p = piece(f, slot);
|
|
438
|
+
if (p.kind === 'mesh' && p.source !== undefined) return { hole: `setup contact support requires unclipped pair members: pair "${pair.pair}" member "${slot}" is cut by a clip ${where}, so its drawing is no longer its attachment's and cannot be carried through its attachment map; motion-opened is not measured` };
|
|
439
|
+
}
|
|
440
|
+
const sa = piece(setup, pair.a), sb = piece(setup, pair.b), fa = piece(frame, pair.a), fb = piece(frame, pair.b);
|
|
441
|
+
const restOf = (slot: string) => {
|
|
442
|
+
const attachment = frame.attachments?.find(a => a.slot === slot)?.attachment;
|
|
443
|
+
return input.rest.find(r => r.slot === slot && r.attachment === attachment);
|
|
444
|
+
};
|
|
445
|
+
const ra = restOf(pair.a), rb = restOf(pair.b);
|
|
446
|
+
if (ra === undefined || rb === undefined || setup.attachments === undefined) return null;
|
|
447
|
+
const sg = seamGridOf({ a: pair.a, b: pair.b }, input.rest, { ...setup, attachments: setup.attachments }, input.pages);
|
|
448
|
+
if (sg === null) return null;
|
|
449
|
+
const page = (p: Frame['pieces'][number]): Plate => api.pageFor(input.pages, p);
|
|
450
|
+
const sv = sg.viewport, W = sv.width;
|
|
451
|
+
const dA = drawnCells(sa, page(sa), sv), dB = drawnCells(sb, page(sb), sv);
|
|
452
|
+
const own = (k: number): number => (dA[k] ? 1 : 0) | (dB[k] ? 2 : 0);
|
|
453
|
+
const X = (x: number): number => sv.minX + x * sg.cell, Y = (y: number): number => sv.maxY - y * sg.cell;
|
|
454
|
+
const edges: Array<[Point, Point]> = [];
|
|
455
|
+
for (let y = 0; y < sv.height; y++) for (let x = 0; x < W; x++) {
|
|
456
|
+
const k = y * W + x, o = own(k);
|
|
457
|
+
if (o !== 1 && o !== 2) continue;
|
|
458
|
+
if (x + 1 < W) { const q = own(k + 1); if ((q === 1 || q === 2) && q !== o) edges.push([[X(x + 1), Y(y)], [X(x + 1), Y(y + 1)]]); }
|
|
459
|
+
if (y + 1 < sv.height) { const q = own(k + W); if ((q === 1 || q === 2) && q !== o) edges.push([[X(x), Y(y + 1)], [X(x + 1), Y(y + 1)]]); }
|
|
460
|
+
}
|
|
461
|
+
if (edges.length === 0) {
|
|
462
|
+
const faintA = new Uint8Array(sv.width * sv.height), project = api.projector(sv);
|
|
463
|
+
api.rasterisePiece(page(sa), sa, project, sv, (x, y, _r, _g, _b, alpha) => { if (alpha > 0) faintA[y * W + x] = 1; });
|
|
464
|
+
let faint = 0;
|
|
465
|
+
api.rasterisePiece(page(sb), sb, project, sv, (x, y, _r, _g, _b, alpha) => { if (alpha > 0 && faintA[y * W + x] === 1) { faintA[y * W + x] = 2; faint++; } });
|
|
466
|
+
if (faint === 0) return null;
|
|
467
|
+
return { hole: `pair "${pair.pair}" has no overlap band and no setup contact edge: its members overlap only below ${DRAWN_ALPHA}/255 at setup (${faint} cell(s) drawn by both at positive alpha, none by both at ${DRAWN_ALPHA}/255 or more, and no cell drawn by one member alone borders a cell drawn by the other alone); motion-opened is not measured` };
|
|
468
|
+
}
|
|
469
|
+
const sweeps: Point[][] = [];
|
|
470
|
+
for (const [p, q] of edges) {
|
|
471
|
+
const images = [carry(ra.triangles, ra.vertices, fa.world, -1, p[0], p[1]), carry(ra.triangles, ra.vertices, fa.world, -1, q[0], q[1]),
|
|
472
|
+
carry(rb.triangles, rb.vertices, fb.world, -1, p[0], p[1]), carry(rb.triangles, rb.vertices, fb.world, -1, q[0], q[1])];
|
|
473
|
+
if (images.some(v => v === null)) return { hole: `pair "${pair.pair}": a setup contact edge cannot be carried to ${label} because every triangle of a member has collapsed; motion-opened is not measured` };
|
|
474
|
+
sweeps.push(hullOf(images as Point[]));
|
|
475
|
+
}
|
|
476
|
+
const { viewport: v, cell } = grid, cells = new Set<number>(), uncounted = new Set<number>();
|
|
477
|
+
const nowA = drawnCells(fa, page(fa), v), nowB = drawnCells(fb, page(fb), v);
|
|
478
|
+
const material = (at: Point | null): boolean => at !== null && (drawsAt(sa, page(sa), at[0], at[1], cell) || drawsAt(sb, page(sb), at[0], at[1], cell));
|
|
479
|
+
for (let y = 0; y < v.height; y++) for (let x = 0; x < v.width; x++) {
|
|
480
|
+
const k = y * v.width + x;
|
|
481
|
+
if (nowA[k] || nowB[k]) continue;
|
|
482
|
+
const qx = v.minX + (x + 0.5) * cell, qy = v.maxY - (y + 0.5) * cell;
|
|
483
|
+
if (!sweeps.some(h => inHull(h, qx, qy))) continue;
|
|
484
|
+
if (material(carry(ra.triangles, fa.world, ra.vertices, -1, qx, qy)) || material(carry(rb.triangles, fb.world, rb.vertices, -1, qx, qy))) cells.add(k);
|
|
485
|
+
else uncounted.add(k);
|
|
486
|
+
}
|
|
487
|
+
return { cells, uncounted };
|
|
488
|
+
}
|
|
489
|
+
|
|
365
490
|
function readBehindFrame(api: BehindSeamsApi, input: BehindSeamsFramesInput, pair: MotionSeamPair, frame: Frame, setup: boolean,
|
|
366
491
|
stock: BehindSeamsStockPair | undefined, threshold: number, allowance: number, unread: (frame: string, reason: string) => void,
|
|
367
492
|
cache: Map<Frame, Map<string, RasterCache>>, pose?: BehindSeamsTurnPose): BehindSeamsFrame {
|
|
@@ -456,8 +581,10 @@ function readBehindFrame(api: BehindSeamsApi, input: BehindSeamsFramesInput, pai
|
|
|
456
581
|
unreadCells.add(at); cells.push(centre(grid, at));
|
|
457
582
|
}
|
|
458
583
|
if (cells.length === 0) continue;
|
|
584
|
+
const kept = evenlySpaced(cells.length, input.sampleCap ?? BEHIND_SAMPLE_CAP).map(i => cells[i]);
|
|
459
585
|
unreadCorridors.push({ ...checkRow('BEHIND_PART_SEAMS.unread_corridors', 'pair', false, [pair.a, pair.b]),
|
|
460
|
-
axis: step === 1 ? 'horizontal' : 'vertical', endpoints: [endpoint(left, a), endpoint(right, b)], cells, cell_count: cells.length
|
|
586
|
+
axis: step === 1 ? 'horizontal' : 'vertical', endpoints: [endpoint(left, a), endpoint(right, b)], cells: kept, cell_count: cells.length,
|
|
587
|
+
...(cells.length > kept.length ? { cells_omitted: cells.length - kept.length } : {}) });
|
|
461
588
|
continue;
|
|
462
589
|
}
|
|
463
590
|
if (a === b) continue;
|
|
@@ -478,8 +605,19 @@ function readBehindFrame(api: BehindSeamsApi, input: BehindSeamsFramesInput, pai
|
|
|
478
605
|
}
|
|
479
606
|
let motionReadable = setup;
|
|
480
607
|
const motionCells = new Map<number, SeamCell>();
|
|
608
|
+
let lowerBound = new Set<number>(), contactRead = false;
|
|
481
609
|
if (!setup) {
|
|
482
|
-
|
|
610
|
+
const complete = stock !== undefined && stock.frames === input.idle.length && stock.drawn === stock.frames;
|
|
611
|
+
const contact = complete && stock.banded === 0 && input.setup !== null && input.plantNoContact !== true
|
|
612
|
+
? contactSupport(api, pair, input.setup, frame, input, grid, label) : null;
|
|
613
|
+
if (contact !== null && 'hole' in contact) unread(label, contact.hole);
|
|
614
|
+
else if (contact !== null) {
|
|
615
|
+
// Like stock gapCovered: support cells have positive rendered alpha from some drawing.
|
|
616
|
+
motionReadable = true;
|
|
617
|
+
contactRead = true;
|
|
618
|
+
for (const k of contact.cells) if (rasters.full.data[k * 4 + 3] !== 0) { const [x, y] = centre(grid, k); motionCells.set(k, { x, y, setupTop: null, setupUnder: null }); }
|
|
619
|
+
lowerBound = contact.uncounted;
|
|
620
|
+
} else if (!complete || stock.banded !== stock.frames) unread(label, `stock transported setup-overlap support is unavailable on every ${pose === undefined ? 'idle frame' : 'named turn pose'}; motion-opened is not measured`);
|
|
483
621
|
else {
|
|
484
622
|
motionReadable = true;
|
|
485
623
|
const hits = stock.gapCovered.filter(h => h.index === frame.index);
|
|
@@ -497,7 +635,7 @@ function readBehindFrame(api: BehindSeamsApi, input: BehindSeamsFramesInput, pai
|
|
|
497
635
|
}
|
|
498
636
|
}
|
|
499
637
|
}
|
|
500
|
-
const targets = new Set([...corridors.keys(), ...motionCells.keys()]);
|
|
638
|
+
const targets = new Set([...corridors.keys(), ...motionCells.keys(), ...lowerBound]);
|
|
501
639
|
const rear = material(n), weights = new Map<number, Map<string, number>>();
|
|
502
640
|
const surviving = new Set<number>(), underflow = new Set<number>();
|
|
503
641
|
for (const piece of frame.pieces) api.rasterisePiece(api.pageFor(input.pages, piece), piece, project, viewport, (x, y, r, g, b, alpha) => {
|
|
@@ -574,6 +712,8 @@ function readBehindFrame(api: BehindSeamsApi, input: BehindSeamsFramesInput, pai
|
|
|
574
712
|
if (rear.alpha[k] <= 0 || underflow.has(k)) { motionReadable = false; unread(label, 'positive symbolic rear contribution underflowed its numeric colour weight'); continue; }
|
|
575
713
|
motionHits.add(k);
|
|
576
714
|
}
|
|
715
|
+
let uncounted = 0;
|
|
716
|
+
for (const k of lowerBound) if (rasters.hidden.data[k * 4 + 3] === 0 && rasters.full.data[k * 4 + 3] !== 0 && surviving.has(k) && rear.alpha[k] > 0) uncounted++;
|
|
577
717
|
// Motion-opened rows carry no distance; keep evenly spaced rows, built only for what is kept.
|
|
578
718
|
const hitCells = [...motionHits];
|
|
579
719
|
row.motion_opened.samples = evenlySpaced(hitCells.length, cap).map(i => sample(hitCells[i], null, true));
|
|
@@ -582,6 +722,8 @@ function readBehindFrame(api: BehindSeamsApi, input: BehindSeamsFramesInput, pai
|
|
|
582
722
|
row.motion_opened.geometric_px = motionHits.size; row.motion_opened.raw_px = motionHits.size;
|
|
583
723
|
counted(row.motion_opened, motionHits, grid, allowance);
|
|
584
724
|
if (!motionReadable) row.motion_opened.status = 'SKIP';
|
|
725
|
+
if (contactRead && motionReadable && uncounted > 0) row.motion_opened.lower_bound_cells = uncounted;
|
|
726
|
+
if (contactRead && motionReadable) row.motion_support = CONTACT_MOTION_SUPPORT;
|
|
585
727
|
if (isIdle && !plantIdleStanding) {
|
|
586
728
|
row.standing = {
|
|
587
729
|
...emptyCount('SKIP'),
|
|
@@ -673,6 +815,9 @@ export function measureBehindSeamFrames(api: BehindSeamsApi, input: BehindSeamsF
|
|
|
673
815
|
const parts: [string, string] = [pair.a, pair.b];
|
|
674
816
|
const motion = reading(frames, 'motion_opened', input.fps, allowance, parts);
|
|
675
817
|
if ((setup === null || setup.motion_opened.status === 'SKIP') && motion.status !== 'FAIL') motion.status = 'SKIP';
|
|
818
|
+
const contactRead = frames.some(f => f.motion_support !== undefined);
|
|
819
|
+
const lowerBoundFrames = frames.filter(f => f.motion_opened.lower_bound_cells !== undefined).length;
|
|
820
|
+
if (lowerBoundFrames > 0) motion.lower_bound_frames = lowerBoundFrames;
|
|
676
821
|
const idleStandingReason = motion.status !== 'SKIP' ? IDLE_STANDING_MOTION_READ_REASON : IDLE_STANDING_NO_ORACLE_REASON;
|
|
677
822
|
const rawStanding = reading(frames, 'standing', input.fps, allowance, parts);
|
|
678
823
|
const standing: BehindSeamsReading = input.plantMeasureIdleStanding === true
|
|
@@ -691,8 +836,10 @@ export function measureBehindSeamFrames(api: BehindSeamsApi, input: BehindSeamsF
|
|
|
691
836
|
const readFrames = frames.filter(f => f.motion_opened.status !== 'SKIP' &&
|
|
692
837
|
!line.unmeasured.some(u => u.pair === pair.pair && u.frame === `idle frame ${f.index}`)).length;
|
|
693
838
|
line.pairs.push({ ...checkRow('BEHIND_PART_SEAMS.pairs', 'pair', failed, parts), animation: 'idle', pair: pair.pair, parts, declared: [...pair.declared], threshold, allowance, setup, frames, motion_opened: motion, standing,
|
|
694
|
-
sampled_frames: input.idle.length, read_frames: readFrames, unmeasured_frames: input.idle.length - readFrames
|
|
839
|
+
sampled_frames: input.idle.length, read_frames: readFrames, unmeasured_frames: input.idle.length - readFrames,
|
|
840
|
+
...(contactRead ? { motion_support: CONTACT_MOTION_SUPPORT } : {}) });
|
|
695
841
|
}
|
|
842
|
+
if (line.pairs.some(p => p.motion_support !== undefined)) line.limitations += CONTACT_LIMITATIONS;
|
|
696
843
|
line.status = problems.length > start ? 'FAIL' : line.pairs.length === 0 || line.pairs.some(p => p.threshold === null || p.setup === null || p.setup.standing.status === 'SKIP' || p.motion_opened.status === 'SKIP') ? 'SKIP' : 'PASS';
|
|
697
844
|
if (declared.turn === true) {
|
|
698
845
|
line.turn = measureBehindTurnFrames(api, input, declared, problems);
|
|
@@ -760,11 +907,14 @@ function measureBehindTurnFrames(api: BehindSeamsApi, input: BehindSeamsFramesIn
|
|
|
760
907
|
// Both clauses overlap on purpose, as in idle readFrames: every path leaving motion_opened SKIP also records turn.unmeasured[].
|
|
761
908
|
const read = rows.filter(row => row.motion_opened.status !== 'SKIP' &&
|
|
762
909
|
!result.unmeasured.some(u => u.pair === pair.pair && u.frame === `turn ${row.pose}`)).length;
|
|
763
|
-
const aggregate = (kind: 'motion_opened' | 'standing'): { status: BehindSeamsCount['status']; max_px: number } => ({
|
|
910
|
+
const aggregate = (kind: 'motion_opened' | 'standing'): { status: BehindSeamsCount['status']; max_px: number; lower_bound_poses?: number } => ({
|
|
764
911
|
status: rows.some(r => r[kind].status === 'FAIL') ? 'FAIL' : complete && rows.length === turn.poses.length && rows.every(r => r[kind].status === 'PASS') ? 'PASS' : 'SKIP',
|
|
765
912
|
max_px: Math.max(0, ...rows.map(r => r[kind].px)),
|
|
766
913
|
});
|
|
767
914
|
const motion = aggregate('motion_opened');
|
|
915
|
+
const lowerBoundPoses = rows.filter(r => r.motion_opened.lower_bound_cells !== undefined).length;
|
|
916
|
+
if (lowerBoundPoses > 0) motion.lower_bound_poses = lowerBoundPoses;
|
|
917
|
+
const turnContactRead = rows.some(r => r.motion_support !== undefined);
|
|
768
918
|
const turnStandingReason = motion.status !== 'SKIP' ? TURN_STANDING_MOTION_READ_REASON : TURN_STANDING_NO_ORACLE_REASON;
|
|
769
919
|
const rawStanding = aggregate('standing');
|
|
770
920
|
const standing: BehindSeamsTurnPair['standing'] = input.plantMeasureTurnStanding === true
|
|
@@ -772,8 +922,9 @@ function measureBehindTurnFrames(api: BehindSeamsApi, input: BehindSeamsFramesIn
|
|
|
772
922
|
: { status: 'SKIP', reason: turnStandingReason, max_px: 0 };
|
|
773
923
|
result.pairs.push({ ...checkRow('BEHIND_PART_SEAMS.turn.pairs', 'pair', motion.status === 'FAIL' || standing.status === 'FAIL' || threshold !== null && read !== turn.poses.length, parts),
|
|
774
924
|
pair: pair.pair, parts, threshold, allowance, frames: rows, sampled_poses: turn.poses.length, read_poses: read, unmeasured_poses: turn.poses.length - read,
|
|
775
|
-
motion_opened: motion, standing });
|
|
925
|
+
motion_opened: motion, standing, ...(turnContactRead ? { motion_support: CONTACT_MOTION_SUPPORT } : {}) });
|
|
776
926
|
}
|
|
927
|
+
if (result.pairs.some(p => p.motion_support !== undefined)) result.limitations += CONTACT_LIMITATIONS;
|
|
777
928
|
if (input.pairs.length === 0) unread(null, 'turn selection', 'no selected seam pair; turn boundary population is unavailable', required);
|
|
778
929
|
result.status = result.pairs.some(p => p.motion_opened.status === 'FAIL' || p.standing.status === 'FAIL') || mandatoryUnread ? 'FAIL'
|
|
779
930
|
: result.pairs.length === 0 || result.pairs.some(p => p.motion_opened.status === 'SKIP') ? 'SKIP' : 'PASS';
|
|
@@ -1037,14 +1188,16 @@ export function behindSeamLines(line: BehindSeamsMeasured | null): string[] {
|
|
|
1037
1188
|
if (r.reason !== undefined) {
|
|
1038
1189
|
return `${BEHIND_SEAM_LINE}: pair "${p.pair}" ${kind} ${r.status} — ${r.reason}; threshold ${p.threshold === null ? 'undeclared' : p.threshold}, allowance ${p.allowance}`;
|
|
1039
1190
|
}
|
|
1040
|
-
|
|
1191
|
+
const support = kind === 'motion_opened' && p.motion_support !== undefined
|
|
1192
|
+
? `; support ${p.motion_support}${r.lower_bound_frames === undefined ? '' : `, lower bound on ${r.lower_bound_frames} frame(s)`}` : '';
|
|
1193
|
+
return `${BEHIND_SEAM_LINE}: pair "${p.pair}" ${kind} ${r.status} — ${r.hit_frames}/${p.frames.length} idle hit frames, sampled/read/unmeasured ${p.sampled_frames ?? p.frames.length}/${p.read_frames ?? 0}/${p.unmeasured_frames ?? 0}, max_px ${r.max_px}, max_run ${r.max_run.frames} frames (${r.max_run.seconds} s), max_spatial_run_cells ${r.max_spatial_run_cells} (${r.max_spatial_run_world} world units), earliest worst ${w === null ? 'none' : `frame ${w.index} t ${w.time}, cell ${w.cell}, box [${w.box.join(', ')}]`}; threshold ${p.threshold === null ? 'undeclared' : p.threshold}, allowance ${p.allowance}${support}`;
|
|
1041
1194
|
};
|
|
1042
1195
|
const setupStanding = setup === null ? '' : setup.standing.reason !== undefined ? `${setup.standing.status} (${setup.standing.reason}), ${setup.standing.px} cells` : setup.standing.px > 0 && setup.standing.status === 'SKIP' ? `${setup.standing.px} cells` : `${setup.standing.status}, ${setup.standing.px} cells`;
|
|
1043
1196
|
return [summary('motion_opened'), summary('standing'), `${BEHIND_SEAM_LINE}: pair "${p.pair}" setup ${setup === null ? 'SKIP — HOLE: setup not read' : `standing ${setupStanding}; motion_opened ${setup.motion_opened.status}, ${setup.motion_opened.px} cells; behind [${setup.behind_slots.join(', ')}]`}`];
|
|
1044
1197
|
}),
|
|
1045
1198
|
...(line.turn === undefined ? [] : [
|
|
1046
1199
|
`${BEHIND_SEAM_LINE}: turn ${line.turn.status} — ${line.turn.poses.length} preselected endpoint/corner pose(s); ${line.turn.limitations}`,
|
|
1047
|
-
...line.turn.pairs.flatMap(p => p.frames.map(f => `${BEHIND_SEAM_LINE}: pair "${p.pair}" turn ${f.pose} — motion_opened ${f.motion_opened.status}, ${f.motion_opened.px} cells; standing ${f.standing.reason !== undefined ? `${f.standing.status} (${f.standing.reason})` : f.standing.status}, ${f.standing.px} cells; threshold ${p.threshold}, allowance ${p.allowance}`)),
|
|
1200
|
+
...line.turn.pairs.flatMap(p => p.frames.map(f => `${BEHIND_SEAM_LINE}: pair "${p.pair}" turn ${f.pose} — motion_opened ${f.motion_opened.status}, ${f.motion_opened.px} cells${f.motion_support === undefined ? '' : ` (support ${f.motion_support}${f.motion_opened.lower_bound_cells === undefined ? '' : `, lower bound: ${f.motion_opened.lower_bound_cells} uncounted`})`}; standing ${f.standing.reason !== undefined ? `${f.standing.status} (${f.standing.reason})` : f.standing.status}, ${f.standing.px} cells; threshold ${p.threshold}, allowance ${p.allowance}`)),
|
|
1048
1201
|
...line.turn.unmeasured.map(u => `${BEHIND_SEAM_LINE}: ${u.pair === null ? 'rig' : `pair "${u.pair}"`} ${u.frame} SKIP — ${u.reason}`),
|
|
1049
1202
|
]),
|
|
1050
1203
|
...line.unmeasured.map(u => {
|
package/src/build.ts
CHANGED
|
@@ -382,6 +382,7 @@ function verifyUnderPlateMasks(
|
|
|
382
382
|
}
|
|
383
383
|
|
|
384
384
|
export interface EmitFillMasksInput {
|
|
385
|
+
requirements?: string;
|
|
385
386
|
source: string;
|
|
386
387
|
full: string;
|
|
387
388
|
head: string | null;
|
|
@@ -391,15 +392,39 @@ export interface EmitFillMasksInput {
|
|
|
391
392
|
project?: ProjectRule;
|
|
392
393
|
}
|
|
393
394
|
|
|
395
|
+
function resolveAssemblyRequirements(
|
|
396
|
+
input: { requirements?: string; config: string },
|
|
397
|
+
cfg: Pick<ReturnType<typeof loadEarlyConfig>, 'requirements' | 'assemble'>,
|
|
398
|
+
project: ProjectRule,
|
|
399
|
+
requirementsFile: ReturnType<typeof readRequirements> | null = input.requirements === undefined ? null : readRequirements(input.requirements),
|
|
400
|
+
): { requirements: BuildRequirements | null; effectiveSetup: ReturnType<typeof readRequirements>['setup_painting'] } {
|
|
401
|
+
const busyVisible = cfg.assemble.ground === 'busy' && project === 'visible';
|
|
402
|
+
const regionTake = (cfg.assemble.take ?? []).some(take => 'seed' in take);
|
|
403
|
+
// Issue #1418: a requirements file whose content reaches assembly must be the one config.requirements names,
|
|
404
|
+
// because assembly_config reads only config.requirements.
|
|
405
|
+
refuseUnnamedAssemblyRequirements(input.requirements, cfg.requirements, input.config, [
|
|
406
|
+
...(regionTake ? ['setup_painting.rgb_tolerance (a region take)'] : []),
|
|
407
|
+
...(busyVisible && requirementsFile?.setup_painting?.figure_mask !== undefined ? ['setup_painting.figure_mask (busy-visible)'] : []),
|
|
408
|
+
]);
|
|
409
|
+
// Where requirements reach assembly, assemble reads them as build does: config.requirements, or the flag when the
|
|
410
|
+
// config declares none, the two being one file when both are given (buildRequirements). Elsewhere nothing here reads them.
|
|
411
|
+
const requirements = busyVisible || regionTake
|
|
412
|
+
? buildRequirements(input.requirements, cfg.requirements, input.config) : null;
|
|
413
|
+
const effectiveSetup = requirements === null ? undefined : readRequirements(requirements.read).setup_painting;
|
|
414
|
+
return { requirements, effectiveSetup };
|
|
415
|
+
}
|
|
416
|
+
|
|
394
417
|
export function emitFillMasksStage(input: EmitFillMasksInput, log: Log): Array<{ into: string; path: string; sha256: string; opaquePx: number }> {
|
|
418
|
+
const requirementsFile = input.requirements === undefined ? null : readRequirements(input.requirements);
|
|
395
419
|
const cfg = loadEarlyConfig(input.config, 'assemble', input.project);
|
|
396
420
|
const { seam, project } = effectiveAssemblyRules(cfg.assemble, input);
|
|
421
|
+
const { requirements, effectiveSetup } = resolveAssemblyRequirements(input, cfg, project, requirementsFile);
|
|
397
422
|
const src = readSource(input.source);
|
|
398
423
|
const read = readRuns(input.full, input.head);
|
|
399
424
|
const takenRuns = applyTakenLayers(read, src, cfg, input.config);
|
|
400
425
|
const receipts = readEditorReceipts(cfg.assemble.editor_receipts, input.config);
|
|
401
426
|
const editedParts = readEditedParts(cfg.assemble.edited_parts, input.config, cfg.assemble.plan ?? []);
|
|
402
|
-
const runs = applyTakenRegions(takenRuns, src, cfg, input.config,
|
|
427
|
+
const runs = applyTakenRegions(takenRuns, src, cfg, input.config, effectiveSetup, receipts, input.source, requirements?.read);
|
|
403
428
|
const fields = stageFields(cfg, runs.single ? { w: src.width, h: src.height } : null);
|
|
404
429
|
const strippedCuts = fields.cuts.map((q) => ({ from: q.from, into: q.into, polygon: q.polygon, draw: q.draw, overlap: q.overlap }));
|
|
405
430
|
const caps = fields.limbs === undefined ? undefined : readCaps(input.config, fields.limbs);
|
|
@@ -517,19 +542,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
517
542
|
const cfg = { ...projection.config, seethrough: projection.config.seethrough! };
|
|
518
543
|
const supportDeclarations = JSON.stringify(cfg.assemble.cuts ?? []);
|
|
519
544
|
const { seam, project } = effectiveAssemblyRules(cfg.assemble, input);
|
|
520
|
-
const
|
|
521
|
-
const regionTake = (cfg.assemble.take ?? []).some(take => 'seed' in take);
|
|
522
|
-
// Issue #1418: a requirements file whose content reaches assembly must be the one config.requirements names,
|
|
523
|
-
// because assembly_config reads only config.requirements.
|
|
524
|
-
refuseUnnamedAssemblyRequirements(input.requirements, cfg.requirements, input.config, [
|
|
525
|
-
...(regionTake ? ['setup_painting.rgb_tolerance (a region take)'] : []),
|
|
526
|
-
...(busyVisible && requirementsFile?.setup_painting?.figure_mask !== undefined ? ['setup_painting.figure_mask (busy-visible)'] : []),
|
|
527
|
-
]);
|
|
528
|
-
// Where requirements reach assembly, assemble reads them as build does: config.requirements, or the flag when the
|
|
529
|
-
// config declares none, the two being one file when both are given (buildRequirements). Elsewhere nothing here reads them.
|
|
530
|
-
const requirements = busyVisible || regionTake
|
|
531
|
-
? buildRequirements(input.requirements, cfg.requirements, input.config) : null;
|
|
532
|
-
const effectiveSetup = requirements === null ? undefined : readRequirements(requirements.read).setup_painting;
|
|
545
|
+
const { requirements, effectiveSetup } = resolveAssemblyRequirements(input, cfg, project, requirementsFile);
|
|
533
546
|
const src = readSource(input.source);
|
|
534
547
|
const read = readRuns(input.full, input.head);
|
|
535
548
|
// Issue #946: every declared receipt is held to its file, and under `required` every edited image needs one, before anything is assembled.
|