@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
@@ -1,103 +1,98 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import macro from '../../macros.js';
3
- import { h as hsv2rgb, i as isNan, G as isInf, H as rgb2hsv, I as rgb2lab, J as lab2rgb, K as floor } from '../../Common/Core/Math/index.js';
1
+ import { m as macro } from '../../macros2.js';
2
+ import { h as hsv2rgb, i as isNan, G as floor, H as isInf, I as rgb2hsv, J as rgb2lab, K as lab2rgb } from '../../Common/Core/Math/index.js';
4
3
  import vtkScalarsToColors from '../../Common/Core/ScalarsToColors.js';
5
4
  import Constants from './ColorTransferFunction/Constants.js';
6
5
 
7
- 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; }
6
+ const {
7
+ ColorSpace,
8
+ Scale
9
+ } = Constants;
10
+ const {
11
+ ScalarMappingTarget
12
+ } = vtkScalarsToColors;
13
+ const {
14
+ vtkDebugMacro,
15
+ vtkErrorMacro,
16
+ vtkWarningMacro
17
+ } = macro;
8
18
 
9
- 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; }
10
- var ColorSpace = Constants.ColorSpace,
11
- Scale = Constants.Scale;
12
- var ScalarMappingTarget = vtkScalarsToColors.ScalarMappingTarget;
13
- var vtkDebugMacro = macro.vtkDebugMacro,
14
- vtkErrorMacro = macro.vtkErrorMacro,
15
- vtkWarningMacro = macro.vtkWarningMacro; // ----------------------------------------------------------------------------
19
+ // ----------------------------------------------------------------------------
16
20
  // Global methods
17
21
  // ----------------------------------------------------------------------------
18
-
19
22
  /* eslint-disable no-continue */
23
+
20
24
  // Convert to and from a special polar version of CIELAB (useful for creating
21
25
  // continuous diverging color maps).
22
-
23
26
  function vtkColorTransferFunctionLabToMsh(lab, msh) {
24
- var L = lab[0];
25
- var a = lab[1];
26
- var b = lab[2];
27
- var M = Math.sqrt(L * L + a * a + b * b);
28
- var s = M > 0.001 ? Math.acos(L / M) : 0.0;
29
- var h = s > 0.001 ? Math.atan2(b, a) : 0.0;
27
+ const L = lab[0];
28
+ const a = lab[1];
29
+ const b = lab[2];
30
+ const M = Math.sqrt(L * L + a * a + b * b);
31
+ const s = M > 0.001 ? Math.acos(L / M) : 0.0;
32
+ const h = s > 0.001 ? Math.atan2(b, a) : 0.0;
30
33
  msh[0] = M;
31
34
  msh[1] = s;
32
35
  msh[2] = h;
33
36
  }
34
-
35
37
  function vtkColorTransferFunctionMshToLab(msh, lab) {
36
- var M = msh[0];
37
- var s = msh[1];
38
- var h = msh[2];
38
+ const M = msh[0];
39
+ const s = msh[1];
40
+ const h = msh[2];
39
41
  lab[0] = M * Math.cos(s);
40
42
  lab[1] = M * Math.sin(s) * Math.cos(h);
41
43
  lab[2] = M * Math.sin(s) * Math.sin(h);
42
- } // For the case when interpolating from a saturated color to an unsaturated
43
- // color, find a hue for the unsaturated color that makes sense.
44
-
44
+ }
45
45
 
46
+ // For the case when interpolating from a saturated color to an unsaturated
47
+ // color, find a hue for the unsaturated color that makes sense.
46
48
  function vtkColorTransferFunctionAdjustHue(msh, unsatM) {
47
49
  if (msh[0] >= unsatM - 0.1) {
48
50
  // The best we can do is hold hue constant.
49
51
  return msh[2];
50
- } // This equation is designed to make the perceptual change of the
51
- // interpolation to be close to constant.
52
-
53
-
54
- var hueSpin = msh[1] * Math.sqrt(unsatM * unsatM - msh[0] * msh[0]) / (msh[0] * Math.sin(msh[1])); // Spin hue away from 0 except in purple hues.
52
+ }
55
53
 
54
+ // This equation is designed to make the perceptual change of the
55
+ // interpolation to be close to constant.
56
+ const hueSpin = msh[1] * Math.sqrt(unsatM * unsatM - msh[0] * msh[0]) / (msh[0] * Math.sin(msh[1]));
57
+ // Spin hue away from 0 except in purple hues.
56
58
  if (msh[2] > -0.3 * Math.PI) {
57
59
  return msh[2] + hueSpin;
58
60
  }
59
-
60
61
  return msh[2] - hueSpin;
61
62
  }
62
-
63
63
  function vtkColorTransferFunctionAngleDiff(a1, a2) {
64
- var adiff = a1 - a2;
65
-
64
+ let adiff = a1 - a2;
66
65
  if (adiff < 0.0) {
67
66
  adiff = -adiff;
68
67
  }
69
-
70
68
  while (adiff >= 2.0 * Math.PI) {
71
69
  adiff -= 2.0 * Math.PI;
72
70
  }
73
-
74
71
  if (adiff > Math.PI) {
75
72
  adiff = 2.0 * Math.PI - adiff;
76
73
  }
77
-
78
74
  return adiff;
79
- } // Interpolate a diverging color map.
80
-
75
+ }
81
76
 
77
+ // Interpolate a diverging color map.
82
78
  function vtkColorTransferFunctionInterpolateDiverging(s, rgb1, rgb2, result) {
83
- var lab1 = [];
84
- var lab2 = [];
79
+ const lab1 = [];
80
+ const lab2 = [];
85
81
  rgb2lab(rgb1, lab1);
86
82
  rgb2lab(rgb2, lab2);
87
- var msh1 = [];
88
- var msh2 = [];
83
+ const msh1 = [];
84
+ const msh2 = [];
89
85
  vtkColorTransferFunctionLabToMsh(lab1, msh1);
90
- vtkColorTransferFunctionLabToMsh(lab2, msh2); // If the endpoints are distinct saturated colors, then place white in between
91
- // them.
92
-
93
- var localS = s;
86
+ vtkColorTransferFunctionLabToMsh(lab2, msh2);
94
87
 
88
+ // If the endpoints are distinct saturated colors, then place white in between
89
+ // them.
90
+ let localS = s;
95
91
  if (msh1[1] > 0.05 && msh2[1] > 0.05 && vtkColorTransferFunctionAngleDiff(msh1[2], msh2[2]) > 0.33 * Math.PI) {
96
92
  // Insert the white midpoint by setting one end to white and adjusting the
97
93
  // scalar value.
98
- var Mmid = Math.max(msh1[0], msh2[0]);
94
+ let Mmid = Math.max(msh1[0], msh2[0]);
99
95
  Mmid = Math.max(88.0, Mmid);
100
-
101
96
  if (s < 0.5) {
102
97
  msh2[0] = Mmid;
103
98
  msh2[1] = 0.0;
@@ -109,473 +104,443 @@ function vtkColorTransferFunctionInterpolateDiverging(s, rgb1, rgb2, result) {
109
104
  msh1[2] = 0.0;
110
105
  localS = 2.0 * localS - 1.0;
111
106
  }
112
- } // If one color has no saturation, then its hue value is invalid. In this
107
+ }
108
+
109
+ // If one color has no saturation, then its hue value is invalid. In this
113
110
  // case, we want to set it to something logical so that the interpolation of
114
111
  // hue makes sense.
115
-
116
-
117
112
  if (msh1[1] < 0.05 && msh2[1] > 0.05) {
118
113
  msh1[2] = vtkColorTransferFunctionAdjustHue(msh2, msh1[0]);
119
114
  } else if (msh2[1] < 0.05 && msh1[1] > 0.05) {
120
115
  msh2[2] = vtkColorTransferFunctionAdjustHue(msh1, msh2[0]);
121
116
  }
122
-
123
- var mshTmp = [];
117
+ const mshTmp = [];
124
118
  mshTmp[0] = (1 - localS) * msh1[0] + localS * msh2[0];
125
119
  mshTmp[1] = (1 - localS) * msh1[1] + localS * msh2[1];
126
- mshTmp[2] = (1 - localS) * msh1[2] + localS * msh2[2]; // Now convert back to RGB
120
+ mshTmp[2] = (1 - localS) * msh1[2] + localS * msh2[2];
127
121
 
128
- var labTmp = [];
122
+ // Now convert back to RGB
123
+ const labTmp = [];
129
124
  vtkColorTransferFunctionMshToLab(mshTmp, labTmp);
130
125
  lab2rgb(labTmp, result);
131
- } // ----------------------------------------------------------------------------
126
+ }
127
+
128
+ // ----------------------------------------------------------------------------
132
129
  // vtkColorTransferFunction methods
133
130
  // ----------------------------------------------------------------------------
134
131
 
135
-
136
132
  function vtkColorTransferFunction(publicAPI, model) {
137
133
  // Set our className
138
- model.classHierarchy.push('vtkColorTransferFunction'); // Return the number of points which specify this function
139
-
140
- publicAPI.getSize = function () {
141
- return model.nodes.length;
142
- }; //----------------------------------------------------------------------------
143
- // Add a point defined in RGB
134
+ model.classHierarchy.push('vtkColorTransferFunction');
144
135
 
136
+ // Return the number of points which specify this function
137
+ publicAPI.getSize = () => model.nodes.length;
145
138
 
146
- publicAPI.addRGBPoint = function (x, r, g, b) {
147
- return publicAPI.addRGBPointLong(x, r, g, b, 0.5, 0.0);
148
- }; //----------------------------------------------------------------------------
139
+ //----------------------------------------------------------------------------
149
140
  // Add a point defined in RGB
141
+ publicAPI.addRGBPoint = (x, r, g, b) => publicAPI.addRGBPointLong(x, r, g, b, 0.5, 0.0);
150
142
 
151
-
143
+ //----------------------------------------------------------------------------
144
+ // Add a point defined in RGB
152
145
  publicAPI.addRGBPointLong = function (x, r, g, b) {
153
- var midpoint = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0.5;
154
- var sharpness = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0.0;
155
-
146
+ let midpoint = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0.5;
147
+ let sharpness = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0.0;
156
148
  // Error check
157
149
  if (midpoint < 0.0 || midpoint > 1.0) {
158
150
  vtkErrorMacro('Midpoint outside range [0.0, 1.0]');
159
151
  return -1;
160
152
  }
161
-
162
153
  if (sharpness < 0.0 || sharpness > 1.0) {
163
154
  vtkErrorMacro('Sharpness outside range [0.0, 1.0]');
164
155
  return -1;
165
- } // remove any node already at this X location
166
-
156
+ }
167
157
 
158
+ // remove any node already at this X location
168
159
  if (!model.allowDuplicateScalars) {
169
160
  publicAPI.removePoint(x);
170
- } // Create the new node
171
-
172
-
173
- var node = {
174
- x: x,
175
- r: r,
176
- g: g,
177
- b: b,
178
- midpoint: midpoint,
179
- sharpness: sharpness
180
- }; // Add it, then sort to get everything in order
161
+ }
181
162
 
163
+ // Create the new node
164
+ const node = {
165
+ x,
166
+ r,
167
+ g,
168
+ b,
169
+ midpoint,
170
+ sharpness
171
+ };
172
+
173
+ // Add it, then sort to get everything in order
182
174
  model.nodes.push(node);
183
- publicAPI.sortAndUpdateRange(); // We need to find the index of the node we just added in order
184
- // to return this value
185
-
186
- var i = 0;
175
+ publicAPI.sortAndUpdateRange();
187
176
 
177
+ // We need to find the index of the node we just added in order
178
+ // to return this value
179
+ let i = 0;
188
180
  for (; i < model.nodes.length; i++) {
189
181
  if (model.nodes[i].x === x) {
190
182
  break;
191
183
  }
192
- } // If we didn't find it, something went horribly wrong so
193
- // return -1
194
-
184
+ }
195
185
 
186
+ // If we didn't find it, something went horribly wrong so
187
+ // return -1
196
188
  if (i < model.nodes.length) {
197
189
  return i;
198
190
  }
199
-
200
191
  return -1;
201
- }; //----------------------------------------------------------------------------
202
- // Add a point defined in HSV
203
-
192
+ };
204
193
 
205
- publicAPI.addHSVPoint = function (x, h, s, v) {
206
- return publicAPI.addHSVPointLong(x, h, s, v, 0.5, 0.0);
207
- }; //----------------------------------------------------------------------------
194
+ //----------------------------------------------------------------------------
208
195
  // Add a point defined in HSV
196
+ publicAPI.addHSVPoint = (x, h, s, v) => publicAPI.addHSVPointLong(x, h, s, v, 0.5, 0.0);
209
197
 
210
-
198
+ //----------------------------------------------------------------------------
199
+ // Add a point defined in HSV
211
200
  publicAPI.addHSVPointLong = function (x, h, s, v) {
212
- var midpoint = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0.5;
213
- var sharpness = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0.0;
214
- var rgb = [];
215
- var hsv = [h, s, v];
201
+ let midpoint = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0.5;
202
+ let sharpness = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0.0;
203
+ const rgb = [];
204
+ const hsv = [h, s, v];
216
205
  hsv2rgb(hsv, rgb);
217
206
  return publicAPI.addRGBPoint(x, rgb[0], rgb[1], rgb[2], midpoint, sharpness);
218
- }; //----------------------------------------------------------------------------
219
- // Set nodes directly
220
-
207
+ };
221
208
 
222
- publicAPI.setNodes = function (nodes) {
209
+ //----------------------------------------------------------------------------
210
+ // Set nodes directly
211
+ publicAPI.setNodes = nodes => {
223
212
  if (model.nodes !== nodes) {
224
- var before = JSON.stringify(model.nodes);
213
+ const before = JSON.stringify(model.nodes);
225
214
  model.nodes = nodes;
226
- var after = JSON.stringify(model.nodes);
227
-
215
+ const after = JSON.stringify(model.nodes);
228
216
  if (publicAPI.sortAndUpdateRange() || before !== after) {
229
217
  publicAPI.modified();
230
218
  return true;
231
219
  }
232
220
  }
233
-
234
221
  return false;
235
- }; //----------------------------------------------------------------------------
222
+ };
223
+
224
+ //----------------------------------------------------------------------------
236
225
  // Sort the vector in increasing order, then fill in
237
226
  // the Range
238
-
239
-
240
- publicAPI.sortAndUpdateRange = function () {
241
- var before = JSON.stringify(model.nodes);
242
- model.nodes.sort(function (a, b) {
243
- return a.x - b.x;
244
- });
245
- var after = JSON.stringify(model.nodes);
246
- var modifiedInvoked = publicAPI.updateRange(); // If range is updated, Modified() has been called, don't call it again.
247
-
227
+ publicAPI.sortAndUpdateRange = () => {
228
+ const before = JSON.stringify(model.nodes);
229
+ model.nodes.sort((a, b) => a.x - b.x);
230
+ const after = JSON.stringify(model.nodes);
231
+ const modifiedInvoked = publicAPI.updateRange();
232
+ // If range is updated, Modified() has been called, don't call it again.
248
233
  if (!modifiedInvoked && before !== after) {
249
234
  publicAPI.modified();
250
235
  return true;
251
236
  }
252
-
253
237
  return modifiedInvoked;
254
- }; //----------------------------------------------------------------------------
255
-
238
+ };
256
239
 
257
- publicAPI.updateRange = function () {
258
- var oldRange = [2];
240
+ //----------------------------------------------------------------------------
241
+ publicAPI.updateRange = () => {
242
+ const oldRange = [2];
259
243
  oldRange[0] = model.mappingRange[0];
260
244
  oldRange[1] = model.mappingRange[1];
261
- var size = model.nodes.length;
262
-
245
+ const size = model.nodes.length;
263
246
  if (size) {
264
247
  model.mappingRange[0] = model.nodes[0].x;
265
248
  model.mappingRange[1] = model.nodes[size - 1].x;
266
249
  } else {
267
250
  model.mappingRange[0] = 0;
268
251
  model.mappingRange[1] = 0;
269
- } // If the range is the same, then no need to call Modified()
270
-
252
+ }
271
253
 
254
+ // If the range is the same, then no need to call Modified()
272
255
  if (oldRange[0] === model.mappingRange[0] && oldRange[1] === model.mappingRange[1]) {
273
256
  return false;
274
257
  }
275
-
276
258
  publicAPI.modified();
277
259
  return true;
278
- }; //----------------------------------------------------------------------------
279
- // Remove a point
280
-
260
+ };
281
261
 
282
- publicAPI.removePoint = function (x) {
262
+ //----------------------------------------------------------------------------
263
+ // Remove a point
264
+ publicAPI.removePoint = x => {
283
265
  // First find the node since we need to know its
284
266
  // index as our return value
285
- var i = 0;
286
-
267
+ let i = 0;
287
268
  for (; i < model.nodes.length; i++) {
288
269
  if (model.nodes[i].x === x) {
289
270
  break;
290
271
  }
291
272
  }
273
+ const retVal = i;
292
274
 
293
- var retVal = i; // If the node doesn't exist, we return -1
294
-
275
+ // If the node doesn't exist, we return -1
295
276
  if (i >= model.nodes.length) {
296
277
  return -1;
297
- } // If the first or last point has been removed, then we update the range
298
- // No need to sort here as the order of points hasn't changed.
299
-
278
+ }
300
279
 
301
- var modifiedInvoked = false;
280
+ // If the first or last point has been removed, then we update the range
281
+ // No need to sort here as the order of points hasn't changed.
282
+ let modifiedInvoked = false;
302
283
  model.nodes.splice(i, 1);
303
-
304
284
  if (i === 0 || i === model.nodes.length) {
305
285
  modifiedInvoked = publicAPI.updateRange();
306
286
  }
307
-
308
287
  if (!modifiedInvoked) {
309
288
  publicAPI.modified();
310
289
  }
311
-
312
290
  return retVal;
313
- }; //----------------------------------------------------------------------------
314
-
291
+ };
315
292
 
316
- publicAPI.movePoint = function (oldX, newX) {
293
+ //----------------------------------------------------------------------------
294
+ publicAPI.movePoint = (oldX, newX) => {
317
295
  if (oldX === newX) {
318
296
  // Nothing to do.
319
297
  return;
320
298
  }
321
-
322
299
  publicAPI.removePoint(newX);
323
-
324
- for (var i = 0; i < model.nodes.length; i++) {
300
+ for (let i = 0; i < model.nodes.length; i++) {
325
301
  if (model.nodes[i].x === oldX) {
326
302
  model.nodes[i].x = newX;
327
303
  publicAPI.sortAndUpdateRange();
328
304
  break;
329
305
  }
330
306
  }
331
- }; //----------------------------------------------------------------------------
332
- // Remove all points
333
-
307
+ };
334
308
 
335
- publicAPI.removeAllPoints = function () {
309
+ //----------------------------------------------------------------------------
310
+ // Remove all points
311
+ publicAPI.removeAllPoints = () => {
336
312
  model.nodes = [];
337
313
  publicAPI.sortAndUpdateRange();
338
- }; //----------------------------------------------------------------------------
339
- // Add a line defined in RGB
340
-
314
+ };
341
315
 
342
- publicAPI.addRGBSegment = function (x1, r1, g1, b1, x2, r2, g2, b2) {
316
+ //----------------------------------------------------------------------------
317
+ // Add a line defined in RGB
318
+ publicAPI.addRGBSegment = (x1, r1, g1, b1, x2, r2, g2, b2) => {
343
319
  // First, find all points in this range and remove them
344
320
  publicAPI.sortAndUpdateRange();
345
-
346
- for (var i = 0; i < model.nodes.length;) {
321
+ for (let i = 0; i < model.nodes.length;) {
347
322
  if (model.nodes[i].x >= x1 && model.nodes[i].x <= x2) {
348
323
  model.nodes.splice(i, 1);
349
324
  } else {
350
325
  i++;
351
326
  }
352
- } // Now add the points
353
-
327
+ }
354
328
 
329
+ // Now add the points
355
330
  publicAPI.addRGBPointLong(x1, r1, g1, b1, 0.5, 0.0);
356
331
  publicAPI.addRGBPointLong(x2, r2, g2, b2, 0.5, 0.0);
357
332
  publicAPI.modified();
358
- }; //----------------------------------------------------------------------------
359
- // Add a line defined in HSV
360
-
333
+ };
361
334
 
362
- publicAPI.addHSVSegment = function (x1, h1, s1, v1, x2, h2, s2, v2) {
363
- var hsv1 = [h1, s1, v1];
364
- var hsv2 = [h2, s2, v2];
365
- var rgb1 = [];
366
- var rgb2 = [];
335
+ //----------------------------------------------------------------------------
336
+ // Add a line defined in HSV
337
+ publicAPI.addHSVSegment = (x1, h1, s1, v1, x2, h2, s2, v2) => {
338
+ const hsv1 = [h1, s1, v1];
339
+ const hsv2 = [h2, s2, v2];
340
+ const rgb1 = [];
341
+ const rgb2 = [];
367
342
  hsv2rgb(hsv1, rgb1);
368
343
  hsv2rgb(hsv2, rgb2);
369
344
  publicAPI.addRGBSegment(x1, rgb1[0], rgb1[1], rgb1[2], x2, rgb2[0], rgb2[1], rgb2[2]);
370
- }; //----------------------------------------------------------------------------
371
- // Returns the RGBA color evaluated at the specified location
372
-
345
+ };
373
346
 
374
- publicAPI.mapValue = function (x) {
375
- var rgb = [];
347
+ //----------------------------------------------------------------------------
348
+ // Returns the RGBA color evaluated at the specified location
349
+ publicAPI.mapValue = x => {
350
+ const rgb = [];
376
351
  publicAPI.getColor(x, rgb);
377
352
  return [Math.floor(255.0 * rgb[0] + 0.5), Math.floor(255.0 * rgb[1] + 0.5), Math.floor(255.0 * rgb[2] + 0.5), 255];
378
- }; //----------------------------------------------------------------------------
379
- // Returns the RGB color evaluated at the specified location
380
-
353
+ };
381
354
 
382
- publicAPI.getColor = function (x, rgb) {
355
+ //----------------------------------------------------------------------------
356
+ // Returns the RGB color evaluated at the specified location
357
+ publicAPI.getColor = (x, rgb) => {
383
358
  if (model.indexedLookup) {
384
- var numNodes = publicAPI.getSize(); // todo
385
-
386
- var idx = publicAPI.getAnnotatedValueIndexInternal(x);
387
-
359
+ const numNodes = publicAPI.getSize();
360
+ // todo
361
+ const idx = publicAPI.getAnnotatedValueIndexInternal(x);
388
362
  if (idx < 0 || numNodes === 0) {
389
- var nanColor = publicAPI.getNanColorByReference();
363
+ const nanColor = publicAPI.getNanColorByReference();
390
364
  rgb[0] = nanColor[0];
391
365
  rgb[1] = nanColor[1];
392
366
  rgb[2] = nanColor[2];
393
367
  } else {
394
- var nodeVal = [];
395
- publicAPI.getNodeValue(idx % numNodes, nodeVal); // nodeVal[0] is the x value. nodeVal[1...3] is rgb.
396
-
368
+ const nodeVal = [];
369
+ publicAPI.getNodeValue(idx % numNodes, nodeVal);
370
+ // nodeVal[0] is the x value. nodeVal[1...3] is rgb.
397
371
  rgb[0] = nodeVal[1];
398
372
  rgb[1] = nodeVal[2];
399
373
  rgb[2] = nodeVal[3];
400
374
  }
401
-
402
375
  return;
403
376
  }
404
-
405
377
  publicAPI.getTable(x, x, 1, rgb);
406
- }; //----------------------------------------------------------------------------
407
- // Returns the red color evaluated at the specified location
408
-
378
+ };
409
379
 
410
- publicAPI.getRedValue = function (x) {
411
- var rgb = [];
380
+ //----------------------------------------------------------------------------
381
+ // Returns the red color evaluated at the specified location
382
+ publicAPI.getRedValue = x => {
383
+ const rgb = [];
412
384
  publicAPI.getColor(x, rgb);
413
385
  return rgb[0];
414
- }; //----------------------------------------------------------------------------
415
- // Returns the green color evaluated at the specified location
416
-
386
+ };
417
387
 
418
- publicAPI.getGreenValue = function (x) {
419
- var rgb = [];
388
+ //----------------------------------------------------------------------------
389
+ // Returns the green color evaluated at the specified location
390
+ publicAPI.getGreenValue = x => {
391
+ const rgb = [];
420
392
  publicAPI.getColor(x, rgb);
421
393
  return rgb[1];
422
- }; //----------------------------------------------------------------------------
423
- // Returns the blue color evaluated at the specified location
424
-
394
+ };
425
395
 
426
- publicAPI.getBlueValue = function (x) {
427
- var rgb = [];
396
+ //----------------------------------------------------------------------------
397
+ // Returns the blue color evaluated at the specified location
398
+ publicAPI.getBlueValue = x => {
399
+ const rgb = [];
428
400
  publicAPI.getColor(x, rgb);
429
401
  return rgb[2];
430
- }; //----------------------------------------------------------------------------
431
- // Returns a table of RGB colors at regular intervals along the function
432
-
402
+ };
433
403
 
434
- publicAPI.getTable = function (xStart_, xEnd_, size, table) {
404
+ //----------------------------------------------------------------------------
405
+ // Returns a table of RGB colors at regular intervals along the function
406
+ publicAPI.getTable = (xStart_, xEnd_, size, table) => {
435
407
  // To handle BigInt limitation
436
- var xStart = Number(xStart_);
437
- var xEnd = Number(xEnd_); // Special case: If either the start or end is a NaN, then all any
408
+ const xStart = Number(xStart_);
409
+ const xEnd = Number(xEnd_);
410
+
411
+ // Special case: If either the start or end is a NaN, then all any
438
412
  // interpolation done on them is also a NaN. Therefore, fill the table with
439
413
  // the NaN color.
440
-
441
414
  if (isNan(xStart) || isNan(xEnd)) {
442
- for (var i = 0; i < size; i++) {
415
+ for (let i = 0; i < size; i++) {
443
416
  table[i * 3 + 0] = model.nanColor[0];
444
417
  table[i * 3 + 1] = model.nanColor[1];
445
418
  table[i * 3 + 2] = model.nanColor[2];
446
419
  }
447
-
448
420
  return;
449
421
  }
422
+ let idx = 0;
423
+ const numNodes = model.nodes.length;
450
424
 
451
- var idx = 0;
452
- var numNodes = model.nodes.length; // Need to keep track of the last value so that
425
+ // Need to keep track of the last value so that
453
426
  // we can fill in table locations past this with
454
427
  // this value if Clamping is On.
455
-
456
- var lastR = 0.0;
457
- var lastG = 0.0;
458
- var lastB = 0.0;
459
-
428
+ let lastR = 0.0;
429
+ let lastG = 0.0;
430
+ let lastB = 0.0;
460
431
  if (numNodes !== 0) {
461
432
  lastR = model.nodes[numNodes - 1].r;
462
433
  lastG = model.nodes[numNodes - 1].g;
463
434
  lastB = model.nodes[numNodes - 1].b;
464
435
  }
465
-
466
- var x = 0.0;
467
- var x1 = 0.0;
468
- var x2 = 0.0;
469
- var rgb1 = [0.0, 0.0, 0.0];
470
- var rgb2 = [0.0, 0.0, 0.0];
471
- var midpoint = 0.0;
472
- var sharpness = 0.0;
473
- var tmpVec = []; // If the scale is logarithmic, make sure the range is valid.
474
-
475
- var usingLogScale = model.scale === Scale.LOG10;
476
-
436
+ let x = 0.0;
437
+ let x1 = 0.0;
438
+ let x2 = 0.0;
439
+ const rgb1 = [0.0, 0.0, 0.0];
440
+ const rgb2 = [0.0, 0.0, 0.0];
441
+ let midpoint = 0.0;
442
+ let sharpness = 0.0;
443
+ const tmpVec = [];
444
+
445
+ // If the scale is logarithmic, make sure the range is valid.
446
+ let usingLogScale = model.scale === Scale.LOG10;
477
447
  if (usingLogScale) {
478
448
  // Note: This requires range[0] <= range[1].
479
449
  usingLogScale = model.mappingRange[0] > 0.0;
480
450
  }
481
-
482
- var logStart = 0.0;
483
- var logEnd = 0.0;
484
- var logX = 0.0;
485
-
451
+ let logStart = 0.0;
452
+ let logEnd = 0.0;
453
+ let logX = 0.0;
486
454
  if (usingLogScale) {
487
455
  logStart = Math.log10(xStart);
488
456
  logEnd = Math.log10(xEnd);
489
- } // For each table entry
490
-
457
+ }
491
458
 
492
- for (var _i = 0; _i < size; _i++) {
459
+ // For each table entry
460
+ for (let i = 0; i < size; i++) {
493
461
  // Find our location in the table
494
- var tidx = 3 * _i; // Find our X location. If we are taking only 1 sample, make
462
+ const tidx = 3 * i;
463
+
464
+ // Find our X location. If we are taking only 1 sample, make
495
465
  // it halfway between start and end (usually start and end will
496
466
  // be the same in this case)
497
-
498
467
  if (size > 1) {
499
468
  if (usingLogScale) {
500
- logX = logStart + _i / (size - 1.0) * (logEnd - logStart);
501
- x = Math.pow(10.0, logX);
469
+ logX = logStart + i / (size - 1.0) * (logEnd - logStart);
470
+ x = 10.0 ** logX;
502
471
  } else {
503
- x = xStart + _i / (size - 1.0) * (xEnd - xStart);
472
+ x = xStart + i / (size - 1.0) * (xEnd - xStart);
504
473
  }
505
474
  } else if (usingLogScale) {
506
475
  logX = 0.5 * (logStart + logEnd);
507
- x = Math.pow(10.0, logX);
476
+ x = 10.0 ** logX;
508
477
  } else {
509
478
  x = 0.5 * (xStart + xEnd);
510
- } // Linearly map x from mappingRange to [0, numberOfValues-1],
479
+ }
480
+
481
+ // Linearly map x from mappingRange to [0, numberOfValues-1],
511
482
  // discretize (round down to the closest integer),
512
483
  // then map back to mappingRange
513
-
514
-
515
484
  if (model.discretize) {
516
- var range = model.mappingRange;
517
-
485
+ const range = model.mappingRange;
518
486
  if (x >= range[0] && x <= range[1]) {
519
- var numberOfValues = model.numberOfValues;
520
- var deltaRange = range[1] - range[0];
521
-
487
+ const numberOfValues = model.numberOfValues;
488
+ const deltaRange = range[1] - range[0];
522
489
  if (numberOfValues <= 1) {
523
490
  x = range[0] + deltaRange / 2.0;
524
491
  } else {
525
492
  // normalize x
526
- var xn = (x - range[0]) / deltaRange; // discretize
527
-
528
- var discretizeIndex = floor(numberOfValues * xn); // get discretized x
529
-
493
+ const xn = (x - range[0]) / deltaRange;
494
+ // discretize
495
+ const discretizeIndex = floor(numberOfValues * xn);
496
+ // get discretized x
530
497
  x = range[0] + discretizeIndex / (numberOfValues - 1) * deltaRange;
531
498
  }
532
499
  }
533
- } // Do we need to move to the next node?
534
-
500
+ }
535
501
 
502
+ // Do we need to move to the next node?
536
503
  while (idx < numNodes && x > model.nodes[idx].x) {
537
- idx++; // If we are at a valid point index, fill in
504
+ idx++;
505
+ // If we are at a valid point index, fill in
538
506
  // the value at this node, and the one before (the
539
507
  // two that surround our current sample location)
540
508
  // idx cannot be 0 since we just incremented it.
541
-
542
509
  if (idx < numNodes) {
543
510
  x1 = model.nodes[idx - 1].x;
544
511
  x2 = model.nodes[idx].x;
545
-
546
512
  if (usingLogScale) {
547
513
  x1 = Math.log10(x1);
548
514
  x2 = Math.log10(x2);
549
515
  }
550
-
551
516
  rgb1[0] = model.nodes[idx - 1].r;
552
517
  rgb2[0] = model.nodes[idx].r;
553
518
  rgb1[1] = model.nodes[idx - 1].g;
554
519
  rgb2[1] = model.nodes[idx].g;
555
520
  rgb1[2] = model.nodes[idx - 1].b;
556
- rgb2[2] = model.nodes[idx].b; // We only need the previous midpoint and sharpness
557
- // since these control this region
521
+ rgb2[2] = model.nodes[idx].b;
558
522
 
523
+ // We only need the previous midpoint and sharpness
524
+ // since these control this region
559
525
  midpoint = model.nodes[idx - 1].midpoint;
560
- sharpness = model.nodes[idx - 1].sharpness; // Move midpoint away from extreme ends of range to avoid
561
- // degenerate math
526
+ sharpness = model.nodes[idx - 1].sharpness;
562
527
 
528
+ // Move midpoint away from extreme ends of range to avoid
529
+ // degenerate math
563
530
  if (midpoint < 0.00001) {
564
531
  midpoint = 0.00001;
565
532
  }
566
-
567
533
  if (midpoint > 0.99999) {
568
534
  midpoint = 0.99999;
569
535
  }
570
536
  }
571
- } // Are we at or past the end? If so, just use the last value
572
-
537
+ }
573
538
 
539
+ // Are we at or past the end? If so, just use the last value
574
540
  if (x > model.mappingRange[1]) {
575
541
  table[tidx] = 0.0;
576
542
  table[tidx + 1] = 0.0;
577
543
  table[tidx + 2] = 0.0;
578
-
579
544
  if (model.clamping) {
580
545
  if (publicAPI.getUseAboveRangeColor()) {
581
546
  table[tidx] = model.aboveRangeColor[0];
@@ -593,7 +558,6 @@ function vtkColorTransferFunction(publicAPI, model) {
593
558
  table[tidx] = 0.0;
594
559
  table[tidx + 1] = 0.0;
595
560
  table[tidx + 2] = 0.0;
596
-
597
561
  if (model.clamping) {
598
562
  if (publicAPI.getUseBelowRangeColor()) {
599
563
  table[tidx] = model.belowRangeColor[0];
@@ -621,23 +585,22 @@ function vtkColorTransferFunction(publicAPI, model) {
621
585
  // we will be modifying this based on midpoint and
622
586
  // sharpness to get the curve shape we want and to have
623
587
  // it pass through (y1+y2)/2 at the midpoint.
624
- var s = 0.0;
625
-
588
+ let s = 0.0;
626
589
  if (usingLogScale) {
627
590
  s = (logX - x1) / (x2 - x1);
628
591
  } else {
629
592
  s = (x - x1) / (x2 - x1);
630
- } // Readjust based on the midpoint - linear adjustment
631
-
593
+ }
632
594
 
595
+ // Readjust based on the midpoint - linear adjustment
633
596
  if (s < midpoint) {
634
597
  s = 0.5 * s / midpoint;
635
598
  } else {
636
599
  s = 0.5 + 0.5 * (s - midpoint) / (1.0 - midpoint);
637
- } // override for sharpness > 0.99
638
- // In this case we just want piecewise constant
639
-
600
+ }
640
601
 
602
+ // override for sharpness > 0.99
603
+ // In this case we just want piecewise constant
641
604
  if (sharpness > 0.99) {
642
605
  // Use the first value since we are below the midpoint
643
606
  if (s < 0.5) {
@@ -652,10 +615,10 @@ function vtkColorTransferFunction(publicAPI, model) {
652
615
  table[tidx + 2] = rgb2[2];
653
616
  continue;
654
617
  }
655
- } // Override for sharpness < 0.01
656
- // In this case we want piecewise linear
657
-
618
+ }
658
619
 
620
+ // Override for sharpness < 0.01
621
+ // In this case we want piecewise linear
659
622
  if (sharpness < 0.01) {
660
623
  // Simple linear interpolation
661
624
  if (model.colorSpace === ColorSpace.RGB) {
@@ -663,11 +626,10 @@ function vtkColorTransferFunction(publicAPI, model) {
663
626
  table[tidx + 1] = (1 - s) * rgb1[1] + s * rgb2[1];
664
627
  table[tidx + 2] = (1 - s) * rgb1[2] + s * rgb2[2];
665
628
  } else if (model.colorSpace === ColorSpace.HSV) {
666
- var hsv1 = [];
667
- var hsv2 = [];
629
+ const hsv1 = [];
630
+ const hsv2 = [];
668
631
  rgb2hsv(rgb1, hsv1);
669
632
  rgb2hsv(rgb2, hsv2);
670
-
671
633
  if (model.hSVWrap && (hsv1[0] - hsv2[0] > 0.5 || hsv2[0] - hsv1[0] > 0.5)) {
672
634
  if (hsv1[0] > hsv2[0]) {
673
635
  hsv1[0] -= 1.0;
@@ -675,31 +637,30 @@ function vtkColorTransferFunction(publicAPI, model) {
675
637
  hsv2[0] -= 1.0;
676
638
  }
677
639
  }
678
-
679
- var hsvTmp = [];
640
+ const hsvTmp = [];
680
641
  hsvTmp[0] = (1.0 - s) * hsv1[0] + s * hsv2[0];
681
-
682
642
  if (hsvTmp[0] < 0.0) {
683
643
  hsvTmp[0] += 1.0;
684
644
  }
685
-
686
645
  hsvTmp[1] = (1.0 - s) * hsv1[1] + s * hsv2[1];
687
- hsvTmp[2] = (1.0 - s) * hsv1[2] + s * hsv2[2]; // Now convert this back to RGB
646
+ hsvTmp[2] = (1.0 - s) * hsv1[2] + s * hsv2[2];
688
647
 
648
+ // Now convert this back to RGB
689
649
  hsv2rgb(hsvTmp, tmpVec);
690
650
  table[tidx] = tmpVec[0];
691
651
  table[tidx + 1] = tmpVec[1];
692
652
  table[tidx + 2] = tmpVec[2];
693
653
  } else if (model.colorSpace === ColorSpace.LAB) {
694
- var lab1 = [];
695
- var lab2 = [];
654
+ const lab1 = [];
655
+ const lab2 = [];
696
656
  rgb2lab(rgb1, lab1);
697
657
  rgb2lab(rgb2, lab2);
698
- var labTmp = [];
658
+ const labTmp = [];
699
659
  labTmp[0] = (1 - s) * lab1[0] + s * lab2[0];
700
660
  labTmp[1] = (1 - s) * lab1[1] + s * lab2[1];
701
- labTmp[2] = (1 - s) * lab1[2] + s * lab2[2]; // Now convert back to RGB
661
+ labTmp[2] = (1 - s) * lab1[2] + s * lab2[2];
702
662
 
663
+ // Now convert back to RGB
703
664
  lab2rgb(labTmp, tmpVec);
704
665
  table[tidx] = tmpVec[0];
705
666
  table[tidx + 1] = tmpVec[1];
@@ -712,90 +673,85 @@ function vtkColorTransferFunction(publicAPI, model) {
712
673
  } else {
713
674
  vtkErrorMacro('ColorSpace set to invalid value.', model.colorSpace);
714
675
  }
715
-
716
676
  continue;
717
- } // We have a sharpness between [0.01, 0.99] - we will
677
+ }
678
+
679
+ // We have a sharpness between [0.01, 0.99] - we will
718
680
  // used a modified hermite curve interpolation where we
719
681
  // derive the slope based on the sharpness, and we compress
720
682
  // the curve non-linearly based on the sharpness
683
+
721
684
  // First, we will adjust our position based on sharpness in
722
685
  // order to make the curve sharper (closer to piecewise constant)
723
-
724
-
725
686
  if (s < 0.5) {
726
- s = 0.5 * Math.pow(s * 2.0, 1.0 + 10.0 * sharpness);
687
+ s = 0.5 * (s * 2.0) ** (1.0 + 10.0 * sharpness);
727
688
  } else if (s > 0.5) {
728
- s = 1.0 - 0.5 * Math.pow((1.0 - s) * 2, 1 + 10.0 * sharpness);
729
- } // Compute some coefficients we will need for the hermite curve
730
-
731
-
732
- var ss = s * s;
733
- var sss = ss * s;
734
- var h1 = 2.0 * sss - 3 * ss + 1;
735
- var h2 = -2 * sss + 3 * ss;
736
- var h3 = sss - 2 * ss + s;
737
- var h4 = sss - ss;
738
- var slope = void 0;
739
- var t = void 0;
689
+ s = 1.0 - 0.5 * ((1.0 - s) * 2) ** (1 + 10.0 * sharpness);
690
+ }
740
691
 
692
+ // Compute some coefficients we will need for the hermite curve
693
+ const ss = s * s;
694
+ const sss = ss * s;
695
+ const h1 = 2.0 * sss - 3 * ss + 1;
696
+ const h2 = -2 * sss + 3 * ss;
697
+ const h3 = sss - 2 * ss + s;
698
+ const h4 = sss - ss;
699
+ let slope;
700
+ let t;
741
701
  if (model.colorSpace === ColorSpace.RGB) {
742
- for (var j = 0; j < 3; j++) {
702
+ for (let j = 0; j < 3; j++) {
743
703
  // Use one slope for both end points
744
704
  slope = rgb2[j] - rgb1[j];
745
- t = (1.0 - sharpness) * slope; // Compute the value
705
+ t = (1.0 - sharpness) * slope;
746
706
 
707
+ // Compute the value
747
708
  table[tidx + j] = h1 * rgb1[j] + h2 * rgb2[j] + h3 * t + h4 * t;
748
709
  }
749
710
  } else if (model.colorSpace === ColorSpace.HSV) {
750
- var _hsv = [];
751
- var _hsv2 = [];
752
- rgb2hsv(rgb1, _hsv);
753
- rgb2hsv(rgb2, _hsv2);
754
-
755
- if (model.hSVWrap && (_hsv[0] - _hsv2[0] > 0.5 || _hsv2[0] - _hsv[0] > 0.5)) {
756
- if (_hsv[0] > _hsv2[0]) {
757
- _hsv[0] -= 1.0;
711
+ const hsv1 = [];
712
+ const hsv2 = [];
713
+ rgb2hsv(rgb1, hsv1);
714
+ rgb2hsv(rgb2, hsv2);
715
+ if (model.hSVWrap && (hsv1[0] - hsv2[0] > 0.5 || hsv2[0] - hsv1[0] > 0.5)) {
716
+ if (hsv1[0] > hsv2[0]) {
717
+ hsv1[0] -= 1.0;
758
718
  } else {
759
- _hsv2[0] -= 1.0;
719
+ hsv2[0] -= 1.0;
760
720
  }
761
721
  }
762
-
763
- var _hsvTmp = [];
764
-
765
- for (var _j = 0; _j < 3; _j++) {
722
+ const hsvTmp = [];
723
+ for (let j = 0; j < 3; j++) {
766
724
  // Use one slope for both end points
767
- slope = _hsv2[_j] - _hsv[_j];
768
- t = (1.0 - sharpness) * slope; // Compute the value
769
-
770
- _hsvTmp[_j] = h1 * _hsv[_j] + h2 * _hsv2[_j] + h3 * t + h4 * t;
725
+ slope = hsv2[j] - hsv1[j];
726
+ t = (1.0 - sharpness) * slope;
771
727
 
772
- if (_j === 0 && _hsvTmp[_j] < 0.0) {
773
- _hsvTmp[_j] += 1.0;
728
+ // Compute the value
729
+ hsvTmp[j] = h1 * hsv1[j] + h2 * hsv2[j] + h3 * t + h4 * t;
730
+ if (j === 0 && hsvTmp[j] < 0.0) {
731
+ hsvTmp[j] += 1.0;
774
732
  }
775
- } // Now convert this back to RGB
776
-
777
-
778
- hsv2rgb(_hsvTmp, tmpVec);
733
+ }
734
+ // Now convert this back to RGB
735
+ hsv2rgb(hsvTmp, tmpVec);
779
736
  table[tidx] = tmpVec[0];
780
737
  table[tidx + 1] = tmpVec[1];
781
738
  table[tidx + 2] = tmpVec[2];
782
739
  } else if (model.colorSpace === ColorSpace.LAB) {
783
- var _lab = [];
784
- var _lab2 = [];
785
- rgb2lab(rgb1, _lab);
786
- rgb2lab(rgb2, _lab2);
787
- var _labTmp = [];
788
-
789
- for (var _j2 = 0; _j2 < 3; _j2++) {
740
+ const lab1 = [];
741
+ const lab2 = [];
742
+ rgb2lab(rgb1, lab1);
743
+ rgb2lab(rgb2, lab2);
744
+ const labTmp = [];
745
+ for (let j = 0; j < 3; j++) {
790
746
  // Use one slope for both end points
791
- slope = _lab2[_j2] - _lab[_j2];
792
- t = (1.0 - sharpness) * slope; // Compute the value
793
-
794
- _labTmp[_j2] = h1 * _lab[_j2] + h2 * _lab2[_j2] + h3 * t + h4 * t;
795
- } // Now convert this back to RGB
796
-
747
+ slope = lab2[j] - lab1[j];
748
+ t = (1.0 - sharpness) * slope;
797
749
 
798
- lab2rgb(_labTmp, tmpVec);
750
+ // Compute the value
751
+ labTmp[j] = h1 * lab1[j] + h2 * lab2[j] + h3 * t + h4 * t;
752
+ }
753
+ // Now convert this back to RGB
754
+ lab2rgb(labTmp, tmpVec);
799
755
  table[tidx] = tmpVec[0];
800
756
  table[tidx + 1] = tmpVec[1];
801
757
  table[tidx + 2] = tmpVec[2];
@@ -809,60 +765,50 @@ function vtkColorTransferFunction(publicAPI, model) {
809
765
  table[tidx + 2] = tmpVec[2];
810
766
  } else {
811
767
  vtkErrorMacro('ColorSpace set to invalid value.');
812
- } // Final error check to make sure we don't go outside [0,1]
813
-
768
+ }
814
769
 
815
- for (var _j3 = 0; _j3 < 3; _j3++) {
816
- table[tidx + _j3] = table[tidx + _j3] < 0.0 ? 0.0 : table[tidx + _j3];
817
- table[tidx + _j3] = table[tidx + _j3] > 1.0 ? 1.0 : table[tidx + _j3];
770
+ // Final error check to make sure we don't go outside [0,1]
771
+ for (let j = 0; j < 3; j++) {
772
+ table[tidx + j] = table[tidx + j] < 0.0 ? 0.0 : table[tidx + j];
773
+ table[tidx + j] = table[tidx + j] > 1.0 ? 1.0 : table[tidx + j];
818
774
  }
819
775
  }
820
776
  }
821
- }; //----------------------------------------------------------------------------
822
-
777
+ };
823
778
 
779
+ //----------------------------------------------------------------------------
824
780
  publicAPI.getUint8Table = function (xStart, xEnd, size) {
825
- var withAlpha = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
826
-
781
+ let withAlpha = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
827
782
  if (publicAPI.getMTime() <= model.buildTime && model.tableSize === size && model.tableWithAlpha !== withAlpha) {
828
783
  return model.table;
829
784
  }
830
-
831
785
  if (model.nodes.length === 0) {
832
786
  vtkErrorMacro('Attempting to lookup a value with no points in the function');
833
787
  return model.table;
834
788
  }
835
-
836
- var nbChannels = withAlpha ? 4 : 3;
837
-
789
+ const nbChannels = withAlpha ? 4 : 3;
838
790
  if (model.tableSize !== size || model.tableWithAlpha !== withAlpha) {
839
791
  model.table = new Uint8Array(size * nbChannels);
840
792
  model.tableSize = size;
841
793
  model.tableWithAlpha = withAlpha;
842
794
  }
843
-
844
- var tmpTable = [];
795
+ const tmpTable = [];
845
796
  publicAPI.getTable(xStart, xEnd, size, tmpTable);
846
-
847
- for (var i = 0; i < size; i++) {
797
+ for (let i = 0; i < size; i++) {
848
798
  model.table[i * nbChannels + 0] = Math.floor(tmpTable[i * 3 + 0] * 255.0 + 0.5);
849
799
  model.table[i * nbChannels + 1] = Math.floor(tmpTable[i * 3 + 1] * 255.0 + 0.5);
850
800
  model.table[i * nbChannels + 2] = Math.floor(tmpTable[i * 3 + 2] * 255.0 + 0.5);
851
-
852
801
  if (withAlpha) {
853
802
  model.table[i * nbChannels + 3] = 255;
854
803
  }
855
804
  }
856
-
857
805
  model.buildTime.modified();
858
806
  return model.table;
859
807
  };
860
-
861
- publicAPI.buildFunctionFromArray = function (array) {
808
+ publicAPI.buildFunctionFromArray = array => {
862
809
  publicAPI.removeAllPoints();
863
- var numComponents = array.getNumberOfComponents();
864
-
865
- for (var i = 0; i < array.getNumberOfTuples(); i++) {
810
+ const numComponents = array.getNumberOfComponents();
811
+ for (let i = 0; i < array.getNumberOfTuples(); i++) {
866
812
  switch (numComponents) {
867
813
  case 3:
868
814
  {
@@ -876,7 +822,6 @@ function vtkColorTransferFunction(publicAPI, model) {
876
822
  });
877
823
  break;
878
824
  }
879
-
880
825
  case 4:
881
826
  {
882
827
  model.nodes.push({
@@ -889,7 +834,6 @@ function vtkColorTransferFunction(publicAPI, model) {
889
834
  });
890
835
  break;
891
836
  }
892
-
893
837
  case 5:
894
838
  {
895
839
  model.nodes.push({
@@ -902,7 +846,6 @@ function vtkColorTransferFunction(publicAPI, model) {
902
846
  });
903
847
  break;
904
848
  }
905
-
906
849
  case 6:
907
850
  {
908
851
  model.nodes.push({
@@ -917,21 +860,18 @@ function vtkColorTransferFunction(publicAPI, model) {
917
860
  }
918
861
  }
919
862
  }
920
-
921
863
  publicAPI.sortAndUpdateRange();
922
- }; //----------------------------------------------------------------------------
923
-
864
+ };
924
865
 
925
- publicAPI.buildFunctionFromTable = function (xStart, xEnd, size, table) {
926
- var inc = 0.0;
866
+ //----------------------------------------------------------------------------
867
+ publicAPI.buildFunctionFromTable = (xStart, xEnd, size, table) => {
868
+ let inc = 0.0;
927
869
  publicAPI.removeAllPoints();
928
-
929
870
  if (size > 1) {
930
871
  inc = (xEnd - xStart) / (size - 1.0);
931
872
  }
932
-
933
- for (var i = 0; i < size; i++) {
934
- var node = {
873
+ for (let i = 0; i < size; i++) {
874
+ const node = {
935
875
  x: xStart + inc * i,
936
876
  r: table[i * 3],
937
877
  g: table[i * 3 + 1],
@@ -941,18 +881,16 @@ function vtkColorTransferFunction(publicAPI, model) {
941
881
  };
942
882
  model.nodes.push(node);
943
883
  }
944
-
945
884
  publicAPI.sortAndUpdateRange();
946
- }; //----------------------------------------------------------------------------
947
- // For a specified index value, get the node parameters
948
-
885
+ };
949
886
 
950
- publicAPI.getNodeValue = function (index, val) {
887
+ //----------------------------------------------------------------------------
888
+ // For a specified index value, get the node parameters
889
+ publicAPI.getNodeValue = (index, val) => {
951
890
  if (index < 0 || index >= model.nodes.length) {
952
891
  vtkErrorMacro('Index out of range!');
953
892
  return -1;
954
893
  }
955
-
956
894
  val[0] = model.nodes[index].x;
957
895
  val[1] = model.nodes[index].r;
958
896
  val[2] = model.nodes[index].g;
@@ -960,121 +898,105 @@ function vtkColorTransferFunction(publicAPI, model) {
960
898
  val[4] = model.nodes[index].midpoint;
961
899
  val[5] = model.nodes[index].sharpness;
962
900
  return 1;
963
- }; //----------------------------------------------------------------------------
964
- // For a specified index value, get the node parameters
965
-
901
+ };
966
902
 
967
- publicAPI.setNodeValue = function (index, val) {
903
+ //----------------------------------------------------------------------------
904
+ // For a specified index value, get the node parameters
905
+ publicAPI.setNodeValue = (index, val) => {
968
906
  if (index < 0 || index >= model.nodes.length) {
969
907
  vtkErrorMacro('Index out of range!');
970
908
  return -1;
971
909
  }
972
-
973
- var oldX = model.nodes[index].x;
910
+ const oldX = model.nodes[index].x;
974
911
  model.nodes[index].x = val[0];
975
912
  model.nodes[index].r = val[1];
976
913
  model.nodes[index].g = val[2];
977
914
  model.nodes[index].b = val[3];
978
915
  model.nodes[index].midpoint = val[4];
979
916
  model.nodes[index].sharpness = val[5];
980
-
981
917
  if (oldX !== val[0]) {
982
918
  // The point has been moved, the order of points or the range might have
983
919
  // been modified.
984
- publicAPI.sortAndUpdateRange(); // No need to call Modified() here because SortAndUpdateRange() has done it
920
+ publicAPI.sortAndUpdateRange();
921
+ // No need to call Modified() here because SortAndUpdateRange() has done it
985
922
  // already.
986
923
  } else {
987
924
  publicAPI.modified();
988
925
  }
989
-
990
926
  return 1;
991
- }; //----------------------------------------------------------------------------
992
-
927
+ };
993
928
 
994
- publicAPI.getNumberOfAvailableColors = function () {
929
+ //----------------------------------------------------------------------------
930
+ publicAPI.getNumberOfAvailableColors = () => {
995
931
  if (model.indexedLookup && publicAPI.getSize()) {
996
932
  return publicAPI.getSize();
997
933
  }
998
-
999
934
  if (model.tableSize) {
1000
935
  // Not sure if this is correct since it is only set if
1001
936
  // "const unsigned char *::GetTable(double xStart, double xEnd,int size)"
1002
937
  // has been called.
1003
938
  return model.tableSize;
1004
939
  }
1005
-
1006
940
  return 16777216; // 2^24
1007
- }; //----------------------------------------------------------------------------
1008
-
1009
-
1010
- publicAPI.getIndexedColor = function (idx, rgba) {
1011
- var n = publicAPI.getSize();
941
+ };
1012
942
 
943
+ //----------------------------------------------------------------------------
944
+ publicAPI.getIndexedColor = (idx, rgba) => {
945
+ const n = publicAPI.getSize();
1013
946
  if (n > 0 && idx >= 0) {
1014
- var nodeValue = [];
947
+ const nodeValue = [];
1015
948
  publicAPI.getNodeValue(idx % n, nodeValue);
1016
-
1017
- for (var j = 0; j < 3; ++j) {
949
+ for (let j = 0; j < 3; ++j) {
1018
950
  rgba[j] = nodeValue[j + 1];
1019
951
  }
1020
-
1021
952
  rgba[3] = 1.0; // NodeColor is RGB-only.
1022
-
1023
953
  return;
1024
954
  }
1025
-
1026
- var nanColor = publicAPI.getNanColorByReference();
955
+ const nanColor = publicAPI.getNanColorByReference();
1027
956
  rgba[0] = nanColor[0];
1028
957
  rgba[1] = nanColor[1];
1029
958
  rgba[2] = nanColor[2];
1030
959
  rgba[3] = 1.0; // NanColor is RGB-only.
1031
- }; //----------------------------------------------------------------------------
1032
-
960
+ };
1033
961
 
1034
- publicAPI.fillFromDataPointer = function (nb, ptr) {
962
+ //----------------------------------------------------------------------------
963
+ publicAPI.fillFromDataPointer = (nb, ptr) => {
1035
964
  if (nb <= 0 || !ptr) {
1036
965
  return;
1037
966
  }
1038
-
1039
967
  publicAPI.removeAllPoints();
1040
-
1041
- for (var i = 0; i < nb; i++) {
968
+ for (let i = 0; i < nb; i++) {
1042
969
  publicAPI.addRGBPoint(ptr[i * 4], ptr[i * 4 + 1], ptr[i * 4 + 2], ptr[i * 4 + 3]);
1043
970
  }
1044
- }; //----------------------------------------------------------------------------
1045
-
1046
-
1047
- publicAPI.setMappingRange = function (min, max) {
1048
- var range = [min, max];
1049
- var originalRange = publicAPI.getRange();
971
+ };
1050
972
 
973
+ //----------------------------------------------------------------------------
974
+ publicAPI.setMappingRange = (min, max) => {
975
+ const range = [min, max];
976
+ const originalRange = publicAPI.getRange();
1051
977
  if (originalRange[1] === range[1] && originalRange[0] === range[0]) {
1052
978
  return;
1053
979
  }
1054
-
1055
980
  if (range[1] === range[0]) {
1056
981
  vtkErrorMacro('attempt to set zero width color range');
1057
982
  return;
1058
983
  }
1059
-
1060
- var scale = (range[1] - range[0]) / (originalRange[1] - originalRange[0]);
1061
- var shift = range[0] - originalRange[0] * scale;
1062
-
1063
- for (var i = 0; i < model.nodes.length; ++i) {
984
+ const scale = (range[1] - range[0]) / (originalRange[1] - originalRange[0]);
985
+ const shift = range[0] - originalRange[0] * scale;
986
+ for (let i = 0; i < model.nodes.length; ++i) {
1064
987
  model.nodes[i].x = model.nodes[i].x * scale + shift;
1065
988
  }
1066
-
1067
989
  model.mappingRange[0] = range[0];
1068
990
  model.mappingRange[1] = range[1];
1069
991
  publicAPI.modified();
1070
- }; //----------------------------------------------------------------------------
1071
-
1072
-
1073
- publicAPI.adjustRange = function (range) {
1074
- var functionRange = publicAPI.getRange(); // Make sure we have points at each end of the range
992
+ };
1075
993
 
1076
- var rgb = [];
994
+ //----------------------------------------------------------------------------
995
+ publicAPI.adjustRange = range => {
996
+ const functionRange = publicAPI.getRange();
1077
997
 
998
+ // Make sure we have points at each end of the range
999
+ const rgb = [];
1078
1000
  if (functionRange[0] < range[0]) {
1079
1001
  publicAPI.getColor(range[0], rgb);
1080
1002
  publicAPI.addRGBPoint(range[0], rgb[0], rgb[1], rgb[2]);
@@ -1082,84 +1004,73 @@ function vtkColorTransferFunction(publicAPI, model) {
1082
1004
  publicAPI.getColor(functionRange[0], rgb);
1083
1005
  publicAPI.addRGBPoint(range[0], rgb[0], rgb[1], rgb[2]);
1084
1006
  }
1085
-
1086
1007
  if (functionRange[1] > range[1]) {
1087
1008
  publicAPI.getColor(range[1], rgb);
1088
1009
  publicAPI.addRGBPoint(range[1], rgb[0], rgb[1], rgb[2]);
1089
1010
  } else {
1090
1011
  publicAPI.getColor(functionRange[1], rgb);
1091
1012
  publicAPI.addRGBPoint(range[1], rgb[0], rgb[1], rgb[2]);
1092
- } // Remove all points out-of-range
1093
-
1013
+ }
1094
1014
 
1015
+ // Remove all points out-of-range
1095
1016
  publicAPI.sortAndUpdateRange();
1096
-
1097
- for (var i = 0; i < model.nodes.length;) {
1017
+ for (let i = 0; i < model.nodes.length;) {
1098
1018
  if (model.nodes[i].x >= range[0] && model.nodes[i].x <= range[1]) {
1099
1019
  model.nodes.splice(i, 1);
1100
1020
  } else {
1101
1021
  ++i;
1102
1022
  }
1103
1023
  }
1104
-
1105
1024
  return 1;
1106
- }; //--------------------------------------------------------------------------
1107
-
1025
+ };
1108
1026
 
1109
- publicAPI.estimateMinNumberOfSamples = function (x1, x2) {
1110
- var d = publicAPI.findMinimumXDistance();
1027
+ //--------------------------------------------------------------------------
1028
+ publicAPI.estimateMinNumberOfSamples = (x1, x2) => {
1029
+ const d = publicAPI.findMinimumXDistance();
1111
1030
  return Math.ceil((x2 - x1) / d);
1112
- }; //----------------------------------------------------------------------------
1113
-
1031
+ };
1114
1032
 
1115
- publicAPI.findMinimumXDistance = function () {
1033
+ //----------------------------------------------------------------------------
1034
+ publicAPI.findMinimumXDistance = () => {
1116
1035
  if (model.nodes.length < 2) {
1117
1036
  return -1.0;
1118
1037
  }
1119
-
1120
- var distance = Number.MAX_VALUE;
1121
-
1122
- for (var i = 0; i < model.nodes.length - 1; i++) {
1123
- var currentDist = model.nodes[i + 1].x - model.nodes[i].x;
1124
-
1038
+ let distance = Number.MAX_VALUE;
1039
+ for (let i = 0; i < model.nodes.length - 1; i++) {
1040
+ const currentDist = model.nodes[i + 1].x - model.nodes[i].x;
1125
1041
  if (currentDist < distance) {
1126
1042
  distance = currentDist;
1127
1043
  }
1128
1044
  }
1129
-
1130
1045
  return distance;
1131
1046
  };
1132
-
1133
- publicAPI.mapScalarsThroughTable = function (input, output, outFormat, inputOffset) {
1047
+ publicAPI.mapScalarsThroughTable = (input, output, outFormat, inputOffset) => {
1134
1048
  if (publicAPI.getSize() === 0) {
1135
1049
  vtkDebugMacro('Transfer Function Has No Points!');
1136
1050
  return;
1137
1051
  }
1138
-
1139
1052
  if (model.indexedLookup) {
1140
1053
  publicAPI.mapDataIndexed(input, output, outFormat, inputOffset);
1141
1054
  } else {
1142
1055
  publicAPI.mapData(input, output, outFormat, inputOffset);
1143
1056
  }
1144
- }; //----------------------------------------------------------------------------
1145
-
1057
+ };
1146
1058
 
1147
- publicAPI.mapData = function (input, output, outFormat, inputOffset) {
1059
+ //----------------------------------------------------------------------------
1060
+ publicAPI.mapData = (input, output, outFormat, inputOffset) => {
1148
1061
  if (publicAPI.getSize() === 0) {
1149
1062
  vtkWarningMacro('Transfer Function Has No Points!');
1150
1063
  return;
1151
1064
  }
1152
-
1153
- var alpha = Math.floor(publicAPI.getAlpha() * 255.0 + 0.5);
1154
- var length = input.getNumberOfTuples();
1155
- var inIncr = input.getNumberOfComponents();
1156
- var outputV = output.getData();
1157
- var inputV = input.getData();
1158
- var rgb = [];
1159
-
1065
+ const alpha = Math.floor(publicAPI.getAlpha() * 255.0 + 0.5);
1066
+ const length = input.getNumberOfTuples();
1067
+ const inIncr = input.getNumberOfComponents();
1068
+ const outputV = output.getData();
1069
+ const inputV = input.getData();
1070
+ const rgb = [];
1160
1071
  if (outFormat === ScalarMappingTarget.RGBA) {
1161
- for (var i = 0; i < length; i++) {
1162
- var x = inputV[i * inIncr + inputOffset];
1072
+ for (let i = 0; i < length; i++) {
1073
+ const x = inputV[i * inIncr + inputOffset];
1163
1074
  publicAPI.getColor(x, rgb);
1164
1075
  outputV[i * 4] = Math.floor(rgb[0] * 255.0 + 0.5);
1165
1076
  outputV[i * 4 + 1] = Math.floor(rgb[1] * 255.0 + 0.5);
@@ -1167,91 +1078,80 @@ function vtkColorTransferFunction(publicAPI, model) {
1167
1078
  outputV[i * 4 + 3] = alpha;
1168
1079
  }
1169
1080
  }
1170
-
1171
1081
  if (outFormat === ScalarMappingTarget.RGB) {
1172
- for (var _i2 = 0; _i2 < length; _i2++) {
1173
- var _x = inputV[_i2 * inIncr + inputOffset];
1174
- publicAPI.getColor(_x, rgb);
1175
- outputV[_i2 * 3] = Math.floor(rgb[0] * 255.0 + 0.5);
1176
- outputV[_i2 * 3 + 1] = Math.floor(rgb[1] * 255.0 + 0.5);
1177
- outputV[_i2 * 3 + 2] = Math.floor(rgb[2] * 255.0 + 0.5);
1082
+ for (let i = 0; i < length; i++) {
1083
+ const x = inputV[i * inIncr + inputOffset];
1084
+ publicAPI.getColor(x, rgb);
1085
+ outputV[i * 3] = Math.floor(rgb[0] * 255.0 + 0.5);
1086
+ outputV[i * 3 + 1] = Math.floor(rgb[1] * 255.0 + 0.5);
1087
+ outputV[i * 3 + 2] = Math.floor(rgb[2] * 255.0 + 0.5);
1178
1088
  }
1179
1089
  }
1180
-
1181
1090
  if (outFormat === ScalarMappingTarget.LUMINANCE) {
1182
- for (var _i3 = 0; _i3 < length; _i3++) {
1183
- var _x2 = inputV[_i3 * inIncr + inputOffset];
1184
- publicAPI.getColor(_x2, rgb);
1185
- outputV[_i3] = Math.floor(rgb[0] * 76.5 + rgb[1] * 150.45 + rgb[2] * 28.05 + 0.5);
1091
+ for (let i = 0; i < length; i++) {
1092
+ const x = inputV[i * inIncr + inputOffset];
1093
+ publicAPI.getColor(x, rgb);
1094
+ outputV[i] = Math.floor(rgb[0] * 76.5 + rgb[1] * 150.45 + rgb[2] * 28.05 + 0.5);
1186
1095
  }
1187
1096
  }
1188
-
1189
1097
  if (outFormat === ScalarMappingTarget.LUMINANCE_ALPHA) {
1190
- for (var _i4 = 0; _i4 < length; _i4++) {
1191
- var _x3 = inputV[_i4 * inIncr + inputOffset];
1192
- publicAPI.getColor(_x3, rgb);
1193
- outputV[_i4 * 2] = Math.floor(rgb[0] * 76.5 + rgb[1] * 150.45 + rgb[2] * 28.05 + 0.5);
1194
- outputV[_i4 * 2 + 1] = alpha;
1098
+ for (let i = 0; i < length; i++) {
1099
+ const x = inputV[i * inIncr + inputOffset];
1100
+ publicAPI.getColor(x, rgb);
1101
+ outputV[i * 2] = Math.floor(rgb[0] * 76.5 + rgb[1] * 150.45 + rgb[2] * 28.05 + 0.5);
1102
+ outputV[i * 2 + 1] = alpha;
1195
1103
  }
1196
1104
  }
1197
- }; //----------------------------------------------------------------------------
1198
-
1199
-
1200
- publicAPI.applyColorMap = function (colorMap) {
1201
- var oldColorSpace = JSON.stringify(model.colorSpace);
1105
+ };
1202
1106
 
1107
+ //----------------------------------------------------------------------------
1108
+ publicAPI.applyColorMap = colorMap => {
1109
+ const oldColorSpace = JSON.stringify(model.colorSpace);
1203
1110
  if (colorMap.ColorSpace) {
1204
1111
  model.colorSpace = ColorSpace[colorMap.ColorSpace.toUpperCase()];
1205
-
1206
1112
  if (model.colorSpace === undefined) {
1207
- vtkErrorMacro("ColorSpace ".concat(colorMap.ColorSpace, " not supported, using RGB instead"));
1113
+ vtkErrorMacro(`ColorSpace ${colorMap.ColorSpace} not supported, using RGB instead`);
1208
1114
  model.colorSpace = ColorSpace.RGB;
1209
1115
  }
1210
1116
  }
1211
-
1212
- var isModified = oldColorSpace !== JSON.stringify(model.colorSpace);
1213
- var oldNanColor = isModified || JSON.stringify(model.nanColor);
1214
-
1117
+ let isModified = oldColorSpace !== JSON.stringify(model.colorSpace);
1118
+ const oldNanColor = isModified || JSON.stringify(model.nanColor);
1215
1119
  if (colorMap.NanColor) {
1216
1120
  model.nanColor = [].concat(colorMap.NanColor);
1217
-
1218
1121
  while (model.nanColor.length < 4) {
1219
1122
  model.nanColor.push(1.0);
1220
1123
  }
1221
1124
  }
1222
-
1223
1125
  isModified = isModified || oldNanColor !== JSON.stringify(model.nanColor);
1224
- var oldNodes = isModified || JSON.stringify(model.nodes);
1225
-
1126
+ const oldNodes = isModified || JSON.stringify(model.nodes);
1226
1127
  if (colorMap.RGBPoints) {
1227
- var size = colorMap.RGBPoints.length;
1128
+ const size = colorMap.RGBPoints.length;
1228
1129
  model.nodes = [];
1229
- var midpoint = 0.5;
1230
- var sharpness = 0.0;
1231
-
1232
- for (var i = 0; i < size; i += 4) {
1130
+ const midpoint = 0.5;
1131
+ const sharpness = 0.0;
1132
+ for (let i = 0; i < size; i += 4) {
1233
1133
  model.nodes.push({
1234
1134
  x: colorMap.RGBPoints[i],
1235
1135
  r: colorMap.RGBPoints[i + 1],
1236
1136
  g: colorMap.RGBPoints[i + 2],
1237
1137
  b: colorMap.RGBPoints[i + 3],
1238
- midpoint: midpoint,
1239
- sharpness: sharpness
1138
+ midpoint,
1139
+ sharpness
1240
1140
  });
1241
1141
  }
1242
1142
  }
1243
-
1244
- var modifiedInvoked = publicAPI.sortAndUpdateRange();
1245
- var callModified = !modifiedInvoked && (isModified || oldNodes !== JSON.stringify(model.nodes));
1143
+ const modifiedInvoked = publicAPI.sortAndUpdateRange();
1144
+ const callModified = !modifiedInvoked && (isModified || oldNodes !== JSON.stringify(model.nodes));
1246
1145
  if (callModified) publicAPI.modified();
1247
1146
  return modifiedInvoked || callModified;
1248
1147
  };
1249
- } // ----------------------------------------------------------------------------
1148
+ }
1149
+
1150
+ // ----------------------------------------------------------------------------
1250
1151
  // Object factory
1251
1152
  // ----------------------------------------------------------------------------
1252
1153
 
1253
-
1254
- var DEFAULT_VALUES = {
1154
+ const DEFAULT_VALUES = {
1255
1155
  clamping: true,
1256
1156
  colorSpace: ColorSpace.RGB,
1257
1157
  hSVWrap: true,
@@ -1268,38 +1168,52 @@ var DEFAULT_VALUES = {
1268
1168
  nodes: null,
1269
1169
  discretize: false,
1270
1170
  numberOfValues: 256
1271
- }; // ----------------------------------------------------------------------------
1171
+ };
1172
+
1173
+ // ----------------------------------------------------------------------------
1272
1174
 
1273
1175
  function extend(publicAPI, model) {
1274
- var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1275
- Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance
1176
+ let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1177
+ Object.assign(model, DEFAULT_VALUES, initialValues);
1276
1178
 
1277
- vtkScalarsToColors.extend(publicAPI, model, initialValues); // Internal objects initialization
1179
+ // Inheritance
1180
+ vtkScalarsToColors.extend(publicAPI, model, initialValues);
1278
1181
 
1182
+ // Internal objects initialization
1279
1183
  model.table = [];
1280
1184
  model.nodes = [];
1281
1185
  model.nanColor = [0.5, 0.0, 0.0, 1.0];
1282
1186
  model.belowRangeColor = [0.0, 0.0, 0.0, 1.0];
1283
1187
  model.aboveRangeColor = [1.0, 1.0, 1.0, 1.0];
1284
1188
  model.buildTime = {};
1285
- macro.obj(model.buildTime); // Create get-only macros
1189
+ macro.obj(model.buildTime);
1286
1190
 
1287
- macro.get(publicAPI, model, ['buildTime', 'mappingRange']); // Create get-set macros
1191
+ // Create get-only macros
1192
+ macro.get(publicAPI, model, ['buildTime', 'mappingRange']);
1288
1193
 
1194
+ // Create get-set macros
1289
1195
  macro.setGet(publicAPI, model, ['useAboveRangeColor', 'useBelowRangeColor', 'colorSpace', 'discretize', 'numberOfValues']);
1290
- macro.setArray(publicAPI, model, ['nanColor', 'belowRangeColor', 'aboveRangeColor'], 4); // Create get macros for array
1196
+ macro.setArray(publicAPI, model, ['nanColor', 'belowRangeColor', 'aboveRangeColor'], 4);
1291
1197
 
1292
- macro.getArray(publicAPI, model, ['nanColor', 'belowRangeColor', 'aboveRangeColor']); // For more macro methods, see "Sources/macros.js"
1293
- // Object specific methods
1198
+ // Create get macros for array
1199
+ macro.getArray(publicAPI, model, ['nanColor', 'belowRangeColor', 'aboveRangeColor']);
1200
+
1201
+ // For more macro methods, see "Sources/macros.js"
1294
1202
 
1203
+ // Object specific methods
1295
1204
  vtkColorTransferFunction(publicAPI, model);
1296
- } // ----------------------------------------------------------------------------
1205
+ }
1297
1206
 
1298
- var newInstance = macro.newInstance(extend, 'vtkColorTransferFunction'); // ----------------------------------------------------------------------------
1207
+ // ----------------------------------------------------------------------------
1208
+
1209
+ const newInstance = macro.newInstance(extend, 'vtkColorTransferFunction');
1210
+
1211
+ // ----------------------------------------------------------------------------
1299
1212
 
1300
- var vtkColorTransferFunction$1 = _objectSpread({
1301
- newInstance: newInstance,
1302
- extend: extend
1303
- }, Constants);
1213
+ var vtkColorTransferFunction$1 = {
1214
+ newInstance,
1215
+ extend,
1216
+ ...Constants
1217
+ };
1304
1218
 
1305
1219
  export { vtkColorTransferFunction$1 as default, extend, newInstance };