@kitware/vtk.js 29.3.1 → 29.4.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/CONTRIBUTING.md +1 -1
- package/Imaging/Core/AbstractImageInterpolator/Constants.d.ts +18 -0
- package/Imaging/Core/ImageReslice/Constants.d.ts +12 -0
- package/Imaging/Core/ImageReslice.d.ts +616 -0
- package/Imaging/Core/ImageReslice.js +8 -9
- package/Rendering/Core/Follower.js +1 -1
- package/Widgets/Manipulators/LineManipulator.js +6 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/Constants.d.ts +62 -0
- package/Widgets/Widgets3D/ResliceCursorWidget.d.ts +8 -0
- package/Widgets/Widgets3D/ResliceCursorWidget.js +12 -2
- package/index.d.ts +4 -0
- package/package.json +1 -1
package/CONTRIBUTING.md
CHANGED
|
@@ -121,7 +121,7 @@ The vtk.js documentation is part of the code repository and is entirely written
|
|
|
121
121
|
|
|
122
122
|
If you create an example, please list it in the [examples landing page](Documentation/content/examples/index.md).
|
|
123
123
|
|
|
124
|
-
Images and GIF videos added to the [gallery](Documentation/content/docs/gallery) must be compressed as much as possible. You may want to use [ezgif.com](https://ezgif.com/).
|
|
124
|
+
Images and GIF videos added to the [gallery](Documentation/content/docs/gallery) must be compressed as much as possible (e.g. 432px by 300px with 50% JPEG compression). You may want to use [ezgif.com](https://ezgif.com/).
|
|
125
125
|
|
|
126
126
|
## Reporting Issues
|
|
127
127
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare enum ImageBorderMode {
|
|
2
|
+
CLAMP = 0,
|
|
3
|
+
REPEAT = 1,
|
|
4
|
+
MIRROR = 2,
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export declare enum InterpolationMode {
|
|
8
|
+
NEAREST = 0,
|
|
9
|
+
LINEAR = 1,
|
|
10
|
+
CUBIC = 2,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare const _default: {
|
|
14
|
+
ImageBorderMode: typeof ImageBorderMode;
|
|
15
|
+
InterpolationMode: typeof InterpolationMode;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,616 @@
|
|
|
1
|
+
import { Bounds, Extent, Nullable, RGBAColor, TypedArray } from './../../types';
|
|
2
|
+
import { InterpolationMode } from './AbstractImageInterpolator/Constants';
|
|
3
|
+
import { SlabMode } from './ImageReslice/Constants';
|
|
4
|
+
import { vtkAlgorithm, vtkObject, vtkRange } from './../../interfaces';
|
|
5
|
+
import vtkImageData from './../../Common/DataModel/ImageData';
|
|
6
|
+
import vtkTransform from './../../Common/Transform/Transform';
|
|
7
|
+
|
|
8
|
+
import { mat3, mat4, vec3, vec4 } from 'gl-matrix';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
export interface IImageResliceInitialValues {
|
|
14
|
+
transformInputSampling: boolean,
|
|
15
|
+
autoCropOutput: boolean,
|
|
16
|
+
outputDimensionality: number,
|
|
17
|
+
outputSpacing: Nullable<vec3>, // automatically computed if null
|
|
18
|
+
outputOrigin: Nullable<vec3>, // automatically computed if null
|
|
19
|
+
outputDirection: Nullable<mat3>, // identity if null
|
|
20
|
+
outputExtent: Nullable<Extent>, // automatically computed if null
|
|
21
|
+
outputScalarType: Nullable<string>,
|
|
22
|
+
wrap: boolean, // don't wrap
|
|
23
|
+
mirror: boolean, // don't mirror
|
|
24
|
+
border: boolean, // apply a border
|
|
25
|
+
interpolationMode: InterpolationMode, // only NEAREST supported so far
|
|
26
|
+
slabMode: SlabMode,
|
|
27
|
+
slabTrapezoidIntegration: boolean,
|
|
28
|
+
slabNumberOfSlices: number,
|
|
29
|
+
slabSliceSpacingFraction: number,
|
|
30
|
+
optimization: boolean, // not supported yet
|
|
31
|
+
scalarShift: number, // for rescaling the data
|
|
32
|
+
scalarScale: number,
|
|
33
|
+
backgroundColor: RGBAColor,
|
|
34
|
+
resliceAxes: Nullable<mat4>,
|
|
35
|
+
resliceTransform?: vtkTransform,
|
|
36
|
+
interpolator: any, // A vtkImageInterpolator (missing typescript header)
|
|
37
|
+
usePermuteExecute: boolean, // no supported yet
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type vtkImageResliceBase = Omit<vtkObject, 'set'> & vtkAlgorithm;
|
|
41
|
+
|
|
42
|
+
export interface vtkImageReslice extends vtkImageResliceBase {
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @param inData
|
|
46
|
+
* @param outData
|
|
47
|
+
*/
|
|
48
|
+
requestData(inData: any, outData: any): void;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Main filter logic
|
|
52
|
+
* @param input
|
|
53
|
+
* @param output
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
56
|
+
vtkImageResliceExecute: (input: vtkImageData, output: vtkImageData) => void;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The transform matrix supplied by the user converts output coordinates
|
|
60
|
+
* to input coordinates.
|
|
61
|
+
* To speed up the pixel lookup, the following function provides a
|
|
62
|
+
* matrix which converts output pixel indices to input pixel indices.
|
|
63
|
+
* This will also concatenate the ResliceAxes and the ResliceTransform
|
|
64
|
+
* if possible (if the ResliceTransform is a 4x4 matrix transform).
|
|
65
|
+
* If it does, this->OptimizedTransform will be set to nullptr, otherwise
|
|
66
|
+
* this->OptimizedTransform will be equal to this->ResliceTransform.
|
|
67
|
+
* @param {vtkImageData} input
|
|
68
|
+
* @param {vtkImageData} output
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
getIndexMatrix: (input: vtkImageData, output: vtkImageData) => mat4;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Compute the bounds required to ensure that none of the data will be cropped
|
|
75
|
+
* @param input
|
|
76
|
+
* @returns
|
|
77
|
+
*/
|
|
78
|
+
getAutoCroppedOutputBounds: (input: vtkImageData) => Bounds;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The min and max of each data type
|
|
82
|
+
* Defaults to a range of 0 to 255
|
|
83
|
+
* @param dataType
|
|
84
|
+
* @returns
|
|
85
|
+
*/
|
|
86
|
+
getDataTypeMinMax: (dataType: string) => vtkRange;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Internal function uses vtkInterpolationMathClamp on `numscalars * n` elements
|
|
90
|
+
* @param outPtr
|
|
91
|
+
* @param inPtr
|
|
92
|
+
* @param numscalars
|
|
93
|
+
* @param n
|
|
94
|
+
* @param min
|
|
95
|
+
* @param max
|
|
96
|
+
* @returns The number of elements processed
|
|
97
|
+
*/
|
|
98
|
+
clamp: (outPtr: TypedArray, inPtr: TypedArray, numscalars: number, n: number, min: number, max: number) => number;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Internal function uses Math.round on `numscalars * n` elements
|
|
102
|
+
* @param outPtr
|
|
103
|
+
* @param inPtr
|
|
104
|
+
* @param numscalars
|
|
105
|
+
* @param n
|
|
106
|
+
* @returns The number of elements processed
|
|
107
|
+
*/
|
|
108
|
+
convert: (outPtr: TypedArray, inPtr: TypedArray, numscalars: number, n: number) => number;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Setup the conversion function and return the right one
|
|
112
|
+
* @param inputType
|
|
113
|
+
* @param dataType
|
|
114
|
+
* @param scalarShift
|
|
115
|
+
* @param scalarScale
|
|
116
|
+
* @param forceClamping
|
|
117
|
+
* @returns publicAPI.convert or publicAPI.clamp
|
|
118
|
+
*/
|
|
119
|
+
getConversionFunc: (inputType: string, dataType: string, scalarShift: number, scalarScale: number, forceClamping: boolean) => (this["convert"] & this["clamp"]);
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Copy the `numscalars * n` first elements from an array to another
|
|
123
|
+
* @param outPtr
|
|
124
|
+
* @param inPtr
|
|
125
|
+
* @param numscalars
|
|
126
|
+
* @param n
|
|
127
|
+
* @returns The number of copied elements
|
|
128
|
+
*/
|
|
129
|
+
set: (outPtr: TypedArray, inPtr: TypedArray, numscalars: number, n: number) => number;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Fill the `n` first elements of the output array with the very first element of the input array
|
|
133
|
+
* @param outPtr
|
|
134
|
+
* @param inPtr
|
|
135
|
+
* @param numscalars
|
|
136
|
+
* @param n
|
|
137
|
+
* @returns The number of elements set in the output array
|
|
138
|
+
*/
|
|
139
|
+
set1: (outPtr: TypedArray, inPtr: TypedArray, numscalars: number, n: number) => number;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Returns the right function used to copy the pixels
|
|
143
|
+
* @param dataType
|
|
144
|
+
* @param dataSize
|
|
145
|
+
* @param numscalars
|
|
146
|
+
* @param dataPtr
|
|
147
|
+
* @returns publicAPI.set or publicAPI.set1
|
|
148
|
+
*/
|
|
149
|
+
getSetPixelsFunc: (dataType: any, dataSize: any, numscalars: number, dataPtr: any) => (this["set"] & this["set1"]);
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Returns the right composition function
|
|
153
|
+
* @param slabMode
|
|
154
|
+
* @param slabTrapezoidIntegration
|
|
155
|
+
* @returns
|
|
156
|
+
*/
|
|
157
|
+
getCompositeFunc: (slabMode: SlabMode, slabTrapezoidIntegration: boolean) => ((tmpPtr: TypedArray, inComponents: number, sampleCount: number) => void);
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Apply `newTrans`, then translate by `-origin`, then scale by `inInvSpacing`
|
|
161
|
+
* @param newTrans
|
|
162
|
+
* @param inPoint
|
|
163
|
+
* @param inOrigin
|
|
164
|
+
* @param inInvSpacing
|
|
165
|
+
* @returns
|
|
166
|
+
*/
|
|
167
|
+
applyTransform: (newTrans: mat4, inPoint: vec4, inOrigin: vec3, inInvSpacing: vec3) => void;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
*
|
|
171
|
+
* @param floatData
|
|
172
|
+
* @param components
|
|
173
|
+
* @param n
|
|
174
|
+
* @param scalarShift
|
|
175
|
+
* @param scalarScale
|
|
176
|
+
* @returns
|
|
177
|
+
*/
|
|
178
|
+
rescaleScalars: (floatData: TypedArray, components: number, n: number, scalarShift: number, scalarScale: number) => void;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* A permutation matrix is the identity matrix with the colomn (or rows) shuffled
|
|
182
|
+
* @param matrix
|
|
183
|
+
* @returns
|
|
184
|
+
*/
|
|
185
|
+
isPermutationMatrix: (matrix: mat4) => boolean;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
*
|
|
189
|
+
* @param matrix
|
|
190
|
+
* @returns
|
|
191
|
+
*/
|
|
192
|
+
isIdentityMatrix: (matrix: mat4) => boolean;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
*
|
|
196
|
+
* @param matrix
|
|
197
|
+
* @returns
|
|
198
|
+
*/
|
|
199
|
+
isPerspectiveMatrix: (matrix: mat4) => boolean;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
*
|
|
203
|
+
* @param matrix
|
|
204
|
+
* @param outExt
|
|
205
|
+
* @returns
|
|
206
|
+
*/
|
|
207
|
+
canUseNearestNeighbor: (matrix: mat4, outExt: Extent) => boolean;
|
|
208
|
+
|
|
209
|
+
// Setters and getters
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Set the slab mode, for generating thick slices.
|
|
213
|
+
* The default is SlabMode.MIN. If SetSlabNumberOfSlices(N) is called with N
|
|
214
|
+
* greater than one, then each output slice will actually be a composite of N
|
|
215
|
+
* slices. This method specifies the compositing mode to be used.
|
|
216
|
+
* @param slabMode
|
|
217
|
+
* @returns
|
|
218
|
+
*/
|
|
219
|
+
setSlabMode: (slabMode: SlabMode) => boolean;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* @see setSlabMode
|
|
223
|
+
* @returns
|
|
224
|
+
*/
|
|
225
|
+
getSlabMode: () => SlabMode;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Set the number of slices that will be combined to create the slab.
|
|
229
|
+
* Defaults to 1.
|
|
230
|
+
* @param numberOfSlices
|
|
231
|
+
* @returns
|
|
232
|
+
*/
|
|
233
|
+
setSlabNumberOfSlices: (slabNumberOfSlices: number) => boolean;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* @see setSlabNumberOfSlices
|
|
237
|
+
* @returns
|
|
238
|
+
*/
|
|
239
|
+
getSlabNumberOfSlices: () => number;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Specify whether to transform the spacing, origin and extent of the Input
|
|
243
|
+
* (or the InformationInput) according to the direction cosines and origin of
|
|
244
|
+
* the ResliceAxes before applying them as the default output spacing, origin
|
|
245
|
+
* and extent.
|
|
246
|
+
* Defaults to false.
|
|
247
|
+
* @param transformInputSampling
|
|
248
|
+
* @returns
|
|
249
|
+
*/
|
|
250
|
+
setTransformInputSampling: (transformInputSampling: boolean) => boolean;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* @see setTransformInputSampling
|
|
254
|
+
* @returns
|
|
255
|
+
*/
|
|
256
|
+
getTransformInputSampling: () => boolean;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Turn this on if you want to guarantee that the extent of the output will
|
|
260
|
+
* be large enough to ensure that none of the data will be cropped.
|
|
261
|
+
* Defaults to false.
|
|
262
|
+
* @param autoCropOutput
|
|
263
|
+
* @returns
|
|
264
|
+
*/
|
|
265
|
+
setAutoCropOutput: (autoCropOutput: boolean) => boolean;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* @see setAutoCropOutput
|
|
269
|
+
* @returns
|
|
270
|
+
*/
|
|
271
|
+
getAutoCropOutput: () => boolean;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Force the dimensionality of the output to either 1, 2, 3 or 0.
|
|
275
|
+
* If the dimensionality is 2D, then the Z extent of the output is forced to
|
|
276
|
+
* (0,0) and the Z origin of the output is forced to 0.0 (i.e. the output
|
|
277
|
+
* extent is confined to the xy plane). If the dimensionality is 1D, the
|
|
278
|
+
* output extent is confined to the x axis. For 0D, the output extent
|
|
279
|
+
* consists of a single voxel at (0,0,0).
|
|
280
|
+
* Defaults to 3.
|
|
281
|
+
* @param outputDimensionality
|
|
282
|
+
* @returns
|
|
283
|
+
*/
|
|
284
|
+
setOutputDimensionality: (outputDimensionality: number) => boolean;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* @see setOutputDimensionality
|
|
288
|
+
* @returns
|
|
289
|
+
*/
|
|
290
|
+
getOutputDimensionality: () => number;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Set the voxel spacing for the output data.
|
|
294
|
+
* The default output spacing is the input spacing permuted through the
|
|
295
|
+
* ResliceAxes.
|
|
296
|
+
* Defaults to null (automatically computed).
|
|
297
|
+
* @param outputSpacing
|
|
298
|
+
* @returns
|
|
299
|
+
*/
|
|
300
|
+
setOutputSpacing: (outputSpacing: vec3 | null) => boolean;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* @see setOutputSpacing
|
|
304
|
+
* @returns
|
|
305
|
+
*/
|
|
306
|
+
getOutputSpacing: () => vec3 | null;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Set the origin for the output data.
|
|
310
|
+
* The default output origin is the input origin permuted through the
|
|
311
|
+
* ResliceAxes.
|
|
312
|
+
* Defaults to null (automatically computed).
|
|
313
|
+
* @param outputOrigin
|
|
314
|
+
* @returns
|
|
315
|
+
*/
|
|
316
|
+
setOutputOrigin: (outputOrigin: vec3 | null) => boolean;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @see setOutputOrigin
|
|
320
|
+
* @returns
|
|
321
|
+
*/
|
|
322
|
+
getOutputOrigin: () => vec3 | null;
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Set the extent for the output data.
|
|
326
|
+
* The default output extent is the input extent permuted through the
|
|
327
|
+
* ResliceAxes.
|
|
328
|
+
* Defaults to null (automatically computed).
|
|
329
|
+
* @param outputExtent
|
|
330
|
+
* @returns
|
|
331
|
+
*/
|
|
332
|
+
setOutputExtent: (outputExtent: Extent | null) => boolean;
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* @see setOutputExtent
|
|
336
|
+
* @returns
|
|
337
|
+
*/
|
|
338
|
+
getOutputExtent: () => Extent | null;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Set the direction for the output data.
|
|
342
|
+
* By default, the direction of the input data is passed to the output.
|
|
343
|
+
* But if SetOutputDirection() is used, then the image will be resliced
|
|
344
|
+
* according to the new output direction. Unlike SetResliceAxes(), this does
|
|
345
|
+
* not change the physical coordinate system for the image. Instead, it
|
|
346
|
+
* changes the orientation of the sampling grid while maintaining the same
|
|
347
|
+
* physical coordinate system.
|
|
348
|
+
* Defaults to null (automatically computed).
|
|
349
|
+
* @param outputDirection
|
|
350
|
+
* @returns
|
|
351
|
+
*/
|
|
352
|
+
setOutputDirection: (outputDirection: mat3 | null) => boolean;
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* @see setOutputDirection
|
|
356
|
+
* @returns
|
|
357
|
+
*/
|
|
358
|
+
getOutputDirection: () => mat3 | null;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Set the background color (for multi-component images).
|
|
362
|
+
* Defaults to full opaque black.
|
|
363
|
+
* @param backgroundColor
|
|
364
|
+
* @returns
|
|
365
|
+
*/
|
|
366
|
+
setBackgroundColor: (backgroundColor: RGBAColor) => boolean;
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* @see setBackgroundColor
|
|
370
|
+
* @returns
|
|
371
|
+
*/
|
|
372
|
+
getBackgroundColor: () => RGBAColor;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* This method is used to set up the axes for the output voxels.
|
|
376
|
+
* The output Spacing, Origin, and Extent specify the locations
|
|
377
|
+
* of the voxels within the coordinate system defined by the axes.
|
|
378
|
+
* The ResliceAxes are used most often to permute the data, e.g.
|
|
379
|
+
* to extract ZY or XZ slices of a volume as 2D XY images.
|
|
380
|
+
* The first column of the matrix specifies the x-axis
|
|
381
|
+
* vector (the fourth element must be set to zero), the second
|
|
382
|
+
* column specifies the y-axis, and the third column the
|
|
383
|
+
* z-axis. The fourth column is the origin of the
|
|
384
|
+
* axes (the fourth element must be set to one).
|
|
385
|
+
* @param resliceAxes
|
|
386
|
+
* @returns
|
|
387
|
+
*/
|
|
388
|
+
setResliceAxes: (resliceAxes: mat4) => boolean;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* @see setResliceAxes
|
|
392
|
+
* @returns
|
|
393
|
+
*/
|
|
394
|
+
getResliceAxes: () => mat4;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Set the scalar type of the output to be different from the input.
|
|
398
|
+
* The default value is null, which means that the input scalar type will be
|
|
399
|
+
* used to set the output scalar type. Otherwise, this must be set to one
|
|
400
|
+
* of the following types: VtkDataTypes.CHAR, VtkDataTypes.SIGNED_CHAR,
|
|
401
|
+
* VtkDataTypes.UNSIGNED_CHAR, VtkDataTypes.SHORT, VtkDataTypes.UNSIGNED_SHORT,
|
|
402
|
+
* VtkDataTypes.INT, VtkDataTypes.UNSIGNED_INT, VtkDataTypes.FLOAT or
|
|
403
|
+
* VtkDataTypes.DOUBLE. Other types are not permitted. If the output type
|
|
404
|
+
* is an integer type, the output will be rounded and clamped to the limits of
|
|
405
|
+
* the type.
|
|
406
|
+
*
|
|
407
|
+
* See the documentation for [vtkDataArray::getDataType()](../api/Common_Core_DataArray.html#getDataType-String) for additional data type settings.
|
|
408
|
+
* Defaults to null (automatically computed).
|
|
409
|
+
* @param outputScalarType
|
|
410
|
+
* @returns
|
|
411
|
+
*/
|
|
412
|
+
setOutputScalarType: (outputScalarType: string | null) => boolean;
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* @see setOutputScalarType
|
|
416
|
+
* @returns
|
|
417
|
+
*/
|
|
418
|
+
getOutputScalarType: () => string | null;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Set a value to add to all the output voxels.
|
|
422
|
+
* After a sample value has been interpolated from the input image, the
|
|
423
|
+
* equation u = (v + ScalarShift)*ScalarScale will be applied to it before
|
|
424
|
+
* it is written to the output image. The result will always be clamped to
|
|
425
|
+
* the limits of the output data type.
|
|
426
|
+
* Defaults to 0.
|
|
427
|
+
* @param scalarShift
|
|
428
|
+
* @returns
|
|
429
|
+
*/
|
|
430
|
+
setScalarShift: (scalarShift: number) => boolean;
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* @see setScalarShift
|
|
434
|
+
* @returns
|
|
435
|
+
*/
|
|
436
|
+
getScalarShift: () => number;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Set multiplication factor to apply to all the output voxels.
|
|
440
|
+
* After a sample value has been interpolated from the input image, the
|
|
441
|
+
* equation u = (v + ScalarShift)*ScalarScale will be applied to it before
|
|
442
|
+
* it is written to the output image. The result will always be clamped to
|
|
443
|
+
* the limits of the output data type.
|
|
444
|
+
* Defaults to 1.
|
|
445
|
+
* @param scalarScale
|
|
446
|
+
* @returns
|
|
447
|
+
*/
|
|
448
|
+
setScalarScale: (scalarScale: number) => boolean;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* @see setScalarScale
|
|
452
|
+
* @returns
|
|
453
|
+
*/
|
|
454
|
+
getScalarScale: () => number;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Turn on wrap-pad feature.
|
|
458
|
+
* Defaults to false.
|
|
459
|
+
* @param wrap
|
|
460
|
+
* @returns
|
|
461
|
+
*/
|
|
462
|
+
setWrap: (wrap: boolean) => boolean;
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* @see setWrap
|
|
466
|
+
* @returns
|
|
467
|
+
*/
|
|
468
|
+
getWrap: () => boolean;
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Turn on mirror-pad feature. This will override the wrap-pad.
|
|
472
|
+
* Defaults to false.
|
|
473
|
+
* @param mirror
|
|
474
|
+
* @returns
|
|
475
|
+
*/
|
|
476
|
+
setMirror: (mirror: boolean) => boolean;
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* @see setMirror
|
|
480
|
+
* @returns
|
|
481
|
+
*/
|
|
482
|
+
getMirror: () => boolean;
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Extend the apparent input border by a half voxel.
|
|
486
|
+
* This changes how interpolation is handled at the borders of the
|
|
487
|
+
* input image: if the center of an output voxel is beyond the edge
|
|
488
|
+
* of the input image, but is within a half voxel width of the edge
|
|
489
|
+
* (using the input voxel width), then the value of the output voxel
|
|
490
|
+
* is calculated as if the input's edge voxels were duplicated past
|
|
491
|
+
* the edges of the input.
|
|
492
|
+
* This has no effect if Mirror or Wrap are on.
|
|
493
|
+
* Defaults to true.
|
|
494
|
+
* @param border
|
|
495
|
+
* @returns
|
|
496
|
+
*/
|
|
497
|
+
setBorder: (border: boolean) => boolean;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* @see setBorder
|
|
501
|
+
* @returns
|
|
502
|
+
*/
|
|
503
|
+
getBorder: () => boolean;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Set interpolation mode.
|
|
507
|
+
* Only nearest neighbor is supported at the moment.
|
|
508
|
+
* Defaults to nearest neighbor.
|
|
509
|
+
* @param interpolationMode
|
|
510
|
+
* @returns
|
|
511
|
+
*/
|
|
512
|
+
setInterpolationMode: (interpolationMode: InterpolationMode) => boolean;
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* @see setInterpolationMode
|
|
516
|
+
* @returns
|
|
517
|
+
*/
|
|
518
|
+
getInterpolationMode: () => InterpolationMode;
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Set a transform to be applied to the resampling grid that has been
|
|
522
|
+
* defined via the ResliceAxes and the output Origin, Spacing and Extent.
|
|
523
|
+
* Note that applying a transform to the resampling grid (which lies in
|
|
524
|
+
* the output coordinate system) is equivalent to applying the inverse of
|
|
525
|
+
* that transform to the input volume. Nonlinear transforms such as
|
|
526
|
+
* vtkGridTransform and vtkThinPlateSplineTransform can be used here.
|
|
527
|
+
* Defaults to undefined.
|
|
528
|
+
* @param resliceTransform
|
|
529
|
+
* @returns
|
|
530
|
+
*/
|
|
531
|
+
setResliceTransform: (resliceTransform: vtkTransform | undefined) => boolean;
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* @see setResliceTransform
|
|
535
|
+
* @returns
|
|
536
|
+
*/
|
|
537
|
+
getResliceTransform: () => vtkTransform | undefined;
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Use trapezoid integration for slab computation.
|
|
541
|
+
* All this does is weigh the first and last slices by half when doing sum
|
|
542
|
+
* and mean. It is off by default.
|
|
543
|
+
* Defaults to false.
|
|
544
|
+
* @param slabTrapezoidIntegration
|
|
545
|
+
* @returns
|
|
546
|
+
*/
|
|
547
|
+
setSlabTrapezoidIntegration: (slabTrapezoidIntegration: boolean) => boolean;
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* @see setSlabTrapezoidIntegration
|
|
551
|
+
* @returns
|
|
552
|
+
*/
|
|
553
|
+
getSlabTrapezoidIntegration: () => boolean;
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* The slab spacing as a fraction of the output slice spacing.
|
|
557
|
+
* When one of the various slab modes is chosen, each output slice is
|
|
558
|
+
* produced by generating several "temporary" output slices and then
|
|
559
|
+
* combining them according to the slab mode. By default, the spacing between
|
|
560
|
+
* these temporary slices is the Z component of the OutputSpacing. This
|
|
561
|
+
* method sets the spacing between these temporary slices to be a fraction of
|
|
562
|
+
* the output spacing.
|
|
563
|
+
* Defaults to 1.
|
|
564
|
+
* @param slabSliceSpacingFraction
|
|
565
|
+
* @returns
|
|
566
|
+
*/
|
|
567
|
+
setSlabSliceSpacingFraction: (slabSliceSpacingFraction: number) => boolean;
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* @see setSlabSliceSpacingFraction
|
|
571
|
+
* @returns
|
|
572
|
+
*/
|
|
573
|
+
getSlabSliceSpacingFraction: () => number;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Method used to decorate a given object (publicAPI+model) with vtkImageReslice characteristics.
|
|
578
|
+
*
|
|
579
|
+
* @param publicAPI object on which methods will be bounds (public)
|
|
580
|
+
* @param model object on which data structure will be bounds (protected)
|
|
581
|
+
* @param {IImageResliceInitialValues} [initialValues] (default: {})
|
|
582
|
+
*/
|
|
583
|
+
export function extend(publicAPI: object, model: object, initialValues?: IImageResliceInitialValues): void;
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Method used to create a new instance of vtkImageReslice
|
|
587
|
+
* @param {IImageResliceInitialValues} [initialValues] for pre-setting some of its content
|
|
588
|
+
*/
|
|
589
|
+
export function newInstance(initialValues?: IImageResliceInitialValues): vtkImageReslice;
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* vtkImageReslice - Reslices a volume along a new set of axes
|
|
594
|
+
*
|
|
595
|
+
* vtkImageReslice is the swiss-army-knife of image geometry filters:
|
|
596
|
+
* It can permute, rotate, flip, scale, resample, deform, and pad image
|
|
597
|
+
* data in any combination with reasonably high efficiency. Simple
|
|
598
|
+
* operations such as permutation, resampling and padding are done
|
|
599
|
+
* with similar efficiently to the specialized vtkImagePermute,
|
|
600
|
+
* vtkImageResample, and vtkImagePad filters. There are a number of
|
|
601
|
+
* tasks that vtkImageReslice is well suited for:
|
|
602
|
+
* 1) Application of simple rotations, scales, and translations to
|
|
603
|
+
* an image. It is often a good idea to use vtkImageChangeInformation
|
|
604
|
+
* to center the image first, so that scales and rotations occur around
|
|
605
|
+
* the center rather than around the lower-left corner of the image.
|
|
606
|
+
* 2) Extraction of slices from an image volume. The method
|
|
607
|
+
* SetOutputDimensionality(2) is used to specify that want to output a
|
|
608
|
+
* slice rather than a volume. You can use both the resliceAxes and the
|
|
609
|
+
* resliceTransform at the same time, in order to extract slices from a
|
|
610
|
+
* volume that you have applied a transformation to.
|
|
611
|
+
* */
|
|
612
|
+
export declare const vtkImageReslice: {
|
|
613
|
+
newInstance: typeof newInstance;
|
|
614
|
+
extend: typeof extend;
|
|
615
|
+
}
|
|
616
|
+
export default vtkImageReslice;
|
|
@@ -101,7 +101,7 @@ function vtkImageReslice(publicAPI, model) {
|
|
|
101
101
|
publicAPI.modified();
|
|
102
102
|
return true;
|
|
103
103
|
}
|
|
104
|
-
return
|
|
104
|
+
return false;
|
|
105
105
|
};
|
|
106
106
|
publicAPI.requestData = (inData, outData) => {
|
|
107
107
|
// implement requestData
|
|
@@ -541,8 +541,8 @@ function vtkImageReslice(publicAPI, model) {
|
|
|
541
541
|
* if possible (if the ResliceTransform is a 4x4 matrix transform).
|
|
542
542
|
* If it does, this->OptimizedTransform will be set to nullptr, otherwise
|
|
543
543
|
* this->OptimizedTransform will be equal to this->ResliceTransform.
|
|
544
|
-
* @param {
|
|
545
|
-
* @param {
|
|
544
|
+
* @param {vtkImageData} input
|
|
545
|
+
* @param {vtkImageData} output
|
|
546
546
|
* @returns
|
|
547
547
|
*/
|
|
548
548
|
publicAPI.getIndexMatrix = (input, output) => {
|
|
@@ -777,10 +777,10 @@ function vtkImageReslice(publicAPI, model) {
|
|
|
777
777
|
}
|
|
778
778
|
}
|
|
779
779
|
if (k !== 1) {
|
|
780
|
-
return
|
|
780
|
+
return false;
|
|
781
781
|
}
|
|
782
782
|
}
|
|
783
|
-
return
|
|
783
|
+
return true;
|
|
784
784
|
};
|
|
785
785
|
|
|
786
786
|
// TODO: to move in vtkMath and add tolerance
|
|
@@ -805,7 +805,7 @@ function vtkImageReslice(publicAPI, model) {
|
|
|
805
805
|
}
|
|
806
806
|
}
|
|
807
807
|
if (j >= 3) {
|
|
808
|
-
return
|
|
808
|
+
return false;
|
|
809
809
|
}
|
|
810
810
|
let x = matrix[4 * j + i];
|
|
811
811
|
let y = matrix[4 * 3 + i];
|
|
@@ -816,10 +816,10 @@ function vtkImageReslice(publicAPI, model) {
|
|
|
816
816
|
const fx = vtkInterpolationMathFloor(x).error;
|
|
817
817
|
const fy = vtkInterpolationMathFloor(y).error;
|
|
818
818
|
if (fx !== 0 || fy !== 0) {
|
|
819
|
-
return
|
|
819
|
+
return false;
|
|
820
820
|
}
|
|
821
821
|
}
|
|
822
|
-
return
|
|
822
|
+
return true;
|
|
823
823
|
};
|
|
824
824
|
}
|
|
825
825
|
|
|
@@ -883,7 +883,6 @@ function extend(publicAPI, model) {
|
|
|
883
883
|
macro.get(publicAPI, model, ['resliceAxes']);
|
|
884
884
|
|
|
885
885
|
// Object specific methods
|
|
886
|
-
macro.algo(publicAPI, model, 1, 1);
|
|
887
886
|
vtkImageReslice(publicAPI, model);
|
|
888
887
|
}
|
|
889
888
|
|
|
@@ -43,7 +43,7 @@ function vtkFollower(publicAPI, model) {
|
|
|
43
43
|
// compute a vpn
|
|
44
44
|
const vpn = new Float64Array(3);
|
|
45
45
|
if (model.camera.getParallelProjection()) {
|
|
46
|
-
vec3.set(vpn, model.camera.getViewPlaneNormal());
|
|
46
|
+
vec3.set(vpn, ...model.camera.getViewPlaneNormal());
|
|
47
47
|
} else {
|
|
48
48
|
vec3.set(vpn, ...model.position);
|
|
49
49
|
vec3.subtract(vpn, model.camera.getPosition(), vpn);
|
|
@@ -13,7 +13,12 @@ function projectDisplayToLine(x, y, lineOrigin, lineDirection, renderer, glRende
|
|
|
13
13
|
const numerator = dot([near[0] - lineOrigin[0], near[1] - lineOrigin[1], near[2] - lineOrigin[2]], normal);
|
|
14
14
|
const denominator = dot(normal, lineDirection);
|
|
15
15
|
const result = lineDirection.slice();
|
|
16
|
-
|
|
16
|
+
if (denominator === 0) {
|
|
17
|
+
// no change is allowed
|
|
18
|
+
multiplyScalar(result, 0);
|
|
19
|
+
} else {
|
|
20
|
+
multiplyScalar(result, numerator / denominator);
|
|
21
|
+
}
|
|
17
22
|
add(lineOrigin, result, result);
|
|
18
23
|
return result;
|
|
19
24
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ViewTypes } from '../../Core/WidgetManager/Constants';
|
|
2
|
+
|
|
3
|
+
export declare enum ScrollingMethods {
|
|
4
|
+
MIDDLE_MOUSE_BUTTON = 0,
|
|
5
|
+
LEFT_MOUSE_BUTTON = 1,
|
|
6
|
+
RIGHT_MOUSE_BUTTON = 2,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Note: These strings are used in ResliceCursorWidget/behavior.js
|
|
10
|
+
// as method's names
|
|
11
|
+
export declare enum InteractionMethodsName {
|
|
12
|
+
TranslateAxis = 'translateAxis',
|
|
13
|
+
RotateLine = 'rotateLine',
|
|
14
|
+
TranslateCenter = 'translateCenter',
|
|
15
|
+
TranslateCenterAndUpdatePlanes = 'translateCenterAndUpdatePlanes',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export declare type defaultViewUpFromViewType = {
|
|
19
|
+
[ViewTypes.YZ_PLANE]: [0, 0, 1], // Sagittal
|
|
20
|
+
[ViewTypes.XZ_PLANE]: [0, 0, 1], // Coronal
|
|
21
|
+
[ViewTypes.XY_PLANE]: [0, -1, 0], // Axial
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export declare type xyzToViewType = [
|
|
25
|
+
ViewTypes.YZ_PLANE,
|
|
26
|
+
ViewTypes.XZ_PLANE,
|
|
27
|
+
ViewTypes.XY_PLANE,
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
export declare type viewTypeToXYZ = {
|
|
31
|
+
[ViewTypes.YZ_PLANE]: 0,
|
|
32
|
+
[ViewTypes.XZ_PLANE]: 1,
|
|
33
|
+
[ViewTypes.XY_PLANE]: 2,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export declare type planeNames = ['X', 'Y', 'Z'];
|
|
37
|
+
|
|
38
|
+
export declare type viewTypeToPlaneName = {
|
|
39
|
+
[ViewTypes.YZ_PLANE]: 'X',
|
|
40
|
+
[ViewTypes.XZ_PLANE]: 'Y',
|
|
41
|
+
[ViewTypes.XY_PLANE]: 'Z',
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export declare type planeNameToViewType = {
|
|
45
|
+
X: ViewTypes.YZ_PLANE,
|
|
46
|
+
Y: ViewTypes.XZ_PLANE,
|
|
47
|
+
Z: ViewTypes.XY_PLANE,
|
|
48
|
+
}
|
|
49
|
+
export declare type lineNames = ['YinX', 'ZinX', 'XinY', 'ZinY', 'XinZ', 'YinZ'];
|
|
50
|
+
|
|
51
|
+
declare const _default: {
|
|
52
|
+
ScrollingMethods: typeof ScrollingMethods;
|
|
53
|
+
InteractionMethodsName: typeof InteractionMethodsName;
|
|
54
|
+
xyzToViewType: xyzToViewType;
|
|
55
|
+
viewTypeToXYZ: viewTypeToXYZ;
|
|
56
|
+
planeNames: planeNames;
|
|
57
|
+
viewTypeToPlaneName: viewTypeToPlaneName;
|
|
58
|
+
planeNameToViewType: planeNameToViewType;
|
|
59
|
+
lineNames: lineNames;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default _default;
|
|
@@ -71,6 +71,14 @@ export interface vtkResliceCursorWidget extends vtkAbstractWidgetFactory {
|
|
|
71
71
|
|
|
72
72
|
getManipulator(): vtkPlaneManipulator;
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Return an array of the first and the last possible points of the plane
|
|
76
|
+
* along its normal.
|
|
77
|
+
* @param {ViewTypes} viewType
|
|
78
|
+
* @returns {[Vector3, Vector3]} first and last points
|
|
79
|
+
*/
|
|
80
|
+
getPlaneExtremities(viewType: ViewTypes): Array<Vector3>;
|
|
81
|
+
|
|
74
82
|
}
|
|
75
83
|
|
|
76
84
|
export interface IResliceCursorWidgetInitialValues {}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
|
|
3
|
+
import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
|
|
4
|
+
import vtkBox from '../../Common/DataModel/Box.js';
|
|
3
5
|
import vtkPlane from '../../Common/DataModel/Plane.js';
|
|
4
6
|
import vtkPlaneSource from '../../Filters/Sources/PlaneSource.js';
|
|
5
7
|
import vtkPlanePointManipulator from '../Manipulators/PlaneManipulator.js';
|
|
@@ -201,8 +203,7 @@ function vtkResliceCursorWidget(publicAPI, model) {
|
|
|
201
203
|
publicAPI.setImage = image => {
|
|
202
204
|
model.widgetState.setImage(image);
|
|
203
205
|
const center = image.getCenter();
|
|
204
|
-
|
|
205
|
-
updateState(model.widgetState, model.scaleInPixels, model.rotationHandlePosition);
|
|
206
|
+
publicAPI.setCenter(center);
|
|
206
207
|
};
|
|
207
208
|
publicAPI.setCenter = center => {
|
|
208
209
|
model.widgetState.setCenter(center);
|
|
@@ -401,6 +402,15 @@ function vtkResliceCursorWidget(publicAPI, model) {
|
|
|
401
402
|
publicAPI.getViewWidgets().forEach(w => w.setScaleInPixels(scale));
|
|
402
403
|
updateState(model.widgetState, model.scaleInPixels, model.rotationHandlePosition);
|
|
403
404
|
});
|
|
405
|
+
publicAPI.getPlaneExtremities = viewType => {
|
|
406
|
+
const dirProj = publicAPI.getWidgetState().getPlanes()[viewType].normal;
|
|
407
|
+
const length = vtkBoundingBox.getDiagonalLength(publicAPI.getWidgetState().getImage().getBounds());
|
|
408
|
+
const p1 = multiplyAccumulate(publicAPI.getWidgetState().getCenter(), dirProj, -length, []);
|
|
409
|
+
const p2 = multiplyAccumulate(publicAPI.getWidgetState().getCenter(), dirProj, length, []);
|
|
410
|
+
// FIXME: support oriented bounds
|
|
411
|
+
const intersectionPoints = vtkBox.intersectWithLine(publicAPI.getWidgetState().getImage().getBounds(), p1, p2);
|
|
412
|
+
return [intersectionPoints.x1, intersectionPoints.x2];
|
|
413
|
+
};
|
|
404
414
|
}
|
|
405
415
|
|
|
406
416
|
// ----------------------------------------------------------------------------
|
package/index.d.ts
CHANGED
|
@@ -105,6 +105,9 @@
|
|
|
105
105
|
/// <reference path="./IO/XML/XMLImageDataReader.d.ts" />
|
|
106
106
|
/// <reference path="./IO/XML/XMLPolyDataReader.d.ts" />
|
|
107
107
|
/// <reference path="./IO/XML/XMLReader.d.ts" />
|
|
108
|
+
/// <reference path="./Imaging/Core/AbstractImageInterpolator/Constants.d.ts" />
|
|
109
|
+
/// <reference path="./Imaging/Core/ImageReslice/Constants.d.ts" />
|
|
110
|
+
/// <reference path="./Imaging/Core/ImageReslice.d.ts" />
|
|
108
111
|
/// <reference path="./Interaction/Manipulators/CompositeCameraManipulator.d.ts" />
|
|
109
112
|
/// <reference path="./Interaction/Manipulators/CompositeGestureManipulator.d.ts" />
|
|
110
113
|
/// <reference path="./Interaction/Manipulators/CompositeKeyboardManipulator.d.ts" />
|
|
@@ -224,6 +227,7 @@
|
|
|
224
227
|
/// <reference path="./Widgets/Manipulators/TrackballManipulator.d.ts" />
|
|
225
228
|
/// <reference path="./Widgets/Representations/WidgetRepresentation.d.ts" />
|
|
226
229
|
/// <reference path="./Widgets/Widgets3D/InteractiveOrientationWidget.d.ts" />
|
|
230
|
+
/// <reference path="./Widgets/Widgets3D/ResliceCursorWidget/Constants.d.ts" />
|
|
227
231
|
/// <reference path="./Widgets/Widgets3D/ResliceCursorWidget.d.ts" />
|
|
228
232
|
/// <reference path="./Widgets/Widgets3D/SeedWidget.d.ts" />
|
|
229
233
|
/// <reference path="./Widgets/Widgets3D/SphereWidget.d.ts" />
|