dicom-three 0.1.0 → 0.2.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/CHANGELOG.md +6 -1
- package/README.md +6 -2
- package/dist/dicom3.js +247 -205
- package/dist/dicom3.umd.cjs +35 -10
- package/dist/types/viewers/orthoSlicer/orthoSlicer.d.ts +2 -2
- package/dist/types/viewers/slice/slice.d.ts +5 -1
- package/package.json +1 -1
package/dist/dicom3.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var a = (i, t, e) =>
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
var Se = Object.defineProperty;
|
|
2
|
+
var _e = (i, t, e) => t in i ? Se(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var a = (i, t, e) => _e(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import be from "@cornerstonejs/dicom-codec";
|
|
5
|
+
import ce from "dicom-parser";
|
|
6
6
|
import * as u from "three";
|
|
7
|
-
import { Vector3 as
|
|
7
|
+
import { Vector3 as I, Box3 as Pe, Matrix3 as Ie } from "three";
|
|
8
8
|
class K {
|
|
9
9
|
constructor(t) {
|
|
10
10
|
a(this, "_dataSet");
|
|
@@ -12,7 +12,7 @@ class K {
|
|
|
12
12
|
this._arrayBuffer = t.buffer;
|
|
13
13
|
try {
|
|
14
14
|
const e = new Uint8Array(this._arrayBuffer);
|
|
15
|
-
this._dataSet =
|
|
15
|
+
this._dataSet = ce.parseDicom(e);
|
|
16
16
|
} catch (e) {
|
|
17
17
|
throw console.log(e), new Error("parsers.dicom could not parse the file");
|
|
18
18
|
}
|
|
@@ -416,7 +416,7 @@ class K {
|
|
|
416
416
|
}
|
|
417
417
|
async _decodePixelData() {
|
|
418
418
|
const t = this.transferSyntaxUID, e = this._dataSet.elements.x7fe00010, n = new Uint8Array(this._dataSet.byteArray.buffer, e.dataOffset, e.length), r = this.bitsAllocated, o = this.columns, s = this.rows, l = this.samplesPerPixel, c = this.pixelRepresentation === 1;
|
|
419
|
-
return await
|
|
419
|
+
return await be.decode(n, { rows: s, columns: o, bitsAllocated: r, samplesPerPixel: l, signed: c }, t);
|
|
420
420
|
}
|
|
421
421
|
_interpretAsRGB(t) {
|
|
422
422
|
return ["RGB", "YBR_RCT", "YBR_ICT", "YBR_FULL_422"].indexOf(t) !== -1;
|
|
@@ -440,9 +440,9 @@ class K {
|
|
|
440
440
|
e = new Uint16Array(t.length);
|
|
441
441
|
else
|
|
442
442
|
throw new Error(`Unsupported typed array: ${t}`);
|
|
443
|
-
let s = t.length / 3, l = 0, c = 0, m = s,
|
|
443
|
+
let s = t.length / 3, l = 0, c = 0, m = s, p = s * 2;
|
|
444
444
|
for (let f = 0; f < s; f++)
|
|
445
|
-
e[l++] = t[c++], e[l++] = t[m++], e[l++] = t[
|
|
445
|
+
e[l++] = t[c++], e[l++] = t[m++], e[l++] = t[p++];
|
|
446
446
|
} else if (n === "YBR_FULL") {
|
|
447
447
|
if (t instanceof Int8Array)
|
|
448
448
|
e = new Int8Array(t.length);
|
|
@@ -456,8 +456,8 @@ class K {
|
|
|
456
456
|
throw new Error(`unsuported typed array: ${t}`);
|
|
457
457
|
let s = t.length / 3, l = 0, c = 0;
|
|
458
458
|
for (let m = 0; m < s; m++) {
|
|
459
|
-
let
|
|
460
|
-
e[c++] =
|
|
459
|
+
let p = t[l++], f = t[l++], g = t[l++];
|
|
460
|
+
e[c++] = p + 1.402 * (g - 128), e[c++] = p - 0.34414 * (f - 128) - 0.71414 * (g - 128), e[c++] = p + 1.772 * (f - 128);
|
|
461
461
|
}
|
|
462
462
|
} else
|
|
463
463
|
throw new Error(`photometric interpolation not supported: ${n}`);
|
|
@@ -483,7 +483,7 @@ class K {
|
|
|
483
483
|
}[t] ?? "none";
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
|
-
class
|
|
486
|
+
class nt extends u.Loader {
|
|
487
487
|
constructor(t) {
|
|
488
488
|
super(t);
|
|
489
489
|
}
|
|
@@ -564,15 +564,15 @@ class it extends u.Loader {
|
|
|
564
564
|
return (await Promise.all(e)).filter((r) => r.length > 0);
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
|
-
const
|
|
567
|
+
const M = 1e-4;
|
|
568
568
|
function A(i) {
|
|
569
569
|
if (i.length !== 6 || !i.every(Number.isFinite)) throw new Error("Invalid ImageOrientationPatient");
|
|
570
570
|
const t = Math.hypot(...i.slice(0, 3)), e = Math.hypot(...i.slice(3));
|
|
571
|
-
if (Math.abs(t - 1) >
|
|
571
|
+
if (Math.abs(t - 1) > M || Math.abs(e - 1) > M || Math.abs(i[0] * i[3] + i[1] * i[4] + i[2] * i[5]) > M)
|
|
572
572
|
throw new Error("ImageOrientationPatient must contain orthonormal direction cosines");
|
|
573
573
|
return i.map((n, r) => n / (r < 3 ? t : e));
|
|
574
574
|
}
|
|
575
|
-
function
|
|
575
|
+
function ue(i) {
|
|
576
576
|
const t = [i[1] * i[5] - i[2] * i[4], i[2] * i[3] - i[0] * i[5], i[0] * i[4] - i[1] * i[3]], e = Math.hypot(...t);
|
|
577
577
|
return t.map((n) => n / e);
|
|
578
578
|
}
|
|
@@ -587,7 +587,7 @@ function j(i, t = !0) {
|
|
|
587
587
|
}))
|
|
588
588
|
try {
|
|
589
589
|
const r = i.reduce((s, l) => s.id < l.id ? s : l), o = A(r.imageOrientation);
|
|
590
|
-
i.every((s) => A(s.imageOrientation).every((l, c) => Math.abs(l - o[c]) <=
|
|
590
|
+
i.every((s) => A(s.imageOrientation).every((l, c) => Math.abs(l - o[c]) <= M)) && (e = ue(o));
|
|
591
591
|
} catch {
|
|
592
592
|
}
|
|
593
593
|
const n = e ? (r) => W(r.imagePosition, e) : i.every((r) => Number.isFinite(r.instanceNumber)) ? (r) => r.instanceNumber : i.every((r) => Number.isFinite(r.sliceLocation)) ? (r) => r.sliceLocation : () => 0;
|
|
@@ -602,23 +602,23 @@ const Te = (i) => {
|
|
|
602
602
|
};
|
|
603
603
|
function Q(i, t, e) {
|
|
604
604
|
var n, r, o, s, l, c, m;
|
|
605
|
-
for (const
|
|
606
|
-
const f = (o = (r = (n = i.elements[
|
|
605
|
+
for (const p of ["x52009230", "x52009229"]) {
|
|
606
|
+
const f = (o = (r = (n = i.elements[p]) == null ? void 0 : n.items) == null ? void 0 : r[0]) == null ? void 0 : o.dataSet, g = (m = (c = (l = (s = f == null ? void 0 : f.elements[t]) == null ? void 0 : s.items) == null ? void 0 : l[0]) == null ? void 0 : c.dataSet) == null ? void 0 : m.string(e);
|
|
607
607
|
if (g !== void 0) return g;
|
|
608
608
|
}
|
|
609
609
|
return i.string(e);
|
|
610
610
|
}
|
|
611
|
-
const
|
|
611
|
+
const rt = async (i) => {
|
|
612
612
|
var n, r, o;
|
|
613
613
|
const t = /* @__PURE__ */ new Map();
|
|
614
614
|
for (const s of Array.from(i))
|
|
615
615
|
try {
|
|
616
|
-
const l = await s.arrayBuffer(), c =
|
|
616
|
+
const l = await s.arrayBuffer(), c = ce.parseDicom(new Uint8Array(l), { untilTag: "x7fe00010" }), m = c.string("x0020000e") || "unknown", p = c.string("x00080018") || "unknown", f = c.floatString("x00201041"), g = (n = Q(c, "x00209113", "x00200032")) == null ? void 0 : n.split("\\").map(parseFloat), v = (r = Q(c, "x00209116", "x00200037")) == null ? void 0 : r.split("\\").map(parseFloat), w = g == null ? void 0 : g[2], y = c.intString("x00200013"), b = c.uint16("x00280010") ?? -1, P = c.uint16("x00280011") ?? -1;
|
|
617
617
|
if (b <= 0 || P <= 0)
|
|
618
618
|
throw new Error(`Invalid DICOM dimensions: rows=${b}, columns=${P}`);
|
|
619
|
-
const
|
|
619
|
+
const T = {
|
|
620
620
|
file: s,
|
|
621
|
-
SOPInstanceUID:
|
|
621
|
+
SOPInstanceUID: p,
|
|
622
622
|
rows: b,
|
|
623
623
|
columns: P,
|
|
624
624
|
numberOfFrames: c.intString("x00280008") ?? 1,
|
|
@@ -632,7 +632,7 @@ const nt = async (i) => {
|
|
|
632
632
|
modality: c.string("x00080060"),
|
|
633
633
|
instanceNumber: y
|
|
634
634
|
};
|
|
635
|
-
t.has(m) || t.set(m, []), (o = t.get(m)) == null || o.push(
|
|
635
|
+
t.has(m) || t.set(m, []), (o = t.get(m)) == null || o.push(T);
|
|
636
636
|
} catch (l) {
|
|
637
637
|
console.error(`Error parsing DICOM file: ${s.name}`, l);
|
|
638
638
|
}
|
|
@@ -646,7 +646,7 @@ function ee() {
|
|
|
646
646
|
const i = new Error("DICOM loading was aborted");
|
|
647
647
|
return i.name = "AbortError", i;
|
|
648
648
|
}
|
|
649
|
-
class
|
|
649
|
+
class ot {
|
|
650
650
|
constructor(t = {}) {
|
|
651
651
|
a(this, "workerFactory");
|
|
652
652
|
a(this, "worker");
|
|
@@ -708,8 +708,8 @@ class rt {
|
|
|
708
708
|
};
|
|
709
709
|
try {
|
|
710
710
|
n.postMessage(m);
|
|
711
|
-
} catch (
|
|
712
|
-
this.clearActiveRequest(), l(
|
|
711
|
+
} catch (p) {
|
|
712
|
+
this.clearActiveRequest(), l(p instanceof Error ? p : new Error(String(p)));
|
|
713
713
|
}
|
|
714
714
|
});
|
|
715
715
|
}
|
|
@@ -734,7 +734,7 @@ class rt {
|
|
|
734
734
|
this.worker && (this.worker.removeEventListener("message", this.handleMessage), this.worker.removeEventListener("error", this.handleWorkerError), this.worker.removeEventListener("messageerror", this.handleMessageError), this.worker.terminate(), this.worker = void 0);
|
|
735
735
|
}
|
|
736
736
|
}
|
|
737
|
-
const
|
|
737
|
+
const Ee = /* @__PURE__ */ new Map([
|
|
738
738
|
["8_false_1", { format: u.RedIntegerFormat, internalFormat: "R8UI", textureType: u.UnsignedByteType }],
|
|
739
739
|
["8_true_1", { format: u.RedIntegerFormat, internalFormat: "R8I", textureType: u.ByteType }],
|
|
740
740
|
["8_false_3", { format: u.RGBIntegerFormat, internalFormat: "RGB8UI", textureType: u.UnsignedByteType }],
|
|
@@ -746,7 +746,7 @@ const Ie = /* @__PURE__ */ new Map([
|
|
|
746
746
|
["32_false_1", { format: u.RedFormat, internalFormat: "R32F", textureType: u.FloatType }],
|
|
747
747
|
["32_true_1", { format: u.RedFormat, internalFormat: "R32F", textureType: u.FloatType }]
|
|
748
748
|
]);
|
|
749
|
-
class
|
|
749
|
+
class Fe {
|
|
750
750
|
constructor(t) {
|
|
751
751
|
a(this, "_data3DTexture");
|
|
752
752
|
this.stack = t;
|
|
@@ -754,19 +754,19 @@ class Ee {
|
|
|
754
754
|
get data3DTexture() {
|
|
755
755
|
if (this._data3DTexture)
|
|
756
756
|
return this._data3DTexture;
|
|
757
|
-
const { pixelData: t, columns: e, rows: n, numberOfFrames: r, bitsAllocated: o, signed: s, samplesPerPixel: l } = this.stack, { format: c, internalFormat: m, textureType:
|
|
757
|
+
const { pixelData: t, columns: e, rows: n, numberOfFrames: r, bitsAllocated: o, signed: s, samplesPerPixel: l } = this.stack, { format: c, internalFormat: m, textureType: p } = Ee.get(`${o}_${s}_${l}`) ?? {
|
|
758
758
|
format: u.RedIntegerFormat,
|
|
759
759
|
internalFormat: "R16UI",
|
|
760
760
|
textureType: u.UnsignedShortType
|
|
761
761
|
};
|
|
762
|
-
return this._data3DTexture = new u.Data3DTexture(t, e, n, r), this._data3DTexture.format = c, this._data3DTexture.internalFormat = m, this._data3DTexture.type =
|
|
762
|
+
return this._data3DTexture = new u.Data3DTexture(t, e, n, r), this._data3DTexture.format = c, this._data3DTexture.internalFormat = m, this._data3DTexture.type = p, this._data3DTexture.minFilter = u.NearestFilter, this._data3DTexture.magFilter = u.NearestFilter, this._data3DTexture.unpackAlignment = 1, this._data3DTexture.needsUpdate = !0, this._data3DTexture;
|
|
763
763
|
}
|
|
764
764
|
dispose() {
|
|
765
765
|
const t = this._data3DTexture;
|
|
766
766
|
this._data3DTexture = void 0, t == null || t.dispose();
|
|
767
767
|
}
|
|
768
768
|
}
|
|
769
|
-
function
|
|
769
|
+
function De(i, t) {
|
|
770
770
|
switch (i) {
|
|
771
771
|
case 8:
|
|
772
772
|
return t ? Int8Array : Uint8Array;
|
|
@@ -779,22 +779,22 @@ function Fe(i, t) {
|
|
|
779
779
|
throw new Error(`Unsupported bitsAllocated: ${i}`);
|
|
780
780
|
}
|
|
781
781
|
}
|
|
782
|
-
async function
|
|
783
|
-
const { rows: r, columns: o, numberOfFrames: s, bitsAllocated: l, samplesPerPixel: c, signed: m } = t,
|
|
782
|
+
async function Re(i, t, e, n) {
|
|
783
|
+
const { rows: r, columns: o, numberOfFrames: s, bitsAllocated: l, samplesPerPixel: c, signed: m } = t, p = De(l, m), f = new p(r * o * c * s);
|
|
784
784
|
let g = 0, v = 0;
|
|
785
785
|
for await (const w of i) {
|
|
786
786
|
e == null || e(w, v);
|
|
787
787
|
const { imageFrame: y } = await w.extractPixelData(), b = w.numberOfFrames ?? 1, P = r * o * c * b;
|
|
788
|
-
if (y.byteLength < P *
|
|
788
|
+
if (y.byteLength < P * p.BYTES_PER_ELEMENT)
|
|
789
789
|
throw new Error(`Pixel data length mismatch: expected ${P}, got ${y.length}`);
|
|
790
|
-
const
|
|
791
|
-
f.set(
|
|
790
|
+
const T = new p(y.buffer, y.byteOffset, P);
|
|
791
|
+
f.set(T, g), g += T.length;
|
|
792
792
|
}
|
|
793
793
|
if (g !== f.length)
|
|
794
794
|
throw new Error(`Pixel data length mismatch: expected ${f.length}, got ${g}`);
|
|
795
795
|
return f;
|
|
796
796
|
}
|
|
797
|
-
const N = 1e-3,
|
|
797
|
+
const N = 1e-3, he = 1e-4;
|
|
798
798
|
function Ce(i, t) {
|
|
799
799
|
const e = i.numberOfFrames ?? 1;
|
|
800
800
|
return Array.from({ length: e }, (n, r) => {
|
|
@@ -830,49 +830,49 @@ function Ce(i, t) {
|
|
|
830
830
|
});
|
|
831
831
|
}
|
|
832
832
|
function Me(i, t) {
|
|
833
|
-
return Math.abs(i - t) <= 1e-6 +
|
|
833
|
+
return Math.abs(i - t) <= 1e-6 + he * Math.max(Math.abs(i), Math.abs(t));
|
|
834
834
|
}
|
|
835
835
|
function _(i) {
|
|
836
836
|
throw new Error(`${i}; a regular 3D texture cannot represent this series. Split the series or resample it before loading`);
|
|
837
837
|
}
|
|
838
|
-
function
|
|
838
|
+
function Ae(i) {
|
|
839
839
|
if (!i.length) throw new Error("No DICOM frames provided");
|
|
840
|
-
const t = j(i, !1), e = i.reduce((h,
|
|
840
|
+
const t = j(i, !1), e = i.reduce((h, d) => h.id < d.id ? h : d);
|
|
841
841
|
for (const h of ["seriesUID", "referenceUID", "stackId", "modality"])
|
|
842
|
-
new Set(i.map((
|
|
842
|
+
new Set(i.map((d) => d[h]).filter((d) => d != null)).size > 1 && _(`Inconsistent ${h} in series`), i.some((d) => d[h] != null) && i.some((d) => d[h] == null) && _(`Incomplete ${h} in series`);
|
|
843
843
|
for (const h of ["imagePosition", "imageOrientation", "pixelSpacing"])
|
|
844
|
-
i.some((
|
|
844
|
+
i.some((d) => d[h] != null) && i.some((d) => d[h] == null) && _("Incomplete spatial metadata in part of the series");
|
|
845
845
|
const n = /* @__PURE__ */ new Set();
|
|
846
846
|
for (const h of i) {
|
|
847
847
|
if (!h.id.startsWith(":") && n.has(h.id) && _("Duplicate SOP instance/frame"), n.add(h.id), h.temporalPosition != null && (!Number.isSafeInteger(h.temporalPosition) || h.temporalPosition < 1)) throw new Error("Invalid temporal position");
|
|
848
848
|
if (h.imagePosition && (h.imagePosition.length !== 3 || !h.imagePosition.every(Number.isFinite))) throw new Error("Invalid ImagePositionPatient");
|
|
849
|
-
if (h.imageOrientation && A(h.imageOrientation), h.pixelSpacing && (h.pixelSpacing.length !== 2 || !h.pixelSpacing.every((
|
|
849
|
+
if (h.imageOrientation && A(h.imageOrientation), h.pixelSpacing && (h.pixelSpacing.length !== 2 || !h.pixelSpacing.every((d) => Number.isFinite(d) && d > 0))) throw new Error("Invalid PixelSpacing");
|
|
850
850
|
if (h.sliceThickness != null && (!Number.isFinite(h.sliceThickness) || h.sliceThickness <= 0)) throw new Error("Invalid SliceThickness");
|
|
851
851
|
if (h.spacingBetweenSlices != null && (!Number.isFinite(h.spacingBetweenSlices) || h.spacingBetweenSlices === 0)) throw new Error("Invalid SpacingBetweenSlices");
|
|
852
852
|
(!Number.isFinite(h.rescaleSlope) || !Number.isFinite(h.rescaleIntercept) || h.rescaleSlope !== e.rescaleSlope || h.rescaleIntercept !== e.rescaleIntercept) && _("Varying or invalid rescale parameters");
|
|
853
853
|
}
|
|
854
854
|
const r = i.map((h) => !!(h.imagePosition && h.imageOrientation && h.pixelSpacing));
|
|
855
855
|
r.some(Boolean) && !r.every(Boolean) && _("Incomplete spatial metadata in part of the series");
|
|
856
|
-
const o = e.modality === "XA", s = new Set(i.map((h) => h.temporalPosition).filter((h) => h != null)), l = s.size > 1 || i.some((h) => (h.frameTime ?? 0) > 0), c = !!e.imagePosition && i.every((h) => h.imagePosition && Math.hypot(...h.imagePosition.map((
|
|
857
|
-
s.size > 1 &&
|
|
856
|
+
const o = e.modality === "XA", s = new Set(i.map((h) => h.temporalPosition).filter((h) => h != null)), l = s.size > 1 || i.some((h) => (h.frameTime ?? 0) > 0), c = !!e.imagePosition && i.every((h) => h.imagePosition && Math.hypot(...h.imagePosition.map((d, S) => d - e.imagePosition[S])) <= N), m = i.length > 1 && c && i.every((h) => h.sourceFrameCount > 1 && !h.perFramePosition), p = !o && r.every(Boolean) && !m && !(l && c);
|
|
857
|
+
s.size > 1 && p && i.length > 1 && _("Mixed spatial and temporal dimensions");
|
|
858
858
|
const f = e.imageOrientation ? A(e.imageOrientation) : [1, 0, 0, 0, 1, 0], g = e.pixelSpacing ?? [1, 1];
|
|
859
859
|
for (const h of i)
|
|
860
|
-
h.imageOrientation && A(h.imageOrientation).some((
|
|
861
|
-
const v =
|
|
860
|
+
h.imageOrientation && A(h.imageOrientation).some((d, S) => Math.abs(d - f[S]) > M) && _("Inconsistent image orientations"), h.pixelSpacing && h.pixelSpacing.some((d, S) => !Me(d, g[S])) && _("Inconsistent pixel spacing"), o && ["distanceSourceToDetector", "distanceSourceToPatient", "positionerPrimaryAngle", "positionerSecondaryAngle"].some((d) => h[d] !== e[d]) && _("Varying XA detector geometry");
|
|
861
|
+
const v = p ? j(i) : t, w = v[0];
|
|
862
862
|
let y, b = w.spacingBetweenSlices ?? void 0;
|
|
863
|
-
if (
|
|
864
|
-
const h =
|
|
863
|
+
if (p) {
|
|
864
|
+
const h = ue(f);
|
|
865
865
|
if (i.length > 1) {
|
|
866
|
-
const
|
|
867
|
-
y =
|
|
868
|
-
const D = Math.max(N, Math.hypot(...y) *
|
|
866
|
+
const d = w.imagePosition, S = v[v.length - 1].imagePosition;
|
|
867
|
+
y = d.map((E, z) => (S[z] - E) / (i.length - 1)), b = W(y, h), b <= N && _("Duplicate or coplanar slice positions");
|
|
868
|
+
const D = Math.max(N, Math.hypot(...y) * he);
|
|
869
869
|
for (let E = 1; E < v.length; E++) {
|
|
870
|
-
const
|
|
871
|
-
W(
|
|
870
|
+
const z = v[E].imagePosition;
|
|
871
|
+
W(z, h) - W(v[E - 1].imagePosition, h) <= N && _("Duplicate or coplanar slice positions"), Math.hypot(...z.map((ve, J) => ve - d[J] - E * y[J])) > D && _("Irregular slice positions");
|
|
872
872
|
}
|
|
873
873
|
} else {
|
|
874
|
-
const
|
|
875
|
-
y = h.map((S) => S *
|
|
874
|
+
const d = b ?? w.sliceThickness ?? 1;
|
|
875
|
+
y = h.map((S) => S * d);
|
|
876
876
|
}
|
|
877
877
|
} else
|
|
878
878
|
y = [0, 0, 0];
|
|
@@ -883,7 +883,7 @@ function Re(i) {
|
|
|
883
883
|
sliceThickness: w.sliceThickness ?? 1,
|
|
884
884
|
spacingBetweenSlices: b,
|
|
885
885
|
sliceStep: y,
|
|
886
|
-
frameAxis:
|
|
886
|
+
frameAxis: p ? "space" : "sequence",
|
|
887
887
|
windowWidth: w.windowWidth,
|
|
888
888
|
windowCenter: w.windowCenter,
|
|
889
889
|
rescaleSlope: w.rescaleSlope,
|
|
@@ -893,10 +893,10 @@ function Re(i) {
|
|
|
893
893
|
distanceSourceToPatient: w.distanceSourceToPatient,
|
|
894
894
|
positionerPrimaryAngle: w.positionerPrimaryAngle,
|
|
895
895
|
positionerSecondaryAngle: w.positionerSecondaryAngle
|
|
896
|
-
},
|
|
897
|
-
return { geometry: P, order: v.map((h) =>
|
|
896
|
+
}, T = new Map(i.map((h, d) => [h, d]));
|
|
897
|
+
return { geometry: P, order: v.map((h) => T.get(h)) };
|
|
898
898
|
}
|
|
899
|
-
function
|
|
899
|
+
function Ve(i, t, e) {
|
|
900
900
|
if (t.every((o, s) => o === s)) return;
|
|
901
901
|
const n = i.slice(0, e), r = new Uint8Array(t.length);
|
|
902
902
|
for (let o = 0; o < t.length; o++) {
|
|
@@ -911,12 +911,12 @@ function Ae(i, t, e) {
|
|
|
911
911
|
}
|
|
912
912
|
}
|
|
913
913
|
async function Oe(i, t, e) {
|
|
914
|
-
const n = [], r = await
|
|
914
|
+
const n = [], r = await Re(i, t, (l, c) => {
|
|
915
915
|
for (const m of Ce(l, c)) n.push(m);
|
|
916
|
-
}), { geometry: o, order: s } =
|
|
917
|
-
return
|
|
916
|
+
}), { geometry: o, order: s } = Ae(n);
|
|
917
|
+
return Ve(r, s, t.rows * t.columns * t.samplesPerPixel), { ...t, ...o, pixelData: r };
|
|
918
918
|
}
|
|
919
|
-
function
|
|
919
|
+
function Ue(i) {
|
|
920
920
|
if (i.length === 0)
|
|
921
921
|
throw new Error("No DICOM parsers provided");
|
|
922
922
|
const t = i[0], e = t.rows ?? -1, n = t.columns ?? -1, r = t.pixelRepresentation === 1, o = t.bitsAllocated ?? 16, s = t.samplesPerPixel ?? 1;
|
|
@@ -981,9 +981,9 @@ class X {
|
|
|
981
981
|
if (this.rows = n, this.columns = o, this.numberOfFrames = s, this.bitsAllocated = r, this.signed = l, this.bytesPerPixel = Math.ceil(r / 8), this.samplesPerPixel = c, this.pixelData = e.pixelData, this.windowWidth = e.windowWidth, this.windowCenter = e.windowCenter, this.rescaleSlope = e.rescaleSlope, this.rescaleIntercept = e.rescaleIntercept, this.imageOrientation = e.imageOrientation, this.imagePosition = e.imagePosition, this.pixelSpacing = e.pixelSpacing, this.sliceThickness = e.sliceThickness, this.spacingBetweenSlices = e.spacingBetweenSlices, this.frameAxis = ((f = e.modality) == null ? void 0 : f.toUpperCase()) === "XA" ? "sequence" : e.frameAxis ?? "space", e.frameAxis !== void 0 && e.frameAxis !== "space" && e.frameAxis !== "sequence") throw new Error("Invalid frameAxis");
|
|
982
982
|
if (e.spacingBetweenSlices !== void 0 && (!Number.isFinite(e.spacingBetweenSlices) || e.spacingBetweenSlices === 0)) throw new Error("Invalid spacingBetweenSlices");
|
|
983
983
|
if (e.sliceStep !== void 0 && (e.sliceStep.length !== 3 || !e.sliceStep.every(Number.isFinite))) throw new Error("Invalid sliceStep");
|
|
984
|
-
const
|
|
985
|
-
if (this.sliceStep = this.frameAxis === "sequence" ? [0, 0, 0] : e.sliceStep ? [...e.sliceStep] :
|
|
986
|
-
if (e.sliceStep && this.frameAxis === "space" &&
|
|
984
|
+
const p = new u.Vector3().crossVectors(new u.Vector3(...this.imageOrientation.slice(0, 3)), new u.Vector3(...this.imageOrientation.slice(3)));
|
|
985
|
+
if (this.sliceStep = this.frameAxis === "sequence" ? [0, 0, 0] : e.sliceStep ? [...e.sliceStep] : p.multiplyScalar(e.spacingBetweenSlices ?? e.sliceThickness).toArray(), !this.sliceStep.every(Number.isFinite)) throw new Error("Invalid sliceStep");
|
|
986
|
+
if (e.sliceStep && this.frameAxis === "space" && p.dot(new u.Vector3(...this.sliceStep)) === 0)
|
|
987
987
|
throw new Error("Spatial sliceStep must have a nonzero component along the slice normal");
|
|
988
988
|
switch (this.modality = e.modality, this.distanceSourceToDetector = e.distanceSourceToDetector, this.distanceSourceToPatient = e.distanceSourceToPatient, this.positionerPrimaryAngle = e.positionerPrimaryAngle, this.positionerSecondaryAngle = e.positionerSecondaryAngle, (g = this.modality) == null ? void 0 : g.toUpperCase()) {
|
|
989
989
|
case "XA":
|
|
@@ -992,10 +992,10 @@ class X {
|
|
|
992
992
|
default:
|
|
993
993
|
this._computeDefaultMath();
|
|
994
994
|
}
|
|
995
|
-
this.textureFactory = new
|
|
995
|
+
this.textureFactory = new Fe(this);
|
|
996
996
|
}
|
|
997
997
|
static async create(t) {
|
|
998
|
-
const e =
|
|
998
|
+
const e = Ue(t);
|
|
999
999
|
return new X([...t], await Oe(t, e));
|
|
1000
1000
|
}
|
|
1001
1001
|
static fromData(t) {
|
|
@@ -1013,14 +1013,14 @@ class X {
|
|
|
1013
1013
|
return t.clone().applyMatrix4(this.lps2ijk);
|
|
1014
1014
|
}
|
|
1015
1015
|
_computeAngioMath() {
|
|
1016
|
-
const t = this.distanceSourceToDetector ?? 1e3, e = this.distanceSourceToPatient ?? 500, n = t - e, r = (this.positionerPrimaryAngle ?? 0) * Math.PI / 180, o = (this.positionerSecondaryAngle ?? 0) * Math.PI / 180, s = Math.cos(r), l = Math.sin(r), c = Math.cos(o), m = Math.sin(o),
|
|
1016
|
+
const t = this.distanceSourceToDetector ?? 1e3, e = this.distanceSourceToPatient ?? 500, n = t - e, r = (this.positionerPrimaryAngle ?? 0) * Math.PI / 180, o = (this.positionerSecondaryAngle ?? 0) * Math.PI / 180, s = Math.cos(r), l = Math.sin(r), c = Math.cos(o), m = Math.sin(o), p = new u.Matrix3().set(s, -l * c, -l * m, l, s * c, s * m, 0, -m, c), [f, g] = this.pixelSpacing, v = this.rows, w = this.columns, y = new u.Vector3(g, 0, 0), b = new u.Vector3(0, 0, -f), P = new u.Vector3(
|
|
1017
1017
|
(-w / 2 + 0.5) * g,
|
|
1018
1018
|
-n,
|
|
1019
1019
|
(v / 2 - 0.5) * f
|
|
1020
|
-
),
|
|
1021
|
-
this.ijk2lps.makeBasis(
|
|
1022
|
-
const S =
|
|
1023
|
-
this.imageOrientation = [S.x, S.y, S.z, D.x, D.y, D.z], this.imagePosition = [
|
|
1020
|
+
), T = y.clone().applyMatrix3(p), h = b.clone().applyMatrix3(p), d = P.clone().applyMatrix3(p);
|
|
1021
|
+
this.ijk2lps.makeBasis(T, h, new u.Vector3()).setPosition(d), this.lps2ijk = null, this.spatialRank = 2;
|
|
1022
|
+
const S = T.clone().normalize(), D = h.clone().normalize();
|
|
1023
|
+
this.imageOrientation = [S.x, S.y, S.z, D.x, D.y, D.z], this.imagePosition = [d.x, d.y, d.z];
|
|
1024
1024
|
}
|
|
1025
1025
|
_computeDefaultMath() {
|
|
1026
1026
|
const t = new u.Vector3(this.imageOrientation[0], this.imageOrientation[1], this.imageOrientation[2]), e = new u.Vector3(this.imageOrientation[3], this.imageOrientation[4], this.imageOrientation[5]), n = this.pixelSpacing[0], r = this.pixelSpacing[1];
|
|
@@ -1037,29 +1037,29 @@ class X {
|
|
|
1037
1037
|
this.lps2ijk = this.ijk2lps.clone().invert(), this.spatialRank = this.lps2ijk.elements.every(Number.isFinite) ? 3 : 2, this.spatialRank === 2 && (this.lps2ijk = null);
|
|
1038
1038
|
}
|
|
1039
1039
|
}
|
|
1040
|
-
function
|
|
1041
|
-
return new
|
|
1040
|
+
function L(i) {
|
|
1041
|
+
return new I(i.columns, i.rows, i.numberOfFrames);
|
|
1042
1042
|
}
|
|
1043
1043
|
function B(i) {
|
|
1044
|
-
return
|
|
1044
|
+
return L(i).subScalar(1).multiplyScalar(0.5);
|
|
1045
1045
|
}
|
|
1046
|
-
function
|
|
1047
|
-
return new
|
|
1046
|
+
function Le(i) {
|
|
1047
|
+
return new Pe(new I(-0.5, -0.5, -0.5), L(i).subScalar(0.5));
|
|
1048
1048
|
}
|
|
1049
|
-
function
|
|
1050
|
-
const { min: t, max: e } =
|
|
1049
|
+
function me(i) {
|
|
1050
|
+
const { min: t, max: e } = Le(i);
|
|
1051
1051
|
return [
|
|
1052
|
-
new
|
|
1053
|
-
new
|
|
1054
|
-
new
|
|
1055
|
-
new
|
|
1056
|
-
new
|
|
1057
|
-
new
|
|
1058
|
-
new
|
|
1059
|
-
new
|
|
1052
|
+
new I(t.x, t.y, t.z),
|
|
1053
|
+
new I(e.x, t.y, t.z),
|
|
1054
|
+
new I(e.x, e.y, t.z),
|
|
1055
|
+
new I(t.x, e.y, t.z),
|
|
1056
|
+
new I(t.x, t.y, e.z),
|
|
1057
|
+
new I(e.x, t.y, e.z),
|
|
1058
|
+
new I(e.x, e.y, e.z),
|
|
1059
|
+
new I(t.x, e.y, e.z)
|
|
1060
1060
|
];
|
|
1061
1061
|
}
|
|
1062
|
-
function
|
|
1062
|
+
function pe(i) {
|
|
1063
1063
|
if (i !== "data" && i !== "lps")
|
|
1064
1064
|
throw new Error(`Unsupported slice plane space: ${i}; expected data or lps`);
|
|
1065
1065
|
}
|
|
@@ -1071,9 +1071,9 @@ function de(i) {
|
|
|
1071
1071
|
k(i, "normal");
|
|
1072
1072
|
const t = Math.max(Math.abs(i.x), Math.abs(i.y), Math.abs(i.z));
|
|
1073
1073
|
if (t === 0) throw new Error("Slice plane normal must be non-zero");
|
|
1074
|
-
return new
|
|
1074
|
+
return new I(i.x / t, i.y / t, i.z / t).normalize();
|
|
1075
1075
|
}
|
|
1076
|
-
function
|
|
1076
|
+
function fe(i) {
|
|
1077
1077
|
const t = i.lps2ijk;
|
|
1078
1078
|
if (!t || !t.elements.every(Number.isFinite) || !i.ijk2lps.elements.every(Number.isFinite) || i.ijk2lps.determinant() === 0)
|
|
1079
1079
|
throw new Error("LPS slice planes require an invertible stack geometry");
|
|
@@ -1082,27 +1082,27 @@ function pe(i) {
|
|
|
1082
1082
|
function Y(i) {
|
|
1083
1083
|
if (!i) throw new Error("Slice plane is required");
|
|
1084
1084
|
const t = i.space === void 0 ? "data" : i.space;
|
|
1085
|
-
return
|
|
1085
|
+
return pe(t), k(i.origin, "origin"), { origin: i.origin.clone(), normal: de(i.normal), space: t };
|
|
1086
1086
|
}
|
|
1087
1087
|
function q(i, t, e) {
|
|
1088
|
-
|
|
1089
|
-
const n = Y(t), r = n.space === "lps" || e === "lps" ?
|
|
1088
|
+
pe(e);
|
|
1089
|
+
const n = Y(t), r = n.space === "lps" || e === "lps" ? fe(i) : null;
|
|
1090
1090
|
if (n.space === e) return n;
|
|
1091
|
-
const o = e === "lps" ? i.ijk2lps : r, s = new
|
|
1091
|
+
const o = e === "lps" ? i.ijk2lps : r, s = new Ie().setFromMatrix4(e === "lps" ? r : i.ijk2lps).transpose();
|
|
1092
1092
|
return n.origin.applyMatrix4(o), k(n.origin, "origin"), { origin: n.origin, normal: de(n.normal.applyMatrix3(s)), space: e };
|
|
1093
1093
|
}
|
|
1094
|
-
function
|
|
1094
|
+
function st(i, t) {
|
|
1095
1095
|
if (!Number.isFinite(t)) throw new Error(`Slice plane offset must be finite, got ${t}`);
|
|
1096
1096
|
const e = Y(i);
|
|
1097
1097
|
return e.origin.addScaledVector(e.normal, t), k(e.origin, "origin"), e;
|
|
1098
1098
|
}
|
|
1099
|
-
function
|
|
1099
|
+
function at(i, t) {
|
|
1100
1100
|
const e = Y(t);
|
|
1101
1101
|
if (![i.columns, i.rows, i.numberOfFrames].every((o) => Number.isSafeInteger(o) && o > 0))
|
|
1102
1102
|
throw new Error("Slice stack dimensions must be positive integers");
|
|
1103
|
-
e.space === "lps" &&
|
|
1103
|
+
e.space === "lps" && fe(i);
|
|
1104
1104
|
let n = 1 / 0, r = -1 / 0;
|
|
1105
|
-
for (const o of
|
|
1105
|
+
for (const o of me(i)) {
|
|
1106
1106
|
e.space === "lps" && o.applyMatrix4(i.ijk2lps);
|
|
1107
1107
|
const s = o.sub(e.origin).dot(e.normal);
|
|
1108
1108
|
if (!Number.isFinite(s)) throw new Error("Slice offset range exceeds the finite numeric range");
|
|
@@ -1133,7 +1133,7 @@ ivec3 nearestVoxelIndex(vec3 dataPosition, vec3 size) {
|
|
|
1133
1133
|
function $(i) {
|
|
1134
1134
|
return Number.isFinite(i) && Number.isFinite(Math.fround(i));
|
|
1135
1135
|
}
|
|
1136
|
-
function
|
|
1136
|
+
function ge(i) {
|
|
1137
1137
|
if (i.samplesPerPixel !== 1)
|
|
1138
1138
|
throw new Error("Slices support scalar data only (samplesPerPixel=1); RGB is not supported");
|
|
1139
1139
|
const t = i.bitsAllocated === 8 ? i.signed ? Int8Array : Uint8Array : i.bitsAllocated === 16 ? i.signed ? Int16Array : Uint16Array : i.bitsAllocated === 32 ? Float32Array : void 0;
|
|
@@ -1145,23 +1145,23 @@ function fe(i) {
|
|
|
1145
1145
|
throw new Error("Slice stack dimensions must be positive integers");
|
|
1146
1146
|
if (!i.ijk2lps.elements.every(Number.isFinite))
|
|
1147
1147
|
throw new Error("Slice stack geometry must be finite");
|
|
1148
|
-
|
|
1148
|
+
we(i);
|
|
1149
1149
|
}
|
|
1150
|
-
function
|
|
1150
|
+
function we(i) {
|
|
1151
1151
|
if (!$(i.rescaleSlope) || Math.fround(i.rescaleSlope) === 0 || !$(i.rescaleIntercept))
|
|
1152
1152
|
throw new Error("Slice rescaleSlope must be finite and non-zero; rescaleIntercept must be finite (Float32 range)");
|
|
1153
1153
|
}
|
|
1154
|
-
function
|
|
1154
|
+
function O(i, t, e) {
|
|
1155
1155
|
if (!$(t) || !$(e) || !(Math.fround(e) > 0))
|
|
1156
1156
|
throw new Error(`Slice window must be finite with positive width (Float32 range), got center=${t}, width=${e}`);
|
|
1157
|
-
return
|
|
1157
|
+
return we(i), {
|
|
1158
1158
|
uWindowCenter: { value: t },
|
|
1159
1159
|
uWindowWidth: { value: e },
|
|
1160
1160
|
uRescaleSlope: { value: i.rescaleSlope },
|
|
1161
1161
|
uRescaleIntercept: { value: i.rescaleIntercept }
|
|
1162
1162
|
};
|
|
1163
1163
|
}
|
|
1164
|
-
const
|
|
1164
|
+
const xe = `
|
|
1165
1165
|
uniform float uWindowCenter;
|
|
1166
1166
|
uniform float uWindowWidth;
|
|
1167
1167
|
uniform float uRescaleSlope;
|
|
@@ -1178,7 +1178,7 @@ float windowRawValue(float rawValue) {
|
|
|
1178
1178
|
R16UI: { samplerType: "usampler3D", texelType: "uvec4" },
|
|
1179
1179
|
R32F: { samplerType: "sampler3D", texelType: "vec4" }
|
|
1180
1180
|
};
|
|
1181
|
-
function
|
|
1181
|
+
function Ne(i) {
|
|
1182
1182
|
const t = te[i];
|
|
1183
1183
|
if (!Object.prototype.hasOwnProperty.call(te, i))
|
|
1184
1184
|
throw new Error(`Unsupported oblique slice texture internalFormat: ${i}`);
|
|
@@ -1194,7 +1194,7 @@ in vec3 vDataPosition;
|
|
|
1194
1194
|
out vec4 fragColor;
|
|
1195
1195
|
|
|
1196
1196
|
${Z}
|
|
1197
|
-
${
|
|
1197
|
+
${xe}
|
|
1198
1198
|
|
|
1199
1199
|
void main() {
|
|
1200
1200
|
vec3 minPosition = vec3(-0.5);
|
|
@@ -1228,8 +1228,8 @@ function U(i) {
|
|
|
1228
1228
|
function x(i, t) {
|
|
1229
1229
|
if (i.isDisposed) throw new Error(`${t} has been disposed`);
|
|
1230
1230
|
}
|
|
1231
|
-
const
|
|
1232
|
-
class
|
|
1231
|
+
const R = 1e-6, C = 6, G = [0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7];
|
|
1232
|
+
class We {
|
|
1233
1233
|
constructor(t) {
|
|
1234
1234
|
a(this, "corners");
|
|
1235
1235
|
a(this, "distances", new Float64Array(8));
|
|
@@ -1241,7 +1241,7 @@ class Ne {
|
|
|
1241
1241
|
a(this, "v", new u.Vector3());
|
|
1242
1242
|
a(this, "left", new u.Vector3());
|
|
1243
1243
|
a(this, "right", new u.Vector3());
|
|
1244
|
-
this.corners =
|
|
1244
|
+
this.corners = me(t);
|
|
1245
1245
|
}
|
|
1246
1246
|
intersect(t) {
|
|
1247
1247
|
const { origin: e, normal: n } = t, { points: r, corners: o, distances: s } = this;
|
|
@@ -1249,11 +1249,11 @@ class Ne {
|
|
|
1249
1249
|
for (let c = 0; c < o.length; c++) {
|
|
1250
1250
|
const m = this.candidate.subVectors(o[c], e).dot(n);
|
|
1251
1251
|
if (!Number.isFinite(m)) throw new Error("Oblique slice plane distance exceeds the finite numeric range");
|
|
1252
|
-
s[c] = Math.abs(m) <=
|
|
1252
|
+
s[c] = Math.abs(m) <= R ? 0 : m;
|
|
1253
1253
|
}
|
|
1254
1254
|
for (let c = 0; c < G.length; c += 2) {
|
|
1255
|
-
const m = G[c],
|
|
1256
|
-
f === 0 && this.pushUnique(o[m]), g === 0 && this.pushUnique(o[
|
|
1255
|
+
const m = G[c], p = G[c + 1], f = s[m], g = s[p];
|
|
1256
|
+
f === 0 && this.pushUnique(o[m]), g === 0 && this.pushUnique(o[p]), (f < 0 && g > 0 || f > 0 && g < 0) && this.pushUnique(this.candidate.copy(o[m]).lerp(o[p], f / (f - g)));
|
|
1257
1257
|
}
|
|
1258
1258
|
if (r.length < 3)
|
|
1259
1259
|
return r.length = 0, r;
|
|
@@ -1263,16 +1263,16 @@ class Ne {
|
|
|
1263
1263
|
let l = 0;
|
|
1264
1264
|
for (let c = 1; c < r.length - 1; c++)
|
|
1265
1265
|
l += this.left.subVectors(r[c], r[0]).cross(this.right.subVectors(r[c + 1], r[0])).dot(n);
|
|
1266
|
-
if (l <=
|
|
1266
|
+
if (l <= R * R)
|
|
1267
1267
|
return r.length = 0, r;
|
|
1268
|
-
if (r.length >
|
|
1268
|
+
if (r.length > C) throw new Error("Oblique slice intersection exceeds the six-vertex capacity");
|
|
1269
1269
|
for (const c of r)
|
|
1270
1270
|
if (!Number.isFinite(Math.fround(c.x)) || !Number.isFinite(Math.fround(c.y)) || !Number.isFinite(Math.fround(c.z)))
|
|
1271
1271
|
throw new Error("Oblique slice intersection exceeds the Float32 geometry range");
|
|
1272
1272
|
return r;
|
|
1273
1273
|
}
|
|
1274
1274
|
pushUnique(t) {
|
|
1275
|
-
this.points.some((e) => e.distanceToSquared(t) <=
|
|
1275
|
+
this.points.some((e) => e.distanceToSquared(t) <= R * R) || this.points.push(this.pool[this.points.length].copy(t));
|
|
1276
1276
|
}
|
|
1277
1277
|
angle(t) {
|
|
1278
1278
|
return this.candidate.subVectors(t, this.center), Math.atan2(this.candidate.dot(this.v), this.candidate.dot(this.u));
|
|
@@ -1283,12 +1283,12 @@ class H extends u.BufferGeometry {
|
|
|
1283
1283
|
super();
|
|
1284
1284
|
a(this, "vertexCount", 0);
|
|
1285
1285
|
a(this, "point", new u.Vector3());
|
|
1286
|
-
this.setAttribute("position", new u.BufferAttribute(new Float32Array(
|
|
1286
|
+
this.setAttribute("position", new u.BufferAttribute(new Float32Array(C * 3), 3).setUsage(u.DynamicDrawUsage)), this.setAttribute("normal", new u.BufferAttribute(new Float32Array(C * 3), 3).setUsage(u.DynamicDrawUsage)), this.setIndex(new u.BufferAttribute(new Uint16Array((C - 2) * 3), 1).setUsage(u.DynamicDrawUsage)), this.boundingBox = new u.Box3(), this.boundingSphere = new u.Sphere(), this.setDrawRange(0, 0);
|
|
1287
1287
|
}
|
|
1288
1288
|
update(e, n) {
|
|
1289
1289
|
const r = this.getAttribute("position"), o = this.getAttribute("normal"), s = this.getIndex();
|
|
1290
1290
|
this.vertexCount = e.length;
|
|
1291
|
-
for (let c = 0; c <
|
|
1291
|
+
for (let c = 0; c < C; c++) {
|
|
1292
1292
|
const m = e[c] ?? e[0];
|
|
1293
1293
|
r.setXYZ(c, (m == null ? void 0 : m.x) ?? 0, (m == null ? void 0 : m.y) ?? 0, (m == null ? void 0 : m.z) ?? 0), o.setXYZ(c, m ? n.x : 0, m ? n.y : 0, m ? n.z : 0);
|
|
1294
1294
|
}
|
|
@@ -1316,7 +1316,7 @@ class H extends u.BufferGeometry {
|
|
|
1316
1316
|
return super.copy(e), this.vertexCount = e instanceof H ? e.vertexCount : 0, this;
|
|
1317
1317
|
}
|
|
1318
1318
|
}
|
|
1319
|
-
class
|
|
1319
|
+
class lt extends u.Object3D {
|
|
1320
1320
|
constructor(e, n, r = {}) {
|
|
1321
1321
|
super();
|
|
1322
1322
|
a(this, "stack");
|
|
@@ -1328,12 +1328,12 @@ class at extends u.Object3D {
|
|
|
1328
1328
|
a(this, "_windowCenter");
|
|
1329
1329
|
a(this, "_windowWidth");
|
|
1330
1330
|
a(this, "_disposed", !1);
|
|
1331
|
-
|
|
1332
|
-
const o =
|
|
1333
|
-
this.intersection = new
|
|
1331
|
+
ge(e), this.stack = e, this._plane = q(e, n, "data"), this._windowCenter = r.windowCenter === void 0 ? e.windowCenter : r.windowCenter, this._windowWidth = r.windowWidth === void 0 ? e.windowWidth : r.windowWidth;
|
|
1332
|
+
const o = O(e, this._windowCenter, this._windowWidth);
|
|
1333
|
+
this.intersection = new We(e);
|
|
1334
1334
|
const s = this.intersection.intersect(this._plane);
|
|
1335
1335
|
this.texture = e.textureFactory.data3DTexture;
|
|
1336
|
-
const l =
|
|
1336
|
+
const l = Ne(String(this.texture.internalFormat));
|
|
1337
1337
|
this.sliceGeometry = new H(), this.sliceGeometry.update(s, this._plane.normal), this.mesh = new u.Mesh(this.sliceGeometry, this.createMaterial(l, o)), this.add(this.mesh), this.matrixAutoUpdate = !1, this.matrix.copy(e.ijk2lps);
|
|
1338
1338
|
}
|
|
1339
1339
|
get plane() {
|
|
@@ -1381,7 +1381,7 @@ class at extends u.Object3D {
|
|
|
1381
1381
|
}
|
|
1382
1382
|
setWindow(e, n) {
|
|
1383
1383
|
x(this, "ObliqueSlice");
|
|
1384
|
-
const r =
|
|
1384
|
+
const r = O(this.stack, e, n);
|
|
1385
1385
|
if (!(e === this._windowCenter && n === this._windowWidth && Object.entries(r).every(([o, s]) => this.material.uniforms[o].value === s.value))) {
|
|
1386
1386
|
this._windowCenter = e, this._windowWidth = n;
|
|
1387
1387
|
for (const [o, s] of Object.entries(r))
|
|
@@ -1410,7 +1410,7 @@ class at extends u.Object3D {
|
|
|
1410
1410
|
glslVersion: u.GLSL3,
|
|
1411
1411
|
uniforms: {
|
|
1412
1412
|
map: { value: this.texture },
|
|
1413
|
-
uSize: { value:
|
|
1413
|
+
uSize: { value: L(this.stack) },
|
|
1414
1414
|
...n
|
|
1415
1415
|
},
|
|
1416
1416
|
vertexShader: ze,
|
|
@@ -1419,7 +1419,7 @@ class at extends u.Object3D {
|
|
|
1419
1419
|
});
|
|
1420
1420
|
}
|
|
1421
1421
|
}
|
|
1422
|
-
var
|
|
1422
|
+
var Be = `in vec3 position;
|
|
1423
1423
|
|
|
1424
1424
|
uniform mat4 modelViewMatrix;\r
|
|
1425
1425
|
uniform mat4 projectionMatrix;
|
|
@@ -1437,11 +1437,11 @@ const ie = {
|
|
|
1437
1437
|
R16UI: { samplerType: "usampler3D", texelType: "uvec4" },
|
|
1438
1438
|
R32F: { samplerType: "sampler3D", texelType: "vec4" }
|
|
1439
1439
|
};
|
|
1440
|
-
function
|
|
1440
|
+
function $e(i) {
|
|
1441
1441
|
const t = ie[i];
|
|
1442
1442
|
if (!Object.prototype.hasOwnProperty.call(ie, i))
|
|
1443
1443
|
throw new Error(`Unsupported slice texture internalFormat: ${i}`);
|
|
1444
|
-
const { samplerType: e, texelType: n } = t, r = (o, s) => `
|
|
1444
|
+
const { samplerType: e, texelType: n } = t, r = (o, s, l) => `
|
|
1445
1445
|
precision highp float;
|
|
1446
1446
|
precision highp int;
|
|
1447
1447
|
precision highp ${e};
|
|
@@ -1449,26 +1449,51 @@ precision highp ${e};
|
|
|
1449
1449
|
uniform ${e} map;
|
|
1450
1450
|
uniform int ${o};
|
|
1451
1451
|
uniform vec3 uSize;
|
|
1452
|
+
uniform bool uLinearInterpolation;
|
|
1452
1453
|
|
|
1453
1454
|
in vec3 vPosition;
|
|
1454
1455
|
out vec4 fragColor;
|
|
1455
1456
|
|
|
1456
1457
|
${Z}
|
|
1457
|
-
${
|
|
1458
|
+
${xe}
|
|
1459
|
+
|
|
1460
|
+
float sampleRaw(ivec3 index) {
|
|
1461
|
+
${n} texel = texelFetch(map, index, 0);
|
|
1462
|
+
return float(texel.r);
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
float sampleLinear(vec3 dataPosition) {
|
|
1466
|
+
vec3 position = clamp(dataPosition, vec3(0.0), uSize - vec3(1.0));
|
|
1467
|
+
ivec3 lower = ivec3(floor(position));
|
|
1468
|
+
ivec3 upper = min(lower + ivec3(1), ivec3(uSize) - ivec3(1));
|
|
1469
|
+
vec2 weight = fract(position.${l});
|
|
1470
|
+
|
|
1471
|
+
ivec3 lowerRight = lower;
|
|
1472
|
+
lowerRight.${l[0]} = upper.${l[0]};
|
|
1473
|
+
ivec3 upperLeft = lower;
|
|
1474
|
+
upperLeft.${l[1]} = upper.${l[1]};
|
|
1475
|
+
ivec3 upperRight = lower;
|
|
1476
|
+
upperRight.${l} = upper.${l};
|
|
1477
|
+
|
|
1478
|
+
float firstRow = mix(sampleRaw(lower), sampleRaw(lowerRight), weight.x);
|
|
1479
|
+
float secondRow = mix(sampleRaw(upperLeft), sampleRaw(upperRight), weight.x);
|
|
1480
|
+
return mix(firstRow, secondRow, weight.y);
|
|
1481
|
+
}
|
|
1458
1482
|
|
|
1459
1483
|
void main() {
|
|
1460
1484
|
// Geometry is embedded in IJK; the mesh translates only along the selected axis.
|
|
1461
1485
|
vec3 dataPosition = ${s};
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1486
|
+
float rawValue = uLinearInterpolation
|
|
1487
|
+
? sampleLinear(dataPosition)
|
|
1488
|
+
: sampleRaw(nearestVoxelIndex(dataPosition, uSize));
|
|
1489
|
+
float pixelValue = windowRawValue(rawValue);
|
|
1465
1490
|
fragColor = vec4(pixelValue, pixelValue, pixelValue, 1.0);
|
|
1466
1491
|
}
|
|
1467
1492
|
`;
|
|
1468
1493
|
return {
|
|
1469
|
-
fragmentX: r("ix", "vec3(float(ix), vPosition.y, vPosition.z)"),
|
|
1470
|
-
fragmentY: r("iy", "vec3(vPosition.x, float(iy), vPosition.z)"),
|
|
1471
|
-
fragmentZ: r("iz", "vec3(vPosition.x, vPosition.y, float(iz))")
|
|
1494
|
+
fragmentX: r("ix", "vec3(float(ix), vPosition.y, vPosition.z)", "yz"),
|
|
1495
|
+
fragmentY: r("iy", "vec3(vPosition.x, float(iy), vPosition.z)", "xz"),
|
|
1496
|
+
fragmentZ: r("iz", "vec3(vPosition.x, vPosition.y, float(iz))", "xy")
|
|
1472
1497
|
};
|
|
1473
1498
|
}
|
|
1474
1499
|
const ne = {
|
|
@@ -1515,7 +1540,7 @@ const ne = {
|
|
|
1515
1540
|
})
|
|
1516
1541
|
}
|
|
1517
1542
|
};
|
|
1518
|
-
class
|
|
1543
|
+
class V extends u.Object3D {
|
|
1519
1544
|
constructor(e, n, r = {}) {
|
|
1520
1545
|
super();
|
|
1521
1546
|
a(this, "stack");
|
|
@@ -1529,14 +1554,17 @@ class O extends u.Object3D {
|
|
|
1529
1554
|
a(this, "_disposed", !1);
|
|
1530
1555
|
if (!Object.prototype.hasOwnProperty.call(ne, n))
|
|
1531
1556
|
throw new Error(`Unsupported slice axis: ${n}; expected x, y or z`);
|
|
1532
|
-
|
|
1533
|
-
const o =
|
|
1557
|
+
ge(e), this.stack = e, this.axis = n, this.config = ne[n], this._index = r.index === void 0 ? this.config.defaultIndex(e) : r.index, this.validateIndex(this._index), this._windowCenter = r.windowCenter === void 0 ? e.windowCenter : r.windowCenter, this._windowWidth = r.windowWidth === void 0 ? e.windowWidth : r.windowWidth;
|
|
1558
|
+
const o = O(e, this._windowCenter, this._windowWidth), s = re(r.interpolation ?? "nearest");
|
|
1534
1559
|
this.texture = e.textureFactory.data3DTexture;
|
|
1535
|
-
const
|
|
1536
|
-
this.mesh = new u.Mesh(
|
|
1560
|
+
const l = $e(String(this.texture.internalFormat));
|
|
1561
|
+
this.mesh = new u.Mesh(
|
|
1562
|
+
this.config.geometry(e),
|
|
1563
|
+
this.createMaterial(l[this.config.fragment], o, s)
|
|
1564
|
+
), this.add(this.mesh), this.matrixAutoUpdate = !1, this.matrix.copy(e.ijk2lps), this.mesh.position[this.config.positionComponent] = this._index;
|
|
1537
1565
|
}
|
|
1538
1566
|
static fromAxis(e, n, r, o = {}) {
|
|
1539
|
-
return new
|
|
1567
|
+
return new V(e, n, { ...o, index: r === void 0 ? o.index : r });
|
|
1540
1568
|
}
|
|
1541
1569
|
get index() {
|
|
1542
1570
|
return this._index;
|
|
@@ -1562,9 +1590,17 @@ class O extends u.Object3D {
|
|
|
1562
1590
|
get material() {
|
|
1563
1591
|
return this.mesh.material;
|
|
1564
1592
|
}
|
|
1593
|
+
get interpolation() {
|
|
1594
|
+
return this.material.uniforms.uLinearInterpolation.value ? "linear" : "nearest";
|
|
1595
|
+
}
|
|
1596
|
+
set interpolation(e) {
|
|
1597
|
+
x(this, "Slice");
|
|
1598
|
+
const n = re(e);
|
|
1599
|
+
n !== this.material.uniforms.uLinearInterpolation.value && (this.material.uniforms.uLinearInterpolation.value = n, this.dispatchEvent({ type: "change", reason: "interpolation" }));
|
|
1600
|
+
}
|
|
1565
1601
|
setWindow(e, n) {
|
|
1566
1602
|
x(this, "Slice");
|
|
1567
|
-
const r =
|
|
1603
|
+
const r = O(this.stack, e, n);
|
|
1568
1604
|
if (!(e === this._windowCenter && n === this._windowWidth && Object.entries(r).every(([o, s]) => this.material.uniforms[o].value === s.value))) {
|
|
1569
1605
|
this._windowCenter = e, this._windowWidth = n;
|
|
1570
1606
|
for (const [o, s] of Object.entries(r))
|
|
@@ -1588,16 +1624,17 @@ class O extends u.Object3D {
|
|
|
1588
1624
|
() => this.dispatchEvent({ type: "dispose" })
|
|
1589
1625
|
]);
|
|
1590
1626
|
}
|
|
1591
|
-
createMaterial(e, n) {
|
|
1627
|
+
createMaterial(e, n, r) {
|
|
1592
1628
|
return new u.RawShaderMaterial({
|
|
1593
1629
|
glslVersion: u.GLSL3,
|
|
1594
1630
|
uniforms: {
|
|
1595
1631
|
map: { value: this.texture },
|
|
1596
|
-
uSize: { value:
|
|
1632
|
+
uSize: { value: L(this.stack) },
|
|
1633
|
+
uLinearInterpolation: { value: r },
|
|
1597
1634
|
...this.config.uniforms(this._index),
|
|
1598
1635
|
...n
|
|
1599
1636
|
},
|
|
1600
|
-
vertexShader:
|
|
1637
|
+
vertexShader: Be,
|
|
1601
1638
|
fragmentShader: e,
|
|
1602
1639
|
side: u.DoubleSide
|
|
1603
1640
|
});
|
|
@@ -1607,7 +1644,12 @@ class O extends u.Object3D {
|
|
|
1607
1644
|
throw new Error(`Slice index must be an integer in [0, ${this.config.size(this.stack) - 1}], got ${e}`);
|
|
1608
1645
|
}
|
|
1609
1646
|
}
|
|
1610
|
-
|
|
1647
|
+
function re(i) {
|
|
1648
|
+
if (i !== "nearest" && i !== "linear")
|
|
1649
|
+
throw new Error(`Unsupported slice interpolation: ${i}`);
|
|
1650
|
+
return i === "linear";
|
|
1651
|
+
}
|
|
1652
|
+
class ct extends u.Object3D {
|
|
1611
1653
|
constructor(e) {
|
|
1612
1654
|
super();
|
|
1613
1655
|
a(this, "stack");
|
|
@@ -1640,7 +1682,7 @@ class lt extends u.Object3D {
|
|
|
1640
1682
|
this._disposed || this.dispatchEvent({ type: "change", reason: "dispose", axis: e.target.axis });
|
|
1641
1683
|
});
|
|
1642
1684
|
if (!e.hasSpatialVolume()) throw new Error("OrthoSlicer requires a spatial volume; use Slice Z for a frame sequence");
|
|
1643
|
-
this.stack = e, this.nx = e.columns, this.ny = e.rows, this.nz = e.numberOfFrames, this.size = this.nx * this.ny * this.nz, this.hx = e.pixelSpacing[1], this.hy = e.pixelSpacing[0], this.hz = Math.hypot(...e.sliceStep), this.lx = (this.nx - 1) * this.hx, this.ly = (this.ny - 1) * this.hy, this.lz = (this.nz - 1) * this.hz, this.sliceX =
|
|
1685
|
+
this.stack = e, this.nx = e.columns, this.ny = e.rows, this.nz = e.numberOfFrames, this.size = this.nx * this.ny * this.nz, this.hx = e.pixelSpacing[1], this.hy = e.pixelSpacing[0], this.hz = Math.hypot(...e.sliceStep), this.lx = (this.nx - 1) * this.hx, this.ly = (this.ny - 1) * this.hy, this.lz = (this.nz - 1) * this.hz, this.sliceX = V.fromAxis(e, "x"), this.sliceY = V.fromAxis(e, "y"), this.sliceZ = V.fromAxis(e, "z"), this.add(this.sliceX, this.sliceY, this.sliceZ);
|
|
1644
1686
|
for (const n of [this.sliceX, this.sliceY, this.sliceZ])
|
|
1645
1687
|
n.addEventListener("change", this.onSliceChange), n.addEventListener("dispose", this.onSliceDispose);
|
|
1646
1688
|
}
|
|
@@ -1666,7 +1708,7 @@ class lt extends u.Object3D {
|
|
|
1666
1708
|
x(this, "OrthoSlicer");
|
|
1667
1709
|
const r = [this.sliceX, this.sliceY, this.sliceZ];
|
|
1668
1710
|
for (const o of r) x(o, "Slice");
|
|
1669
|
-
|
|
1711
|
+
O(this.stack, e, n), this.windowUpdateDepth++;
|
|
1670
1712
|
try {
|
|
1671
1713
|
U(r.map((o) => () => o.setWindow(e, n)));
|
|
1672
1714
|
} finally {
|
|
@@ -1690,7 +1732,7 @@ class lt extends u.Object3D {
|
|
|
1690
1732
|
]);
|
|
1691
1733
|
}
|
|
1692
1734
|
}
|
|
1693
|
-
const
|
|
1735
|
+
const ke = {
|
|
1694
1736
|
"ct-soft-tissue": {
|
|
1695
1737
|
name: "CT soft tissue",
|
|
1696
1738
|
mode: "composite",
|
|
@@ -1797,15 +1839,15 @@ const $e = {
|
|
|
1797
1839
|
]
|
|
1798
1840
|
}
|
|
1799
1841
|
};
|
|
1800
|
-
function
|
|
1801
|
-
return typeof i != "string" ? i :
|
|
1842
|
+
function qe(i) {
|
|
1843
|
+
return typeof i != "string" ? i : ke[i];
|
|
1802
1844
|
}
|
|
1803
|
-
const
|
|
1845
|
+
const oe = {
|
|
1804
1846
|
mip: 0,
|
|
1805
1847
|
composite: 1,
|
|
1806
1848
|
iso: 2
|
|
1807
1849
|
};
|
|
1808
|
-
var
|
|
1850
|
+
var Ge = `in vec3 position;
|
|
1809
1851
|
|
|
1810
1852
|
uniform mat4 modelViewMatrix;
|
|
1811
1853
|
uniform mat4 projectionMatrix;
|
|
@@ -1816,7 +1858,7 @@ void main() {
|
|
|
1816
1858
|
vPosition = position;
|
|
1817
1859
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
1818
1860
|
}`;
|
|
1819
|
-
const
|
|
1861
|
+
const je = {
|
|
1820
1862
|
R8I: { samplerType: "isampler3D", texelType: "ivec4" },
|
|
1821
1863
|
R8UI: { samplerType: "usampler3D", texelType: "uvec4" },
|
|
1822
1864
|
R16I: { samplerType: "isampler3D", texelType: "ivec4" },
|
|
@@ -1827,8 +1869,8 @@ const Ge = {
|
|
|
1827
1869
|
RGB16I: { samplerType: "isampler3D", texelType: "ivec4" },
|
|
1828
1870
|
RGB16UI: { samplerType: "usampler3D", texelType: "uvec4" }
|
|
1829
1871
|
};
|
|
1830
|
-
function
|
|
1831
|
-
const n =
|
|
1872
|
+
function Xe(i, { maxSteps: t, maxTransferPoints: e }) {
|
|
1873
|
+
const n = je[i];
|
|
1832
1874
|
if (!n)
|
|
1833
1875
|
throw new Error(`Unsupported volume texture internalFormat: ${i}`);
|
|
1834
1876
|
const r = Math.max(1, Math.trunc(t)), o = Math.max(2, Math.trunc(e));
|
|
@@ -2158,13 +2200,13 @@ void castIso(vec3 startLoc, vec3 stepVec, int nsteps, vec3 viewRay) {
|
|
|
2158
2200
|
}
|
|
2159
2201
|
`;
|
|
2160
2202
|
}
|
|
2161
|
-
const F = 8,
|
|
2203
|
+
const F = 8, Ye = 1024, Ze = {
|
|
2162
2204
|
ambient: 0.22,
|
|
2163
2205
|
diffuse: 0.78,
|
|
2164
2206
|
specular: 0.16,
|
|
2165
2207
|
shininess: 32
|
|
2166
2208
|
};
|
|
2167
|
-
class
|
|
2209
|
+
class ut extends u.Object3D {
|
|
2168
2210
|
constructor(e, n = {}) {
|
|
2169
2211
|
var f;
|
|
2170
2212
|
super();
|
|
@@ -2188,17 +2230,17 @@ class ct extends u.Object3D {
|
|
|
2188
2230
|
a(this, "_sampleDistance", 1);
|
|
2189
2231
|
a(this, "_opacityScale", 1);
|
|
2190
2232
|
a(this, "_lightingEnabled", !0);
|
|
2191
|
-
a(this, "_lighting", { ...
|
|
2233
|
+
a(this, "_lighting", { ...Ze });
|
|
2192
2234
|
a(this, "_transferFunction");
|
|
2193
2235
|
a(this, "_disposed", !1);
|
|
2194
2236
|
a(this, "_inverseMatrixWorld", new u.Matrix4());
|
|
2195
2237
|
a(this, "_cameraWorldPosition", new u.Vector3());
|
|
2196
2238
|
a(this, "_cameraWorldDirection", new u.Vector3());
|
|
2197
2239
|
if (!e.hasSpatialVolume()) throw new Error("VolumeRaycaster requires a spatial volume; use Slice Z for a frame sequence");
|
|
2198
|
-
this.stack = e, this.nx = e.columns, this.ny = e.rows, this.nz = e.numberOfFrames, this.size = this.nx * this.ny * this.nz, this.hx = e.pixelSpacing[1], this.hy = e.pixelSpacing[0], this.hz = Math.hypot(...e.sliceStep), this.lx = (this.nx - 1) * this.hx, this.ly = (this.ny - 1) * this.hy, this.lz = (this.nz - 1) * this.hz, this.texture = e.textureFactory.data3DTexture, this.maxSteps = Math.max(1, Math.trunc(n.maxSteps ??
|
|
2199
|
-
const r =
|
|
2200
|
-
this._window = [...r], this._threshold = r[0] + (r[1] - r[0]) * 0.65, this._transferFunction =
|
|
2201
|
-
const o =
|
|
2240
|
+
this.stack = e, this.nx = e.columns, this.ny = e.rows, this.nz = e.numberOfFrames, this.size = this.nx * this.ny * this.nz, this.hx = e.pixelSpacing[1], this.hy = e.pixelSpacing[0], this.hz = Math.hypot(...e.sliceStep), this.lx = (this.nx - 1) * this.hx, this.ly = (this.ny - 1) * this.hy, this.lz = (this.nz - 1) * this.hz, this.texture = e.textureFactory.data3DTexture, this.maxSteps = Math.max(1, Math.trunc(n.maxSteps ?? Ye));
|
|
2241
|
+
const r = ae(e);
|
|
2242
|
+
this._window = [...r], this._threshold = r[0] + (r[1] - r[0]) * 0.65, this._transferFunction = se(r);
|
|
2243
|
+
const o = Xe(String(this.texture.internalFormat), {
|
|
2202
2244
|
maxSteps: this.maxSteps,
|
|
2203
2245
|
maxTransferPoints: F
|
|
2204
2246
|
}), s = {
|
|
@@ -2206,23 +2248,23 @@ class ct extends u.Object3D {
|
|
|
2206
2248
|
uCameraLocalPosition: { value: new u.Vector3() },
|
|
2207
2249
|
uCameraLocalDirection: { value: new u.Vector3(0, 0, -1) },
|
|
2208
2250
|
uOrthographicCamera: { value: !1 },
|
|
2209
|
-
uSize: { value:
|
|
2251
|
+
uSize: { value: L(e) },
|
|
2210
2252
|
uRescaleSlope: { value: e.rescaleSlope },
|
|
2211
2253
|
uRescaleIntercept: { value: e.rescaleIntercept },
|
|
2212
|
-
uMode: { value:
|
|
2254
|
+
uMode: { value: oe[this._mode] },
|
|
2213
2255
|
uWindow: { value: new u.Vector2(this._window[0], this._window[1]) },
|
|
2214
2256
|
uThreshold: { value: this._threshold },
|
|
2215
2257
|
uSampleDistance: { value: this._sampleDistance },
|
|
2216
2258
|
uOpacityScale: { value: this._opacityScale },
|
|
2217
2259
|
uLightingEnabled: { value: this._lightingEnabled },
|
|
2218
|
-
uLighting: { value:
|
|
2260
|
+
uLighting: { value: le(this._lighting) },
|
|
2219
2261
|
uTransferPointCount: { value: this._transferFunction.length },
|
|
2220
|
-
uTransferPoints: { value:
|
|
2221
|
-
uOpacityPoints: { value:
|
|
2262
|
+
uTransferPoints: { value: Je() },
|
|
2263
|
+
uOpacityPoints: { value: Ke() }
|
|
2222
2264
|
}, l = new u.RawShaderMaterial({
|
|
2223
2265
|
glslVersion: u.GLSL3,
|
|
2224
2266
|
uniforms: s,
|
|
2225
|
-
vertexShader:
|
|
2267
|
+
vertexShader: Ge,
|
|
2226
2268
|
fragmentShader: o,
|
|
2227
2269
|
side: u.BackSide,
|
|
2228
2270
|
transparent: !0,
|
|
@@ -2231,12 +2273,12 @@ class ct extends u.Object3D {
|
|
|
2231
2273
|
c.translate(m.x, m.y, m.z), this.mesh = new u.Mesh(c, l), this.mesh.onBeforeRender = (g, v, w) => {
|
|
2232
2274
|
this.updateCameraUniforms(w);
|
|
2233
2275
|
}, this.add(this.mesh), this.transferFunction = this._transferFunction;
|
|
2234
|
-
const
|
|
2235
|
-
|
|
2276
|
+
const p = n.preset ?? (((f = e.modality) == null ? void 0 : f.toUpperCase()) === "CT" ? "ct-soft-tissue" : void 0);
|
|
2277
|
+
p && this.setPreset(p), this.applyOptions(n), this.matrixAutoUpdate = !1, this.matrix.copy(e.ijk2lps);
|
|
2236
2278
|
}
|
|
2237
2279
|
set mode(e) {
|
|
2238
2280
|
x(this, "VolumeRaycaster");
|
|
2239
|
-
const n =
|
|
2281
|
+
const n = oe[e];
|
|
2240
2282
|
if (n === void 0)
|
|
2241
2283
|
throw new Error(`Unsupported volume rendering mode: ${e}`);
|
|
2242
2284
|
this._mode = e, this.mesh.material.uniforms.uMode.value = n;
|
|
@@ -2246,7 +2288,7 @@ class ct extends u.Object3D {
|
|
|
2246
2288
|
}
|
|
2247
2289
|
set window(e) {
|
|
2248
2290
|
x(this, "VolumeRaycaster");
|
|
2249
|
-
const n =
|
|
2291
|
+
const n = ye(e);
|
|
2250
2292
|
this._window = n, this.mesh.material.uniforms.uWindow.value.set(n[0], n[1]);
|
|
2251
2293
|
}
|
|
2252
2294
|
get window() {
|
|
@@ -2286,13 +2328,13 @@ class ct extends u.Object3D {
|
|
|
2286
2328
|
x(this, "VolumeRaycaster"), this._lighting = {
|
|
2287
2329
|
...this._lighting,
|
|
2288
2330
|
...e
|
|
2289
|
-
}, this.mesh.material.uniforms.uLighting.value.copy(
|
|
2331
|
+
}, this.mesh.material.uniforms.uLighting.value.copy(le(this._lighting));
|
|
2290
2332
|
}
|
|
2291
2333
|
get lighting() {
|
|
2292
2334
|
return { ...this._lighting };
|
|
2293
2335
|
}
|
|
2294
2336
|
set transferFunction(e) {
|
|
2295
|
-
x(this, "VolumeRaycaster"), this._transferFunction =
|
|
2337
|
+
x(this, "VolumeRaycaster"), this._transferFunction = He(e);
|
|
2296
2338
|
const n = this.mesh.material.uniforms.uTransferPoints.value, r = this.mesh.material.uniforms.uOpacityPoints.value, o = this._transferFunction[this._transferFunction.length - 1];
|
|
2297
2339
|
for (let s = 0; s < F; s++) {
|
|
2298
2340
|
const l = this._transferFunction[s] ?? o;
|
|
@@ -2309,13 +2351,13 @@ class ct extends u.Object3D {
|
|
|
2309
2351
|
}
|
|
2310
2352
|
setPreset(e) {
|
|
2311
2353
|
x(this, "VolumeRaycaster");
|
|
2312
|
-
const n =
|
|
2354
|
+
const n = qe(e);
|
|
2313
2355
|
n.mode && (this.mode = n.mode), n.window && (this.window = n.window), n.threshold !== void 0 && (this.threshold = n.threshold), n.sampleDistance !== void 0 && (this.sampleDistance = n.sampleDistance), n.opacityScale !== void 0 && (this.opacityScale = n.opacityScale), n.lightingEnabled !== void 0 && (this.lightingEnabled = n.lightingEnabled), n.lighting && (this.lighting = n.lighting), n.transferFunction && (this.transferFunction = n.transferFunction);
|
|
2314
2356
|
}
|
|
2315
2357
|
resetToStackWindow() {
|
|
2316
2358
|
x(this, "VolumeRaycaster");
|
|
2317
|
-
const e =
|
|
2318
|
-
this.window = e, this.threshold = e[0] + (e[1] - e[0]) * 0.65, this.transferFunction =
|
|
2359
|
+
const e = ae(this.stack);
|
|
2360
|
+
this.window = e, this.threshold = e[0] + (e[1] - e[0]) * 0.65, this.transferFunction = se(e);
|
|
2319
2361
|
}
|
|
2320
2362
|
get isDisposed() {
|
|
2321
2363
|
return this._disposed;
|
|
@@ -2342,24 +2384,24 @@ class ct extends u.Object3D {
|
|
|
2342
2384
|
n.uCameraLocalPosition.value.copy(this._cameraWorldPosition).applyMatrix4(this._inverseMatrixWorld), n.uCameraLocalDirection.value.copy(this._cameraWorldDirection).transformDirection(this._inverseMatrixWorld), n.uOrthographicCamera.value = e.isOrthographicCamera === !0;
|
|
2343
2385
|
}
|
|
2344
2386
|
}
|
|
2345
|
-
function
|
|
2346
|
-
const [t, e] =
|
|
2387
|
+
function se(i) {
|
|
2388
|
+
const [t, e] = ye(i);
|
|
2347
2389
|
return [
|
|
2348
2390
|
{ value: t, color: [0, 0, 0], opacity: 0 },
|
|
2349
2391
|
{ value: e, color: [1, 1, 1], opacity: 1 }
|
|
2350
2392
|
];
|
|
2351
2393
|
}
|
|
2352
|
-
function
|
|
2394
|
+
function ae(i) {
|
|
2353
2395
|
const t = Number.isFinite(i.windowWidth) && i.windowWidth > 0 ? i.windowWidth : 1, e = Number.isFinite(i.windowCenter) ? i.windowCenter : 0;
|
|
2354
2396
|
return [e - t / 2, e + t / 2];
|
|
2355
2397
|
}
|
|
2356
|
-
function
|
|
2398
|
+
function ye(i) {
|
|
2357
2399
|
const [t, e] = i;
|
|
2358
2400
|
if (!(Number.isFinite(t) && Number.isFinite(e) && t < e))
|
|
2359
2401
|
throw new Error(`Volume window must be [finite lower, finite upper], got: [${t}, ${e}]`);
|
|
2360
2402
|
return [t, e];
|
|
2361
2403
|
}
|
|
2362
|
-
function
|
|
2404
|
+
function He(i) {
|
|
2363
2405
|
if (i.length === 0)
|
|
2364
2406
|
throw new Error("Volume transferFunction must contain at least one point");
|
|
2365
2407
|
if (i.length > F)
|
|
@@ -2380,37 +2422,37 @@ function Ze(i) {
|
|
|
2380
2422
|
};
|
|
2381
2423
|
});
|
|
2382
2424
|
}
|
|
2383
|
-
function
|
|
2425
|
+
function Je() {
|
|
2384
2426
|
return Array.from({ length: F }, () => new u.Vector4());
|
|
2385
2427
|
}
|
|
2386
|
-
function
|
|
2428
|
+
function Ke() {
|
|
2387
2429
|
return Array.from({ length: F }, () => new u.Vector2());
|
|
2388
2430
|
}
|
|
2389
|
-
function
|
|
2431
|
+
function le(i) {
|
|
2390
2432
|
return new u.Vector4(i.ambient, i.diffuse, i.specular, i.shininess);
|
|
2391
2433
|
}
|
|
2392
2434
|
export {
|
|
2393
|
-
|
|
2394
|
-
|
|
2435
|
+
Ye as DEFAULT_VOLUME_MAX_STEPS,
|
|
2436
|
+
nt as DicomLoader,
|
|
2395
2437
|
K as DicomParser,
|
|
2396
|
-
|
|
2438
|
+
ot as DicomWorkerLoader,
|
|
2397
2439
|
F as MAX_VOLUME_TRANSFER_POINTS,
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2440
|
+
lt as ObliqueSlice,
|
|
2441
|
+
ct as OrthoSlicer,
|
|
2442
|
+
V as Slice,
|
|
2401
2443
|
X as Stack,
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2444
|
+
oe as VOLUME_RENDERING_MODE_VALUES,
|
|
2445
|
+
ke as VOLUME_RENDERING_PRESETS,
|
|
2446
|
+
ut as VolumeRaycaster,
|
|
2405
2447
|
q as convertSlicePlane,
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2448
|
+
se as createWindowTransferFunction,
|
|
2449
|
+
rt as dicomPreloader,
|
|
2450
|
+
at as getSliceOffsetRange,
|
|
2451
|
+
Le as getStackBounds,
|
|
2410
2452
|
B as getStackCenter,
|
|
2411
|
-
|
|
2412
|
-
|
|
2453
|
+
me as getStackCorners,
|
|
2454
|
+
L as getStackSize,
|
|
2413
2455
|
Y as normalizeSlicePlane,
|
|
2414
|
-
|
|
2415
|
-
|
|
2456
|
+
st as offsetSlicePlane,
|
|
2457
|
+
qe as resolveVolumeRenderingPreset
|
|
2416
2458
|
};
|