@kitware/vtk.js 28.10.2 → 28.11.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.
Files changed (565) hide show
  1. package/Common/Core/Base64.js +53 -82
  2. package/Common/Core/CellArray.js +52 -60
  3. package/Common/Core/ClassHierarchy.js +8 -36
  4. package/Common/Core/DataArray/Constants.js +6 -6
  5. package/Common/Core/DataArray.js +185 -270
  6. package/Common/Core/Endian.js +14 -17
  7. package/Common/Core/HalfFloat.js +17 -34
  8. package/Common/Core/ImageHelper.js +17 -25
  9. package/Common/Core/LookupTable.js +131 -144
  10. package/Common/Core/Math/Constants.js +8 -8
  11. package/Common/Core/Math/index.js +754 -942
  12. package/Common/Core/Math.js +2 -4
  13. package/Common/Core/MatrixBuilder.js +99 -151
  14. package/Common/Core/Points.js +43 -43
  15. package/Common/Core/PriorityQueue.js +30 -28
  16. package/Common/Core/ProgressHandler.js +31 -32
  17. package/Common/Core/ScalarsToColors/Constants.js +4 -4
  18. package/Common/Core/ScalarsToColors.js +196 -253
  19. package/Common/Core/StringArray.js +48 -73
  20. package/Common/Core/URLExtract.js +10 -29
  21. package/Common/Core/VariantArray.js +48 -73
  22. package/Common/Core.js +11 -11
  23. package/Common/DataModel/AbstractPointLocator.js +19 -17
  24. package/Common/DataModel/BoundingBox.js +322 -490
  25. package/Common/DataModel/Box.js +46 -63
  26. package/Common/DataModel/CardinalSpline1D.js +92 -102
  27. package/Common/DataModel/Cell.js +41 -61
  28. package/Common/DataModel/CellLinks.js +91 -127
  29. package/Common/DataModel/CellTypes/Constants.js +7 -6
  30. package/Common/DataModel/CellTypes.js +55 -74
  31. package/Common/DataModel/Collection.js +45 -61
  32. package/Common/DataModel/Cone.js +28 -20
  33. package/Common/DataModel/Cylinder.js +41 -35
  34. package/Common/DataModel/DataSet/Constants.js +11 -5
  35. package/Common/DataModel/DataSet.js +37 -25
  36. package/Common/DataModel/DataSetAttributes/Constants.js +18 -18
  37. package/Common/DataModel/DataSetAttributes/FieldData.js +103 -194
  38. package/Common/DataModel/DataSetAttributes.js +96 -138
  39. package/Common/DataModel/EdgeLocator.js +45 -70
  40. package/Common/DataModel/ITKHelper.js +67 -137
  41. package/Common/DataModel/ImageData.js +115 -172
  42. package/Common/DataModel/ImplicitBoolean/Constants.js +2 -2
  43. package/Common/DataModel/ImplicitBoolean.js +66 -96
  44. package/Common/DataModel/IncrementalOctreeNode.js +201 -231
  45. package/Common/DataModel/IncrementalOctreePointLocator.js +160 -198
  46. package/Common/DataModel/KochanekSpline1D.js +78 -81
  47. package/Common/DataModel/Line/Constants.js +2 -2
  48. package/Common/DataModel/Line.js +82 -105
  49. package/Common/DataModel/Locator.js +17 -10
  50. package/Common/DataModel/Molecule.js +26 -17
  51. package/Common/DataModel/PiecewiseFunction.js +218 -239
  52. package/Common/DataModel/Plane.js +90 -113
  53. package/Common/DataModel/PointSet.js +30 -26
  54. package/Common/DataModel/PolyData/Constants.js +2 -2
  55. package/Common/DataModel/PolyData.js +95 -120
  56. package/Common/DataModel/PolyLine.js +44 -61
  57. package/Common/DataModel/Polygon/Constants.js +4 -4
  58. package/Common/DataModel/Polygon.js +128 -169
  59. package/Common/DataModel/Quad/Constants.js +2 -2
  60. package/Common/DataModel/Quad.js +61 -100
  61. package/Common/DataModel/SelectionNode/Constants.js +5 -4
  62. package/Common/DataModel/SelectionNode.js +25 -21
  63. package/Common/DataModel/Sphere.js +40 -35
  64. package/Common/DataModel/Spline1D/Constants.js +3 -2
  65. package/Common/DataModel/Spline1D.js +34 -18
  66. package/Common/DataModel/Spline3D/Constants.js +2 -2
  67. package/Common/DataModel/Spline3D.js +46 -41
  68. package/Common/DataModel/StructuredData/Constants.js +2 -2
  69. package/Common/DataModel/StructuredData.js +9 -20
  70. package/Common/DataModel/Triangle.js +207 -250
  71. package/Common/DataModel.js +19 -19
  72. package/Common/System/MobileVR.js +56 -61
  73. package/Common/System/TimerLog.js +1 -1
  74. package/Common/System.js +2 -2
  75. package/Common/Transform/LandmarkTransform/Constants.js +2 -2
  76. package/Common/Transform/LandmarkTransform.js +133 -117
  77. package/Common/Transform/Transform.js +42 -57
  78. package/Common/Transform.js +2 -2
  79. package/Common/index.js +4 -4
  80. package/Filters/Core/Cutter.js +134 -146
  81. package/Filters/Core/PolyDataNormals.js +44 -50
  82. package/Filters/Core.js +2 -2
  83. package/Filters/Cornerstone/ImageDataToCornerstoneImage.js +45 -33
  84. package/Filters/Cornerstone.js +1 -1
  85. package/Filters/General/AppendPolyData.js +84 -100
  86. package/Filters/General/Calculator.js +95 -163
  87. package/Filters/General/ClipClosedSurface/Constants.js +2 -2
  88. package/Filters/General/ClipClosedSurface.js +341 -416
  89. package/Filters/General/ClosedPolyLineToSurfaceFilter.js +141 -156
  90. package/Filters/General/ContourTriangulator/Constants.js +2 -2
  91. package/Filters/General/ContourTriangulator/helper.js +684 -812
  92. package/Filters/General/ContourTriangulator.js +92 -89
  93. package/Filters/General/ImageCropFilter.js +77 -78
  94. package/Filters/General/ImageDataOutlineFilter.js +42 -36
  95. package/Filters/General/ImageMarchingCubes/caseTable.js +9 -521
  96. package/Filters/General/ImageMarchingCubes.js +99 -112
  97. package/Filters/General/ImageMarchingSquares/caseTable.js +9 -41
  98. package/Filters/General/ImageMarchingSquares.js +93 -118
  99. package/Filters/General/ImageOutlineFilter.js +53 -54
  100. package/Filters/General/ImageSliceFilter.js +39 -30
  101. package/Filters/General/ImageStreamline.js +107 -124
  102. package/Filters/General/LineFilter.js +26 -15
  103. package/Filters/General/MoleculeToRepresentation.js +136 -149
  104. package/Filters/General/OBBTree/OBBNode.js +36 -34
  105. package/Filters/General/OBBTree/helper.js +19 -24
  106. package/Filters/General/OBBTree.js +396 -488
  107. package/Filters/General/OutlineFilter.js +52 -34
  108. package/Filters/General/PaintFilter/PaintFilter.worker.js +93 -130
  109. package/Filters/General/PaintFilter.js +150 -162
  110. package/Filters/General/ScalarToRGBA.js +38 -33
  111. package/Filters/General/TriangleFilter.js +65 -62
  112. package/Filters/General/TubeFilter/Constants.js +4 -4
  113. package/Filters/General/TubeFilter.js +376 -496
  114. package/Filters/General/WarpScalar.js +58 -60
  115. package/Filters/General/WindowedSincPolyDataFilter.js +258 -330
  116. package/Filters/General.js +21 -21
  117. package/Filters/Sources/Arrow2DSource/Constants.js +2 -2
  118. package/Filters/Sources/Arrow2DSource.js +56 -56
  119. package/Filters/Sources/ArrowSource.js +39 -29
  120. package/Filters/Sources/CircleSource.js +43 -43
  121. package/Filters/Sources/ConcentricCylinderSource.js +151 -174
  122. package/Filters/Sources/ConeSource.js +51 -42
  123. package/Filters/Sources/CubeSource.js +75 -96
  124. package/Filters/Sources/Cursor3D.js +94 -109
  125. package/Filters/Sources/CylinderSource.js +90 -90
  126. package/Filters/Sources/ImageGridSource.js +43 -43
  127. package/Filters/Sources/LineSource.js +49 -39
  128. package/Filters/Sources/PlaneSource.js +97 -104
  129. package/Filters/Sources/PointSource.js +46 -37
  130. package/Filters/Sources/RTAnalyticSource.js +50 -48
  131. package/Filters/Sources/SLICSource.js +63 -73
  132. package/Filters/Sources/SphereSource.js +88 -78
  133. package/Filters/Sources/ViewFinderSource.js +26 -23
  134. package/Filters/Sources.js +14 -14
  135. package/Filters/Texture/TextureMapToPlane.js +95 -97
  136. package/Filters/Texture/TextureMapToSphere.js +46 -54
  137. package/Filters/Texture.js +2 -2
  138. package/Filters/index.js +5 -5
  139. package/IO/Core/BinaryHelper.js +12 -18
  140. package/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js +43 -59
  141. package/IO/Core/DataAccessHelper/HttpDataAccessHelper.js +76 -113
  142. package/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js +62 -112
  143. package/IO/Core/DataAccessHelper/LiteHttpDataAccessHelper.js +76 -113
  144. package/IO/Core/DataAccessHelper.js +6 -6
  145. package/IO/Core/HttpDataSetReader.js +136 -139
  146. package/IO/Core/HttpDataSetSeriesReader.js +64 -75
  147. package/IO/Core/HttpSceneLoader.js +130 -179
  148. package/IO/Core/ImageStream/DefaultProtocol.js +29 -43
  149. package/IO/Core/ImageStream/ViewStream.js +100 -103
  150. package/IO/Core/ImageStream.js +62 -54
  151. package/IO/Core/ResourceLoader.js +10 -9
  152. package/IO/Core/Serializer/ArraySerializer.js +40 -40
  153. package/IO/Core/Serializer/FieldDataSerializer.js +18 -28
  154. package/IO/Core/Serializer/ImageDataSerializer.js +22 -23
  155. package/IO/Core/Serializer/PolyDataSerializer.js +17 -21
  156. package/IO/Core/Serializer.js +6 -13
  157. package/IO/Core/WSLinkClient.js +90 -76
  158. package/IO/Core/ZipMultiDataSetReader.js +46 -44
  159. package/IO/Core/ZipMultiDataSetWriter.js +43 -34
  160. package/IO/Core.js +7 -7
  161. package/IO/Geometry/DracoReader.js +118 -121
  162. package/IO/Geometry/PLYReader.js +163 -223
  163. package/IO/Geometry/PLYWriter/Constants.js +5 -5
  164. package/IO/Geometry/PLYWriter.js +139 -154
  165. package/IO/Geometry/STLReader.js +123 -146
  166. package/IO/Geometry/STLWriter/Constants.js +2 -2
  167. package/IO/Geometry/STLWriter.js +83 -82
  168. package/IO/Geometry.js +5 -5
  169. package/IO/Legacy/LegacyAsciiParser.js +78 -139
  170. package/IO/Legacy/PolyDataReader.js +48 -36
  171. package/IO/Legacy.js +2 -2
  172. package/IO/Misc/ElevationReader.js +67 -60
  173. package/IO/Misc/HttpDataSetLODsLoader.js +41 -38
  174. package/IO/Misc/ITKImageReader.js +58 -45
  175. package/IO/Misc/ITKPolyDataReader.js +50 -38
  176. package/IO/Misc/JSONNucleoReader.js +49 -42
  177. package/IO/Misc/JSONReader.js +38 -33
  178. package/IO/Misc/MTLReader.js +74 -119
  179. package/IO/Misc/OBJReader.js +153 -206
  180. package/IO/Misc/PDBReader.js +70 -68
  181. package/IO/Misc/SkyboxReader.js +77 -82
  182. package/IO/Misc.js +9 -9
  183. package/IO/XML/XMLImageDataReader.js +36 -38
  184. package/IO/XML/XMLImageDataWriter.js +28 -21
  185. package/IO/XML/XMLPolyDataReader.js +49 -46
  186. package/IO/XML/XMLPolyDataWriter.js +43 -42
  187. package/IO/XML/XMLReader.js +262 -304
  188. package/IO/XML/XMLWriter/Constants.js +3 -3
  189. package/IO/XML/XMLWriter.js +70 -84
  190. package/IO/XML.js +6 -6
  191. package/IO/index.js +5 -5
  192. package/Imaging/Core/AbstractImageInterpolator/Constants.js +4 -4
  193. package/Imaging/Core/AbstractImageInterpolator/InterpolationInfo.js +30 -27
  194. package/Imaging/Core/AbstractImageInterpolator.js +74 -87
  195. package/Imaging/Core/ImageInterpolator.js +201 -252
  196. package/Imaging/Core/ImagePointDataIterator.js +96 -122
  197. package/Imaging/Core/ImageReslice/Constants.js +2 -2
  198. package/Imaging/Core/ImageReslice.js +327 -464
  199. package/Imaging/Core.js +4 -4
  200. package/Imaging/Hybrid/SampleFunction.js +58 -51
  201. package/Imaging/Hybrid.js +1 -1
  202. package/Imaging/index.js +2 -2
  203. package/Interaction/Animations/TimeStepBasedAnimationHandler.js +39 -54
  204. package/Interaction/Manipulators/CompositeCameraManipulator.js +22 -13
  205. package/Interaction/Manipulators/CompositeGestureManipulator.js +31 -43
  206. package/Interaction/Manipulators/CompositeKeyboardManipulator.js +15 -11
  207. package/Interaction/Manipulators/CompositeMouseManipulator.js +27 -33
  208. package/Interaction/Manipulators/CompositeVRManipulator.js +22 -15
  209. package/Interaction/Manipulators/GestureCameraManipulator.js +54 -36
  210. package/Interaction/Manipulators/KeyboardCameraManipulator.js +95 -97
  211. package/Interaction/Manipulators/MouseBoxSelectorManipulator.js +70 -89
  212. package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +67 -54
  213. package/Interaction/Manipulators/MouseCameraSliceManipulator.js +40 -38
  214. package/Interaction/Manipulators/MouseCameraTrackballFirstPersonManipulator.js +83 -68
  215. package/Interaction/Manipulators/MouseCameraTrackballMultiRotateManipulator.js +32 -28
  216. package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.js +47 -40
  217. package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +55 -43
  218. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +56 -46
  219. package/Interaction/Manipulators/MouseCameraTrackballZoomManipulator.js +41 -46
  220. package/Interaction/Manipulators/MouseCameraTrackballZoomToMouseManipulator.js +29 -27
  221. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +123 -146
  222. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +144 -166
  223. package/Interaction/Manipulators/MouseRangeManipulator.js +127 -132
  224. package/Interaction/Manipulators/VRButtonPanManipulator.js +33 -23
  225. package/Interaction/Manipulators.js +21 -21
  226. package/Interaction/Misc/DeviceOrientationToCamera.js +25 -47
  227. package/Interaction/Misc.js +1 -1
  228. package/Interaction/Style/InteractorStyleImage.js +101 -121
  229. package/Interaction/Style/InteractorStyleMPRSlice.js +111 -128
  230. package/Interaction/Style/InteractorStyleManipulator/Presets.js +9 -17
  231. package/Interaction/Style/InteractorStyleManipulator.js +254 -329
  232. package/Interaction/Style/InteractorStyleRemoteMouse.js +195 -180
  233. package/Interaction/Style/InteractorStyleTrackballCamera.js +154 -157
  234. package/Interaction/Style/InteractorStyleUnicam.js +30 -38
  235. package/Interaction/Style.js +5 -5
  236. package/Interaction/UI/CornerAnnotation/CornerAnnotation.module.css.js +1 -1
  237. package/Interaction/UI/CornerAnnotation.js +65 -48
  238. package/Interaction/UI/FPSMonitor.js +104 -105
  239. package/Interaction/UI/Icons.js +1 -1
  240. package/Interaction/UI/Slider/Constants.js +2 -2
  241. package/Interaction/UI/Slider.js +78 -95
  242. package/Interaction/UI/VolumeController.js +104 -97
  243. package/Interaction/UI.js +5 -5
  244. package/Interaction/Widgets/OrientationMarkerWidget/Constants.js +2 -2
  245. package/Interaction/Widgets/OrientationMarkerWidget.js +90 -135
  246. package/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +0 -3
  247. package/Interaction/Widgets/PiecewiseGaussianWidget.js +381 -498
  248. package/Interaction/Widgets.js +2 -2
  249. package/Interaction/index.js +5 -5
  250. package/Proxy/Animation/AbstractAnimationProxy.js +22 -15
  251. package/Proxy/Animation/AnimationProxyManager.js +43 -51
  252. package/Proxy/Animation/TimeStepBasedAnimationHandlerProxy.js +26 -19
  253. package/Proxy/Core/AbstractRepresentationProxy.js +97 -151
  254. package/Proxy/Core/LookupTableProxy/Constants.js +4 -4
  255. package/Proxy/Core/LookupTableProxy.js +49 -52
  256. package/Proxy/Core/PiecewiseFunctionProxy/Constants.js +4 -4
  257. package/Proxy/Core/PiecewiseFunctionProxy.js +63 -72
  258. package/Proxy/Core/ProxyManager/core.js +83 -106
  259. package/Proxy/Core/ProxyManager/properties.js +53 -76
  260. package/Proxy/Core/ProxyManager/state.js +100 -110
  261. package/Proxy/Core/ProxyManager/view.js +45 -55
  262. package/Proxy/Core/ProxyManager.js +16 -8
  263. package/Proxy/Core/SourceProxy.js +41 -38
  264. package/Proxy/Core/View2DProxy.js +143 -199
  265. package/Proxy/Core/ViewProxy.js +223 -269
  266. package/Proxy/Core.js +7 -7
  267. package/Proxy/Representations/GeometryRepresentationProxy.js +34 -20
  268. package/Proxy/Representations/GlyphRepresentationProxy.js +42 -41
  269. package/Proxy/Representations/MoleculeRepresentationProxy.js +32 -22
  270. package/Proxy/Representations/ResliceRepresentationProxy.js +48 -32
  271. package/Proxy/Representations/SkyboxRepresentationProxy.js +30 -29
  272. package/Proxy/Representations/SliceRepresentationProxy.js +93 -112
  273. package/Proxy/Representations/SlicedGeometryRepresentationProxy.js +46 -42
  274. package/Proxy/Representations/VolumeRepresentationProxy.js +108 -133
  275. package/Proxy/Representations.js +7 -7
  276. package/Proxy/index.js +2 -2
  277. package/Rendering/Core/AbstractImageMapper/helper.js +44 -49
  278. package/Rendering/Core/AbstractImageMapper.js +18 -19
  279. package/Rendering/Core/AbstractMapper.js +39 -55
  280. package/Rendering/Core/AbstractMapper3D.js +26 -31
  281. package/Rendering/Core/AbstractPicker.js +25 -21
  282. package/Rendering/Core/Actor.js +71 -93
  283. package/Rendering/Core/Actor2D.js +64 -78
  284. package/Rendering/Core/AnnotatedCubeActor/Presets.js +5 -11
  285. package/Rendering/Core/AnnotatedCubeActor.js +94 -79
  286. package/Rendering/Core/AxesActor.js +65 -87
  287. package/Rendering/Core/Camera.js +246 -271
  288. package/Rendering/Core/CellPicker.js +125 -148
  289. package/Rendering/Core/ColorTransferFunction/ColorMaps.js +20 -21
  290. package/Rendering/Core/ColorTransferFunction/ColorMapsLite.js +20 -21
  291. package/Rendering/Core/ColorTransferFunction/Constants.js +4 -4
  292. package/Rendering/Core/ColorTransferFunction.js +460 -546
  293. package/Rendering/Core/Coordinate/Constants.js +2 -2
  294. package/Rendering/Core/Coordinate.js +119 -198
  295. package/Rendering/Core/CubeAxesActor.js +294 -320
  296. package/Rendering/Core/Follower.js +46 -45
  297. package/Rendering/Core/Glyph3DMapper/Constants.js +4 -4
  298. package/Rendering/Core/Glyph3DMapper.js +96 -148
  299. package/Rendering/Core/HardwareSelector.js +36 -69
  300. package/Rendering/Core/ImageArrayMapper.js +87 -126
  301. package/Rendering/Core/ImageCPRMapper.js +134 -209
  302. package/Rendering/Core/ImageMapper/Constants.js +2 -2
  303. package/Rendering/Core/ImageMapper.js +85 -144
  304. package/Rendering/Core/ImageProperty/Constants.js +2 -2
  305. package/Rendering/Core/ImageProperty.js +66 -81
  306. package/Rendering/Core/ImageResliceMapper/Constants.js +2 -2
  307. package/Rendering/Core/ImageResliceMapper.js +36 -29
  308. package/Rendering/Core/ImageSlice.js +85 -127
  309. package/Rendering/Core/InteractorObserver.js +82 -73
  310. package/Rendering/Core/InteractorStyle/Constants.js +2 -2
  311. package/Rendering/Core/InteractorStyle.js +56 -58
  312. package/Rendering/Core/Light.js +43 -49
  313. package/Rendering/Core/Mapper/CoincidentTopologyHelper.js +37 -48
  314. package/Rendering/Core/Mapper/Constants.js +6 -6
  315. package/Rendering/Core/Mapper/Static.js +15 -12
  316. package/Rendering/Core/Mapper.js +194 -259
  317. package/Rendering/Core/Mapper2D.js +61 -100
  318. package/Rendering/Core/Picker.js +124 -143
  319. package/Rendering/Core/PixelSpaceCallbackMapper.js +40 -37
  320. package/Rendering/Core/PointPicker.js +68 -79
  321. package/Rendering/Core/Prop/Constants.js +2 -2
  322. package/Rendering/Core/Prop.js +58 -106
  323. package/Rendering/Core/Prop3D.js +54 -83
  324. package/Rendering/Core/Property/Constants.js +6 -6
  325. package/Rendering/Core/Property.js +45 -74
  326. package/Rendering/Core/Property2D/Constants.js +2 -2
  327. package/Rendering/Core/Property2D.js +33 -42
  328. package/Rendering/Core/RenderWindow.js +70 -82
  329. package/Rendering/Core/RenderWindowInteractor/Constants.js +7 -7
  330. package/Rendering/Core/RenderWindowInteractor.js +324 -439
  331. package/Rendering/Core/Renderer.js +192 -256
  332. package/Rendering/Core/ScalarBarActor.js +267 -272
  333. package/Rendering/Core/Skybox.js +26 -24
  334. package/Rendering/Core/SphereMapper.js +22 -12
  335. package/Rendering/Core/StickMapper.js +22 -12
  336. package/Rendering/Core/SurfaceLICInterface/Constants.js +6 -6
  337. package/Rendering/Core/SurfaceLICInterface.js +13 -9
  338. package/Rendering/Core/SurfaceLICMapper.js +23 -15
  339. package/Rendering/Core/Texture.js +99 -141
  340. package/Rendering/Core/Viewport.js +60 -88
  341. package/Rendering/Core/Volume.js +55 -77
  342. package/Rendering/Core/VolumeMapper/Constants.js +4 -4
  343. package/Rendering/Core/VolumeMapper.js +59 -91
  344. package/Rendering/Core/VolumeProperty/Constants.js +4 -4
  345. package/Rendering/Core/VolumeProperty.js +78 -115
  346. package/Rendering/Core.js +47 -49
  347. package/Rendering/Misc/CanvasView.js +62 -61
  348. package/Rendering/Misc/FullScreenRenderWindow.js +60 -62
  349. package/Rendering/Misc/GenericRenderWindow.js +48 -37
  350. package/Rendering/Misc/RemoteView.js +86 -80
  351. package/Rendering/Misc/RenderWindowWithControlBar.js +54 -48
  352. package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/CameraSynchronizer.js +43 -51
  353. package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager.js +52 -82
  354. package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.js +258 -308
  355. package/Rendering/Misc/SynchronizableRenderWindow.js +133 -163
  356. package/Rendering/Misc/TextureLODsDownloader.js +72 -74
  357. package/Rendering/Misc.js +7 -7
  358. package/Rendering/OpenGL/Actor.js +57 -68
  359. package/Rendering/OpenGL/Actor2D.js +56 -56
  360. package/Rendering/OpenGL/BufferObject/Constants.js +2 -2
  361. package/Rendering/OpenGL/BufferObject.js +50 -65
  362. package/Rendering/OpenGL/Camera.js +35 -29
  363. package/Rendering/OpenGL/CellArrayBufferObject.js +119 -149
  364. package/Rendering/OpenGL/Convolution2DPass.js +87 -81
  365. package/Rendering/OpenGL/CubeAxesActor.js +28 -21
  366. package/Rendering/OpenGL/ForwardPass.js +53 -64
  367. package/Rendering/OpenGL/Framebuffer.js +61 -101
  368. package/Rendering/OpenGL/Glyph3DMapper.js +165 -196
  369. package/Rendering/OpenGL/HardwareSelector/Constants.js +2 -2
  370. package/Rendering/OpenGL/HardwareSelector.js +272 -397
  371. package/Rendering/OpenGL/Helper.js +58 -73
  372. package/Rendering/OpenGL/ImageCPRMapper.js +339 -421
  373. package/Rendering/OpenGL/ImageMapper.js +268 -361
  374. package/Rendering/OpenGL/ImageResliceMapper.js +306 -438
  375. package/Rendering/OpenGL/ImageSlice.js +48 -54
  376. package/Rendering/OpenGL/OrderIndependentTranslucentPass.js +102 -84
  377. package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +43 -42
  378. package/Rendering/OpenGL/PolyDataMapper.js +358 -492
  379. package/Rendering/OpenGL/PolyDataMapper2D.js +153 -205
  380. package/Rendering/OpenGL/RadialDistortionPass.js +86 -89
  381. package/Rendering/OpenGL/RenderWindow/Constants.js +2 -2
  382. package/Rendering/OpenGL/RenderWindow/ContextProxy.js +20 -29
  383. package/Rendering/OpenGL/RenderWindow.js +356 -510
  384. package/Rendering/OpenGL/Renderer.js +77 -89
  385. package/Rendering/OpenGL/ReplacementShaderMapper.js +28 -46
  386. package/Rendering/OpenGL/ScalarBarActor.js +28 -21
  387. package/Rendering/OpenGL/Shader.js +37 -31
  388. package/Rendering/OpenGL/ShaderCache.js +67 -74
  389. package/Rendering/OpenGL/ShaderProgram.js +136 -248
  390. package/Rendering/OpenGL/Skybox.js +99 -60
  391. package/Rendering/OpenGL/SphereMapper.js +94 -108
  392. package/Rendering/OpenGL/StickMapper.js +110 -114
  393. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +91 -157
  394. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +142 -151
  395. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +142 -216
  396. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +79 -100
  397. package/Rendering/OpenGL/SurfaceLIC.js +2 -2
  398. package/Rendering/OpenGL/Texture/Constants.js +4 -4
  399. package/Rendering/OpenGL/Texture.js +443 -608
  400. package/Rendering/OpenGL/TextureUnitManager.js +47 -43
  401. package/Rendering/OpenGL/VertexArrayObject.js +92 -131
  402. package/Rendering/OpenGL/ViewNodeFactory.js +25 -13
  403. package/Rendering/OpenGL/Volume.js +38 -34
  404. package/Rendering/OpenGL/VolumeMapper.js +437 -547
  405. package/Rendering/OpenGL.js +28 -28
  406. package/Rendering/SceneGraph/RenderPass.js +34 -31
  407. package/Rendering/SceneGraph/RenderWindowViewNode.js +68 -94
  408. package/Rendering/SceneGraph/ViewNode.js +82 -111
  409. package/Rendering/SceneGraph/ViewNodeFactory.js +31 -26
  410. package/Rendering/SceneGraph.js +4 -4
  411. package/Rendering/WebGPU/Actor.js +49 -49
  412. package/Rendering/WebGPU/Actor2D.js +45 -44
  413. package/Rendering/WebGPU/BindGroup.js +43 -50
  414. package/Rendering/WebGPU/Buffer.js +41 -50
  415. package/Rendering/WebGPU/BufferManager/Constants.js +4 -4
  416. package/Rendering/WebGPU/BufferManager.js +111 -141
  417. package/Rendering/WebGPU/Camera.js +65 -67
  418. package/Rendering/WebGPU/CellArrayMapper.js +621 -388
  419. package/Rendering/WebGPU/CubeAxesActor.js +28 -19
  420. package/Rendering/WebGPU/Device.js +78 -133
  421. package/Rendering/WebGPU/ForwardPass.js +75 -72
  422. package/Rendering/WebGPU/FullScreenQuad.js +25 -18
  423. package/Rendering/WebGPU/Glyph3DMapper.js +62 -74
  424. package/Rendering/WebGPU/HardwareSelectionPass.js +45 -38
  425. package/Rendering/WebGPU/HardwareSelector.js +200 -276
  426. package/Rendering/WebGPU/ImageMapper.js +180 -171
  427. package/Rendering/WebGPU/ImageSlice.js +45 -44
  428. package/Rendering/WebGPU/IndexBuffer.js +166 -200
  429. package/Rendering/WebGPU/OpaquePass.js +37 -36
  430. package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +72 -45
  431. package/Rendering/WebGPU/Pipeline.js +37 -51
  432. package/Rendering/WebGPU/PixelSpaceCallbackMapper.js +27 -19
  433. package/Rendering/WebGPU/PolyDataMapper.js +50 -53
  434. package/Rendering/WebGPU/PolyDataMapper2D.js +39 -39
  435. package/Rendering/WebGPU/RenderEncoder.js +68 -88
  436. package/Rendering/WebGPU/RenderWindow.js +262 -376
  437. package/Rendering/WebGPU/Renderer.js +224 -208
  438. package/Rendering/WebGPU/Sampler.js +27 -21
  439. package/Rendering/WebGPU/ScalarBarActor.js +28 -19
  440. package/Rendering/WebGPU/ShaderCache.js +43 -41
  441. package/Rendering/WebGPU/ShaderDescription.js +52 -59
  442. package/Rendering/WebGPU/ShaderModule.js +26 -17
  443. package/Rendering/WebGPU/SimpleMapper.js +185 -121
  444. package/Rendering/WebGPU/SphereMapper.js +200 -130
  445. package/Rendering/WebGPU/StickMapper.js +289 -152
  446. package/Rendering/WebGPU/StorageBuffer.js +100 -115
  447. package/Rendering/WebGPU/Texture.js +79 -99
  448. package/Rendering/WebGPU/TextureManager.js +52 -54
  449. package/Rendering/WebGPU/TextureView.js +40 -43
  450. package/Rendering/WebGPU/Types.js +53 -70
  451. package/Rendering/WebGPU/UniformBuffer.js +158 -184
  452. package/Rendering/WebGPU/VertexInput.js +64 -90
  453. package/Rendering/WebGPU/ViewNodeFactory.js +25 -13
  454. package/Rendering/WebGPU/Volume.js +52 -51
  455. package/Rendering/WebGPU/VolumePass.js +218 -239
  456. package/Rendering/WebGPU/VolumePassFSQ.js +625 -306
  457. package/Rendering/WebGPU.js +1 -1
  458. package/Rendering/index.js +5 -5
  459. package/Widgets/Core/AbstractWidget/Constants.js +2 -2
  460. package/Widgets/Core/AbstractWidget.js +49 -58
  461. package/Widgets/Core/AbstractWidgetFactory.js +101 -122
  462. package/Widgets/Core/StateBuilder/boundsMixin.js +23 -28
  463. package/Widgets/Core/StateBuilder/color3Mixin.js +10 -7
  464. package/Widgets/Core/StateBuilder/colorMixin.js +10 -6
  465. package/Widgets/Core/StateBuilder/cornerMixin.js +16 -15
  466. package/Widgets/Core/StateBuilder/directionMixin.js +20 -18
  467. package/Widgets/Core/StateBuilder/manipulatorMixin.js +26 -18
  468. package/Widgets/Core/StateBuilder/nameMixin.js +10 -6
  469. package/Widgets/Core/StateBuilder/orientationMixin.js +19 -16
  470. package/Widgets/Core/StateBuilder/originMixin.js +25 -32
  471. package/Widgets/Core/StateBuilder/scale1Mixin.js +10 -6
  472. package/Widgets/Core/StateBuilder/scale3Mixin.js +10 -6
  473. package/Widgets/Core/StateBuilder/shapeMixin.js +12 -6
  474. package/Widgets/Core/StateBuilder/textMixin.js +10 -6
  475. package/Widgets/Core/StateBuilder/visibleMixin.js +10 -6
  476. package/Widgets/Core/StateBuilder.js +120 -149
  477. package/Widgets/Core/WidgetManager/Constants.js +7 -7
  478. package/Widgets/Core/WidgetManager.js +249 -421
  479. package/Widgets/Core/WidgetState.js +48 -57
  480. package/Widgets/Core.js +5 -5
  481. package/Widgets/Manipulators/AbstractManipulator.js +20 -14
  482. package/Widgets/Manipulators/CPRManipulator.js +55 -71
  483. package/Widgets/Manipulators/LineManipulator.js +31 -28
  484. package/Widgets/Manipulators/PickerManipulator.d.ts +48 -0
  485. package/Widgets/Manipulators/PickerManipulator.js +65 -0
  486. package/Widgets/Manipulators/PlaneManipulator.js +26 -23
  487. package/Widgets/Manipulators/TrackballManipulator.js +39 -35
  488. package/Widgets/Manipulators.js +4 -2
  489. package/Widgets/Representations/ArrowHandleRepresentation.js +148 -162
  490. package/Widgets/Representations/CircleContextRepresentation.js +44 -38
  491. package/Widgets/Representations/ContextRepresentation.js +17 -14
  492. package/Widgets/Representations/ConvexFaceContextRepresentation.js +50 -47
  493. package/Widgets/Representations/CroppingOutlineRepresentation.js +38 -27
  494. package/Widgets/Representations/CubeHandleRepresentation.js +21 -18
  495. package/Widgets/Representations/GlyphRepresentation.js +107 -152
  496. package/Widgets/Representations/HandleRepresentation.js +17 -14
  497. package/Widgets/Representations/ImplicitPlaneRepresentation.js +97 -91
  498. package/Widgets/Representations/LineHandleRepresentation.js +44 -41
  499. package/Widgets/Representations/OutlineContextRepresentation.js +42 -36
  500. package/Widgets/Representations/PolyLineRepresentation.js +60 -75
  501. package/Widgets/Representations/RectangleContextRepresentation.js +42 -37
  502. package/Widgets/Representations/SphereContextRepresentation.js +19 -27
  503. package/Widgets/Representations/SphereHandleRepresentation.js +31 -27
  504. package/Widgets/Representations/SplineContextRepresentation.js +46 -70
  505. package/Widgets/Representations/WidgetRepresentation/Constants.js +2 -2
  506. package/Widgets/Representations/WidgetRepresentation.js +99 -134
  507. package/Widgets/Representations.js +13 -13
  508. package/Widgets/Widgets3D/AngleWidget/behavior.js +41 -63
  509. package/Widgets/Widgets3D/AngleWidget.js +40 -38
  510. package/Widgets/Widgets3D/DistanceWidget/behavior.js +40 -61
  511. package/Widgets/Widgets3D/DistanceWidget.js +38 -36
  512. package/Widgets/Widgets3D/EllipseWidget/behavior.js +14 -19
  513. package/Widgets/Widgets3D/EllipseWidget/state.js +4 -2
  514. package/Widgets/Widgets3D/EllipseWidget.js +37 -26
  515. package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +26 -56
  516. package/Widgets/Widgets3D/ImageCroppingWidget/helpers.js +14 -17
  517. package/Widgets/Widgets3D/ImageCroppingWidget/state.js +20 -16
  518. package/Widgets/Widgets3D/ImageCroppingWidget.js +80 -98
  519. package/Widgets/Widgets3D/ImplicitPlaneWidget.js +55 -77
  520. package/Widgets/Widgets3D/InteractiveOrientationWidget/behavior.js +17 -18
  521. package/Widgets/Widgets3D/InteractiveOrientationWidget/state.js +15 -7
  522. package/Widgets/Widgets3D/InteractiveOrientationWidget.js +30 -29
  523. package/Widgets/Widgets3D/LabelWidget/behavior.js +37 -62
  524. package/Widgets/Widgets3D/LabelWidget.js +31 -25
  525. package/Widgets/Widgets3D/LineWidget/Constants.js +8 -8
  526. package/Widgets/Widgets3D/LineWidget/behavior.js +77 -114
  527. package/Widgets/Widgets3D/LineWidget/helpers.js +13 -20
  528. package/Widgets/Widgets3D/LineWidget/state.js +2 -1
  529. package/Widgets/Widgets3D/LineWidget.js +39 -35
  530. package/Widgets/Widgets3D/PaintWidget/behavior.js +24 -59
  531. package/Widgets/Widgets3D/PaintWidget.js +39 -37
  532. package/Widgets/Widgets3D/PolyLineWidget/behavior.js +44 -68
  533. package/Widgets/Widgets3D/PolyLineWidget.js +36 -31
  534. package/Widgets/Widgets3D/RectangleWidget/behavior.js +6 -11
  535. package/Widgets/Widgets3D/RectangleWidget/state.js +4 -2
  536. package/Widgets/Widgets3D/RectangleWidget.js +37 -25
  537. package/Widgets/Widgets3D/ResliceCursorWidget/Constants.js +35 -21
  538. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +133 -209
  539. package/Widgets/Widgets3D/ResliceCursorWidget/cprBehavior.js +26 -41
  540. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +89 -116
  541. package/Widgets/Widgets3D/ResliceCursorWidget/state.js +33 -40
  542. package/Widgets/Widgets3D/ResliceCursorWidget.js +186 -227
  543. package/Widgets/Widgets3D/SeedWidget/behavior.js +82 -0
  544. package/Widgets/Widgets3D/SeedWidget/state.js +18 -0
  545. package/Widgets/Widgets3D/SeedWidget.d.ts +44 -0
  546. package/Widgets/Widgets3D/SeedWidget.js +43 -0
  547. package/Widgets/Widgets3D/ShapeWidget/Constants.js +19 -19
  548. package/Widgets/Widgets3D/ShapeWidget/behavior.js +150 -252
  549. package/Widgets/Widgets3D/ShapeWidget.js +24 -27
  550. package/Widgets/Widgets3D/SphereWidget/behavior.js +35 -69
  551. package/Widgets/Widgets3D/SphereWidget/state.js +9 -5
  552. package/Widgets/Widgets3D/SphereWidget.js +34 -44
  553. package/Widgets/Widgets3D/SplineWidget/behavior.js +85 -120
  554. package/Widgets/Widgets3D/SplineWidget.js +43 -39
  555. package/Widgets/Widgets3D.js +15 -15
  556. package/Widgets/index.js +4 -4
  557. package/_virtual/rollup-plugin-worker-loader__module_Sources/Filters/General/PaintFilter/PaintFilter.worker.js +95 -207
  558. package/_virtual/rollup-plugin-worker-loader__module_Sources/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +0 -3
  559. package/favicon.js +5 -6
  560. package/index.d.ts +4 -2
  561. package/index.js +4 -3
  562. package/macros.js +4 -1931
  563. package/macros2.js +1684 -0
  564. package/package.json +6 -6
  565. package/vtk.js +18 -31
package/macros.js CHANGED
@@ -1,1931 +1,4 @@
1
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
- import _typeof from '@babel/runtime/helpers/typeof';
3
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
5
- import _construct from '@babel/runtime/helpers/construct';
6
- import DeepEqual from 'fast-deep-equal';
7
- import vtk, { vtkGlobal } from './vtk.js';
8
- import ClassHierarchy from './Common/Core/ClassHierarchy.js';
9
-
10
- 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; }
11
-
12
- 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; }
13
- var globalMTime = 0;
14
- var VOID = Symbol('void');
15
-
16
- function getCurrentGlobalMTime() {
17
- return globalMTime;
18
- } // ----------------------------------------------------------------------------
19
- // Logging function calls
20
- // ----------------------------------------------------------------------------
21
-
22
- /* eslint-disable no-prototype-builtins */
23
-
24
-
25
- var fakeConsole = {};
26
-
27
- function noOp() {}
28
-
29
- var consoleMethods = ['log', 'debug', 'info', 'warn', 'error', 'time', 'timeEnd', 'group', 'groupEnd'];
30
- consoleMethods.forEach(function (methodName) {
31
- fakeConsole[methodName] = noOp;
32
- });
33
- vtkGlobal.console = console.hasOwnProperty('log') ? console : fakeConsole;
34
- var loggerFunctions = {
35
- debug: noOp,
36
- // Don't print debug by default
37
- error: vtkGlobal.console.error || noOp,
38
- info: vtkGlobal.console.info || noOp,
39
- log: vtkGlobal.console.log || noOp,
40
- warn: vtkGlobal.console.warn || noOp
41
- };
42
- function setLoggerFunction(name, fn) {
43
- if (loggerFunctions[name]) {
44
- loggerFunctions[name] = fn || noOp;
45
- }
46
- }
47
- function vtkLogMacro() {
48
- loggerFunctions.log.apply(loggerFunctions, arguments);
49
- }
50
- function vtkInfoMacro() {
51
- loggerFunctions.info.apply(loggerFunctions, arguments);
52
- }
53
- function vtkDebugMacro() {
54
- loggerFunctions.debug.apply(loggerFunctions, arguments);
55
- }
56
- function vtkErrorMacro() {
57
- loggerFunctions.error.apply(loggerFunctions, arguments);
58
- }
59
- function vtkWarningMacro() {
60
- loggerFunctions.warn.apply(loggerFunctions, arguments);
61
- }
62
- var ERROR_ONCE_MAP = {};
63
- function vtkOnceErrorMacro(str) {
64
- if (!ERROR_ONCE_MAP[str]) {
65
- loggerFunctions.error(str);
66
- ERROR_ONCE_MAP[str] = true;
67
- }
68
- } // ----------------------------------------------------------------------------
69
- // TypedArray
70
- // ----------------------------------------------------------------------------
71
-
72
- var TYPED_ARRAYS = Object.create(null);
73
- TYPED_ARRAYS.Float32Array = Float32Array;
74
- TYPED_ARRAYS.Float64Array = Float64Array;
75
- TYPED_ARRAYS.Uint8Array = Uint8Array;
76
- TYPED_ARRAYS.Int8Array = Int8Array;
77
- TYPED_ARRAYS.Uint16Array = Uint16Array;
78
- TYPED_ARRAYS.Int16Array = Int16Array;
79
- TYPED_ARRAYS.Uint32Array = Uint32Array;
80
- TYPED_ARRAYS.Int32Array = Int32Array;
81
- TYPED_ARRAYS.Uint8ClampedArray = Uint8ClampedArray;
82
-
83
- try {
84
- TYPED_ARRAYS.BigInt64Array = BigInt64Array;
85
- TYPED_ARRAYS.BigUint64Array = BigUint64Array;
86
- } catch (_unused) {// ignore
87
- }
88
-
89
- function newTypedArray(type) {
90
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
91
- args[_key - 1] = arguments[_key];
92
- }
93
-
94
- return _construct(TYPED_ARRAYS[type] || Float64Array, args);
95
- }
96
- function newTypedArrayFrom(type) {
97
- var _ref;
98
-
99
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
100
- args[_key2 - 1] = arguments[_key2];
101
- }
102
-
103
- return (_ref = TYPED_ARRAYS[type] || Float64Array).from.apply(_ref, args);
104
- } // ----------------------------------------------------------------------------
105
- // capitilize provided string
106
- // ----------------------------------------------------------------------------
107
-
108
- function capitalize(str) {
109
- return str.charAt(0).toUpperCase() + str.slice(1);
110
- }
111
- function _capitalize(str) {
112
- return capitalize(str[0] === '_' ? str.slice(1) : str);
113
- }
114
- function uncapitalize(str) {
115
- return str.charAt(0).toLowerCase() + str.slice(1);
116
- } // ----------------------------------------------------------------------------
117
- // Convert byte size into a well formatted string
118
- // ----------------------------------------------------------------------------
119
-
120
- function formatBytesToProperUnit(size) {
121
- var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
122
- var chunkSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
123
- var units = ['TB', 'GB', 'MB', 'KB'];
124
- var value = Number(size);
125
- var currentUnit = 'B';
126
-
127
- while (value > chunkSize) {
128
- value /= chunkSize;
129
- currentUnit = units.pop();
130
- }
131
-
132
- return "".concat(value.toFixed(precision), " ").concat(currentUnit);
133
- } // ----------------------------------------------------------------------------
134
- // Convert thousand number with proper separator
135
- // ----------------------------------------------------------------------------
136
-
137
- function formatNumbersWithThousandSeparator(n) {
138
- var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ' ';
139
- var sections = [];
140
- var size = n;
141
-
142
- while (size > 1000) {
143
- sections.push("000".concat(size % 1000).slice(-3));
144
- size = Math.floor(size / 1000);
145
- }
146
-
147
- if (size > 0) {
148
- sections.push(size);
149
- }
150
-
151
- sections.reverse();
152
- return sections.join(separator);
153
- } // ----------------------------------------------------------------------------
154
- // Array helper
155
- // ----------------------------------------------------------------------------
156
-
157
- function safeArrays(model) {
158
- Object.keys(model).forEach(function (key) {
159
- if (Array.isArray(model[key])) {
160
- model[key] = [].concat(model[key]);
161
- }
162
- });
163
- } // ----------------------------------------------------------------------------
164
- // shallow equals
165
- // ----------------------------------------------------------------------------
166
-
167
-
168
- function shallowEquals(a, b) {
169
- if (a === b) {
170
- return true;
171
- }
172
-
173
- if (Array.isArray(a) && Array.isArray(b)) {
174
- if (a.length !== b.length) {
175
- return false;
176
- }
177
-
178
- for (var i = 0; i < a.length; i++) {
179
- if (a[i] !== b[i]) {
180
- return false;
181
- }
182
- }
183
-
184
- return true;
185
- }
186
-
187
- return false;
188
- } // ----------------------------------------------------------------------------
189
-
190
-
191
- function enumToString(e, value) {
192
- return Object.keys(e).find(function (key) {
193
- return e[key] === value;
194
- });
195
- }
196
-
197
- function getStateArrayMapFunc(item) {
198
- if (item && item.isA) {
199
- return item.getState();
200
- }
201
-
202
- return item;
203
- } // ----------------------------------------------------------------------------
204
- // setImmediate
205
- // ----------------------------------------------------------------------------
206
-
207
-
208
- function setImmediateVTK(fn) {
209
- setTimeout(fn, 0);
210
- } // ----------------------------------------------------------------------------
211
- // measurePromiseExecution
212
- //
213
- // Measures the time it takes for a promise to finish from
214
- // the time this function is invoked.
215
- // The callback receives the time it took for the promise to resolve or reject.
216
- // ----------------------------------------------------------------------------
217
-
218
- function measurePromiseExecution(promise, callback) {
219
- var start = performance.now();
220
- promise.finally(function () {
221
- var delta = performance.now() - start;
222
- callback(delta);
223
- });
224
- } // ----------------------------------------------------------------------------
225
- // vtkObject: modified(), onModified(callback), delete()
226
- // ----------------------------------------------------------------------------
227
-
228
- function obj() {
229
- var publicAPI = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
230
- var model = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
231
- // Ensure each instance as a unique ref of array
232
- safeArrays(model);
233
- var callbacks = [];
234
-
235
- if (!Number.isInteger(model.mtime)) {
236
- model.mtime = ++globalMTime;
237
- }
238
-
239
- if (!('classHierarchy' in model)) {
240
- model.classHierarchy = new ClassHierarchy('vtkObject');
241
- } else if (!(model.classHierarchy instanceof ClassHierarchy)) {
242
- var hierarchy = new ClassHierarchy();
243
-
244
- for (var i = 0; i < model.classHierarchy.length; i++) {
245
- hierarchy.push(model.classHierarchy[i]);
246
- }
247
-
248
- model.classHierarchy = hierarchy;
249
- }
250
-
251
- function off(index) {
252
- callbacks[index] = null;
253
- }
254
-
255
- function on(index) {
256
- function unsubscribe() {
257
- off(index);
258
- }
259
-
260
- return Object.freeze({
261
- unsubscribe: unsubscribe
262
- });
263
- }
264
-
265
- publicAPI.isDeleted = function () {
266
- return !!model.deleted;
267
- };
268
-
269
- publicAPI.modified = function (otherMTime) {
270
- if (model.deleted) {
271
- vtkErrorMacro('instance deleted - cannot call any method');
272
- return;
273
- }
274
-
275
- if (otherMTime && otherMTime < publicAPI.getMTime()) {
276
- return;
277
- }
278
-
279
- model.mtime = ++globalMTime;
280
- callbacks.forEach(function (callback) {
281
- return callback && callback(publicAPI);
282
- });
283
- };
284
-
285
- publicAPI.onModified = function (callback) {
286
- if (model.deleted) {
287
- vtkErrorMacro('instance deleted - cannot call any method');
288
- return null;
289
- }
290
-
291
- var index = callbacks.length;
292
- callbacks.push(callback);
293
- return on(index);
294
- };
295
-
296
- publicAPI.getMTime = function () {
297
- return model.mtime;
298
- };
299
-
300
- publicAPI.isA = function (className) {
301
- var count = model.classHierarchy.length; // we go backwards as that is more likely for
302
- // early termination
303
-
304
- while (count--) {
305
- if (model.classHierarchy[count] === className) {
306
- return true;
307
- }
308
- }
309
-
310
- return false;
311
- };
312
-
313
- publicAPI.getClassName = function () {
314
- var depth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
315
- return model.classHierarchy[model.classHierarchy.length - 1 - depth];
316
- };
317
-
318
- publicAPI.set = function () {
319
- var map = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
320
- var noWarning = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
321
- var noFunction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
322
- var ret = false;
323
- Object.keys(map).forEach(function (name) {
324
- var fn = noFunction ? null : publicAPI["set".concat(capitalize(name))];
325
-
326
- if (fn && Array.isArray(map[name]) && fn.length > 1) {
327
- ret = fn.apply(void 0, _toConsumableArray(map[name])) || ret;
328
- } else if (fn) {
329
- ret = fn(map[name]) || ret;
330
- } else {
331
- // Set data on model directly
332
- if (['mtime'].indexOf(name) === -1 && !noWarning) {
333
- vtkWarningMacro("Warning: Set value to model directly ".concat(name, ", ").concat(map[name]));
334
- }
335
-
336
- ret = model[name] !== map[name] || ret;
337
- model[name] = map[name];
338
- }
339
- });
340
- return ret;
341
- };
342
-
343
- publicAPI.get = function () {
344
- for (var _len3 = arguments.length, list = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
345
- list[_key3] = arguments[_key3];
346
- }
347
-
348
- if (!list.length) {
349
- return model;
350
- }
351
-
352
- var subset = {};
353
- list.forEach(function (name) {
354
- subset[name] = model[name];
355
- });
356
- return subset;
357
- };
358
-
359
- publicAPI.getReferenceByName = function (val) {
360
- return model[val];
361
- };
362
-
363
- publicAPI.delete = function () {
364
- Object.keys(model).forEach(function (field) {
365
- return delete model[field];
366
- });
367
- callbacks.forEach(function (el, index) {
368
- return off(index);
369
- }); // Flag the instance being deleted
370
-
371
- model.deleted = true;
372
- }; // Add serialization support
373
-
374
-
375
- publicAPI.getState = function () {
376
- if (model.deleted) {
377
- return null;
378
- }
379
-
380
- var jsonArchive = _objectSpread(_objectSpread({}, model), {}, {
381
- vtkClass: publicAPI.getClassName()
382
- }); // Convert every vtkObject to its serializable form
383
-
384
-
385
- Object.keys(jsonArchive).forEach(function (keyName) {
386
- if (jsonArchive[keyName] === null || jsonArchive[keyName] === undefined || keyName[0] === '_' // protected members start with _
387
- ) {
388
- delete jsonArchive[keyName];
389
- } else if (jsonArchive[keyName].isA) {
390
- jsonArchive[keyName] = jsonArchive[keyName].getState();
391
- } else if (Array.isArray(jsonArchive[keyName])) {
392
- jsonArchive[keyName] = jsonArchive[keyName].map(getStateArrayMapFunc);
393
- }
394
- }); // Sort resulting object by key name
395
-
396
- var sortedObj = {};
397
- Object.keys(jsonArchive).sort().forEach(function (name) {
398
- sortedObj[name] = jsonArchive[name];
399
- }); // Remove mtime
400
-
401
- if (sortedObj.mtime) {
402
- delete sortedObj.mtime;
403
- }
404
-
405
- return sortedObj;
406
- }; // Add shallowCopy(otherInstance) support
407
-
408
-
409
- publicAPI.shallowCopy = function (other) {
410
- var debug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
411
-
412
- if (other.getClassName() !== publicAPI.getClassName()) {
413
- throw new Error("Cannot ShallowCopy ".concat(other.getClassName(), " into ").concat(publicAPI.getClassName()));
414
- }
415
-
416
- var otherModel = other.get();
417
- var keyList = Object.keys(model).sort();
418
- var otherKeyList = Object.keys(otherModel).sort();
419
- otherKeyList.forEach(function (key) {
420
- var keyIdx = keyList.indexOf(key);
421
-
422
- if (keyIdx === -1) {
423
- if (debug) {
424
- vtkDebugMacro("add ".concat(key, " in shallowCopy"));
425
- }
426
- } else {
427
- keyList.splice(keyIdx, 1);
428
- }
429
-
430
- model[key] = otherModel[key];
431
- });
432
-
433
- if (keyList.length && debug) {
434
- vtkDebugMacro("Untouched keys: ".concat(keyList.join(', ')));
435
- }
436
-
437
- publicAPI.modified();
438
- }; // This function will get called when one invoke JSON.stringify(vtkObject)
439
- // JSON.stringify will only stringify the return value of this function
440
-
441
-
442
- publicAPI.toJSON = function vtkObjToJSON() {
443
- return publicAPI.getState();
444
- }; // Allow usage as decorator
445
-
446
-
447
- return publicAPI;
448
- } // ----------------------------------------------------------------------------
449
- // getXXX: add getters
450
- // ----------------------------------------------------------------------------
451
-
452
- var objectGetterMap = {
453
- object: function object(publicAPI, model, field) {
454
- return function getter() {
455
- return _objectSpread({}, model[field.name]);
456
- };
457
- }
458
- };
459
- function get(publicAPI, model, fieldNames) {
460
- fieldNames.forEach(function (field) {
461
- if (_typeof(field) === 'object') {
462
- var getter = objectGetterMap[field.type];
463
-
464
- if (getter) {
465
- publicAPI["get".concat(_capitalize(field.name))] = getter(publicAPI, model, field);
466
- } else {
467
- publicAPI["get".concat(_capitalize(field.name))] = function () {
468
- return model[field.name];
469
- };
470
- }
471
- } else {
472
- publicAPI["get".concat(_capitalize(field))] = function () {
473
- return model[field];
474
- };
475
- }
476
- });
477
- } // ----------------------------------------------------------------------------
478
- // setXXX: add setters
479
- // ----------------------------------------------------------------------------
480
-
481
- var objectSetterMap = {
482
- enum: function _enum(publicAPI, model, field) {
483
- var onChanged = "_on".concat(_capitalize(field.name), "Changed");
484
- return function (value) {
485
- if (typeof value === 'string') {
486
- if (field.enum[value] !== undefined) {
487
- if (model[field.name] !== field.enum[value]) {
488
- model[field.name] = field.enum[value];
489
- publicAPI.modified();
490
- return true;
491
- }
492
-
493
- return false;
494
- }
495
-
496
- vtkErrorMacro("Set Enum with invalid argument ".concat(field, ", ").concat(value));
497
- throw new RangeError('Set Enum with invalid string argument');
498
- }
499
-
500
- if (typeof value === 'number') {
501
- if (model[field.name] !== value) {
502
- if (Object.keys(field.enum).map(function (key) {
503
- return field.enum[key];
504
- }).indexOf(value) !== -1) {
505
- var _model$onChanged;
506
-
507
- var previousValue = model[field.name];
508
- model[field.name] = value;
509
- (_model$onChanged = model[onChanged]) === null || _model$onChanged === void 0 ? void 0 : _model$onChanged.call(model, publicAPI, model, value, previousValue);
510
- publicAPI.modified();
511
- return true;
512
- }
513
-
514
- vtkErrorMacro("Set Enum outside numeric range ".concat(field, ", ").concat(value));
515
- throw new RangeError('Set Enum outside numeric range');
516
- }
517
-
518
- return false;
519
- }
520
-
521
- vtkErrorMacro("Set Enum with invalid argument (String/Number) ".concat(field, ", ").concat(value));
522
- throw new TypeError('Set Enum with invalid argument (String/Number)');
523
- };
524
- },
525
- object: function object(publicAPI, model, field) {
526
- var onChanged = "_on".concat(_capitalize(field.name), "Changed");
527
- return function (value) {
528
- if (!DeepEqual(model[field.name], value)) {
529
- var _model$onChanged2;
530
-
531
- var previousValue = model[field.name];
532
- model[field.name] = value;
533
- (_model$onChanged2 = model[onChanged]) === null || _model$onChanged2 === void 0 ? void 0 : _model$onChanged2.call(model, publicAPI, model, value, previousValue);
534
- publicAPI.modified();
535
- return true;
536
- }
537
-
538
- return false;
539
- };
540
- }
541
- };
542
-
543
- function findSetter(field) {
544
- if (_typeof(field) === 'object') {
545
- var fn = objectSetterMap[field.type];
546
-
547
- if (fn) {
548
- return function (publicAPI, model) {
549
- return fn(publicAPI, model, field);
550
- };
551
- }
552
-
553
- vtkErrorMacro("No setter for field ".concat(field));
554
- throw new TypeError('No setter for field');
555
- }
556
-
557
- return function getSetter(publicAPI, model) {
558
- var onChanged = "_on".concat(_capitalize(field), "Changed");
559
- return function setter(value) {
560
- if (model.deleted) {
561
- vtkErrorMacro('instance deleted - cannot call any method');
562
- return false;
563
- }
564
-
565
- if (model[field] !== value) {
566
- var _model$onChanged3;
567
-
568
- var previousValue = model[field.name];
569
- model[field] = value;
570
- (_model$onChanged3 = model[onChanged]) === null || _model$onChanged3 === void 0 ? void 0 : _model$onChanged3.call(model, publicAPI, model, value, previousValue);
571
- publicAPI.modified();
572
- return true;
573
- }
574
-
575
- return false;
576
- };
577
- };
578
- }
579
-
580
- function set(publicAPI, model, fields) {
581
- fields.forEach(function (field) {
582
- if (_typeof(field) === 'object') {
583
- publicAPI["set".concat(_capitalize(field.name))] = findSetter(field)(publicAPI, model);
584
- } else {
585
- publicAPI["set".concat(_capitalize(field))] = findSetter(field)(publicAPI, model);
586
- }
587
- });
588
- } // ----------------------------------------------------------------------------
589
- // set/get XXX: add both setters and getters
590
- // ----------------------------------------------------------------------------
591
-
592
- function setGet(publicAPI, model, fieldNames) {
593
- get(publicAPI, model, fieldNames);
594
- set(publicAPI, model, fieldNames);
595
- } // ----------------------------------------------------------------------------
596
- // getXXX: add getters for object of type array with copy to be safe
597
- // getXXXByReference: add getters for object of type array without copy
598
- // ----------------------------------------------------------------------------
599
-
600
- function getArray(publicAPI, model, fieldNames) {
601
- fieldNames.forEach(function (field) {
602
- publicAPI["get".concat(_capitalize(field))] = function () {
603
- return model[field] ? Array.from(model[field]) : model[field];
604
- };
605
-
606
- publicAPI["get".concat(_capitalize(field), "ByReference")] = function () {
607
- return model[field];
608
- };
609
- });
610
- } // ----------------------------------------------------------------------------
611
- // setXXX: add setter for object of type array
612
- // if 'defaultVal' is supplied, shorter arrays will be padded to 'size' with 'defaultVal'
613
- // set...From: fast path to copy the content of an array to the current one without call to modified.
614
- // ----------------------------------------------------------------------------
615
-
616
- function setArray(publicAPI, model, fieldNames, size) {
617
- var defaultVal = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
618
- fieldNames.forEach(function (field) {
619
- if (model[field] && size && model[field].length !== size) {
620
- throw new RangeError("Invalid initial number of values for array (".concat(field, ")"));
621
- }
622
-
623
- var onChanged = "_on".concat(_capitalize(field), "Changed");
624
-
625
- publicAPI["set".concat(_capitalize(field))] = function () {
626
- if (model.deleted) {
627
- vtkErrorMacro('instance deleted - cannot call any method');
628
- return false;
629
- }
630
-
631
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
632
- args[_key4] = arguments[_key4];
633
- }
634
-
635
- var array = args;
636
- var changeDetected;
637
- var needCopy = false; // allow null or an array to be passed as a single arg.
638
-
639
- if (array.length === 1 && (array[0] == null || array[0].length >= 0)) {
640
- /* eslint-disable prefer-destructuring */
641
- array = array[0];
642
- /* eslint-enable prefer-destructuring */
643
-
644
- needCopy = true;
645
- }
646
-
647
- if (array == null) {
648
- changeDetected = model[field] !== array;
649
- } else {
650
- if (size && array.length !== size) {
651
- if (array.length < size && defaultVal !== undefined) {
652
- array = Array.from(array);
653
- needCopy = false;
654
-
655
- while (array.length < size) {
656
- array.push(defaultVal);
657
- }
658
- } else {
659
- throw new RangeError("Invalid number of values for array setter (".concat(field, ")"));
660
- }
661
- }
662
-
663
- changeDetected = model[field] == null || model[field].length !== array.length;
664
-
665
- for (var i = 0; !changeDetected && i < array.length; ++i) {
666
- changeDetected = model[field][i] !== array[i];
667
- }
668
-
669
- if (changeDetected && needCopy) {
670
- array = Array.from(array);
671
- }
672
- }
673
-
674
- if (changeDetected) {
675
- var _model$onChanged4;
676
-
677
- var previousValue = model[field.name];
678
- model[field] = array;
679
- (_model$onChanged4 = model[onChanged]) === null || _model$onChanged4 === void 0 ? void 0 : _model$onChanged4.call(model, publicAPI, model, array, previousValue);
680
- publicAPI.modified();
681
- }
682
-
683
- return changeDetected;
684
- };
685
-
686
- publicAPI["set".concat(_capitalize(field), "From")] = function (otherArray) {
687
- var target = model[field];
688
- otherArray.forEach(function (v, i) {
689
- target[i] = v;
690
- });
691
- };
692
- });
693
- } // ----------------------------------------------------------------------------
694
- // set/get XXX: add setter and getter for object of type array
695
- // ----------------------------------------------------------------------------
696
-
697
- function setGetArray(publicAPI, model, fieldNames, size) {
698
- var defaultVal = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
699
- getArray(publicAPI, model, fieldNames);
700
- setArray(publicAPI, model, fieldNames, size, defaultVal);
701
- }
702
- function moveToProtected(publicAPI, model, fieldNames) {
703
- for (var i = 0; i < fieldNames.length; i++) {
704
- var fieldName = fieldNames[i];
705
-
706
- if (model[fieldName] !== undefined) {
707
- model["_".concat(fieldName)] = model[fieldName];
708
- delete model[fieldName];
709
- }
710
- }
711
- } // ----------------------------------------------------------------------------
712
- // vtkAlgorithm: setInputData(), setInputConnection(), getOutputData(), getOutputPort()
713
- // ----------------------------------------------------------------------------
714
-
715
- function algo(publicAPI, model, numberOfInputs, numberOfOutputs) {
716
- if (model.inputData) {
717
- model.inputData = model.inputData.map(vtk);
718
- } else {
719
- model.inputData = [];
720
- }
721
-
722
- if (model.inputConnection) {
723
- model.inputConnection = model.inputConnection.map(vtk);
724
- } else {
725
- model.inputConnection = [];
726
- }
727
-
728
- if (model.output) {
729
- model.output = model.output.map(vtk);
730
- } else {
731
- model.output = [];
732
- }
733
-
734
- if (model.inputArrayToProcess) {
735
- model.inputArrayToProcess = model.inputArrayToProcess.map(vtk);
736
- } else {
737
- model.inputArrayToProcess = [];
738
- } // Cache the argument for later manipulation
739
-
740
-
741
- model.numberOfInputs = numberOfInputs; // Methods
742
-
743
- function setInputData(dataset) {
744
- var port = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
745
-
746
- if (model.deleted) {
747
- vtkErrorMacro('instance deleted - cannot call any method');
748
- return;
749
- }
750
-
751
- if (port >= model.numberOfInputs) {
752
- vtkErrorMacro("algorithm ".concat(publicAPI.getClassName(), " only has ").concat(model.numberOfInputs, " input ports. To add more input ports, use addInputData()"));
753
- return;
754
- }
755
-
756
- if (model.inputData[port] !== dataset || model.inputConnection[port]) {
757
- model.inputData[port] = dataset;
758
- model.inputConnection[port] = null;
759
-
760
- if (publicAPI.modified) {
761
- publicAPI.modified();
762
- }
763
- }
764
- }
765
-
766
- function getInputData() {
767
- var port = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
768
-
769
- if (model.inputConnection[port]) {
770
- model.inputData[port] = model.inputConnection[port]();
771
- }
772
-
773
- return model.inputData[port];
774
- }
775
-
776
- function setInputConnection(outputPort) {
777
- var port = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
778
-
779
- if (model.deleted) {
780
- vtkErrorMacro('instance deleted - cannot call any method');
781
- return;
782
- }
783
-
784
- if (port >= model.numberOfInputs) {
785
- var msg = "algorithm ".concat(publicAPI.getClassName(), " only has ");
786
- msg += "".concat(model.numberOfInputs);
787
- msg += ' input ports. To add more input ports, use addInputConnection()';
788
- vtkErrorMacro(msg);
789
- return;
790
- }
791
-
792
- model.inputData[port] = null;
793
- model.inputConnection[port] = outputPort;
794
- }
795
-
796
- function getInputConnection() {
797
- var port = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
798
- return model.inputConnection[port];
799
- }
800
-
801
- function getPortToFill() {
802
- var portToFill = model.numberOfInputs;
803
-
804
- while (portToFill && !model.inputData[portToFill - 1] && !model.inputConnection[portToFill - 1]) {
805
- portToFill--;
806
- }
807
-
808
- if (portToFill === model.numberOfInputs) {
809
- model.numberOfInputs++;
810
- }
811
-
812
- return portToFill;
813
- }
814
-
815
- function addInputConnection(outputPort) {
816
- if (model.deleted) {
817
- vtkErrorMacro('instance deleted - cannot call any method');
818
- return;
819
- }
820
-
821
- setInputConnection(outputPort, getPortToFill());
822
- }
823
-
824
- function addInputData(dataset) {
825
- if (model.deleted) {
826
- vtkErrorMacro('instance deleted - cannot call any method');
827
- return;
828
- }
829
-
830
- setInputData(dataset, getPortToFill());
831
- }
832
-
833
- function getOutputData() {
834
- var port = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
835
-
836
- if (model.deleted) {
837
- vtkErrorMacro('instance deleted - cannot call any method');
838
- return null;
839
- }
840
-
841
- if (publicAPI.shouldUpdate()) {
842
- publicAPI.update();
843
- }
844
-
845
- return model.output[port];
846
- }
847
-
848
- publicAPI.shouldUpdate = function () {
849
- var localMTime = publicAPI.getMTime();
850
- var minOutputMTime = Infinity;
851
- var count = numberOfOutputs;
852
-
853
- while (count--) {
854
- if (!model.output[count] || model.output[count].isDeleted()) {
855
- return true;
856
- }
857
-
858
- var mt = model.output[count].getMTime();
859
-
860
- if (mt < localMTime) {
861
- return true;
862
- }
863
-
864
- if (mt < minOutputMTime) {
865
- minOutputMTime = mt;
866
- }
867
- }
868
-
869
- count = model.numberOfInputs;
870
-
871
- while (count--) {
872
- var _model$inputConnectio, _publicAPI$getInputDa;
873
-
874
- if ((_model$inputConnectio = model.inputConnection[count]) !== null && _model$inputConnectio !== void 0 && _model$inputConnectio.filter.shouldUpdate() || ((_publicAPI$getInputDa = publicAPI.getInputData(count)) === null || _publicAPI$getInputDa === void 0 ? void 0 : _publicAPI$getInputDa.getMTime()) > minOutputMTime) {
875
- return true;
876
- }
877
- }
878
-
879
- return false;
880
- };
881
-
882
- function getOutputPort() {
883
- var port = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
884
-
885
- var outputPortAccess = function outputPortAccess() {
886
- return getOutputData(port);
887
- }; // Add reference to filter
888
-
889
-
890
- outputPortAccess.filter = publicAPI;
891
- return outputPortAccess;
892
- } // Handle input if needed
893
-
894
-
895
- if (model.numberOfInputs) {
896
- // Reserve inputs
897
- var count = model.numberOfInputs;
898
-
899
- while (count--) {
900
- model.inputData.push(null);
901
- model.inputConnection.push(null);
902
- } // Expose public methods
903
-
904
-
905
- publicAPI.setInputData = setInputData;
906
- publicAPI.setInputConnection = setInputConnection;
907
- publicAPI.addInputData = addInputData;
908
- publicAPI.addInputConnection = addInputConnection;
909
- publicAPI.getInputData = getInputData;
910
- publicAPI.getInputConnection = getInputConnection;
911
- }
912
-
913
- if (numberOfOutputs) {
914
- publicAPI.getOutputData = getOutputData;
915
- publicAPI.getOutputPort = getOutputPort;
916
- }
917
-
918
- publicAPI.update = function () {
919
- var ins = [];
920
-
921
- if (model.numberOfInputs) {
922
- var _count = 0;
923
-
924
- while (_count < model.numberOfInputs) {
925
- ins[_count] = publicAPI.getInputData(_count);
926
- _count++;
927
- }
928
- }
929
-
930
- if (publicAPI.shouldUpdate() && publicAPI.requestData) {
931
- publicAPI.requestData(ins, model.output);
932
- }
933
- };
934
-
935
- publicAPI.getNumberOfInputPorts = function () {
936
- return model.numberOfInputs;
937
- };
938
-
939
- publicAPI.getNumberOfOutputPorts = function () {
940
- return numberOfOutputs || model.output.length;
941
- };
942
-
943
- publicAPI.getInputArrayToProcess = function (inputPort) {
944
- var arrayDesc = model.inputArrayToProcess[inputPort];
945
- var ds = model.inputData[inputPort];
946
-
947
- if (arrayDesc && ds) {
948
- return ds["get".concat(arrayDesc.fieldAssociation)]().getArray(arrayDesc.arrayName);
949
- }
950
-
951
- return null;
952
- };
953
-
954
- publicAPI.setInputArrayToProcess = function (inputPort, arrayName, fieldAssociation) {
955
- var attributeType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'Scalars';
956
-
957
- while (model.inputArrayToProcess.length < inputPort) {
958
- model.inputArrayToProcess.push(null);
959
- }
960
-
961
- model.inputArrayToProcess[inputPort] = {
962
- arrayName: arrayName,
963
- fieldAssociation: fieldAssociation,
964
- attributeType: attributeType
965
- };
966
- };
967
- } // ----------------------------------------------------------------------------
968
- // Event handling: onXXX(callback), invokeXXX(args...)
969
- // ----------------------------------------------------------------------------
970
-
971
- var EVENT_ABORT = Symbol('Event abort');
972
- function event(publicAPI, model, eventName) {
973
- var callbacks = [];
974
- var previousDelete = publicAPI.delete;
975
- var curCallbackID = 1;
976
-
977
- function off(callbackID) {
978
- for (var i = 0; i < callbacks.length; ++i) {
979
- var _callbacks$i = _slicedToArray(callbacks[i], 1),
980
- cbID = _callbacks$i[0];
981
-
982
- if (cbID === callbackID) {
983
- callbacks.splice(i, 1);
984
- return;
985
- }
986
- }
987
- }
988
-
989
- function on(callbackID) {
990
- function unsubscribe() {
991
- off(callbackID);
992
- }
993
-
994
- return Object.freeze({
995
- unsubscribe: unsubscribe
996
- });
997
- }
998
-
999
- function invoke() {
1000
- var _arguments = arguments;
1001
-
1002
- if (model.deleted) {
1003
- vtkErrorMacro('instance deleted - cannot call any method');
1004
- return;
1005
- }
1006
- /* eslint-disable prefer-rest-params */
1007
- // Go through a copy of the callbacks array in case new callbacks
1008
- // get prepended within previous callbacks
1009
-
1010
-
1011
- var currentCallbacks = callbacks.slice();
1012
-
1013
- var _loop = function _loop(index) {
1014
- var _currentCallbacks$ind = _slicedToArray(currentCallbacks[index], 3),
1015
- cb = _currentCallbacks$ind[1],
1016
- priority = _currentCallbacks$ind[2];
1017
-
1018
- if (!cb) {
1019
- return "continue"; // eslint-disable-line
1020
- }
1021
-
1022
- if (priority < 0) {
1023
- setTimeout(function () {
1024
- return cb.apply(publicAPI, _arguments);
1025
- }, 1 - priority);
1026
- } else {
1027
- // Abort only if the callback explicitly returns false
1028
- var continueNext = cb.apply(publicAPI, _arguments);
1029
-
1030
- if (continueNext === EVENT_ABORT) {
1031
- return "break";
1032
- }
1033
- }
1034
- };
1035
-
1036
- for (var index = 0; index < currentCallbacks.length; ++index) {
1037
- var _ret = _loop(index);
1038
-
1039
- if (_ret === "continue") continue;
1040
- if (_ret === "break") break;
1041
- }
1042
- /* eslint-enable prefer-rest-params */
1043
-
1044
- }
1045
-
1046
- publicAPI["invoke".concat(_capitalize(eventName))] = invoke;
1047
-
1048
- publicAPI["on".concat(_capitalize(eventName))] = function (callback) {
1049
- var priority = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.0;
1050
-
1051
- if (!callback.apply) {
1052
- console.error("Invalid callback for event ".concat(eventName));
1053
- return null;
1054
- }
1055
-
1056
- if (model.deleted) {
1057
- vtkErrorMacro('instance deleted - cannot call any method');
1058
- return null;
1059
- }
1060
-
1061
- var callbackID = curCallbackID++;
1062
- callbacks.push([callbackID, callback, priority]);
1063
- callbacks.sort(function (cb1, cb2) {
1064
- return cb2[2] - cb1[2];
1065
- });
1066
- return on(callbackID);
1067
- };
1068
-
1069
- publicAPI.delete = function () {
1070
- previousDelete();
1071
- callbacks.forEach(function (_ref2) {
1072
- var _ref3 = _slicedToArray(_ref2, 1),
1073
- cbID = _ref3[0];
1074
-
1075
- return off(cbID);
1076
- });
1077
- };
1078
- } // ----------------------------------------------------------------------------
1079
- // newInstance
1080
- // ----------------------------------------------------------------------------
1081
-
1082
- function newInstance(extend, className) {
1083
- var constructor = function constructor() {
1084
- var initialValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1085
- var model = {};
1086
- var publicAPI = {};
1087
- extend(publicAPI, model, initialValues);
1088
- return Object.freeze(publicAPI);
1089
- }; // Register constructor to factory
1090
-
1091
-
1092
- if (className) {
1093
- vtk.register(className, constructor);
1094
- }
1095
-
1096
- return constructor;
1097
- } // ----------------------------------------------------------------------------
1098
- // Chain function calls
1099
- // ----------------------------------------------------------------------------
1100
-
1101
- function chain() {
1102
- for (var _len5 = arguments.length, fn = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
1103
- fn[_key5] = arguments[_key5];
1104
- }
1105
-
1106
- return function () {
1107
- for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
1108
- args[_key6] = arguments[_key6];
1109
- }
1110
-
1111
- return fn.filter(function (i) {
1112
- return !!i;
1113
- }).map(function (i) {
1114
- return i.apply(void 0, args);
1115
- });
1116
- };
1117
- } // ----------------------------------------------------------------------------
1118
- // Some utility methods for vtk objects
1119
- // ----------------------------------------------------------------------------
1120
-
1121
- function isVtkObject(instance) {
1122
- return instance && instance.isA && instance.isA('vtkObject');
1123
- }
1124
- function traverseInstanceTree(instance, extractFunction) {
1125
- var accumulator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
1126
- var visitedInstances = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
1127
-
1128
- if (isVtkObject(instance)) {
1129
- if (visitedInstances.indexOf(instance) >= 0) {
1130
- // avoid cycles
1131
- return accumulator;
1132
- }
1133
-
1134
- visitedInstances.push(instance);
1135
- var result = extractFunction(instance);
1136
-
1137
- if (result !== undefined) {
1138
- accumulator.push(result);
1139
- } // Now go through this instance's model
1140
-
1141
-
1142
- var model = instance.get();
1143
- Object.keys(model).forEach(function (key) {
1144
- var modelObj = model[key];
1145
-
1146
- if (Array.isArray(modelObj)) {
1147
- modelObj.forEach(function (subObj) {
1148
- traverseInstanceTree(subObj, extractFunction, accumulator, visitedInstances);
1149
- });
1150
- } else {
1151
- traverseInstanceTree(modelObj, extractFunction, accumulator, visitedInstances);
1152
- }
1153
- });
1154
- }
1155
-
1156
- return accumulator;
1157
- } // ----------------------------------------------------------------------------
1158
- // Returns a function, that, as long as it continues to be invoked, will not
1159
- // be triggered. The function will be called after it stops being called for
1160
- // N milliseconds. If `immediate` is passed, trigger the function on the
1161
- // leading edge, instead of the trailing.
1162
-
1163
- function debounce(func, wait, immediate) {
1164
- var _this = this;
1165
-
1166
- var timeout;
1167
-
1168
- var debounced = function debounced() {
1169
- for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
1170
- args[_key7] = arguments[_key7];
1171
- }
1172
-
1173
- var context = _this;
1174
-
1175
- var later = function later() {
1176
- timeout = null;
1177
-
1178
- if (!immediate) {
1179
- func.apply(context, args);
1180
- }
1181
- };
1182
-
1183
- var callNow = immediate && !timeout;
1184
- clearTimeout(timeout);
1185
- timeout = setTimeout(later, wait);
1186
-
1187
- if (callNow) {
1188
- func.apply(context, args);
1189
- }
1190
- };
1191
-
1192
- debounced.cancel = function () {
1193
- return clearTimeout(timeout);
1194
- };
1195
-
1196
- return debounced;
1197
- } // ----------------------------------------------------------------------------
1198
- // Creates a throttled function that only invokes `func` at most once per
1199
- // every `wait` milliseconds.
1200
-
1201
- function throttle(callback, delay) {
1202
- var isThrottled = false;
1203
- var argsToUse = null;
1204
-
1205
- function next() {
1206
- isThrottled = false;
1207
-
1208
- if (argsToUse !== null) {
1209
- wrapper.apply(void 0, _toConsumableArray(argsToUse)); // eslint-disable-line
1210
-
1211
- argsToUse = null;
1212
- }
1213
- }
1214
-
1215
- function wrapper() {
1216
- for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
1217
- args[_key8] = arguments[_key8];
1218
- }
1219
-
1220
- if (isThrottled) {
1221
- argsToUse = args;
1222
- return;
1223
- }
1224
-
1225
- isThrottled = true;
1226
- callback.apply(void 0, args);
1227
- setTimeout(next, delay);
1228
- }
1229
-
1230
- return wrapper;
1231
- } // ----------------------------------------------------------------------------
1232
- // keystore(publicAPI, model, initialKeystore)
1233
- //
1234
- // - initialKeystore: Initial keystore. This can be either a Map or an
1235
- // object.
1236
- //
1237
- // Generated API
1238
- // setKey(key, value) : mixed (returns value)
1239
- // getKey(key) : mixed
1240
- // getAllKeys() : [mixed]
1241
- // deleteKey(key) : Boolean
1242
- // ----------------------------------------------------------------------------
1243
-
1244
- function keystore(publicAPI, model) {
1245
- var initialKeystore = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1246
- model.keystore = Object.assign(model.keystore || {}, initialKeystore);
1247
-
1248
- publicAPI.setKey = function (key, value) {
1249
- model.keystore[key] = value;
1250
- };
1251
-
1252
- publicAPI.getKey = function (key) {
1253
- return model.keystore[key];
1254
- };
1255
-
1256
- publicAPI.getAllKeys = function () {
1257
- return Object.keys(model.keystore);
1258
- };
1259
-
1260
- publicAPI.deleteKey = function (key) {
1261
- return delete model.keystore[key];
1262
- };
1263
-
1264
- publicAPI.clearKeystore = function () {
1265
- return publicAPI.getAllKeys().forEach(function (key) {
1266
- return delete model.keystore[key];
1267
- });
1268
- };
1269
- } // ----------------------------------------------------------------------------
1270
- // proxy(publicAPI, model, sectionName, propertyUI)
1271
- //
1272
- // - sectionName: Name of the section for UI
1273
- // - propertyUI: List of props with their UI description
1274
- //
1275
- // Generated API
1276
- // getProxyId() : String
1277
- // listProxyProperties() : [string]
1278
- // updateProxyProperty(name, prop)
1279
- // getProxySection() => List of properties for UI generation
1280
- // ----------------------------------------------------------------------------
1281
-
1282
- var nextProxyId = 1;
1283
- var ROOT_GROUP_NAME = '__root__';
1284
- function proxy(publicAPI, model) {
1285
- // Proxies are keystores
1286
- keystore(publicAPI, model);
1287
- var parentDelete = publicAPI.delete; // getProxyId
1288
-
1289
- model.proxyId = "".concat(nextProxyId++); // ui handling
1290
-
1291
- model.ui = JSON.parse(JSON.stringify(model.ui || [])); // deep copy
1292
-
1293
- get(publicAPI, model, ['proxyId', 'proxyGroup', 'proxyName']);
1294
- setGet(publicAPI, model, ['proxyManager']); // group properties
1295
-
1296
- var propertyMap = {};
1297
- var groupChildrenNames = {};
1298
-
1299
- function registerProperties(descriptionList, currentGroupName) {
1300
- if (!groupChildrenNames[currentGroupName]) {
1301
- groupChildrenNames[currentGroupName] = [];
1302
- }
1303
-
1304
- var childrenNames = groupChildrenNames[currentGroupName];
1305
-
1306
- for (var i = 0; i < descriptionList.length; i++) {
1307
- childrenNames.push(descriptionList[i].name);
1308
- propertyMap[descriptionList[i].name] = descriptionList[i];
1309
-
1310
- if (descriptionList[i].children && descriptionList[i].children.length) {
1311
- registerProperties(descriptionList[i].children, descriptionList[i].name);
1312
- }
1313
- }
1314
- }
1315
-
1316
- registerProperties(model.ui, ROOT_GROUP_NAME);
1317
-
1318
- publicAPI.updateUI = function (ui) {
1319
- model.ui = JSON.parse(JSON.stringify(ui || [])); // deep copy
1320
-
1321
- Object.keys(propertyMap).forEach(function (k) {
1322
- return delete propertyMap[k];
1323
- });
1324
- Object.keys(groupChildrenNames).forEach(function (k) {
1325
- return delete groupChildrenNames[k];
1326
- });
1327
- registerProperties(model.ui, ROOT_GROUP_NAME);
1328
- publicAPI.modified();
1329
- };
1330
-
1331
- function listProxyProperties() {
1332
- var gName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ROOT_GROUP_NAME;
1333
- return groupChildrenNames[gName];
1334
- }
1335
-
1336
- publicAPI.updateProxyProperty = function (propertyName, propUI) {
1337
- var prop = propertyMap[propertyName];
1338
-
1339
- if (prop) {
1340
- Object.assign(prop, propUI);
1341
- } else {
1342
- propertyMap[propertyName] = _objectSpread({}, propUI);
1343
- }
1344
- };
1345
-
1346
- publicAPI.activate = function () {
1347
- if (model.proxyManager) {
1348
- var setActiveMethod = "setActive".concat(_capitalize(publicAPI.getProxyGroup().slice(0, -1)));
1349
-
1350
- if (model.proxyManager[setActiveMethod]) {
1351
- model.proxyManager[setActiveMethod](publicAPI);
1352
- }
1353
- }
1354
- }; // property link
1355
-
1356
-
1357
- model.propertyLinkSubscribers = {};
1358
-
1359
- publicAPI.registerPropertyLinkForGC = function (otherLink, type) {
1360
- if (!(type in model.propertyLinkSubscribers)) {
1361
- model.propertyLinkSubscribers[type] = [];
1362
- }
1363
-
1364
- model.propertyLinkSubscribers[type].push(otherLink);
1365
- };
1366
-
1367
- publicAPI.gcPropertyLinks = function (type) {
1368
- var subscribers = model.propertyLinkSubscribers[type] || [];
1369
-
1370
- while (subscribers.length) {
1371
- subscribers.pop().unbind(publicAPI);
1372
- }
1373
- };
1374
-
1375
- model.propertyLinkMap = {};
1376
-
1377
- publicAPI.getPropertyLink = function (id) {
1378
- var persistent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1379
-
1380
- if (model.propertyLinkMap[id]) {
1381
- return model.propertyLinkMap[id];
1382
- }
1383
-
1384
- var value = null;
1385
- var links = [];
1386
- var count = 0;
1387
- var updateInProgress = false;
1388
-
1389
- function update(source) {
1390
- var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1391
-
1392
- if (updateInProgress) {
1393
- return null;
1394
- }
1395
-
1396
- var needUpdate = [];
1397
- var sourceLink = null;
1398
- count = links.length;
1399
-
1400
- while (count--) {
1401
- var link = links[count];
1402
-
1403
- if (link.instance === source) {
1404
- sourceLink = link;
1405
- } else {
1406
- needUpdate.push(link);
1407
- }
1408
- }
1409
-
1410
- if (!sourceLink) {
1411
- return null;
1412
- }
1413
-
1414
- var newValue = sourceLink.instance["get".concat(_capitalize(sourceLink.propertyName))]();
1415
-
1416
- if (!shallowEquals(newValue, value) || force) {
1417
- value = newValue;
1418
- updateInProgress = true;
1419
-
1420
- while (needUpdate.length) {
1421
- var linkToUpdate = needUpdate.pop();
1422
- linkToUpdate.instance.set(_defineProperty({}, linkToUpdate.propertyName, value));
1423
- }
1424
-
1425
- updateInProgress = false;
1426
- }
1427
-
1428
- if (model.propertyLinkMap[id].persistent) {
1429
- model.propertyLinkMap[id].value = newValue;
1430
- }
1431
-
1432
- return newValue;
1433
- }
1434
-
1435
- function unbind(instance, propertyName) {
1436
- var indexToDelete = [];
1437
- count = links.length;
1438
-
1439
- while (count--) {
1440
- var link = links[count];
1441
-
1442
- if (link.instance === instance && (link.propertyName === propertyName || propertyName === undefined)) {
1443
- link.subscription.unsubscribe();
1444
- indexToDelete.push(count);
1445
- }
1446
- }
1447
-
1448
- while (indexToDelete.length) {
1449
- links.splice(indexToDelete.pop(), 1);
1450
- }
1451
- }
1452
-
1453
- function bind(instance, propertyName) {
1454
- var updateMe = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1455
- var subscription = instance.onModified(update);
1456
- var other = links[0];
1457
- links.push({
1458
- instance: instance,
1459
- propertyName: propertyName,
1460
- subscription: subscription
1461
- });
1462
-
1463
- if (updateMe) {
1464
- if (model.propertyLinkMap[id].persistent && model.propertyLinkMap[id].value !== undefined) {
1465
- instance.set(_defineProperty({}, propertyName, model.propertyLinkMap[id].value));
1466
- } else if (other) {
1467
- update(other.instance, true);
1468
- }
1469
- }
1470
-
1471
- return {
1472
- unsubscribe: function unsubscribe() {
1473
- return unbind(instance, propertyName);
1474
- }
1475
- };
1476
- }
1477
-
1478
- function unsubscribe() {
1479
- while (links.length) {
1480
- links.pop().subscription.unsubscribe();
1481
- }
1482
- }
1483
-
1484
- var linkHandler = {
1485
- bind: bind,
1486
- unbind: unbind,
1487
- unsubscribe: unsubscribe,
1488
- persistent: persistent
1489
- };
1490
- model.propertyLinkMap[id] = linkHandler;
1491
- return linkHandler;
1492
- }; // extract values
1493
-
1494
-
1495
- function getProperties() {
1496
- var groupName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ROOT_GROUP_NAME;
1497
- var values = [];
1498
- var id = model.proxyId;
1499
- var propertyNames = listProxyProperties(groupName) || [];
1500
-
1501
- for (var i = 0; i < propertyNames.length; i++) {
1502
- var name = propertyNames[i];
1503
- var method = publicAPI["get".concat(_capitalize(name))];
1504
- var value = method ? method() : undefined;
1505
- var prop = {
1506
- id: id,
1507
- name: name,
1508
- value: value
1509
- };
1510
- var children = getProperties(name);
1511
-
1512
- if (children.length) {
1513
- prop.children = children;
1514
- }
1515
-
1516
- values.push(prop);
1517
- }
1518
-
1519
- return values;
1520
- }
1521
-
1522
- publicAPI.listPropertyNames = function () {
1523
- return getProperties().map(function (p) {
1524
- return p.name;
1525
- });
1526
- };
1527
-
1528
- publicAPI.getPropertyByName = function (name) {
1529
- return getProperties().find(function (p) {
1530
- return p.name === name;
1531
- });
1532
- };
1533
-
1534
- publicAPI.getPropertyDomainByName = function (name) {
1535
- return (propertyMap[name] || {}).domain;
1536
- }; // ui section
1537
-
1538
-
1539
- publicAPI.getProxySection = function () {
1540
- return {
1541
- id: model.proxyId,
1542
- name: model.proxyGroup,
1543
- ui: model.ui,
1544
- properties: getProperties()
1545
- };
1546
- }; // free resources
1547
-
1548
-
1549
- publicAPI.delete = function () {
1550
- var list = Object.keys(model.propertyLinkMap);
1551
- var count = list.length;
1552
-
1553
- while (count--) {
1554
- model.propertyLinkMap[list[count]].unsubscribe();
1555
- }
1556
-
1557
- Object.keys(model.propertyLinkSubscribers).forEach(publicAPI.gcPropertyLinks);
1558
- parentDelete();
1559
- }; // @todo fix infinite recursion due to active source
1560
-
1561
-
1562
- publicAPI.getState = function () {
1563
- return null;
1564
- };
1565
-
1566
- function registerLinks() {
1567
- // Allow dynamic registration of links at the application level
1568
- if (model.links) {
1569
- for (var i = 0; i < model.links.length; i++) {
1570
- var _model$links$i = model.links[i],
1571
- link = _model$links$i.link,
1572
- property = _model$links$i.property,
1573
- persistent = _model$links$i.persistent,
1574
- updateOnBind = _model$links$i.updateOnBind,
1575
- type = _model$links$i.type;
1576
-
1577
- if (type === 'application') {
1578
- var sLink = model.proxyManager.getPropertyLink(link, persistent);
1579
- publicAPI.registerPropertyLinkForGC(sLink, 'application');
1580
- sLink.bind(publicAPI, property, updateOnBind);
1581
- }
1582
- }
1583
- }
1584
- }
1585
-
1586
- setImmediateVTK(registerLinks);
1587
- } // ----------------------------------------------------------------------------
1588
- // proxyPropertyMapping(publicAPI, model, map)
1589
- //
1590
- // map = {
1591
- // opacity: { modelKey: 'property', property: 'opacity' },
1592
- // }
1593
- //
1594
- // Generated API:
1595
- // Elevate set/get methods from internal object stored in the model to current one
1596
- // ----------------------------------------------------------------------------
1597
-
1598
- function proxyPropertyMapping(publicAPI, model, map) {
1599
- var parentDelete = publicAPI.delete;
1600
- var subscriptions = [];
1601
- var propertyNames = Object.keys(map);
1602
- var count = propertyNames.length;
1603
-
1604
- while (count--) {
1605
- var propertyName = propertyNames[count];
1606
- var _map$propertyName = map[propertyName],
1607
- modelKey = _map$propertyName.modelKey,
1608
- property = _map$propertyName.property,
1609
- _map$propertyName$mod = _map$propertyName.modified,
1610
- modified = _map$propertyName$mod === void 0 ? true : _map$propertyName$mod;
1611
-
1612
- var methodSrc = _capitalize(property);
1613
-
1614
- var methodDst = _capitalize(propertyName);
1615
-
1616
- publicAPI["get".concat(methodDst)] = model[modelKey]["get".concat(methodSrc)];
1617
- publicAPI["set".concat(methodDst)] = model[modelKey]["set".concat(methodSrc)];
1618
-
1619
- if (modified) {
1620
- subscriptions.push(model[modelKey].onModified(publicAPI.modified));
1621
- }
1622
- }
1623
-
1624
- publicAPI.delete = function () {
1625
- while (subscriptions.length) {
1626
- subscriptions.pop().unsubscribe();
1627
- }
1628
-
1629
- parentDelete();
1630
- };
1631
- } // ----------------------------------------------------------------------------
1632
- // proxyPropertyState(publicAPI, model, state, defaults)
1633
- //
1634
- // state = {
1635
- // representation: {
1636
- // 'Surface with edges': { property: { edgeVisibility: true, representation: 2 } },
1637
- // Surface: { property: { edgeVisibility: false, representation: 2 } },
1638
- // Wireframe: { property: { edgeVisibility: false, representation: 1 } },
1639
- // Points: { property: { edgeVisibility: false, representation: 0 } },
1640
- // },
1641
- // }
1642
- //
1643
- // defaults = {
1644
- // representation: 'Surface',
1645
- // }
1646
- //
1647
- // Generated API
1648
- // get / set Representation ( string ) => push state to various internal objects
1649
- // ----------------------------------------------------------------------------
1650
-
1651
- function proxyPropertyState(publicAPI, model) {
1652
- var state = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1653
- var defaults = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1654
- model.this = publicAPI;
1655
-
1656
- function applyState(map) {
1657
- var modelKeys = Object.keys(map);
1658
- var count = modelKeys.length;
1659
-
1660
- while (count--) {
1661
- var modelKey = modelKeys[count];
1662
- model[modelKey].set(map[modelKey]);
1663
- }
1664
- }
1665
-
1666
- var modelKeys = Object.keys(defaults);
1667
- var count = modelKeys.length;
1668
-
1669
- var _loop2 = function _loop2() {
1670
- // Add default
1671
- var key = modelKeys[count];
1672
- model[key] = defaults[key]; // Add set method
1673
-
1674
- var mapping = state[key];
1675
-
1676
- publicAPI["set".concat(_capitalize(key))] = function (value) {
1677
- if (value !== model[key]) {
1678
- model[key] = value;
1679
- var propValues = mapping[value];
1680
- applyState(propValues);
1681
- publicAPI.modified();
1682
- }
1683
- };
1684
- };
1685
-
1686
- while (count--) {
1687
- _loop2();
1688
- } // Add getter
1689
-
1690
-
1691
- if (modelKeys.length) {
1692
- get(publicAPI, model, modelKeys);
1693
- }
1694
- } // ----------------------------------------------------------------------------
1695
- // From : https://github.com/facebookarchive/fixed-data-table/blob/master/src/vendor_upstream/dom/normalizeWheel.js
1696
- //
1697
- //
1698
- // Copyright (c) 2015, Facebook, Inc.
1699
- // All rights reserved.
1700
- //
1701
- // This source code is licensed under the BSD-style license found in the
1702
- // LICENSE file in the root directory of this source tree. An additional grant
1703
- // of patent rights can be found in the PATENTS file in the same directory.
1704
- //
1705
- //
1706
- // Mouse wheel (and 2-finger trackpad) support on the web sucks. It is
1707
- // complicated, thus this doc is long and (hopefully) detailed enough to answer
1708
- // your questions.
1709
- //
1710
- // If you need to react to the mouse wheel in a predictable way, this code is
1711
- // like your bestest friend.// hugs//
1712
- //
1713
- // As of today, there are 4 DOM event types you can listen to:
1714
- //
1715
- // 'wheel' -- Chrome(31+), FF(17+), IE(9+)
1716
- // 'mousewheel' -- Chrome, IE(6+), Opera, Safari
1717
- // 'MozMousePixelScroll' -- FF(3.5 only!) (2010-2013) -- don't bother!
1718
- // 'DOMMouseScroll' -- FF(0.9.7+) since 2003
1719
- //
1720
- // So what to do? The is the best:
1721
- //
1722
- // normalizeWheel.getEventType();
1723
- //
1724
- // In your event callback, use this code to get sane interpretation of the
1725
- // deltas. This code will return an object with properties:
1726
- //
1727
- // spinX -- normalized spin speed (use for zoom) - x plane
1728
- // spinY -- " - y plane
1729
- // pixelX -- normalized distance (to pixels) - x plane
1730
- // pixelY -- " - y plane
1731
- //
1732
- // Wheel values are provided by the browser assuming you are using the wheel to
1733
- // scroll a web page by a number of lines or pixels (or pages). Values can vary
1734
- // significantly on different platforms and browsers, forgetting that you can
1735
- // scroll at different speeds. Some devices (like trackpads) emit more events
1736
- // at smaller increments with fine granularity, and some emit massive jumps with
1737
- // linear speed or acceleration.
1738
- //
1739
- // This code does its best to normalize the deltas for you:
1740
- //
1741
- // - spin is trying to normalize how far the wheel was spun (or trackpad
1742
- // dragged). This is super useful for zoom support where you want to
1743
- // throw away the chunky scroll steps on the PC and make those equal to
1744
- // the slow and smooth tiny steps on the Mac. Key data: This code tries to
1745
- // resolve a single slow step on a wheel to 1.
1746
- //
1747
- // - pixel is normalizing the desired scroll delta in pixel units. You'll
1748
- // get the crazy differences between browsers, but at least it'll be in
1749
- // pixels!
1750
- //
1751
- // - positive value indicates scrolling DOWN/RIGHT, negative UP/LEFT. This
1752
- // should translate to positive value zooming IN, negative zooming OUT.
1753
- // This matches the newer 'wheel' event.
1754
- //
1755
- // Why are there spinX, spinY (or pixels)?
1756
- //
1757
- // - spinX is a 2-finger side drag on the trackpad, and a shift + wheel turn
1758
- // with a mouse. It results in side-scrolling in the browser by default.
1759
- //
1760
- // - spinY is what you expect -- it's the classic axis of a mouse wheel.
1761
- //
1762
- // - I dropped spinZ/pixelZ. It is supported by the DOM 3 'wheel' event and
1763
- // probably is by browsers in conjunction with fancy 3D controllers .. but
1764
- // you know.
1765
- //
1766
- // Implementation info:
1767
- //
1768
- // Examples of 'wheel' event if you scroll slowly (down) by one step with an
1769
- // average mouse:
1770
- //
1771
- // OS X + Chrome (mouse) - 4 pixel delta (wheelDelta -120)
1772
- // OS X + Safari (mouse) - N/A pixel delta (wheelDelta -12)
1773
- // OS X + Firefox (mouse) - 0.1 line delta (wheelDelta N/A)
1774
- // Win8 + Chrome (mouse) - 100 pixel delta (wheelDelta -120)
1775
- // Win8 + Firefox (mouse) - 3 line delta (wheelDelta -120)
1776
- //
1777
- // On the trackpad:
1778
- //
1779
- // OS X + Chrome (trackpad) - 2 pixel delta (wheelDelta -6)
1780
- // OS X + Firefox (trackpad) - 1 pixel delta (wheelDelta N/A)
1781
- //
1782
- // On other/older browsers.. it's more complicated as there can be multiple and
1783
- // also missing delta values.
1784
- //
1785
- // The 'wheel' event is more standard:
1786
- //
1787
- // http://www.w3.org/TR/DOM-Level-3-Events/#events-wheelevents
1788
- //
1789
- // The basics is that it includes a unit, deltaMode (pixels, lines, pages), and
1790
- // deltaX, deltaY and deltaZ. Some browsers provide other values to maintain
1791
- // backward compatibility with older events. Those other values help us
1792
- // better normalize spin speed. Example of what the browsers provide:
1793
- //
1794
- // | event.wheelDelta | event.detail
1795
- // ------------------+------------------+--------------
1796
- // Safari v5/OS X | -120 | 0
1797
- // Safari v5/Win7 | -120 | 0
1798
- // Chrome v17/OS X | -120 | 0
1799
- // Chrome v17/Win7 | -120 | 0
1800
- // IE9/Win7 | -120 | undefined
1801
- // Firefox v4/OS X | undefined | 1
1802
- // Firefox v4/Win7 | undefined | 3
1803
- //
1804
- // ----------------------------------------------------------------------------
1805
- // Reasonable defaults
1806
-
1807
- var PIXEL_STEP = 10;
1808
- var LINE_HEIGHT = 40;
1809
- var PAGE_HEIGHT = 800;
1810
- function normalizeWheel(wheelEvent) {
1811
- var sX = 0; // spinX
1812
-
1813
- var sY = 0; // spinY
1814
-
1815
- var pX = 0; // pixelX
1816
-
1817
- var pY = 0; // pixelY
1818
- // Legacy
1819
-
1820
- if ('detail' in wheelEvent) {
1821
- sY = wheelEvent.detail;
1822
- }
1823
-
1824
- if ('wheelDelta' in wheelEvent) {
1825
- sY = -wheelEvent.wheelDelta / 120;
1826
- }
1827
-
1828
- if ('wheelDeltaY' in wheelEvent) {
1829
- sY = -wheelEvent.wheelDeltaY / 120;
1830
- }
1831
-
1832
- if ('wheelDeltaX' in wheelEvent) {
1833
- sX = -wheelEvent.wheelDeltaX / 120;
1834
- } // side scrolling on FF with DOMMouseScroll
1835
-
1836
-
1837
- if ('axis' in wheelEvent && wheelEvent.axis === wheelEvent.HORIZONTAL_AXIS) {
1838
- sX = sY;
1839
- sY = 0;
1840
- }
1841
-
1842
- pX = sX * PIXEL_STEP;
1843
- pY = sY * PIXEL_STEP;
1844
-
1845
- if ('deltaY' in wheelEvent) {
1846
- pY = wheelEvent.deltaY;
1847
- }
1848
-
1849
- if ('deltaX' in wheelEvent) {
1850
- pX = wheelEvent.deltaX;
1851
- }
1852
-
1853
- if ((pX || pY) && wheelEvent.deltaMode) {
1854
- if (wheelEvent.deltaMode === 1) {
1855
- // delta in LINE units
1856
- pX *= LINE_HEIGHT;
1857
- pY *= LINE_HEIGHT;
1858
- } else {
1859
- // delta in PAGE units
1860
- pX *= PAGE_HEIGHT;
1861
- pY *= PAGE_HEIGHT;
1862
- }
1863
- } // Fall-back if spin cannot be determined
1864
-
1865
-
1866
- if (pX && !sX) {
1867
- sX = pX < 1 ? -1 : 1;
1868
- }
1869
-
1870
- if (pY && !sY) {
1871
- sY = pY < 1 ? -1 : 1;
1872
- }
1873
-
1874
- return {
1875
- spinX: sX,
1876
- spinY: sY,
1877
- pixelX: pX,
1878
- pixelY: pY
1879
- };
1880
- } // ----------------------------------------------------------------------------
1881
- // Default export
1882
- // ----------------------------------------------------------------------------
1883
-
1884
- var macro = {
1885
- algo: algo,
1886
- capitalize: capitalize,
1887
- chain: chain,
1888
- debounce: debounce,
1889
- enumToString: enumToString,
1890
- event: event,
1891
- EVENT_ABORT: EVENT_ABORT,
1892
- formatBytesToProperUnit: formatBytesToProperUnit,
1893
- formatNumbersWithThousandSeparator: formatNumbersWithThousandSeparator,
1894
- get: get,
1895
- getArray: getArray,
1896
- getCurrentGlobalMTime: getCurrentGlobalMTime,
1897
- getStateArrayMapFunc: getStateArrayMapFunc,
1898
- isVtkObject: isVtkObject,
1899
- keystore: keystore,
1900
- measurePromiseExecution: measurePromiseExecution,
1901
- moveToProtected: moveToProtected,
1902
- newInstance: newInstance,
1903
- newTypedArray: newTypedArray,
1904
- newTypedArrayFrom: newTypedArrayFrom,
1905
- normalizeWheel: normalizeWheel,
1906
- obj: obj,
1907
- proxy: proxy,
1908
- proxyPropertyMapping: proxyPropertyMapping,
1909
- proxyPropertyState: proxyPropertyState,
1910
- safeArrays: safeArrays,
1911
- set: set,
1912
- setArray: setArray,
1913
- setGet: setGet,
1914
- setGetArray: setGetArray,
1915
- setImmediate: setImmediateVTK,
1916
- setLoggerFunction: setLoggerFunction,
1917
- throttle: throttle,
1918
- traverseInstanceTree: traverseInstanceTree,
1919
- TYPED_ARRAYS: TYPED_ARRAYS,
1920
- // deprecated todo remove on breaking API revision
1921
- uncapitalize: uncapitalize,
1922
- VOID: VOID,
1923
- vtkDebugMacro: vtkDebugMacro,
1924
- vtkErrorMacro: vtkErrorMacro,
1925
- vtkInfoMacro: vtkInfoMacro,
1926
- vtkLogMacro: vtkLogMacro,
1927
- vtkOnceErrorMacro: vtkOnceErrorMacro,
1928
- vtkWarningMacro: vtkWarningMacro
1929
- };
1930
-
1931
- export { EVENT_ABORT, TYPED_ARRAYS, VOID, _capitalize, algo, capitalize, chain, debounce, macro as default, event, formatBytesToProperUnit, formatNumbersWithThousandSeparator, get, getArray, isVtkObject, keystore, measurePromiseExecution, moveToProtected, newInstance, newTypedArray, newTypedArrayFrom, normalizeWheel, obj, proxy, proxyPropertyMapping, proxyPropertyState, set, setArray, setGet, setGetArray, setImmediateVTK, setLoggerFunction, throttle, traverseInstanceTree, uncapitalize, vtkDebugMacro, vtkErrorMacro, vtkInfoMacro, vtkLogMacro, vtkOnceErrorMacro, vtkWarningMacro };
1
+ import 'fast-deep-equal';
2
+ import './vtk.js';
3
+ import './Common/Core/ClassHierarchy.js';
4
+ export { G as EVENT_ABORT, T as TYPED_ARRAYS, V as VOID, _ as _capitalize, d as algo, q as capitalize, h as chain, I as debounce, m as default, f as event, B as formatBytesToProperUnit, C as formatNumbersWithThousandSeparator, g as get, k as getArray, H as isVtkObject, K as keystore, E as measurePromiseExecution, i as moveToProtected, n as newInstance, a as newTypedArray, b as newTypedArrayFrom, M as normalizeWheel, o as obj, p as proxy, j as proxyPropertyMapping, L as proxyPropertyState, s as set, F as setArray, e as setGet, l as setGetArray, D as setImmediateVTK, u as setLoggerFunction, J as throttle, t as traverseInstanceTree, A as uncapitalize, y as vtkDebugMacro, r as vtkErrorMacro, x as vtkInfoMacro, w as vtkLogMacro, z as vtkOnceErrorMacro, v as vtkWarningMacro } from './macros2.js';