@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/BREAKING_CHANGES.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
## From 32.x to 33
|
|
2
|
+
|
|
3
|
+
- **vtkMapper**: many properties have moved to `vtkVolumeProperty`. The full list of changed methods is: `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`.
|
|
1
4
|
## From 31.x to 32
|
|
2
5
|
|
|
3
6
|
- **vtkMapper**: remove `mapScalarsToTexture` from the public API. The function becomes protected and its API changes. This shouldn't cause any issue in most cases.
|
package/IO/Image.js
CHANGED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Vector3 } from './../../types';
|
|
2
|
+
import { vtkObject } from './../../interfaces';
|
|
3
|
+
import vtkCompositeKeyboardManipulator from './CompositeKeyboardManipulator';
|
|
4
|
+
import vtkRenderWindowInteractor from './../../Rendering/Core/RenderWindowInteractor';
|
|
5
|
+
import vtkCamera from './../../Rendering/Core/Camera';
|
|
6
|
+
import vtkRenderer from './../../Rendering/Core/Renderer';
|
|
7
|
+
|
|
8
|
+
export interface vtkKeyboardCameraManipulator
|
|
9
|
+
extends vtkObject,
|
|
10
|
+
vtkCompositeKeyboardManipulator {
|
|
11
|
+
/**
|
|
12
|
+
* Returns whether a movement is ongoing.
|
|
13
|
+
*/
|
|
14
|
+
inMotion(): boolean;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Reset the movement speed to be proportional to the longest length of the renderer's bounds.
|
|
18
|
+
*/
|
|
19
|
+
resetMovementSpeed(): void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Initialize a movement of the current camera.
|
|
23
|
+
*/
|
|
24
|
+
startMovement(): void;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Cancel any ongoing camera movement.
|
|
28
|
+
*/
|
|
29
|
+
endMovement(): void;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Update active camera direction, depending on currently pressed keys.
|
|
33
|
+
*/
|
|
34
|
+
calculateCurrentDirection(): void;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Returns the direction vector of the given camera for the given key.
|
|
38
|
+
* @param key the movedkey
|
|
39
|
+
* @param camera the camera
|
|
40
|
+
*/
|
|
41
|
+
getDirectionFromKey(key: KeyboardEvent['key'], camera: vtkCamera): Vector3;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Moves the given camera, in the given direction, at the given speed.
|
|
45
|
+
* @param camera the moved camera
|
|
46
|
+
* @param direction the direction of the movemnt
|
|
47
|
+
* @param speed the speed
|
|
48
|
+
*/
|
|
49
|
+
moveCamera(camera: vtkCamera, direction: Vector3, speed: number): void;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Handles a keypress event.
|
|
53
|
+
* @param interactor the interactor
|
|
54
|
+
* @param renderer the renderer
|
|
55
|
+
* @param key the key
|
|
56
|
+
*/
|
|
57
|
+
onKeyPress(
|
|
58
|
+
interactor: vtkRenderWindowInteractor,
|
|
59
|
+
renderer: vtkRenderer,
|
|
60
|
+
key: KeyboardEvent['key']
|
|
61
|
+
): void;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Handles a keydown event.
|
|
65
|
+
* @param interactor the interactor
|
|
66
|
+
* @param renderer the renderer
|
|
67
|
+
* @param key the key
|
|
68
|
+
*/
|
|
69
|
+
onKeyDown(
|
|
70
|
+
interactor: vtkRenderWindowInteractor,
|
|
71
|
+
renderer: vtkRenderer,
|
|
72
|
+
key: KeyboardEvent['key']
|
|
73
|
+
): void;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Handles a keyup event.
|
|
77
|
+
* @param interactor the interactor
|
|
78
|
+
* @param renderer the renderer
|
|
79
|
+
* @param key the key
|
|
80
|
+
*/
|
|
81
|
+
onKeyUp(
|
|
82
|
+
interactor: vtkRenderWindowInteractor,
|
|
83
|
+
renderer: vtkRenderer,
|
|
84
|
+
key: KeyboardEvent['key']
|
|
85
|
+
): void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface IKeyboardCameraManipulatorInitialValues {
|
|
89
|
+
movementSpeed?: number;
|
|
90
|
+
moveForwardKeys?: KeyboardEvent['key'][];
|
|
91
|
+
moveLeftKeys?: KeyboardEvent['key'][];
|
|
92
|
+
moveBackwardKeys?: KeyboardEvent['key'][];
|
|
93
|
+
moveRightKeys?: KeyboardEvent['key'][];
|
|
94
|
+
moveUpKeys?: KeyboardEvent['key'][];
|
|
95
|
+
moveDownKeys?: KeyboardEvent['key'][];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function newInstance(
|
|
99
|
+
initialValues?: IKeyboardCameraManipulatorInitialValues
|
|
100
|
+
): vtkKeyboardCameraManipulator;
|
|
101
|
+
|
|
102
|
+
export function extend(
|
|
103
|
+
publicAPI: object,
|
|
104
|
+
model: object,
|
|
105
|
+
initialValues?: IKeyboardCameraManipulatorInitialValues
|
|
106
|
+
): void;
|
|
107
|
+
|
|
108
|
+
export const vtkKeyboardCameraManipulator: {
|
|
109
|
+
newInstance: typeof newInstance;
|
|
110
|
+
extend: typeof extend;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export default vtkKeyboardCameraManipulator;
|
|
@@ -36,12 +36,6 @@ export interface vtkActor extends vtkProp3D {
|
|
|
36
36
|
*/
|
|
37
37
|
getBackfaceProperty(): vtkProperty;
|
|
38
38
|
|
|
39
|
-
/**
|
|
40
|
-
* Get the bounds for this mapper as [xmin, xmax, ymin, ymax,zmin, zmax].
|
|
41
|
-
* @return {Bounds} The bounds for the mapper.
|
|
42
|
-
*/
|
|
43
|
-
getBounds(): Bounds;
|
|
44
|
-
|
|
45
39
|
/**
|
|
46
40
|
* Check whether the opaque is forced or not.
|
|
47
41
|
*/
|
|
@@ -63,16 +57,6 @@ export interface vtkActor extends vtkProp3D {
|
|
|
63
57
|
*/
|
|
64
58
|
getMapper(): Nullable<vtkMapper>;
|
|
65
59
|
|
|
66
|
-
/**
|
|
67
|
-
* Get the property object that controls this actors surface
|
|
68
|
-
* properties. This should be an instance of a vtkProperty object. Every
|
|
69
|
-
* actor must have a property associated with it. If one isn’t specified,
|
|
70
|
-
* then one will be generated automatically. Multiple actors can share one
|
|
71
|
-
* property object.
|
|
72
|
-
* @return {vtkProperty} The property object
|
|
73
|
-
*/
|
|
74
|
-
getProperty(): vtkProperty;
|
|
75
|
-
|
|
76
60
|
/**
|
|
77
61
|
* Check whether if the actor supports selection
|
|
78
62
|
* @return {Boolean} true if the actor support selection.
|
|
@@ -111,11 +95,12 @@ export interface vtkActor extends vtkProp3D {
|
|
|
111
95
|
*/
|
|
112
96
|
setMapper(mapper: vtkMapper): boolean;
|
|
113
97
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
98
|
+
// Inherited from vtkProp3D, but takes a vtkProperty instead of a generic vtkObject
|
|
99
|
+
getProperty(mapperInputPort?: number): vtkProperty;
|
|
100
|
+
getProperties(): vtkProperty[];
|
|
101
|
+
setProperty(mapperInputPort: number, property: vtkProperty): boolean;
|
|
118
102
|
setProperty(property: vtkProperty): boolean;
|
|
103
|
+
setProperties(properties: vtkProperty[]): boolean;
|
|
119
104
|
}
|
|
120
105
|
|
|
121
106
|
/**
|
package/Rendering/Core/Actor.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 vtkProperty from './Property.js';
|
|
6
4
|
|
|
7
|
-
const {
|
|
8
|
-
vtkDebugMacro
|
|
9
|
-
} = macro;
|
|
10
|
-
|
|
11
5
|
// ----------------------------------------------------------------------------
|
|
12
6
|
// vtkActor methods
|
|
13
7
|
// ----------------------------------------------------------------------------
|
|
@@ -29,11 +23,11 @@ function vtkActor(publicAPI, model) {
|
|
|
29
23
|
return false;
|
|
30
24
|
}
|
|
31
25
|
// make sure we have a property
|
|
32
|
-
if (!model.
|
|
26
|
+
if (!model.properties[0]) {
|
|
33
27
|
// force creation of a property
|
|
34
28
|
publicAPI.getProperty();
|
|
35
29
|
}
|
|
36
|
-
let isOpaque = model.
|
|
30
|
+
let isOpaque = model.properties[0].getOpacity() >= 1.0;
|
|
37
31
|
|
|
38
32
|
// are we using an opaque texture, if any?
|
|
39
33
|
isOpaque = isOpaque && (!model.texture || !model.texture.isTranslucent());
|
|
@@ -47,71 +41,17 @@ function vtkActor(publicAPI, model) {
|
|
|
47
41
|
return false;
|
|
48
42
|
}
|
|
49
43
|
// make sure we have a property
|
|
50
|
-
if (model.
|
|
44
|
+
if (!model.properties[0]) {
|
|
51
45
|
// force creation of a property
|
|
52
|
-
publicAPI.
|
|
46
|
+
publicAPI.getProperty();
|
|
53
47
|
}
|
|
54
48
|
|
|
55
49
|
// is this actor opaque ?
|
|
56
50
|
return !publicAPI.getIsOpaque();
|
|
57
51
|
};
|
|
58
52
|
publicAPI.makeProperty = vtkProperty.newInstance;
|
|
59
|
-
publicAPI.getProperty = () => {
|
|
60
|
-
if (model.property === null) {
|
|
61
|
-
model.property = publicAPI.makeProperty();
|
|
62
|
-
}
|
|
63
|
-
return model.property;
|
|
64
|
-
};
|
|
65
|
-
publicAPI.getBounds = () => {
|
|
66
|
-
if (model.mapper === null) {
|
|
67
|
-
return model.bounds;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Check for the special case when the mapper's bounds are unknown
|
|
71
|
-
const bds = model.mapper.getBounds();
|
|
72
|
-
if (!bds || bds.length !== 6) {
|
|
73
|
-
return bds;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Check for the special case when the actor is empty.
|
|
77
|
-
if (bds[0] > bds[1]) {
|
|
78
|
-
model.mapperBounds = bds.concat(); // copy the mapper's bounds
|
|
79
|
-
model.bounds = [1, -1, 1, -1, 1, -1];
|
|
80
|
-
model.boundsMTime.modified();
|
|
81
|
-
return bds;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Check if we have cached values for these bounds - we cache the
|
|
85
|
-
// values returned by model.mapper.getBounds() and we store the time
|
|
86
|
-
// of caching. If the values returned this time are different, or
|
|
87
|
-
// the modified time of this class is newer than the cached time,
|
|
88
|
-
// then we need to rebuild.
|
|
89
|
-
if (!model.mapperBounds || bds[0] !== model.mapperBounds[0] || bds[1] !== model.mapperBounds[1] || bds[2] !== model.mapperBounds[2] || bds[3] !== model.mapperBounds[3] || bds[4] !== model.mapperBounds[4] || bds[5] !== model.mapperBounds[5] || publicAPI.getMTime() > model.boundsMTime.getMTime()) {
|
|
90
|
-
vtkDebugMacro('Recomputing bounds...');
|
|
91
|
-
model.mapperBounds = bds.concat(); // copy the mapper's bounds
|
|
92
|
-
const bbox = [];
|
|
93
|
-
vtkBoundingBox.getCorners(bds, bbox);
|
|
94
|
-
publicAPI.computeMatrix();
|
|
95
|
-
const tmp4 = new Float64Array(16);
|
|
96
|
-
mat4.transpose(tmp4, model.matrix);
|
|
97
|
-
bbox.forEach(pt => vec3.transformMat4(pt, pt, tmp4));
|
|
98
|
-
|
|
99
|
-
/* eslint-disable no-multi-assign */
|
|
100
|
-
model.bounds[0] = model.bounds[2] = model.bounds[4] = Number.MAX_VALUE;
|
|
101
|
-
model.bounds[1] = model.bounds[3] = model.bounds[5] = -Number.MAX_VALUE;
|
|
102
|
-
/* eslint-enable no-multi-assign */
|
|
103
|
-
|
|
104
|
-
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));
|
|
105
|
-
model.boundsMTime.modified();
|
|
106
|
-
}
|
|
107
|
-
return model.bounds;
|
|
108
|
-
};
|
|
109
53
|
publicAPI.getMTime = () => {
|
|
110
54
|
let mt = superClass.getMTime();
|
|
111
|
-
if (model.property !== null) {
|
|
112
|
-
const time = model.property.getMTime();
|
|
113
|
-
mt = time > mt ? time : mt;
|
|
114
|
-
}
|
|
115
55
|
if (model.backfaceProperty !== null) {
|
|
116
56
|
const time = model.backfaceProperty.getMTime();
|
|
117
57
|
mt = time > mt ? time : mt;
|
|
@@ -146,11 +86,9 @@ function vtkActor(publicAPI, model) {
|
|
|
146
86
|
|
|
147
87
|
const DEFAULT_VALUES = {
|
|
148
88
|
mapper: null,
|
|
149
|
-
property: null,
|
|
150
89
|
backfaceProperty: null,
|
|
151
90
|
forceOpaque: false,
|
|
152
|
-
forceTranslucent: false
|
|
153
|
-
bounds: [1, -1, 1, -1, 1, -1]
|
|
91
|
+
forceTranslucent: false
|
|
154
92
|
};
|
|
155
93
|
|
|
156
94
|
// ----------------------------------------------------------------------------
|
|
@@ -167,7 +105,6 @@ function extend(publicAPI, model) {
|
|
|
167
105
|
macro.obj(model.boundsMTime);
|
|
168
106
|
|
|
169
107
|
// Build VTK API
|
|
170
|
-
macro.set(publicAPI, model, ['property']);
|
|
171
108
|
macro.setGet(publicAPI, model, ['backfaceProperty', 'forceOpaque', 'forceTranslucent', 'mapper']);
|
|
172
109
|
|
|
173
110
|
// Object methods
|
|
@@ -94,28 +94,6 @@ export interface vtkImageProperty extends vtkObject {
|
|
|
94
94
|
*/
|
|
95
95
|
getScalarOpacity(idx?: number): vtkPiecewiseFunction;
|
|
96
96
|
|
|
97
|
-
/**
|
|
98
|
-
* Enable label outline rendering.
|
|
99
|
-
* @param {Boolean} useLabelOutline
|
|
100
|
-
*/
|
|
101
|
-
setUseLabelOutline(useLabelOutline: boolean): boolean;
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Check if label outline rendering.
|
|
105
|
-
*/
|
|
106
|
-
getUseLabelOutline(): boolean;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Set the 0 to 1 opacity of the label outline.
|
|
110
|
-
* @param {Number} opacity
|
|
111
|
-
*/
|
|
112
|
-
setLabelOutlineOpacity(opacity: number): boolean;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Get the 0 to 1 opacity of the label outline.
|
|
116
|
-
*/
|
|
117
|
-
getLabelOutlineOpacity(): number;
|
|
118
|
-
|
|
119
97
|
/**
|
|
120
98
|
* gets the label outline thickness
|
|
121
99
|
*/
|
|
@@ -17,18 +17,6 @@ export interface vtkImageSlice extends vtkProp3D {
|
|
|
17
17
|
*/
|
|
18
18
|
getActors(): any;
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* Get the bounds for this mapper as [xmin, xmax, ymin, ymax,zmin, zmax].
|
|
22
|
-
* @return {Bounds} The bounds for the mapper.
|
|
23
|
-
*/
|
|
24
|
-
getBounds(): Bounds;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Get the bounds for this mapper as [xmin, xmax, ymin, ymax,zmin, zmax].
|
|
28
|
-
* @return {Bounds} The bounds for the mapper.
|
|
29
|
-
*/
|
|
30
|
-
getBoundsByReference(): Bounds;
|
|
31
|
-
|
|
32
20
|
/**
|
|
33
21
|
* Get the bounds for a given slice as [xmin, xmax, ymin, ymax,zmin, zmax].
|
|
34
22
|
* @param {Number} slice The slice index. If undefined, the current slice is considered.
|
|
@@ -47,11 +35,6 @@ export interface vtkImageSlice extends vtkProp3D {
|
|
|
47
35
|
*/
|
|
48
36
|
getIsOpaque(): boolean;
|
|
49
37
|
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
getProperty(): vtkImageProperty;
|
|
54
|
-
|
|
55
38
|
/**
|
|
56
39
|
*
|
|
57
40
|
*/
|
|
@@ -130,12 +113,6 @@ export interface vtkImageSlice extends vtkProp3D {
|
|
|
130
113
|
*/
|
|
131
114
|
setMapper(mapper: vtkAbstractImageMapper): boolean;
|
|
132
115
|
|
|
133
|
-
/**
|
|
134
|
-
*
|
|
135
|
-
* @param {vtkImageProperty} property The vtkImageProperty instance.
|
|
136
|
-
*/
|
|
137
|
-
setProperty(property: vtkImageProperty): boolean;
|
|
138
|
-
|
|
139
116
|
/**
|
|
140
117
|
*
|
|
141
118
|
* @param {boolean} forceOpaque If true, render during opaque pass even if opacity value is below 1.0.
|
|
@@ -147,6 +124,13 @@ export interface vtkImageSlice extends vtkProp3D {
|
|
|
147
124
|
* @param {boolean} forceTranslucent If true, render during translucent pass even if opacity value is 1.0.
|
|
148
125
|
*/
|
|
149
126
|
setForceTranslucent(forceTranslucent: boolean): boolean;
|
|
127
|
+
|
|
128
|
+
// Inherited from vtkProp3D, but takes a vtkImageProperty instead of a generic vtkObject
|
|
129
|
+
getProperty(mapperInputPort?: number): vtkImageProperty;
|
|
130
|
+
getProperties(): vtkImageProperty[];
|
|
131
|
+
setProperty(mapperInputPort: number, property: vtkImageProperty): boolean;
|
|
132
|
+
setProperty(property: vtkImageProperty): boolean;
|
|
133
|
+
setProperties(properties: vtkImageProperty[]): boolean;
|
|
150
134
|
}
|
|
151
135
|
|
|
152
136
|
/**
|
|
@@ -4,10 +4,6 @@ import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
|
|
|
4
4
|
import vtkProp3D from './Prop3D.js';
|
|
5
5
|
import vtkImageProperty from './ImageProperty.js';
|
|
6
6
|
|
|
7
|
-
const {
|
|
8
|
-
vtkDebugMacro
|
|
9
|
-
} = macro;
|
|
10
|
-
|
|
11
7
|
// ----------------------------------------------------------------------------
|
|
12
8
|
// vtkImageSlice methods
|
|
13
9
|
// ----------------------------------------------------------------------------
|
|
@@ -25,11 +21,11 @@ function vtkImageSlice(publicAPI, model) {
|
|
|
25
21
|
return false;
|
|
26
22
|
}
|
|
27
23
|
// make sure we have a property
|
|
28
|
-
if (!model.
|
|
24
|
+
if (!model.properties[0]) {
|
|
29
25
|
// force creation of a property
|
|
30
26
|
publicAPI.getProperty();
|
|
31
27
|
}
|
|
32
|
-
let isOpaque = model.
|
|
28
|
+
let isOpaque = model.properties[0].getOpacity() >= 1.0;
|
|
33
29
|
|
|
34
30
|
// are we using an opaque scalar array, if any?
|
|
35
31
|
isOpaque = isOpaque && (!model.mapper || model.mapper.getIsOpaque());
|
|
@@ -43,48 +39,6 @@ function vtkImageSlice(publicAPI, model) {
|
|
|
43
39
|
// and the Renderer will do the images in their own pass.
|
|
44
40
|
publicAPI.hasTranslucentPolygonalGeometry = () => false;
|
|
45
41
|
publicAPI.makeProperty = vtkImageProperty.newInstance;
|
|
46
|
-
publicAPI.getProperty = () => {
|
|
47
|
-
if (model.property === null) {
|
|
48
|
-
model.property = publicAPI.makeProperty();
|
|
49
|
-
}
|
|
50
|
-
return model.property;
|
|
51
|
-
};
|
|
52
|
-
publicAPI.getBounds = () => {
|
|
53
|
-
if (model.mapper === null) {
|
|
54
|
-
return model.bounds;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Check for the special case when the mapper's bounds are unknown
|
|
58
|
-
const bds = model.mapper.getBounds();
|
|
59
|
-
if (!bds || bds.length !== 6) {
|
|
60
|
-
return bds;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Check for the special case when the actor is empty.
|
|
64
|
-
if (bds[0] > bds[1]) {
|
|
65
|
-
model.mapperBounds = bds.concat(); // copy the mapper's bounds
|
|
66
|
-
model.bounds = [1, -1, 1, -1, 1, -1];
|
|
67
|
-
model.boundsMTime.modified();
|
|
68
|
-
return bds;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Check if we have cached values for these bounds - we cache the
|
|
72
|
-
// values returned by model.mapper.getBounds() and we store the time
|
|
73
|
-
// of caching. If the values returned this time are different, or
|
|
74
|
-
// the modified time of this class is newer than the cached time,
|
|
75
|
-
// then we need to rebuild.
|
|
76
|
-
const zip = rows => rows[0].map((_, c) => rows.map(row => row[c]));
|
|
77
|
-
if (!model.mapperBounds || !zip([bds, model.mapperBounds]).reduce((a, b) => a && b[0] === b[1], true) || publicAPI.getMTime() > model.boundsMTime.getMTime()) {
|
|
78
|
-
vtkDebugMacro('Recomputing bounds...');
|
|
79
|
-
model.mapperBounds = bds.map(x => x);
|
|
80
|
-
publicAPI.computeMatrix();
|
|
81
|
-
const tmp4 = new Float64Array(16);
|
|
82
|
-
mat4.transpose(tmp4, model.matrix);
|
|
83
|
-
vtkBoundingBox.transformBounds(bds, tmp4, model.bounds);
|
|
84
|
-
model.boundsMTime.modified();
|
|
85
|
-
}
|
|
86
|
-
return model.bounds;
|
|
87
|
-
};
|
|
88
42
|
publicAPI.getBoundsForSlice = (slice, thickness) => {
|
|
89
43
|
// Check for the special case when the mapper's bounds are unknown
|
|
90
44
|
const bds = model.mapper.getBoundsForSlice(slice, thickness);
|
|
@@ -117,14 +71,6 @@ function vtkImageSlice(publicAPI, model) {
|
|
|
117
71
|
|
|
118
72
|
// Get the maximum Z bound
|
|
119
73
|
publicAPI.getMaxZBound = () => publicAPI.getBounds()[5];
|
|
120
|
-
publicAPI.getMTime = () => {
|
|
121
|
-
let mt = model.mtime;
|
|
122
|
-
if (model.property !== null) {
|
|
123
|
-
const time = model.property.getMTime();
|
|
124
|
-
mt = time > mt ? time : mt;
|
|
125
|
-
}
|
|
126
|
-
return mt;
|
|
127
|
-
};
|
|
128
74
|
publicAPI.getRedrawMTime = () => {
|
|
129
75
|
let mt = model.mtime;
|
|
130
76
|
if (model.mapper !== null) {
|
|
@@ -137,14 +83,13 @@ function vtkImageSlice(publicAPI, model) {
|
|
|
137
83
|
mt = time > mt ? time : mt;
|
|
138
84
|
}
|
|
139
85
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (
|
|
144
|
-
|
|
145
|
-
mt = time > mt ? time : mt;
|
|
86
|
+
model.properties.forEach(property => {
|
|
87
|
+
mt = Math.max(mt, property.getMTime());
|
|
88
|
+
const rgbFunc = property.getRGBTransferFunction();
|
|
89
|
+
if (rgbFunc !== null) {
|
|
90
|
+
mt = Math.max(mt, rgbFunc.getMTime());
|
|
146
91
|
}
|
|
147
|
-
}
|
|
92
|
+
});
|
|
148
93
|
return mt;
|
|
149
94
|
};
|
|
150
95
|
publicAPI.getSupportsSelection = () => model.mapper ? model.mapper.getSupportsSelection() : false;
|
|
@@ -156,10 +101,8 @@ function vtkImageSlice(publicAPI, model) {
|
|
|
156
101
|
|
|
157
102
|
const DEFAULT_VALUES = {
|
|
158
103
|
mapper: null,
|
|
159
|
-
property: null,
|
|
160
104
|
forceOpaque: false,
|
|
161
|
-
forceTranslucent: false
|
|
162
|
-
bounds: [...vtkBoundingBox.INIT_BOUNDS]
|
|
105
|
+
forceTranslucent: false
|
|
163
106
|
};
|
|
164
107
|
|
|
165
108
|
// ----------------------------------------------------------------------------
|
|
@@ -176,9 +119,7 @@ function extend(publicAPI, model) {
|
|
|
176
119
|
macro.obj(model.boundsMTime);
|
|
177
120
|
|
|
178
121
|
// Build VTK API
|
|
179
|
-
macro.set(publicAPI, model, ['property']);
|
|
180
122
|
macro.setGet(publicAPI, model, ['mapper', 'forceOpaque', 'forceTranslucent']);
|
|
181
|
-
macro.getArray(publicAPI, model, ['bounds'], 6);
|
|
182
123
|
|
|
183
124
|
// Object methods
|
|
184
125
|
vtkImageSlice(publicAPI, model);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { mat4, quat } from 'gl-matrix';
|
|
2
2
|
import { Bounds, Vector3, Range } from './../../types';
|
|
3
3
|
import vtkProp, { IPropInitialValues } from './Prop';
|
|
4
|
+
import { vtkObject } from './../../interfaces';
|
|
4
5
|
|
|
5
6
|
export interface IProp3DInitialValues extends IPropInitialValues {
|
|
6
7
|
origin?: number[];
|
|
@@ -19,11 +20,17 @@ export interface vtkProp3D extends vtkProp {
|
|
|
19
20
|
addPosition(deltaXYZ: number[]): void;
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
|
-
* Get the bounds as [xmin, xmax, ymin, ymax, zmin, zmax].
|
|
23
|
-
*
|
|
23
|
+
* Get the bounds of this actor as [xmin, xmax, ymin, ymax, zmin, zmax].
|
|
24
|
+
* They are the bounds of the underlying mapper, transformed using the actor's matrix.
|
|
25
|
+
* @return {Bounds} The bounds for the actor.
|
|
24
26
|
*/
|
|
25
27
|
getBounds(): Bounds;
|
|
26
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Same as getBounds() but the returned array is not copied, so it should not be written to.
|
|
31
|
+
*/
|
|
32
|
+
getBoundsByReference(): Bounds;
|
|
33
|
+
|
|
27
34
|
/**
|
|
28
35
|
* Check if there was a modification or transformation.
|
|
29
36
|
* @default null
|
|
@@ -131,6 +138,21 @@ export interface vtkProp3D extends vtkProp {
|
|
|
131
138
|
*/
|
|
132
139
|
getUserMatrix(): mat4;
|
|
133
140
|
|
|
141
|
+
/**
|
|
142
|
+
* Get the actor property for the specified mapper input port, which defaults to 0
|
|
143
|
+
* It controls this actors rendering properties. If one isn’t specified,
|
|
144
|
+
* then one will be generated automatically. Multiple actors can share one
|
|
145
|
+
* property object.
|
|
146
|
+
* @param {number} mapperInputPort Defaults to 0
|
|
147
|
+
*/
|
|
148
|
+
getProperty(mapperInputPort?: number): vtkObject;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Get the actor properties array
|
|
152
|
+
* Each element of the array corresponds to a mapper input port
|
|
153
|
+
*/
|
|
154
|
+
getProperties(): vtkObject[];
|
|
155
|
+
|
|
134
156
|
/**
|
|
135
157
|
* Rotate the Prop3D in degrees about the X axis using the right hand
|
|
136
158
|
* rule. The axis is the Prop3D’s X axis, which can change as other
|
|
@@ -256,6 +278,21 @@ export interface vtkProp3D extends vtkProp {
|
|
|
256
278
|
* Generate the matrix based on internal model.
|
|
257
279
|
*/
|
|
258
280
|
computeMatrix(): void;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Set the actor property for the specified mapper input port, which defaults to 0
|
|
284
|
+
* @param {vtkObject} property
|
|
285
|
+
* @param {number} mapperInputPort Is 0 when not given
|
|
286
|
+
*/
|
|
287
|
+
setProperty(mapperInputPort: number, property: vtkObject): boolean;
|
|
288
|
+
setProperty(property: vtkObject): boolean;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Set the actor properties array
|
|
292
|
+
* Each element of the array corresponds to a mapper input port
|
|
293
|
+
* @param {vtkObject[]} properties
|
|
294
|
+
*/
|
|
295
|
+
setProperties(properties: vtkObject[]): boolean;
|
|
259
296
|
}
|
|
260
297
|
|
|
261
298
|
/**
|