@cornerstonejs/core 5.8.1 → 5.10.2

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.
Files changed (88) hide show
  1. package/dist/esm/RenderingEngine/BaseRenderingEngine.js +4 -2
  2. package/dist/esm/RenderingEngine/BaseVolumeViewport.d.ts +1 -0
  3. package/dist/esm/RenderingEngine/BaseVolumeViewport.js +13 -3
  4. package/dist/esm/RenderingEngine/ContextPoolRenderingEngine.js +3 -1
  5. package/dist/esm/RenderingEngine/GenericViewport/DefaultRenderPathResolver.js +3 -1
  6. package/dist/esm/RenderingEngine/GenericViewport/Planar/DefaultPlanarDataProvider.js +3 -1
  7. package/dist/esm/RenderingEngine/GenericViewport/Planar/PlanarViewport.js +3 -1
  8. package/dist/esm/RenderingEngine/GenericViewport/Planar/PlanarViewportLegacyAdapter.js +3 -1
  9. package/dist/esm/RenderingEngine/GenericViewport/Planar/planarViewReference.js +1 -1
  10. package/dist/esm/RenderingEngine/GenericViewport/genericViewportReferenceCompatibility.js +3 -2
  11. package/dist/esm/RenderingEngine/RenderingEngine.js +3 -1
  12. package/dist/esm/RenderingEngine/StackViewport.js +8 -4
  13. package/dist/esm/RenderingEngine/TiledRenderingEngine.js +3 -1
  14. package/dist/esm/RenderingEngine/VideoViewport.d.ts +1 -0
  15. package/dist/esm/RenderingEngine/VideoViewport.js +18 -12
  16. package/dist/esm/RenderingEngine/Viewport.d.ts +1 -0
  17. package/dist/esm/RenderingEngine/Viewport.js +17 -10
  18. package/dist/esm/RenderingEngine/VolumeViewport.js +4 -2
  19. package/dist/esm/RenderingEngine/WSIViewport.js +1 -2
  20. package/dist/esm/RenderingEngine/helpers/addImageSlicesToViewports.js +3 -1
  21. package/dist/esm/RenderingEngine/helpers/addVolumesToViewports.js +3 -1
  22. package/dist/esm/RenderingEngine/helpers/attachWebGLContextEvents.js +3 -1
  23. package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/renderPseudoColorImage.js +3 -1
  24. package/dist/esm/RenderingEngine/helpers/getCameraVectors.js +3 -1
  25. package/dist/esm/RenderingEngine/helpers/stats/StatsOverlay.js +3 -1
  26. package/dist/esm/RenderingEngine/helpers/volumeNewImageEventDispatcher.js +3 -1
  27. package/dist/esm/RenderingEngine/vtkClasses/vtkStreamingOpenGLVolumeMapper.js +3 -1
  28. package/dist/esm/cache/cache.js +16 -14
  29. package/dist/esm/cache/classes/BaseStreamingImageVolume.js +4 -2
  30. package/dist/esm/eventTarget.js +3 -1
  31. package/dist/esm/init.js +7 -5
  32. package/dist/esm/loaders/ProgressiveRetrieveImages.js +3 -1
  33. package/dist/esm/loaders/cornerstoneStreamingImageVolumeLoader.js +4 -2
  34. package/dist/esm/loaders/fillNearbyFrames.js +3 -1
  35. package/dist/esm/requestPool/requestPoolManager.js +3 -1
  36. package/dist/esm/types/IViewport.d.ts +2 -0
  37. package/dist/esm/utilities/ProgressiveIterator.js +4 -2
  38. package/dist/esm/utilities/VoxelManager.js +12 -10
  39. package/dist/esm/utilities/calculateSpacingBetweenImageIds.js +5 -3
  40. package/dist/esm/utilities/calculateViewportsSpatialRegistration.js +4 -2
  41. package/dist/esm/utilities/deepEqual.js +3 -1
  42. package/dist/esm/utilities/eventListener/TargetEventListeners.js +3 -1
  43. package/dist/esm/utilities/getBufferConfiguration.js +3 -1
  44. package/dist/esm/utilities/getEffectiveSpacingAlongDirection.d.ts +6 -0
  45. package/dist/esm/utilities/getEffectiveSpacingAlongDirection.js +11 -0
  46. package/dist/esm/utilities/getImageSliceDataForVolumeViewport.js +3 -1
  47. package/dist/esm/utilities/getVolumeSliceRangeInfo.js +3 -1
  48. package/dist/esm/utilities/index.d.ts +5 -1
  49. package/dist/esm/utilities/index.js +5 -1
  50. package/dist/esm/utilities/loadImageToCanvas.js +3 -1
  51. package/dist/esm/utilities/logger.d.ts +2 -1
  52. package/dist/esm/utilities/logger.js +2 -1
  53. package/dist/esm/utilities/resolveApplicationUrl.d.ts +3 -0
  54. package/dist/esm/utilities/resolveApplicationUrl.js +31 -0
  55. package/dist/esm/utilities/snapFocalPointToSlice.js +7 -1
  56. package/dist/esm/utilities/updatePlaneRestriction.d.ts +2 -2
  57. package/dist/esm/utilities/updatePlaneRestriction.js +47 -19
  58. package/dist/esm/utilities/voxelSlab/getVoxelThicknessAlongNormal.d.ts +6 -0
  59. package/dist/esm/utilities/voxelSlab/getVoxelThicknessAlongNormal.js +10 -0
  60. package/dist/esm/utilities/voxelSlab/index.d.ts +10 -0
  61. package/dist/esm/utilities/voxelSlab/index.js +7 -0
  62. package/dist/esm/utilities/voxelSlab/indexSpaceSlab.d.ts +29 -0
  63. package/dist/esm/utilities/voxelSlab/indexSpaceSlab.js +121 -0
  64. package/dist/esm/utilities/voxelSlab/isPlaneDepthViewable.d.ts +2 -0
  65. package/dist/esm/utilities/voxelSlab/isPlaneDepthViewable.js +12 -0
  66. package/dist/esm/utilities/voxelSlab/iterateVoxelsInShape.d.ts +20 -0
  67. package/dist/esm/utilities/voxelSlab/iterateVoxelsInShape.js +91 -0
  68. package/dist/esm/utilities/voxelSlab/sampleVoxelsInShape.d.ts +16 -0
  69. package/dist/esm/utilities/voxelSlab/sampleVoxelsInShape.js +24 -0
  70. package/dist/esm/utilities/voxelSlab/shapes/createEllipseShape.d.ts +22 -0
  71. package/dist/esm/utilities/voxelSlab/shapes/createEllipseShape.js +90 -0
  72. package/dist/esm/utilities/voxelSlab/shapes/createPolylineShape.d.ts +10 -0
  73. package/dist/esm/utilities/voxelSlab/shapes/createPolylineShape.js +170 -0
  74. package/dist/esm/utilities/voxelSlab/shapes/createRectangleShape.d.ts +14 -0
  75. package/dist/esm/utilities/voxelSlab/shapes/createRectangleShape.js +69 -0
  76. package/dist/esm/utilities/voxelSlab/shapes/index.d.ts +8 -0
  77. package/dist/esm/utilities/voxelSlab/shapes/index.js +4 -0
  78. package/dist/esm/utilities/voxelSlab/shapes/shapeGeometry.d.ts +28 -0
  79. package/dist/esm/utilities/voxelSlab/shapes/shapeGeometry.js +99 -0
  80. package/dist/esm/utilities/voxelSlab/slabMembership.d.ts +11 -0
  81. package/dist/esm/utilities/voxelSlab/slabMembership.js +42 -0
  82. package/dist/esm/utilities/wasmBasePath.d.ts +3 -0
  83. package/dist/esm/utilities/wasmBasePath.js +12 -0
  84. package/dist/esm/version.d.ts +1 -1
  85. package/dist/esm/version.js +1 -1
  86. package/dist/esm/webWorkerManager/webWorkerManager.js +6 -6
  87. package/package.json +6 -7
  88. package/LICENSE +0 -21
@@ -0,0 +1,90 @@
1
+ import { vec3 } from 'gl-matrix';
2
+ import getVoxelThicknessAlongNormal from '../getVoxelThicknessAlongNormal.js';
3
+ import { projectPointOntoPlane } from '../slabMembership.js';
4
+ import { createColumnLineResolver, createPlaneBasis, SHAPE_BOUNDARY_EPSILON, solveQuadraticLeqZero, toIntegerRun, } from './shapeGeometry.js';
5
+ const UNIT_BOUNDARY = 1 + SHAPE_BOUNDARY_EPSILON;
6
+ export function createEllipseShape(options) {
7
+ const { volume, planePoint, viewPlaneNormal: normal, majorAxis, majorRadius, minorRadius, depthRadius, } = options;
8
+ if (!(majorRadius > 0) || !(minorRadius > 0)) {
9
+ throw new Error('Ellipse radii must be positive');
10
+ }
11
+ if (depthRadius !== undefined && !(depthRadius > 0)) {
12
+ throw new Error('Ellipse depthRadius must be positive when supplied');
13
+ }
14
+ const basis = createPlaneBasis(normal, majorAxis);
15
+ const isSolid = depthRadius !== undefined;
16
+ const voxelThickness = getVoxelThicknessAlongNormal(volume, basis.n);
17
+ const depthSemiAxis = isSolid
18
+ ? depthRadius + voxelThickness / 2
19
+ : 0;
20
+ const center = isSolid
21
+ ? [...options.centerWorld]
22
+ : projectPointOntoPlane(options.centerWorld, planePoint, basis.n);
23
+ const scaledAxes = [
24
+ { axis: basis.u, inverseRadius: 1 / majorRadius },
25
+ { axis: basis.v, inverseRadius: 1 / minorRadius },
26
+ ];
27
+ if (isSolid) {
28
+ scaledAxes.push({ axis: basis.n, inverseRadius: 1 / depthSemiAxis });
29
+ }
30
+ const resolveColumnLine = createColumnLineResolver(volume, basis.n);
31
+ function containsPoint(point) {
32
+ const tested = isSolid
33
+ ? point
34
+ : projectPointOntoPlane(point, planePoint, basis.n);
35
+ let total = 0;
36
+ for (const { axis, inverseRadius } of scaledAxes) {
37
+ const offset = (tested[0] - center[0]) * axis[0] +
38
+ (tested[1] - center[1]) * axis[1] +
39
+ (tested[2] - center[2]) * axis[2];
40
+ const scaled = offset * inverseRadius;
41
+ total += scaled * scaled;
42
+ }
43
+ return total <= UNIT_BOUNDARY;
44
+ }
45
+ function* getRuns(outerIndex, rowIndex, _depthRun, slab) {
46
+ const line = resolveColumnLine(slab, outerIndex, rowIndex);
47
+ const lineBase = isSolid ? line.base : line.projectedBase;
48
+ const lineStep = isSolid ? line.step : line.projectedStep;
49
+ let a = 0;
50
+ let b = 0;
51
+ let c = -UNIT_BOUNDARY;
52
+ for (const { axis, inverseRadius } of scaledAxes) {
53
+ const offset = ((lineBase[0] - center[0]) * axis[0] +
54
+ (lineBase[1] - center[1]) * axis[1] +
55
+ (lineBase[2] - center[2]) * axis[2]) *
56
+ inverseRadius;
57
+ const slope = (lineStep[0] * axis[0] +
58
+ lineStep[1] * axis[1] +
59
+ lineStep[2] * axis[2]) *
60
+ inverseRadius;
61
+ a += slope * slope;
62
+ b += 2 * offset * slope;
63
+ c += offset * offset;
64
+ }
65
+ const run = toIntegerRun(solveQuadraticLeqZero(a, b, c));
66
+ if (run) {
67
+ yield run;
68
+ }
69
+ }
70
+ return {
71
+ containsPoint,
72
+ getRuns,
73
+ getRequiredThickness: () => (isSolid ? depthSemiAxis * 2 : 0),
74
+ };
75
+ }
76
+ export function createCircleShape(options) {
77
+ const { viewPlaneNormal: normal } = options;
78
+ const candidate = Math.abs(normal[0]) < 0.9 ? [1, 0, 0] : [0, 1, 0];
79
+ const majorAxis = vec3.cross(vec3.create(), normal, candidate);
80
+ return createEllipseShape({
81
+ volume: options.volume,
82
+ planePoint: options.planePoint,
83
+ viewPlaneNormal: normal,
84
+ centerWorld: options.centerWorld,
85
+ majorAxis,
86
+ majorRadius: options.radius,
87
+ minorRadius: options.radius,
88
+ depthRadius: options.depthRadius,
89
+ });
90
+ }
@@ -0,0 +1,10 @@
1
+ import type { Point3 } from '../../../types/index.js';
2
+ import type { VolumeGeometry } from '../indexSpaceSlab.js';
3
+ import type { VoxelSlabShape } from './shapeGeometry.js';
4
+ export interface PolylineShapeOptions {
5
+ volume: VolumeGeometry;
6
+ planePoint?: Point3;
7
+ viewPlaneNormal: Point3;
8
+ polyline: Point3[] | Point3[][];
9
+ }
10
+ export declare function createPolylineShape(options: PolylineShapeOptions): VoxelSlabShape;
@@ -0,0 +1,170 @@
1
+ import { vec3 } from 'gl-matrix';
2
+ import { projectPointOntoPlane } from '../slabMembership.js';
3
+ import { SHAPE_BOUNDARY_EPSILON, createColumnLineResolver, createPlaneBasis, toIntegerRun, } from './shapeGeometry.js';
4
+ export function createPolylineShape(options) {
5
+ const { volume, viewPlaneNormal: normal, polyline } = options;
6
+ if (!polyline?.length) {
7
+ throw new Error('A polyline shape needs an outline');
8
+ }
9
+ const inputRings = Array.isArray(polyline[0]?.[0])
10
+ ? polyline
11
+ : [polyline];
12
+ if (inputRings.some((ring) => !ring?.length || ring.length < 3)) {
13
+ throw new Error('Every polyline ring needs at least three points');
14
+ }
15
+ const planePoint = options.planePoint ?? inputRings[0][0];
16
+ const candidate = Math.abs(normal[0]) < 0.9 ? [1, 0, 0] : [0, 1, 0];
17
+ const basis = createPlaneBasis(normal, vec3.cross(vec3.create(), normal, candidate));
18
+ const toPlanePoint = (point) => [
19
+ (point[0] - planePoint[0]) * basis.u[0] +
20
+ (point[1] - planePoint[1]) * basis.u[1] +
21
+ (point[2] - planePoint[2]) * basis.u[2],
22
+ (point[0] - planePoint[0]) * basis.v[0] +
23
+ (point[1] - planePoint[1]) * basis.v[1] +
24
+ (point[2] - planePoint[2]) * basis.v[2],
25
+ ];
26
+ const toPlaneDirection = (vector) => [
27
+ vector[0] * basis.u[0] + vector[1] * basis.u[1] + vector[2] * basis.u[2],
28
+ vector[0] * basis.v[0] + vector[1] * basis.v[1] + vector[2] * basis.v[2],
29
+ ];
30
+ const rings = inputRings.map((ring) => ring.map((point) => toPlanePoint(projectPointOntoPlane(point, planePoint, basis.n))));
31
+ let extent = 0;
32
+ for (const ring of rings) {
33
+ for (const [x, y] of ring) {
34
+ extent = Math.max(extent, Math.abs(x), Math.abs(y));
35
+ }
36
+ }
37
+ const boundarySlack = Math.max(extent, 1) * SHAPE_BOUNDARY_EPSILON;
38
+ function distanceToOutline(planePoint2) {
39
+ let best = Infinity;
40
+ for (const ring of rings) {
41
+ const distance = distanceToRing(ring, planePoint2);
42
+ if (distance < best) {
43
+ best = distance;
44
+ }
45
+ }
46
+ return best;
47
+ }
48
+ function distanceToRing(ring, [x, y]) {
49
+ let best = Infinity;
50
+ const vertexCount = ring.length;
51
+ for (let i = 0, j = vertexCount - 1; i < vertexCount; j = i++) {
52
+ const [xi, yi] = ring[i];
53
+ const [xj, yj] = ring[j];
54
+ const edgeX = xj - xi;
55
+ const edgeY = yj - yi;
56
+ const lengthSquared = edgeX * edgeX + edgeY * edgeY;
57
+ let t = 0;
58
+ if (lengthSquared > 0) {
59
+ t = ((x - xi) * edgeX + (y - yi) * edgeY) / lengthSquared;
60
+ t = t < 0 ? 0 : t > 1 ? 1 : t;
61
+ }
62
+ const dx = x - (xi + t * edgeX);
63
+ const dy = y - (yi + t * edgeY);
64
+ const distance = Math.hypot(dx, dy);
65
+ if (distance < best) {
66
+ best = distance;
67
+ }
68
+ }
69
+ return best;
70
+ }
71
+ const resolveColumnLine = createColumnLineResolver(volume, basis.n);
72
+ function containsPlanePoint([x, y]) {
73
+ let inside = false;
74
+ for (const ring of rings) {
75
+ const vertexCount = ring.length;
76
+ for (let i = 0, j = vertexCount - 1; i < vertexCount; j = i++) {
77
+ const [xi, yi] = ring[i];
78
+ const [xj, yj] = ring[j];
79
+ if (yi > y !== yj > y) {
80
+ const crossingX = xi + ((y - yi) / (yj - yi)) * (xj - xi);
81
+ if (x < crossingX) {
82
+ inside = !inside;
83
+ }
84
+ }
85
+ }
86
+ }
87
+ return inside || distanceToOutline([x, y]) <= boundarySlack;
88
+ }
89
+ function containsPoint(point) {
90
+ return containsPlanePoint(toPlanePoint(projectPointOntoPlane(point, planePoint, basis.n)));
91
+ }
92
+ function* getRuns(outerIndex, rowIndex, depthRun, slab) {
93
+ const line = resolveColumnLine(slab, outerIndex, rowIndex);
94
+ const origin2 = toPlanePoint(line.projectedBase);
95
+ const direction2 = toPlaneDirection(line.projectedStep);
96
+ const directionLengthSquared = direction2[0] * direction2[0] + direction2[1] * direction2[1];
97
+ if (directionLengthSquared <= 0) {
98
+ if (containsPlanePoint(origin2)) {
99
+ yield [depthRun[0], depthRun[1]];
100
+ }
101
+ return;
102
+ }
103
+ const directionLength = Math.sqrt(directionLengthSquared);
104
+ const slack = boundarySlack / directionLength;
105
+ const perpendicularScale = 1 / directionLength;
106
+ const columnOf = ([x, y]) => ((x - origin2[0]) * direction2[0] + (y - origin2[1]) * direction2[1]) /
107
+ directionLengthSquared;
108
+ const sideOf = ([x, y]) => direction2[0] * (y - origin2[1]) - direction2[1] * (x - origin2[0]);
109
+ const intervals = [];
110
+ const crossings = [];
111
+ for (const ring of rings) {
112
+ const vertexCount = ring.length;
113
+ let previousIndex = vertexCount - 1;
114
+ let previousSide = sideOf(ring[previousIndex]);
115
+ for (let i = 0; i < vertexCount; i++) {
116
+ const side = sideOf(ring[i]);
117
+ const previousOnLine = Math.abs(previousSide) * perpendicularScale <= boundarySlack;
118
+ const currentOnLine = Math.abs(side) * perpendicularScale <= boundarySlack;
119
+ if (previousOnLine && currentOnLine) {
120
+ const a = columnOf(ring[previousIndex]);
121
+ const b = columnOf(ring[i]);
122
+ intervals.push(a <= b ? [a - slack, b + slack] : [b - slack, a + slack]);
123
+ }
124
+ else if (currentOnLine) {
125
+ const at = columnOf(ring[i]);
126
+ intervals.push([at - slack, at + slack]);
127
+ }
128
+ if (previousSide > 0 !== side > 0) {
129
+ const t = previousSide / (previousSide - side);
130
+ const crossingX = ring[previousIndex][0] + t * (ring[i][0] - ring[previousIndex][0]);
131
+ const crossingY = ring[previousIndex][1] + t * (ring[i][1] - ring[previousIndex][1]);
132
+ crossings.push(columnOf([crossingX, crossingY]));
133
+ }
134
+ previousIndex = i;
135
+ previousSide = side;
136
+ }
137
+ }
138
+ crossings.sort((a, b) => a - b);
139
+ for (let pair = 0; pair + 1 < crossings.length; pair += 2) {
140
+ intervals.push([crossings[pair] - slack, crossings[pair + 1] + slack]);
141
+ }
142
+ if (!intervals.length) {
143
+ return;
144
+ }
145
+ intervals.sort((a, b) => a[0] - b[0]);
146
+ let [low, high] = intervals[0];
147
+ for (let index = 1; index < intervals.length; index++) {
148
+ const [nextLow, nextHigh] = intervals[index];
149
+ if (nextLow <= high) {
150
+ high = Math.max(high, nextHigh);
151
+ continue;
152
+ }
153
+ const run = toIntegerRun([low, high]);
154
+ if (run) {
155
+ yield run;
156
+ }
157
+ low = nextLow;
158
+ high = nextHigh;
159
+ }
160
+ const finalRun = toIntegerRun([low, high]);
161
+ if (finalRun) {
162
+ yield finalRun;
163
+ }
164
+ }
165
+ return {
166
+ containsPoint,
167
+ getRuns,
168
+ getRequiredThickness: () => 0,
169
+ };
170
+ }
@@ -0,0 +1,14 @@
1
+ import type { Point3 } from '../../../types/index.js';
2
+ import type { VolumeGeometry } from '../indexSpaceSlab.js';
3
+ import type { VoxelSlabShape } from './shapeGeometry.js';
4
+ export interface RectangleShapeOptions {
5
+ volume: VolumeGeometry;
6
+ planePoint: Point3;
7
+ viewPlaneNormal: Point3;
8
+ centerWorld: Point3;
9
+ majorAxis: Point3;
10
+ majorHalfLength: number;
11
+ minorHalfLength: number;
12
+ depthHalfLength?: number;
13
+ }
14
+ export declare function createRectangleShape(options: RectangleShapeOptions): VoxelSlabShape;
@@ -0,0 +1,69 @@
1
+ import getVoxelThicknessAlongNormal from '../getVoxelThicknessAlongNormal.js';
2
+ import { projectPointOntoPlane } from '../slabMembership.js';
3
+ import { UNBOUNDED, createColumnLineResolver, createPlaneBasis, SHAPE_BOUNDARY_EPSILON, intersectRanges, solveAbsLinearLeq, toIntegerRun, } from './shapeGeometry.js';
4
+ const expand = (halfExtent) => halfExtent + Math.max(halfExtent, 1) * SHAPE_BOUNDARY_EPSILON;
5
+ export function createRectangleShape(options) {
6
+ const { volume, planePoint, viewPlaneNormal: normal, majorAxis, majorHalfLength, minorHalfLength, depthHalfLength, } = options;
7
+ if (!(majorHalfLength > 0) || !(minorHalfLength > 0)) {
8
+ throw new Error('Rectangle half lengths must be positive');
9
+ }
10
+ if (depthHalfLength !== undefined && !(depthHalfLength > 0)) {
11
+ throw new Error('Rectangle depthHalfLength must be positive when supplied');
12
+ }
13
+ const basis = createPlaneBasis(normal, majorAxis);
14
+ const isSolid = depthHalfLength !== undefined;
15
+ const voxelThickness = getVoxelThicknessAlongNormal(volume, basis.n);
16
+ const depthExtent = isSolid
17
+ ? depthHalfLength + voxelThickness / 2
18
+ : 0;
19
+ const center = isSolid
20
+ ? [...options.centerWorld]
21
+ : projectPointOntoPlane(options.centerWorld, planePoint, basis.n);
22
+ const constraints = [
23
+ { axis: basis.u, halfExtent: expand(majorHalfLength) },
24
+ { axis: basis.v, halfExtent: expand(minorHalfLength) },
25
+ ];
26
+ if (isSolid) {
27
+ constraints.push({ axis: basis.n, halfExtent: expand(depthExtent) });
28
+ }
29
+ const resolveColumnLine = createColumnLineResolver(volume, basis.n);
30
+ function containsPoint(point) {
31
+ const tested = isSolid
32
+ ? point
33
+ : projectPointOntoPlane(point, planePoint, basis.n);
34
+ for (const { axis, halfExtent } of constraints) {
35
+ const offset = (tested[0] - center[0]) * axis[0] +
36
+ (tested[1] - center[1]) * axis[1] +
37
+ (tested[2] - center[2]) * axis[2];
38
+ if (Math.abs(offset) > halfExtent) {
39
+ return false;
40
+ }
41
+ }
42
+ return true;
43
+ }
44
+ function* getRuns(outerIndex, rowIndex, _depthRun, slab) {
45
+ const line = resolveColumnLine(slab, outerIndex, rowIndex);
46
+ const lineBase = isSolid ? line.base : line.projectedBase;
47
+ const lineStep = isSolid ? line.step : line.projectedStep;
48
+ let range = UNBOUNDED;
49
+ for (const { axis, halfExtent } of constraints) {
50
+ const offset = (lineBase[0] - center[0]) * axis[0] +
51
+ (lineBase[1] - center[1]) * axis[1] +
52
+ (lineBase[2] - center[2]) * axis[2];
53
+ const slope = lineStep[0] * axis[0] + lineStep[1] * axis[1] + lineStep[2] * axis[2];
54
+ range = intersectRanges(range, solveAbsLinearLeq(offset, slope, halfExtent));
55
+ if (!range) {
56
+ return;
57
+ }
58
+ }
59
+ const run = toIntegerRun(range);
60
+ if (run) {
61
+ yield run;
62
+ }
63
+ }
64
+ return {
65
+ containsPoint,
66
+ getRuns,
67
+ getRequiredThickness: () => (isSolid ? depthExtent * 2 : 0),
68
+ };
69
+ }
@@ -0,0 +1,8 @@
1
+ export type { VoxelSlabShape, PlaneBasis, ColumnLine, RealRange, } from './shapeGeometry.js';
2
+ export { createPlaneBasis, createColumnLineResolver, getAxisSteps, intersectRanges, solveAbsLinearLeq, solveQuadraticLeqZero, toIntegerRun, UNBOUNDED, } from './shapeGeometry.js';
3
+ export { createEllipseShape, createCircleShape } from './createEllipseShape.js';
4
+ export type { EllipseShapeOptions } from './createEllipseShape.js';
5
+ export { createRectangleShape } from './createRectangleShape.js';
6
+ export type { RectangleShapeOptions } from './createRectangleShape.js';
7
+ export { createPolylineShape } from './createPolylineShape.js';
8
+ export type { PolylineShapeOptions } from './createPolylineShape.js';
@@ -0,0 +1,4 @@
1
+ export { createPlaneBasis, createColumnLineResolver, getAxisSteps, intersectRanges, solveAbsLinearLeq, solveQuadraticLeqZero, toIntegerRun, UNBOUNDED, } from './shapeGeometry.js';
2
+ export { createEllipseShape, createCircleShape } from './createEllipseShape.js';
3
+ export { createRectangleShape } from './createRectangleShape.js';
4
+ export { createPolylineShape } from './createPolylineShape.js';
@@ -0,0 +1,28 @@
1
+ import type { Point2, Point3 } from '../../../types/index.js';
2
+ import type { IndexSpaceSlab, VolumeGeometry } from '../indexSpaceSlab.js';
3
+ export interface VoxelSlabShape {
4
+ containsPoint(point: Point3): boolean;
5
+ getRuns(outerIndex: number, rowIndex: number, depthRun: Point2, slab: IndexSpaceSlab): Iterable<Point2>;
6
+ getRequiredThickness(): number;
7
+ }
8
+ export interface PlaneBasis {
9
+ u: Point3;
10
+ v: Point3;
11
+ n: Point3;
12
+ }
13
+ export declare function createPlaneBasis(normal: Point3, orientation: Point3): PlaneBasis;
14
+ export declare function getAxisSteps(volume: VolumeGeometry): [Point3, Point3, Point3];
15
+ export interface ColumnLine {
16
+ base: Point3;
17
+ step: Point3;
18
+ projectedBase: Point3;
19
+ projectedStep: Point3;
20
+ }
21
+ export declare function createColumnLineResolver(volume: VolumeGeometry, normal: Point3): (slab: IndexSpaceSlab, outerIndex: number, rowIndex: number) => ColumnLine;
22
+ export declare const SHAPE_BOUNDARY_EPSILON = 0.00001;
23
+ export type RealRange = [number, number];
24
+ export declare const UNBOUNDED: RealRange;
25
+ export declare function intersectRanges(a: RealRange | null, b: RealRange | null): RealRange | null;
26
+ export declare function solveAbsLinearLeq(a: number, b: number, halfExtent: number): RealRange | null;
27
+ export declare function solveQuadraticLeqZero(A: number, B: number, C: number): RealRange | null;
28
+ export declare function toIntegerRun(range: RealRange | null): Point2 | null;
@@ -0,0 +1,99 @@
1
+ import { vec3 } from 'gl-matrix';
2
+ export function createPlaneBasis(normal, orientation) {
3
+ const n = vec3.normalize(vec3.create(), normal);
4
+ const along = vec3.dot(orientation, n);
5
+ const u = vec3.sub(vec3.create(), orientation, vec3.scale(vec3.create(), n, along));
6
+ const uLength = vec3.length(u);
7
+ if (!(uLength > 1e-12)) {
8
+ throw new Error('Shape orientation vector is parallel to the plane normal, so it defines no in-plane direction');
9
+ }
10
+ vec3.scale(u, u, 1 / uLength);
11
+ const v = vec3.cross(vec3.create(), n, u);
12
+ return { u: u, v, n };
13
+ }
14
+ export function getAxisSteps(volume) {
15
+ const { direction, spacing } = volume;
16
+ return [0, 1, 2].map((axis) => {
17
+ const unit = direction.slice(axis * 3, axis * 3 + 3);
18
+ return [
19
+ unit[0] * spacing[axis],
20
+ unit[1] * spacing[axis],
21
+ unit[2] * spacing[axis],
22
+ ];
23
+ });
24
+ }
25
+ export function createColumnLineResolver(volume, normal) {
26
+ const axisSteps = getAxisSteps(volume);
27
+ const { origin } = volume;
28
+ const line = {
29
+ base: [0, 0, 0],
30
+ step: [0, 0, 0],
31
+ projectedBase: [0, 0, 0],
32
+ projectedStep: [0, 0, 0],
33
+ };
34
+ let preparedSlab = null;
35
+ return function resolve(slab, outerIndex, rowIndex) {
36
+ const { g, c0, outerAxis, rowAxis, columnAxis } = slab;
37
+ if (preparedSlab !== slab) {
38
+ const columnStep = axisSteps[columnAxis];
39
+ const gColumn = g[columnAxis];
40
+ for (let axis = 0; axis < 3; axis++) {
41
+ line.step[axis] = columnStep[axis];
42
+ line.projectedStep[axis] = columnStep[axis] - gColumn * normal[axis];
43
+ }
44
+ preparedSlab = slab;
45
+ }
46
+ const outerStep = axisSteps[outerAxis];
47
+ const rowStep = axisSteps[rowAxis];
48
+ const baseDepth = outerIndex * g[outerAxis] + rowIndex * g[rowAxis] + c0;
49
+ for (let axis = 0; axis < 3; axis++) {
50
+ const base = origin[axis] + outerIndex * outerStep[axis] + rowIndex * rowStep[axis];
51
+ line.base[axis] = base;
52
+ line.projectedBase[axis] = base - baseDepth * normal[axis];
53
+ }
54
+ return line;
55
+ };
56
+ }
57
+ export const SHAPE_BOUNDARY_EPSILON = 1e-5;
58
+ export const UNBOUNDED = [-Infinity, Infinity];
59
+ export function intersectRanges(a, b) {
60
+ if (!a || !b) {
61
+ return null;
62
+ }
63
+ const low = Math.max(a[0], b[0]);
64
+ const high = Math.min(a[1], b[1]);
65
+ return low > high ? null : [low, high];
66
+ }
67
+ export function solveAbsLinearLeq(a, b, halfExtent) {
68
+ if (b === 0) {
69
+ return Math.abs(a) <= halfExtent ? UNBOUNDED : null;
70
+ }
71
+ const first = (-halfExtent - a) / b + 0;
72
+ const second = (halfExtent - a) / b + 0;
73
+ return first <= second ? [first, second] : [second, first];
74
+ }
75
+ export function solveQuadraticLeqZero(A, B, C) {
76
+ if (A === 0) {
77
+ if (B === 0) {
78
+ return C <= 0 ? UNBOUNDED : null;
79
+ }
80
+ const root = -C / B + 0;
81
+ return B > 0 ? [-Infinity, root] : [root, Infinity];
82
+ }
83
+ const discriminant = B * B - 4 * A * C;
84
+ if (discriminant < 0) {
85
+ return null;
86
+ }
87
+ const rootOfDiscriminant = Math.sqrt(discriminant);
88
+ const first = (-B - rootOfDiscriminant) / (2 * A) + 0;
89
+ const second = (-B + rootOfDiscriminant) / (2 * A) + 0;
90
+ return first <= second ? [first, second] : [second, first];
91
+ }
92
+ export function toIntegerRun(range) {
93
+ if (!range) {
94
+ return null;
95
+ }
96
+ const low = Math.ceil(range[0]);
97
+ const high = Math.floor(range[1]);
98
+ return low > high ? null : [low, high];
99
+ }
@@ -0,0 +1,11 @@
1
+ import type { Point3 } from '../../types/index.js';
2
+ export declare const SLAB_RELATIVE_EPSILON = 0.00001;
3
+ export declare function getSlabEpsilon(voxelThickness: number): number;
4
+ export declare function resolveReferencePlaneThickness(referencePlaneThickness: number | null | undefined, voxelThickness: number): number;
5
+ export declare function getMembershipHalfWidth(referencePlaneThickness: number, voxelThickness: number): number;
6
+ export declare function getDisplayHalfWidth(viewportSlabThickness: number, referencePlaneThickness: number): number;
7
+ export declare function signedDistanceToPlane(point: Point3, planePoint: Point3, normal: Point3): number;
8
+ export declare function isWithinSlab(signedDistance: number, halfWidth: number, epsilon: number): boolean;
9
+ export declare function isVoxelCenterInSlab(voxelCenter: Point3, planePoint: Point3, normal: Point3, referencePlaneThickness: number, voxelThickness: number): boolean;
10
+ export declare function projectPointOntoPlane(point: Point3, planePoint: Point3, normal: Point3, out?: Point3): Point3;
11
+ export declare function asUnitNormal(normal: Point3): Point3;
@@ -0,0 +1,42 @@
1
+ import { vec3 } from 'gl-matrix';
2
+ export const SLAB_RELATIVE_EPSILON = 1e-5;
3
+ export function getSlabEpsilon(voxelThickness) {
4
+ return Math.abs(voxelThickness) * SLAB_RELATIVE_EPSILON;
5
+ }
6
+ export function resolveReferencePlaneThickness(referencePlaneThickness, voxelThickness) {
7
+ return Number.isFinite(referencePlaneThickness) &&
8
+ referencePlaneThickness > 0
9
+ ? referencePlaneThickness
10
+ : voxelThickness;
11
+ }
12
+ export function getMembershipHalfWidth(referencePlaneThickness, voxelThickness) {
13
+ return (referencePlaneThickness + voxelThickness) / 2;
14
+ }
15
+ export function getDisplayHalfWidth(viewportSlabThickness, referencePlaneThickness) {
16
+ return (viewportSlabThickness + referencePlaneThickness) / 2;
17
+ }
18
+ export function signedDistanceToPlane(point, planePoint, normal) {
19
+ return ((point[0] - planePoint[0]) * normal[0] +
20
+ (point[1] - planePoint[1]) * normal[1] +
21
+ (point[2] - planePoint[2]) * normal[2]);
22
+ }
23
+ export function isWithinSlab(signedDistance, halfWidth, epsilon) {
24
+ return Math.abs(signedDistance) < halfWidth - epsilon;
25
+ }
26
+ export function isVoxelCenterInSlab(voxelCenter, planePoint, normal, referencePlaneThickness, voxelThickness) {
27
+ return isWithinSlab(signedDistanceToPlane(voxelCenter, planePoint, normal), getMembershipHalfWidth(referencePlaneThickness, voxelThickness), getSlabEpsilon(voxelThickness));
28
+ }
29
+ export function projectPointOntoPlane(point, planePoint, normal, out = [0, 0, 0]) {
30
+ const distance = signedDistanceToPlane(point, planePoint, normal);
31
+ out[0] = point[0] - distance * normal[0];
32
+ out[1] = point[1] - distance * normal[1];
33
+ out[2] = point[2] - distance * normal[2];
34
+ return out;
35
+ }
36
+ export function asUnitNormal(normal) {
37
+ const lengthSquared = normal[0] * normal[0] + normal[1] * normal[1] + normal[2] * normal[2];
38
+ if (Math.abs(lengthSquared - 1) < Number.EPSILON * 8) {
39
+ return normal;
40
+ }
41
+ return vec3.normalize(vec3.create(), normal);
42
+ }
@@ -0,0 +1,3 @@
1
+ export declare function setWasmBasePath(basePath?: string): void;
2
+ export declare function getWasmBasePath(): string | undefined;
3
+ export declare function resolveWasmBasePath(defaultDirectory?: string): string;
@@ -0,0 +1,12 @@
1
+ import resolveApplicationUrl from './resolveApplicationUrl.js';
2
+ let wasmBasePath;
3
+ export function setWasmBasePath(basePath) {
4
+ wasmBasePath = basePath || undefined;
5
+ }
6
+ export function getWasmBasePath() {
7
+ return wasmBasePath;
8
+ }
9
+ export function resolveWasmBasePath(defaultDirectory = '') {
10
+ const directory = wasmBasePath || defaultDirectory;
11
+ return resolveApplicationUrl(!directory || directory.endsWith('/') ? directory : `${directory}/`);
12
+ }
@@ -1 +1 @@
1
- export declare const version = "5.8.1";
1
+ export declare const version = "5.10.2";
@@ -1 +1 @@
1
- export const version = '5.8.1';
1
+ export const version = '5.10.2';
@@ -1,8 +1,8 @@
1
1
  import * as Comlink from 'comlink';
2
2
  import { RequestType } from '../enums/index.js';
3
3
  import { RequestPoolManager } from '../requestPool/requestPoolManager.js';
4
- import { workerLog } from '../utilities/logger.js';
5
- const registrationLog = workerLog.getLogger('registration');
4
+ import { coreLog } from '../utilities/logger.js';
5
+ const registrationLog = coreLog.getLogger('webWorkerManager', 'webWorkerManager');
6
6
  class CentralizedWorkerManager {
7
7
  constructor() {
8
8
  this.workerRegistry = {};
@@ -43,7 +43,7 @@ class CentralizedWorkerManager {
43
43
  getNextWorkerAPI(workerName) {
44
44
  const workerProperties = this.workerRegistry[workerName];
45
45
  if (!workerProperties) {
46
- console.error(`Worker type '${workerName}' is not registered.`);
46
+ registrationLog.error(`Worker type '${workerName}' is not registered.`);
47
47
  return null;
48
48
  }
49
49
  const workerInstances = workerProperties.instances.filter((instance) => instance !== null);
@@ -73,7 +73,7 @@ class CentralizedWorkerManager {
73
73
  const { api, index } = this.getNextWorkerAPI(workerName);
74
74
  if (!api) {
75
75
  const error = new Error(`No available worker instance for '${workerName}'`);
76
- console.error(error);
76
+ registrationLog.error(error);
77
77
  reject(error);
78
78
  return;
79
79
  }
@@ -99,7 +99,7 @@ class CentralizedWorkerManager {
99
99
  resolve(results);
100
100
  }
101
101
  catch (err) {
102
- console.error(`Error executing method '${methodName}' on worker '${workerName}':`, err);
102
+ registrationLog.error(`Error executing method '${methodName}' on worker '${workerName}':`, err);
103
103
  reject(err);
104
104
  }
105
105
  finally {
@@ -127,7 +127,7 @@ class CentralizedWorkerManager {
127
127
  terminate(workerName) {
128
128
  const workerProperties = this.workerRegistry[workerName];
129
129
  if (!workerProperties) {
130
- console.error(`Worker type '${workerName}' is not registered.`);
130
+ registrationLog.error(`Worker type '${workerName}' is not registered.`);
131
131
  return;
132
132
  }
133
133
  workerProperties.instances.forEach((_, index) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "5.8.1",
3
+ "version": "5.10.2",
4
4
  "description": "Cornerstone3D Core",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/esm/index.d.ts",
@@ -85,18 +85,18 @@
85
85
  "prepublishOnly": "pnpm run build"
86
86
  },
87
87
  "dependencies": {
88
- "@cornerstonejs/utils": "5.8.1",
88
+ "@cornerstonejs/utils": "5.10.2",
89
89
  "@kitware/vtk.js": "36.4.1",
90
90
  "comlink": "4.4.2",
91
91
  "gl-matrix": "3.4.3",
92
92
  "loglevel": "1.9.2"
93
93
  },
94
94
  "devDependencies": {
95
- "@cornerstonejs/metadata": "5.8.1"
95
+ "@cornerstonejs/metadata": "5.10.2"
96
96
  },
97
97
  "peerDependencies": {
98
- "@cornerstonejs/metadata": "5.8.1",
99
- "@cornerstonejs/utils": "5.8.1"
98
+ "@cornerstonejs/metadata": "5.10.2",
99
+ "@cornerstonejs/utils": "5.10.2"
100
100
  },
101
101
  "contributors": [
102
102
  {
@@ -108,6 +108,5 @@
108
108
  "funding": {
109
109
  "type": "individual",
110
110
  "url": "https://ohif.org/donate"
111
- },
112
- "gitHead": "b0e07ac229d4118fa46350210a0ed6ce2cd24a25"
111
+ }
113
112
  }