@kitware/vtk.js 22.1.4 → 22.1.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.
@@ -3,11 +3,11 @@ import vtkBoundingBox, { STATIC } from '../../../Common/DataModel/BoundingBox.js
3
3
  import vtkCubeSource from '../../../Filters/Sources/CubeSource.js';
4
4
  import vtkCutter from '../../../Filters/Core/Cutter.js';
5
5
  import vtkPlane from '../../../Common/DataModel/Plane.js';
6
- import { g as subtract, l as normalize, j as cross, Q as multiplyAccumulate, S as signedAngleBetweenVectors } from '../../../Common/Core/Math/index.js';
6
+ import { g as subtract, l as normalize, j as cross, t as multiplyScalar, Q as multiplyAccumulate, S as signedAngleBetweenVectors } from '../../../Common/Core/Math/index.js';
7
7
  import vtkMatrixBuilder from '../../../Common/Core/MatrixBuilder.js';
8
8
  import { ViewTypes } from '../../Core/WidgetManager/Constants.js';
9
9
 
10
- var EPSILON = 0.00001;
10
+ var EPSILON = 10e-7;
11
11
  /**
12
12
  * Fit the plane defined by origin, p1, p2 onto the bounds.
13
13
  * Plane is untouched if does not intersect bounds.
@@ -15,6 +15,7 @@ var EPSILON = 0.00001;
15
15
  * @param {Array} origin
16
16
  * @param {Array} p1
17
17
  * @param {Array} p2
18
+ * @return {Boolean} false if no bounds have been found, else true
18
19
  */
19
20
 
20
21
  function boundPlane(bounds, origin, p1, p2) {
@@ -26,19 +27,26 @@ function boundPlane(bounds, origin, p1, p2) {
26
27
  normalize(v2);
27
28
  var n = [0, 0, 1];
28
29
  cross(v1, v2, n);
29
- normalize(n);
30
+ normalize(n); // Inflate bounds in order to avoid precision error when cutting cubesource
31
+
32
+ var inflatedBounds = _toConsumableArray(bounds);
33
+
34
+ var eps = [].concat(n);
35
+ multiplyScalar(eps, EPSILON);
36
+ vtkBoundingBox.addBounds(inflatedBounds, bounds[0] + eps[0], bounds[1] + eps[0], bounds[2] + eps[1], bounds[3] + eps[1], bounds[4] + eps[2], bounds[5] + eps[2]);
37
+ vtkBoundingBox.addBounds(inflatedBounds, bounds[0] - eps[0], bounds[1] - eps[0], bounds[2] - eps[1], bounds[3] - eps[1], bounds[4] - eps[2], bounds[5] - eps[2]);
30
38
  var plane = vtkPlane.newInstance();
31
39
  plane.setOrigin.apply(plane, _toConsumableArray(origin));
32
40
  plane.setNormal.apply(plane, n);
33
41
  var cubeSource = vtkCubeSource.newInstance();
34
- cubeSource.setBounds(bounds);
42
+ cubeSource.setBounds(inflatedBounds);
35
43
  var cutter = vtkCutter.newInstance();
36
44
  cutter.setCutFunction(plane);
37
45
  cutter.setInputConnection(cubeSource.getOutputPort());
38
46
  var cutBounds = cutter.getOutputData();
39
47
 
40
48
  if (cutBounds.getNumberOfPoints() === 0) {
41
- return;
49
+ return false;
42
50
  }
43
51
 
44
52
  var localBounds = STATIC.computeLocalBounds(cutBounds.getPoints(), v1, v2, n);
@@ -48,6 +56,8 @@ function boundPlane(bounds, origin, p1, p2) {
48
56
  p1[i] = localBounds[1] * v1[i] + localBounds[2] * v2[i] + localBounds[4] * n[i];
49
57
  p2[i] = localBounds[0] * v1[i] + localBounds[3] * v2[i] + localBounds[4] * n[i];
50
58
  }
59
+
60
+ return true;
51
61
  } // Project point (inPoint) to the bounds of the image according to a plane
52
62
  // defined by two vectors (v1, v2)
53
63
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "22.1.4",
3
+ "version": "22.1.5",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",