@kitware/vtk.js 32.0.0 → 32.1.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/Common/DataModel/Box.d.ts +2 -1
- package/Common/DataModel/Box.js +2 -1
- package/Common/DataModel/Cone.d.ts +2 -6
- package/Common/DataModel/Cone.js +2 -1
- package/Common/DataModel/Cylinder.d.ts +3 -2
- package/Common/DataModel/Cylinder.js +2 -1
- package/Common/DataModel/ImageData.d.ts +0 -1
- package/Common/DataModel/ImageData.js +2 -2
- package/Common/DataModel/ImplicitBoolean.js +5 -4
- package/Common/DataModel/ImplicitFunction.d.ts +68 -0
- package/Common/DataModel/ImplicitFunction.js +60 -0
- package/Common/DataModel/Plane.d.ts +2 -1
- package/Common/DataModel/Plane.js +2 -1
- package/Common/DataModel/Sphere.d.ts +10 -17
- package/Common/DataModel/Sphere.js +11 -19
- package/Rendering/Core/Mapper.js +2 -2
- package/Rendering/OpenGL/HardwareSelector.d.ts +17 -0
- package/Rendering/OpenGL/HardwareSelector.js +12 -4
- package/Rendering/OpenGL/ImageCPRMapper.js +90 -66
- package/Rendering/OpenGL/ImageMapper.js +3 -9
- package/Rendering/OpenGL/ImageResliceMapper.js +9 -17
- package/Rendering/OpenGL/PolyDataMapper.js +3 -2
- package/Rendering/OpenGL/RenderWindow/resourceSharingHelper.d.ts +34 -0
- package/Rendering/OpenGL/RenderWindow/resourceSharingHelper.js +14 -0
- package/Rendering/OpenGL/Texture.d.ts +26 -0
- package/Rendering/OpenGL/Texture.js +124 -68
- package/Rendering/OpenGL/VolumeMapper.js +21 -18
- package/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { vtkObject } from './../../interfaces';
|
|
2
2
|
import { Bounds, Vector3 } from './../../types';
|
|
3
|
+
import vtkImplicitFunction from './ImplicitFunction';
|
|
3
4
|
|
|
4
5
|
export interface IBoxInitialValues {
|
|
5
6
|
bbox?: Bounds;
|
|
@@ -12,7 +13,7 @@ export interface IBoxIntersections {
|
|
|
12
13
|
x2: Vector3;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
export interface vtkBox extends
|
|
16
|
+
export interface vtkBox extends vtkImplicitFunction {
|
|
16
17
|
/**
|
|
17
18
|
* Add the bounds for the box.
|
|
18
19
|
* @param {Bounds} bounds
|
package/Common/DataModel/Box.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import vtkBoundingBox from './BoundingBox.js';
|
|
3
|
+
import vtkImplicitFunction from './ImplicitFunction.js';
|
|
3
4
|
|
|
4
5
|
// ----------------------------------------------------------------------------
|
|
5
6
|
// Global methods
|
|
@@ -202,7 +203,7 @@ function extend(publicAPI, model) {
|
|
|
202
203
|
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
203
204
|
|
|
204
205
|
// Object methods
|
|
205
|
-
|
|
206
|
+
vtkImplicitFunction.extend(publicAPI, model, initialValues);
|
|
206
207
|
vtkBox(publicAPI, model);
|
|
207
208
|
}
|
|
208
209
|
|
|
@@ -13,7 +13,7 @@ export interface vtkCone extends vtkObject {
|
|
|
13
13
|
* Given the point x evaluate the cone equation.
|
|
14
14
|
* @param {Vector3} x The point coordinate.
|
|
15
15
|
*/
|
|
16
|
-
evaluateFunction(x: Vector3): number
|
|
16
|
+
evaluateFunction(x: Vector3): number;
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Given the point x evaluate the equation for the cone gradient.
|
|
@@ -54,11 +54,7 @@ export function newInstance(initialValues?: IConeInitialValues): vtkCone;
|
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* vtkCone computes the implicit function and/or gradient for a cone. vtkCone is
|
|
57
|
-
* a concrete implementation of vtkImplicitFunction.
|
|
58
|
-
* axis of rotation is along the x-axis with the apex at the origin. To
|
|
59
|
-
* transform this to a different location requires the application of a
|
|
60
|
-
* transformation matrix. This can be performed by supporting transforms at the
|
|
61
|
-
* implicit function level, and should be added.
|
|
57
|
+
* a concrete implementation of vtkImplicitFunction.
|
|
62
58
|
*/
|
|
63
59
|
export declare const vtkCone: {
|
|
64
60
|
newInstance: typeof newInstance;
|
package/Common/DataModel/Cone.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import { r as radiansFromDegrees } from '../Core/Math/index.js';
|
|
3
|
+
import vtkImplicitFunction from './ImplicitFunction.js';
|
|
3
4
|
|
|
4
5
|
// ----------------------------------------------------------------------------
|
|
5
6
|
// Global methods
|
|
@@ -42,7 +43,7 @@ function extend(publicAPI, model) {
|
|
|
42
43
|
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
43
44
|
|
|
44
45
|
// Object methods
|
|
45
|
-
|
|
46
|
+
vtkImplicitFunction.extend(publicAPI, model, initialValues);
|
|
46
47
|
macro.setGet(publicAPI, model, ['angle']);
|
|
47
48
|
vtkCone(publicAPI, model);
|
|
48
49
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { vtkObject } from './../../interfaces';
|
|
2
2
|
import { Vector3 } from './../../types';
|
|
3
|
+
import vtkImplicitFunction from './ImplicitFunction';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
*
|
|
@@ -10,13 +11,13 @@ export interface ICylinderInitialValues {
|
|
|
10
11
|
axis?: number[];
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
export interface vtkCylinder extends
|
|
14
|
+
export interface vtkCylinder extends vtkImplicitFunction {
|
|
14
15
|
/**
|
|
15
16
|
* Given the point xyz (three floating value) evaluate the cylinder
|
|
16
17
|
* equation.
|
|
17
18
|
* @param {Vector3} xyz The point coordinate.
|
|
18
19
|
*/
|
|
19
|
-
evaluateFunction(xyz: Vector3): number
|
|
20
|
+
evaluateFunction(xyz: Vector3): number;
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Given the point xyz (three floating values) evaluate the equation for the
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import { d as dot } from '../Core/Math/index.js';
|
|
3
|
+
import vtkImplicitFunction from './ImplicitFunction.js';
|
|
3
4
|
|
|
4
5
|
// ----------------------------------------------------------------------------
|
|
5
6
|
// Global methods
|
|
@@ -60,7 +61,7 @@ function extend(publicAPI, model) {
|
|
|
60
61
|
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
61
62
|
|
|
62
63
|
// Object methods
|
|
63
|
-
|
|
64
|
+
vtkImplicitFunction.extend(publicAPI, model, initialValues);
|
|
64
65
|
macro.setGet(publicAPI, model, ['radius']);
|
|
65
66
|
macro.setGetArray(publicAPI, model, ['center', 'axis'], 3);
|
|
66
67
|
vtkCylinder(publicAPI, model);
|
|
@@ -27,7 +27,6 @@ export interface vtkImageData extends vtkDataSet {
|
|
|
27
27
|
* `voxelFunc(index, bounds)` is an optional function that is called with
|
|
28
28
|
* the `[i,j,k]` index and index `bounds`, expected to return truthy if the
|
|
29
29
|
* data point should be counted in the histogram, and falsey if not.
|
|
30
|
-
* @param {Bounds} worldBounds The bounds of the world.
|
|
31
30
|
* @param [voxelFunc]
|
|
32
31
|
*/
|
|
33
32
|
computeHistogram(worldBounds: Bounds, voxelFunc?: any): IComputeHistogram;
|
|
@@ -197,7 +197,7 @@ function vtkImageData(publicAPI, model) {
|
|
|
197
197
|
publicAPI.computeTransforms();
|
|
198
198
|
publicAPI.getCenter = () => vtkBoundingBox.getCenter(publicAPI.getBounds());
|
|
199
199
|
publicAPI.computeHistogram = function (worldBounds) {
|
|
200
|
-
let
|
|
200
|
+
let voxelFunction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
201
201
|
const bounds = [0, 0, 0, 0, 0, 0];
|
|
202
202
|
publicAPI.worldToIndexBounds(worldBounds, bounds);
|
|
203
203
|
const point1 = [0, 0, 0];
|
|
@@ -220,7 +220,7 @@ function vtkImageData(publicAPI, model) {
|
|
|
220
220
|
for (let y = point1[1]; y <= point2[1]; y++) {
|
|
221
221
|
let index = point1[0] + y * yStride + z * zStride;
|
|
222
222
|
for (let x = point1[0]; x <= point2[0]; x++) {
|
|
223
|
-
if (!
|
|
223
|
+
if (!voxelFunction || voxelFunction([x, y, z], bounds)) {
|
|
224
224
|
const pixel = pixels[index];
|
|
225
225
|
if (pixel > maximum) maximum = pixel;
|
|
226
226
|
if (pixel < minimum) minimum = pixel;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import Constants from './ImplicitBoolean/Constants.js';
|
|
3
|
+
import vtkImplicitFunction from './ImplicitFunction.js';
|
|
3
4
|
|
|
4
5
|
const {
|
|
5
6
|
Operation
|
|
@@ -64,7 +65,7 @@ function vtkImplicitBoolean(publicAPI, model) {
|
|
|
64
65
|
value = Number.MAX_VALUE;
|
|
65
66
|
for (let i = 0; i < model.functions.length; ++i) {
|
|
66
67
|
const f = model.functions[i];
|
|
67
|
-
const v = f.
|
|
68
|
+
const v = f.functionValue(xyz);
|
|
68
69
|
if (v < value) {
|
|
69
70
|
value = v;
|
|
70
71
|
}
|
|
@@ -73,14 +74,14 @@ function vtkImplicitBoolean(publicAPI, model) {
|
|
|
73
74
|
value = -Number.MAX_VALUE;
|
|
74
75
|
for (let i = 0; i < model.functions.length; ++i) {
|
|
75
76
|
const f = model.functions[i];
|
|
76
|
-
const v = f.
|
|
77
|
+
const v = f.functionValue(xyz);
|
|
77
78
|
if (v > value) {
|
|
78
79
|
value = v;
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
} else {
|
|
82
83
|
const firstF = model.functions[0];
|
|
83
|
-
value = firstF.
|
|
84
|
+
value = firstF.functionValue(xyz);
|
|
84
85
|
for (let i = 1; i < model.functions.length; ++i) {
|
|
85
86
|
const f = model.functions[i];
|
|
86
87
|
const v = -1.0 * f.evaluateFunction(xyz);
|
|
@@ -117,7 +118,7 @@ function extend(publicAPI, model) {
|
|
|
117
118
|
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
118
119
|
|
|
119
120
|
// Object methods
|
|
120
|
-
|
|
121
|
+
vtkImplicitFunction.extend(publicAPI, model, initialValues);
|
|
121
122
|
macro.setGet(publicAPI, model, ['operation']);
|
|
122
123
|
vtkImplicitBoolean(publicAPI, model);
|
|
123
124
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { vtkObject } from './../../interfaces';
|
|
2
|
+
import { Vector3 } from './../../types';
|
|
3
|
+
import { vtkTransform } from './../Transform/Transform';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export interface IImplicitFunctionInitialValues {
|
|
9
|
+
transform?: vtkTransform;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface vtkImplicitFunction extends vtkObject {
|
|
13
|
+
/**
|
|
14
|
+
* Given the point x evaluate the function.
|
|
15
|
+
* @see functionValue
|
|
16
|
+
* @param {Vector3} x The point coordinate.
|
|
17
|
+
*/
|
|
18
|
+
evaluateFunction(x: Vector3): number;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Evaluate function at position x-y-z and return value. Point x[3] is
|
|
22
|
+
* transformed through transform (if provided).
|
|
23
|
+
* @see evaluateFunction
|
|
24
|
+
* @param {Vector3} x The point coordinate.
|
|
25
|
+
*/
|
|
26
|
+
functionValue(x: Vector3): number;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get the transform. undefined by default
|
|
30
|
+
*/
|
|
31
|
+
getTransform(): vtkTransform;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Set the transform to apply on all points.
|
|
35
|
+
* @param {vtkTransform} transform The transform to apply
|
|
36
|
+
*/
|
|
37
|
+
setTransform(transform: vtkTransform): boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Method used to decorate a given object (publicAPI+model) with vtkImplicitFunction characteristics.
|
|
42
|
+
*
|
|
43
|
+
* @param publicAPI object on which methods will be bounds (public)
|
|
44
|
+
* @param model object on which data structure will be bounds (protected)
|
|
45
|
+
* @param {IImplicitFunctionInitialValues} [initialValues] (default: {})
|
|
46
|
+
*/
|
|
47
|
+
export function extend(
|
|
48
|
+
publicAPI: object,
|
|
49
|
+
model: object,
|
|
50
|
+
initialValues?: IImplicitFunctionInitialValues
|
|
51
|
+
): void;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Method used to create a new instance of vtkImplicitFunction.
|
|
55
|
+
* @param {IImplicitFunctionInitialValues} [initialValues] for pre-setting some of its content
|
|
56
|
+
*/
|
|
57
|
+
export function newInstance(
|
|
58
|
+
initialValues?: IImplicitFunctionInitialValues
|
|
59
|
+
): vtkImplicitFunction;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* vtkImplicitFunction computes the implicit function and/or gradient for a function.
|
|
63
|
+
*/
|
|
64
|
+
export declare const vtkImplicitFunction: {
|
|
65
|
+
newInstance: typeof newInstance;
|
|
66
|
+
extend: typeof extend;
|
|
67
|
+
};
|
|
68
|
+
export default vtkImplicitFunction;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { m as macro } from '../../macros2.js';
|
|
2
|
+
|
|
3
|
+
// ----------------------------------------------------------------------------
|
|
4
|
+
// Global methods
|
|
5
|
+
// ----------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
// ----------------------------------------------------------------------------
|
|
8
|
+
// Static API
|
|
9
|
+
// ----------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
// ----------------------------------------------------------------------------
|
|
12
|
+
// vtkImplicitFunction methods
|
|
13
|
+
// ----------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
function vtkImplicitFunction(publicAPI, model) {
|
|
16
|
+
model.classHierarchy.push('vtkImplicitFunction');
|
|
17
|
+
publicAPI.functionValue = xyz => {
|
|
18
|
+
if (!model.transform) {
|
|
19
|
+
return publicAPI.evaluateFunction(xyz);
|
|
20
|
+
}
|
|
21
|
+
const transformedXYZ = [];
|
|
22
|
+
model.transform.transformPoint(xyz, transformedXYZ);
|
|
23
|
+
return publicAPI.evaluateFunction(transformedXYZ);
|
|
24
|
+
};
|
|
25
|
+
publicAPI.evaluateFunction = _xyz => {
|
|
26
|
+
macro.vtkErrorMacro('not implemented');
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// ----------------------------------------------------------------------------
|
|
31
|
+
// Object factory
|
|
32
|
+
// ----------------------------------------------------------------------------
|
|
33
|
+
const DEFAULT_VALUES = {
|
|
34
|
+
// transform : null
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// ----------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
function extend(publicAPI, model) {
|
|
40
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
41
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
42
|
+
|
|
43
|
+
// Object methods
|
|
44
|
+
macro.obj(publicAPI, model);
|
|
45
|
+
macro.setGet(publicAPI, model, ['transform']);
|
|
46
|
+
vtkImplicitFunction(publicAPI, model);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ----------------------------------------------------------------------------
|
|
50
|
+
|
|
51
|
+
const newInstance = macro.newInstance(extend, 'vtkImplicitFunction');
|
|
52
|
+
|
|
53
|
+
// ----------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
var vtkImplicitFunction$1 = {
|
|
56
|
+
newInstance,
|
|
57
|
+
extend
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { vtkImplicitFunction$1 as default, extend, newInstance };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { vtkObject } from './../../interfaces';
|
|
2
2
|
import { Vector3 } from './../../types';
|
|
3
|
+
import vtkImplicitFunction from './ImplicitFunction';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
*
|
|
@@ -16,7 +17,7 @@ interface IIntersectWithLine {
|
|
|
16
17
|
x: Vector3;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
export interface vtkPlane extends
|
|
20
|
+
export interface vtkPlane extends vtkImplicitFunction {
|
|
20
21
|
/**
|
|
21
22
|
* Get the distance of a point x to a plane defined by n (x-p0) = 0.
|
|
22
23
|
* The normal n must be magnitude = 1.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { s as subtract, d as dot, j as cross, k as add } from '../Core/Math/index.js';
|
|
2
2
|
import { m as macro } from '../../macros2.js';
|
|
3
|
+
import vtkImplicitFunction from './ImplicitFunction.js';
|
|
3
4
|
|
|
4
5
|
const PLANE_TOLERANCE = 1.0e-6;
|
|
5
6
|
const COINCIDE = 'coincide';
|
|
@@ -235,7 +236,7 @@ function extend(publicAPI, model) {
|
|
|
235
236
|
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
236
237
|
|
|
237
238
|
// Object methods
|
|
238
|
-
|
|
239
|
+
vtkImplicitFunction.extend(publicAPI, model, initialValues);
|
|
239
240
|
macro.setGetArray(publicAPI, model, ['normal', 'origin'], 3);
|
|
240
241
|
vtkPlane(publicAPI, model);
|
|
241
242
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Vector3 } from './../../types';
|
|
2
|
+
import vtkImplicitFunction from './ImplicitFunction';
|
|
3
3
|
|
|
4
4
|
export interface ISphereInitialValues {
|
|
5
|
-
radius?: number;
|
|
5
|
+
radius?: number | Vector3;
|
|
6
6
|
center?: Vector3;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export interface vtkSphere extends
|
|
9
|
+
export interface vtkSphere extends vtkImplicitFunction {
|
|
10
10
|
/**
|
|
11
11
|
* Given the point xyz (three floating value) evaluate the sphere
|
|
12
12
|
* equation.
|
|
13
13
|
* @param {Vector3} xyz The point coordinate.
|
|
14
14
|
*/
|
|
15
|
-
evaluateFunction(xyz: Vector3): number
|
|
15
|
+
evaluateFunction(xyz: Vector3): number;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Given the point xyz (three floating values) evaluate the equation for the
|
|
@@ -34,7 +34,7 @@ export interface vtkSphere extends vtkObject {
|
|
|
34
34
|
/**
|
|
35
35
|
* Get the radius of the sphere.
|
|
36
36
|
*/
|
|
37
|
-
getRadius(): number;
|
|
37
|
+
getRadius(): number | Vector3;
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Set the center of the sphere.
|
|
@@ -57,10 +57,11 @@ export interface vtkSphere extends vtkObject {
|
|
|
57
57
|
setCenterFrom(center: Vector3): boolean;
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
* Set the radius of the sphere.
|
|
61
|
-
*
|
|
60
|
+
* Set the radius of the sphere. Radius must be > 0.
|
|
61
|
+
* It can also be an array of 3 positive values for ellipsoids
|
|
62
|
+
* @param {Number|Vector3} radius The radius of the sphere.
|
|
62
63
|
*/
|
|
63
|
-
setRadius(radius: number): boolean;
|
|
64
|
+
setRadius(radius: number | Vector3): boolean;
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
/**
|
|
@@ -89,13 +90,6 @@ export function newInstance(initialValues?: ISphereInitialValues): vtkSphere;
|
|
|
89
90
|
*/
|
|
90
91
|
declare function evaluate(radius: number, center: Vector3, x: Vector3): number;
|
|
91
92
|
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
* @param {Vector3} point
|
|
95
|
-
* @param {Bounds} bounds
|
|
96
|
-
*/
|
|
97
|
-
declare function isPointIn3DEllipse(point: Vector3, bounds: Bounds): boolean;
|
|
98
|
-
|
|
99
93
|
/**
|
|
100
94
|
* vtkSphere provides methods for creating a 1D cubic spline object from given
|
|
101
95
|
* parameters, and allows for the calculation of the spline value and derivative
|
|
@@ -105,6 +99,5 @@ export declare const vtkSphere: {
|
|
|
105
99
|
newInstance: typeof newInstance;
|
|
106
100
|
extend: typeof extend;
|
|
107
101
|
evaluate: typeof evaluate;
|
|
108
|
-
isPointIn3DEllipse: typeof isPointIn3DEllipse;
|
|
109
102
|
};
|
|
110
103
|
export default vtkSphere;
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
const VTK_SMALL_NUMBER = 1e-12;
|
|
2
|
+
import vtkImplicitFunction from './ImplicitFunction.js';
|
|
5
3
|
|
|
6
4
|
// ----------------------------------------------------------------------------
|
|
7
5
|
// Global methods
|
|
8
6
|
// ----------------------------------------------------------------------------
|
|
9
7
|
|
|
10
|
-
function evaluate(radius, center,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const radius = [(point[0] - center[0]) / scale3[0], (point[1] - center[1]) / scale3[1], (point[2] - center[2]) / scale3[2]];
|
|
18
|
-
return radius[0] * radius[0] + radius[1] * radius[1] + radius[2] * radius[2] <= 1;
|
|
8
|
+
function evaluate(radius, center, xyz) {
|
|
9
|
+
if (!Array.isArray(radius)) {
|
|
10
|
+
const retVal = (xyz[0] - center[0]) * (xyz[0] - center[0]) + (xyz[1] - center[1]) * (xyz[1] - center[1]) + (xyz[2] - center[2]) * (xyz[2] - center[2]) - radius * radius;
|
|
11
|
+
return retVal;
|
|
12
|
+
}
|
|
13
|
+
const r = [(xyz[0] - center[0]) / radius[0], (xyz[1] - center[1]) / radius[1], (xyz[2] - center[2]) / radius[2]];
|
|
14
|
+
return r[0] * r[0] + r[1] * r[1] + r[2] * r[2] - 1;
|
|
19
15
|
}
|
|
20
16
|
|
|
21
17
|
// ----------------------------------------------------------------------------
|
|
@@ -23,8 +19,7 @@ function isPointIn3DEllipse(point, bounds) {
|
|
|
23
19
|
// ----------------------------------------------------------------------------
|
|
24
20
|
|
|
25
21
|
const STATIC = {
|
|
26
|
-
evaluate
|
|
27
|
-
isPointIn3DEllipse
|
|
22
|
+
evaluate
|
|
28
23
|
};
|
|
29
24
|
|
|
30
25
|
// ----------------------------------------------------------------------------
|
|
@@ -34,10 +29,7 @@ const STATIC = {
|
|
|
34
29
|
function vtkSphere(publicAPI, model) {
|
|
35
30
|
// Set our className
|
|
36
31
|
model.classHierarchy.push('vtkSphere');
|
|
37
|
-
publicAPI.evaluateFunction = xyz =>
|
|
38
|
-
const retVal = (xyz[0] - model.center[0]) * (xyz[0] - model.center[0]) + (xyz[1] - model.center[1]) * (xyz[1] - model.center[1]) + (xyz[2] - model.center[2]) * (xyz[2] - model.center[2]) - model.radius * model.radius;
|
|
39
|
-
return retVal;
|
|
40
|
-
};
|
|
32
|
+
publicAPI.evaluateFunction = xyz => evaluate(model.radius, model.center, xyz);
|
|
41
33
|
publicAPI.evaluateGradient = xyz => {
|
|
42
34
|
const retVal = [2.0 - (xyz[0] - model.center[0]), 2.0 - (xyz[1] - model.center[1]), 2.0 - (xyz[2] - model.center[2])];
|
|
43
35
|
return retVal;
|
|
@@ -60,7 +52,7 @@ function extend(publicAPI, model) {
|
|
|
60
52
|
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
61
53
|
|
|
62
54
|
// Object methods
|
|
63
|
-
|
|
55
|
+
vtkImplicitFunction.extend(publicAPI, model, initialValues);
|
|
64
56
|
macro.setGet(publicAPI, model, ['radius']);
|
|
65
57
|
macro.setGetArray(publicAPI, model, ['center'], 3);
|
|
66
58
|
vtkSphere(publicAPI, model);
|
package/Rendering/Core/Mapper.js
CHANGED
|
@@ -595,11 +595,11 @@ function vtkMapper(publicAPI, model) {
|
|
|
595
595
|
let inValue = 0;
|
|
596
596
|
inValue += rawHighData[pos];
|
|
597
597
|
inValue *= 256;
|
|
598
|
-
inValue += rawLowData[pos];
|
|
598
|
+
inValue += rawLowData[pos + 2];
|
|
599
599
|
inValue *= 256;
|
|
600
600
|
inValue += rawLowData[pos + 1];
|
|
601
601
|
inValue *= 256;
|
|
602
|
-
inValue += rawLowData[pos
|
|
602
|
+
inValue += rawLowData[pos];
|
|
603
603
|
const outValue = idMap[inValue];
|
|
604
604
|
const highData = selector.getPixelBuffer(PassTypes.ID_HIGH24);
|
|
605
605
|
highData[pos] = (outValue & 0xff000000) >> 24;
|
|
@@ -331,6 +331,23 @@ export function extend(
|
|
|
331
331
|
initialValues?: IOpenGLHardwareSelectorInitialValues
|
|
332
332
|
): void;
|
|
333
333
|
|
|
334
|
+
/**
|
|
335
|
+
* The WebGL implementation of the hardware selector renders the id of the VBO
|
|
336
|
+
* vertices (gl_VertexID) with an offset to a RGBA texture.
|
|
337
|
+
* Only the RGB channels of the RGBA texture are used. This means that a single
|
|
338
|
+
* render can only draw 24 bits of information. To reach 32 bits, the hardware
|
|
339
|
+
* selector renders a second pass which only writes in the R channel of the
|
|
340
|
+
* texture.
|
|
341
|
+
*
|
|
342
|
+
* Note:
|
|
343
|
+
* - With Webgl 2, it is now possible to render directly to a R32 texture and
|
|
344
|
+
* even render to multiple render targets.
|
|
345
|
+
* - The raw pixel buffers fetched from WebGL are processed in the core mapper
|
|
346
|
+
* (see `processSelectorPixelBuffers`) instead of the PolydataMapper.
|
|
347
|
+
* - The processing of the raw pixel buffers does not output an UInt32Array as
|
|
348
|
+
* we could expect, but one or two textures with the same layout as the RGBA
|
|
349
|
+
* textures as input.
|
|
350
|
+
*/
|
|
334
351
|
export const vtkOpenGLHardwareSelector: {
|
|
335
352
|
newInstance: typeof newInstance;
|
|
336
353
|
extend: typeof extend;
|
|
@@ -358,6 +358,7 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
|
|
|
358
358
|
model._renderer.setBackground(0.0, 0.0, 0.0, 0.0);
|
|
359
359
|
const rpasses = model._openGLRenderWindow.getRenderPasses();
|
|
360
360
|
publicAPI.beginSelection();
|
|
361
|
+
const pixelBufferSavedPasses = [];
|
|
361
362
|
for (model.currentPass = PassTypes.MIN_KNOWN_PASS; model.currentPass <= PassTypes.MAX_KNOWN_PASS; model.currentPass++) {
|
|
362
363
|
if (publicAPI.passRequired(model.currentPass)) {
|
|
363
364
|
publicAPI.preCapturePass(model.currentPass);
|
|
@@ -369,9 +370,16 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
|
|
|
369
370
|
}
|
|
370
371
|
publicAPI.postCapturePass(model.currentPass);
|
|
371
372
|
publicAPI.savePixelBuffer(model.currentPass);
|
|
372
|
-
|
|
373
|
+
pixelBufferSavedPasses.push(model.currentPass);
|
|
373
374
|
}
|
|
374
375
|
}
|
|
376
|
+
|
|
377
|
+
// Process pixel buffers
|
|
378
|
+
pixelBufferSavedPasses.forEach(pass => {
|
|
379
|
+
model.currentPass = pass;
|
|
380
|
+
publicAPI.processPixelBuffers();
|
|
381
|
+
});
|
|
382
|
+
model.currentPass = PassTypes.MAX_KNOWN_PASS;
|
|
375
383
|
publicAPI.endSelection();
|
|
376
384
|
|
|
377
385
|
// restore original background
|
|
@@ -631,9 +639,9 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
|
|
|
631
639
|
|
|
632
640
|
//----------------------------------------------------------------------------
|
|
633
641
|
|
|
634
|
-
publicAPI.attach = (
|
|
635
|
-
model._openGLRenderWindow =
|
|
636
|
-
model._renderer =
|
|
642
|
+
publicAPI.attach = (openGLRenderWindow, renderer) => {
|
|
643
|
+
model._openGLRenderWindow = openGLRenderWindow;
|
|
644
|
+
model._renderer = renderer;
|
|
637
645
|
};
|
|
638
646
|
|
|
639
647
|
// override
|