@kitware/vtk.js 23.4.3 → 23.4.4
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/Constants.js +12 -0
- package/Common/Core/Math/index.js +1 -1
- package/Common/Core/Math.js +1 -1
- package/Common/Core/ScalarsToColors/Constants.d.ts +18 -0
- package/Common/DataModel/AbstractPointLocator.d.ts +54 -0
- package/Common/DataModel/AbstractPointLocator.js +40 -0
- package/Common/DataModel/BoundingBox.d.ts +659 -0
- package/Common/DataModel/Collection.d.ts +118 -0
- package/Common/DataModel/Collection.js +113 -0
- package/Common/DataModel/DataSet/Constants.d.ts +27 -0
- package/Common/DataModel/EdgeLocator.d.ts +79 -0
- package/Common/DataModel/EdgeLocator.js +85 -0
- package/Common/DataModel/ITKHelper.d.ts +54 -0
- package/Common/DataModel/IncrementalOctreeNode.d.ts +297 -0
- package/Common/DataModel/IncrementalOctreeNode.js +640 -0
- package/Common/DataModel/IncrementalOctreePointLocator.d.ts +61 -0
- package/Common/DataModel/IncrementalOctreePointLocator.js +398 -0
- package/Common/DataModel/Locator.d.ts +43 -0
- package/Common/DataModel/Locator.js +37 -0
- package/Common/DataModel/Plane.js +1 -1
- package/Common/DataModel/PolyData/Constants.d.ts +6 -0
- package/Common/DataModel/PolyLine.d.ts +63 -0
- package/Common/DataModel/PolyLine.js +77 -0
- package/Common/DataModel/Polygon/Constants.js +12 -0
- package/Common/DataModel/Polygon.js +1 -1
- package/Common/DataModel/Quad/Constants.js +9 -0
- package/Common/DataModel/Quad.d.ts +91 -0
- package/Common/DataModel/Quad.js +235 -0
- package/Common/DataModel/SelectionNode/Constants.d.ts +27 -0
- package/Common/DataModel/Spline1D/Constants.js +17 -0
- package/Common/DataModel/Spline3D/Constants.d.ts +9 -0
- package/Common/Transform/Transform.js +51 -0
- package/Filters/Core/PolyDataNormals.js +124 -0
- package/Filters/General/ClipClosedSurface/Constants.js +10 -0
- package/Filters/General/ClipClosedSurface.d.ts +95 -0
- package/Filters/General/ClipClosedSurface.js +972 -0
- package/Filters/General/ContourTriangulator/Constants.js +6 -0
- package/Filters/General/ContourTriangulator/helper.js +1951 -0
- package/Filters/General/ContourTriangulator.d.ts +136 -0
- package/Filters/General/ContourTriangulator.js +202 -0
- package/Filters/General/ImageMarchingCubes.js +1 -1
- package/Filters/General/MoleculeToRepresentation.js +1 -1
- package/Filters/General/OBBTree/OBBNode.js +82 -0
- package/Filters/General/OBBTree/helper.js +92 -0
- package/Filters/General/OBBTree.js +1243 -0
- package/Filters/General/TubeFilter.js +1 -1
- package/Filters/Sources/LineSource.js +1 -1
- package/Filters/Sources/PlaneSource.js +1 -1
- package/Filters/Texture/TextureMapToPlane.js +1 -1
- package/Interaction/Manipulators/CompositeCameraManipulator.d.ts +68 -0
- package/Interaction/Manipulators/CompositeGestureManipulator.d.ts +168 -0
- package/Interaction/Manipulators/CompositeKeyboardManipulator.d.ts +48 -0
- package/Interaction/Manipulators/CompositeMouseManipulator.d.ts +149 -0
- package/Interaction/Manipulators/CompositeVRManipulator.d.ts +44 -0
- package/Interaction/Manipulators/GestureCameraManipulator.d.ts +34 -0
- package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
- package/Interaction/Manipulators/MouseBoxSelectorManipulator.d.ts +88 -0
- package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballMultiRotateManipulator.d.ts +32 -0
- package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.d.ts +33 -0
- package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.d.ts +33 -0
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.d.ts +67 -0
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballZoomManipulator.d.ts +45 -0
- package/Interaction/Manipulators/MouseCameraTrackballZoomToMouseManipulator.d.ts +26 -0
- package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseRangeManipulator.d.ts +53 -0
- package/Interaction/Style/InteractorStyleImage.d.ts +107 -0
- package/Interaction/Style/InteractorStyleMPRSlice.js +1 -1
- package/Interaction/Style/InteractorStyleManipulator.d.ts +348 -0
- package/Interaction/Style/InteractorStyleTrackballCamera.d.ts +170 -0
- package/Interaction/Widgets/ImageCroppingRegionsWidget.js +1 -1
- package/Interaction/Widgets/LabelRepresentation.js +1 -1
- package/Interaction/Widgets/OrientationMarkerWidget/Constants.d.ts +11 -0
- package/Interaction/Widgets/ResliceCursor/ResliceCursor.js +1 -1
- package/Interaction/Widgets/ResliceCursor/ResliceCursorLineRepresentation.js +1 -1
- package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +1 -1
- package/Proxy/Core/AbstractRepresentationProxy.d.ts +24 -0
- package/Proxy/Core/LookupTableProxy.d.ts +45 -0
- package/Proxy/Core/PiecewiseFunctionProxy.d.ts +62 -0
- package/Proxy/Core/ProxyManager.d.ts +115 -0
- package/Proxy/Core/SourceProxy.d.ts +22 -0
- package/Proxy/Core/View2DProxy.d.ts +7 -0
- package/Proxy/Core/View2DProxy.js +1 -1
- package/Proxy/Core/ViewProxy.d.ts +86 -0
- package/Proxy/Representations/SliceRepresentationProxy.d.ts +27 -0
- package/Proxy/Representations/VolumeRepresentationProxy.d.ts +44 -0
- package/README.md +2 -2
- package/Rendering/Core/AbstractImageMapper/helper.js +127 -0
- package/Rendering/Core/AbstractImageMapper.d.ts +82 -0
- package/Rendering/Core/AbstractImageMapper.js +44 -0
- package/Rendering/Core/Camera.js +1 -1
- package/Rendering/Core/CellPicker.js +1 -1
- package/Rendering/Core/ColorTransferFunction/ColorMaps.d.ts +24 -0
- package/Rendering/Core/ColorTransferFunction/Constants.d.ts +17 -0
- package/Rendering/Core/ColorTransferFunction.js +1 -1
- package/Rendering/Core/Coordinate/Constants.d.ts +14 -0
- package/Rendering/Core/Coordinate.js +1 -1
- package/Rendering/Core/Glyph3DMapper/Constants.d.ts +17 -0
- package/Rendering/Core/Glyph3DMapper.js +1 -1
- package/Rendering/Core/HardwareSelector.d.ts +84 -0
- package/Rendering/Core/ImageArrayMapper.d.ts +253 -0
- package/Rendering/Core/ImageArrayMapper.js +242 -0
- package/Rendering/Core/ImageMapper/Constants.d.ts +14 -0
- package/Rendering/Core/ImageMapper.js +1 -1
- package/Rendering/Core/ImageProperty/Constants.d.ts +9 -0
- package/Rendering/Core/ImageResliceMapper/Constants.d.ts +11 -0
- package/Rendering/Core/ImageResliceMapper/Constants.js +11 -0
- package/Rendering/Core/ImageResliceMapper.d.ts +245 -0
- package/Rendering/Core/ImageResliceMapper.js +70 -0
- package/Rendering/Core/InteractorObserver.d.ts +132 -0
- package/Rendering/Core/InteractorStyle/Constants.d.ts +16 -0
- package/Rendering/Core/InteractorStyle.d.ts +229 -0
- package/Rendering/Core/Light.js +1 -1
- package/Rendering/Core/Mapper/Constants.d.ts +26 -0
- package/Rendering/Core/Mapper.js +1 -1
- package/Rendering/Core/Picker.js +1 -1
- package/Rendering/Core/Prop/Constants.d.ts +9 -0
- package/Rendering/Core/Prop/Constants.js +9 -0
- package/Rendering/Core/Property/Constants.d.ts +24 -0
- package/Rendering/Core/Property2D/Constants.d.ts +9 -0
- package/Rendering/Core/RenderWindow.js +1 -1
- package/Rendering/Core/RenderWindowInteractor/Constants.d.ts +31 -0
- package/Rendering/Core/Renderer.js +1 -1
- package/Rendering/Core/VolumeMapper/Constants.d.ts +20 -0
- package/Rendering/Core/VolumeMapper.js +1 -1
- package/Rendering/Core/VolumeProperty/Constants.d.ts +16 -0
- package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/CameraSynchronizer.js +129 -0
- package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager.js +131 -0
- package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.d.ts +80 -0
- package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.js +763 -0
- package/Rendering/OpenGL/HardwareSelector/Constants.d.ts +8 -0
- package/Rendering/OpenGL/HardwareSelector.d.ts +339 -0
- package/Rendering/OpenGL/ImageResliceMapper.js +996 -0
- package/Rendering/OpenGL/PolyDataMapper.js +1 -1
- package/Rendering/OpenGL/PolyDataMapper2D.js +1 -1
- package/Rendering/OpenGL/RenderWindow/Constants.d.ts +10 -0
- package/Rendering/OpenGL/RenderWindow/Constants.js +13 -0
- package/Rendering/OpenGL/RenderWindow/ContextProxy.js +70 -0
- package/Rendering/OpenGL/glsl/vtkImageResliceMapperFS.glsl.js +3 -0
- package/Rendering/OpenGL/glsl/vtkImageResliceMapperVS.glsl.js +3 -0
- package/Rendering/WebGPU/Actor2D.js +151 -0
- package/Rendering/WebGPU/BufferManager.js +1 -1
- package/Rendering/WebGPU/CellArrayMapper.js +853 -0
- package/Rendering/WebGPU/IndexBuffer.js +397 -0
- package/Rendering/WebGPU/PolyDataMapper2D.js +99 -0
- package/Rendering/WebGPU/SimpleMapper.js +290 -0
- package/Widgets/Core/AbstractWidget.d.ts +187 -0
- package/Widgets/Core/AbstractWidgetFactory.d.ts +131 -0
- package/Widgets/Core/StateBuilder/color3Mixin.js +24 -0
- package/Widgets/Core/StateBuilder/orientationMixin.js +1 -1
- package/Widgets/Core/StateBuilder.d.ts +29 -0
- package/Widgets/Core/WidgetManager/Constants.d.ts +27 -0
- package/Widgets/Core/WidgetManager.d.ts +231 -0
- package/Widgets/Core/WidgetState.d.ts +81 -0
- package/Widgets/Manipulators/AbstractManipulator.d.ts +221 -0
- package/Widgets/Manipulators/AbstractManipulator.js +57 -0
- package/Widgets/Manipulators/LineManipulator.js +1 -1
- package/Widgets/Manipulators/TrackballManipulator.js +1 -1
- package/Widgets/Representations/GlyphRepresentation.js +325 -0
- package/Widgets/Representations/LineHandleRepresentation.js +116 -0
- package/Widgets/Representations/ResliceCursorContextRepresentation.js +1 -1
- package/Widgets/Representations/WidgetRepresentation.js +1 -1
- package/Widgets/Widgets3D/AngleWidget.js +1 -1
- package/Widgets/Widgets3D/InteractiveOrientationWidget.d.ts +40 -0
- package/Widgets/Widgets3D/LabelWidget/behavior.js +157 -0
- package/Widgets/Widgets3D/LabelWidget/state.js +22 -0
- package/Widgets/Widgets3D/LabelWidget.js +78 -0
- package/Widgets/Widgets3D/LineWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
- package/index.d.ts +133 -74
- package/package.json +1 -1
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
3
|
+
import _createClass from '@babel/runtime/helpers/createClass';
|
|
4
|
+
import macro from '../../macros.js';
|
|
5
|
+
import Constants from './BufferManager/Constants.js';
|
|
6
|
+
import vtkProperty from '../Core/Property.js';
|
|
7
|
+
import vtkWebGPUBuffer from './Buffer.js';
|
|
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; }
|
|
12
|
+
var Representation = vtkProperty.Representation;
|
|
13
|
+
var PrimitiveTypes = Constants.PrimitiveTypes; // Simulate a small map of pointId to flatId for a cell. The original code
|
|
14
|
+
// used a map and was 2.6x slower (4.7 to 1.9 seconds). Using two fixed
|
|
15
|
+
// length arrays with a count is so much faster even with the required for
|
|
16
|
+
// loops and if statements. This only works as we know the usage is
|
|
17
|
+
// restricted to clear(), set() get() and has() so the count is always
|
|
18
|
+
// incrmenting except for clear where it goes back to 0. Performance
|
|
19
|
+
// improvement is probably due to this appoach not hitting the heap but wow
|
|
20
|
+
// it is so much faster. Code that adds to these vectors checks against 9 to
|
|
21
|
+
// make sure there is room. Switching to test against vec.length -1 results
|
|
22
|
+
// in a small performance hit, so if you change 10, search for 9 in this
|
|
23
|
+
// small class and change those as well.
|
|
24
|
+
|
|
25
|
+
var _LimitedMap = /*#__PURE__*/function () {
|
|
26
|
+
function _LimitedMap() {
|
|
27
|
+
_classCallCheck(this, _LimitedMap);
|
|
28
|
+
|
|
29
|
+
this.keys = new Uint32Array(10);
|
|
30
|
+
this.values = new Uint32Array(10);
|
|
31
|
+
this.count = 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_createClass(_LimitedMap, [{
|
|
35
|
+
key: "clear",
|
|
36
|
+
value: function clear() {
|
|
37
|
+
this.count = 0;
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
key: "has",
|
|
41
|
+
value: function has(key) {
|
|
42
|
+
for (var i = 0; i < this.count; i++) {
|
|
43
|
+
if (this.keys[i] === key) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
key: "get",
|
|
52
|
+
value: function get(key) {
|
|
53
|
+
for (var i = 0; i < this.count; i++) {
|
|
54
|
+
if (this.keys[i] === key) {
|
|
55
|
+
return this.values[i];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "set",
|
|
63
|
+
value: function set(key, value) {
|
|
64
|
+
if (this.count < 9) {
|
|
65
|
+
this.keys[this.count] = key;
|
|
66
|
+
this.values[this.count++] = value;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}]);
|
|
70
|
+
|
|
71
|
+
return _LimitedMap;
|
|
72
|
+
}();
|
|
73
|
+
|
|
74
|
+
function getPrimitiveName(primType) {
|
|
75
|
+
switch (primType) {
|
|
76
|
+
case PrimitiveTypes.Points:
|
|
77
|
+
return 'points';
|
|
78
|
+
|
|
79
|
+
case PrimitiveTypes.Lines:
|
|
80
|
+
return 'lines';
|
|
81
|
+
|
|
82
|
+
case PrimitiveTypes.Triangles:
|
|
83
|
+
case PrimitiveTypes.TriangleEdges:
|
|
84
|
+
return 'polys';
|
|
85
|
+
|
|
86
|
+
case PrimitiveTypes.TriangleStripEdges:
|
|
87
|
+
case PrimitiveTypes.TriangleStrips:
|
|
88
|
+
return 'strips';
|
|
89
|
+
|
|
90
|
+
default:
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function _getOrAddFlatId(state, ptId, cellId) {
|
|
96
|
+
var flatId = state.pointIdToFlatId[ptId];
|
|
97
|
+
|
|
98
|
+
if (flatId < 0) {
|
|
99
|
+
flatId = state.flatId;
|
|
100
|
+
state.pointIdToFlatId[ptId] = flatId;
|
|
101
|
+
state.flatIdToPointId[state.flatId] = ptId;
|
|
102
|
+
state.flatIdToCellId[state.flatId] = cellId;
|
|
103
|
+
state.flatId++;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return flatId;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function fillCell(ptIds, cellId, state) {
|
|
110
|
+
var numPtIds = ptIds.length; // are any points already marked for this cell? If so use that as the provoking point
|
|
111
|
+
|
|
112
|
+
for (var ptIdx = 0; ptIdx < numPtIds; ptIdx++) {
|
|
113
|
+
var _ptId = ptIds[ptIdx];
|
|
114
|
+
|
|
115
|
+
if (state.cellProvokedMap.has(_ptId)) {
|
|
116
|
+
state.ibo[state.iboId++] = state.cellProvokedMap.get(_ptId); // insert remaining ptIds (they do not need to provoke)
|
|
117
|
+
|
|
118
|
+
for (var ptIdx2 = ptIdx + 1; ptIdx2 < ptIdx + numPtIds; ptIdx2++) {
|
|
119
|
+
_ptId = ptIds[ptIdx2 % numPtIds];
|
|
120
|
+
|
|
121
|
+
var _flatId = _getOrAddFlatId(state, _ptId, cellId); // add to ibo
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
state.ibo[state.iboId++] = _flatId;
|
|
125
|
+
} // all done now
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
} // else have any of the points not been used yet? (not in provokedPointIds)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
for (var _ptIdx = 0; _ptIdx < numPtIds; _ptIdx++) {
|
|
134
|
+
var _ptId2 = ptIds[_ptIdx];
|
|
135
|
+
|
|
136
|
+
if (!state.provokedPointIds[_ptId2]) {
|
|
137
|
+
var _flatId2 = _getOrAddFlatId(state, _ptId2, cellId); // mark provoking and add to ibo
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
state.provokedPointIds[_ptId2] = 1;
|
|
141
|
+
state.cellProvokedMap.set(_ptId2, _flatId2); // when provoking always set the cellId as an original non-provoking value
|
|
142
|
+
// will have been stored and we need to overwrite that
|
|
143
|
+
|
|
144
|
+
state.flatIdToCellId[_flatId2] = cellId;
|
|
145
|
+
state.ibo[state.iboId++] = _flatId2; // insert remaining ptIds (they do not need to provoke)
|
|
146
|
+
|
|
147
|
+
for (var _ptIdx2 = _ptIdx + 1; _ptIdx2 < _ptIdx + numPtIds; _ptIdx2++) {
|
|
148
|
+
_ptId2 = ptIds[_ptIdx2 % numPtIds];
|
|
149
|
+
_flatId2 = _getOrAddFlatId(state, _ptId2, cellId); // add to ibo
|
|
150
|
+
|
|
151
|
+
state.ibo[state.iboId++] = _flatId2;
|
|
152
|
+
} // all done now
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
} // if we got here then none of the ptIds could be used to provoke
|
|
158
|
+
// so just duplicate the first one
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
var ptId = ptIds[0];
|
|
162
|
+
var flatId = state.flatId;
|
|
163
|
+
state.cellProvokedMap.set(ptId, flatId);
|
|
164
|
+
state.flatIdToPointId[state.flatId] = ptId;
|
|
165
|
+
state.flatIdToCellId[state.flatId] = cellId;
|
|
166
|
+
state.flatId++; // add to ibo
|
|
167
|
+
|
|
168
|
+
state.ibo[state.iboId++] = flatId; // insert remaining ptIds (they do not need to provoke)
|
|
169
|
+
|
|
170
|
+
for (var _ptIdx3 = 1; _ptIdx3 < numPtIds; _ptIdx3++) {
|
|
171
|
+
ptId = ptIds[_ptIdx3];
|
|
172
|
+
flatId = _getOrAddFlatId(state, ptId, cellId); // add to ibo
|
|
173
|
+
|
|
174
|
+
state.ibo[state.iboId++] = flatId;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function countCell(ptIds, cellId, state) {
|
|
179
|
+
var numPtIds = ptIds.length;
|
|
180
|
+
state.iboSize += numPtIds; // are any points already marked for this cell? If so use that as the provoking point
|
|
181
|
+
|
|
182
|
+
for (var ptIdx = 0; ptIdx < numPtIds; ptIdx++) {
|
|
183
|
+
var ptId = ptIds[ptIdx];
|
|
184
|
+
|
|
185
|
+
if (state.cellProvokedMap.has(ptId)) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
} // else have any of the points not been used yet? (not in provokedPointIds)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
for (var _ptIdx4 = 0; _ptIdx4 < numPtIds; _ptIdx4++) {
|
|
192
|
+
var _ptId3 = ptIds[_ptIdx4];
|
|
193
|
+
|
|
194
|
+
if (!state.provokedPointIds[_ptId3]) {
|
|
195
|
+
state.provokedPointIds[_ptId3] = 1;
|
|
196
|
+
state.cellProvokedMap.set(_ptId3, 1);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
} // if we got here then none of the ptIds could be used to provoke
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
state.cellProvokedMap.set(ptIds[0], 1);
|
|
203
|
+
state.extraPoints++;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
var processCell;
|
|
207
|
+
|
|
208
|
+
var _single = new Uint32Array(1);
|
|
209
|
+
|
|
210
|
+
var _double = new Uint32Array(2);
|
|
211
|
+
|
|
212
|
+
var _triple = new Uint32Array(3);
|
|
213
|
+
|
|
214
|
+
var _indexCellBuilders = {
|
|
215
|
+
// easy, every input point becomes an output point
|
|
216
|
+
anythingToPoints: function anythingToPoints(numPoints, cellPts, offset, cellId, state) {
|
|
217
|
+
for (var i = 0; i < numPoints; ++i) {
|
|
218
|
+
_single[0] = cellPts[offset + i];
|
|
219
|
+
processCell(_single, cellId, state);
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
linesToWireframe: function linesToWireframe(numPoints, cellPts, offset, cellId, state) {
|
|
223
|
+
// for lines we add a bunch of segments
|
|
224
|
+
for (var i = 0; i < numPoints - 1; ++i) {
|
|
225
|
+
_double[0] = cellPts[offset + i];
|
|
226
|
+
_double[1] = cellPts[offset + i + 1];
|
|
227
|
+
processCell(_double, cellId, state);
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
polysToWireframe: function polysToWireframe(numPoints, cellPts, offset, cellId, state) {
|
|
231
|
+
// for polys we add a bunch of segments and close it
|
|
232
|
+
if (numPoints > 2) {
|
|
233
|
+
for (var i = 0; i < numPoints; ++i) {
|
|
234
|
+
_double[0] = cellPts[offset + i];
|
|
235
|
+
_double[1] = cellPts[offset + (i + 1) % numPoints];
|
|
236
|
+
processCell(_double, cellId, state);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
stripsToWireframe: function stripsToWireframe(numPoints, cellPts, offset, cellId, state) {
|
|
241
|
+
if (numPoints > 2) {
|
|
242
|
+
// for strips we add a bunch of segments and close it
|
|
243
|
+
for (var i = 0; i < numPoints - 1; ++i) {
|
|
244
|
+
_double[0] = cellPts[offset + i];
|
|
245
|
+
_double[1] = cellPts[offset + i + 1];
|
|
246
|
+
processCell(_double, cellId, state);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
for (var _i = 0; _i < numPoints - 2; _i++) {
|
|
250
|
+
_double[0] = cellPts[offset + _i];
|
|
251
|
+
_double[1] = cellPts[offset + _i + 2];
|
|
252
|
+
processCell(_double, cellId, state);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
polysToSurface: function polysToSurface(npts, cellPts, offset, cellId, state) {
|
|
257
|
+
for (var i = 0; i < npts - 2; i++) {
|
|
258
|
+
_triple[0] = cellPts[offset];
|
|
259
|
+
_triple[1] = cellPts[offset + i + 1];
|
|
260
|
+
_triple[2] = cellPts[offset + i + 2];
|
|
261
|
+
processCell(_triple, cellId, state);
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
stripsToSurface: function stripsToSurface(npts, cellPts, offset, cellId, state) {
|
|
265
|
+
for (var i = 0; i < npts - 2; i++) {
|
|
266
|
+
_triple[0] = cellPts[offset + i];
|
|
267
|
+
_triple[1] = cellPts[offset + i + 1 + i % 2];
|
|
268
|
+
_triple[2] = cellPts[offset + i + 1 + (i + 1) % 2];
|
|
269
|
+
processCell(_triple, cellId, state);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}; // ----------------------------------------------------------------------------
|
|
273
|
+
// vtkWebGPUIndexBufferManager methods
|
|
274
|
+
// ----------------------------------------------------------------------------
|
|
275
|
+
|
|
276
|
+
function vtkWebGPUIndexBuffer(publicAPI, model) {
|
|
277
|
+
// Set our className
|
|
278
|
+
model.classHierarchy.push('vtkWebGPUIndexBuffer');
|
|
279
|
+
|
|
280
|
+
publicAPI.buildIndexBuffer = function (req) {
|
|
281
|
+
var cellArray = req.cells;
|
|
282
|
+
var primitiveType = req.primitiveType;
|
|
283
|
+
var representation = req.representation;
|
|
284
|
+
var cellOffset = req.cellOffset;
|
|
285
|
+
var array = cellArray.getData();
|
|
286
|
+
var cellArraySize = array.length;
|
|
287
|
+
var inRepName = getPrimitiveName(primitiveType);
|
|
288
|
+
var numPts = req.numberOfPoints;
|
|
289
|
+
var state = {
|
|
290
|
+
provokedPointIds: new Uint8Array(numPts),
|
|
291
|
+
// size is good
|
|
292
|
+
extraPoints: 0,
|
|
293
|
+
iboSize: 0,
|
|
294
|
+
flatId: 0,
|
|
295
|
+
iboId: 0,
|
|
296
|
+
cellProvokedMap: new _LimitedMap()
|
|
297
|
+
};
|
|
298
|
+
var func = null;
|
|
299
|
+
|
|
300
|
+
if (representation === Representation.POINTS || primitiveType === PrimitiveTypes.Points) {
|
|
301
|
+
func = _indexCellBuilders.anythingToPoints;
|
|
302
|
+
} else if (representation === Representation.WIREFRAME || primitiveType === PrimitiveTypes.Lines) {
|
|
303
|
+
func = _indexCellBuilders["".concat(inRepName, "ToWireframe")];
|
|
304
|
+
} else {
|
|
305
|
+
func = _indexCellBuilders["".concat(inRepName, "ToSurface")];
|
|
306
|
+
} // first we count how many extra provoking points we need
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
processCell = countCell;
|
|
310
|
+
var cellId = cellOffset || 0;
|
|
311
|
+
|
|
312
|
+
for (var cellArrayIndex = 0; cellArrayIndex < cellArraySize;) {
|
|
313
|
+
state.cellProvokedMap.clear();
|
|
314
|
+
func(array[cellArrayIndex], array, cellArrayIndex + 1, cellId, state);
|
|
315
|
+
cellArrayIndex += array[cellArrayIndex] + 1;
|
|
316
|
+
cellId++;
|
|
317
|
+
} // then we allocate the remaining structures
|
|
318
|
+
// (we pick the best size to save space and transfer costs)
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
if (numPts <= 0xffff) {
|
|
322
|
+
state.flatIdToPointId = new Uint16Array(numPts + state.extraPoints);
|
|
323
|
+
} else {
|
|
324
|
+
state.flatIdToPointId = new Uint32Array(numPts + state.extraPoints);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (numPts + state.extraPoints < 0x8fff) {
|
|
328
|
+
state.pointIdToFlatId = new Int16Array(numPts);
|
|
329
|
+
} else {
|
|
330
|
+
state.pointIdToFlatId = new Int32Array(numPts);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (numPts + state.extraPoints <= 0xffff) {
|
|
334
|
+
state.ibo = new Uint16Array(state.iboSize);
|
|
335
|
+
req.format = 'uint16';
|
|
336
|
+
} else {
|
|
337
|
+
state.ibo = new Uint32Array(state.iboSize);
|
|
338
|
+
req.format = 'uint32';
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (cellId <= 0xffff) {
|
|
342
|
+
state.flatIdToCellId = new Uint16Array(numPts + state.extraPoints);
|
|
343
|
+
} else {
|
|
344
|
+
state.flatIdToCellId = new Uint32Array(numPts + state.extraPoints);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
state.pointIdToFlatId.fill(-1);
|
|
348
|
+
state.provokedPointIds.fill(0); // and fill them in
|
|
349
|
+
|
|
350
|
+
processCell = fillCell;
|
|
351
|
+
cellId = cellOffset || 0;
|
|
352
|
+
|
|
353
|
+
for (var _cellArrayIndex = 0; _cellArrayIndex < cellArraySize;) {
|
|
354
|
+
state.cellProvokedMap.clear();
|
|
355
|
+
func(array[_cellArrayIndex], array, _cellArrayIndex + 1, cellId, state);
|
|
356
|
+
_cellArrayIndex += array[_cellArrayIndex] + 1;
|
|
357
|
+
cellId++;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
delete state.provokedPointIds;
|
|
361
|
+
delete state.pointIdToFlatId; // store the results we need
|
|
362
|
+
|
|
363
|
+
req.nativeArray = state.ibo;
|
|
364
|
+
model.flatIdToPointId = state.flatIdToPointId;
|
|
365
|
+
model.flatIdToCellId = state.flatIdToCellId;
|
|
366
|
+
model.flatSize = state.flatId;
|
|
367
|
+
model.indexCount = state.iboId;
|
|
368
|
+
};
|
|
369
|
+
} // ----------------------------------------------------------------------------
|
|
370
|
+
// Object factory
|
|
371
|
+
// ----------------------------------------------------------------------------
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
var DEFAULT_VALUES = {
|
|
375
|
+
flatIdToPointId: null,
|
|
376
|
+
flatIdToCellId: null,
|
|
377
|
+
flatSize: 0,
|
|
378
|
+
indexCount: 0
|
|
379
|
+
}; // ----------------------------------------------------------------------------
|
|
380
|
+
|
|
381
|
+
function extend(publicAPI, model) {
|
|
382
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
383
|
+
Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance
|
|
384
|
+
|
|
385
|
+
vtkWebGPUBuffer.extend(publicAPI, model, initialValues);
|
|
386
|
+
macro.setGet(publicAPI, model, ['flatIdToPointId', 'flatIdToCellId', 'flatSize', 'indexCount']);
|
|
387
|
+
vtkWebGPUIndexBuffer(publicAPI, model);
|
|
388
|
+
} // ----------------------------------------------------------------------------
|
|
389
|
+
|
|
390
|
+
var newInstance = macro.newInstance(extend); // ----------------------------------------------------------------------------
|
|
391
|
+
|
|
392
|
+
var vtkWebGPUIndexBuffer$1 = _objectSpread({
|
|
393
|
+
newInstance: newInstance,
|
|
394
|
+
extend: extend
|
|
395
|
+
}, Constants);
|
|
396
|
+
|
|
397
|
+
export { vtkWebGPUIndexBuffer$1 as default, extend, newInstance };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import { newInstance as newInstance$1 } from '../../macros.js';
|
|
3
|
+
import vtkWebGPUBufferManager from './BufferManager.js';
|
|
4
|
+
import vtkWebGPUCellArrayMapper from './CellArrayMapper.js';
|
|
5
|
+
import vtkViewNode from '../SceneGraph/ViewNode.js';
|
|
6
|
+
import { registerOverride } from './ViewNodeFactory.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
|
+
var PrimitiveTypes = vtkWebGPUBufferManager.PrimitiveTypes; // ----------------------------------------------------------------------------
|
|
12
|
+
// vtkWebGPUPolyDataMapper methods
|
|
13
|
+
// ----------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
function vtkWebGPUPolyDataMapper2D(publicAPI, model) {
|
|
16
|
+
// Set our className
|
|
17
|
+
model.classHierarchy.push('vtkWebGPUPolyDataMapper2D');
|
|
18
|
+
|
|
19
|
+
publicAPI.createCellArrayMapper = function () {
|
|
20
|
+
return vtkWebGPUCellArrayMapper.newInstance();
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
publicAPI.buildPass = function (prepass) {
|
|
24
|
+
if (prepass) {
|
|
25
|
+
model.WebGPUActor = publicAPI.getFirstAncestorOfType('vtkWebGPUActor2D');
|
|
26
|
+
|
|
27
|
+
if (!model.renderable.getStatic()) {
|
|
28
|
+
model.renderable.update();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var poly = model.renderable.getInputData();
|
|
32
|
+
model.renderable.mapScalars(poly, 1.0);
|
|
33
|
+
publicAPI.updateCellArrayMappers(poly);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
publicAPI.updateCellArrayMappers = function (poly) {
|
|
38
|
+
var prims = [poly.getVerts(), poly.getLines(), poly.getPolys(), poly.getStrips()]; // we instantiate a cell array mapper for each cellArray that has cells
|
|
39
|
+
// and they handle the rendering of that cell array
|
|
40
|
+
|
|
41
|
+
var cellMappers = [];
|
|
42
|
+
var cellOffset = 0;
|
|
43
|
+
|
|
44
|
+
for (var i = PrimitiveTypes.Points; i <= PrimitiveTypes.Triangles; i++) {
|
|
45
|
+
if (prims[i].getNumberOfValues() > 0) {
|
|
46
|
+
if (!model.primitives[i]) {
|
|
47
|
+
model.primitives[i] = publicAPI.createCellArrayMapper();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var cellMapper = model.primitives[i];
|
|
51
|
+
cellMapper.setCellArray(prims[i]);
|
|
52
|
+
cellMapper.setCurrentInput(poly);
|
|
53
|
+
cellMapper.setCellOffset(cellOffset);
|
|
54
|
+
cellMapper.setPrimitiveType(i);
|
|
55
|
+
cellMapper.setRenderable(model.renderable);
|
|
56
|
+
cellMapper.setIs2D(true);
|
|
57
|
+
cellOffset += prims[i].getNumberOfCells();
|
|
58
|
+
cellMappers.push(cellMapper);
|
|
59
|
+
} else {
|
|
60
|
+
model.primitives[i] = null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
publicAPI.prepareNodes();
|
|
65
|
+
publicAPI.addMissingChildren(cellMappers);
|
|
66
|
+
publicAPI.removeUnusedNodes();
|
|
67
|
+
};
|
|
68
|
+
} // ----------------------------------------------------------------------------
|
|
69
|
+
// Object factory
|
|
70
|
+
// ----------------------------------------------------------------------------
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
function defaultValues(initialValues) {
|
|
74
|
+
return _objectSpread({
|
|
75
|
+
primitives: []
|
|
76
|
+
}, initialValues);
|
|
77
|
+
} // ----------------------------------------------------------------------------
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
function extend(publicAPI, model) {
|
|
81
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
82
|
+
Object.assign(model, defaultValues(initialValues)); // Inheritance
|
|
83
|
+
|
|
84
|
+
vtkViewNode.extend(publicAPI, model, initialValues);
|
|
85
|
+
model.primitives = []; // Object methods
|
|
86
|
+
|
|
87
|
+
vtkWebGPUPolyDataMapper2D(publicAPI, model);
|
|
88
|
+
} // ----------------------------------------------------------------------------
|
|
89
|
+
|
|
90
|
+
var newInstance = newInstance$1(extend, 'vtkWebGPUPolyDataMapper2D'); // ----------------------------------------------------------------------------
|
|
91
|
+
|
|
92
|
+
var index = {
|
|
93
|
+
newInstance: newInstance,
|
|
94
|
+
extend: extend
|
|
95
|
+
}; // Register ourself to WebGPU backend if imported
|
|
96
|
+
|
|
97
|
+
registerOverride('vtkMapper2D', newInstance);
|
|
98
|
+
|
|
99
|
+
export { index as default, extend, newInstance };
|