@cornerstonejs/tools 4.15.10 → 4.15.11

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.
@@ -45,7 +45,7 @@ class LivewireContourSegmentationTool extends LivewireContourTool {
45
45
  });
46
46
  }
47
47
  const acceptedPath = new LivewirePath();
48
- for (let i = 0; i < count; i++) {
48
+ for (let i = 0; i < count - 1; i++) {
49
49
  scissors.startSearch(worldToSlice(points[i]));
50
50
  const path = scissors.findPathToPoint(worldToSlice(points[(i + 1) % count]));
51
51
  acceptedPath.addPoints(path);
@@ -76,8 +76,6 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
76
76
  viewportIdsToRender,
77
77
  movingTextBox: false,
78
78
  };
79
- const enabledElement = getEnabledElement(element);
80
- const { renderingEngine } = enabledElement;
81
79
  this._activateModify(element);
82
80
  triggerAnnotationRenderForViewportIds(viewportIdsToRender);
83
81
  evt.preventDefault();
@@ -104,8 +102,6 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
104
102
  movingTextBox,
105
103
  };
106
104
  this._activateModify(element);
107
- const enabledElement = getEnabledElement(element);
108
- const { renderingEngine } = enabledElement;
109
105
  triggerAnnotationRenderForViewportIds(viewportIdsToRender);
110
106
  evt.preventDefault();
111
107
  };
@@ -154,7 +150,7 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
154
150
  const { canvas: canvasPos, world: worldPosOriginal } = currentPoints;
155
151
  let worldPos = worldPosOriginal;
156
152
  const enabledElement = getEnabledElement(element);
157
- const { viewport, renderingEngine } = enabledElement;
153
+ const { viewport } = enabledElement;
158
154
  const controlPoints = this.editData.currentPath.getControlPoints();
159
155
  let closePath = controlPoints.length >= 2 && doubleClick;
160
156
  this.doneEditMemo();
@@ -200,6 +196,9 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
200
196
  annotation.invalidated = true;
201
197
  triggerAnnotationRenderForViewportIds(viewportIdsToRender);
202
198
  if (this.editData.closed) {
199
+ if (closePath) {
200
+ annotation.data.isOpenUShapeContour = 'lineSegment';
201
+ }
203
202
  this.updateAnnotation(this.editData.confirmedPath);
204
203
  this._endCallback(evt);
205
204
  }
@@ -208,7 +207,6 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
208
207
  this._mouseMoveCallback = (evt) => {
209
208
  const { element, currentPoints } = evt.detail;
210
209
  const { world: worldPos, canvas: canvasPos } = currentPoints;
211
- const { renderingEngine } = getEnabledElement(element);
212
210
  const viewportIdsToRender = getViewportIdsWithToolToRender(element, this.getToolName());
213
211
  this.editData.lastCanvasPoint = canvasPos;
214
212
  const { width: imgWidth, height: imgHeight } = this.scissors;
@@ -254,8 +252,6 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
254
252
  this.editHandle(worldPos, element, annotation, handleIndex);
255
253
  }
256
254
  this.editData.hasMoved = true;
257
- const enabledElement = getEnabledElement(element);
258
- const { renderingEngine } = enabledElement;
259
255
  triggerAnnotationRenderForViewportIds(viewportIdsToRender);
260
256
  };
261
257
  this.cancel = (element) => {
@@ -315,7 +311,7 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
315
311
  return;
316
312
  }
317
313
  const enabledElement = getEnabledElement(element);
318
- const { viewport, renderingEngine } = enabledElement;
314
+ const { viewport } = enabledElement;
319
315
  const { cachedStats } = data;
320
316
  const { polyline: points } = data.contour;
321
317
  const targetIds = Object.keys(cachedStats);
@@ -133,7 +133,7 @@ function completeDrawClosedContour(element, options) {
133
133
  }
134
134
  const { annotation, viewportIdsToRender } = this.commonData;
135
135
  const enabledElement = getEnabledElement(element);
136
- const { viewport, renderingEngine } = enabledElement;
136
+ const { viewport } = enabledElement;
137
137
  addCanvasPointsToArray(element, canvasPoints, canvasPoints[0], this.commonData);
138
138
  canvasPoints.pop();
139
139
  const updatedPoints = shouldSmooth(this.configuration, annotation)
@@ -179,7 +179,7 @@ function completeDrawOpenContour(element, options) {
179
179
  }
180
180
  const { annotation, viewportIdsToRender } = this.commonData;
181
181
  const enabledElement = getEnabledElement(element);
182
- const { viewport, renderingEngine } = enabledElement;
182
+ const { viewport } = enabledElement;
183
183
  const updatedPoints = shouldSmooth(this.configuration, annotation)
184
184
  ? getInterpolatedPoints(this.configuration, canvasPoints)
185
185
  : canvasPoints;
@@ -193,7 +193,8 @@ function completeDrawOpenContour(element, options) {
193
193
  worldPoints[0],
194
194
  worldPoints[worldPoints.length - 1],
195
195
  ];
196
- if (annotation.data.isOpenUShapeContour) {
196
+ if (annotation.data.isOpenUShapeContour === true ||
197
+ annotation.data.isOpenUShapeContour === 'farthestT') {
197
198
  annotation.data.openUShapeContourVectorToPeak =
198
199
  findOpenUShapedContourVectorToPeak(canvasPoints, viewport);
199
200
  }
@@ -261,8 +262,6 @@ function haltDrawing(element, canvasPoints) {
261
262
  const { subPixelResolution } = this.configuration;
262
263
  if (shouldHaltDrawing(canvasPoints, subPixelResolution)) {
263
264
  const { annotation, viewportIdsToRender } = this.commonData;
264
- const enabledElement = getEnabledElement(element);
265
- const { renderingEngine } = enabledElement;
266
265
  removeAnnotation(annotation.annotationUID);
267
266
  this.isDrawing = false;
268
267
  this.drawData = undefined;
@@ -11,6 +11,7 @@ export type AnnotationData = {
11
11
  cachedStats?: Record<string, unknown>;
12
12
  label?: string;
13
13
  contour?: Contour;
14
+ isOpenUShapeContour?: boolean | 'farthestT' | 'lineSegment' | 'orthogonalT';
14
15
  [key: string]: unknown;
15
16
  };
16
17
  export type Annotation = {
@@ -311,7 +311,7 @@ export interface CircleROIStartEndThresholdAnnotation extends Annotation {
311
311
  export type PlanarFreehandROIAnnotation = ContourAnnotation & {
312
312
  data: {
313
313
  label?: string;
314
- isOpenUShapeContour?: boolean;
314
+ isOpenUShapeContour?: boolean | 'lineSegment' | 'orthogonalT';
315
315
  openUShapeContourVectorToPeak?: Types.Point3[];
316
316
  cachedStats?: ROICachedStats;
317
317
  };
@@ -63,6 +63,7 @@ function _linearlyInterpolateBetween(indices, annotationPair, interpolationData,
63
63
  const annotation1 = interpolationData.get(annotationPair[1])[0];
64
64
  const c1 = _generateClosedContour(annotation0.data.contour.polyline);
65
65
  const c2 = _generateClosedContour(annotation1.data.contour.polyline);
66
+ console.warn('annotation0=', annotation0);
66
67
  const { c1Interp, c2Interp } = _generateInterpolationContourPair(c1, c2);
67
68
  c1Interp.kIndex = annotationPair[0];
68
69
  c2Interp.kIndex = annotationPair[1];
@@ -70,15 +71,6 @@ function _linearlyInterpolateBetween(indices, annotationPair, interpolationData,
70
71
  _linearlyInterpolateContour(c1Interp, c2Interp, index, annotationPair, interpolationData, c1.x.length > c2.x.length, eventData);
71
72
  });
72
73
  }
73
- function getPointCount(pointArray) {
74
- let sum = 0;
75
- for (let i = 0; i < pointArray.I.length; i++) {
76
- if (pointArray.I[i]) {
77
- sum++;
78
- }
79
- }
80
- return sum;
81
- }
82
74
  function _linearlyInterpolateContour(c1Interp, c2Interp, sliceIndex, annotationPair, interpolationData, c1HasMoreNodes, eventData) {
83
75
  const [startIndex, endIndex] = annotationPair;
84
76
  const zInterp = (sliceIndex - startIndex) / (endIndex - startIndex);
@@ -86,7 +78,10 @@ function _linearlyInterpolateContour(c1Interp, c2Interp, sliceIndex, annotationP
86
78
  const annotation1 = interpolationData.get(endIndex)[0];
87
79
  const interpolated3DPoints = _generateInterpolatedOpenContour(c1Interp, c2Interp, zInterp, c1HasMoreNodes);
88
80
  const nearestAnnotation = zInterp > 0.5 ? annotation1 : annotation0;
89
- const handlePoints = selectHandles(interpolated3DPoints);
81
+ const isOpenUShapeContour = nearestAnnotation.data.isOpenUShapeContour;
82
+ const handlePoints = selectHandles(interpolated3DPoints, {
83
+ isOpenUShapeContour,
84
+ });
90
85
  if (interpolationData.has(sliceIndex)) {
91
86
  _editInterpolatedContour(interpolated3DPoints, handlePoints, sliceIndex, nearestAnnotation, eventData);
92
87
  }
@@ -1,4 +1,8 @@
1
1
  import type { PointsArray3 } from './interpolate';
2
- export default function selectHandles(polyline: PointsArray3, handleCount?: number): PointsArray3;
2
+ export interface SelectHandlesOptions {
3
+ handleCount?: number;
4
+ isOpenUShapeContour?: boolean;
5
+ }
6
+ export default function selectHandles(polyline: PointsArray3, options?: SelectHandlesOptions): PointsArray3;
3
7
  export declare function createDotValues(polyline: PointsArray3, distance?: number): Float32Array;
4
8
  export declare function addInterval(indices: any, start: any, finish: any, interval: any, length: any): any;
@@ -1,12 +1,18 @@
1
1
  import { vec3 } from 'gl-matrix';
2
2
  import { utilities } from '@cornerstonejs/core';
3
3
  const { PointsManager } = utilities;
4
- export default function selectHandles(polyline, handleCount = 12) {
4
+ export default function selectHandles(polyline, options = {}) {
5
+ const { handleCount = 12, isOpenUShapeContour } = options;
5
6
  const handles = PointsManager.create3(handleCount);
6
7
  handles.sources = [];
7
8
  const { sources: destPoints } = handles;
8
9
  const { length, sources: sourcePoints = [] } = polyline;
9
10
  const distance = 5;
11
+ if (isOpenUShapeContour) {
12
+ const handles = polyline.subselect(handleCount);
13
+ handles.push(polyline.getPoint(polyline.length - 1));
14
+ return handles;
15
+ }
10
16
  if (length < distance * 3) {
11
17
  return polyline.subselect(handleCount);
12
18
  }
@@ -1 +1 @@
1
- export declare const version = "4.15.10";
1
+ export declare const version = "4.15.11";
@@ -1 +1 @@
1
- export const version = '4.15.10';
1
+ export const version = '4.15.11';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "4.15.10",
3
+ "version": "4.15.11",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -108,7 +108,7 @@
108
108
  "canvas": "3.2.0"
109
109
  },
110
110
  "peerDependencies": {
111
- "@cornerstonejs/core": "4.15.10",
111
+ "@cornerstonejs/core": "4.15.11",
112
112
  "@kitware/vtk.js": "34.15.1",
113
113
  "@types/d3-array": "3.2.1",
114
114
  "@types/d3-interpolate": "3.0.4",
@@ -127,5 +127,5 @@
127
127
  "type": "individual",
128
128
  "url": "https://ohif.org/donate"
129
129
  },
130
- "gitHead": "e86eb206088373c38b7a6d0e9c91bf39250e1eea"
130
+ "gitHead": "6b73b3890a2f0501ab1dfb2db1aef1206224560c"
131
131
  }