@kitware/vtk.js 33.0.0-beta.1 → 33.0.0-beta.3

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.
Files changed (62) hide show
  1. package/Common/Core/DataArray.d.ts +4 -0
  2. package/Common/Core/DataArray.js +3 -0
  3. package/Common/Core/Math/index.js +1 -1
  4. package/Common/Core/Math.js +1 -1
  5. package/Common/Core/URLExtract.js +2 -6
  6. package/Common/DataModel/Line.js +1 -0
  7. package/Common/DataModel/PolyLine.js +4 -0
  8. package/Filters/Core/ThresholdPoints.d.ts +72 -0
  9. package/Filters/Core/ThresholdPoints.js +219 -0
  10. package/Filters/General/ContourTriangulator/helper.js +1 -1
  11. package/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js +1 -1
  12. package/IO/Geometry/DracoReader.d.ts +4 -4
  13. package/IO/Geometry/DracoReader.js +154 -105
  14. package/IO/Geometry/GLTFImporter/Animations.js +239 -0
  15. package/IO/Geometry/GLTFImporter/Constants.js +87 -0
  16. package/IO/Geometry/GLTFImporter/Decoder.js +69 -0
  17. package/IO/Geometry/GLTFImporter/Extensions.js +110 -0
  18. package/IO/Geometry/GLTFImporter/ORMTexture.worker.js +42 -0
  19. package/IO/Geometry/GLTFImporter/Parser.js +359 -0
  20. package/IO/Geometry/GLTFImporter/Reader.js +518 -0
  21. package/IO/Geometry/GLTFImporter/Utils.js +165 -0
  22. package/IO/Geometry/GLTFImporter.d.ts +266 -0
  23. package/IO/Geometry/GLTFImporter.js +245 -0
  24. package/IO/Geometry/IFCImporter.d.ts +163 -0
  25. package/IO/Geometry/IFCImporter.js +270 -0
  26. package/IO/Geometry/STLReader.d.ts +14 -0
  27. package/IO/Geometry/STLReader.js +57 -1
  28. package/IO/Geometry.js +5 -1
  29. package/IO/Image/HDRReader/Utils.js +1 -1
  30. package/IO/Image/HDRReader.js +1 -1
  31. package/IO/Image/TGAReader/Constants.js +28 -0
  32. package/IO/Image/TGAReader.d.ts +121 -0
  33. package/IO/Image/TGAReader.js +418 -0
  34. package/IO/Image/TIFFReader.d.ts +133 -0
  35. package/IO/Image/TIFFReader.js +144 -0
  36. package/IO/Image.js +5 -1
  37. package/IO/XML/XMLPolyDataWriter.js +1 -0
  38. package/Interaction/Manipulators/KeyboardCameraManipulator.d.ts +113 -0
  39. package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +1 -1
  40. package/Interaction/Style/InteractorStyleTrackballCamera.js +1 -1
  41. package/Rendering/Core/Glyph3DMapper.d.ts +45 -29
  42. package/Rendering/Core/ImageCPRMapper.js +1 -1
  43. package/Rendering/Core/ImageProperty.d.ts +22 -0
  44. package/Rendering/Core/PointPicker.js +10 -1
  45. package/Rendering/Core/Prop3D.js +1 -1
  46. package/Rendering/Core/RenderWindowInteractor.d.ts +1 -1
  47. package/Rendering/Core/RenderWindowInteractor.js +1 -1
  48. package/Rendering/Misc/CanvasView.js +4 -2
  49. package/Rendering/Misc/RemoteView.d.ts +9 -3
  50. package/Rendering/Misc/RemoteView.js +7 -3
  51. package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.d.ts +1 -1
  52. package/Rendering/OpenGL/ImageMapper.js +14 -7
  53. package/Rendering/OpenGL/Texture/supportsNorm16Linear.js +97 -0
  54. package/Rendering/OpenGL/Texture.js +18 -11
  55. package/Widgets/Widgets3D/AngleWidget/behavior.js +2 -0
  56. package/Widgets/Widgets3D/InteractiveOrientationWidget.js +1 -1
  57. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +17 -0
  58. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -0
  59. package/Widgets/Widgets3D/ShapeWidget/behavior.js +3 -0
  60. package/_virtual/rollup-plugin-worker-loader__module_Sources/IO/Geometry/GLTFImporter/ORMTexture.worker.js +296 -0
  61. package/index.d.ts +6 -0
  62. package/package.json +12 -10
@@ -408,6 +408,10 @@ export function extend(
408
408
 
409
409
  /**
410
410
  * Method use to create a new instance of vtkDataArray
411
+ *
412
+ * If the provided `values` is a plain Array and `dataType` is not explicitly provided,
413
+ * then the vtkDataArray data type will be a Float32Array.
414
+ *
411
415
  * @param {object} [initialValues] for pre-setting some of its content
412
416
  */
413
417
  export function newInstance(initialValues?: object): vtkDataArray;
@@ -497,6 +497,9 @@ const DEFAULT_VALUES = {
497
497
  function extend(publicAPI, model) {
498
498
  let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
499
499
  Object.assign(model, DEFAULT_VALUES, initialValues);
500
+ if (Array.isArray(initialValues.values) && initialValues.dataType === undefined) {
501
+ console.warn('vtkDataArray.newInstance: no dataType provided, converting to Float32Array');
502
+ }
500
503
  if (!model.empty && !model.values && !model.size) {
501
504
  throw new TypeError('Cannot create vtkDataArray object without: size > 0, values');
502
505
  }
@@ -2256,4 +2256,4 @@ var vtkMath$1 = /*#__PURE__*/Object.freeze({
2256
2256
  'default': vtkMath
2257
2257
  });
2258
2258
 
2259
- export { min as $, ldexp as A, xyz2rgb as B, degreesFromRadians as C, areEquals as D, clampValue as E, arrayRange as F, getMajorAxisIndex as G, createUninitializedBounds as H, identity as I, multiplyMatrix as J, floor as K, isInf as L, rgb2hsv as M, rgb2lab as N, lab2rgb as O, round as P, normalize2D as Q, nearestPowerOfTwo as R, multiply3x3_vect3 as S, getSparseOrthogonalMatrix as T, areBoundsInitialized as U, isPowerOfTwo as V, angleBetweenVectors as W, signedAngleBetweenVectors as X, createArray as Y, Pi as Z, ceil as _, areMatricesEqual as a, floatRGB2HexCode as a$, max as a0, arrayMin as a1, arrayMax as a2, ceilLog2 as a3, factorial as a4, binomial as a5, beginCombination as a6, nextCombination as a7, randomSeed as a8, getSeed as a9, multiplyQuaternion as aA, orthogonalize3x3 as aB, diagonalize3x3 as aC, singularValueDecomposition3x3 as aD, luFactorLinearSystem as aE, luSolveLinearSystem as aF, invertMatrix as aG, estimateMatrixCondition as aH, solveHomogeneousLeastSquares as aI, solveLeastSquares as aJ, hex2float as aK, lab2xyz as aL, xyz2lab as aM, rgb2xyz as aN, computeBoundsFromPoints as aO, clampAndNormalizeValue as aP, getScalarTypeFittingRange as aQ, getAdjustedScalarRange as aR, extentIsWithinOtherExtent as aS, boundsIsWithinOtherBounds as aT, pointIsWithinBounds as aU, solve3PointCircle as aV, inf as aW, negInf as aX, isFinite as aY, isNaN as aZ, floatToHex2 as a_, gaussian as aa, multiplyScalar2D as ab, multiplyAccumulate2D as ac, outer as ad, projectVector as ae, dot2D as af, projectVector2D as ag, gaussianAmplitude as ah, gaussianWeight as ai, outer2D as aj, norm2D as ak, rowsToMat4 as al, columnsToMat4 as am, columnsToMat3 as an, LUFactor3x3 as ao, LUSolve3x3 as ap, linearSolve3x3 as aq, multiply3x3_mat3 as ar, transpose3x3 as as, invert3x3 as at, identity3x3 as au, isIdentity as av, isIdentity3x3 as aw, quaternionToMatrix3x3 as ax, roundNumber as ay, matrix3x3ToQuaternion as az, roundVector as b, float2CssRGBA as b0, clampVector as c, dot as d, distance2BetweenPoints as e, vtkMath as f, solveLinearSystem as g, hsv2rgb as h, isNan as i, cross as j, add as k, normalize as l, multiplyAccumulate as m, norm as n, determinant2x2 as o, jacobiN as p, perpendiculars as q, radiansFromDegrees as r, subtract as s, jacobi as t, uninitializeBounds as u, vtkMath$1 as v, multiplyScalar as w, random as x, determinant3x3 as y, rowsToMat3 as z };
2259
+ export { min as $, degreesFromRadians as A, ldexp as B, xyz2rgb as C, areEquals as D, clampValue as E, arrayRange as F, getMajorAxisIndex as G, createUninitializedBounds as H, identity as I, multiplyMatrix as J, floor as K, isInf as L, rgb2hsv as M, rgb2lab as N, lab2rgb as O, round as P, normalize2D as Q, nearestPowerOfTwo as R, multiply3x3_vect3 as S, getSparseOrthogonalMatrix as T, areBoundsInitialized as U, isPowerOfTwo as V, angleBetweenVectors as W, signedAngleBetweenVectors as X, createArray as Y, Pi as Z, ceil as _, areMatricesEqual as a, floatRGB2HexCode as a$, max as a0, arrayMin as a1, arrayMax as a2, ceilLog2 as a3, factorial as a4, binomial as a5, beginCombination as a6, nextCombination as a7, randomSeed as a8, getSeed as a9, multiplyQuaternion as aA, orthogonalize3x3 as aB, diagonalize3x3 as aC, singularValueDecomposition3x3 as aD, luFactorLinearSystem as aE, luSolveLinearSystem as aF, invertMatrix as aG, estimateMatrixCondition as aH, solveHomogeneousLeastSquares as aI, solveLeastSquares as aJ, hex2float as aK, lab2xyz as aL, xyz2lab as aM, rgb2xyz as aN, computeBoundsFromPoints as aO, clampAndNormalizeValue as aP, getScalarTypeFittingRange as aQ, getAdjustedScalarRange as aR, extentIsWithinOtherExtent as aS, boundsIsWithinOtherBounds as aT, pointIsWithinBounds as aU, solve3PointCircle as aV, inf as aW, negInf as aX, isFinite as aY, isNaN as aZ, floatToHex2 as a_, gaussian as aa, multiplyScalar2D as ab, multiplyAccumulate2D as ac, outer as ad, projectVector as ae, dot2D as af, projectVector2D as ag, gaussianAmplitude as ah, gaussianWeight as ai, outer2D as aj, norm2D as ak, rowsToMat4 as al, columnsToMat4 as am, columnsToMat3 as an, LUFactor3x3 as ao, LUSolve3x3 as ap, linearSolve3x3 as aq, multiply3x3_mat3 as ar, transpose3x3 as as, invert3x3 as at, identity3x3 as au, isIdentity as av, isIdentity3x3 as aw, quaternionToMatrix3x3 as ax, roundNumber as ay, matrix3x3ToQuaternion as az, roundVector as b, float2CssRGBA as b0, clampVector as c, dot as d, distance2BetweenPoints as e, vtkMath as f, solveLinearSystem as g, hsv2rgb as h, isNan as i, cross as j, add as k, normalize as l, multiplyAccumulate as m, norm as n, determinant2x2 as o, jacobiN as p, perpendiculars as q, radiansFromDegrees as r, subtract as s, jacobi as t, uninitializeBounds as u, vtkMath$1 as v, multiplyScalar as w, random as x, determinant3x3 as y, rowsToMat3 as z };
@@ -1,4 +1,4 @@
1
1
  import 'seedrandom';
2
2
  import '../../macros2.js';
3
3
  import './Math/Constants.js';
4
- export { ao as LUFactor3x3, ap as LUSolve3x3, Z as Pi, k as add, W as angleBetweenVectors, U as areBoundsInitialized, D as areEquals, a as areMatricesEqual, a2 as arrayMax, a1 as arrayMin, F as arrayRange, a6 as beginCombination, a5 as binomial, aT as boundsIsWithinOtherBounds, _ as ceil, a3 as ceilLog2, aP as clampAndNormalizeValue, E as clampValue, c as clampVector, an as columnsToMat3, am as columnsToMat4, aO as computeBoundsFromPoints, Y as createArray, H as createUninitializedBounds, j as cross, f as default, C as degreesFromRadians, o as determinant2x2, y as determinant3x3, aC as diagonalize3x3, e as distance2BetweenPoints, d as dot, af as dot2D, aH as estimateMatrixCondition, aS as extentIsWithinOtherExtent, a4 as factorial, b0 as float2CssRGBA, a$ as floatRGB2HexCode, a_ as floatToHex2, K as floor, aa as gaussian, ah as gaussianAmplitude, ai as gaussianWeight, aR as getAdjustedScalarRange, G as getMajorAxisIndex, aQ as getScalarTypeFittingRange, a9 as getSeed, T as getSparseOrthogonalMatrix, aK as hex2float, h as hsv2rgb, I as identity, au as identity3x3, aW as inf, at as invert3x3, aG as invertMatrix, aY as isFinite, av as isIdentity, aw as isIdentity3x3, L as isInf, aZ as isNaN, i as isNan, V as isPowerOfTwo, t as jacobi, p as jacobiN, O as lab2rgb, aL as lab2xyz, A as ldexp, aq as linearSolve3x3, aE as luFactorLinearSystem, aF as luSolveLinearSystem, az as matrix3x3ToQuaternion, a0 as max, $ as min, ar as multiply3x3_mat3, S as multiply3x3_vect3, m as multiplyAccumulate, ac as multiplyAccumulate2D, J as multiplyMatrix, aA as multiplyQuaternion, w as multiplyScalar, ab as multiplyScalar2D, R as nearestPowerOfTwo, aX as negInf, a7 as nextCombination, n as norm, ak as norm2D, l as normalize, Q as normalize2D, aB as orthogonalize3x3, ad as outer, aj as outer2D, q as perpendiculars, aU as pointIsWithinBounds, ae as projectVector, ag as projectVector2D, ax as quaternionToMatrix3x3, r as radiansFromDegrees, x as random, a8 as randomSeed, M as rgb2hsv, N as rgb2lab, aN as rgb2xyz, P as round, ay as roundNumber, b as roundVector, z as rowsToMat3, al as rowsToMat4, X as signedAngleBetweenVectors, aD as singularValueDecomposition3x3, aV as solve3PointCircle, aI as solveHomogeneousLeastSquares, aJ as solveLeastSquares, g as solveLinearSystem, s as subtract, as as transpose3x3, u as uninitializeBounds, aM as xyz2lab, B as xyz2rgb } from './Math/index.js';
4
+ export { ao as LUFactor3x3, ap as LUSolve3x3, Z as Pi, k as add, W as angleBetweenVectors, U as areBoundsInitialized, D as areEquals, a as areMatricesEqual, a2 as arrayMax, a1 as arrayMin, F as arrayRange, a6 as beginCombination, a5 as binomial, aT as boundsIsWithinOtherBounds, _ as ceil, a3 as ceilLog2, aP as clampAndNormalizeValue, E as clampValue, c as clampVector, an as columnsToMat3, am as columnsToMat4, aO as computeBoundsFromPoints, Y as createArray, H as createUninitializedBounds, j as cross, f as default, A as degreesFromRadians, o as determinant2x2, y as determinant3x3, aC as diagonalize3x3, e as distance2BetweenPoints, d as dot, af as dot2D, aH as estimateMatrixCondition, aS as extentIsWithinOtherExtent, a4 as factorial, b0 as float2CssRGBA, a$ as floatRGB2HexCode, a_ as floatToHex2, K as floor, aa as gaussian, ah as gaussianAmplitude, ai as gaussianWeight, aR as getAdjustedScalarRange, G as getMajorAxisIndex, aQ as getScalarTypeFittingRange, a9 as getSeed, T as getSparseOrthogonalMatrix, aK as hex2float, h as hsv2rgb, I as identity, au as identity3x3, aW as inf, at as invert3x3, aG as invertMatrix, aY as isFinite, av as isIdentity, aw as isIdentity3x3, L as isInf, aZ as isNaN, i as isNan, V as isPowerOfTwo, t as jacobi, p as jacobiN, O as lab2rgb, aL as lab2xyz, B as ldexp, aq as linearSolve3x3, aE as luFactorLinearSystem, aF as luSolveLinearSystem, az as matrix3x3ToQuaternion, a0 as max, $ as min, ar as multiply3x3_mat3, S as multiply3x3_vect3, m as multiplyAccumulate, ac as multiplyAccumulate2D, J as multiplyMatrix, aA as multiplyQuaternion, w as multiplyScalar, ab as multiplyScalar2D, R as nearestPowerOfTwo, aX as negInf, a7 as nextCombination, n as norm, ak as norm2D, l as normalize, Q as normalize2D, aB as orthogonalize3x3, ad as outer, aj as outer2D, q as perpendiculars, aU as pointIsWithinBounds, ae as projectVector, ag as projectVector2D, ax as quaternionToMatrix3x3, r as radiansFromDegrees, x as random, a8 as randomSeed, M as rgb2hsv, N as rgb2lab, aN as rgb2xyz, P as round, ay as roundNumber, b as roundVector, z as rowsToMat3, al as rowsToMat4, X as signedAngleBetweenVectors, aD as singularValueDecomposition3x3, aV as solve3PointCircle, aI as solveHomogeneousLeastSquares, aJ as solveLeastSquares, g as solveLinearSystem, s as subtract, as as transpose3x3, u as uninitializeBounds, aM as xyz2lab, C as xyz2rgb } from './Math/index.js';
@@ -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 queryTokens = (query || '').replace(/#.*/, '') // remove hash query
31
- .replace('?', '') // Remove ? from the head
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
  }
@@ -92,6 +92,7 @@ function intersection(a1, a2, b1, b2, u, v) {
92
92
  obj = distanceToLine(p[i], l1[i], l2[i]);
93
93
  if (obj.distance < minDist) {
94
94
  minDist = obj.distance;
95
+ obj.t;
95
96
  }
96
97
  }
97
98
  return IntersectionState.ON_LINE;
@@ -28,6 +28,10 @@ function vtkPolyLine(publicAPI, model) {
28
28
  outObj.subId = subId;
29
29
  outObj.t = lineIntersected.t;
30
30
  pDistMin = pDist;
31
+ for (let k = 0; k < 3; k++) {
32
+ x[k];
33
+ pCoords[k];
34
+ }
31
35
  }
32
36
  }
33
37
  }
@@ -0,0 +1,72 @@
1
+ import { vtkAlgorithm, vtkObject } from './../../interfaces';
2
+
3
+ export interface ThresholdCriteria {
4
+ arrayName: string;
5
+ fieldAssociation: string;
6
+ operation: string;
7
+ value: number;
8
+ }
9
+
10
+ /**
11
+ *
12
+ */
13
+ export interface IThresholdPointsInitialValues {
14
+ criterias?: ThresholdCriteria[];
15
+ }
16
+
17
+ type vtkThresholdPointsBase = vtkObject & vtkAlgorithm;
18
+
19
+ export interface vtkThresholdPoints extends vtkThresholdPointsBase {
20
+ /**
21
+ * Get the desired precision for the output types.
22
+ */
23
+ getCriterias(): ThresholdCriteria[];
24
+
25
+ /**
26
+ * Set the desired precision for the output types.
27
+ * @param outputPointsPrecision
28
+ */
29
+ setCriterias(criterias: ThresholdCriteria[]): boolean;
30
+
31
+ /**
32
+ *
33
+ * @param inData
34
+ * @param outData
35
+ */
36
+ requestData(inData: any, outData: any): void;
37
+ }
38
+
39
+ /**
40
+ * Method used to decorate a given object (publicAPI+model) with vtkThresholdPoints characteristics.
41
+ *
42
+ * @param publicAPI object on which methods will be bounds (public)
43
+ * @param model object on which data structure will be bounds (protected)
44
+ * @param {IThresholdPointsInitialValues} [initialValues] (default: {})
45
+ */
46
+ export function extend(
47
+ publicAPI: object,
48
+ model: object,
49
+ initialValues?: IThresholdPointsInitialValues
50
+ ): void;
51
+
52
+ /**
53
+ * Method used to create a new instance of vtkThresholdPoints
54
+ * @param {IThresholdPointsInitialValues} [initialValues] for pre-setting some of its content
55
+ */
56
+ export function newInstance(
57
+ initialValues?: IThresholdPointsInitialValues
58
+ ): vtkThresholdPoints;
59
+
60
+ /**
61
+ * vtkThresholdPoints - extracts points whose scalar value satisfies threshold criterion
62
+ *
63
+ * vtkThresholdPoints is a filter that extracts points from a dataset that
64
+ * satisfy a threshold criterion. The criterion can take three forms:
65
+ * 1) greater than a particular value; 2) less than a particular value; or
66
+ * 3) between a particular value. The output of the filter is polygonal data.
67
+ */
68
+ export declare const vtkThresholdPoints: {
69
+ newInstance: typeof newInstance;
70
+ extend: typeof extend;
71
+ };
72
+ export default vtkThresholdPoints;
@@ -0,0 +1,219 @@
1
+ import { m as macro } from '../../macros2.js';
2
+ import vtkCellArray from '../../Common/Core/CellArray.js';
3
+ import vtkDataArray from '../../Common/Core/DataArray.js';
4
+ import vtkPoints from '../../Common/Core/Points.js';
5
+ import vtkPolyData from '../../Common/DataModel/PolyData.js';
6
+ import { POLYDATA_FIELDS } from '../../Common/DataModel/PolyData/Constants.js';
7
+
8
+ const {
9
+ vtkErrorMacro
10
+ } = macro;
11
+ const OperationType = {
12
+ Below: 'Below',
13
+ Above: 'Above'
14
+ };
15
+
16
+ // Function to perform binary search on a sorted array
17
+ function binarySearch(items, value) {
18
+ let firstIndex = 0;
19
+ let lastIndex = items.length - 1;
20
+ let middleIndex = Math.floor((lastIndex + firstIndex) / 2);
21
+ while (items[middleIndex] !== value && firstIndex < lastIndex) {
22
+ if (value < items[middleIndex]) {
23
+ lastIndex = middleIndex - 1;
24
+ } else if (value > items[middleIndex]) {
25
+ firstIndex = middleIndex + 1;
26
+ }
27
+ middleIndex = Math.floor((lastIndex + firstIndex) / 2);
28
+ }
29
+ return {
30
+ found: items[middleIndex] === value,
31
+ index: Math.max(items[middleIndex] < value ? middleIndex + 1 : middleIndex, 0)
32
+ };
33
+ }
34
+ function camelize(str) {
35
+ return str.replace(/(?:^\w|[A-Z]|\b\w)/g, letter => letter.toUpperCase()).replace(/\s+/g, '');
36
+ }
37
+ // ----------------------------------------------------------------------------
38
+ // vtkThresholdPoints methods
39
+ // ----------------------------------------------------------------------------
40
+
41
+ function vtkThresholdPoints(publicAPI, model) {
42
+ // Set our classname
43
+ model.classHierarchy.push('vtkThresholdPoints');
44
+ publicAPI.requestData = (inData, outData) => {
45
+ const input = inData[0];
46
+ const output = vtkPolyData.newInstance();
47
+ outData[0] = output;
48
+ if (model.criterias.length === 0) {
49
+ output.shallowCopy(input);
50
+ return;
51
+ }
52
+ const oldPoints = input.getPoints();
53
+ const oldPointCount = oldPoints.getNumberOfPoints();
54
+ const oldPointData = input.getPointData();
55
+ const oldPointsData = oldPoints.getData();
56
+ const newPointsData = macro.newTypedArray(input.getPoints().getDataType(), 3 * oldPointCount);
57
+ const oldArrays = [];
58
+ const newArraysData = [];
59
+ const numArrays = oldPointData.getNumberOfArrays();
60
+ for (let i = 0; i < numArrays; ++i) {
61
+ const oldArray = oldPointData.getArrayByIndex(i);
62
+ oldArrays.push(oldArray);
63
+ newArraysData.push(macro.newTypedArray(oldArray.getDataType(), oldPointCount * oldArray.getNumberOfComponents()));
64
+ }
65
+ const pointAcceptanceFunctions = model.criterias.map(criteria => {
66
+ let inputArray = null;
67
+ let component = 0;
68
+ let numberOfComponents = 1;
69
+ if (criteria.fieldAssociation === 'PointData') {
70
+ inputArray = oldArrays.find(oldArray => oldArray.getName() === criteria.arrayName);
71
+ numberOfComponents = inputArray.getNumberOfComponents();
72
+ } else if (criteria.fieldAssociation === 'Points') {
73
+ inputArray = oldPoints;
74
+ if (criteria.arrayName === 'z') {
75
+ component = 2;
76
+ } else {
77
+ component = criteria.arrayName === 'y' ? 1 : 0;
78
+ }
79
+ numberOfComponents = 3;
80
+ } else {
81
+ vtkErrorMacro('No field association');
82
+ }
83
+ const inputArrayData = inputArray.getData();
84
+ const operation = criteria.operation === OperationType.Below ? (a, b) => a < b : (a, b) => a > b;
85
+ const pointAcceptanceFunction = pointId => operation(inputArrayData[numberOfComponents * pointId + component], criteria.value);
86
+ return pointAcceptanceFunction;
87
+ });
88
+ const thresholdedPointIds = []; // sorted list
89
+ let newI = 0;
90
+ for (let i = 0; i < oldPointCount; ++i) {
91
+ const keepPoint = pointAcceptanceFunctions.reduce((keep, pointAcceptanceFunction) => keep && pointAcceptanceFunction(i), true);
92
+ if (keepPoint) {
93
+ let ii = 3 * i;
94
+ let newII = 3 * newI;
95
+ for (let c = 0; c < 3; ++c) {
96
+ newPointsData[newII++] = oldPointsData[ii++];
97
+ }
98
+ for (let j = 0; j < numArrays; ++j) {
99
+ const oldArrayData = oldArrays[j].getData();
100
+ const newArrayData = newArraysData[j];
101
+ const cc = oldArrays[j].getNumberOfComponents();
102
+ ii = cc * i;
103
+ newII = cc * newI;
104
+ for (let c = 0; c < cc; ++c) {
105
+ newArrayData[newII++] = oldArrayData[ii++];
106
+ }
107
+ }
108
+ ++newI;
109
+ } else {
110
+ thresholdedPointIds.push(i);
111
+ }
112
+ }
113
+ if (thresholdedPointIds.length === 0) {
114
+ output.shallowCopy(input);
115
+ return;
116
+ }
117
+ output.setPoints(vtkPoints.newInstance({
118
+ values: newPointsData,
119
+ size: 3 * newI
120
+ }));
121
+ for (let i = 0; i < numArrays; ++i) {
122
+ const oldArray = oldArrays[i];
123
+ const newArray = vtkDataArray.newInstance({
124
+ name: oldArray.getName(),
125
+ values: newArraysData[i],
126
+ dataType: oldArray.getDataType(),
127
+ numberOfComponents: oldArray.getNumberOfComponents(),
128
+ size: newI * oldArray.getNumberOfComponents()
129
+ });
130
+ output.getPointData().addArray(newArray);
131
+ oldPointData.getAttributes(oldArray).forEach(attrType => {
132
+ output.getPointData().setAttribute(newArray, attrType);
133
+ });
134
+ }
135
+ POLYDATA_FIELDS.forEach(cellType => {
136
+ const oldPolysData = input[`get${camelize(cellType)}`]().getData();
137
+ const newCellData = macro.newTypedArray(input.getPolys().getDataType(), oldPolysData.length);
138
+ const newPointIds = []; // first point starts at [1]
139
+ const firstPointIndex = cellType === 'verts' ? 0 : 1;
140
+ let numberOfPoints = 1;
141
+ let newP = 0;
142
+ for (let c = 0; c < oldPolysData.length; c += numberOfPoints + firstPointIndex) {
143
+ if (firstPointIndex === 1) {
144
+ // not for verts
145
+ numberOfPoints = oldPolysData[c];
146
+ }
147
+ let keepCell = true;
148
+ for (let p = firstPointIndex; p <= numberOfPoints; ++p) {
149
+ const {
150
+ found,
151
+ index
152
+ } = binarySearch(thresholdedPointIds, oldPolysData[c + p]);
153
+ if (found) {
154
+ keepCell = false;
155
+ break;
156
+ }
157
+ newPointIds[p] = oldPolysData[c + p] - index;
158
+ }
159
+ if (keepCell) {
160
+ newCellData[newP++] = numberOfPoints;
161
+ for (let p = firstPointIndex; p <= numberOfPoints;) {
162
+ newCellData[newP++] = newPointIds[p++];
163
+ }
164
+ }
165
+ }
166
+ output[`set${camelize(cellType)}`](vtkCellArray.newInstance({
167
+ values: newCellData,
168
+ size: newP,
169
+ // it may shorter than original array if cells are not kept
170
+ dataType: input.getPolys().getDataType()
171
+ }));
172
+ });
173
+ outData[0] = output;
174
+ };
175
+ }
176
+
177
+ // ----------------------------------------------------------------------------
178
+
179
+ function defaultValues(publicAPI, model) {
180
+ let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
181
+ return {
182
+ criterias: [],
183
+ // arrayName: string, fieldAssociation: string, operation: string, value: number
184
+ ...initialValues
185
+ };
186
+ }
187
+
188
+ // ----------------------------------------------------------------------------
189
+
190
+ function extend(publicAPI, model) {
191
+ let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
192
+ Object.assign(model, defaultValues(publicAPI, model, initialValues));
193
+
194
+ // Build VTK API
195
+ macro.setGet(publicAPI, model, []);
196
+ macro.get(publicAPI, model, []);
197
+ macro.setGetArray(publicAPI, model, ['criterias']);
198
+
199
+ // Make this a VTK object
200
+ macro.obj(publicAPI, model);
201
+ macro.algo(publicAPI, model, 1, 1);
202
+
203
+ // Object specific methods
204
+ vtkThresholdPoints(publicAPI, model);
205
+ }
206
+
207
+ // ----------------------------------------------------------------------------
208
+
209
+ const newInstance = macro.newInstance(extend, 'vtkThresholdPoints');
210
+
211
+ // ----------------------------------------------------------------------------
212
+
213
+ var index = {
214
+ newInstance,
215
+ extend,
216
+ OperationType
217
+ };
218
+
219
+ export { index as default, extend, newInstance };
@@ -1747,11 +1747,11 @@ function vtkCCSCutHoleyPolys(polys, points, polyGroups, polyEdges, normal) {
1747
1747
  // Do a quick search first, then do an exhaustive search.
1748
1748
  let madeCut = 0;
1749
1749
  let inner = 0;
1750
+ const cuts = [[0, 0], [0, 0]];
1750
1751
  for (let exhaustive = 0; exhaustive < 2 && !madeCut; exhaustive++) {
1751
1752
  for (let j = 1; j < polyGroup.length; j++) {
1752
1753
  inner = innerBySize[j][1];
1753
1754
  innerPolyId = polyGroup[inner];
1754
- const cuts = [];
1755
1755
  if (vtkCCSFindCuts(polys, polyGroup, outerPolyId, innerPolyId, points, normal, cuts, exhaustive)) {
1756
1756
  vtkCCSMakeCuts(polys, polyEdges, outerPolyId, innerPolyId, points, cuts);
1757
1757
  madeCut = 1;
@@ -1,4 +1,4 @@
1
- import { strToU8, unzipSync, strFromU8, decompressSync } from 'fflate';
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';
@@ -118,15 +118,15 @@ export function newInstance(
118
118
  ): vtkDracoReader;
119
119
 
120
120
  /**
121
- *
121
+ * Get the draco decoder
122
122
  */
123
123
  export function getDracoDecoder(): any;
124
124
 
125
125
  /**
126
- *
127
- * @param createDracoModule
126
+ * Set the draco decoder
127
+ * @param dracoDecoder
128
128
  */
129
- export function setDracoDecoder(createDracoModule: any): void;
129
+ export function setDracoDecoder(dracoDecoder: any): Promise<any>;
130
130
 
131
131
  /**
132
132
  * Load the WASM decoder from url and set the decoderModule