@cornerstonejs/tools 1.49.2 → 1.50.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/cjs/tools/annotation/LivewireContourTool.d.ts +5 -0
- package/dist/cjs/tools/annotation/LivewireContourTool.js +133 -44
- package/dist/cjs/tools/annotation/LivewireContourTool.js.map +1 -1
- package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +1 -1
- package/dist/cjs/utilities/contours/findHandlePolylineIndex.d.ts +2 -0
- package/dist/cjs/utilities/contours/findHandlePolylineIndex.js +35 -0
- package/dist/cjs/utilities/contours/findHandlePolylineIndex.js.map +1 -0
- package/dist/cjs/utilities/contours/index.d.ts +2 -1
- package/dist/cjs/utilities/contours/index.js +3 -1
- package/dist/cjs/utilities/contours/index.js.map +1 -1
- package/dist/cjs/utilities/contours/interpolation/interpolate.js +1 -1
- package/dist/cjs/utilities/contours/interpolation/interpolate.js.map +1 -1
- package/dist/cjs/utilities/contours/reverseIfAntiClockwise.d.ts +1 -1
- package/dist/cjs/utilities/contours/reverseIfAntiClockwise.js +5 -5
- package/dist/cjs/utilities/contours/reverseIfAntiClockwise.js.map +1 -1
- package/dist/cjs/utilities/livewire/LiveWirePath.d.ts +3 -0
- package/dist/cjs/utilities/livewire/LiveWirePath.js +12 -0
- package/dist/cjs/utilities/livewire/LiveWirePath.js.map +1 -1
- package/dist/cjs/utilities/livewire/LivewireScissors.d.ts +2 -1
- package/dist/cjs/utilities/livewire/LivewireScissors.js +26 -7
- package/dist/cjs/utilities/livewire/LivewireScissors.js.map +1 -1
- package/dist/cjs/utilities/segmentation/InterpolationManager/InterpolationManager.js +1 -0
- package/dist/cjs/utilities/segmentation/InterpolationManager/InterpolationManager.js.map +1 -1
- package/dist/esm/tools/annotation/LivewireContourTool.js +131 -44
- package/dist/esm/tools/annotation/LivewireContourTool.js.map +1 -1
- package/dist/esm/utilities/contours/findHandlePolylineIndex.js +32 -0
- package/dist/esm/utilities/contours/findHandlePolylineIndex.js.map +1 -0
- package/dist/esm/utilities/contours/index.js +2 -1
- package/dist/esm/utilities/contours/index.js.map +1 -1
- package/dist/esm/utilities/contours/interpolation/interpolate.js +1 -1
- package/dist/esm/utilities/contours/interpolation/interpolate.js.map +1 -1
- package/dist/esm/utilities/contours/reverseIfAntiClockwise.js +5 -5
- package/dist/esm/utilities/contours/reverseIfAntiClockwise.js.map +1 -1
- package/dist/esm/utilities/livewire/LiveWirePath.js +12 -0
- package/dist/esm/utilities/livewire/LiveWirePath.js.map +1 -1
- package/dist/esm/utilities/livewire/LivewireScissors.js +26 -7
- package/dist/esm/utilities/livewire/LivewireScissors.js.map +1 -1
- package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js +1 -0
- package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js.map +1 -1
- package/dist/types/tools/annotation/LivewireContourTool.d.ts +5 -0
- package/dist/types/tools/annotation/LivewireContourTool.d.ts.map +1 -1
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts +1 -1
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts.map +1 -1
- package/dist/types/utilities/contours/findHandlePolylineIndex.d.ts +3 -0
- package/dist/types/utilities/contours/findHandlePolylineIndex.d.ts.map +1 -0
- package/dist/types/utilities/contours/index.d.ts +2 -1
- package/dist/types/utilities/contours/index.d.ts.map +1 -1
- package/dist/types/utilities/contours/interpolation/interpolate.d.ts.map +1 -1
- package/dist/types/utilities/contours/reverseIfAntiClockwise.d.ts +1 -1
- package/dist/types/utilities/contours/reverseIfAntiClockwise.d.ts.map +1 -1
- package/dist/types/utilities/livewire/LiveWirePath.d.ts +3 -0
- package/dist/types/utilities/livewire/LiveWirePath.d.ts.map +1 -1
- package/dist/types/utilities/livewire/LivewireScissors.d.ts +2 -1
- package/dist/types/utilities/livewire/LivewireScissors.d.ts.map +1 -1
- package/dist/types/utilities/segmentation/InterpolationManager/InterpolationManager.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/tools/annotation/EllipticalROITool.ts +1 -1
- package/src/tools/annotation/LivewireContourTool.ts +220 -71
- package/src/types/ToolSpecificAnnotationTypes.ts +2 -0
- package/src/utilities/contours/findHandlePolylineIndex.ts +52 -0
- package/src/utilities/contours/index.ts +2 -0
- package/src/utilities/contours/interpolation/interpolate.ts +3 -2
- package/src/utilities/contours/reverseIfAntiClockwise.ts +11 -13
- package/src/utilities/livewire/LiveWirePath.ts +24 -0
- package/src/utilities/livewire/LivewireScissors.ts +52 -8
- package/src/utilities/segmentation/InterpolationManager/InterpolationManager.ts +1 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Types, utilities } from '@cornerstonejs/core';
|
|
2
|
+
|
|
2
3
|
import { BucketQueue } from '../BucketQueue';
|
|
3
4
|
|
|
5
|
+
const { isEqual } = utilities;
|
|
4
6
|
const MAX_UINT32 = 4294967295;
|
|
5
7
|
const TWO_THIRD_PI = 2 / (3 * Math.PI);
|
|
6
8
|
|
|
@@ -102,6 +104,48 @@ export class LivewireScissors {
|
|
|
102
104
|
this.priorityQueueNew.push(startPointIndex);
|
|
103
105
|
}
|
|
104
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Returns a smoothing path count for how many items to remove.
|
|
109
|
+
* This will remove points, up to count which have a high gradient, up to
|
|
110
|
+
* count of them where the clip value is larger than that provided.
|
|
111
|
+
*
|
|
112
|
+
* @returns Count of items to remove from the path.
|
|
113
|
+
*/
|
|
114
|
+
public smoothPathCount(
|
|
115
|
+
pathPoints: Types.Point2[],
|
|
116
|
+
lastPoint: Types.Point2,
|
|
117
|
+
count = 5,
|
|
118
|
+
clipValue = 0.85
|
|
119
|
+
) {
|
|
120
|
+
const lastIndex =
|
|
121
|
+
(lastPoint &&
|
|
122
|
+
pathPoints.findIndex((point) => isEqual(point, lastPoint))) ||
|
|
123
|
+
-1;
|
|
124
|
+
if (pathPoints.length - lastIndex < count * 2) {
|
|
125
|
+
// If a nearby point is clicked, just add it anyways, because that means
|
|
126
|
+
// the user actually wants the given point
|
|
127
|
+
return 0;
|
|
128
|
+
}
|
|
129
|
+
let removeCount = 0;
|
|
130
|
+
for (
|
|
131
|
+
let i = pathPoints.length - 1;
|
|
132
|
+
i > pathPoints.length - count && i > 0;
|
|
133
|
+
i--
|
|
134
|
+
) {
|
|
135
|
+
const weighted = this._getWeightedDistance(
|
|
136
|
+
pathPoints[i],
|
|
137
|
+
pathPoints[i - 1]
|
|
138
|
+
);
|
|
139
|
+
if (weighted < clipValue) {
|
|
140
|
+
return removeCount ? removeCount + 2 : 0;
|
|
141
|
+
}
|
|
142
|
+
removeCount++;
|
|
143
|
+
}
|
|
144
|
+
// Tried all of them, they were all too big, so assume they are really moving
|
|
145
|
+
// along a high gradient.
|
|
146
|
+
return 0;
|
|
147
|
+
}
|
|
148
|
+
|
|
105
149
|
/**
|
|
106
150
|
* Runs Dijsktra until it finds a path from the start point to the target
|
|
107
151
|
* point. Once it reaches the target point all the state is preserved in order
|
|
@@ -156,20 +200,20 @@ export class LivewireScissors {
|
|
|
156
200
|
// Update the cost of all neighbors that have higher costs
|
|
157
201
|
for (let i = 0, len = neighborsPoints.length; i < len; i++) {
|
|
158
202
|
const neighborPoint = neighborsPoints[i];
|
|
159
|
-
const
|
|
203
|
+
const neighborPointIndex = index(neighborPoint[1], neighborPoint[0]);
|
|
160
204
|
const dist = this._getWeightedDistance(point, neighborPoint);
|
|
161
205
|
const neighborCost = cost[pointIndex] + dist;
|
|
162
206
|
|
|
163
|
-
if (neighborCost < cost[
|
|
164
|
-
if (cost[
|
|
207
|
+
if (neighborCost < cost[neighborPointIndex]) {
|
|
208
|
+
if (cost[neighborPointIndex] !== Infinity) {
|
|
165
209
|
// The item needs to be removed from the priority queue and
|
|
166
210
|
// re-added in order to be moved to the right bucket.
|
|
167
|
-
priorityQueue.remove(
|
|
211
|
+
priorityQueue.remove(neighborPointIndex);
|
|
168
212
|
}
|
|
169
213
|
|
|
170
|
-
cost[
|
|
171
|
-
parents[
|
|
172
|
-
priorityQueue.push(
|
|
214
|
+
cost[neighborPointIndex] = neighborCost;
|
|
215
|
+
parents[neighborPointIndex] = pointIndex;
|
|
216
|
+
priorityQueue.push(neighborPointIndex);
|
|
173
217
|
}
|
|
174
218
|
}
|
|
175
219
|
}
|