@cornerstonejs/adapters 1.51.4 → 1.52.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/dist/adapters.es.js +390 -128
- package/dist/adapters.es.js.map +1 -1
- package/package.json +5 -5
package/dist/adapters.es.js
CHANGED
|
@@ -38144,6 +38144,164 @@ function applyPointsToPiecewiseFunction(points, range, pwf) {
|
|
|
38144
38144
|
return rescaled;
|
|
38145
38145
|
}
|
|
38146
38146
|
|
|
38147
|
+
let PointsManager$2 = class PointsManager {
|
|
38148
|
+
constructor(configuration = {}) {
|
|
38149
|
+
this._dimensions = 3;
|
|
38150
|
+
this._length = 0;
|
|
38151
|
+
this._byteSize = 4;
|
|
38152
|
+
this.growSize = 128;
|
|
38153
|
+
const {
|
|
38154
|
+
initialSize = 1024,
|
|
38155
|
+
dimensions = 3,
|
|
38156
|
+
growSize = 128
|
|
38157
|
+
} = configuration;
|
|
38158
|
+
const itemLength = initialSize * dimensions;
|
|
38159
|
+
this.growSize = growSize;
|
|
38160
|
+
this.array = new ArrayBuffer(itemLength * this._byteSize);
|
|
38161
|
+
this.data = new Float32Array(this.array);
|
|
38162
|
+
this._dimensions = dimensions;
|
|
38163
|
+
}
|
|
38164
|
+
forEach(func) {
|
|
38165
|
+
for (let i = 0; i < this._length; i++) {
|
|
38166
|
+
func(this.getPoint(i), i);
|
|
38167
|
+
}
|
|
38168
|
+
}
|
|
38169
|
+
get length() {
|
|
38170
|
+
return this._length;
|
|
38171
|
+
}
|
|
38172
|
+
get dimensions() {
|
|
38173
|
+
return this._dimensions;
|
|
38174
|
+
}
|
|
38175
|
+
get dimensionLength() {
|
|
38176
|
+
return this._length * this._dimensions;
|
|
38177
|
+
}
|
|
38178
|
+
getPoint(index) {
|
|
38179
|
+
if (index < 0) {
|
|
38180
|
+
index += this._length;
|
|
38181
|
+
}
|
|
38182
|
+
if (index < 0 || index >= this._length) {
|
|
38183
|
+
return;
|
|
38184
|
+
}
|
|
38185
|
+
const offset = this._dimensions * index;
|
|
38186
|
+
return this.data.subarray(offset, offset + this._dimensions);
|
|
38187
|
+
}
|
|
38188
|
+
getPointArray(index) {
|
|
38189
|
+
const array = [];
|
|
38190
|
+
if (index < 0) {
|
|
38191
|
+
index += this._length;
|
|
38192
|
+
}
|
|
38193
|
+
if (index < 0 || index >= this._length) {
|
|
38194
|
+
return;
|
|
38195
|
+
}
|
|
38196
|
+
const offset = this._dimensions * index;
|
|
38197
|
+
for (let i = 0; i < this._dimensions; i++) {
|
|
38198
|
+
array.push(this.data[i + offset]);
|
|
38199
|
+
}
|
|
38200
|
+
return array;
|
|
38201
|
+
}
|
|
38202
|
+
grow(additionalSize = 1, growSize = this.growSize) {
|
|
38203
|
+
if (this.dimensionLength + additionalSize * this._dimensions <= this.data.length) {
|
|
38204
|
+
return;
|
|
38205
|
+
}
|
|
38206
|
+
const newSize = this.data.length + growSize;
|
|
38207
|
+
const newArray = new ArrayBuffer(newSize * this._dimensions * this._byteSize);
|
|
38208
|
+
const newData = new Float32Array(newArray);
|
|
38209
|
+
newData.set(this.data);
|
|
38210
|
+
this.data = newData;
|
|
38211
|
+
this.array = newArray;
|
|
38212
|
+
}
|
|
38213
|
+
reverse() {
|
|
38214
|
+
const midLength = Math.floor(this._length / 2);
|
|
38215
|
+
for (let i = 0; i < midLength; i++) {
|
|
38216
|
+
const indexStart = i * this._dimensions;
|
|
38217
|
+
const indexEnd = (this._length - 1 - i) * this._dimensions;
|
|
38218
|
+
for (let dimension = 0; dimension < this._dimensions; dimension++) {
|
|
38219
|
+
const valueStart = this.data[indexStart + dimension];
|
|
38220
|
+
this.data[indexStart + dimension] = this.data[indexEnd + dimension];
|
|
38221
|
+
this.data[indexEnd + dimension] = valueStart;
|
|
38222
|
+
}
|
|
38223
|
+
}
|
|
38224
|
+
}
|
|
38225
|
+
push(point) {
|
|
38226
|
+
this.grow(1);
|
|
38227
|
+
const offset = this.length * this._dimensions;
|
|
38228
|
+
for (let i = 0; i < this._dimensions; i++) {
|
|
38229
|
+
this.data[i + offset] = point[i];
|
|
38230
|
+
}
|
|
38231
|
+
this._length++;
|
|
38232
|
+
}
|
|
38233
|
+
map(f) {
|
|
38234
|
+
const mapData = [];
|
|
38235
|
+
for (let i = 0; i < this._length; i++) {
|
|
38236
|
+
mapData.push(f(this.getPoint(i), i));
|
|
38237
|
+
}
|
|
38238
|
+
return mapData;
|
|
38239
|
+
}
|
|
38240
|
+
get points() {
|
|
38241
|
+
return this.map(p => p);
|
|
38242
|
+
}
|
|
38243
|
+
toXYZ() {
|
|
38244
|
+
const xyz = {
|
|
38245
|
+
x: [],
|
|
38246
|
+
y: []
|
|
38247
|
+
};
|
|
38248
|
+
if (this._dimensions >= 3) {
|
|
38249
|
+
xyz.z = [];
|
|
38250
|
+
}
|
|
38251
|
+
const {
|
|
38252
|
+
x,
|
|
38253
|
+
y,
|
|
38254
|
+
z
|
|
38255
|
+
} = xyz;
|
|
38256
|
+
this.forEach(p => {
|
|
38257
|
+
x.push(p[0]);
|
|
38258
|
+
y.push(p[1]);
|
|
38259
|
+
if (z) {
|
|
38260
|
+
z.push(p[2]);
|
|
38261
|
+
}
|
|
38262
|
+
});
|
|
38263
|
+
return xyz;
|
|
38264
|
+
}
|
|
38265
|
+
static fromXYZ({
|
|
38266
|
+
x,
|
|
38267
|
+
y,
|
|
38268
|
+
z
|
|
38269
|
+
}) {
|
|
38270
|
+
const array = PointsManager.create3(x.length);
|
|
38271
|
+
let offset = 0;
|
|
38272
|
+
for (let i = 0; i < x.length; i++) {
|
|
38273
|
+
array.data[offset++] = x[i];
|
|
38274
|
+
array.data[offset++] = y[i];
|
|
38275
|
+
array.data[offset++] = z ? z[i] : 0;
|
|
38276
|
+
}
|
|
38277
|
+
array._length = x.length;
|
|
38278
|
+
return array;
|
|
38279
|
+
}
|
|
38280
|
+
subselect(count = 10, offset = 0) {
|
|
38281
|
+
const selected = new PointsManager({
|
|
38282
|
+
initialSize: count,
|
|
38283
|
+
dimensions: this._dimensions
|
|
38284
|
+
});
|
|
38285
|
+
for (let i = 0; i < count; i++) {
|
|
38286
|
+
const index = (offset + Math.floor(this.length * i / count)) % this.length;
|
|
38287
|
+
selected.push(this.getPoint(index));
|
|
38288
|
+
}
|
|
38289
|
+
return selected;
|
|
38290
|
+
}
|
|
38291
|
+
static create3(initialSize = 128) {
|
|
38292
|
+
return new PointsManager({
|
|
38293
|
+
initialSize,
|
|
38294
|
+
dimensions: 3
|
|
38295
|
+
});
|
|
38296
|
+
}
|
|
38297
|
+
static create2(initialSize = 128) {
|
|
38298
|
+
return new PointsManager({
|
|
38299
|
+
initialSize,
|
|
38300
|
+
dimensions: 2
|
|
38301
|
+
});
|
|
38302
|
+
}
|
|
38303
|
+
};
|
|
38304
|
+
|
|
38147
38305
|
const isMergeableObject = val => {
|
|
38148
38306
|
const nonNullObject = val && typeof val === 'object';
|
|
38149
38307
|
return nonNullObject && Object.prototype.toString.call(val) !== '[object RegExp]' && Object.prototype.toString.call(val) !== '[object Date]';
|
|
@@ -42216,6 +42374,7 @@ var colormap = /*#__PURE__*/Object.freeze({
|
|
|
42216
42374
|
|
|
42217
42375
|
var utilities = /*#__PURE__*/Object.freeze({
|
|
42218
42376
|
__proto__: null,
|
|
42377
|
+
PointsManager: PointsManager$2,
|
|
42219
42378
|
ProgressiveIterator: ProgressiveIterator,
|
|
42220
42379
|
VoxelManager: VoxelManager,
|
|
42221
42380
|
actorIsA: actorIsA,
|
|
@@ -45160,7 +45319,9 @@ class StackViewport extends Viewport$1 {
|
|
|
45160
45319
|
}
|
|
45161
45320
|
const csImgFrame = this.csImage?.imageFrame;
|
|
45162
45321
|
const imgFrame = image?.imageFrame;
|
|
45163
|
-
|
|
45322
|
+
const photometricInterpretation = csImgFrame?.photometricInterpretation || this.csImage?.photometricInterpretation;
|
|
45323
|
+
const newPhotometricInterpretation = imgFrame?.photometricInterpretation || image?.photometricInterpretation;
|
|
45324
|
+
if (photometricInterpretation !== newPhotometricInterpretation) {
|
|
45164
45325
|
this.stackInvalidated = true;
|
|
45165
45326
|
}
|
|
45166
45327
|
this._setCSImage(image);
|
|
@@ -47039,6 +47200,7 @@ var ChangeTypes;
|
|
|
47039
47200
|
ChangeTypes["StatsUpdated"] = "StatsUpdated";
|
|
47040
47201
|
ChangeTypes["InitialSetup"] = "InitialSetup";
|
|
47041
47202
|
ChangeTypes["Completed"] = "Completed";
|
|
47203
|
+
ChangeTypes["InterpolationUpdated"] = "InterpolationUpdated";
|
|
47042
47204
|
})(ChangeTypes || (ChangeTypes = {}));
|
|
47043
47205
|
var ChangeTypes$1 = ChangeTypes;
|
|
47044
47206
|
|
|
@@ -48231,7 +48393,9 @@ function getInterpolationData(viewportData, filterParams = []) {
|
|
|
48231
48393
|
return value === x.value;
|
|
48232
48394
|
});
|
|
48233
48395
|
});
|
|
48234
|
-
|
|
48396
|
+
if (filteredInterpolatedAnnotations.length) {
|
|
48397
|
+
interpolationDatas.set(i, filteredInterpolatedAnnotations);
|
|
48398
|
+
}
|
|
48235
48399
|
}
|
|
48236
48400
|
return interpolationDatas;
|
|
48237
48401
|
}
|
|
@@ -48264,7 +48428,8 @@ function createPolylineToolData(polyline, handlePoints, referencedToolData) {
|
|
|
48264
48428
|
});
|
|
48265
48429
|
Object.assign(annotation.data, {
|
|
48266
48430
|
handles: {
|
|
48267
|
-
points: handlePoints || [],
|
|
48431
|
+
points: handlePoints.points || handlePoints || [],
|
|
48432
|
+
interpolationSources: handlePoints.sources,
|
|
48268
48433
|
activeHandleIndex: null,
|
|
48269
48434
|
textBox: {
|
|
48270
48435
|
hasMoved: false,
|
|
@@ -48334,7 +48499,7 @@ function _getSlicePositionOfToolData(interpolationData, annotationUID) {
|
|
|
48334
48499
|
}
|
|
48335
48500
|
function _sliceNeedsInterpolating(interpolationData, sliceIndex) {
|
|
48336
48501
|
const annotations = interpolationData.get(sliceIndex);
|
|
48337
|
-
return !annotations || annotations.length === 1 && annotations[0].autoGenerated;
|
|
48502
|
+
return !annotations?.length || annotations.length === 1 && annotations[0].autoGenerated;
|
|
48338
48503
|
}
|
|
48339
48504
|
function _appendInterpolationList(contourPair, interpolationList, itemIndex) {
|
|
48340
48505
|
const [startIndex] = contourPair;
|
|
@@ -48382,99 +48547,182 @@ function _getBoundingPair(sliceIndex, sliceRange, interpolationData) {
|
|
|
48382
48547
|
return annotationPair;
|
|
48383
48548
|
}
|
|
48384
48549
|
|
|
48385
|
-
|
|
48386
|
-
|
|
48387
|
-
|
|
48388
|
-
|
|
48389
|
-
|
|
48390
|
-
|
|
48391
|
-
|
|
48392
|
-
|
|
48393
|
-
|
|
48394
|
-
|
|
48395
|
-
|
|
48396
|
-
|
|
48397
|
-
|
|
48398
|
-
|
|
48399
|
-
|
|
48400
|
-
|
|
48401
|
-
|
|
48402
|
-
|
|
48403
|
-
|
|
48404
|
-
|
|
48405
|
-
|
|
48406
|
-
|
|
48407
|
-
|
|
48408
|
-
|
|
48409
|
-
|
|
48550
|
+
const {
|
|
48551
|
+
PointsManager: PointsManager$1
|
|
48552
|
+
} = utilities;
|
|
48553
|
+
function selectHandles(polyline, handleCount = 8) {
|
|
48554
|
+
const handles = PointsManager$1.create3(handleCount);
|
|
48555
|
+
handles.sources = [];
|
|
48556
|
+
const {
|
|
48557
|
+
sources: destPoints
|
|
48558
|
+
} = handles;
|
|
48559
|
+
const {
|
|
48560
|
+
length,
|
|
48561
|
+
sources: sourcePoints = []
|
|
48562
|
+
} = polyline;
|
|
48563
|
+
const distance = 6;
|
|
48564
|
+
if (length < distance * 3) {
|
|
48565
|
+
console.log('Adding subselect handles', handleCount, length);
|
|
48566
|
+
return polyline.subselect(handleCount);
|
|
48567
|
+
}
|
|
48568
|
+
const interval = Math.min(30, Math.floor(length / 3));
|
|
48569
|
+
sourcePoints.forEach(() => destPoints.push(PointsManager$1.create3(handleCount)));
|
|
48570
|
+
const dotValues = createDotValues(polyline, distance);
|
|
48571
|
+
const minimumRegions = findMinimumRegions(dotValues, handleCount);
|
|
48572
|
+
const indices = [];
|
|
48573
|
+
if (minimumRegions?.length > 2) {
|
|
48574
|
+
let lastHandle = -1;
|
|
48575
|
+
const thirdInterval = interval / 3;
|
|
48576
|
+
minimumRegions.forEach(region => {
|
|
48577
|
+
const [start,, end] = region;
|
|
48578
|
+
const midIndex = Math.ceil((start + end) / 2);
|
|
48579
|
+
if (end - lastHandle < thirdInterval) {
|
|
48580
|
+
return;
|
|
48410
48581
|
}
|
|
48582
|
+
if (midIndex - start > 2 * thirdInterval) {
|
|
48583
|
+
addInterval(indices, lastHandle, start, interval, length);
|
|
48584
|
+
lastHandle = addInterval(indices, start, midIndex, interval, length);
|
|
48585
|
+
} else {
|
|
48586
|
+
lastHandle = addInterval(indices, lastHandle, midIndex, interval, length);
|
|
48587
|
+
}
|
|
48588
|
+
if (end - lastHandle > thirdInterval) {
|
|
48589
|
+
lastHandle = addInterval(indices, lastHandle, end, interval, length);
|
|
48590
|
+
}
|
|
48591
|
+
});
|
|
48592
|
+
const firstHandle = indices[0];
|
|
48593
|
+
const lastDistance = indexValue(firstHandle + length - lastHandle, length);
|
|
48594
|
+
if (lastDistance > 2 * thirdInterval) {
|
|
48595
|
+
addInterval(indices, lastHandle, firstHandle - thirdInterval, interval, length);
|
|
48411
48596
|
}
|
|
48597
|
+
} else {
|
|
48598
|
+
const interval = Math.floor(length / handleCount);
|
|
48599
|
+
addInterval(indices, -1, length - interval, interval, length);
|
|
48412
48600
|
}
|
|
48413
|
-
|
|
48414
|
-
const
|
|
48415
|
-
|
|
48416
|
-
|
|
48601
|
+
indices.forEach(index => {
|
|
48602
|
+
const point = polyline.getPointArray(index);
|
|
48603
|
+
handles.push(point);
|
|
48604
|
+
sourcePoints.forEach((source, destSourceIndex) => destPoints[destSourceIndex].push(source.getPoint(index)));
|
|
48605
|
+
});
|
|
48606
|
+
return handles;
|
|
48607
|
+
}
|
|
48608
|
+
function createDotValues(polyline, distance = 6) {
|
|
48609
|
+
const {
|
|
48610
|
+
length
|
|
48611
|
+
} = polyline;
|
|
48612
|
+
const prevVec3 = vec3.create();
|
|
48613
|
+
const nextVec3 = vec3.create();
|
|
48614
|
+
const dotValues = new Float32Array(length);
|
|
48615
|
+
for (let i = 0; i < length; i++) {
|
|
48616
|
+
const point = polyline.getPoint(i);
|
|
48617
|
+
const prevPoint = polyline.getPoint(i - distance);
|
|
48618
|
+
const nextPoint = polyline.getPoint((i + distance) % length);
|
|
48619
|
+
vec3.sub(prevVec3, point, prevPoint);
|
|
48620
|
+
vec3.sub(nextVec3, nextPoint, point);
|
|
48621
|
+
const dot = vec3.dot(prevVec3, nextVec3) / (vec3.len(prevVec3) * vec3.len(nextVec3));
|
|
48622
|
+
dotValues[i] = dot;
|
|
48623
|
+
}
|
|
48624
|
+
return dotValues;
|
|
48625
|
+
}
|
|
48626
|
+
function findMinimumRegions(dotValues, handleCount) {
|
|
48627
|
+
const {
|
|
48628
|
+
max,
|
|
48629
|
+
deviation
|
|
48630
|
+
} = getStats(dotValues);
|
|
48631
|
+
const {
|
|
48632
|
+
length
|
|
48633
|
+
} = dotValues;
|
|
48634
|
+
if (deviation < 0.01 || length < handleCount * 3) {
|
|
48635
|
+
return [0, Math.floor(length / 3), Math.floor(length * 2 / 3)];
|
|
48636
|
+
}
|
|
48637
|
+
const inflection = [];
|
|
48638
|
+
let pair = null;
|
|
48639
|
+
let minValue;
|
|
48640
|
+
let minIndex = 0;
|
|
48641
|
+
for (let i = 0; i < length; i++) {
|
|
48642
|
+
const dot = dotValues[i];
|
|
48643
|
+
if (dot < max - deviation) {
|
|
48644
|
+
if (pair) {
|
|
48645
|
+
pair[2] = i;
|
|
48646
|
+
if (dot < minValue) {
|
|
48647
|
+
minValue = dot;
|
|
48648
|
+
minIndex = i;
|
|
48649
|
+
}
|
|
48650
|
+
pair[1] = minIndex;
|
|
48651
|
+
} else {
|
|
48652
|
+
minValue = dot;
|
|
48653
|
+
minIndex = i;
|
|
48654
|
+
pair = [i, i, i];
|
|
48655
|
+
}
|
|
48656
|
+
} else {
|
|
48657
|
+
if (pair) {
|
|
48658
|
+
inflection.push(pair);
|
|
48659
|
+
pair = null;
|
|
48660
|
+
}
|
|
48417
48661
|
}
|
|
48418
|
-
return mapData;
|
|
48419
48662
|
}
|
|
48420
|
-
|
|
48421
|
-
|
|
48422
|
-
|
|
48423
|
-
|
|
48424
|
-
|
|
48425
|
-
|
|
48426
|
-
|
|
48427
|
-
});
|
|
48428
|
-
let offset = 0;
|
|
48429
|
-
for (let i = 0; i < x.length; i++) {
|
|
48430
|
-
array.data[offset++] = x[i];
|
|
48431
|
-
array.data[offset++] = y[i];
|
|
48432
|
-
array.data[offset++] = z[i];
|
|
48663
|
+
if (pair) {
|
|
48664
|
+
if (inflection[0][0] === 0) {
|
|
48665
|
+
inflection[0][0] = pair[0];
|
|
48666
|
+
} else {
|
|
48667
|
+
pair[1] = minIndex;
|
|
48668
|
+
pair[2] = length - 1;
|
|
48669
|
+
inflection.push(pair);
|
|
48433
48670
|
}
|
|
48434
|
-
array.length = x.length;
|
|
48435
|
-
return array;
|
|
48436
48671
|
}
|
|
48672
|
+
return inflection;
|
|
48437
48673
|
}
|
|
48438
|
-
|
|
48439
|
-
|
|
48440
|
-
|
|
48441
|
-
...configuration,
|
|
48442
|
-
dimensions: 3
|
|
48443
|
-
});
|
|
48444
|
-
}
|
|
48445
|
-
forEach(func, point = vec3.create()) {
|
|
48446
|
-
super.forEach(func, point);
|
|
48674
|
+
function addInterval(indices, start, finish, interval, length) {
|
|
48675
|
+
if (finish < start) {
|
|
48676
|
+
finish += length;
|
|
48447
48677
|
}
|
|
48448
|
-
|
|
48449
|
-
|
|
48450
|
-
|
|
48678
|
+
const distance = finish - start;
|
|
48679
|
+
const count = Math.ceil(distance / interval);
|
|
48680
|
+
if (count <= 0) {
|
|
48681
|
+
if (indices[indices.length - 1] !== finish) {
|
|
48682
|
+
indices.push(indexValue(finish, length));
|
|
48451
48683
|
}
|
|
48452
|
-
|
|
48453
|
-
point[0] = this.data[index2];
|
|
48454
|
-
point[1] = this.data[index2 + 1];
|
|
48455
|
-
point[2] = this.data[index2 + 2];
|
|
48456
|
-
return point;
|
|
48684
|
+
return finish;
|
|
48457
48685
|
}
|
|
48458
|
-
|
|
48459
|
-
|
|
48686
|
+
for (let i = 1; i <= count; i++) {
|
|
48687
|
+
const index = indexValue(start + i * distance / count, length);
|
|
48688
|
+
indices.push(index);
|
|
48460
48689
|
}
|
|
48461
|
-
|
|
48462
|
-
|
|
48463
|
-
|
|
48464
|
-
|
|
48465
|
-
|
|
48466
|
-
|
|
48467
|
-
|
|
48468
|
-
|
|
48469
|
-
|
|
48470
|
-
|
|
48471
|
-
|
|
48472
|
-
|
|
48473
|
-
|
|
48474
|
-
|
|
48690
|
+
return indices[indices.length - 1];
|
|
48691
|
+
}
|
|
48692
|
+
function indexValue(v, length) {
|
|
48693
|
+
return (Math.round(v) + length) % length;
|
|
48694
|
+
}
|
|
48695
|
+
function getStats(dotValues) {
|
|
48696
|
+
const {
|
|
48697
|
+
length
|
|
48698
|
+
} = dotValues;
|
|
48699
|
+
let sum = 0;
|
|
48700
|
+
let min = Infinity;
|
|
48701
|
+
let max = -Infinity;
|
|
48702
|
+
let sumSq = 0;
|
|
48703
|
+
for (let i = 0; i < length; i++) {
|
|
48704
|
+
const dot = dotValues[i];
|
|
48705
|
+
sum += dot;
|
|
48706
|
+
min = Math.min(min, dot);
|
|
48707
|
+
max = Math.max(max, dot);
|
|
48708
|
+
}
|
|
48709
|
+
const mean = sum / length;
|
|
48710
|
+
for (let i = 0; i < length; i++) {
|
|
48711
|
+
const valueDiff = dotValues[i] - mean;
|
|
48712
|
+
sumSq += valueDiff * valueDiff;
|
|
48475
48713
|
}
|
|
48714
|
+
return {
|
|
48715
|
+
mean,
|
|
48716
|
+
max,
|
|
48717
|
+
min,
|
|
48718
|
+
sumSq,
|
|
48719
|
+
deviation: Math.sqrt(sumSq / length)
|
|
48720
|
+
};
|
|
48476
48721
|
}
|
|
48477
48722
|
|
|
48723
|
+
const {
|
|
48724
|
+
PointsManager
|
|
48725
|
+
} = utilities;
|
|
48478
48726
|
const dP = 0.2;
|
|
48479
48727
|
let interpolating = false;
|
|
48480
48728
|
function interpolate(viewportData) {
|
|
@@ -48482,11 +48730,24 @@ function interpolate(viewportData) {
|
|
|
48482
48730
|
return;
|
|
48483
48731
|
}
|
|
48484
48732
|
interpolating = true;
|
|
48485
|
-
|
|
48486
|
-
|
|
48487
|
-
|
|
48488
|
-
|
|
48489
|
-
|
|
48733
|
+
const {
|
|
48734
|
+
isInterpolationUpdate,
|
|
48735
|
+
annotation
|
|
48736
|
+
} = viewportData;
|
|
48737
|
+
queueMicrotask(() => {
|
|
48738
|
+
try {
|
|
48739
|
+
if (isInterpolationUpdate) {
|
|
48740
|
+
annotation.isInterpolationUpdate = true;
|
|
48741
|
+
annotation.autoGenerated = false;
|
|
48742
|
+
}
|
|
48743
|
+
startInterpolation(viewportData);
|
|
48744
|
+
} finally {
|
|
48745
|
+
interpolating = false;
|
|
48746
|
+
if (isInterpolationUpdate) {
|
|
48747
|
+
annotation.autoGenerated = true;
|
|
48748
|
+
}
|
|
48749
|
+
}
|
|
48750
|
+
});
|
|
48490
48751
|
}
|
|
48491
48752
|
function startInterpolation(viewportData) {
|
|
48492
48753
|
const toolData = viewportData.annotation;
|
|
@@ -48526,6 +48787,8 @@ function _linearlyInterpolateBetween(indices, annotationPair, interpolationData,
|
|
|
48526
48787
|
c1Interp,
|
|
48527
48788
|
c2Interp
|
|
48528
48789
|
} = _generateInterpolationContourPair(c1, c2);
|
|
48790
|
+
c1Interp.kIndex = annotationPair[0];
|
|
48791
|
+
c2Interp.kIndex = annotationPair[1];
|
|
48529
48792
|
indices.forEach(function (index) {
|
|
48530
48793
|
_linearlyInterpolateContour(c1Interp, c2Interp, index, annotationPair, interpolationData, c1.x.length > c2.x.length, eventData);
|
|
48531
48794
|
});
|
|
@@ -48535,30 +48798,15 @@ function _linearlyInterpolateContour(c1Interp, c2Interp, sliceIndex, annotationP
|
|
|
48535
48798
|
const zInterp = (sliceIndex - startIndex) / (endIndex - startIndex);
|
|
48536
48799
|
const interpolated3DPoints = _generateInterpolatedOpenContour(c1Interp, c2Interp, zInterp, c1HasMoreNodes);
|
|
48537
48800
|
const nearestAnnotation = interpolationData.get(annotationPair[zInterp > 0.5 ? 1 : 0])[0];
|
|
48538
|
-
const
|
|
48539
|
-
const handlePoints = _subselect(interpolated3DPoints, handleCount);
|
|
48801
|
+
const handlePoints = selectHandles(interpolated3DPoints);
|
|
48540
48802
|
if (interpolationData.has(sliceIndex)) {
|
|
48541
48803
|
_editInterpolatedContour(interpolated3DPoints, handlePoints, sliceIndex, nearestAnnotation, eventData);
|
|
48542
48804
|
} else {
|
|
48543
48805
|
_addInterpolatedContour(interpolated3DPoints, handlePoints, sliceIndex, nearestAnnotation, eventData);
|
|
48544
48806
|
}
|
|
48545
48807
|
}
|
|
48546
|
-
function _subselect(points, count = 10) {
|
|
48547
|
-
const handles = [];
|
|
48548
|
-
const {
|
|
48549
|
-
length
|
|
48550
|
-
} = points.x;
|
|
48551
|
-
if (!length) {
|
|
48552
|
-
return handles;
|
|
48553
|
-
}
|
|
48554
|
-
for (let i = 0; i < count; i++) {
|
|
48555
|
-
const handleIndex = Math.floor(length * i / count);
|
|
48556
|
-
handles.push(vec3.fromValues(points.x[handleIndex], points.y[handleIndex], points.z[handleIndex]));
|
|
48557
|
-
}
|
|
48558
|
-
return handles;
|
|
48559
|
-
}
|
|
48560
48808
|
function _addInterpolatedContour(interpolated3DPoints, handlePoints, sliceIndex, referencedToolData, eventData) {
|
|
48561
|
-
const points =
|
|
48809
|
+
const points = interpolated3DPoints.points;
|
|
48562
48810
|
const {
|
|
48563
48811
|
viewport
|
|
48564
48812
|
} = eventData;
|
|
@@ -48569,7 +48817,7 @@ function _addInterpolatedContour(interpolated3DPoints, handlePoints, sliceIndex,
|
|
|
48569
48817
|
interpolatedAnnotation.metadata.referencedImageId = targetId;
|
|
48570
48818
|
interpolatedAnnotation.metadata.referencedSliceIndex = sliceIndex;
|
|
48571
48819
|
addAnnotation(interpolatedAnnotation, viewport.element);
|
|
48572
|
-
referencedToolData.
|
|
48820
|
+
referencedToolData.onInterpolationComplete?.(interpolatedAnnotation, referencedToolData);
|
|
48573
48821
|
}
|
|
48574
48822
|
function _editInterpolatedContour(interpolated3DPoints, handlePoints, sliceIndex, referencedToolData, eventData) {
|
|
48575
48823
|
const {
|
|
@@ -48589,26 +48837,37 @@ function _editInterpolatedContour(interpolated3DPoints, handlePoints, sliceIndex
|
|
|
48589
48837
|
return;
|
|
48590
48838
|
}
|
|
48591
48839
|
const oldToolData = annotations[toolDataIndex];
|
|
48592
|
-
const points =
|
|
48840
|
+
const points = interpolated3DPoints.points;
|
|
48593
48841
|
const interpolatedAnnotation = createPolylineToolData(points, handlePoints, oldToolData);
|
|
48594
48842
|
interpolatedAnnotation.annotationUID = oldToolData.annotationUID;
|
|
48595
48843
|
removeAnnotation(oldToolData.annotationUID);
|
|
48596
48844
|
addAnnotation(interpolatedAnnotation, viewport.element);
|
|
48597
48845
|
}
|
|
48598
48846
|
function _generateInterpolatedOpenContour(c1ir, c2ir, zInterp, c1HasMoreNodes) {
|
|
48599
|
-
const cInterp = {
|
|
48600
|
-
x: [],
|
|
48601
|
-
y: [],
|
|
48602
|
-
z: []
|
|
48603
|
-
};
|
|
48604
48847
|
const indices = c1HasMoreNodes ? c1ir.I : c2ir.I;
|
|
48848
|
+
const c1 = PointsManager.fromXYZ(c1ir);
|
|
48849
|
+
const c2 = PointsManager.fromXYZ(c2ir);
|
|
48850
|
+
const {
|
|
48851
|
+
length
|
|
48852
|
+
} = c1;
|
|
48853
|
+
const cInterp = PointsManager.create3(length);
|
|
48854
|
+
const vecSubtract = vec3.create();
|
|
48855
|
+
const vecResult = vec3.create();
|
|
48856
|
+
const c1Source = PointsManager.create3(length);
|
|
48857
|
+
c1Source.kIndex = c1ir.kIndex;
|
|
48858
|
+
const c2Source = PointsManager.create3(length);
|
|
48859
|
+
c2Source.kIndex = c2ir.kIndex;
|
|
48605
48860
|
for (let i = 0; i < c1ir.x.length; i++) {
|
|
48606
48861
|
if (indices[i]) {
|
|
48607
|
-
|
|
48608
|
-
|
|
48609
|
-
|
|
48862
|
+
const c1point = c1.getPoint(i);
|
|
48863
|
+
const c2point = c2.getPoint(i);
|
|
48864
|
+
c1Source.push(c1point);
|
|
48865
|
+
c2Source.push(c2point);
|
|
48866
|
+
vec3.sub(vecSubtract, c2point, c1point);
|
|
48867
|
+
cInterp.push(vec3.scaleAndAdd(vecResult, c1point, vecSubtract, zInterp));
|
|
48610
48868
|
}
|
|
48611
48869
|
}
|
|
48870
|
+
cInterp.sources = [c1Source, c2Source];
|
|
48612
48871
|
return cInterp;
|
|
48613
48872
|
}
|
|
48614
48873
|
function _generateInterpolationContourPair(c1, c2) {
|
|
@@ -48621,8 +48880,8 @@ function _generateInterpolationContourPair(c1, c2) {
|
|
|
48621
48880
|
const numNodes2 = interpNodes + c1.x.length;
|
|
48622
48881
|
const perim1Interp = _getInterpolatedPerim(numNodes1, cumPerim1Norm);
|
|
48623
48882
|
const perim2Interp = _getInterpolatedPerim(numNodes2, cumPerim2Norm);
|
|
48624
|
-
const perim1Ind = _getIndicatorArray(
|
|
48625
|
-
const perim2Ind = _getIndicatorArray(
|
|
48883
|
+
const perim1Ind = _getIndicatorArray(numNodes1 - 2, c1.x.length);
|
|
48884
|
+
const perim2Ind = _getIndicatorArray(numNodes2 - 2, c2.x.length);
|
|
48626
48885
|
const nodesPerSegment1 = _getNodesPerSegment(perim1Interp, perim1Ind);
|
|
48627
48886
|
const nodesPerSegment2 = _getNodesPerSegment(perim2Interp, perim2Ind);
|
|
48628
48887
|
const c1i = _getSuperSampledContour(c1, nodesPerSegment1);
|
|
@@ -48741,14 +49000,10 @@ function _getNodesPerSegment(perimInterp, perimInd) {
|
|
|
48741
49000
|
}
|
|
48742
49001
|
return nodesPerSegment;
|
|
48743
49002
|
}
|
|
48744
|
-
function _getIndicatorArray(
|
|
48745
|
-
const perimInd =
|
|
48746
|
-
|
|
48747
|
-
|
|
48748
|
-
}
|
|
48749
|
-
for (let i = 0; i < contour.x.length; i++) {
|
|
48750
|
-
perimInd.push(true);
|
|
48751
|
-
}
|
|
49003
|
+
function _getIndicatorArray(numFalse, numTrue) {
|
|
49004
|
+
const perimInd = new Array(numFalse + numTrue);
|
|
49005
|
+
perimInd.fill(false, 0, numFalse);
|
|
49006
|
+
perimInd.fill(true, numFalse, numFalse + numTrue);
|
|
48752
49007
|
return perimInd;
|
|
48753
49008
|
}
|
|
48754
49009
|
function _getInterpolatedPerim(numNodes, cumPerimNorm) {
|
|
@@ -48855,6 +49110,7 @@ function deleteRelatedAnnotations(viewportData) {
|
|
|
48855
49110
|
const {
|
|
48856
49111
|
uuidv4
|
|
48857
49112
|
} = utilities;
|
|
49113
|
+
const ChangeTypesForInterpolation = [ChangeTypes$1.HandlesUpdated, ChangeTypes$1.InterpolationUpdated];
|
|
48858
49114
|
class InterpolationManager {
|
|
48859
49115
|
static {
|
|
48860
49116
|
this.toolNames = [];
|
|
@@ -48868,7 +49124,8 @@ class InterpolationManager {
|
|
|
48868
49124
|
const {
|
|
48869
49125
|
toolNames,
|
|
48870
49126
|
segmentationId,
|
|
48871
|
-
segmentIndex
|
|
49127
|
+
segmentIndex,
|
|
49128
|
+
sliceIndex
|
|
48872
49129
|
} = selector;
|
|
48873
49130
|
for (const toolName of toolNames || InterpolationManager.toolNames) {
|
|
48874
49131
|
const annotations = getAnnotations(toolName, annotationGroupSelector);
|
|
@@ -48878,7 +49135,8 @@ class InterpolationManager {
|
|
|
48878
49135
|
for (const annotation of annotations) {
|
|
48879
49136
|
const {
|
|
48880
49137
|
data,
|
|
48881
|
-
autoGenerated
|
|
49138
|
+
autoGenerated,
|
|
49139
|
+
metadata
|
|
48882
49140
|
} = annotation;
|
|
48883
49141
|
if (!autoGenerated) {
|
|
48884
49142
|
continue;
|
|
@@ -48886,6 +49144,9 @@ class InterpolationManager {
|
|
|
48886
49144
|
if (segmentIndex && segmentIndex !== data.segmentation.segmentIndex) {
|
|
48887
49145
|
continue;
|
|
48888
49146
|
}
|
|
49147
|
+
if (sliceIndex !== undefined && metadata && sliceIndex !== metadata.referencedSliceIndex) {
|
|
49148
|
+
continue;
|
|
49149
|
+
}
|
|
48889
49150
|
if (segmentationId && segmentationId !== data.segmentation.segmentationId) {
|
|
48890
49151
|
continue;
|
|
48891
49152
|
}
|
|
@@ -48958,7 +49219,7 @@ class InterpolationManager {
|
|
|
48958
49219
|
const {
|
|
48959
49220
|
toolName
|
|
48960
49221
|
} = annotation.metadata;
|
|
48961
|
-
if (!this.toolNames.includes(toolName) || changeType
|
|
49222
|
+
if (!this.toolNames.includes(toolName) || !ChangeTypesForInterpolation.includes(changeType)) {
|
|
48962
49223
|
return;
|
|
48963
49224
|
}
|
|
48964
49225
|
const viewport = getViewportForAnnotation(annotation);
|
|
@@ -48972,7 +49233,8 @@ class InterpolationManager {
|
|
|
48972
49233
|
viewport,
|
|
48973
49234
|
sliceData,
|
|
48974
49235
|
annotation,
|
|
48975
|
-
interpolationUID: annotation.interpolationUID
|
|
49236
|
+
interpolationUID: annotation.interpolationUID,
|
|
49237
|
+
isInterpolationUpdate: changeType === ChangeTypes$1.InterpolationUpdated
|
|
48976
49238
|
};
|
|
48977
49239
|
interpolate(viewportData);
|
|
48978
49240
|
};
|