@kitware/vtk.js 27.4.3 → 27.4.5

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.
@@ -20,6 +20,20 @@ export interface vtkContourTriangulator extends vtkContourTriangulatorBase {
20
20
  * @param {any} outData
21
21
  */
22
22
  requestData(inData: any, outData: any): void;
23
+
24
+ /**
25
+ * Sets the behavior of the filter regarding polys.
26
+ * @param {boolean} triangulate whether the filter should triangulate polys
27
+ * or leave them untouched. True by default
28
+ * @return {boolean} true if it changes
29
+ */
30
+ setTriangulatePolys(triangulate: boolean): boolean;
31
+
32
+ /**
33
+ * Returns the behavior of the filter regarding polys.
34
+ * @return {boolean} True if the filter triangulates polys, false otherwise.
35
+ */
36
+ getTriangulatePolys(): boolean;
23
37
  }
24
38
 
25
39
  // ----------------------------------------------------------------------------
@@ -27,12 +27,13 @@ function triangulateContours(polyData, firstLine, numLines, polys, normal) {
27
27
 
28
28
  var newPolys = [];
29
29
  var incompletePolys = [];
30
- var oriented = normal != null;
30
+ var oriented = (normal === null || normal === void 0 ? void 0 : normal.length) < 3;
31
31
  vtkCCSMakePolysFromLines(polyData, firstLine, firstLine + numLines, oriented, newPolys, incompletePolys); // if no normal specified, then compute one from largest contour
32
32
 
33
33
  var computedNormal = normal;
34
34
 
35
- if (normal == null) {
35
+ if (!oriented) {
36
+ computedNormal = [0, 0, 1];
36
37
  var maxnorm = 0;
37
38
  var n = [];
38
39
 
@@ -65,7 +66,7 @@ function triangulateContours(polyData, firstLine, numLines, polys, normal) {
65
66
  // Initialize each group to hold just one polygon.
66
67
 
67
68
  var numNewPolys = newPolys.length;
68
- var polyGroups = [];
69
+ var polyGroups = new Array(numNewPolys);
69
70
 
70
71
  for (var _i = 0; _i < numNewPolys; _i++) {
71
72
  polyGroups[_i] = [_i];
@@ -137,7 +138,8 @@ function vtkContourTriangulator(publicAPI, model) {
137
138
 
138
139
  publicAPI.requestData = function (inData, outData) {
139
140
  // implement requestData
140
- var input = inData[0];
141
+ var input = inData[0]; // FIXME: do not instantiate a new polydata each time the filter is executed.
142
+
141
143
  var output = vtkPolyData.newInstance();
142
144
  outData[0] = output;
143
145
 
@@ -161,7 +163,7 @@ function vtkContourTriangulator(publicAPI, model) {
161
163
  output.setPolys(polysArray);
162
164
  output.setPoints(input.getPoints());
163
165
  output.getPointData().passData(input.getPointData());
164
- triangulationError = !triangulateContours(input, input.getNumberOfVerts(), lines.getNumberOfCells(), polysArray, [], model.triangulatePolys);
166
+ triangulationError = !triangulateContours(input, input.getNumberOfVerts(), lines.getNumberOfCells(), polysArray, null, model.triangulatePolys);
165
167
 
166
168
  if (triangulationError && TRIANGULATION_ERROR_DISPLAY) {
167
169
  vtkErrorMacro('Triangulation failed, output might have holes.');
@@ -185,7 +187,7 @@ function extend(publicAPI, model) {
185
187
  macro.obj(publicAPI, model); // Also make it an algorithm with one input and one output
186
188
 
187
189
  macro.algo(publicAPI, model, 1, 1);
188
- macro.setGet(publicAPI, model, ['triangulate']); // Object specific methods
190
+ macro.setGet(publicAPI, model, ['triangulatePolys']); // Object specific methods
189
191
 
190
192
  vtkContourTriangulator(publicAPI, model);
191
193
  } // ----------------------------------------------------------------------------
@@ -649,7 +649,7 @@ export interface vtkRenderer extends vtkViewport {
649
649
  * @param {Number} r Defines the red component (between 0 and 1).
650
650
  * @param {Number} g Defines the green component (between 0 and 1).
651
651
  * @param {Number} b Defines the blue component (between 0 and 1).
652
- * @param {Number} b Defines the alpha component (between 0 and 1).
652
+ * @param {Number} a Defines the alpha component (between 0 and 1).
653
653
  */
654
654
  setBackground(r: number, g: number, b: number, a: number): boolean;
655
655
 
@@ -1,5 +1,5 @@
1
1
  import { vtkObject } from './../../interfaces';
2
- import { RGBColor } from './../../types';
2
+ import { RGBAColor, RGBColor } from './../../types';
3
3
  import vtkRenderer from './../Core/Renderer';
4
4
  import vtkRenderWindow from './../Core/RenderWindow';
5
5
  import vtkRenderWindowInteractor from './../Core/RenderWindowInteractor';
@@ -12,7 +12,7 @@ import vtkRenderWindowInteractor from './../Core/RenderWindowInteractor';
12
12
  *
13
13
  */
14
14
  export interface IFullScreenRenderWindowInitialValues {
15
- background?: RGBColor;
15
+ background?: RGBColor | RGBAColor;
16
16
  container?: HTMLElement
17
17
  containerStyle?: object;
18
18
  controlPanelStyle?: object;
@@ -94,9 +94,9 @@ export interface vtkFullScreenRenderWindow extends vtkObject {
94
94
 
95
95
  /**
96
96
  * Set background color
97
- * @param {Number[]} background The background color.
97
+ * @param {RGBColor | RGBAColor} background The background color.
98
98
  */
99
- setBackground(background: number[]): boolean;
99
+ setBackground(background: RGBColor | RGBAColor): boolean;
100
100
 
101
101
  /**
102
102
  * Hide or show controller
@@ -1,5 +1,5 @@
1
1
  import { vtkObject, vtkSubscription } from './../../interfaces';
2
- import { RGBColor } from './../../types';
2
+ import { RGBAColor, RGBColor } from './../../types';
3
3
  import vtkRenderer from './../Core/Renderer';
4
4
  import vtkRenderWindow from './../Core/RenderWindow';
5
5
  import vtkRenderWindowInteractor from './../Core/RenderWindowInteractor';
@@ -10,7 +10,7 @@ import vtkOpenGLRenderWindow from './../OpenGL/RenderWindow';
10
10
  *
11
11
  */
12
12
  export interface IGenericRenderWindowInitialValues {
13
- background?: RGBColor;
13
+ background?: RGBColor|RGBAColor;
14
14
  listenWindowResize?: boolean;
15
15
  container?: HTMLElement,
16
16
  }
@@ -62,9 +62,10 @@ export interface vtkGenericRenderWindow extends vtkObject {
62
62
 
63
63
  /**
64
64
  * Set background color
65
- * @param {RGBColor} background The background color.
65
+ * @param {RGBColor|RGBAColor} background The background color.
66
+ * @returns true if the background color actually changed, false otherwise
66
67
  */
67
- setBackground(background: RGBColor): boolean;
68
+ setBackground(background: RGBColor|RGBAColor): boolean;
68
69
 
69
70
  /**
70
71
  * Set thecontainer element
@@ -499,6 +499,18 @@ function removeUnavailableArrays(fields, availableNames) {
499
499
  fields.removeArray(namesToDelete[_i]);
500
500
  }
501
501
  }
502
+ /**
503
+ * Get a unique string suitable for use as state.arrays key.
504
+ * @param {object} arrayMeta
505
+ * @returns {string} array key
506
+ */
507
+
508
+
509
+ function getArrayKey(arrayMeta) {
510
+ // Two arrays can have exactly the same hash so try to distinquish with name.
511
+ var namePart = arrayMeta.name ? "_".concat(arrayMeta.name) : '';
512
+ return "".concat(arrayMeta.hash, "_").concat(arrayMeta.dataType).concat(namePart);
513
+ }
502
514
 
503
515
  function createDataSetUpdate() {
504
516
  var piecesToFetch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
@@ -520,7 +532,7 @@ function createDataSetUpdate() {
520
532
  if (state.properties[key]) {
521
533
  var arrayMeta = state.properties[key];
522
534
  arrayMeta.registration = "set".concat(capitalize(key));
523
- var arrayKey = "".concat(arrayMeta.hash, "_").concat(arrayMeta.dataType);
535
+ var arrayKey = getArrayKey(arrayMeta);
524
536
  state.arrays[arrayKey] = arrayMeta;
525
537
  delete localProperties[key];
526
538
  }
@@ -532,7 +544,7 @@ function createDataSetUpdate() {
532
544
  for (var _i2 = 0; _i2 < fieldsArrays.length; _i2++) {
533
545
  var _arrayMeta = fieldsArrays[_i2];
534
546
 
535
- var _arrayKey = "".concat(_arrayMeta.hash, "_").concat(_arrayMeta.dataType);
547
+ var _arrayKey = getArrayKey(_arrayMeta);
536
548
 
537
549
  state.arrays[_arrayKey] = _arrayMeta;
538
550
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "27.4.3",
3
+ "version": "27.4.5",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",