@kitware/vtk.js 32.9.0 → 32.10.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/Core/URLExtract.js +2 -6
- package/Common/DataModel/Line.js +1 -0
- package/Common/DataModel/PolyLine.js +4 -0
- package/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js +1 -1
- package/IO/Geometry/STLReader.d.ts +14 -0
- package/IO/Geometry/STLReader.js +57 -1
- package/Rendering/Core/Glyph3DMapper.d.ts +45 -29
- package/Rendering/Core/ImageCPRMapper.js +1 -1
- package/Rendering/Core/PointPicker.js +6 -0
- package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.d.ts +1 -1
- package/Widgets/Widgets3D/InteractiveOrientationWidget.js +1 -1
- package/package.json +11 -10
|
@@ -27,12 +27,8 @@ function extractURLParameters() {
|
|
|
27
27
|
let query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.location.search;
|
|
28
28
|
const summary = {};
|
|
29
29
|
const convert = castToNativeType ? toNativeType : identity;
|
|
30
|
-
const
|
|
31
|
-
.
|
|
32
|
-
.split('&'); // extract token pair
|
|
33
|
-
|
|
34
|
-
queryTokens.forEach(token => {
|
|
35
|
-
const [key, value] = token.split('=').map(s => decodeURIComponent(s));
|
|
30
|
+
const params = new URLSearchParams(query);
|
|
31
|
+
params.forEach((value, key) => {
|
|
36
32
|
if (key) {
|
|
37
33
|
summary[key] = value ? convert(value) : true;
|
|
38
34
|
}
|
package/Common/DataModel/Line.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unzipSync, strFromU8, decompressSync, strToU8 } from 'fflate';
|
|
2
2
|
import { m as macro } from '../../../macros2.js';
|
|
3
3
|
import Endian from '../../../Common/Core/Endian.js';
|
|
4
4
|
import { DataTypeByteSize } from '../../../Common/Core/DataArray/Constants.js';
|
|
@@ -46,6 +46,11 @@ export interface vtkSTLReader extends vtkSTLReaderBase {
|
|
|
46
46
|
*/
|
|
47
47
|
getUrl(): string;
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Get tolerance when removeDuplicateVertices is set
|
|
51
|
+
*/
|
|
52
|
+
getRemoveDuplicateVertices(): number;
|
|
53
|
+
|
|
49
54
|
/**
|
|
50
55
|
* Load the object data.
|
|
51
56
|
* @param {ISTLReaderOptions} [options]
|
|
@@ -94,6 +99,15 @@ export interface vtkSTLReader extends vtkSTLReaderBase {
|
|
|
94
99
|
* @param {ISTLReaderOptions} [option] The STL reader options.
|
|
95
100
|
*/
|
|
96
101
|
setUrl(url: string, option?: ISTLReaderOptions): Promise<string | any>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Turn on/off automatic removeDuplicateVertices
|
|
105
|
+
* After reading the STL file, if `tolerance` is >= 0, then points with the same coordinates at 10 power tolerance are merged.
|
|
106
|
+
* For a smooth rendering, you might want to compute normals with vtkPolyDataNormals.
|
|
107
|
+
*
|
|
108
|
+
* @param {Number} tolerance
|
|
109
|
+
*/
|
|
110
|
+
setRemoveDuplicateVertices(tolerance: number): boolean;
|
|
97
111
|
}
|
|
98
112
|
|
|
99
113
|
/**
|
package/IO/Geometry/STLReader.js
CHANGED
|
@@ -103,6 +103,55 @@ function vtkSTLReader(publicAPI, model) {
|
|
|
103
103
|
progressCallback
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
|
+
function removeDuplicateVertices(tolerance) {
|
|
107
|
+
const polydata = model.output[0];
|
|
108
|
+
const points = polydata.getPoints().getData();
|
|
109
|
+
const faces = polydata.getPolys().getData();
|
|
110
|
+
if (!points || !faces) {
|
|
111
|
+
console.warn('No valid polydata.');
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const vMap = new Map();
|
|
115
|
+
const vIndexMap = new Map();
|
|
116
|
+
let vInc = 0;
|
|
117
|
+
let pointsChanged = false;
|
|
118
|
+
for (let i = 0; i < points.length; i += 3) {
|
|
119
|
+
const k1 = (points[i] * 10 ** tolerance).toFixed(0);
|
|
120
|
+
const k2 = (points[i + 1] * 10 ** tolerance).toFixed(0);
|
|
121
|
+
const k3 = (points[i + 2] * 10 ** tolerance).toFixed(0);
|
|
122
|
+
const key = `${k1},${k2},${k3}`;
|
|
123
|
+
if (vMap.get(key) !== undefined) {
|
|
124
|
+
vIndexMap.set(i / 3, vMap.get(key));
|
|
125
|
+
pointsChanged = true;
|
|
126
|
+
} else {
|
|
127
|
+
vIndexMap.set(i / 3, vInc);
|
|
128
|
+
vMap.set(key, vInc);
|
|
129
|
+
vInc++;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const outVerts = new Float32Array(vMap.size * 3);
|
|
133
|
+
const keys = Array.from(vMap.keys());
|
|
134
|
+
for (let i = 0; i < keys.length; i++) {
|
|
135
|
+
const k = keys[i];
|
|
136
|
+
const j = vMap.get(k) * 3;
|
|
137
|
+
const coords = k.split(',').map(e => +e * 10 ** -tolerance);
|
|
138
|
+
outVerts[j] = coords[0];
|
|
139
|
+
outVerts[j + 1] = coords[1];
|
|
140
|
+
outVerts[j + 2] = coords[2];
|
|
141
|
+
}
|
|
142
|
+
const outFaces = new Int32Array(faces);
|
|
143
|
+
for (let i = 0; i < faces.length; i += 4) {
|
|
144
|
+
outFaces[i] = 3;
|
|
145
|
+
outFaces[i + 1] = vIndexMap.get(faces[i + 1]);
|
|
146
|
+
outFaces[i + 2] = vIndexMap.get(faces[i + 2]);
|
|
147
|
+
outFaces[i + 3] = vIndexMap.get(faces[i + 3]);
|
|
148
|
+
}
|
|
149
|
+
polydata.getPoints().setData(outVerts);
|
|
150
|
+
polydata.getPolys().setData(outFaces);
|
|
151
|
+
if (pointsChanged) {
|
|
152
|
+
publicAPI.modified();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
106
155
|
|
|
107
156
|
// Set DataSet url
|
|
108
157
|
publicAPI.setUrl = function (url) {
|
|
@@ -251,6 +300,9 @@ function vtkSTLReader(publicAPI, model) {
|
|
|
251
300
|
|
|
252
301
|
// Add new output
|
|
253
302
|
model.output[0] = polydata;
|
|
303
|
+
if (model.removeDuplicateVertices >= 0) {
|
|
304
|
+
removeDuplicateVertices(model.removeDuplicateVertices);
|
|
305
|
+
}
|
|
254
306
|
};
|
|
255
307
|
publicAPI.parseAsText = content => {
|
|
256
308
|
if (!content) {
|
|
@@ -281,6 +333,9 @@ function vtkSTLReader(publicAPI, model) {
|
|
|
281
333
|
|
|
282
334
|
// Add new output
|
|
283
335
|
model.output[0] = polydata;
|
|
336
|
+
if (model.removeDuplicateVertices >= 0) {
|
|
337
|
+
removeDuplicateVertices(model.removeDuplicateVertices);
|
|
338
|
+
}
|
|
284
339
|
};
|
|
285
340
|
publicAPI.requestData = (inData, outData) => {
|
|
286
341
|
publicAPI.parse(model.parseData);
|
|
@@ -295,6 +350,7 @@ const DEFAULT_VALUES = {
|
|
|
295
350
|
// baseURL: null,
|
|
296
351
|
// dataAccessHelper: null,
|
|
297
352
|
// url: null,
|
|
353
|
+
removeDuplicateVertices: -1
|
|
298
354
|
};
|
|
299
355
|
|
|
300
356
|
// ----------------------------------------------------------------------------
|
|
@@ -306,7 +362,7 @@ function extend(publicAPI, model) {
|
|
|
306
362
|
// Build VTK API
|
|
307
363
|
macro.obj(publicAPI, model);
|
|
308
364
|
macro.get(publicAPI, model, ['url', 'baseURL']);
|
|
309
|
-
macro.setGet(publicAPI, model, ['dataAccessHelper']);
|
|
365
|
+
macro.setGet(publicAPI, model, ['dataAccessHelper', 'removeDuplicateVertices']);
|
|
310
366
|
macro.algo(publicAPI, model, 0, 1);
|
|
311
367
|
|
|
312
368
|
// vtkSTLReader methods
|
|
@@ -12,11 +12,11 @@ interface IPrimitiveCount {
|
|
|
12
12
|
export interface IGlyph3DMapperInitialValues extends IMapperInitialValues {
|
|
13
13
|
orient?: boolean;
|
|
14
14
|
orientationMode?: OrientationModes;
|
|
15
|
-
orientationArray?:
|
|
15
|
+
orientationArray?: string;
|
|
16
16
|
scaling?: boolean;
|
|
17
17
|
scaleFactor?: number;
|
|
18
18
|
scaleMode?: ScaleModes;
|
|
19
|
-
scaleArray?:
|
|
19
|
+
scaleArray?: string;
|
|
20
20
|
matrixArray?: number[];
|
|
21
21
|
normalArray?: number[];
|
|
22
22
|
colorArray?: number[];
|
|
@@ -24,29 +24,26 @@ export interface IGlyph3DMapperInitialValues extends IMapperInitialValues {
|
|
|
24
24
|
|
|
25
25
|
export interface vtkGlyph3DMapper extends vtkMapper {
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
* This definition is compliant with SetOrientation method on vtkProp3D.
|
|
27
|
+
* Get the bounds for this mapper as [xmin, xmax, ymin, ymax,zmin, zmax].
|
|
28
|
+
* @return {Bounds} The bounds for the mapper.
|
|
29
|
+
*/
|
|
30
|
+
getBounds(): Bounds;
|
|
31
|
+
|
|
32
|
+
/**
|
|
34
33
|
*
|
|
35
|
-
* By using vector or normal there is a degree of freedom or rotation left
|
|
36
|
-
* (underconstrained). With the orientation array, there is no degree of
|
|
37
|
-
* freedom left.
|
|
38
34
|
*/
|
|
39
|
-
|
|
35
|
+
buildArrays(): void;
|
|
40
36
|
|
|
41
37
|
/**
|
|
42
|
-
*
|
|
38
|
+
*
|
|
43
39
|
*/
|
|
44
|
-
|
|
40
|
+
getPrimitiveCount(): IPrimitiveCount;
|
|
45
41
|
|
|
46
42
|
/**
|
|
47
|
-
* Get
|
|
43
|
+
* Get scale mode
|
|
44
|
+
* @default `SCALE_BY_MAGNITUDE`
|
|
48
45
|
*/
|
|
49
|
-
|
|
46
|
+
getScaleMode(): ScaleModes;
|
|
50
47
|
|
|
51
48
|
/**
|
|
52
49
|
* Get scale factor to scale object by.
|
|
@@ -54,15 +51,20 @@ export interface vtkGlyph3DMapper extends vtkMapper {
|
|
|
54
51
|
getScaleFactor(): number;
|
|
55
52
|
|
|
56
53
|
/**
|
|
57
|
-
* Get scale mode
|
|
58
|
-
* @default `SCALE_BY_MAGNITUDE`
|
|
54
|
+
* Get scale mode as string
|
|
59
55
|
*/
|
|
60
|
-
|
|
56
|
+
getScaleModeAsString(): string;
|
|
61
57
|
|
|
62
58
|
/**
|
|
63
|
-
*
|
|
59
|
+
* Sets the name of the array to use as scale values.
|
|
60
|
+
* @param {String} arrayName Name of the array
|
|
64
61
|
*/
|
|
65
|
-
|
|
62
|
+
setScaleArray(arrayName: Nullable<string>): boolean;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Gets the name of the array used as scale values.
|
|
66
|
+
*/
|
|
67
|
+
getScaleArray(): string;
|
|
66
68
|
|
|
67
69
|
/**
|
|
68
70
|
* Get scale mode as array
|
|
@@ -70,20 +72,29 @@ export interface vtkGlyph3DMapper extends vtkMapper {
|
|
|
70
72
|
getScaleArrayData(): number[];
|
|
71
73
|
|
|
72
74
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
+
* An orientation array is a vtkDataArray with 3 components. The first
|
|
76
|
+
* component is the angle of rotation along the X axis. The second component
|
|
77
|
+
* is the angle of rotation along the Y axis. The third component is the
|
|
78
|
+
* angle of rotation along the Z axis. Orientation is specified in X,Y,Z
|
|
79
|
+
* order but the rotations are performed in Z,X an Y.
|
|
80
|
+
*
|
|
81
|
+
* This definition is compliant with SetOrientation method on vtkProp3D.
|
|
82
|
+
*
|
|
83
|
+
* By using vector or normal there is a degree of freedom or rotation left
|
|
84
|
+
* (underconstrained). With the orientation array, there is no degree of
|
|
85
|
+
* freedom left.
|
|
75
86
|
*/
|
|
76
|
-
|
|
87
|
+
getOrientationMode(): OrientationModes;
|
|
77
88
|
|
|
78
89
|
/**
|
|
79
|
-
*
|
|
90
|
+
* Get orientation as string
|
|
80
91
|
*/
|
|
81
|
-
|
|
92
|
+
getOrientationModeAsString(): string;
|
|
82
93
|
|
|
83
94
|
/**
|
|
84
|
-
*
|
|
95
|
+
* Get orientation as array
|
|
85
96
|
*/
|
|
86
|
-
|
|
97
|
+
getOrientationArrayData(): number[];
|
|
87
98
|
|
|
88
99
|
/**
|
|
89
100
|
* Sets the name of the array to use as orientation.
|
|
@@ -91,6 +102,11 @@ export interface vtkGlyph3DMapper extends vtkMapper {
|
|
|
91
102
|
*/
|
|
92
103
|
setOrientationArray(arrayName: Nullable<string>): boolean;
|
|
93
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Gets the name of the array used as orientation values.
|
|
107
|
+
*/
|
|
108
|
+
getOrientationArray(): string;
|
|
109
|
+
|
|
94
110
|
/**
|
|
95
111
|
* Orientation mode indicates if the OrientationArray provides the direction
|
|
96
112
|
* vector for the orientation or the rotations around each axes.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { vec3, mat4
|
|
1
|
+
import { quat, vec3, mat4 } from 'gl-matrix';
|
|
2
2
|
import CoincidentTopologyHelper from './Mapper/CoincidentTopologyHelper.js';
|
|
3
3
|
import vtkAbstractImageMapper from './AbstractImageMapper.js';
|
|
4
4
|
import { m as macro } from '../../macros2.js';
|
|
@@ -80,6 +80,9 @@ function vtkPointPicker(publicAPI, model) {
|
|
|
80
80
|
if (maxDist <= tolerance && maxDist < minPtDist) {
|
|
81
81
|
// within tolerance
|
|
82
82
|
minPtId = ptId;
|
|
83
|
+
x[0];
|
|
84
|
+
x[1];
|
|
85
|
+
x[2];
|
|
83
86
|
minPtDist = maxDist;
|
|
84
87
|
tMin = t;
|
|
85
88
|
}
|
|
@@ -108,6 +111,9 @@ function vtkPointPicker(publicAPI, model) {
|
|
|
108
111
|
if (maxDist <= tolerance && maxDist < minPtDist) {
|
|
109
112
|
// within tolerance
|
|
110
113
|
minPtId = ptId;
|
|
114
|
+
x[0];
|
|
115
|
+
x[1];
|
|
116
|
+
x[2];
|
|
111
117
|
minPtDist = maxDist;
|
|
112
118
|
tMin = t;
|
|
113
119
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { vtkObject } from './../../../interfaces';
|
|
2
2
|
import { Nullable } from './../../../types';
|
|
3
|
-
import { ISynchronizerContext, IViewState } from '
|
|
3
|
+
import { ISynchronizerContext, IViewState } from '../SynchronizableRenderWindow';
|
|
4
4
|
|
|
5
5
|
export type BuilderFunction = <T extends vtkObject>(
|
|
6
6
|
type: string,
|
|
@@ -2,7 +2,7 @@ import { m as macro } from '../../macros2.js';
|
|
|
2
2
|
import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
|
|
3
3
|
import vtkConvexFaceContextRepresentation from '../Representations/ConvexFaceContextRepresentation.js';
|
|
4
4
|
import widgetBehavior from './InteractiveOrientationWidget/behavior.js';
|
|
5
|
-
import {
|
|
5
|
+
import { INITIAL_POINTS, generateState } from './InteractiveOrientationWidget/state.js';
|
|
6
6
|
import { Behavior } from '../Representations/WidgetRepresentation/Constants.js';
|
|
7
7
|
import { ViewTypes } from '../Core/WidgetManager/Constants.js';
|
|
8
8
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitware/vtk.js",
|
|
3
|
-
"version": "32.
|
|
3
|
+
"version": "32.10.0",
|
|
4
4
|
"description": "Visualization Toolkit for the Web",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"3d",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"@babel/eslint-parser": "7.22.11",
|
|
54
54
|
"@babel/plugin-transform-runtime": "7.22.10",
|
|
55
55
|
"@babel/preset-env": "7.22.10",
|
|
56
|
-
"@commitlint/cli": "
|
|
57
|
-
"@commitlint/config-conventional": "
|
|
56
|
+
"@commitlint/cli": "19.7.1",
|
|
57
|
+
"@commitlint/config-conventional": "19.7.1",
|
|
58
58
|
"@mapbox/node-pre-gyp": "1.0.9",
|
|
59
59
|
"@rollup/plugin-alias": "3.1.9",
|
|
60
60
|
"@rollup/plugin-babel": "5.3.1",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"@rollup/plugin-eslint": "8.0.2",
|
|
63
63
|
"@rollup/plugin-json": "4.1.0",
|
|
64
64
|
"@rollup/plugin-node-resolve": "13.1.3",
|
|
65
|
+
"@types/node": "^22.13.1",
|
|
65
66
|
"autoprefixer": "10.4.7",
|
|
66
67
|
"babel-loader": "8.2.5",
|
|
67
68
|
"babel-plugin-istanbul": "6.1.1",
|
|
@@ -72,7 +73,7 @@
|
|
|
72
73
|
"cross-env": "7.0.3",
|
|
73
74
|
"css-loader": "6.7.1",
|
|
74
75
|
"dotenv": "16.0.1",
|
|
75
|
-
"dox": "0.
|
|
76
|
+
"dox": "1.0.0",
|
|
76
77
|
"eslint": "8.15.0",
|
|
77
78
|
"eslint-config-airbnb": "19.0.4",
|
|
78
79
|
"eslint-config-prettier": "8.5.0",
|
|
@@ -105,7 +106,7 @@
|
|
|
105
106
|
"prettier": "2.6.2",
|
|
106
107
|
"process": "0.11.10",
|
|
107
108
|
"regenerator-runtime": "0.13.9",
|
|
108
|
-
"rollup": "2.
|
|
109
|
+
"rollup": "2.79.2",
|
|
109
110
|
"rollup-plugin-auto-external": "2.0.0",
|
|
110
111
|
"rollup-plugin-copy": "3.4.0",
|
|
111
112
|
"rollup-plugin-ignore": "1.0.10",
|
|
@@ -119,14 +120,14 @@
|
|
|
119
120
|
"string-replace-loader": "3.1.0",
|
|
120
121
|
"style-loader": "3.3.1",
|
|
121
122
|
"tape": "5.5.3",
|
|
122
|
-
"webpack": "5.
|
|
123
|
+
"webpack": "5.97.1",
|
|
123
124
|
"webpack-bundle-analyzer": "4.5.0",
|
|
124
125
|
"webpack-cli": "4.9.2",
|
|
125
126
|
"webpack-dashboard": "3.3.7",
|
|
126
127
|
"webpack-dev-server": "4.9.0",
|
|
127
128
|
"webpack-merge": "5.8.0",
|
|
128
129
|
"webpack-notifier": "1.15.0",
|
|
129
|
-
"wslink": "1.
|
|
130
|
+
"wslink": "1.12.4",
|
|
130
131
|
"xml2js": "0.5.0"
|
|
131
132
|
},
|
|
132
133
|
"peerDependencies": {
|
|
@@ -142,7 +143,7 @@
|
|
|
142
143
|
"lint": "eslint Sources Examples",
|
|
143
144
|
"doc": "kw-doc -c ./Documentation/config.js",
|
|
144
145
|
"doc:www": "npm t -- --single-run && kw-doc -c ./Documentation/config.js -s",
|
|
145
|
-
"doc:
|
|
146
|
+
"doc:minified": "kw-doc -c ./Documentation/config.js -m",
|
|
146
147
|
"doc:generate-api": "node ./Documentation/generate-api-docs.js",
|
|
147
148
|
"example": "node ./Utilities/ExampleRunner/example-runner-cli.js -c ./Documentation/config.js",
|
|
148
149
|
"example:https": "node ./Utilities/ExampleRunner/example-runner-cli.js --server-type https -c ./Documentation/config.js",
|
|
@@ -150,7 +151,7 @@
|
|
|
150
151
|
"dev:esm": "npm run build:esm -- -w",
|
|
151
152
|
"dev:umd": "webpack --watch --config webpack.dev.js --progress",
|
|
152
153
|
"build": "npm run build:release",
|
|
153
|
-
"build:esm": "
|
|
154
|
+
"build:esm": "rollup -c rollup.config.js",
|
|
154
155
|
"build:umd": "webpack --config webpack.prod.js --progress",
|
|
155
156
|
"build:release": "npm run lint && concurrently \"cross-env NOLINT=1 npm run build:esm\" \"cross-env NOLINT=1 npm run build:umd\"",
|
|
156
157
|
"release:create-packages": "node ./Utilities/ci/build-npm-package.js",
|
|
@@ -163,7 +164,7 @@
|
|
|
163
164
|
"commit": "git cz",
|
|
164
165
|
"semantic-release": "semantic-release",
|
|
165
166
|
"prepare": "node ./Utilities/prepare.js",
|
|
166
|
-
"
|
|
167
|
+
"postinstall": "patch-package"
|
|
167
168
|
},
|
|
168
169
|
"config": {
|
|
169
170
|
"commitizen": {
|