@kitware/vtk.js 33.0.0-beta.3 → 33.0.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/BREAKING_CHANGES.md +0 -3
- package/Common/Core/DataArray.d.ts +17 -0
- package/Common/Core/DataArray.js +36 -0
- package/Common/Core/ScalarsToColors/Constants.js +7 -2
- package/Common/Core/ScalarsToColors.js +3 -1
- package/Rendering/Core/AbstractImageMapper.d.ts +81 -0
- package/Rendering/Core/AbstractImageMapper.js +5 -2
- package/Rendering/Core/AbstractPicker.d.ts +13 -13
- package/Rendering/Core/AbstractPicker.js +1 -1
- package/Rendering/Core/Actor.d.ts +20 -5
- package/Rendering/Core/Actor.js +68 -5
- package/Rendering/Core/Actor2D.d.ts +22 -0
- package/Rendering/Core/Actor2D.js +1 -1
- package/Rendering/Core/CellPicker.js +4 -1
- package/Rendering/Core/ColorTransferFunction.js +26 -35
- package/Rendering/Core/ImageCPRMapper.d.ts +20 -1
- package/Rendering/Core/ImageCPRMapper.js +7 -5
- package/Rendering/Core/ImageResliceMapper.d.ts +20 -2
- package/Rendering/Core/ImageResliceMapper.js +7 -5
- package/Rendering/Core/ImageSlice.d.ts +23 -7
- package/Rendering/Core/ImageSlice.js +68 -9
- package/Rendering/Core/Mapper.js +8 -16
- package/Rendering/Core/Prop3D.d.ts +2 -39
- package/Rendering/Core/Prop3D.js +2 -81
- package/Rendering/Core/ScalarBarActor.js +4 -2
- package/Rendering/Core/Viewport.js +13 -3
- package/Rendering/Core/Volume.d.ts +20 -5
- package/Rendering/Core/Volume.js +70 -2
- package/Rendering/Core/VolumeMapper/Constants.d.ts +7 -0
- package/Rendering/Core/VolumeMapper/Constants.js +8 -2
- package/Rendering/Core/VolumeMapper.d.ts +243 -16
- package/Rendering/Core/VolumeMapper.js +60 -20
- package/Rendering/Core/VolumeProperty/Constants.d.ts +3 -12
- package/Rendering/Core/VolumeProperty/Constants.js +4 -11
- package/Rendering/Core/VolumeProperty.d.ts +4 -120
- package/Rendering/Core/VolumeProperty.js +4 -49
- package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/CameraSynchronizer.js +2 -2
- package/Rendering/OpenGL/ImageCPRMapper.js +36 -29
- package/Rendering/OpenGL/ImageMapper.js +55 -31
- package/Rendering/OpenGL/ImageResliceMapper.js +191 -263
- package/Rendering/OpenGL/PolyDataMapper.js +8 -1
- package/Rendering/OpenGL/RenderWindow/resourceSharingHelper.d.ts +3 -3
- package/Rendering/OpenGL/RenderWindow/resourceSharingHelper.js +5 -8
- package/Rendering/OpenGL/Renderer.js +1 -1
- package/Rendering/OpenGL/Texture.d.ts +29 -8
- package/Rendering/OpenGL/Texture.js +154 -23
- package/Rendering/OpenGL/VolumeMapper.js +792 -712
- package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
- package/Rendering/SceneGraph/ViewNode.js +12 -2
- package/Rendering/WebGPU/VolumePassFSQ.js +2 -2
- package/Rendering/WebXR/RenderWindowHelper.js +9 -0
- package/Widgets/Core/WidgetManager.d.ts +12 -1
- package/Widgets/Representations/WidgetRepresentation.d.ts +1 -7
- package/Widgets/Widgets3D/ResliceCursorWidget.d.ts +1 -8
- package/index.d.ts +0 -1
- package/macros2.js +1 -1
- package/package.json +11 -11
- package/Interaction/Manipulators/KeyboardCameraManipulator.d.ts +0 -113
package/Rendering/Core/Volume.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { mat4, vec3 } from 'gl-matrix';
|
|
1
2
|
import { m as macro } from '../../macros2.js';
|
|
3
|
+
import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
|
|
2
4
|
import vtkProp3D from './Prop3D.js';
|
|
3
5
|
import vtkVolumeProperty from './VolumeProperty.js';
|
|
4
6
|
|
|
7
|
+
const {
|
|
8
|
+
vtkDebugMacro
|
|
9
|
+
} = macro;
|
|
10
|
+
|
|
5
11
|
// ----------------------------------------------------------------------------
|
|
6
12
|
// vtkVolume methods
|
|
7
13
|
// ----------------------------------------------------------------------------
|
|
@@ -9,8 +15,66 @@ import vtkVolumeProperty from './VolumeProperty.js';
|
|
|
9
15
|
function vtkVolume(publicAPI, model) {
|
|
10
16
|
// Set our className
|
|
11
17
|
model.classHierarchy.push('vtkVolume');
|
|
12
|
-
publicAPI.getVolumes = () =>
|
|
18
|
+
publicAPI.getVolumes = () => publicAPI;
|
|
13
19
|
publicAPI.makeProperty = vtkVolumeProperty.newInstance;
|
|
20
|
+
publicAPI.getProperty = () => {
|
|
21
|
+
if (model.property === null) {
|
|
22
|
+
model.property = publicAPI.makeProperty();
|
|
23
|
+
}
|
|
24
|
+
return model.property;
|
|
25
|
+
};
|
|
26
|
+
publicAPI.getBounds = () => {
|
|
27
|
+
if (model.mapper === null) {
|
|
28
|
+
return model.bounds;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Check for the special case when the mapper's bounds are unknown
|
|
32
|
+
const bds = model.mapper.getBounds();
|
|
33
|
+
if (!bds || bds.length !== 6) {
|
|
34
|
+
return bds;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Check for the special case when the actor is empty.
|
|
38
|
+
if (bds[0] > bds[1]) {
|
|
39
|
+
model.mapperBounds = bds.concat(); // copy the mapper's bounds
|
|
40
|
+
model.bounds = [1, -1, 1, -1, 1, -1];
|
|
41
|
+
model.boundsMTime.modified();
|
|
42
|
+
return bds;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Check if we have cached values for these bounds - we cache the
|
|
46
|
+
// values returned by model.mapper.getBounds() and we store the time
|
|
47
|
+
// of caching. If the values returned this time are different, or
|
|
48
|
+
// the modified time of this class is newer than the cached time,
|
|
49
|
+
// then we need to rebuild.
|
|
50
|
+
const zip = rows => rows[0].map((_, c) => rows.map(row => row[c]));
|
|
51
|
+
if (!model.mapperBounds || !zip([bds, model.mapperBounds]).reduce((a, b) => a && b[0] === b[1], true) || publicAPI.getMTime() > model.boundsMTime.getMTime()) {
|
|
52
|
+
vtkDebugMacro('Recomputing bounds...');
|
|
53
|
+
model.mapperBounds = bds.map(x => x);
|
|
54
|
+
const bbox = [];
|
|
55
|
+
vtkBoundingBox.getCorners(bds, bbox);
|
|
56
|
+
publicAPI.computeMatrix();
|
|
57
|
+
const tmp4 = new Float64Array(16);
|
|
58
|
+
mat4.transpose(tmp4, model.matrix);
|
|
59
|
+
bbox.forEach(pt => vec3.transformMat4(pt, pt, tmp4));
|
|
60
|
+
|
|
61
|
+
/* eslint-disable no-multi-assign */
|
|
62
|
+
model.bounds[0] = model.bounds[2] = model.bounds[4] = Number.MAX_VALUE;
|
|
63
|
+
model.bounds[1] = model.bounds[3] = model.bounds[5] = -Number.MAX_VALUE;
|
|
64
|
+
/* eslint-enable no-multi-assign */
|
|
65
|
+
model.bounds = model.bounds.map((d, i) => i % 2 === 0 ? bbox.reduce((a, b) => a > b[i / 2] ? b[i / 2] : a, d) : bbox.reduce((a, b) => a < b[(i - 1) / 2] ? b[(i - 1) / 2] : a, d));
|
|
66
|
+
model.boundsMTime.modified();
|
|
67
|
+
}
|
|
68
|
+
return model.bounds;
|
|
69
|
+
};
|
|
70
|
+
publicAPI.getMTime = () => {
|
|
71
|
+
let mt = model.mtime;
|
|
72
|
+
if (model.property !== null) {
|
|
73
|
+
const time = model.property.getMTime();
|
|
74
|
+
mt = time > mt ? time : mt;
|
|
75
|
+
}
|
|
76
|
+
return mt;
|
|
77
|
+
};
|
|
14
78
|
publicAPI.getRedrawMTime = () => {
|
|
15
79
|
let mt = model.mtime;
|
|
16
80
|
if (model.mapper !== null) {
|
|
@@ -32,7 +96,9 @@ function vtkVolume(publicAPI, model) {
|
|
|
32
96
|
// ----------------------------------------------------------------------------
|
|
33
97
|
|
|
34
98
|
const DEFAULT_VALUES = {
|
|
35
|
-
mapper: null
|
|
99
|
+
mapper: null,
|
|
100
|
+
property: null,
|
|
101
|
+
bounds: [1, -1, 1, -1, 1, -1]
|
|
36
102
|
};
|
|
37
103
|
|
|
38
104
|
// ----------------------------------------------------------------------------
|
|
@@ -49,7 +115,9 @@ function extend(publicAPI, model) {
|
|
|
49
115
|
macro.obj(model.boundsMTime);
|
|
50
116
|
|
|
51
117
|
// Build VTK API
|
|
118
|
+
macro.set(publicAPI, model, ['property']);
|
|
52
119
|
macro.setGet(publicAPI, model, ['mapper']);
|
|
120
|
+
macro.getArray(publicAPI, model, ['bounds'], 6);
|
|
53
121
|
|
|
54
122
|
// Object methods
|
|
55
123
|
vtkVolume(publicAPI, model);
|
|
@@ -8,7 +8,14 @@ export declare enum BlendMode {
|
|
|
8
8
|
LABELMAP_EDGE_PROJECTION_BLEND = 6,
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
export declare enum FilterMode {
|
|
12
|
+
OFF = 0,
|
|
13
|
+
NORMALIZED = 1,
|
|
14
|
+
RAW = 2,
|
|
15
|
+
}
|
|
16
|
+
|
|
11
17
|
declare const _default: {
|
|
12
18
|
BlendMode: typeof BlendMode;
|
|
19
|
+
FilterMode: typeof FilterMode;
|
|
13
20
|
};
|
|
14
21
|
export default _default;
|
|
@@ -7,8 +7,14 @@ const BlendMode = {
|
|
|
7
7
|
RADON_TRANSFORM_BLEND: 5,
|
|
8
8
|
LABELMAP_EDGE_PROJECTION_BLEND: 6
|
|
9
9
|
};
|
|
10
|
+
const FilterMode = {
|
|
11
|
+
OFF: 0,
|
|
12
|
+
NORMALIZED: 1,
|
|
13
|
+
RAW: 2
|
|
14
|
+
};
|
|
10
15
|
var Constants = {
|
|
11
|
-
BlendMode
|
|
16
|
+
BlendMode,
|
|
17
|
+
FilterMode
|
|
12
18
|
};
|
|
13
19
|
|
|
14
|
-
export { BlendMode, Constants as default };
|
|
20
|
+
export { BlendMode, FilterMode, Constants as default };
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
import vtkPiecewiseFunction from './../../Common/DataModel/PiecewiseFunction';
|
|
2
|
-
import { Bounds } from './../../types';
|
|
2
|
+
import { Bounds, Range, Extent } from './../../types';
|
|
3
3
|
import vtkAbstractMapper3D, {
|
|
4
4
|
IAbstractMapper3DInitialValues,
|
|
5
5
|
} from './AbstractMapper3D';
|
|
6
|
-
import { BlendMode } from './VolumeMapper/Constants';
|
|
6
|
+
import { BlendMode, FilterMode } from './VolumeMapper/Constants';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
*/
|
|
11
11
|
export interface IVolumeMapperInitialValues
|
|
12
12
|
extends IAbstractMapper3DInitialValues {
|
|
13
|
+
anisotropy?: number;
|
|
13
14
|
autoAdjustSampleDistances?: boolean;
|
|
15
|
+
averageIPScalarRange?: Range;
|
|
14
16
|
blendMode?: BlendMode;
|
|
15
17
|
bounds?: Bounds;
|
|
18
|
+
computeNormalFromOpacity?: boolean;
|
|
19
|
+
getVolumeShadowSamplingDistFactor?: number;
|
|
20
|
+
globalIlluminationReach?: number;
|
|
21
|
+
imageSampleDistance?: number;
|
|
22
|
+
localAmbientOcclusion?: boolean;
|
|
16
23
|
maximumSamplesPerRay?: number;
|
|
17
24
|
sampleDistance?: number;
|
|
18
|
-
|
|
25
|
+
LAOKernelRadius?: number;
|
|
26
|
+
LAOKernelSize?: number;
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
export interface vtkVolumeMapper extends vtkAbstractMapper3D {
|
|
@@ -41,12 +49,6 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D {
|
|
|
41
49
|
*/
|
|
42
50
|
getSampleDistance(): number;
|
|
43
51
|
|
|
44
|
-
/**
|
|
45
|
-
* Get the multipler for volume shadow sampling distance
|
|
46
|
-
* @default 5.0
|
|
47
|
-
*/
|
|
48
|
-
getVolumeShadowSamplingDistFactor(): number;
|
|
49
|
-
|
|
50
52
|
/**
|
|
51
53
|
* Sampling distance in the XY image dimensions.
|
|
52
54
|
* Default value of 1 meaning 1 ray cast per pixel. If set to 0.5, 4 rays will be cast per pixel.
|
|
@@ -82,6 +84,71 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D {
|
|
|
82
84
|
*/
|
|
83
85
|
getInteractionSampleDistanceFactor(): number;
|
|
84
86
|
|
|
87
|
+
/**
|
|
88
|
+
*
|
|
89
|
+
*/
|
|
90
|
+
getAverageIPScalarRange(): Range;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
*
|
|
94
|
+
*/
|
|
95
|
+
getAverageIPScalarRangeByReference(): Range;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Get the blending coefficient that interpolates between surface and volume rendering
|
|
99
|
+
* @default 0.0
|
|
100
|
+
*/
|
|
101
|
+
getVolumetricScatteringBlending(): number;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Get the global illumination reach of volume shadow
|
|
105
|
+
* @default 0.0
|
|
106
|
+
*/
|
|
107
|
+
getGlobalIlluminationReach(): number;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Get the multipler for volume shadow sampling distance
|
|
111
|
+
* @default 5.0
|
|
112
|
+
*/
|
|
113
|
+
getVolumeShadowSamplingDistFactor(): number;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Get anisotropy of volume shadow scatter
|
|
117
|
+
* @default 0.0
|
|
118
|
+
*/
|
|
119
|
+
getAnisotropy(): number;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Get local ambient occlusion flag
|
|
123
|
+
* @default false
|
|
124
|
+
*/
|
|
125
|
+
getLocalAmbientOcclusion(): boolean;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Get kernel size for local ambient occlusion
|
|
129
|
+
* @default 15
|
|
130
|
+
*/
|
|
131
|
+
getLAOKernelSize(): number;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Get kernel radius for local ambient occlusion
|
|
135
|
+
* @default 7
|
|
136
|
+
*/
|
|
137
|
+
getLAOKernelRadius(): number;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
*
|
|
141
|
+
* @param x
|
|
142
|
+
* @param y
|
|
143
|
+
*/
|
|
144
|
+
setAverageIPScalarRange(x: number, y: number): boolean;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
*
|
|
148
|
+
* @param {Range} averageIPScalarRange
|
|
149
|
+
*/
|
|
150
|
+
setAverageIPScalarRangeFrom(averageIPScalarRange: Range): boolean;
|
|
151
|
+
|
|
85
152
|
/**
|
|
86
153
|
* Set blend mode to COMPOSITE_BLEND
|
|
87
154
|
* @param {BlendMode} blendMode
|
|
@@ -119,13 +186,6 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D {
|
|
|
119
186
|
*/
|
|
120
187
|
setSampleDistance(sampleDistance: number): boolean;
|
|
121
188
|
|
|
122
|
-
/**
|
|
123
|
-
* Set the multipler for volume shadow sampling distance. This function is only effective when volumeScatterBlendCoef is greater than 0.
|
|
124
|
-
* For VSSampleDistanceFactor >= 1.0, volume shadow sampling distance = VSSampleDistanceFactor * SampleDistance.
|
|
125
|
-
* @param VSSampleDistanceFactor
|
|
126
|
-
*/
|
|
127
|
-
setVolumeShadowSamplingDistFactor(VSSampleDistanceFactor: number): void;
|
|
128
|
-
|
|
129
189
|
/**
|
|
130
190
|
*
|
|
131
191
|
* @param imageSampleDistance
|
|
@@ -158,10 +218,176 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D {
|
|
|
158
218
|
interactionSampleDistanceFactor: number
|
|
159
219
|
): boolean;
|
|
160
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Set the normal computation to be dependent on the transfer function.
|
|
223
|
+
* By default, the mapper relies on the scalar gradient for computing normals at sample locations
|
|
224
|
+
* for lighting calculations. This is an approximation and can lead to inaccurate results.
|
|
225
|
+
* When enabled, this property makes the mapper compute normals based on the accumulated opacity
|
|
226
|
+
* at sample locations. This can generate a more accurate representation of edge structures in the
|
|
227
|
+
* data but adds an overhead and drops frame rate.
|
|
228
|
+
* @param computeNormalFromOpacity
|
|
229
|
+
*/
|
|
230
|
+
setComputeNormalFromOpacity(computeNormalFromOpacity: boolean): boolean;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Set the blending coefficient that determines the interpolation between surface and volume rendering.
|
|
234
|
+
* Default value of 0.0 means shadow effect is computed with phong model.
|
|
235
|
+
* Value of 1.0 means shadow is created by volume occlusion.
|
|
236
|
+
* @param volumeScatterBlendCoef
|
|
237
|
+
*/
|
|
238
|
+
setVolumetricScatteringBlending(volumeScatterBlendCoef: number): void;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Set the global illumination reach of volume shadow. This function is only effective when volumeScatterBlendCoef is greater than 0.
|
|
242
|
+
* Default value of 0.0 means only the neighboring voxel is considered when creating global shadow.
|
|
243
|
+
* Value of 1.0 means the shadow ray traverses through the entire volume.
|
|
244
|
+
* @param globalIlluminationReach
|
|
245
|
+
*/
|
|
246
|
+
setGlobalIlluminationReach(globalIlluminationReach: number): void;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Set the multipler for volume shadow sampling distance. This function is only effective when volumeScatterBlendCoef is greater than 0.
|
|
250
|
+
* For VSSampleDistanceFactor >= 1.0, volume shadow sampling distance = VSSampleDistanceFactor * SampleDistance.
|
|
251
|
+
* @param VSSampleDistanceFactor
|
|
252
|
+
*/
|
|
253
|
+
setVolumeShadowSamplingDistFactor(VSSampleDistanceFactor: number): void;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Set anisotropy of volume shadow scatter. This function is only effective when volumeScatterBlendCoef is greater than 0.
|
|
257
|
+
* Default value of 0.0 means light scatters uniformly in all directions.
|
|
258
|
+
* Value of -1.0 means light scatters backward, value of 1.0 means light scatters forward.
|
|
259
|
+
* @param anisotropy
|
|
260
|
+
*/
|
|
261
|
+
setAnisotropy(anisotropy: number): void;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Set whether to turn on local ambient occlusion (LAO). LAO is only effective if shading is on and volumeScatterBlendCoef is set to 0.
|
|
265
|
+
* LAO effect is added to ambient lighting, so the ambient component of the actor needs to be great than 0.
|
|
266
|
+
* @param localAmbientOcclusion
|
|
267
|
+
*/
|
|
268
|
+
setLocalAmbientOcclusion(localAmbientOcclusion: boolean): void;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Set kernel size for local ambient occlusion. It specifies the number of rays that are randomly sampled in the hemisphere.
|
|
272
|
+
* Value is clipped between 1 and 32.
|
|
273
|
+
* @param LAOKernelSize
|
|
274
|
+
*/
|
|
275
|
+
setLAOKernelSize(LAOKernelSize: number): void;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Set kernel radius for local ambient occlusion. It specifies the number of samples that are considered on each random ray.
|
|
279
|
+
* Value must be greater than or equal to 1.
|
|
280
|
+
* @param LAOKernelRadius
|
|
281
|
+
*/
|
|
282
|
+
setLAOKernelRadius(LAOKernelRadius: number): void;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Set kernel size for local ambient occlusion. It specifies the number of rays that are randomly sampled in the hemisphere.
|
|
286
|
+
* Value is clipped between 1 and 32.
|
|
287
|
+
* @param LAOKernelSize
|
|
288
|
+
*/
|
|
289
|
+
setLAOKernelSize(LAOKernelSize: number): void;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Set kernel radius for local ambient occlusion. It specifies the number of samples that are considered on each random ray.
|
|
293
|
+
* Value must be greater than or equal to 1.
|
|
294
|
+
* @param LAOKernelRadius
|
|
295
|
+
*/
|
|
296
|
+
setLAOKernelRadius(LAOKernelRadius: number): void;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Tells the mapper to only update the specified extents.
|
|
300
|
+
*
|
|
301
|
+
* If there are zero extents, the mapper updates the entire volume texture.
|
|
302
|
+
* Otherwise, the mapper will only update the texture by the specified extents
|
|
303
|
+
* during the next render call.
|
|
304
|
+
*
|
|
305
|
+
* This array is cleared after a successful render.
|
|
306
|
+
* @param extents
|
|
307
|
+
*/
|
|
308
|
+
setUpdatedExtents(extents: Extent[]): boolean;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Retrieves the updated extents.
|
|
312
|
+
*
|
|
313
|
+
* This array is cleared after every successful render.
|
|
314
|
+
*/
|
|
315
|
+
getUpdatedExtents(): Extent[];
|
|
316
|
+
|
|
161
317
|
/**
|
|
162
318
|
*
|
|
163
319
|
*/
|
|
164
320
|
update(): void;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Set the opacity texture width.
|
|
324
|
+
*
|
|
325
|
+
* The default width (1024) should be fine in most instances.
|
|
326
|
+
* Only set this property if your opacity function range width is
|
|
327
|
+
* larger than 1024.
|
|
328
|
+
*
|
|
329
|
+
* @param {Number} width the texture width (defaults to 1024)
|
|
330
|
+
*/
|
|
331
|
+
setOpacityTextureWidth(width: number): boolean;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Get the opacity texture width.
|
|
335
|
+
*/
|
|
336
|
+
getOpacityTextureWidth(): number;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Set the color texture width.
|
|
340
|
+
*
|
|
341
|
+
* The default width (1024) should be fine in most instances.
|
|
342
|
+
* Only set this property if your color transfer function range width is
|
|
343
|
+
* larger than 1024.
|
|
344
|
+
*
|
|
345
|
+
* A reasonable max texture size would be either 2048 or 4096, as those
|
|
346
|
+
* widths are supported by the vast majority of devices. Any width larger
|
|
347
|
+
* than that will have issues with device support.
|
|
348
|
+
*
|
|
349
|
+
* Specifying a width that is less than or equal to 0 will use the largest
|
|
350
|
+
* possible texture width on the device. Use this with caution! The max texture
|
|
351
|
+
* width of one device may not be the same for another device.
|
|
352
|
+
*
|
|
353
|
+
* You can find more information about supported texture widths at the following link:
|
|
354
|
+
* https://web3dsurvey.com/webgl/parameters/MAX_TEXTURE_SIZE
|
|
355
|
+
*
|
|
356
|
+
* @param {Number} width the texture width (defaults to 1024)
|
|
357
|
+
*/
|
|
358
|
+
setColorTextureWidth(width: number): boolean;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Get the color texture width.
|
|
362
|
+
*/
|
|
363
|
+
getColorTextureWidth(): number;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Set the label outline texture width.
|
|
367
|
+
*
|
|
368
|
+
* The default width (1024) should be fine in most instances.
|
|
369
|
+
* Only set this property if you have more than 1024 labels
|
|
370
|
+
* that you want to render with thickness.
|
|
371
|
+
*
|
|
372
|
+
* A reasonable max texture size would be either 2048 or 4096, as those
|
|
373
|
+
* widths are supported by the vast majority of devices. Any width larger
|
|
374
|
+
* than that will have issues with device support.
|
|
375
|
+
*
|
|
376
|
+
* Specifying a width that is less than or equal to 0 will use the largest
|
|
377
|
+
* possible texture width on the device. Use this with caution! The max texture
|
|
378
|
+
* width of one device may not be the same for another device.
|
|
379
|
+
*
|
|
380
|
+
* You can find more information about supported texture widths at the following link:
|
|
381
|
+
* https://web3dsurvey.com/webgl/parameters/MAX_TEXTURE_SIZE
|
|
382
|
+
*
|
|
383
|
+
* @param {Number} width the texture width (defaults to 1024)
|
|
384
|
+
*/
|
|
385
|
+
setLabelOutlineTextureWidth(width: number): boolean;
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Get the label outline texture width.
|
|
389
|
+
*/
|
|
390
|
+
getLabelOutlineTextureWidth(): number;
|
|
165
391
|
}
|
|
166
392
|
|
|
167
393
|
/**
|
|
@@ -223,5 +449,6 @@ export declare const vtkVolumeMapper: {
|
|
|
223
449
|
newInstance: typeof newInstance;
|
|
224
450
|
extend: typeof extend;
|
|
225
451
|
BlendMode: typeof BlendMode;
|
|
452
|
+
FilterMode: typeof FilterMode;
|
|
226
453
|
};
|
|
227
454
|
export default vtkVolumeMapper;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
|
+
import { H as createUninitializedBounds, E as clampValue, K as floor } from '../../Common/Core/Math/index.js';
|
|
2
3
|
import Constants from './VolumeMapper/Constants.js';
|
|
3
4
|
import vtkAbstractMapper3D from './AbstractMapper3D.js';
|
|
4
|
-
import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
|
|
5
5
|
import vtkPiecewiseFunction from '../../Common/DataModel/PiecewiseFunction.js';
|
|
6
6
|
|
|
7
7
|
const {
|
|
8
|
-
BlendMode
|
|
8
|
+
BlendMode,
|
|
9
|
+
FilterMode
|
|
9
10
|
} = Constants;
|
|
10
11
|
function createRadonTransferFunction(firstAbsorbentMaterialHounsfieldValue, firstAbsorbentMaterialAbsorption, maxAbsorbentMaterialHounsfieldValue, maxAbsorbentMaterialAbsorption, outputTransferFunction) {
|
|
11
12
|
let ofun = null;
|
|
@@ -20,7 +21,6 @@ function createRadonTransferFunction(firstAbsorbentMaterialHounsfieldValue, firs
|
|
|
20
21
|
ofun.addPoint(maxAbsorbentMaterialHounsfieldValue, maxAbsorbentMaterialAbsorption);
|
|
21
22
|
return ofun;
|
|
22
23
|
}
|
|
23
|
-
const methodNamesMovedToVolumeProperties = ['getAnisotropy', 'getComputeNormalFromOpacity', 'getFilterMode', 'getFilterModeAsString', 'getGlobalIlluminationReach', 'getIpScalarRange', 'getIpScalarRangeByReference', 'getLAOKernelRadius', 'getLAOKernelSize', 'getLocalAmbientOcclusion', 'getPreferSizeOverAccuracy', 'getVolumetricScatteringBlending', 'setAnisotropy', 'setAverageIPScalarRange', 'setComputeNormalFromOpacity', 'setFilterMode', 'setFilterModeToNormalized', 'setFilterModeToOff', 'setFilterModeToRaw', 'setGlobalIlluminationReach', 'setIpScalarRange', 'setIpScalarRangeFrom', 'setLAOKernelRadius', 'setLAOKernelSize', 'setLocalAmbientOcclusion', 'setPreferSizeOverAccuracy', 'setVolumetricScatteringBlending'];
|
|
24
24
|
|
|
25
25
|
// ----------------------------------------------------------------------------
|
|
26
26
|
// Static API
|
|
@@ -41,12 +41,20 @@ function vtkVolumeMapper(publicAPI, model) {
|
|
|
41
41
|
...publicAPI
|
|
42
42
|
};
|
|
43
43
|
publicAPI.getBounds = () => {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const input = publicAPI.getInputData();
|
|
45
|
+
if (!input) {
|
|
46
|
+
model.bounds = createUninitializedBounds();
|
|
47
|
+
} else {
|
|
48
|
+
if (!model.static) {
|
|
49
|
+
publicAPI.update();
|
|
50
|
+
}
|
|
51
|
+
model.bounds = input.getBounds();
|
|
46
52
|
}
|
|
47
|
-
model.bounds = [...publicAPI.getInputData().getBounds()];
|
|
48
53
|
return model.bounds;
|
|
49
54
|
};
|
|
55
|
+
publicAPI.update = () => {
|
|
56
|
+
publicAPI.getInputData();
|
|
57
|
+
};
|
|
50
58
|
publicAPI.setBlendModeToComposite = () => {
|
|
51
59
|
publicAPI.setBlendMode(BlendMode.COMPOSITE_BLEND);
|
|
52
60
|
};
|
|
@@ -66,23 +74,35 @@ function vtkVolumeMapper(publicAPI, model) {
|
|
|
66
74
|
publicAPI.setBlendMode(BlendMode.RADON_TRANSFORM_BLEND);
|
|
67
75
|
};
|
|
68
76
|
publicAPI.getBlendModeAsString = () => macro.enumToString(BlendMode, model.blendMode);
|
|
77
|
+
publicAPI.setAverageIPScalarRange = (min, max) => {
|
|
78
|
+
console.warn('setAverageIPScalarRange is deprecated use setIpScalarRange');
|
|
79
|
+
publicAPI.setIpScalarRange(min, max);
|
|
80
|
+
};
|
|
81
|
+
publicAPI.getFilterModeAsString = () => macro.enumToString(FilterMode, model.filterMode);
|
|
82
|
+
publicAPI.setFilterModeToOff = () => {
|
|
83
|
+
publicAPI.setFilterMode(FilterMode.OFF);
|
|
84
|
+
};
|
|
85
|
+
publicAPI.setFilterModeToNormalized = () => {
|
|
86
|
+
publicAPI.setFilterMode(FilterMode.NORMALIZED);
|
|
87
|
+
};
|
|
88
|
+
publicAPI.setFilterModeToRaw = () => {
|
|
89
|
+
publicAPI.setFilterMode(FilterMode.RAW);
|
|
90
|
+
};
|
|
91
|
+
publicAPI.setGlobalIlluminationReach = gl => superClass.setGlobalIlluminationReach(clampValue(gl, 0.0, 1.0));
|
|
92
|
+
publicAPI.setVolumetricScatteringBlending = vsb => superClass.setVolumetricScatteringBlending(clampValue(vsb, 0.0, 1.0));
|
|
69
93
|
publicAPI.setVolumeShadowSamplingDistFactor = vsdf => superClass.setVolumeShadowSamplingDistFactor(vsdf >= 1.0 ? vsdf : 1.0);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const removedMethod = () => {
|
|
74
|
-
throw new Error(`The method "volumeMapper.${removedMethodName}()" doesn't exist anymore. ` + `It is a rendering property that has been moved to the volume property. ` + `Replace your code with:\n` + `volumeActor.getProperty().${removedMethodName}()\n`);
|
|
75
|
-
};
|
|
76
|
-
publicAPI[removedMethodName] = removedMethod;
|
|
77
|
-
});
|
|
94
|
+
publicAPI.setAnisotropy = at => superClass.setAnisotropy(clampValue(at, -0.99, 0.99));
|
|
95
|
+
publicAPI.setLAOKernelSize = ks => superClass.setLAOKernelSize(floor(clampValue(ks, 1, 32)));
|
|
96
|
+
publicAPI.setLAOKernelRadius = kr => superClass.setLAOKernelRadius(kr >= 1 ? kr : 1);
|
|
78
97
|
}
|
|
79
98
|
|
|
80
99
|
// ----------------------------------------------------------------------------
|
|
81
100
|
// Object factory
|
|
82
101
|
// ----------------------------------------------------------------------------
|
|
83
102
|
|
|
84
|
-
|
|
85
|
-
|
|
103
|
+
// TODO: what values to use for averageIPScalarRange to get GLSL to use max / min values like [-Math.inf, Math.inf]?
|
|
104
|
+
const defaultValues = initialValues => ({
|
|
105
|
+
bounds: [1, -1, 1, -1, 1, -1],
|
|
86
106
|
sampleDistance: 1.0,
|
|
87
107
|
imageSampleDistance: 1.0,
|
|
88
108
|
maximumSamplesPerRay: 1000,
|
|
@@ -90,16 +110,36 @@ const DEFAULT_VALUES = {
|
|
|
90
110
|
initialInteractionScale: 1.0,
|
|
91
111
|
interactionSampleDistanceFactor: 1.0,
|
|
92
112
|
blendMode: BlendMode.COMPOSITE_BLEND,
|
|
93
|
-
|
|
94
|
-
|
|
113
|
+
ipScalarRange: [-1000000.0, 1000000.0],
|
|
114
|
+
filterMode: FilterMode.OFF,
|
|
115
|
+
// ignored by WebGL so no behavior change
|
|
116
|
+
preferSizeOverAccuracy: false,
|
|
117
|
+
// Whether to use halfFloat representation of float, when it is inaccurate
|
|
118
|
+
computeNormalFromOpacity: false,
|
|
119
|
+
// volume shadow parameters
|
|
120
|
+
volumetricScatteringBlending: 0.0,
|
|
121
|
+
globalIlluminationReach: 0.0,
|
|
122
|
+
volumeShadowSamplingDistFactor: 5.0,
|
|
123
|
+
anisotropy: 0.0,
|
|
124
|
+
// local ambient occlusion
|
|
125
|
+
localAmbientOcclusion: false,
|
|
126
|
+
LAOKernelSize: 15,
|
|
127
|
+
LAOKernelRadius: 7,
|
|
128
|
+
updatedExtents: [],
|
|
129
|
+
colorTextureWidth: 1024,
|
|
130
|
+
opacityTextureWidth: 1024,
|
|
131
|
+
labelOutlineTextureWidth: 1024,
|
|
132
|
+
...initialValues
|
|
133
|
+
});
|
|
95
134
|
|
|
96
135
|
// ----------------------------------------------------------------------------
|
|
97
136
|
|
|
98
137
|
function extend(publicAPI, model) {
|
|
99
138
|
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
100
|
-
Object.assign(model,
|
|
139
|
+
Object.assign(model, defaultValues(initialValues));
|
|
101
140
|
vtkAbstractMapper3D.extend(publicAPI, model, initialValues);
|
|
102
|
-
macro.setGet(publicAPI, model, ['sampleDistance', 'imageSampleDistance', 'maximumSamplesPerRay', 'autoAdjustSampleDistances', 'initialInteractionScale', 'interactionSampleDistanceFactor', 'blendMode', 'volumeShadowSamplingDistFactor']);
|
|
141
|
+
macro.setGet(publicAPI, model, ['sampleDistance', 'imageSampleDistance', 'maximumSamplesPerRay', 'autoAdjustSampleDistances', 'initialInteractionScale', 'interactionSampleDistanceFactor', 'blendMode', 'filterMode', 'preferSizeOverAccuracy', 'computeNormalFromOpacity', 'volumetricScatteringBlending', 'globalIlluminationReach', 'volumeShadowSamplingDistFactor', 'anisotropy', 'localAmbientOcclusion', 'LAOKernelSize', 'LAOKernelRadius', 'updatedExtents', 'colorTextureWidth', 'opacityTextureWidth', 'labelOutlineTextureWidth']);
|
|
142
|
+
macro.setGetArray(publicAPI, model, ['ipScalarRange'], 2);
|
|
103
143
|
macro.event(publicAPI, model, 'lightingActivated');
|
|
104
144
|
|
|
105
145
|
// Object methods
|
|
@@ -10,7 +10,9 @@ export declare enum OpacityMode {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export declare enum ColorMixPreset {
|
|
13
|
-
|
|
13
|
+
// Add a `//VTK::CustomColorMix` tag to the Fragment shader
|
|
14
|
+
// See usage in file `testColorMix` and in function `setColorMixPreset`
|
|
15
|
+
CUSTOM = 0,
|
|
14
16
|
|
|
15
17
|
// Two components preset
|
|
16
18
|
// Out color: sum of colors weighted by opacity
|
|
@@ -21,22 +23,11 @@ export declare enum ColorMixPreset {
|
|
|
21
23
|
// Out color: color of the first component, colorized by second component with an intensity that is the second component's opacity
|
|
22
24
|
// Out opacity: opacity of the first component
|
|
23
25
|
COLORIZE = 2,
|
|
24
|
-
|
|
25
|
-
// Add a `//VTK::CustomColorMix` tag to the Fragment shader
|
|
26
|
-
// See usage in file `testColorMix` and in function `setColorMixPreset`
|
|
27
|
-
CUSTOM = 3,
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export declare enum FilterMode {
|
|
31
|
-
OFF = 0,
|
|
32
|
-
NORMALIZED = 1,
|
|
33
|
-
RAW = 2,
|
|
34
26
|
}
|
|
35
27
|
|
|
36
28
|
declare const _default: {
|
|
37
29
|
InterpolationType: typeof InterpolationType;
|
|
38
30
|
OpacityMode: typeof OpacityMode;
|
|
39
31
|
ColorMixPreset: typeof ColorMixPreset;
|
|
40
|
-
FilterMode: typeof FilterMode;
|
|
41
32
|
};
|
|
42
33
|
export default _default;
|
|
@@ -8,21 +8,14 @@ const OpacityMode = {
|
|
|
8
8
|
PROPORTIONAL: 1
|
|
9
9
|
};
|
|
10
10
|
const ColorMixPreset = {
|
|
11
|
-
|
|
11
|
+
CUSTOM: 0,
|
|
12
12
|
ADDITIVE: 1,
|
|
13
|
-
COLORIZE: 2
|
|
14
|
-
CUSTOM: 3
|
|
15
|
-
};
|
|
16
|
-
const FilterMode = {
|
|
17
|
-
OFF: 0,
|
|
18
|
-
NORMALIZED: 1,
|
|
19
|
-
RAW: 2
|
|
13
|
+
COLORIZE: 2
|
|
20
14
|
};
|
|
21
15
|
var Constants = {
|
|
22
16
|
InterpolationType,
|
|
23
17
|
OpacityMode,
|
|
24
|
-
ColorMixPreset
|
|
25
|
-
FilterMode
|
|
18
|
+
ColorMixPreset
|
|
26
19
|
};
|
|
27
20
|
|
|
28
|
-
export { ColorMixPreset,
|
|
21
|
+
export { ColorMixPreset, InterpolationType, OpacityMode, Constants as default };
|