@kitware/vtk.js 32.6.2 → 33.0.0-beta.2
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 +3 -0
- package/IO/Image.js +1 -3
- package/Interaction/Manipulators/KeyboardCameraManipulator.d.ts +113 -0
- package/Rendering/Core/Actor.d.ts +5 -20
- package/Rendering/Core/Actor.js +5 -68
- package/Rendering/Core/ImageProperty.d.ts +0 -22
- package/Rendering/Core/ImageSlice.d.ts +7 -23
- package/Rendering/Core/ImageSlice.js +9 -68
- package/Rendering/Core/PointPicker.js +1 -4
- package/Rendering/Core/Prop3D.d.ts +39 -2
- package/Rendering/Core/Prop3D.js +81 -2
- package/Rendering/Core/RenderWindowInteractor.d.ts +1 -1
- package/Rendering/Core/Volume.d.ts +5 -20
- package/Rendering/Core/Volume.js +2 -70
- package/Rendering/Core/VolumeMapper/Constants.d.ts +0 -7
- package/Rendering/Core/VolumeMapper/Constants.js +2 -8
- package/Rendering/Core/VolumeMapper.d.ts +16 -140
- package/Rendering/Core/VolumeMapper.js +17 -52
- package/Rendering/Core/VolumeProperty/Constants.d.ts +12 -3
- package/Rendering/Core/VolumeProperty/Constants.js +11 -4
- package/Rendering/Core/VolumeProperty.d.ts +120 -4
- package/Rendering/Core/VolumeProperty.js +49 -4
- package/Rendering/OpenGL/ImageCPRMapper.js +27 -19
- package/Rendering/OpenGL/ImageMapper.js +34 -41
- package/Rendering/OpenGL/ImageResliceMapper.js +261 -172
- package/Rendering/OpenGL/PolyDataMapper.js +1 -8
- package/Rendering/OpenGL/RenderWindow/resourceSharingHelper.d.ts +3 -3
- package/Rendering/OpenGL/RenderWindow/resourceSharingHelper.js +8 -5
- package/Rendering/OpenGL/VolumeMapper.js +710 -772
- package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
- package/Rendering/WebGPU/VolumePassFSQ.js +2 -2
- package/index.d.ts +1 -1
- package/macros2.js +1 -1
- package/package.json +1 -1
- package/IO/Image/TGAReader/Constants.js +0 -28
- package/IO/Image/TGAReader.d.ts +0 -121
- package/IO/Image/TGAReader.js +0 -418
package/Rendering/Core/Prop3D.js
CHANGED
|
@@ -121,6 +121,54 @@ function vtkProp3D(publicAPI, model) {
|
|
|
121
121
|
model.matrixMTime.modified();
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
|
+
publicAPI.getBoundsByReference = () => {
|
|
125
|
+
if (model.mapper === null) {
|
|
126
|
+
return model.bounds;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Check for the special case when the mapper's bounds are unknown
|
|
130
|
+
const bds = model.mapper.getBounds();
|
|
131
|
+
if (!bds || bds.length !== 6) {
|
|
132
|
+
return bds;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Check for the special case when the actor is empty.
|
|
136
|
+
if (bds[0] > bds[1]) {
|
|
137
|
+
// No need to copy bds, a new array is created when calling getBounds()
|
|
138
|
+
model.mapperBounds = bds;
|
|
139
|
+
model.bounds = [...vtkBoundingBox.INIT_BOUNDS];
|
|
140
|
+
model.boundsMTime.modified();
|
|
141
|
+
return bds;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Check if we have cached values for these bounds - we cache the
|
|
145
|
+
// values returned by model.mapper.getBounds() and we store the time
|
|
146
|
+
// of caching. If the values returned this time are different, or
|
|
147
|
+
// the modified time of this class is newer than the cached time,
|
|
148
|
+
// then we need to rebuild.
|
|
149
|
+
if (!model.mapperBounds || !bds.every((_, i) => bds[i] === model.mapperBounds[i]) || publicAPI.getMTime() > model.boundsMTime.getMTime()) {
|
|
150
|
+
macro.vtkDebugMacro('Recomputing bounds...');
|
|
151
|
+
// No need to copy bds, a new array is created when calling getBounds()
|
|
152
|
+
model.mapperBounds = bds;
|
|
153
|
+
|
|
154
|
+
// Compute actor bounds from matrix and mapper bounds
|
|
155
|
+
publicAPI.computeMatrix();
|
|
156
|
+
const transposedMatrix = new Float64Array(16);
|
|
157
|
+
mat4.transpose(transposedMatrix, model.matrix);
|
|
158
|
+
vtkBoundingBox.transformBounds(bds, transposedMatrix, model.bounds);
|
|
159
|
+
model.boundsMTime.modified();
|
|
160
|
+
}
|
|
161
|
+
return model.bounds;
|
|
162
|
+
};
|
|
163
|
+
publicAPI.getBounds = () => {
|
|
164
|
+
const bounds = publicAPI.getBoundsByReference();
|
|
165
|
+
// Handle case when bounds are not iterable (for example null or undefined)
|
|
166
|
+
try {
|
|
167
|
+
return [...bounds];
|
|
168
|
+
} catch {
|
|
169
|
+
return bounds;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
124
172
|
publicAPI.getCenter = () => vtkBoundingBox.getCenter(model.bounds);
|
|
125
173
|
publicAPI.getLength = () => vtkBoundingBox.getLength(model.bounds);
|
|
126
174
|
publicAPI.getXRange = () => vtkBoundingBox.getXRange(model.bounds);
|
|
@@ -131,6 +179,35 @@ function vtkProp3D(publicAPI, model) {
|
|
|
131
179
|
publicAPI.computeMatrix();
|
|
132
180
|
}
|
|
133
181
|
publicAPI.onModified(updateIdentityFlag);
|
|
182
|
+
publicAPI.getProperty = function () {
|
|
183
|
+
let mapperInputPort = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
184
|
+
if (model.properties[mapperInputPort] == null) {
|
|
185
|
+
model.properties[mapperInputPort] = publicAPI.makeProperty?.();
|
|
186
|
+
}
|
|
187
|
+
return model.properties[mapperInputPort];
|
|
188
|
+
};
|
|
189
|
+
publicAPI.setProperty = (firstArg, secondArg) => {
|
|
190
|
+
// Two options for argument layout:
|
|
191
|
+
// - (mapperInputPort, property)
|
|
192
|
+
// - (property)
|
|
193
|
+
const useInputPortArgument = Number.isInteger(firstArg);
|
|
194
|
+
const [mapperInputPort, property] = useInputPortArgument ? [firstArg, secondArg] : [0, firstArg];
|
|
195
|
+
if (model.properties[mapperInputPort] === property) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
model.properties[mapperInputPort] = property;
|
|
199
|
+
return true;
|
|
200
|
+
};
|
|
201
|
+
publicAPI.getMTime = () => {
|
|
202
|
+
let mt = model.mtime;
|
|
203
|
+
model.properties.forEach(property => {
|
|
204
|
+
if (property !== null) {
|
|
205
|
+
const time = property.getMTime();
|
|
206
|
+
mt = time > mt ? time : mt;
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
return mt;
|
|
210
|
+
};
|
|
134
211
|
}
|
|
135
212
|
|
|
136
213
|
// ----------------------------------------------------------------------------
|
|
@@ -143,7 +220,8 @@ const DEFAULT_VALUES = {
|
|
|
143
220
|
orientation: [0, 0, 0],
|
|
144
221
|
rotation: null,
|
|
145
222
|
scale: [1, 1, 1],
|
|
146
|
-
bounds: [
|
|
223
|
+
bounds: [...vtkBoundingBox.INIT_BOUNDS],
|
|
224
|
+
properties: [],
|
|
147
225
|
userMatrix: null,
|
|
148
226
|
userMatrixMTime: null,
|
|
149
227
|
cachedProp3D: null,
|
|
@@ -163,9 +241,10 @@ function extend(publicAPI, model) {
|
|
|
163
241
|
macro.obj(model.matrixMTime);
|
|
164
242
|
|
|
165
243
|
// Build VTK API
|
|
166
|
-
macro.get(publicAPI, model, ['
|
|
244
|
+
macro.get(publicAPI, model, ['isIdentity']);
|
|
167
245
|
macro.getArray(publicAPI, model, ['orientation']);
|
|
168
246
|
macro.setGetArray(publicAPI, model, ['origin', 'position', 'scale'], 3);
|
|
247
|
+
macro.setGet(publicAPI, model, ['properties']);
|
|
169
248
|
|
|
170
249
|
// Object internal instance
|
|
171
250
|
model.matrix = mat4.identity(new Float64Array(16));
|
|
@@ -29,22 +29,6 @@ export interface vtkVolume extends vtkProp3D {
|
|
|
29
29
|
*/
|
|
30
30
|
getVolumes(): vtkVolume[];
|
|
31
31
|
|
|
32
|
-
/**
|
|
33
|
-
* Get the volume property
|
|
34
|
-
*/
|
|
35
|
-
getProperty(): vtkVolumeProperty;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Get the bounds for this mapper as [xmin, xmax, ymin, ymax,zmin, zmax].
|
|
39
|
-
* @return {Bounds} The bounds for the mapper.
|
|
40
|
-
*/
|
|
41
|
-
getBounds(): Bounds;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Get the bounds as [xmin, xmax, ymin, ymax, zmin, zmax].
|
|
45
|
-
*/
|
|
46
|
-
getBoundsByReference(): Bounds;
|
|
47
|
-
|
|
48
32
|
/**
|
|
49
33
|
* Get the `Modified Time` which is a monotonic increasing integer
|
|
50
34
|
* global for all vtkObjects.
|
|
@@ -75,11 +59,12 @@ export interface vtkVolume extends vtkProp3D {
|
|
|
75
59
|
*/
|
|
76
60
|
setMapper(mapper: vtkVolumeMapper): boolean;
|
|
77
61
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
62
|
+
// Inherited from vtkProp3D, but takes a vtkVolumeProperty instead of a generic vtkObject
|
|
63
|
+
getProperty(mapperInputPort?: number): vtkVolumeProperty;
|
|
64
|
+
getProperties(): vtkVolumeProperty[];
|
|
65
|
+
setProperty(mapperInputPort: number, property: vtkVolumeProperty): boolean;
|
|
82
66
|
setProperty(property: vtkVolumeProperty): boolean;
|
|
67
|
+
setProperties(properties: vtkVolumeProperty[]): boolean;
|
|
83
68
|
}
|
|
84
69
|
|
|
85
70
|
/**
|
package/Rendering/Core/Volume.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import { mat4, vec3 } from 'gl-matrix';
|
|
2
1
|
import { m as macro } from '../../macros2.js';
|
|
3
|
-
import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
|
|
4
2
|
import vtkProp3D from './Prop3D.js';
|
|
5
3
|
import vtkVolumeProperty from './VolumeProperty.js';
|
|
6
4
|
|
|
7
|
-
const {
|
|
8
|
-
vtkDebugMacro
|
|
9
|
-
} = macro;
|
|
10
|
-
|
|
11
5
|
// ----------------------------------------------------------------------------
|
|
12
6
|
// vtkVolume methods
|
|
13
7
|
// ----------------------------------------------------------------------------
|
|
@@ -15,66 +9,8 @@ const {
|
|
|
15
9
|
function vtkVolume(publicAPI, model) {
|
|
16
10
|
// Set our className
|
|
17
11
|
model.classHierarchy.push('vtkVolume');
|
|
18
|
-
publicAPI.getVolumes = () => publicAPI;
|
|
12
|
+
publicAPI.getVolumes = () => [publicAPI];
|
|
19
13
|
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
|
-
};
|
|
78
14
|
publicAPI.getRedrawMTime = () => {
|
|
79
15
|
let mt = model.mtime;
|
|
80
16
|
if (model.mapper !== null) {
|
|
@@ -96,9 +32,7 @@ function vtkVolume(publicAPI, model) {
|
|
|
96
32
|
// ----------------------------------------------------------------------------
|
|
97
33
|
|
|
98
34
|
const DEFAULT_VALUES = {
|
|
99
|
-
mapper: null
|
|
100
|
-
property: null,
|
|
101
|
-
bounds: [1, -1, 1, -1, 1, -1]
|
|
35
|
+
mapper: null
|
|
102
36
|
};
|
|
103
37
|
|
|
104
38
|
// ----------------------------------------------------------------------------
|
|
@@ -115,9 +49,7 @@ function extend(publicAPI, model) {
|
|
|
115
49
|
macro.obj(model.boundsMTime);
|
|
116
50
|
|
|
117
51
|
// Build VTK API
|
|
118
|
-
macro.set(publicAPI, model, ['property']);
|
|
119
52
|
macro.setGet(publicAPI, model, ['mapper']);
|
|
120
|
-
macro.getArray(publicAPI, model, ['bounds'], 6);
|
|
121
53
|
|
|
122
54
|
// Object methods
|
|
123
55
|
vtkVolume(publicAPI, model);
|
|
@@ -8,14 +8,7 @@ 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
|
-
|
|
17
11
|
declare const _default: {
|
|
18
12
|
BlendMode: typeof BlendMode;
|
|
19
|
-
FilterMode: typeof FilterMode;
|
|
20
13
|
};
|
|
21
14
|
export default _default;
|
|
@@ -7,14 +7,8 @@ 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
|
-
};
|
|
15
10
|
var Constants = {
|
|
16
|
-
BlendMode
|
|
17
|
-
FilterMode
|
|
11
|
+
BlendMode
|
|
18
12
|
};
|
|
19
13
|
|
|
20
|
-
export { BlendMode,
|
|
14
|
+
export { BlendMode, Constants as default };
|
|
@@ -1,29 +1,21 @@
|
|
|
1
1
|
import vtkPiecewiseFunction from './../../Common/DataModel/PiecewiseFunction';
|
|
2
|
-
import { Bounds
|
|
2
|
+
import { Bounds } from './../../types';
|
|
3
3
|
import vtkAbstractMapper3D, {
|
|
4
4
|
IAbstractMapper3DInitialValues,
|
|
5
5
|
} from './AbstractMapper3D';
|
|
6
|
-
import { BlendMode
|
|
6
|
+
import { BlendMode } from './VolumeMapper/Constants';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
*/
|
|
11
11
|
export interface IVolumeMapperInitialValues
|
|
12
12
|
extends IAbstractMapper3DInitialValues {
|
|
13
|
-
anisotropy?: number;
|
|
14
13
|
autoAdjustSampleDistances?: boolean;
|
|
15
|
-
averageIPScalarRange?: Range;
|
|
16
14
|
blendMode?: BlendMode;
|
|
17
15
|
bounds?: Bounds;
|
|
18
|
-
computeNormalFromOpacity?: boolean;
|
|
19
|
-
getVolumeShadowSamplingDistFactor?: number;
|
|
20
|
-
globalIlluminationReach?: number;
|
|
21
|
-
imageSampleDistance?: number;
|
|
22
|
-
localAmbientOcclusion?: boolean;
|
|
23
16
|
maximumSamplesPerRay?: number;
|
|
24
17
|
sampleDistance?: number;
|
|
25
|
-
|
|
26
|
-
LAOKernelSize?: number;
|
|
18
|
+
volumeShadowSamplingDistFactor?: number;
|
|
27
19
|
}
|
|
28
20
|
|
|
29
21
|
export interface vtkVolumeMapper extends vtkAbstractMapper3D {
|
|
@@ -49,6 +41,12 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D {
|
|
|
49
41
|
*/
|
|
50
42
|
getSampleDistance(): number;
|
|
51
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Get the multipler for volume shadow sampling distance
|
|
46
|
+
* @default 5.0
|
|
47
|
+
*/
|
|
48
|
+
getVolumeShadowSamplingDistFactor(): number;
|
|
49
|
+
|
|
52
50
|
/**
|
|
53
51
|
* Sampling distance in the XY image dimensions.
|
|
54
52
|
* Default value of 1 meaning 1 ray cast per pixel. If set to 0.5, 4 rays will be cast per pixel.
|
|
@@ -84,71 +82,6 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D {
|
|
|
84
82
|
*/
|
|
85
83
|
getInteractionSampleDistanceFactor(): number;
|
|
86
84
|
|
|
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
|
-
|
|
152
85
|
/**
|
|
153
86
|
* Set blend mode to COMPOSITE_BLEND
|
|
154
87
|
* @param {BlendMode} blendMode
|
|
@@ -186,6 +119,13 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D {
|
|
|
186
119
|
*/
|
|
187
120
|
setSampleDistance(sampleDistance: number): boolean;
|
|
188
121
|
|
|
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
|
+
|
|
189
129
|
/**
|
|
190
130
|
*
|
|
191
131
|
* @param imageSampleDistance
|
|
@@ -218,69 +158,6 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D {
|
|
|
218
158
|
interactionSampleDistanceFactor: number
|
|
219
159
|
): boolean;
|
|
220
160
|
|
|
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
161
|
/**
|
|
285
162
|
*
|
|
286
163
|
*/
|
|
@@ -346,6 +223,5 @@ export declare const vtkVolumeMapper: {
|
|
|
346
223
|
newInstance: typeof newInstance;
|
|
347
224
|
extend: typeof extend;
|
|
348
225
|
BlendMode: typeof BlendMode;
|
|
349
|
-
FilterMode: typeof FilterMode;
|
|
350
226
|
};
|
|
351
227
|
export default vtkVolumeMapper;
|
|
@@ -1,12 +1,11 @@
|
|
|
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';
|
|
3
2
|
import Constants from './VolumeMapper/Constants.js';
|
|
4
3
|
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
|
|
9
|
-
FilterMode
|
|
8
|
+
BlendMode
|
|
10
9
|
} = Constants;
|
|
11
10
|
function createRadonTransferFunction(firstAbsorbentMaterialHounsfieldValue, firstAbsorbentMaterialAbsorption, maxAbsorbentMaterialHounsfieldValue, maxAbsorbentMaterialAbsorption, outputTransferFunction) {
|
|
12
11
|
let ofun = null;
|
|
@@ -21,6 +20,7 @@ function createRadonTransferFunction(firstAbsorbentMaterialHounsfieldValue, firs
|
|
|
21
20
|
ofun.addPoint(maxAbsorbentMaterialHounsfieldValue, maxAbsorbentMaterialAbsorption);
|
|
22
21
|
return ofun;
|
|
23
22
|
}
|
|
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,20 +41,12 @@ function vtkVolumeMapper(publicAPI, model) {
|
|
|
41
41
|
...publicAPI
|
|
42
42
|
};
|
|
43
43
|
publicAPI.getBounds = () => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
model.bounds = createUninitializedBounds();
|
|
47
|
-
} else {
|
|
48
|
-
if (!model.static) {
|
|
49
|
-
publicAPI.update();
|
|
50
|
-
}
|
|
51
|
-
model.bounds = input.getBounds();
|
|
44
|
+
if (!model.static) {
|
|
45
|
+
publicAPI.update();
|
|
52
46
|
}
|
|
47
|
+
model.bounds = [...publicAPI.getInputData().getBounds()];
|
|
53
48
|
return model.bounds;
|
|
54
49
|
};
|
|
55
|
-
publicAPI.update = () => {
|
|
56
|
-
publicAPI.getInputData();
|
|
57
|
-
};
|
|
58
50
|
publicAPI.setBlendModeToComposite = () => {
|
|
59
51
|
publicAPI.setBlendMode(BlendMode.COMPOSITE_BLEND);
|
|
60
52
|
};
|
|
@@ -74,35 +66,23 @@ function vtkVolumeMapper(publicAPI, model) {
|
|
|
74
66
|
publicAPI.setBlendMode(BlendMode.RADON_TRANSFORM_BLEND);
|
|
75
67
|
};
|
|
76
68
|
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));
|
|
93
69
|
publicAPI.setVolumeShadowSamplingDistFactor = vsdf => superClass.setVolumeShadowSamplingDistFactor(vsdf >= 1.0 ? vsdf : 1.0);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
70
|
+
|
|
71
|
+
// Instead of a "undefined is not a function" error, give more context and advice for these widely used methods
|
|
72
|
+
methodNamesMovedToVolumeProperties.forEach(removedMethodName => {
|
|
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
|
+
});
|
|
97
78
|
}
|
|
98
79
|
|
|
99
80
|
// ----------------------------------------------------------------------------
|
|
100
81
|
// Object factory
|
|
101
82
|
// ----------------------------------------------------------------------------
|
|
102
83
|
|
|
103
|
-
// TODO: what values to use for averageIPScalarRange to get GLSL to use max / min values like [-Math.inf, Math.inf]?
|
|
104
84
|
const DEFAULT_VALUES = {
|
|
105
|
-
bounds: [
|
|
85
|
+
bounds: [...vtkBoundingBox.INIT_BOUNDS],
|
|
106
86
|
sampleDistance: 1.0,
|
|
107
87
|
imageSampleDistance: 1.0,
|
|
108
88
|
maximumSamplesPerRay: 1000,
|
|
@@ -110,21 +90,7 @@ const DEFAULT_VALUES = {
|
|
|
110
90
|
initialInteractionScale: 1.0,
|
|
111
91
|
interactionSampleDistanceFactor: 1.0,
|
|
112
92
|
blendMode: BlendMode.COMPOSITE_BLEND,
|
|
113
|
-
|
|
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
|
|
93
|
+
volumeShadowSamplingDistFactor: 5.0
|
|
128
94
|
};
|
|
129
95
|
|
|
130
96
|
// ----------------------------------------------------------------------------
|
|
@@ -133,8 +99,7 @@ function extend(publicAPI, model) {
|
|
|
133
99
|
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
134
100
|
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
135
101
|
vtkAbstractMapper3D.extend(publicAPI, model, initialValues);
|
|
136
|
-
macro.setGet(publicAPI, model, ['sampleDistance', 'imageSampleDistance', 'maximumSamplesPerRay', 'autoAdjustSampleDistances', 'initialInteractionScale', 'interactionSampleDistanceFactor', 'blendMode', '
|
|
137
|
-
macro.setGetArray(publicAPI, model, ['ipScalarRange'], 2);
|
|
102
|
+
macro.setGet(publicAPI, model, ['sampleDistance', 'imageSampleDistance', 'maximumSamplesPerRay', 'autoAdjustSampleDistances', 'initialInteractionScale', 'interactionSampleDistanceFactor', 'blendMode', 'volumeShadowSamplingDistFactor']);
|
|
138
103
|
macro.event(publicAPI, model, 'lightingActivated');
|
|
139
104
|
|
|
140
105
|
// Object methods
|
|
@@ -10,9 +10,7 @@ export declare enum OpacityMode {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export declare enum ColorMixPreset {
|
|
13
|
-
|
|
14
|
-
// See usage in file `testColorMix` and in function `setColorMixPreset`
|
|
15
|
-
CUSTOM = 0,
|
|
13
|
+
DEFAULT = 0,
|
|
16
14
|
|
|
17
15
|
// Two components preset
|
|
18
16
|
// Out color: sum of colors weighted by opacity
|
|
@@ -23,11 +21,22 @@ export declare enum ColorMixPreset {
|
|
|
23
21
|
// Out color: color of the first component, colorized by second component with an intensity that is the second component's opacity
|
|
24
22
|
// Out opacity: opacity of the first component
|
|
25
23
|
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,
|
|
26
34
|
}
|
|
27
35
|
|
|
28
36
|
declare const _default: {
|
|
29
37
|
InterpolationType: typeof InterpolationType;
|
|
30
38
|
OpacityMode: typeof OpacityMode;
|
|
31
39
|
ColorMixPreset: typeof ColorMixPreset;
|
|
40
|
+
FilterMode: typeof FilterMode;
|
|
32
41
|
};
|
|
33
42
|
export default _default;
|
|
@@ -8,14 +8,21 @@ const OpacityMode = {
|
|
|
8
8
|
PROPORTIONAL: 1
|
|
9
9
|
};
|
|
10
10
|
const ColorMixPreset = {
|
|
11
|
-
|
|
11
|
+
DEFAULT: 0,
|
|
12
12
|
ADDITIVE: 1,
|
|
13
|
-
COLORIZE: 2
|
|
13
|
+
COLORIZE: 2,
|
|
14
|
+
CUSTOM: 3
|
|
15
|
+
};
|
|
16
|
+
const FilterMode = {
|
|
17
|
+
OFF: 0,
|
|
18
|
+
NORMALIZED: 1,
|
|
19
|
+
RAW: 2
|
|
14
20
|
};
|
|
15
21
|
var Constants = {
|
|
16
22
|
InterpolationType,
|
|
17
23
|
OpacityMode,
|
|
18
|
-
ColorMixPreset
|
|
24
|
+
ColorMixPreset,
|
|
25
|
+
FilterMode
|
|
19
26
|
};
|
|
20
27
|
|
|
21
|
-
export { ColorMixPreset, InterpolationType, OpacityMode, Constants as default };
|
|
28
|
+
export { ColorMixPreset, FilterMode, InterpolationType, OpacityMode, Constants as default };
|