Skip to content

feat: support the OL (Other Long) value representation - #632

Merged
wayfarer3130 merged 1 commit into
masterfrom
other-long-vr
Nov 11, 2026
Merged

wayfarer3130 merged 1 commit into
masterfrom
other-long-vr

Conversation

@pieper

@pieper pieper commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

The gap

OL was missing entirely. VRinstances held only OB, OD, OF and OW, so
createByTypeString("OL") fell through to the "Invalid vr type … - using UN" path. An OL
element could not be written at all, and reading one produced an element whose VR was wrong on the
wire.

It is a stream of 32-bit words, so it behaves exactly like its siblings: a 32-bit length, a single
value, no multiplicity. The implementation is the same BinaryRepresentation subclass, plus "OL"
in length32VRs and singleVRs.

What needs it

The large mesh attributes of Surface Segmentation. TrianglePointIndexList (0066,0023) is OW,
and 16-bit indices cap a surface at 65 535 points. LongTrianglePointIndexList (0066,0041) is
the OL form that lifts the cap, with its Edge (0066,0042) and Vertex (0066,0043) counterparts.

Surfaces of a few million vertices are ordinary output from a marching-cubes or surface-nets
pipeline — the case that prompted this was 6 million — so the OW cap is reached routinely rather
than exceptionally.

Two things for a reviewer, neither fixed here

  • The shipped dictionary still lists (0066,0041) as UL with VM 3-3n. That is the definition
    CP-1365 left behind and CP-1499
    ("Fix CP 1365 setback with Long xxx Index List VR") corrected to OL/1. Writing by tag is
    unaffected; writing by keyword needs _vrMap to say which VR is meant, which already works
    and now has a test. Regenerating the dictionary is a separate change, and since the dictionary is
    generated rather than hand-edited it did not belong in this PR.
  • OV (Other Very Long) is the same gap, deliberately left out to keep this to one topic. It
    would be the same three lines.

Interaction with #622

#622 adds a binaryVRWordWidths table for byte swapping in Explicit VR Big Endian. When both land,
OL needs an entry of 4 there, since PS3.5 requires swapping within each 32-bit word. The two
branches do not otherwise touch the same lines, so they merge cleanly in either order — this one is
based on master, not on #622.

Tests

test/other-long.test.js, 7 tests: that OL resolves to a real VR rather than UN and reports a
32-bit length and no multiplicity; a round trip of values above 0xFFFF; the bytes on the wire
carrying OL and a 32-bit length; a 600 000-index surface; an empty value; the _vrMap route for
writing by keyword; and a lossless re-encode.

All seven fail without the change.

Full suite: 26 suites / 361 tests.

Disclosure

AI-assisted (Claude), per the process in #517.

OL was missing entirely. VRinstances held only OB, OD, OF and OW, so
createByTypeString("OL") fell through to the "Invalid vr type" path and
returned UN - an OL element could not be written at all, and reading one
gave back an element whose VR was wrong on the wire.

It is a stream of 32 bit words, so it behaves exactly like its siblings: a
32 bit length, a single value, no multiplicity. The implementation is the
same BinaryRepresentation subclass with "OL" added to length32VRs and
singleVRs.

What needs it: the large mesh attributes of Surface Segmentation. Triangle
Point Index List (0066,0023) is OW, and 16 bit indices cap a surface at
65535 points; Long Triangle Point Index List (0066,0041) is the OL form
that lifts the cap, along with its Edge (0066,0042) and Vertex (0066,0043)
counterparts. Surfaces of a few million vertices are ordinary output from a
marching-cubes or surface-nets pipeline, so this is not an edge case.

Two things a reviewer should know, neither of them fixed here:

- The dictionary that ships with dcmjs still lists (0066,0041) as UL with
  VM 3-3n. That is the definition CP-1365 left behind and CP-1499 ("Fix CP
  1365 setback with Long xxx Index List VR") corrected to OL/1. Writing by
  TAG is unaffected; writing by KEYWORD needs _vrMap to say which VR is
  meant, which already works and now has a test. Regenerating the
  dictionary is a separate change.
- OV (Other Very Long) is the same gap and is deliberately not included, to
  keep this to one topic. It would be the same three lines.

#622 adds a binaryVRWordWidths table for byte swapping in Explicit VR Big
Endian; when both land, OL needs an entry of 4 there, since PS3.5 requires
swapping within each 32 bit word. The two branches do not otherwise touch
the same lines.

All seven tests fail without the change.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@netlify

netlify Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for dcmjs2 ready!

Name Link
🔨 Latest commit 73dcedf
🔍 Latest deploy log https://app.netlify.com/projects/dcmjs2/deploys/6ae6322deb08e1b5427b06ee
😎 Deploy Preview https://deploy-preview-632--dcmjs2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@wayfarer3130
wayfarer3130 merged commit 5b215ca into master Nov 11, 2026
20 checks passed
@wayfarer3130
wayfarer3130 deleted the other-long-vr branch November 11, 2026 14:55
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.52.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

wayfarer3130 added a commit that referenced this pull request Nov 25, 2026
Record master (d236313) as a parent with -s ours; the tree stays the 1.0-beta tree. Master fixes #657, #622, #510, #625 and #632 are not in 1.x and need ports.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
wayfarer3130 added a commit that referenced this pull request Nov 25, 2026
* fix: support the OL (Other Long) value representation

1.0 port of #632 (commit 5b215ca).

The Vrs registry in packages/core had no OL class, so
createByTypeString("OL") fell back to UN. Add OtherLongString, a
BinaryRepresentation like OF and OD, register it in Vrs, and give OL
the seed flags "length32 single byteStream" in constants/vrs.js. These
are the flags of 0.x: a 32 bit length, a single value, and not in the
read-side singleVRs list.

The 0.x test test/other-long.test.js moves to
test/issues/pr632-other-long.test.js. Six of its seven tests fail
without the change; the _vrMap test already passes.

Other changes for OL:
- The #457 contract test pinned OL as a UN fallback; it now pins only
  OV and SV.
- test/core/registries.test.js uses OV as its unknown VR for
  registerVr, because OL is now registered.
- The texts that said OL has no class change: the vrs.js comment, the
  registerVr example, REG-I-5 in docs/specs/registries-implementation.md,
  the createByTypeString comment, and the absentValues comment.
- The bundle-size ceilings move to 1.081 and 1.063 for the new class.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: record that OL reads and writes as OL

Maintainer decision Q2 of the review of the 1.0 port of #632: one line in docs/MIGRATION.md, and one bullet in beta-1-release-notes.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(core): support the SV and OV value representations

Maintainer request on #653. Before, OV and SV fell back to UN, so an
element could not be written with its own VR.

- OV: OtherVeryLongString, a BinaryRepresentation with raw bytes, like
  OL. Seed flags "length32 single byteStream", the same as OL; OB, OW
  and OF also have readSingle, but OL and OV do not, so the exported
  singleVRs list does not change (REG-I-4).
- SV: Signed64BitVeryLong extends Unsigned64BitVeryLong, which now takes
  the type and the stream accessor (BigUint64 or BigInt64). SV reads a
  BigInt with readBigInt64 and writes with writeBigInt64, and coerces a
  Number or a numeric string with BigInt(), as UV does. Seed flags
  "binary length32", the same as UV.
- BufferStream.readBigInt64/writeBigInt64 and
  SplitDataView.getBigInt64/setBigInt64 mirror the BigUint64 methods.
- VALID_VRS, BULKDATA_VRS, BINARY_VRS and the schema rules already
  listed OV and SV. No other code special-cases UV.

Tests: test/issues/vr-sv-ov.test.js (OV bytes; SV negative, the 64 bit
limits and a Number input) fails before this change. The #457 test and
the registerVr test of test/core/registries.test.js now use codes that
are not DICOM VRs (ZZ, QQ, XX), and the #457 once-per-type test now
expects exactly one warning. test/core/absentValues.test.js no longer
filters the "Invalid vr type" warning.

Docs: the JSDoc of UV, SV and OV cites PS3.5 Section 6.2, Table 6.2-1.
REG-I-5, the docs/MIGRATION.md OL line and the beta 1 release notes
bullet now cover OV and SV. The bundle-size ceilings move to 1.083 and
1.065.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(generator): write SV and UV to DICOM JSON as a Number or a string

DicomWebJsonWriter put the BigInt value of an SV or UV element in Value,
and JSON.stringify threw. PS3.18 Table F.2.3-1 allows a Number or a
String, so a safe integer is a Number and a larger value is a decimal
string, as for DS and IS beyond 2^53.

Also: rewrap a long JSDoc line, rename the #457 describe title, and
raise the bundle ceilings to 1.086 and 1.067 after the merge of
1.0-beta (measured x1.0851 and x1.0666).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants