@kitware/vtk.js 24.4.1 → 24.5.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/Math/index.js +1 -1
- package/Common/Core/Math.js +1 -1
- package/Filters/Core/PolyDataNormals.js +124 -0
- package/Filters/Core.js +3 -1
- package/Filters/General/OBBTree.js +1 -1
- package/Filters/General/WindowedSincPolyDataFilter.js +1 -1
- package/IO/Misc/OBJReader.d.ts +33 -2
- package/IO/Misc/OBJReader.js +132 -34
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +1 -1
- package/package.json +1 -1
|
@@ -2329,4 +2329,4 @@ var vtkMath$1 = /*#__PURE__*/Object.freeze({
|
|
|
2329
2329
|
'default': vtkMath
|
|
2330
2330
|
});
|
|
2331
2331
|
|
|
2332
|
-
export { binomial as $, degreesFromRadians as A, areEquals as B, clampValue as C, arrayRange as D, getMajorAxisIndex as E, isInf as F, rgb2hsv as G, rgb2lab as H, lab2rgb as I, floor as J, round as K, normalize2D as L, nearestPowerOfTwo as M, createUninitializedBounds as N, multiply3x3_vect3 as O, areBoundsInitialized as P, isPowerOfTwo as Q, angleBetweenVectors as R, signedAngleBetweenVectors as S, Pi as T, ceil as U, min as V, max as W, arrayMin as X, arrayMax as Y, ceilLog2 as Z, factorial as _, areMatricesEqual as a, beginCombination as a0, nextCombination as a1, randomSeed as a2, getSeed as a3, gaussian as a4, multiplyScalar2D as a5, multiplyAccumulate2D as a6, outer as a7, projectVector as a8, dot2D as a9, hex2float as aA, lab2xyz as aB, xyz2lab as aC, xyz2rgb as aD, rgb2xyz as aE, clampAndNormalizeValue as aF, getScalarTypeFittingRange as aG, getAdjustedScalarRange as aH, extentIsWithinOtherExtent as aI, boundsIsWithinOtherBounds as aJ, pointIsWithinBounds as aK, solve3PointCircle as aL, inf as aM, negInf as aN, isFinite as aO, isNaN as aP, floatToHex2 as aQ, floatRGB2HexCode as aR, float2CssRGBA as aS, projectVector2D as aa, gaussianAmplitude as ab, gaussianWeight as ac, outer2D as ad, norm2D as ae, LUFactor3x3 as af, LUSolve3x3 as ag, linearSolve3x3 as ah, multiply3x3_mat3 as ai, multiplyMatrix as aj, transpose3x3 as ak, invert3x3 as al, identity3x3 as am, quaternionToMatrix3x3 as an, roundNumber as ao, matrix3x3ToQuaternion as ap, multiplyQuaternion as aq, orthogonalize3x3 as ar, diagonalize3x3 as as, singularValueDecomposition3x3 as at, luFactorLinearSystem as au, luSolveLinearSystem as av, invertMatrix as aw, estimateMatrixCondition as ax, solveHomogeneousLeastSquares as ay, solveLeastSquares as az, roundVector as b, computeBoundsFromPoints as c, dot as d, clampVector as e, distance2BetweenPoints as f, subtract 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, solveLinearSystem as s,
|
|
2332
|
+
export { binomial as $, degreesFromRadians as A, areEquals as B, clampValue as C, arrayRange as D, getMajorAxisIndex as E, isInf as F, rgb2hsv as G, rgb2lab as H, lab2rgb as I, floor as J, round as K, normalize2D as L, nearestPowerOfTwo as M, createUninitializedBounds as N, multiply3x3_vect3 as O, areBoundsInitialized as P, isPowerOfTwo as Q, angleBetweenVectors as R, signedAngleBetweenVectors as S, Pi as T, ceil as U, min as V, max as W, arrayMin as X, arrayMax as Y, ceilLog2 as Z, factorial as _, areMatricesEqual as a, beginCombination as a0, nextCombination as a1, randomSeed as a2, getSeed as a3, gaussian as a4, multiplyScalar2D as a5, multiplyAccumulate2D as a6, outer as a7, projectVector as a8, dot2D as a9, hex2float as aA, lab2xyz as aB, xyz2lab as aC, xyz2rgb as aD, rgb2xyz as aE, clampAndNormalizeValue as aF, getScalarTypeFittingRange as aG, getAdjustedScalarRange as aH, extentIsWithinOtherExtent as aI, boundsIsWithinOtherBounds as aJ, pointIsWithinBounds as aK, solve3PointCircle as aL, inf as aM, negInf as aN, isFinite as aO, isNaN as aP, floatToHex2 as aQ, floatRGB2HexCode as aR, float2CssRGBA as aS, projectVector2D as aa, gaussianAmplitude as ab, gaussianWeight as ac, outer2D as ad, norm2D as ae, LUFactor3x3 as af, LUSolve3x3 as ag, linearSolve3x3 as ah, multiply3x3_mat3 as ai, multiplyMatrix as aj, transpose3x3 as ak, invert3x3 as al, identity3x3 as am, quaternionToMatrix3x3 as an, roundNumber as ao, matrix3x3ToQuaternion as ap, multiplyQuaternion as aq, orthogonalize3x3 as ar, diagonalize3x3 as as, singularValueDecomposition3x3 as at, luFactorLinearSystem as au, luSolveLinearSystem as av, invertMatrix as aw, estimateMatrixCondition as ax, solveHomogeneousLeastSquares as ay, solveLeastSquares as az, roundVector as b, computeBoundsFromPoints as c, dot as d, clampVector as e, distance2BetweenPoints as f, subtract 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, solveLinearSystem as s, vtkMath as t, uninitializeBounds as u, vtkMath$1 as v, jacobi as w, multiplyScalar as x, random as y, determinant3x3 as z };
|
package/Common/Core/Math.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '@babel/runtime/helpers/slicedToArray';
|
|
2
2
|
import 'seedrandom';
|
|
3
3
|
import '../../macros.js';
|
|
4
|
-
export { af as LUFactor3x3, ag as LUSolve3x3, T as Pi, k as add, R as angleBetweenVectors, P as areBoundsInitialized, B as areEquals, a as areMatricesEqual, Y as arrayMax, X as arrayMin, D as arrayRange, a0 as beginCombination, $ as binomial, aJ as boundsIsWithinOtherBounds, U as ceil, Z as ceilLog2, aF as clampAndNormalizeValue, C as clampValue, e as clampVector, c as computeBoundsFromPoints, N as createUninitializedBounds, j as cross,
|
|
4
|
+
export { af as LUFactor3x3, ag as LUSolve3x3, T as Pi, k as add, R as angleBetweenVectors, P as areBoundsInitialized, B as areEquals, a as areMatricesEqual, Y as arrayMax, X as arrayMin, D as arrayRange, a0 as beginCombination, $ as binomial, aJ as boundsIsWithinOtherBounds, U as ceil, Z as ceilLog2, aF as clampAndNormalizeValue, C as clampValue, e as clampVector, c as computeBoundsFromPoints, N as createUninitializedBounds, j as cross, t as default, A as degreesFromRadians, o as determinant2x2, z as determinant3x3, as as diagonalize3x3, f as distance2BetweenPoints, d as dot, a9 as dot2D, ax as estimateMatrixCondition, aI as extentIsWithinOtherExtent, _ as factorial, aS as float2CssRGBA, aR as floatRGB2HexCode, aQ as floatToHex2, J as floor, a4 as gaussian, ab as gaussianAmplitude, ac as gaussianWeight, aH as getAdjustedScalarRange, E as getMajorAxisIndex, aG as getScalarTypeFittingRange, a3 as getSeed, aA as hex2float, h as hsv2rgb, am as identity3x3, aM as inf, al as invert3x3, aw as invertMatrix, aO as isFinite, F as isInf, aP as isNaN, i as isNan, Q as isPowerOfTwo, w as jacobi, p as jacobiN, I as lab2rgb, aB as lab2xyz, ah as linearSolve3x3, au as luFactorLinearSystem, av as luSolveLinearSystem, ap as matrix3x3ToQuaternion, W as max, V as min, ai as multiply3x3_mat3, O as multiply3x3_vect3, m as multiplyAccumulate, a6 as multiplyAccumulate2D, aj as multiplyMatrix, aq as multiplyQuaternion, x as multiplyScalar, a5 as multiplyScalar2D, M as nearestPowerOfTwo, aN as negInf, a1 as nextCombination, n as norm, ae as norm2D, l as normalize, L as normalize2D, ar as orthogonalize3x3, a7 as outer, ad as outer2D, q as perpendiculars, aK as pointIsWithinBounds, a8 as projectVector, aa as projectVector2D, an as quaternionToMatrix3x3, r as radiansFromDegrees, y as random, a2 as randomSeed, G as rgb2hsv, H as rgb2lab, aE as rgb2xyz, K as round, ao as roundNumber, b as roundVector, S as signedAngleBetweenVectors, at as singularValueDecomposition3x3, aL as solve3PointCircle, ay as solveHomogeneousLeastSquares, az as solveLeastSquares, s as solveLinearSystem, g as subtract, ak as transpose3x3, u as uninitializeBounds, aC as xyz2lab, aD as xyz2rgb } from './Math/index.js';
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import macro from '../../macros.js';
|
|
3
|
+
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
4
|
+
import { t as vtkMath } from '../../Common/Core/Math/index.js';
|
|
5
|
+
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
6
|
+
import vtkTriangle from '../../Common/DataModel/Triangle.js';
|
|
7
|
+
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
|
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
+
// vtkPolyDataNormals methods
|
|
12
|
+
// ----------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
function vtkPolyDataNormals(publicAPI, model) {
|
|
15
|
+
// Set our className
|
|
16
|
+
model.classHierarchy.push('vtkPolyDataNormals');
|
|
17
|
+
|
|
18
|
+
publicAPI.vtkPolyDataNormalsExecute = function (pointsData, polysData) {
|
|
19
|
+
if (!pointsData) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var normalsData = new Float32Array(pointsData.length);
|
|
24
|
+
var numberOfPoints = 0;
|
|
25
|
+
var polysDataLength = polysData.length;
|
|
26
|
+
var cellPointIds = [0, 0, 0];
|
|
27
|
+
|
|
28
|
+
for (var c = 0; c < polysDataLength; c += numberOfPoints + 1) {
|
|
29
|
+
numberOfPoints = polysData[c];
|
|
30
|
+
|
|
31
|
+
if (numberOfPoints < 3) {
|
|
32
|
+
continue; // eslint-disable-line
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
for (var i = 1; i <= 3; ++i) {
|
|
36
|
+
cellPointIds[i - 1] = 3 * polysData[c + i];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var cellNormal = [];
|
|
40
|
+
vtkTriangle.computeNormal(pointsData.slice(cellPointIds[0], cellPointIds[0] + 3), pointsData.slice(cellPointIds[1], cellPointIds[1] + 3), pointsData.slice(cellPointIds[2], cellPointIds[2] + 3), cellNormal);
|
|
41
|
+
|
|
42
|
+
for (var _i = 1; _i <= numberOfPoints; ++_i) {
|
|
43
|
+
var pointId = 3 * polysData[c + _i];
|
|
44
|
+
normalsData[pointId] += cellNormal[0];
|
|
45
|
+
normalsData[++pointId] += cellNormal[1];
|
|
46
|
+
normalsData[++pointId] += cellNormal[2];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/* Normalize normals */
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
for (var _i2 = 0; _i2 < pointsData.length;) {
|
|
53
|
+
var pointNormal = normalsData.slice(_i2, _i2 + 3);
|
|
54
|
+
vtkMath.normalize(pointNormal);
|
|
55
|
+
normalsData[_i2++] = pointNormal[0];
|
|
56
|
+
normalsData[_i2++] = pointNormal[1];
|
|
57
|
+
normalsData[_i2++] = pointNormal[2];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return normalsData;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
publicAPI.requestData = function (inData, outData) {
|
|
64
|
+
var numberOfInputs = publicAPI.getNumberOfInputPorts();
|
|
65
|
+
|
|
66
|
+
if (!numberOfInputs) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
var input = inData[0];
|
|
71
|
+
|
|
72
|
+
if (!input) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var outputNormalsData = publicAPI.vtkPolyDataNormalsExecute(input.getPoints().getData(), input.getPolys().getData());
|
|
77
|
+
var output = vtkPolyData.newInstance();
|
|
78
|
+
var outputNormals = vtkDataArray.newInstance({
|
|
79
|
+
numberOfComponents: 3,
|
|
80
|
+
values: outputNormalsData
|
|
81
|
+
});
|
|
82
|
+
output.setPointData(input.getPointData());
|
|
83
|
+
output.setCellData(input.getCellData());
|
|
84
|
+
output.setFieldData(input.getFieldData());
|
|
85
|
+
output.setPoints(input.getPoints());
|
|
86
|
+
output.setVerts(input.getVerts());
|
|
87
|
+
output.setLines(input.getLines());
|
|
88
|
+
output.setPolys(input.getPolys());
|
|
89
|
+
output.setStrips(input.getStrips());
|
|
90
|
+
output.getPointData().setNormals(outputNormals);
|
|
91
|
+
outData[0] = output;
|
|
92
|
+
};
|
|
93
|
+
} // ----------------------------------------------------------------------------
|
|
94
|
+
// Object factory
|
|
95
|
+
// ----------------------------------------------------------------------------
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
function defaultValues(initialValues) {
|
|
99
|
+
return _objectSpread({}, initialValues);
|
|
100
|
+
} // ----------------------------------------------------------------------------
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
function extend(publicAPI, model) {
|
|
104
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
105
|
+
Object.assign(model, defaultValues(initialValues));
|
|
106
|
+
/* Make this a VTK object */
|
|
107
|
+
|
|
108
|
+
macro.obj(publicAPI, model);
|
|
109
|
+
/* Also make it an algorithm with one input and one output */
|
|
110
|
+
|
|
111
|
+
macro.algo(publicAPI, model, 1, 1);
|
|
112
|
+
/* Object specific methods */
|
|
113
|
+
|
|
114
|
+
vtkPolyDataNormals(publicAPI, model);
|
|
115
|
+
} // ----------------------------------------------------------------------------
|
|
116
|
+
|
|
117
|
+
var newInstance = macro.newInstance(extend, 'vtkPolyDataNormals'); // ----------------------------------------------------------------------------
|
|
118
|
+
|
|
119
|
+
var vtkPolyDataNormals$1 = {
|
|
120
|
+
newInstance: newInstance,
|
|
121
|
+
extend: extend
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export { vtkPolyDataNormals$1 as default, extend, newInstance };
|
package/Filters/Core.js
CHANGED
|
@@ -2,7 +2,7 @@ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
|
2
2
|
import macro from '../../macros.js';
|
|
3
3
|
import vtkCellArray from '../../Common/Core/CellArray.js';
|
|
4
4
|
import vtkLine from '../../Common/DataModel/Line.js';
|
|
5
|
-
import { d as dot, j as cross, n as norm,
|
|
5
|
+
import { d as dot, j as cross, n as norm, w as jacobi, l as normalize, k as add } from '../../Common/Core/Math/index.js';
|
|
6
6
|
import vtkMatrixBuilder from '../../Common/Core/MatrixBuilder.js';
|
|
7
7
|
import vtkOBBNode from './OBBTree/OBBNode.js';
|
|
8
8
|
import vtkPoints from '../../Common/Core/Points.js';
|
|
@@ -2,7 +2,7 @@ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
|
2
2
|
import macro from '../../macros.js';
|
|
3
3
|
import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
|
|
4
4
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
5
|
-
import {
|
|
5
|
+
import { t as vtkMath } from '../../Common/Core/Math/index.js';
|
|
6
6
|
import { AttributeTypes } from '../../Common/DataModel/DataSetAttributes/Constants.js';
|
|
7
7
|
import vtkPoints from '../../Common/Core/Points.js';
|
|
8
8
|
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
package/IO/Misc/OBJReader.d.ts
CHANGED
|
@@ -28,6 +28,24 @@ type vtkOBJReaderBase = vtkObject & Omit<vtkAlgorithm,
|
|
|
28
28
|
| 'addInputConnection'
|
|
29
29
|
| 'addInputData'>;
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Convenient method to get the id of all duplicated points.
|
|
33
|
+
* Relies on a "Duplicates" array that contains the id of:
|
|
34
|
+
* - the first duplicate id for the original point (or self Id if there is no duplicate)
|
|
35
|
+
* - the original id for the duplicate points
|
|
36
|
+
* Duplicated points must be adjacent to each other.
|
|
37
|
+
* Example:
|
|
38
|
+
* - Points: [pt0, pt1, pt2, pt3, pt1d0, pt1d1, pt1d3, pt3d1, pt3d2]
|
|
39
|
+
* - Duplicates: [0, 4, 2, 3, 1, 1, 1, 3, 3]
|
|
40
|
+
* Expected results:
|
|
41
|
+
* - getPointDuplicateIds(p, 1) => [1, 4, 5, 6]
|
|
42
|
+
* - getPointDuplicateIds(p, 0) => [0]
|
|
43
|
+
* - getPointDuplicateIds(p, 5) => [1, 4, 5, 6]
|
|
44
|
+
* @param polydata A polydata generated by the OBJReader
|
|
45
|
+
* @param pointId A point Id (duplicated or not)
|
|
46
|
+
*/
|
|
47
|
+
export function getPointDuplicateIds(polydata: any, pointId: number): Array<number>;
|
|
48
|
+
|
|
31
49
|
export interface vtkOBJReader extends vtkOBJReaderBase {
|
|
32
50
|
|
|
33
51
|
/**
|
|
@@ -50,6 +68,11 @@ export interface vtkOBJReader extends vtkOBJReaderBase {
|
|
|
50
68
|
*/
|
|
51
69
|
getSplitMode(): number;
|
|
52
70
|
|
|
71
|
+
/**
|
|
72
|
+
* True if duplicates are tracked in output polydata.
|
|
73
|
+
*/
|
|
74
|
+
getTrackDuplicates(): boolean
|
|
75
|
+
|
|
53
76
|
/**
|
|
54
77
|
*
|
|
55
78
|
* @param {Boolean} busy
|
|
@@ -93,11 +116,19 @@ export interface vtkOBJReader extends vtkOBJReaderBase {
|
|
|
93
116
|
setDataAccessHelper(dataAccessHelper: HtmlDataAccessHelper | HttpDataAccessHelper | JSZipDataAccessHelper | LiteHttpDataAccessHelper): boolean;
|
|
94
117
|
|
|
95
118
|
/**
|
|
96
|
-
*
|
|
97
|
-
* @param {String} splitMode
|
|
119
|
+
* String in OBJ file used to split in multiple output polydata.
|
|
120
|
+
* @param {Null | String} splitMode
|
|
98
121
|
*/
|
|
99
122
|
setSplitMode(splitMode: string): boolean;
|
|
100
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Set to true to be able to use getPointDuplicateIds() on output polydata.
|
|
126
|
+
* Requires splitMode to not be null.
|
|
127
|
+
* @param trackDuplicates true or false (false by default)
|
|
128
|
+
* @see getPointDuplicateIds(), setSplitMode()
|
|
129
|
+
*/
|
|
130
|
+
setTrackDuplicates(trackDuplicates: boolean): boolean;
|
|
131
|
+
|
|
101
132
|
/**
|
|
102
133
|
* Set the url of the object to load.
|
|
103
134
|
* @param {String} url the url of the object to load.
|
package/IO/Misc/OBJReader.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
1
2
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
3
|
import macro from '../../macros.js';
|
|
3
4
|
import DataAccessHelper from '../Core/DataAccessHelper.js';
|
|
@@ -5,6 +6,9 @@ import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
|
5
6
|
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
6
7
|
import '../Core/DataAccessHelper/LiteHttpDataAccessHelper.js';
|
|
7
8
|
|
|
9
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
+
|
|
11
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
12
|
// import 'vtk.js/Sources/IO/Core/DataAccessHelper/HttpDataAccessHelper'; // HTTP + gz
|
|
9
13
|
// import 'vtk.js/Sources/IO/Core/DataAccessHelper/HtmlDataAccessHelper'; // html + base64 + zip
|
|
10
14
|
// import 'vtk.js/Sources/IO/Core/DataAccessHelper/JSZipDataAccessHelper'; // zip
|
|
@@ -12,9 +16,9 @@ import '../Core/DataAccessHelper/LiteHttpDataAccessHelper.js';
|
|
|
12
16
|
|
|
13
17
|
var data = {}; // ----------------------------------------------------------------------------
|
|
14
18
|
|
|
15
|
-
function
|
|
19
|
+
function copyVector(src, srcOffset, dst, dstOffset, vectorSize) {
|
|
16
20
|
for (var i = 0; i < vectorSize; i++) {
|
|
17
|
-
dst
|
|
21
|
+
dst[dstOffset + i] = src[srcOffset + i];
|
|
18
22
|
}
|
|
19
23
|
} // ----------------------------------------------------------------------------
|
|
20
24
|
|
|
@@ -93,6 +97,60 @@ function end(model) {
|
|
|
93
97
|
model.numberOfOutputs = data.size;
|
|
94
98
|
|
|
95
99
|
for (var idx = 0; idx < data.size; idx++) {
|
|
100
|
+
var polyIn = data.f[idx];
|
|
101
|
+
var nbElems = polyIn.length;
|
|
102
|
+
var nbPoints = data.v.length / 3;
|
|
103
|
+
var keyPointId = {};
|
|
104
|
+
var pointDuplicatesReferences = void 0;
|
|
105
|
+
|
|
106
|
+
if (model.trackDuplicates) {
|
|
107
|
+
// In trackDuplicates mode, we want the following point layout:
|
|
108
|
+
// [pt0, pt1, pt2, ... ptN, pt0d1, pt0d2, pt1d1]
|
|
109
|
+
var pointKeys = [];
|
|
110
|
+
var duplicatesCount = 0;
|
|
111
|
+
|
|
112
|
+
for (var _offset = 0; _offset < nbElems;) {
|
|
113
|
+
var cellSize = polyIn[_offset++];
|
|
114
|
+
|
|
115
|
+
for (var pIdx = 0; pIdx < cellSize; pIdx++) {
|
|
116
|
+
var _polyIn$_offset = _slicedToArray(polyIn[_offset++], 3),
|
|
117
|
+
vIdx = _polyIn$_offset[0],
|
|
118
|
+
tcIdx = _polyIn$_offset[1],
|
|
119
|
+
nIdx = _polyIn$_offset[2];
|
|
120
|
+
|
|
121
|
+
var key = "".concat(vIdx, "/").concat(tcIdx, "/").concat(nIdx);
|
|
122
|
+
|
|
123
|
+
if (keyPointId[key] === undefined) {
|
|
124
|
+
if (pointKeys[vIdx] === undefined) {
|
|
125
|
+
pointKeys[vIdx] = [key];
|
|
126
|
+
} else {
|
|
127
|
+
pointKeys[vIdx].push(key);
|
|
128
|
+
++duplicatesCount;
|
|
129
|
+
} // will be overwritten for duplicates
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
keyPointId[key] = vIdx;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
pointDuplicatesReferences = new Uint16Array(nbPoints + duplicatesCount);
|
|
138
|
+
var duplicates = 0;
|
|
139
|
+
|
|
140
|
+
for (var pointId = 0; pointId < pointKeys.length; ++pointId) {
|
|
141
|
+
var usageCount = pointKeys[pointId] ? pointKeys[pointId].length : 0; // Set the first duplicate index on the original point
|
|
142
|
+
|
|
143
|
+
pointDuplicatesReferences[pointId] = usageCount > 1 ? nbPoints + duplicates : pointId; // Set the original index on each duplicated point
|
|
144
|
+
|
|
145
|
+
for (var duplicateId = 1; duplicateId < usageCount; ++duplicateId) {
|
|
146
|
+
var finalDuplicateId = nbPoints + duplicates++;
|
|
147
|
+
pointDuplicatesReferences[finalDuplicateId] = pointId; // Associate the duplicate index to the key
|
|
148
|
+
|
|
149
|
+
keyPointId[pointKeys[pointId][duplicateId]] = finalDuplicateId;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
96
154
|
var ctMapping = {};
|
|
97
155
|
var polydata = vtkPolyData.newInstance({
|
|
98
156
|
name: data.pieces[idx]
|
|
@@ -101,42 +159,50 @@ function end(model) {
|
|
|
101
159
|
var tc = [];
|
|
102
160
|
var normals = [];
|
|
103
161
|
var polys = [];
|
|
104
|
-
var polyIn = data.f[idx];
|
|
105
|
-
var nbElems = polyIn.length;
|
|
106
162
|
var offset = 0;
|
|
107
163
|
|
|
108
164
|
while (offset < nbElems) {
|
|
109
|
-
var
|
|
110
|
-
polys.push(
|
|
165
|
+
var _cellSize = polyIn[offset];
|
|
166
|
+
polys.push(_cellSize);
|
|
111
167
|
|
|
112
|
-
for (var
|
|
113
|
-
var _polyIn = _slicedToArray(polyIn[offset +
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
168
|
+
for (var _pIdx = 0; _pIdx < _cellSize; _pIdx++) {
|
|
169
|
+
var _polyIn = _slicedToArray(polyIn[offset + _pIdx + 1], 3),
|
|
170
|
+
_vIdx = _polyIn[0],
|
|
171
|
+
_tcIdx = _polyIn[1],
|
|
172
|
+
_nIdx = _polyIn[2];
|
|
117
173
|
|
|
118
|
-
var
|
|
174
|
+
var _key = "".concat(_vIdx, "/").concat(_tcIdx, "/").concat(_nIdx);
|
|
119
175
|
|
|
120
|
-
if (ctMapping[
|
|
121
|
-
|
|
122
|
-
|
|
176
|
+
if (ctMapping[_key] === undefined) {
|
|
177
|
+
var dstOffset = model.trackDuplicates ? keyPointId[_key] : pts.length / 3;
|
|
178
|
+
ctMapping[_key] = dstOffset;
|
|
179
|
+
copyVector(data.v, _vIdx * 3, pts, dstOffset * 3, 3);
|
|
123
180
|
|
|
124
181
|
if (hasTcoords) {
|
|
125
|
-
|
|
182
|
+
copyVector(data.vt, _tcIdx * 2, tc, dstOffset * 2, 2);
|
|
126
183
|
}
|
|
127
184
|
|
|
128
185
|
if (hasNormals) {
|
|
129
|
-
|
|
186
|
+
copyVector(data.vn, _nIdx * 3, normals, dstOffset * 3, 3);
|
|
130
187
|
}
|
|
131
188
|
}
|
|
132
189
|
|
|
133
|
-
polys.push(ctMapping[
|
|
190
|
+
polys.push(ctMapping[_key]);
|
|
134
191
|
}
|
|
135
192
|
|
|
136
|
-
offset +=
|
|
193
|
+
offset += _cellSize + 1;
|
|
137
194
|
}
|
|
138
195
|
|
|
139
196
|
polydata.getPoints().setData(Float32Array.from(pts), 3);
|
|
197
|
+
|
|
198
|
+
if (model.trackDuplicates) {
|
|
199
|
+
var duplicatesArray = vtkDataArray.newInstance({
|
|
200
|
+
name: 'Duplicates',
|
|
201
|
+
values: pointDuplicatesReferences
|
|
202
|
+
});
|
|
203
|
+
polydata.getPointData().addArray(duplicatesArray);
|
|
204
|
+
}
|
|
205
|
+
|
|
140
206
|
polydata.getPolys().setData(Uint32Array.from(polys));
|
|
141
207
|
|
|
142
208
|
if (hasTcoords) {
|
|
@@ -190,21 +256,21 @@ function end(model) {
|
|
|
190
256
|
var _polys = [];
|
|
191
257
|
var _polyIn2 = data.f[0];
|
|
192
258
|
var _nbElems = _polyIn2.length;
|
|
193
|
-
var
|
|
259
|
+
var _offset2 = 0;
|
|
194
260
|
|
|
195
|
-
while (
|
|
196
|
-
var
|
|
261
|
+
while (_offset2 < _nbElems) {
|
|
262
|
+
var _cellSize2 = _polyIn2[_offset2];
|
|
197
263
|
|
|
198
|
-
_polys.push(
|
|
264
|
+
_polys.push(_cellSize2);
|
|
199
265
|
|
|
200
|
-
for (var
|
|
201
|
-
var _polyIn3 = _slicedToArray(_polyIn2[
|
|
202
|
-
|
|
266
|
+
for (var _pIdx2 = 0; _pIdx2 < _cellSize2; _pIdx2++) {
|
|
267
|
+
var _polyIn3 = _slicedToArray(_polyIn2[_offset2 + _pIdx2 + 1], 1),
|
|
268
|
+
_vIdx2 = _polyIn3[0];
|
|
203
269
|
|
|
204
|
-
_polys.push(
|
|
270
|
+
_polys.push(_vIdx2);
|
|
205
271
|
}
|
|
206
272
|
|
|
207
|
-
|
|
273
|
+
_offset2 += _cellSize2 + 1;
|
|
208
274
|
}
|
|
209
275
|
|
|
210
276
|
_polydata.getPolys().setData(Uint32Array.from(_polys));
|
|
@@ -212,10 +278,41 @@ function end(model) {
|
|
|
212
278
|
model.output[0] = _polydata;
|
|
213
279
|
}
|
|
214
280
|
} // ----------------------------------------------------------------------------
|
|
215
|
-
//
|
|
281
|
+
// Static API
|
|
216
282
|
// ----------------------------------------------------------------------------
|
|
217
283
|
|
|
218
284
|
|
|
285
|
+
function getPointDuplicateIds(polyData, pointId) {
|
|
286
|
+
var res = [];
|
|
287
|
+
var duplicates = polyData.getPointData().getArrayByName('Duplicates');
|
|
288
|
+
|
|
289
|
+
if (duplicates == null) {
|
|
290
|
+
return res;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
var duplicatesData = duplicates.getData();
|
|
294
|
+
var originalPointId = Math.min(pointId, duplicatesData[pointId]);
|
|
295
|
+
res.push(originalPointId);
|
|
296
|
+
var duplicateId = duplicatesData[originalPointId];
|
|
297
|
+
|
|
298
|
+
if (duplicateId !== originalPointId) {
|
|
299
|
+
// point has duplicates
|
|
300
|
+
while (duplicateId < duplicatesData.length && duplicatesData[duplicateId] === originalPointId) {
|
|
301
|
+
// Duplicated points must be next to each other and original point must
|
|
302
|
+
// reference first duplicate
|
|
303
|
+
res.push(duplicateId++);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return res;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
var STATIC = {
|
|
311
|
+
getPointDuplicateIds: getPointDuplicateIds
|
|
312
|
+
}; // ----------------------------------------------------------------------------
|
|
313
|
+
// vtkOBJReader methods
|
|
314
|
+
// ----------------------------------------------------------------------------
|
|
315
|
+
|
|
219
316
|
function vtkOBJReader(publicAPI, model) {
|
|
220
317
|
// Set our className
|
|
221
318
|
model.classHierarchy.push('vtkOBJReader'); // Create default dataAccessHelper if not available
|
|
@@ -292,7 +389,8 @@ function vtkOBJReader(publicAPI, model) {
|
|
|
292
389
|
var DEFAULT_VALUES = {
|
|
293
390
|
numberOfOutputs: 1,
|
|
294
391
|
requestCount: 0,
|
|
295
|
-
splitMode: null
|
|
392
|
+
splitMode: null,
|
|
393
|
+
trackDuplicates: false // baseURL: null,
|
|
296
394
|
// dataAccessHelper: null,
|
|
297
395
|
// url: null,
|
|
298
396
|
|
|
@@ -304,7 +402,7 @@ function extend(publicAPI, model) {
|
|
|
304
402
|
|
|
305
403
|
macro.obj(publicAPI, model);
|
|
306
404
|
macro.get(publicAPI, model, ['url', 'baseURL']);
|
|
307
|
-
macro.setGet(publicAPI, model, ['dataAccessHelper', 'splitMode']);
|
|
405
|
+
macro.setGet(publicAPI, model, ['dataAccessHelper', 'splitMode', 'trackDuplicates']);
|
|
308
406
|
macro.algo(publicAPI, model, 0, 1);
|
|
309
407
|
macro.event(publicAPI, model, 'busy'); // Object methods
|
|
310
408
|
|
|
@@ -313,9 +411,9 @@ function extend(publicAPI, model) {
|
|
|
313
411
|
|
|
314
412
|
var newInstance = macro.newInstance(extend, 'vtkOBJReader'); // ----------------------------------------------------------------------------
|
|
315
413
|
|
|
316
|
-
var vtkOBJReader$1 = {
|
|
414
|
+
var vtkOBJReader$1 = _objectSpread({
|
|
317
415
|
newInstance: newInstance,
|
|
318
416
|
extend: extend
|
|
319
|
-
};
|
|
417
|
+
}, STATIC);
|
|
320
418
|
|
|
321
|
-
export { vtkOBJReader$1 as default, extend, newInstance };
|
|
419
|
+
export { STATIC, vtkOBJReader$1 as default, extend, newInstance };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
3
|
import macro from '../../../macros.js';
|
|
4
|
-
import {
|
|
4
|
+
import { t as vtkMath } from '../../../Common/Core/Math/index.js';
|
|
5
5
|
import vtkBoundingBox from '../../../Common/DataModel/BoundingBox.js';
|
|
6
6
|
import vtkPlane from '../../../Common/DataModel/Plane.js';
|
|
7
7
|
import { ShapeBehavior, BehaviorCategory, TextPosition } from './Constants.js';
|