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