@kitware/vtk.js 28.10.1 → 28.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +185 -270
- 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 +778 -903
- package/Common/Core/Math.d.ts +14 -0
- 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/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 +92 -170
- 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 +193 -257
- 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 +444 -609
- 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 +41 -39
- 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 +134 -210
- package/Widgets/Widgets3D/ResliceCursorWidget/cprBehavior.js +26 -41
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +90 -117
- 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
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
3
|
-
import { newInstance as newInstance$1, obj, get, vtkErrorMacro as vtkErrorMacro$1 } from '../../macros.js';
|
|
1
|
+
import { n as newInstance$1, o as obj, g as get, c as macro } from '../../macros2.js';
|
|
4
2
|
import { mat4, mat3, vec3 } from 'gl-matrix';
|
|
5
3
|
import vtkClosedPolyLineToSurfaceFilter from '../../Filters/General/ClosedPolyLineToSurfaceFilter.js';
|
|
6
4
|
import vtkCutter from '../../Filters/Core/Cutter.js';
|
|
@@ -23,70 +21,64 @@ import { Representation } from '../Core/Property/Constants.js';
|
|
|
23
21
|
import { VtkDataTypes } from '../../Common/Core/DataArray/Constants.js';
|
|
24
22
|
import { registerOverride } from './ViewNodeFactory.js';
|
|
25
23
|
|
|
26
|
-
|
|
24
|
+
const {
|
|
25
|
+
vtkErrorMacro
|
|
26
|
+
} = macro;
|
|
27
|
+
|
|
28
|
+
// ----------------------------------------------------------------------------
|
|
27
29
|
// helper methods
|
|
28
30
|
// ----------------------------------------------------------------------------
|
|
29
31
|
|
|
30
32
|
function computeFnToString(property, fn, numberOfComponents) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
const pwfun = fn.apply(property);
|
|
33
34
|
if (pwfun) {
|
|
34
|
-
|
|
35
|
-
return
|
|
35
|
+
const iComps = property.getIndependentComponents();
|
|
36
|
+
return `${property.getMTime()}-${iComps}-${numberOfComponents}`;
|
|
36
37
|
}
|
|
37
|
-
|
|
38
38
|
return '0';
|
|
39
39
|
}
|
|
40
|
-
|
|
41
40
|
function safeMatrixMultiply(matrixArray, matrixType, tmpMat) {
|
|
42
41
|
matrixType.identity(tmpMat);
|
|
43
|
-
return matrixArray.reduce(
|
|
42
|
+
return matrixArray.reduce((res, matrix, index) => {
|
|
44
43
|
if (index === 0) {
|
|
45
44
|
return matrix ? matrixType.copy(res, matrix) : matrixType.identity(res);
|
|
46
45
|
}
|
|
47
|
-
|
|
48
46
|
return matrix ? matrixType.multiply(res, res, matrix) : res;
|
|
49
47
|
}, tmpMat);
|
|
50
|
-
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ----------------------------------------------------------------------------
|
|
51
51
|
// vtkOpenGLImageResliceMapper methods
|
|
52
52
|
// ----------------------------------------------------------------------------
|
|
53
53
|
|
|
54
|
-
|
|
55
54
|
function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
56
55
|
// Set our className
|
|
57
56
|
model.classHierarchy.push('vtkOpenGLImageResliceMapper');
|
|
58
|
-
|
|
59
|
-
publicAPI.buildPass = function (prepass) {
|
|
57
|
+
publicAPI.buildPass = prepass => {
|
|
60
58
|
if (prepass) {
|
|
61
59
|
model.currentRenderPass = null;
|
|
62
60
|
model._openGLImageSlice = publicAPI.getFirstAncestorOfType('vtkOpenGLImageSlice');
|
|
63
61
|
model._openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer');
|
|
64
|
-
|
|
65
|
-
var ren = model._openGLRenderer.getRenderable();
|
|
66
|
-
|
|
62
|
+
const ren = model._openGLRenderer.getRenderable();
|
|
67
63
|
model._openGLCamera = model._openGLRenderer.getViewNodeFor(ren.getActiveCamera());
|
|
68
64
|
model._openGLRenderWindow = model._openGLRenderer.getParent();
|
|
69
65
|
model.context = model._openGLRenderWindow.getContext();
|
|
70
66
|
model.tris.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
71
|
-
|
|
72
67
|
if (!model.openGLTexture) {
|
|
73
68
|
model.openGLTexture = vtkOpenGLTexture.newInstance();
|
|
74
69
|
}
|
|
75
|
-
|
|
76
70
|
model.openGLTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
77
71
|
model.colorTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
78
72
|
model.pwfTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
79
73
|
}
|
|
80
74
|
};
|
|
81
|
-
|
|
82
|
-
publicAPI.translucentPass = function (prepass, renderPass) {
|
|
75
|
+
publicAPI.translucentPass = (prepass, renderPass) => {
|
|
83
76
|
if (prepass) {
|
|
84
77
|
model.currentRenderPass = renderPass;
|
|
85
78
|
publicAPI.render();
|
|
86
79
|
}
|
|
87
80
|
};
|
|
88
|
-
|
|
89
|
-
publicAPI.zBufferPass = function (prepass) {
|
|
81
|
+
publicAPI.zBufferPass = prepass => {
|
|
90
82
|
if (prepass) {
|
|
91
83
|
model.haveSeenDepthRequest = true;
|
|
92
84
|
model.renderDepth = true;
|
|
@@ -94,46 +86,35 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
94
86
|
model.renderDepth = false;
|
|
95
87
|
}
|
|
96
88
|
};
|
|
97
|
-
|
|
98
|
-
publicAPI.
|
|
99
|
-
return publicAPI.zBufferPass(prepass);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
publicAPI.opaquePass = function (prepass) {
|
|
89
|
+
publicAPI.opaqueZBufferPass = prepass => publicAPI.zBufferPass(prepass);
|
|
90
|
+
publicAPI.opaquePass = prepass => {
|
|
103
91
|
if (prepass) {
|
|
104
92
|
publicAPI.render();
|
|
105
93
|
}
|
|
106
94
|
};
|
|
107
|
-
|
|
108
|
-
publicAPI.getCoincidentParameters = function (ren, actor) {
|
|
95
|
+
publicAPI.getCoincidentParameters = (ren, actor) => {
|
|
109
96
|
if (model.renderable.getResolveCoincidentTopology()) {
|
|
110
97
|
return model.renderable.getCoincidentTopologyPolygonOffsetParameters();
|
|
111
98
|
}
|
|
112
|
-
|
|
113
99
|
return null;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
publicAPI.render = function () {
|
|
118
|
-
var actor = model._openGLImageSlice.getRenderable();
|
|
119
|
-
|
|
120
|
-
var ren = model._openGLRenderer.getRenderable();
|
|
100
|
+
};
|
|
121
101
|
|
|
102
|
+
// Renders myself
|
|
103
|
+
publicAPI.render = () => {
|
|
104
|
+
const actor = model._openGLImageSlice.getRenderable();
|
|
105
|
+
const ren = model._openGLRenderer.getRenderable();
|
|
122
106
|
publicAPI.renderPiece(ren, actor);
|
|
123
107
|
};
|
|
124
|
-
|
|
125
|
-
publicAPI.renderPiece = function (ren, actor) {
|
|
108
|
+
publicAPI.renderPiece = (ren, actor) => {
|
|
126
109
|
publicAPI.invokeEvent({
|
|
127
110
|
type: 'StartEvent'
|
|
128
111
|
});
|
|
129
112
|
model.renderable.update();
|
|
130
113
|
model.currentInput = model.renderable.getInputData();
|
|
131
|
-
|
|
132
114
|
if (!model.currentInput) {
|
|
133
115
|
vtkErrorMacro('No input!');
|
|
134
116
|
return;
|
|
135
117
|
}
|
|
136
|
-
|
|
137
118
|
publicAPI.updateResliceGeometry();
|
|
138
119
|
publicAPI.renderPieceStart(ren, actor);
|
|
139
120
|
publicAPI.renderPieceDraw(ren, actor);
|
|
@@ -142,12 +123,10 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
142
123
|
type: 'EndEvent'
|
|
143
124
|
});
|
|
144
125
|
};
|
|
145
|
-
|
|
146
|
-
publicAPI.renderPieceStart = function (ren, actor) {
|
|
126
|
+
publicAPI.renderPieceStart = (ren, actor) => {
|
|
147
127
|
// make sure the BOs are up to date
|
|
148
128
|
publicAPI.updateBufferObjects(ren, actor);
|
|
149
|
-
|
|
150
|
-
|
|
129
|
+
const iType = actor.getProperty().getInterpolationType();
|
|
151
130
|
if (iType === InterpolationType.NEAREST) {
|
|
152
131
|
model.openGLTexture.setMinificationFilter(Filter.NEAREST);
|
|
153
132
|
model.openGLTexture.setMagnificationFilter(Filter.NEAREST);
|
|
@@ -162,433 +141,375 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
162
141
|
model.colorTexture.setMagnificationFilter(Filter.LINEAR);
|
|
163
142
|
model.pwfTexture.setMinificationFilter(Filter.LINEAR);
|
|
164
143
|
model.pwfTexture.setMagnificationFilter(Filter.LINEAR);
|
|
165
|
-
}
|
|
166
|
-
|
|
144
|
+
}
|
|
167
145
|
|
|
146
|
+
// No buffer objects bound.
|
|
168
147
|
model.lastBoundBO = null;
|
|
169
148
|
};
|
|
149
|
+
publicAPI.renderPieceDraw = (ren, actor) => {
|
|
150
|
+
const gl = model.context;
|
|
170
151
|
|
|
171
|
-
|
|
172
|
-
var gl = model.context; // render the texture
|
|
173
|
-
|
|
152
|
+
// render the texture
|
|
174
153
|
model.openGLTexture.activate();
|
|
175
154
|
model.colorTexture.activate();
|
|
176
|
-
model.pwfTexture.activate();
|
|
155
|
+
model.pwfTexture.activate();
|
|
177
156
|
|
|
178
|
-
|
|
157
|
+
// update shaders if required
|
|
158
|
+
publicAPI.updateShaders(model.tris, ren, actor);
|
|
179
159
|
|
|
160
|
+
// Finally draw
|
|
180
161
|
gl.drawArrays(gl.TRIANGLES, 0, model.tris.getCABO().getElementCount());
|
|
181
162
|
model.tris.getVAO().release();
|
|
182
163
|
model.openGLTexture.deactivate();
|
|
183
164
|
model.colorTexture.deactivate();
|
|
184
165
|
model.pwfTexture.deactivate();
|
|
185
166
|
};
|
|
186
|
-
|
|
187
|
-
publicAPI.
|
|
188
|
-
|
|
189
|
-
publicAPI.updateBufferObjects = function (ren, actor) {
|
|
167
|
+
publicAPI.renderPieceFinish = (ren, actor) => {};
|
|
168
|
+
publicAPI.updateBufferObjects = (ren, actor) => {
|
|
190
169
|
// Rebuild buffer objects if needed
|
|
191
170
|
if (publicAPI.getNeedToRebuildBufferObjects(ren, actor)) {
|
|
192
171
|
publicAPI.buildBufferObjects(ren, actor);
|
|
193
172
|
}
|
|
194
173
|
};
|
|
195
|
-
|
|
196
|
-
publicAPI.
|
|
197
|
-
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
publicAPI.buildBufferObjects = function (ren, actor) {
|
|
201
|
-
var _image$getPointData;
|
|
202
|
-
|
|
203
|
-
var image = model.currentInput;
|
|
204
|
-
|
|
174
|
+
publicAPI.getNeedToRebuildBufferObjects = (ren, actor) => model.VBOBuildTime.getMTime() < publicAPI.getMTime() || model.VBOBuildTime.getMTime() < actor.getMTime() || model.VBOBuildTime.getMTime() < model.renderable.getMTime() || model.VBOBuildTime.getMTime() < actor.getProperty().getMTime() || model.VBOBuildTime.getMTime() < model.currentInput.getMTime() || model.VBOBuildTime.getMTime() < model.resliceGeom.getMTime();
|
|
175
|
+
publicAPI.buildBufferObjects = (ren, actor) => {
|
|
176
|
+
const image = model.currentInput;
|
|
205
177
|
if (!image) {
|
|
206
178
|
return;
|
|
207
179
|
}
|
|
208
|
-
|
|
209
|
-
var scalars = (_image$getPointData = image.getPointData()) === null || _image$getPointData === void 0 ? void 0 : _image$getPointData.getScalars();
|
|
210
|
-
|
|
180
|
+
const scalars = image.getPointData()?.getScalars();
|
|
211
181
|
if (!scalars) {
|
|
212
182
|
return;
|
|
213
183
|
}
|
|
214
|
-
|
|
215
|
-
var numComp = scalars.getNumberOfComponents();
|
|
216
|
-
|
|
184
|
+
const numComp = scalars.getNumberOfComponents();
|
|
217
185
|
if (!model._externalOpenGLTexture) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (model.openGLTextureString !== _toString) {
|
|
186
|
+
const toString = `${image.getMTime()}A${scalars.getMTime()}`;
|
|
187
|
+
if (model.openGLTextureString !== toString) {
|
|
221
188
|
// Build the image scalar texture
|
|
222
|
-
|
|
223
|
-
|
|
189
|
+
const dims = image.getDimensions();
|
|
190
|
+
// Use norm16 for the 3D texture if the extension is available
|
|
224
191
|
model.openGLTexture.getOglNorm16Ext(model.context.getExtension('EXT_texture_norm16'));
|
|
225
192
|
model.openGLTexture.releaseGraphicsResources(model._openGLRenderWindow);
|
|
226
193
|
model.openGLTexture.resetFormatAndType();
|
|
227
194
|
model.openGLTexture.create3DFilterableFromDataArray(dims[0], dims[1], dims[2], scalars);
|
|
228
|
-
model.openGLTextureString =
|
|
195
|
+
model.openGLTextureString = toString;
|
|
229
196
|
}
|
|
230
197
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
var cfunToString = computeFnToString(ppty, ppty.getRGBTransferFunction, numIComps);
|
|
237
|
-
|
|
198
|
+
const ppty = actor.getProperty();
|
|
199
|
+
const iComps = ppty.getIndependentComponents();
|
|
200
|
+
const numIComps = iComps ? numComp : 1;
|
|
201
|
+
const textureHeight = iComps ? 2 * numIComps : 1;
|
|
202
|
+
const cfunToString = computeFnToString(ppty, ppty.getRGBTransferFunction, numIComps);
|
|
238
203
|
if (model.colorTextureString !== cfunToString) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
204
|
+
const cWidth = 1024;
|
|
205
|
+
const cSize = cWidth * textureHeight * 3;
|
|
206
|
+
const cTable = new Uint8Array(cSize);
|
|
207
|
+
let cfun = ppty.getRGBTransferFunction();
|
|
244
208
|
if (cfun) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
for (var c = 0; c < numIComps; c++) {
|
|
209
|
+
const tmpTable = new Float32Array(cWidth * 3);
|
|
210
|
+
for (let c = 0; c < numIComps; c++) {
|
|
248
211
|
cfun = ppty.getRGBTransferFunction(c);
|
|
249
|
-
|
|
212
|
+
const cRange = cfun.getRange();
|
|
250
213
|
cfun.getTable(cRange[0], cRange[1], cWidth, tmpTable, 1);
|
|
251
|
-
|
|
252
214
|
if (iComps) {
|
|
253
|
-
for (
|
|
215
|
+
for (let i = 0; i < cWidth * 3; i++) {
|
|
254
216
|
cTable[c * cWidth * 6 + i] = 255.0 * tmpTable[i];
|
|
255
217
|
cTable[c * cWidth * 6 + i + cWidth * 3] = 255.0 * tmpTable[i];
|
|
256
218
|
}
|
|
257
219
|
} else {
|
|
258
|
-
for (
|
|
259
|
-
cTable[c * cWidth * 6 +
|
|
220
|
+
for (let i = 0; i < cWidth * 3; i++) {
|
|
221
|
+
cTable[c * cWidth * 6 + i] = 255.0 * tmpTable[i];
|
|
260
222
|
}
|
|
261
223
|
}
|
|
262
224
|
}
|
|
263
|
-
|
|
264
225
|
model.colorTexture.releaseGraphicsResources(model._openGLRenderWindow);
|
|
265
226
|
model.colorTexture.resetFormatAndType();
|
|
266
227
|
model.colorTexture.create2DFromRaw(cWidth, textureHeight, 3, VtkDataTypes.UNSIGNED_CHAR, cTable);
|
|
267
228
|
} else {
|
|
268
|
-
for (
|
|
269
|
-
cTable[
|
|
270
|
-
cTable[
|
|
271
|
-
cTable[
|
|
229
|
+
for (let i = 0; i < cWidth * 3; ++i) {
|
|
230
|
+
cTable[i] = 255.0 * i / ((cWidth - 1) * 3);
|
|
231
|
+
cTable[i + 1] = 255.0 * i / ((cWidth - 1) * 3);
|
|
232
|
+
cTable[i + 2] = 255.0 * i / ((cWidth - 1) * 3);
|
|
272
233
|
}
|
|
273
|
-
|
|
274
234
|
model.colorTexture.create2DFromRaw(cWidth, 1, 3, VtkDataTypes.UNSIGNED_CHAR, cTable);
|
|
275
235
|
}
|
|
276
|
-
|
|
277
236
|
model.colorTextureString = cfunToString;
|
|
278
|
-
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Build piecewise function buffer. This buffer is used either
|
|
279
240
|
// for component weighting or opacity, depending on whether we're
|
|
280
241
|
// rendering components independently or not.
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
var pwfunToString = computeFnToString(ppty, ppty.getPiecewiseFunction, numIComps);
|
|
284
|
-
|
|
242
|
+
const pwfunToString = computeFnToString(ppty, ppty.getPiecewiseFunction, numIComps);
|
|
285
243
|
if (model.pwfTextureString !== pwfunToString) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
244
|
+
const pwfWidth = 1024;
|
|
245
|
+
const pwfSize = pwfWidth * textureHeight;
|
|
246
|
+
const pwfTable = new Uint8Array(pwfSize);
|
|
247
|
+
let pwfun = ppty.getPiecewiseFunction();
|
|
248
|
+
// support case where pwfun is added/removed
|
|
291
249
|
model.pwfTexture.releaseGraphicsResources(model._openGLRenderWindow);
|
|
292
250
|
model.pwfTexture.resetFormatAndType();
|
|
293
|
-
|
|
294
251
|
if (pwfun) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
for (var _c = 0; _c < numIComps; ++_c) {
|
|
300
|
-
pwfun = ppty.getPiecewiseFunction(_c);
|
|
301
|
-
|
|
252
|
+
const pwfFloatTable = new Float32Array(pwfSize);
|
|
253
|
+
const tmpTable = new Float32Array(pwfWidth);
|
|
254
|
+
for (let c = 0; c < numIComps; ++c) {
|
|
255
|
+
pwfun = ppty.getPiecewiseFunction(c);
|
|
302
256
|
if (pwfun === null) {
|
|
303
257
|
// Piecewise constant max if no function supplied for this component
|
|
304
258
|
pwfFloatTable.fill(1.0);
|
|
305
259
|
} else {
|
|
306
|
-
|
|
307
|
-
pwfun.getTable(pwfRange[0], pwfRange[1], pwfWidth,
|
|
308
|
-
|
|
260
|
+
const pwfRange = pwfun.getRange();
|
|
261
|
+
pwfun.getTable(pwfRange[0], pwfRange[1], pwfWidth, tmpTable, 1);
|
|
262
|
+
// adjust for sample distance etc
|
|
309
263
|
if (iComps) {
|
|
310
|
-
for (
|
|
311
|
-
pwfFloatTable[
|
|
312
|
-
pwfFloatTable[
|
|
264
|
+
for (let i = 0; i < pwfWidth; i++) {
|
|
265
|
+
pwfFloatTable[c * pwfWidth * 2 + i] = tmpTable[i];
|
|
266
|
+
pwfFloatTable[c * pwfWidth * 2 + i + pwfWidth] = tmpTable[i];
|
|
313
267
|
}
|
|
314
268
|
} else {
|
|
315
|
-
for (
|
|
316
|
-
pwfFloatTable[
|
|
269
|
+
for (let i = 0; i < pwfWidth; i++) {
|
|
270
|
+
pwfFloatTable[c * pwfWidth * 2 + i] = tmpTable[i];
|
|
317
271
|
}
|
|
318
272
|
}
|
|
319
273
|
}
|
|
320
274
|
}
|
|
321
|
-
|
|
322
275
|
model.pwfTexture.create2DFromRaw(pwfWidth, textureHeight, 1, VtkDataTypes.FLOAT, pwfFloatTable);
|
|
323
276
|
} else {
|
|
324
277
|
// default is opaque
|
|
325
278
|
pwfTable.fill(255.0);
|
|
326
279
|
model.pwfTexture.create2DFromRaw(pwfWidth, 1, 1, VtkDataTypes.UNSIGNED_CHAR, pwfTable);
|
|
327
280
|
}
|
|
328
|
-
|
|
329
281
|
model.pwfTextureString = pwfunToString;
|
|
330
282
|
}
|
|
331
|
-
|
|
332
|
-
var vboString = "".concat(model.resliceGeom.getMTime(), "A").concat(model.renderable.getSlabThickness());
|
|
333
|
-
|
|
283
|
+
const vboString = `${model.resliceGeom.getMTime()}A${model.renderable.getSlabThickness()}`;
|
|
334
284
|
if (!model.tris.getCABO().getElementCount() || model.VBOBuildString !== vboString) {
|
|
335
|
-
|
|
285
|
+
const points = vtkDataArray.newInstance({
|
|
336
286
|
numberOfComponents: 3,
|
|
337
287
|
values: model.resliceGeom.getPoints().getData()
|
|
338
288
|
});
|
|
339
289
|
points.setName('points');
|
|
340
|
-
|
|
290
|
+
const cells = vtkDataArray.newInstance({
|
|
341
291
|
numberOfComponents: 1,
|
|
342
292
|
values: model.resliceGeom.getPolys().getData()
|
|
343
293
|
});
|
|
344
|
-
|
|
345
|
-
points
|
|
294
|
+
const options = {
|
|
295
|
+
points,
|
|
346
296
|
cellOffset: 0
|
|
347
297
|
};
|
|
348
|
-
|
|
349
298
|
if (model.renderable.getSlabThickness() > 0.0) {
|
|
350
|
-
|
|
351
|
-
|
|
299
|
+
const n = model.resliceGeom.getPointData().getNormals();
|
|
352
300
|
if (!n) {
|
|
353
301
|
vtkErrorMacro('Slab mode requested without normals');
|
|
354
302
|
} else {
|
|
355
303
|
options.normals = n;
|
|
356
304
|
}
|
|
357
305
|
}
|
|
358
|
-
|
|
359
306
|
model.tris.getCABO().createVBO(cells, 'polys', Representation.SURFACE, options);
|
|
360
307
|
}
|
|
361
|
-
|
|
362
308
|
model.VBOBuildString = vboString;
|
|
363
309
|
model.VBOBuildTime.modified();
|
|
364
310
|
};
|
|
311
|
+
publicAPI.updateShaders = (cellBO, ren, actor) => {
|
|
312
|
+
model.lastBoundBO = cellBO;
|
|
365
313
|
|
|
366
|
-
|
|
367
|
-
model.lastBoundBO = cellBO; // has something changed that would require us to recreate the shader?
|
|
368
|
-
|
|
314
|
+
// has something changed that would require us to recreate the shader?
|
|
369
315
|
if (publicAPI.getNeedToRebuildShaders(cellBO, ren, actor)) {
|
|
370
|
-
|
|
316
|
+
const shaders = {
|
|
371
317
|
Vertex: null,
|
|
372
318
|
Fragment: null,
|
|
373
319
|
Geometry: null
|
|
374
320
|
};
|
|
375
|
-
publicAPI.buildShaders(shaders, ren, actor);
|
|
376
|
-
|
|
377
|
-
var newShader = model._openGLRenderWindow.getShaderCache().readyShaderProgramArray(shaders.Vertex, shaders.Fragment, shaders.Geometry); // if the shader changed reinitialize the VAO
|
|
321
|
+
publicAPI.buildShaders(shaders, ren, actor);
|
|
378
322
|
|
|
323
|
+
// compile and bind the program if needed
|
|
324
|
+
const newShader = model._openGLRenderWindow.getShaderCache().readyShaderProgramArray(shaders.Vertex, shaders.Fragment, shaders.Geometry);
|
|
379
325
|
|
|
326
|
+
// if the shader changed reinitialize the VAO
|
|
380
327
|
if (newShader !== cellBO.getProgram()) {
|
|
381
|
-
cellBO.setProgram(newShader);
|
|
382
|
-
|
|
328
|
+
cellBO.setProgram(newShader);
|
|
329
|
+
// reset the VAO as the shader has changed
|
|
383
330
|
cellBO.getVAO().releaseGraphicsResources();
|
|
384
331
|
}
|
|
385
|
-
|
|
386
332
|
cellBO.getShaderSourceTime().modified();
|
|
387
333
|
} else {
|
|
388
334
|
model._openGLRenderWindow.getShaderCache().readyShaderProgram(cellBO.getProgram());
|
|
389
335
|
}
|
|
390
|
-
|
|
391
336
|
cellBO.getVAO().bind();
|
|
392
337
|
publicAPI.setMapperShaderParameters(cellBO, ren, actor);
|
|
393
338
|
publicAPI.setCameraShaderParameters(cellBO, ren, actor);
|
|
394
339
|
publicAPI.setPropertyShaderParameters(cellBO, ren, actor);
|
|
395
340
|
};
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
var program = cellBO.getProgram();
|
|
399
|
-
|
|
341
|
+
publicAPI.setMapperShaderParameters = (cellBO, ren, actor) => {
|
|
342
|
+
const program = cellBO.getProgram();
|
|
400
343
|
if (cellBO.getCABO().getElementCount() && (model.VBOBuildTime.getMTime() > cellBO.getAttributeUpdateTime().getMTime() || cellBO.getShaderSourceTime().getMTime() > cellBO.getAttributeUpdateTime().getMTime())) {
|
|
401
344
|
// Set the 3D texture
|
|
402
345
|
if (program.isUniformUsed('texture1')) {
|
|
403
346
|
program.setUniformi('texture1', model.openGLTexture.getTextureUnit());
|
|
404
|
-
}
|
|
405
|
-
|
|
347
|
+
}
|
|
406
348
|
|
|
349
|
+
// Set the plane vertex attributes
|
|
407
350
|
if (program.isAttributeUsed('vertexWC')) {
|
|
408
351
|
if (!cellBO.getVAO().addAttributeArray(program, cellBO.getCABO(), 'vertexWC', cellBO.getCABO().getVertexOffset(), cellBO.getCABO().getStride(), model.context.FLOAT, 3, model.context.FALSE)) {
|
|
409
352
|
vtkErrorMacro('Error setting vertexWC in shader VAO.');
|
|
410
353
|
}
|
|
411
|
-
}
|
|
412
|
-
|
|
354
|
+
}
|
|
413
355
|
|
|
356
|
+
// If we are doing slab mode, we need normals
|
|
414
357
|
if (program.isAttributeUsed('normalWC')) {
|
|
415
358
|
if (!cellBO.getVAO().addAttributeArray(program, cellBO.getCABO(), 'normalWC', cellBO.getCABO().getNormalOffset(), cellBO.getCABO().getStride(), model.context.FLOAT, 3, model.context.FALSE)) {
|
|
416
359
|
vtkErrorMacro('Error setting normalWC in shader VAO.');
|
|
417
360
|
}
|
|
418
361
|
}
|
|
419
|
-
|
|
420
362
|
if (program.isUniformUsed('slabThickness')) {
|
|
421
363
|
program.setUniformf('slabThickness', model.renderable.getSlabThickness());
|
|
422
364
|
}
|
|
423
|
-
|
|
424
365
|
if (program.isUniformUsed('spacing')) {
|
|
425
366
|
program.setUniform3fv('spacing', model.currentInput.getSpacing());
|
|
426
367
|
}
|
|
427
|
-
|
|
428
368
|
if (program.isUniformUsed('slabType')) {
|
|
429
369
|
program.setUniformi('slabType', model.renderable.getSlabType());
|
|
430
370
|
}
|
|
431
|
-
|
|
432
371
|
if (program.isUniformUsed('slabType')) {
|
|
433
372
|
program.setUniformi('slabType', model.renderable.getSlabType());
|
|
434
373
|
}
|
|
435
|
-
|
|
436
374
|
if (program.isUniformUsed('slabTrapezoid')) {
|
|
437
375
|
program.setUniformi('slabTrapezoid', model.renderable.getSlabTrapezoidIntegration());
|
|
438
376
|
}
|
|
377
|
+
const shiftScaleEnabled = cellBO.getCABO().getCoordShiftAndScaleEnabled();
|
|
378
|
+
const inverseShiftScaleMatrix = shiftScaleEnabled ? cellBO.getCABO().getInverseShiftAndScaleMatrix() : null;
|
|
439
379
|
|
|
440
|
-
|
|
441
|
-
var inverseShiftScaleMatrix = shiftScaleEnabled ? cellBO.getCABO().getInverseShiftAndScaleMatrix() : null; // Set the world->texture matrix
|
|
442
|
-
|
|
380
|
+
// Set the world->texture matrix
|
|
443
381
|
if (program.isUniformUsed('WCTCMatrix')) {
|
|
444
|
-
|
|
445
|
-
|
|
382
|
+
const image = model.currentInput;
|
|
383
|
+
const dim = image.getDimensions();
|
|
446
384
|
mat4.copy(model.tmpMat4, image.getIndexToWorld());
|
|
447
385
|
mat4.scale(model.tmpMat4, model.tmpMat4, dim);
|
|
448
386
|
mat4.invert(model.tmpMat4, model.tmpMat4);
|
|
449
|
-
|
|
450
387
|
if (inverseShiftScaleMatrix) {
|
|
451
388
|
mat4.multiply(model.tmpMat4, model.tmpMat4, inverseShiftScaleMatrix);
|
|
452
389
|
}
|
|
453
|
-
|
|
454
390
|
program.setUniformMatrix('WCTCMatrix', model.tmpMat4);
|
|
455
391
|
}
|
|
456
|
-
|
|
457
392
|
if (program.isUniformUsed('vboScaling')) {
|
|
458
393
|
program.setUniform3fv('vboScaling', cellBO.getCABO().getCoordScale());
|
|
459
394
|
}
|
|
460
|
-
|
|
461
395
|
cellBO.getAttributeUpdateTime().modified();
|
|
462
|
-
}
|
|
463
|
-
|
|
396
|
+
}
|
|
464
397
|
|
|
398
|
+
// Depth request
|
|
465
399
|
if (model.haveSeenDepthRequest) {
|
|
466
400
|
cellBO.getProgram().setUniformi('depthRequest', model.renderDepth ? 1 : 0);
|
|
467
|
-
}
|
|
468
|
-
|
|
401
|
+
}
|
|
469
402
|
|
|
403
|
+
// handle coincident
|
|
470
404
|
if (cellBO.getProgram().isUniformUsed('coffset')) {
|
|
471
|
-
|
|
472
|
-
cellBO.getProgram().setUniformf('coffset', cp.offset);
|
|
473
|
-
|
|
405
|
+
const cp = publicAPI.getCoincidentParameters(ren, actor);
|
|
406
|
+
cellBO.getProgram().setUniformf('coffset', cp.offset);
|
|
407
|
+
// cfactor isn't always used when coffset is.
|
|
474
408
|
if (cellBO.getProgram().isUniformUsed('cfactor')) {
|
|
475
409
|
cellBO.getProgram().setUniformf('cfactor', cp.factor);
|
|
476
410
|
}
|
|
477
411
|
}
|
|
478
412
|
};
|
|
479
|
-
|
|
480
|
-
publicAPI.setCameraShaderParameters = function (cellBO, ren, actor) {
|
|
413
|
+
publicAPI.setCameraShaderParameters = (cellBO, ren, actor) => {
|
|
481
414
|
// [WMVP]C == {world, model, view, projection} coordinates
|
|
482
415
|
// e.g. WCPC == world to projection coordinate transformation
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
var inverseShiftScaleMatrix = shiftScaleEnabled ? cellBO.getCABO().getInverseShiftAndScaleMatrix() : null;
|
|
489
|
-
var program = cellBO.getProgram();
|
|
490
|
-
|
|
416
|
+
const keyMats = model._openGLCamera.getKeyMatrices(ren);
|
|
417
|
+
const actMats = model._openGLImageSlice.getKeyMatrices();
|
|
418
|
+
const shiftScaleEnabled = cellBO.getCABO().getCoordShiftAndScaleEnabled();
|
|
419
|
+
const inverseShiftScaleMatrix = shiftScaleEnabled ? cellBO.getCABO().getInverseShiftAndScaleMatrix() : null;
|
|
420
|
+
const program = cellBO.getProgram();
|
|
491
421
|
if (program.isUniformUsed('MCPCMatrix')) {
|
|
492
422
|
mat4.identity(model.tmpMat4);
|
|
493
423
|
program.setUniformMatrix('MCPCMatrix', safeMatrixMultiply([keyMats.wcpc, actMats.mcwc, inverseShiftScaleMatrix], mat4, model.tmpMat4));
|
|
494
424
|
}
|
|
495
|
-
|
|
496
425
|
if (program.isUniformUsed('MCVCMatrix')) {
|
|
497
426
|
mat4.identity(model.tmpMat4);
|
|
498
427
|
program.setUniformMatrix('MCVCMatrix', safeMatrixMultiply([keyMats.wcvc, actMats.mcwc, inverseShiftScaleMatrix], mat4, model.tmpMat4));
|
|
499
428
|
}
|
|
500
429
|
};
|
|
430
|
+
publicAPI.setPropertyShaderParameters = (cellBO, ren, actor) => {
|
|
431
|
+
const program = cellBO.getProgram();
|
|
432
|
+
const ppty = actor.getProperty();
|
|
433
|
+
const opacity = ppty.getOpacity();
|
|
434
|
+
program.setUniformf('opacity', opacity);
|
|
501
435
|
|
|
502
|
-
|
|
503
|
-
var program = cellBO.getProgram();
|
|
504
|
-
var ppty = actor.getProperty();
|
|
505
|
-
var opacity = ppty.getOpacity();
|
|
506
|
-
program.setUniformf('opacity', opacity); // Component mix
|
|
436
|
+
// Component mix
|
|
507
437
|
// Independent components: Mixed according to component weights
|
|
508
438
|
// Dependent components: Mixed using the following logic:
|
|
509
439
|
// - 2 comps => LA
|
|
510
440
|
// - 3 comps => RGB + opacity from pwf
|
|
511
441
|
// - 4 comps => RGBA
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
var iComps = ppty.getIndependentComponents();
|
|
515
|
-
|
|
442
|
+
const numComp = model.openGLTexture.getComponents();
|
|
443
|
+
const iComps = ppty.getIndependentComponents();
|
|
516
444
|
if (iComps) {
|
|
517
|
-
for (
|
|
518
|
-
program.setUniformf(
|
|
445
|
+
for (let i = 0; i < numComp; ++i) {
|
|
446
|
+
program.setUniformf(`mix${i}`, ppty.getComponentWeight(i));
|
|
519
447
|
}
|
|
520
|
-
}
|
|
448
|
+
}
|
|
521
449
|
|
|
450
|
+
// Color opacity map
|
|
451
|
+
const volInfo = model.openGLTexture.getVolumeInfo();
|
|
522
452
|
|
|
523
|
-
|
|
453
|
+
// three levels of shift scale combined into one
|
|
524
454
|
// for performance in the fragment shader
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
var cfun = ppty.getRGBTransferFunction(target);
|
|
531
|
-
|
|
455
|
+
for (let i = 0; i < numComp; i++) {
|
|
456
|
+
let cw = ppty.getColorWindow();
|
|
457
|
+
let cl = ppty.getColorLevel();
|
|
458
|
+
const target = iComps ? i : 0;
|
|
459
|
+
const cfun = ppty.getRGBTransferFunction(target);
|
|
532
460
|
if (cfun && ppty.getUseLookupTableScalarRange()) {
|
|
533
|
-
|
|
461
|
+
const cRange = cfun.getRange();
|
|
534
462
|
cw = cRange[1] - cRange[0];
|
|
535
463
|
cl = 0.5 * (cRange[1] + cRange[0]);
|
|
536
464
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
program.setUniformf(
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
var _target = iComps ? _i6 : 0;
|
|
552
|
-
|
|
553
|
-
var pwfun = ppty.getPiecewiseFunction(_target);
|
|
554
|
-
|
|
465
|
+
const scale = volInfo.scale[i] / cw;
|
|
466
|
+
const shift = (volInfo.offset[i] - cl) / cw + 0.5;
|
|
467
|
+
program.setUniformf(`cshift${i}`, shift);
|
|
468
|
+
program.setUniformf(`cscale${i}`, scale);
|
|
469
|
+
}
|
|
470
|
+
const texColorUnit = model.colorTexture.getTextureUnit();
|
|
471
|
+
program.setUniformi('colorTexture1', texColorUnit);
|
|
472
|
+
|
|
473
|
+
// pwf shift/scale
|
|
474
|
+
for (let i = 0; i < numComp; i++) {
|
|
475
|
+
let pwfScale = 1.0;
|
|
476
|
+
let pwfShift = 0.0;
|
|
477
|
+
const target = iComps ? i : 0;
|
|
478
|
+
const pwfun = ppty.getPiecewiseFunction(target);
|
|
555
479
|
if (pwfun) {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
pwfScale = volInfo.scale[
|
|
560
|
-
pwfShift = (volInfo.offset[
|
|
480
|
+
const pwfRange = pwfun.getRange();
|
|
481
|
+
const length = pwfRange[1] - pwfRange[0];
|
|
482
|
+
const mid = 0.5 * (pwfRange[0] + pwfRange[1]);
|
|
483
|
+
pwfScale = volInfo.scale[i] / length;
|
|
484
|
+
pwfShift = (volInfo.offset[i] - mid) / length + 0.5;
|
|
561
485
|
}
|
|
562
|
-
|
|
563
|
-
program.setUniformf(
|
|
564
|
-
program.setUniformf("pwfscale".concat(_i6), pwfScale);
|
|
486
|
+
program.setUniformf(`pwfshift${i}`, pwfShift);
|
|
487
|
+
program.setUniformf(`pwfscale${i}`, pwfScale);
|
|
565
488
|
}
|
|
489
|
+
const texOpacityUnit = model.pwfTexture.getTextureUnit();
|
|
490
|
+
program.setUniformi('pwfTexture1', texOpacityUnit);
|
|
566
491
|
|
|
567
|
-
|
|
568
|
-
program.setUniformi('pwfTexture1', texOpacityUnit); // Background color
|
|
569
|
-
|
|
492
|
+
// Background color
|
|
570
493
|
program.setUniform4fv('backgroundColor', model.renderable.getBackgroundColor());
|
|
571
494
|
};
|
|
572
|
-
|
|
573
|
-
publicAPI.getNeedToRebuildShaders = function (cellBO, ren, actor) {
|
|
495
|
+
publicAPI.getNeedToRebuildShaders = (cellBO, ren, actor) => {
|
|
574
496
|
// has something changed that would require us to recreate the shader?
|
|
575
497
|
// candidates are
|
|
576
498
|
// property modified (representation interpolation and lighting)
|
|
577
499
|
// input modified
|
|
578
500
|
// light complexity changed
|
|
579
501
|
// render pass shader replacement changed
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
502
|
+
const tNumComp = model.openGLTexture.getComponents();
|
|
503
|
+
const iComp = actor.getProperty().getIndependentComponents();
|
|
504
|
+
const slabTh = model.renderable.getSlabThickness();
|
|
505
|
+
const slabType = model.renderable.getSlabType();
|
|
506
|
+
const slabTrap = model.renderable.getSlabTrapezoidIntegration();
|
|
507
|
+
|
|
508
|
+
// has the render pass shader replacement changed? Two options
|
|
509
|
+
let needRebuild = false;
|
|
588
510
|
if (!model.currentRenderPass && model.lastRenderPassShaderReplacement || model.currentRenderPass && model.currentRenderPass.getShaderReplacement() !== model.lastRenderPassShaderReplacement) {
|
|
589
511
|
needRebuild = true;
|
|
590
512
|
}
|
|
591
|
-
|
|
592
513
|
if (needRebuild || model.lastHaveSeenDepthRequest !== model.haveSeenDepthRequest || cellBO.getProgram() === 0 || model.lastTextureComponents !== tNumComp || model.lastIndependentComponents !== iComp || model.lastSlabThickness !== slabTh || model.lastSlabType !== slabType || model.lastSlabTrapezoidIntegration !== slabTrap) {
|
|
593
514
|
model.lastHaveSeenDepthRequest = model.haveSeenDepthRequest;
|
|
594
515
|
model.lastTextureComponents = tNumComp;
|
|
@@ -598,118 +519,103 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
598
519
|
model.lastSlabTrapezoidIntegration = slabTrap;
|
|
599
520
|
return true;
|
|
600
521
|
}
|
|
601
|
-
|
|
602
522
|
return false;
|
|
603
523
|
};
|
|
604
|
-
|
|
605
|
-
publicAPI.getShaderTemplate = function (shaders, ren, actor) {
|
|
524
|
+
publicAPI.getShaderTemplate = (shaders, ren, actor) => {
|
|
606
525
|
shaders.Vertex = vtkImageResliceMapperVS;
|
|
607
526
|
shaders.Fragment = vtkImageResliceMapperFS;
|
|
608
527
|
shaders.Geometry = '';
|
|
609
528
|
};
|
|
610
|
-
|
|
611
|
-
publicAPI.replaceShaderValues = function (shaders, ren, actor) {
|
|
529
|
+
publicAPI.replaceShaderValues = (shaders, ren, actor) => {
|
|
612
530
|
publicAPI.replaceShaderTCoord(shaders, ren, actor);
|
|
613
531
|
publicAPI.replaceShaderPositionVC(shaders, ren, actor);
|
|
614
|
-
|
|
615
532
|
if (model.haveSeenDepthRequest) {
|
|
616
|
-
|
|
533
|
+
let FSSource = shaders.Fragment;
|
|
617
534
|
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ZBuffer::Dec', 'uniform int depthRequest;').result;
|
|
618
535
|
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ZBuffer::Impl', ['if (depthRequest == 1) {', 'float iz = floor(gl_FragCoord.z*65535.0 + 0.1);', 'float rf = floor(iz/256.0)/255.0;', 'float gf = mod(iz,256.0)/255.0;', 'gl_FragData[0] = vec4(rf, gf, 0.0, 1.0); }']).result;
|
|
619
536
|
shaders.Fragment = FSSource;
|
|
620
537
|
}
|
|
621
|
-
|
|
622
538
|
publicAPI.replaceShaderCoincidentOffset(shaders, ren, actor);
|
|
623
539
|
};
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
var slabThickness = model.renderable.getSlabThickness();
|
|
540
|
+
publicAPI.replaceShaderTCoord = (shaders, ren, actor) => {
|
|
541
|
+
let VSSource = shaders.Vertex;
|
|
542
|
+
const GSSource = shaders.Geometry;
|
|
543
|
+
let FSSource = shaders.Fragment;
|
|
544
|
+
const tcoordVSDec = ['uniform mat4 WCTCMatrix;', 'out vec3 fragTexCoord;'];
|
|
545
|
+
const slabThickness = model.renderable.getSlabThickness();
|
|
631
546
|
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::TCoord::Dec', tcoordVSDec).result;
|
|
632
|
-
|
|
547
|
+
const tcoordVSImpl = ['fragTexCoord = (WCTCMatrix * vertexWC).xyz;'];
|
|
633
548
|
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::TCoord::Impl', tcoordVSImpl).result;
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
'uniform float
|
|
639
|
-
|
|
640
|
-
'uniform float
|
|
549
|
+
const tNumComp = model.openGLTexture.getComponents();
|
|
550
|
+
const iComps = actor.getProperty().getIndependentComponents();
|
|
551
|
+
let tcoordFSDec = ['in vec3 fragTexCoord;', 'uniform highp sampler3D texture1;', 'uniform mat4 WCTCMatrix;',
|
|
552
|
+
// color shift and scale
|
|
553
|
+
'uniform float cshift0;', 'uniform float cscale0;',
|
|
554
|
+
// pwf shift and scale
|
|
555
|
+
'uniform float pwfshift0;', 'uniform float pwfscale0;',
|
|
556
|
+
// color and pwf textures
|
|
557
|
+
'uniform sampler2D colorTexture1;', 'uniform sampler2D pwfTexture1;',
|
|
558
|
+
// opacity
|
|
559
|
+
'uniform float opacity;',
|
|
560
|
+
// background color
|
|
641
561
|
'uniform vec4 backgroundColor;'];
|
|
642
|
-
|
|
643
562
|
if (iComps) {
|
|
644
|
-
for (
|
|
645
|
-
tcoordFSDec = tcoordFSDec.concat([
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
563
|
+
for (let comp = 1; comp < tNumComp; comp++) {
|
|
564
|
+
tcoordFSDec = tcoordFSDec.concat([
|
|
565
|
+
// color shift and scale
|
|
566
|
+
`uniform float cshift${comp};`, `uniform float cscale${comp};`,
|
|
567
|
+
// weighting shift and scale
|
|
568
|
+
`uniform float pwfshift${comp};`, `uniform float pwfscale${comp};`]);
|
|
569
|
+
}
|
|
570
|
+
// the heights defined below are the locations
|
|
649
571
|
// for the up to four components of the tfuns
|
|
650
572
|
// the tfuns have a height of 2XnumComps pixels so the
|
|
651
573
|
// values are computed to hit the middle of the two rows
|
|
652
574
|
// for that component
|
|
653
|
-
|
|
654
|
-
|
|
655
575
|
switch (tNumComp) {
|
|
656
576
|
case 1:
|
|
657
577
|
tcoordFSDec = tcoordFSDec.concat(['uniform float mix0;', '#define height0 0.5']);
|
|
658
578
|
break;
|
|
659
|
-
|
|
660
579
|
case 2:
|
|
661
580
|
tcoordFSDec = tcoordFSDec.concat(['uniform float mix0;', 'uniform float mix1;', '#define height0 0.25', '#define height1 0.75']);
|
|
662
581
|
break;
|
|
663
|
-
|
|
664
582
|
case 3:
|
|
665
583
|
tcoordFSDec = tcoordFSDec.concat(['uniform float mix0;', 'uniform float mix1;', 'uniform float mix2;', '#define height0 0.17', '#define height1 0.5', '#define height2 0.83']);
|
|
666
584
|
break;
|
|
667
|
-
|
|
668
585
|
case 4:
|
|
669
586
|
tcoordFSDec = tcoordFSDec.concat(['uniform float mix0;', 'uniform float mix1;', 'uniform float mix2;', 'uniform float mix3;', '#define height0 0.125', '#define height1 0.375', '#define height2 0.625', '#define height3 0.875']);
|
|
670
587
|
break;
|
|
671
|
-
|
|
672
588
|
default:
|
|
673
589
|
vtkErrorMacro('Unsupported number of independent coordinates.');
|
|
674
590
|
}
|
|
675
591
|
}
|
|
676
|
-
|
|
677
592
|
if (slabThickness > 0.0) {
|
|
678
593
|
tcoordFSDec = tcoordFSDec.concat(['uniform vec3 spacing;', 'uniform float slabThickness;', 'uniform int slabType;', 'uniform int slabTrapezoid;', 'uniform vec3 vboScaling;']);
|
|
679
594
|
tcoordFSDec = tcoordFSDec.concat(['vec4 compositeValue(vec4 currVal, vec4 valToComp, int trapezoid)', '{', ' vec4 retVal = vec4(1.0);', ' if (slabType == 0) // min', ' {', ' retVal = min(currVal, valToComp);', ' }', ' else if (slabType == 1) // max', ' {', ' retVal = max(currVal, valToComp);', ' }', ' else if (slabType == 3) // sum', ' {', ' retVal = currVal + (trapezoid > 0 ? 0.5 * valToComp : valToComp); ', ' }', ' else // mean', ' {', ' retVal = currVal + (trapezoid > 0 ? 0.5 * valToComp : valToComp); ', ' }', ' return retVal;', '}']);
|
|
680
595
|
}
|
|
681
|
-
|
|
682
596
|
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Dec', tcoordFSDec).result;
|
|
683
|
-
|
|
684
|
-
|
|
597
|
+
let tcoordFSImpl = ['if (any(greaterThan(fragTexCoord, vec3(1.0))) || any(lessThan(fragTexCoord, vec3(0.0))))', '{', ' // set the background color and exit', ' gl_FragData[0] = backgroundColor;', ' return;', '}', 'vec4 tvalue = texture(texture1, fragTexCoord);'];
|
|
685
598
|
if (slabThickness > 0.0) {
|
|
686
599
|
tcoordFSImpl = tcoordFSImpl.concat(['// Get the first and last samples', 'int numSlices = 1;', 'float scaling = min(min(spacing.x, spacing.y), spacing.z) * 0.5;', 'vec3 normalxspacing = scaling * normalWCVSOutput;', 'float distTraveled = length(normalxspacing);', 'int trapezoid = 0;', 'while (distTraveled < slabThickness * 0.5)', '{', ' distTraveled += length(normalxspacing);', ' float fnumSlices = float(numSlices);', ' if (distTraveled > slabThickness * 0.5)', ' {', ' // Before stepping outside the slab, sample at the boundaries', ' normalxspacing = normalWCVSOutput * slabThickness * 0.5 / fnumSlices;', ' trapezoid = slabTrapezoid;', ' }', ' vec3 fragTCoordNeg = (WCTCMatrix * vec4(vertexWCVSOutput.xyz - fnumSlices * normalxspacing * vboScaling, 1.0)).xyz;', ' if (!any(greaterThan(fragTCoordNeg, vec3(1.0))) && !any(lessThan(fragTCoordNeg, vec3(0.0))))', ' {', ' vec4 newVal = texture(texture1, fragTCoordNeg);', ' tvalue = compositeValue(tvalue, newVal, trapezoid);', ' numSlices += 1;', ' }', ' vec3 fragTCoordPos = (WCTCMatrix * vec4(vertexWCVSOutput.xyz + fnumSlices * normalxspacing * vboScaling, 1.0)).xyz;', ' if (!any(greaterThan(fragTCoordNeg, vec3(1.0))) && !any(lessThan(fragTCoordNeg, vec3(0.0))))', ' {', ' vec4 newVal = texture(texture1, fragTCoordPos);', ' tvalue = compositeValue(tvalue, newVal, trapezoid);', ' numSlices += 1;', ' }', '}', '// Finally, if slab type is *mean*, divide the sum by the numSlices', 'if (slabType == 2)', '{', ' tvalue = tvalue / float(numSlices);', '}']);
|
|
687
600
|
}
|
|
688
|
-
|
|
689
601
|
if (iComps) {
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
tcoordFSImpl = tcoordFSImpl.concat(["vec3 tcolor".concat(_comp, " = mix").concat(_comp, " * texture2D(colorTexture1, vec2(tvalue.").concat(rgba[_comp], " * cscale").concat(_comp, " + cshift").concat(_comp, ", height").concat(_comp, ")).rgb;"), "float compWeight".concat(_comp, " = mix").concat(_comp, " * texture2D(pwfTexture1, vec2(tvalue.").concat(rgba[_comp], " * pwfscale").concat(_comp, " + pwfshift").concat(_comp, ", height").concat(_comp, ")).r;")]);
|
|
602
|
+
const rgba = ['r', 'g', 'b', 'a'];
|
|
603
|
+
for (let comp = 0; comp < tNumComp; ++comp) {
|
|
604
|
+
tcoordFSImpl = tcoordFSImpl.concat([`vec3 tcolor${comp} = mix${comp} * texture2D(colorTexture1, vec2(tvalue.${rgba[comp]} * cscale${comp} + cshift${comp}, height${comp})).rgb;`, `float compWeight${comp} = mix${comp} * texture2D(pwfTexture1, vec2(tvalue.${rgba[comp]} * pwfscale${comp} + pwfshift${comp}, height${comp})).r;`]);
|
|
694
605
|
}
|
|
695
|
-
|
|
696
606
|
switch (tNumComp) {
|
|
697
607
|
case 1:
|
|
698
608
|
tcoordFSImpl = tcoordFSImpl.concat(['gl_FragData[0] = vec4(tcolor0.rgb, compWeight0 * opacity);']);
|
|
699
609
|
break;
|
|
700
|
-
|
|
701
610
|
case 2:
|
|
702
611
|
tcoordFSImpl = tcoordFSImpl.concat(['float weightSum = compWeight0 + compWeight1;', 'gl_FragData[0] = vec4(vec3((tcolor0.rgb * (compWeight0 / weightSum)) + (tcolor1.rgb * (compWeight1 / weightSum))), opacity);']);
|
|
703
612
|
break;
|
|
704
|
-
|
|
705
613
|
case 3:
|
|
706
614
|
tcoordFSImpl = tcoordFSImpl.concat(['float weightSum = compWeight0 + compWeight1 + compWeight2;', 'gl_FragData[0] = vec4(vec3((tcolor0.rgb * (compWeight0 / weightSum)) + (tcolor1.rgb * (compWeight1 / weightSum)) + (tcolor2.rgb * (compWeight2 / weightSum))), opacity);']);
|
|
707
615
|
break;
|
|
708
|
-
|
|
709
616
|
case 4:
|
|
710
617
|
tcoordFSImpl = tcoordFSImpl.concat(['float weightSum = compWeight0 + compWeight1 + compWeight2 + compWeight3;', 'gl_FragData[0] = vec4(vec3((tcolor0.rgb * (compWeight0 / weightSum)) + (tcolor1.rgb * (compWeight1 / weightSum)) + (tcolor2.rgb * (compWeight2 / weightSum)) + (tcolor3.rgb * (compWeight3 / weightSum))), opacity);']);
|
|
711
618
|
break;
|
|
712
|
-
|
|
713
619
|
default:
|
|
714
620
|
vtkErrorMacro('Unsupported number of independent coordinates.');
|
|
715
621
|
}
|
|
@@ -719,140 +625,107 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
719
625
|
case 1:
|
|
720
626
|
tcoordFSImpl = tcoordFSImpl.concat(['// Dependent components', 'float intensity = tvalue.r;', 'vec3 tcolor = texture2D(colorTexture1, vec2(intensity * cscale0 + cshift0, 0.5)).rgb;', 'float scalarOpacity = texture2D(pwfTexture1, vec2(intensity * pwfscale0 + pwfshift0, 0.5)).r;', 'gl_FragData[0] = vec4(tcolor, scalarOpacity * opacity);']);
|
|
721
627
|
break;
|
|
722
|
-
|
|
723
628
|
case 2:
|
|
724
629
|
tcoordFSImpl = tcoordFSImpl.concat(['float intensity = tvalue.r*cscale0 + cshift0;', 'gl_FragData[0] = vec4(texture2D(colorTexture1, vec2(intensity, 0.5)).rgb, pwfscale0*tvalue.g + pwfshift0);']);
|
|
725
630
|
break;
|
|
726
|
-
|
|
727
631
|
case 3:
|
|
728
632
|
tcoordFSImpl = tcoordFSImpl.concat(['vec4 tcolor = cscale0*tvalue + cshift0;', 'gl_FragData[0] = vec4(texture2D(colorTexture1, vec2(tcolor.r,0.5)).r,', ' texture2D(colorTexture1, vec2(tcolor.g,0.5)).r,', ' texture2D(colorTexture1, vec2(tcolor.b,0.5)).r, opacity);']);
|
|
729
633
|
break;
|
|
730
|
-
|
|
731
634
|
default:
|
|
732
635
|
tcoordFSImpl = tcoordFSImpl.concat(['vec4 tcolor = cscale0*tvalue + cshift0;', 'gl_FragData[0] = vec4(texture2D(colorTexture1, vec2(tcolor.r,0.5)).r,', ' texture2D(colorTexture1, vec2(tcolor.g,0.5)).r,', ' texture2D(colorTexture1, vec2(tcolor.b,0.5)).r, tcolor.a);']);
|
|
733
636
|
}
|
|
734
637
|
}
|
|
735
|
-
|
|
736
638
|
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Impl', tcoordFSImpl).result;
|
|
737
639
|
shaders.Vertex = VSSource;
|
|
738
640
|
shaders.Fragment = FSSource;
|
|
739
641
|
shaders.Geometry = GSSource;
|
|
740
642
|
};
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
posVCVSDec = posVCVSDec.concat(["//".concat(publicAPI.getMTime()).concat(model.resliceGeomUpdateString)]);
|
|
750
|
-
|
|
643
|
+
publicAPI.replaceShaderPositionVC = (shaders, ren, actor) => {
|
|
644
|
+
let VSSource = shaders.Vertex;
|
|
645
|
+
const GSSource = shaders.Geometry;
|
|
646
|
+
let FSSource = shaders.Fragment;
|
|
647
|
+
const slabThickness = model.renderable.getSlabThickness();
|
|
648
|
+
let posVCVSDec = ['attribute vec4 vertexWC;'];
|
|
649
|
+
// Add a unique hash to the shader to ensure that the shader program is unique to this mapper.
|
|
650
|
+
posVCVSDec = posVCVSDec.concat([`//${publicAPI.getMTime()}${model.resliceGeomUpdateString}`]);
|
|
751
651
|
if (slabThickness > 0.0) {
|
|
752
652
|
posVCVSDec = posVCVSDec.concat(['attribute vec3 normalWC;', 'varying vec3 normalWCVSOutput;', 'varying vec4 vertexWCVSOutput;']);
|
|
753
653
|
}
|
|
754
|
-
|
|
755
654
|
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::PositionVC::Dec', posVCVSDec).result;
|
|
756
|
-
|
|
757
|
-
|
|
655
|
+
let posVCVSImpl = ['gl_Position = MCPCMatrix * vertexWC;'];
|
|
758
656
|
if (slabThickness > 0.0) {
|
|
759
657
|
posVCVSImpl = posVCVSImpl.concat(['normalWCVSOutput = normalWC;', 'vertexWCVSOutput = vertexWC;']);
|
|
760
658
|
}
|
|
761
|
-
|
|
762
659
|
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::PositionVC::Impl', posVCVSImpl).result;
|
|
763
660
|
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Camera::Dec', ['uniform mat4 MCPCMatrix;', 'uniform mat4 MCVCMatrix;']).result;
|
|
764
|
-
|
|
765
|
-
|
|
661
|
+
let posVCFSDec = [];
|
|
766
662
|
if (slabThickness > 0.0) {
|
|
767
663
|
posVCFSDec = posVCFSDec.concat(['varying vec3 normalWCVSOutput;', 'varying vec4 vertexWCVSOutput;']);
|
|
768
664
|
}
|
|
769
|
-
|
|
770
665
|
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::PositionVC::Dec', posVCFSDec).result;
|
|
771
666
|
shaders.Vertex = VSSource;
|
|
772
667
|
shaders.Geometry = GSSource;
|
|
773
668
|
shaders.Fragment = FSSource;
|
|
774
669
|
};
|
|
775
|
-
|
|
776
670
|
function isVectorAxisAligned(n) {
|
|
777
671
|
vtkMath.normalize(n);
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
for (var i = 0; i < 3; ++i) {
|
|
672
|
+
const tmpN = [0, 0, 0];
|
|
673
|
+
for (let i = 0; i < 3; ++i) {
|
|
781
674
|
vec3.zero(tmpN);
|
|
782
675
|
tmpN[i] = 1.0;
|
|
783
|
-
|
|
784
|
-
|
|
676
|
+
const dotP = vtkMath.dot(n, tmpN);
|
|
785
677
|
if (dotP < -0.999 || dotP > 0.999) {
|
|
786
678
|
return [true, i];
|
|
787
679
|
}
|
|
788
680
|
}
|
|
789
|
-
|
|
790
681
|
return [false, 2];
|
|
791
682
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
var slicePlane = model.renderable.getSlicePlane();
|
|
802
|
-
|
|
683
|
+
publicAPI.updateResliceGeometry = () => {
|
|
684
|
+
let resGeomString = '';
|
|
685
|
+
const image = model.currentInput;
|
|
686
|
+
const imageBounds = image?.getBounds();
|
|
687
|
+
// Orthogonal slicing by default
|
|
688
|
+
let orthoSlicing = true;
|
|
689
|
+
let orthoAxis = 2;
|
|
690
|
+
const slicePD = model.renderable.getSlicePolyData();
|
|
691
|
+
const slicePlane = model.renderable.getSlicePlane();
|
|
803
692
|
if (slicePD) {
|
|
804
|
-
resGeomString = resGeomString.concat(
|
|
693
|
+
resGeomString = resGeomString.concat(`PolyData${slicePD.getMTime()}`);
|
|
805
694
|
} else if (slicePlane) {
|
|
806
|
-
resGeomString = resGeomString.concat(
|
|
807
|
-
|
|
695
|
+
resGeomString = resGeomString.concat(`Plane${slicePlane.getMTime()}`);
|
|
808
696
|
if (image) {
|
|
809
|
-
resGeomString = resGeomString.concat(
|
|
810
|
-
}
|
|
697
|
+
resGeomString = resGeomString.concat(`Image${image.getMTime()}`);
|
|
698
|
+
}
|
|
699
|
+
// Check to see if we can bypass oblique slicing related bounds computation
|
|
811
700
|
// Compute a world-to-image-orientation matrix.
|
|
812
701
|
// Ignore the translation component since we are
|
|
813
702
|
// using it on vectors rather than positions.
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
var imageLocalNormal = _toConsumableArray(slicePlane.getNormal());
|
|
820
|
-
|
|
703
|
+
const w2io = mat3.fromValues(image?.getDirection());
|
|
704
|
+
mat3.invert(w2io, w2io);
|
|
705
|
+
// transform the cutting plane normal to image local coords
|
|
706
|
+
const imageLocalNormal = [...slicePlane.getNormal()];
|
|
821
707
|
vec3.transformMat3(imageLocalNormal, imageLocalNormal, w2io);
|
|
822
|
-
|
|
823
|
-
var _isVectorAxisAligned = isVectorAxisAligned(imageLocalNormal);
|
|
824
|
-
|
|
825
|
-
var _isVectorAxisAligned2 = _slicedToArray(_isVectorAxisAligned, 2);
|
|
826
|
-
|
|
827
|
-
orthoSlicing = _isVectorAxisAligned2[0];
|
|
828
|
-
orthoAxis = _isVectorAxisAligned2[1];
|
|
708
|
+
[orthoSlicing, orthoAxis] = isVectorAxisAligned(imageLocalNormal);
|
|
829
709
|
} else {
|
|
830
710
|
// Create a default slice plane here
|
|
831
|
-
|
|
711
|
+
const plane = vtkPlane.newInstance();
|
|
832
712
|
plane.setNormal(0, 0, 1);
|
|
833
|
-
|
|
834
|
-
|
|
713
|
+
let bds = [0, 1, 0, 1, 0, 1];
|
|
835
714
|
if (image) {
|
|
836
715
|
bds = imageBounds;
|
|
837
716
|
}
|
|
838
|
-
|
|
839
717
|
plane.setOrigin(bds[0], bds[2], 0.5 * (bds[5] + bds[4]));
|
|
840
718
|
model.renderable.setSlicePlane(plane);
|
|
841
|
-
resGeomString = resGeomString.concat(
|
|
842
|
-
|
|
719
|
+
resGeomString = resGeomString.concat(`Plane${slicePlane?.getMTime()}`);
|
|
843
720
|
if (image) {
|
|
844
|
-
resGeomString = resGeomString.concat(
|
|
721
|
+
resGeomString = resGeomString.concat(`Image${image.getMTime()}`);
|
|
845
722
|
}
|
|
846
723
|
}
|
|
847
|
-
|
|
848
724
|
if (!model.resliceGeom || model.resliceGeomUpdateString !== resGeomString) {
|
|
849
|
-
var _model$resliceGeom;
|
|
850
|
-
|
|
851
725
|
if (slicePD) {
|
|
852
726
|
if (!model.resliceGeom) {
|
|
853
727
|
model.resliceGeom = vtkPolyData.newInstance();
|
|
854
728
|
}
|
|
855
|
-
|
|
856
729
|
model.resliceGeom.getPoints().setData(slicePD.getPoints().getData(), 3);
|
|
857
730
|
model.resliceGeom.getPolys().setData(slicePD.getPolys().getData(), 1);
|
|
858
731
|
model.resliceGeom.getPointData().setNormals(slicePD.getPointData().getNormals());
|
|
@@ -863,29 +736,25 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
863
736
|
model.cutter.setCutFunction(slicePlane);
|
|
864
737
|
model.lineToSurfaceFilter.setInputConnection(model.cutter.getOutputPort());
|
|
865
738
|
model.lineToSurfaceFilter.update();
|
|
866
|
-
|
|
867
739
|
if (!model.resliceGeom) {
|
|
868
740
|
model.resliceGeom = vtkPolyData.newInstance();
|
|
869
741
|
}
|
|
870
|
-
|
|
871
|
-
var planePD = model.lineToSurfaceFilter.getOutputData();
|
|
742
|
+
const planePD = model.lineToSurfaceFilter.getOutputData();
|
|
872
743
|
model.resliceGeom.getPoints().setData(planePD.getPoints().getData(), 3);
|
|
873
744
|
model.resliceGeom.getPolys().setData(planePD.getPolys().getData(), 1);
|
|
874
|
-
model.resliceGeom.getPointData().setNormals(planePD.getPointData().getNormals());
|
|
745
|
+
model.resliceGeom.getPointData().setNormals(planePD.getPointData().getNormals());
|
|
746
|
+
// The above method does not generate point normals
|
|
875
747
|
// Set it manually here.
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
var npts = model.resliceGeom.getNumberOfPoints();
|
|
748
|
+
const n = slicePlane.getNormal();
|
|
749
|
+
const npts = model.resliceGeom.getNumberOfPoints();
|
|
879
750
|
vtkMath.normalize(n);
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
for (var i = 0; i < npts; ++i) {
|
|
751
|
+
const normalsData = new Float32Array(npts * 3);
|
|
752
|
+
for (let i = 0; i < npts; ++i) {
|
|
883
753
|
normalsData[3 * i] = n[0];
|
|
884
754
|
normalsData[3 * i + 1] = n[1];
|
|
885
755
|
normalsData[3 * i + 2] = n[2];
|
|
886
756
|
}
|
|
887
|
-
|
|
888
|
-
var normals = vtkDataArray.newInstance({
|
|
757
|
+
const normals = vtkDataArray.newInstance({
|
|
889
758
|
numberOfComponents: 3,
|
|
890
759
|
values: normalsData,
|
|
891
760
|
name: 'Normals'
|
|
@@ -894,25 +763,23 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
894
763
|
} else {
|
|
895
764
|
// Since the image-local normal is axis-aligned, we
|
|
896
765
|
// can quickly construct the cutting plane using indexToWorld transforms.
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
for (var j = 0; j < 2; ++j) {
|
|
766
|
+
const ptsArray = new Float32Array(12);
|
|
767
|
+
const indexSpacePlaneOrigin = image.worldToIndex(slicePlane.getOrigin(), [0, 0, 0]);
|
|
768
|
+
const otherAxes = [(orthoAxis + 1) % 3, (orthoAxis + 2) % 3].sort();
|
|
769
|
+
const dim = image.getDimensions();
|
|
770
|
+
const ext = [0, dim[0] - 1, 0, dim[1] - 1, 0, dim[2] - 1];
|
|
771
|
+
let ptIdx = 0;
|
|
772
|
+
for (let i = 0; i < 2; ++i) {
|
|
773
|
+
for (let j = 0; j < 2; ++j) {
|
|
906
774
|
ptsArray[ptIdx + orthoAxis] = indexSpacePlaneOrigin[orthoAxis];
|
|
907
775
|
ptsArray[ptIdx + otherAxes[0]] = ext[2 * otherAxes[0] + j];
|
|
908
|
-
ptsArray[ptIdx + otherAxes[1]] = ext[2 * otherAxes[1] +
|
|
776
|
+
ptsArray[ptIdx + otherAxes[1]] = ext[2 * otherAxes[1] + i];
|
|
909
777
|
ptIdx += 3;
|
|
910
778
|
}
|
|
911
779
|
}
|
|
912
|
-
|
|
913
780
|
model.transform.setMatrix(image.getIndexToWorld());
|
|
914
781
|
model.transform.transformPoints(ptsArray, ptsArray);
|
|
915
|
-
|
|
782
|
+
const cellArray = new Uint16Array(8);
|
|
916
783
|
cellArray[0] = 3;
|
|
917
784
|
cellArray[1] = 0;
|
|
918
785
|
cellArray[2] = 1;
|
|
@@ -921,55 +788,46 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
921
788
|
cellArray[5] = 0;
|
|
922
789
|
cellArray[6] = 3;
|
|
923
790
|
cellArray[7] = 2;
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
for (var _i8 = 0; _i8 < 4; ++_i8) {
|
|
932
|
-
_normalsData[3 * _i8] = _n[0];
|
|
933
|
-
_normalsData[3 * _i8 + 1] = _n[1];
|
|
934
|
-
_normalsData[3 * _i8 + 2] = _n[2];
|
|
791
|
+
const n = slicePlane.getNormal();
|
|
792
|
+
vtkMath.normalize(n);
|
|
793
|
+
const normalsData = new Float32Array(12);
|
|
794
|
+
for (let i = 0; i < 4; ++i) {
|
|
795
|
+
normalsData[3 * i] = n[0];
|
|
796
|
+
normalsData[3 * i + 1] = n[1];
|
|
797
|
+
normalsData[3 * i + 2] = n[2];
|
|
935
798
|
}
|
|
936
|
-
|
|
937
799
|
if (!model.resliceGeom) {
|
|
938
800
|
model.resliceGeom = vtkPolyData.newInstance();
|
|
939
801
|
}
|
|
940
|
-
|
|
941
802
|
model.resliceGeom.getPoints().setData(ptsArray, 3);
|
|
942
803
|
model.resliceGeom.getPolys().setData(cellArray, 1);
|
|
943
|
-
|
|
944
|
-
var _normals = vtkDataArray.newInstance({
|
|
804
|
+
const normals = vtkDataArray.newInstance({
|
|
945
805
|
numberOfComponents: 3,
|
|
946
|
-
values:
|
|
806
|
+
values: normalsData,
|
|
947
807
|
name: 'Normals'
|
|
948
808
|
});
|
|
949
|
-
|
|
950
|
-
model.resliceGeom.getPointData().setNormals(_normals);
|
|
809
|
+
model.resliceGeom.getPointData().setNormals(normals);
|
|
951
810
|
}
|
|
952
811
|
} else {
|
|
953
812
|
vtkErrorMacro('Something went wrong.', 'A default slice plane should have been created in the beginning of', 'updateResliceGeometry.');
|
|
954
813
|
}
|
|
955
|
-
|
|
956
814
|
model.resliceGeomUpdateString = resGeomString;
|
|
957
|
-
|
|
815
|
+
model.resliceGeom?.modified();
|
|
958
816
|
}
|
|
959
817
|
};
|
|
960
|
-
|
|
961
|
-
publicAPI.setOpenGLTexture = function (oglTex) {
|
|
818
|
+
publicAPI.setOpenGLTexture = oglTex => {
|
|
962
819
|
if (oglTex) {
|
|
963
820
|
model.openGLTexture = oglTex;
|
|
964
821
|
model._externalOpenGLTexture = true;
|
|
965
822
|
}
|
|
966
823
|
};
|
|
967
|
-
}
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
// ----------------------------------------------------------------------------
|
|
968
827
|
// Object factory
|
|
969
828
|
// ----------------------------------------------------------------------------
|
|
970
829
|
|
|
971
|
-
|
|
972
|
-
var DEFAULT_VALUES = {
|
|
830
|
+
const DEFAULT_VALUES = {
|
|
973
831
|
VBOBuildTime: {},
|
|
974
832
|
VBOBuildString: null,
|
|
975
833
|
haveSeenDepthRequest: false,
|
|
@@ -989,12 +847,15 @@ var DEFAULT_VALUES = {
|
|
|
989
847
|
colorTexture: null,
|
|
990
848
|
pwfTexture: null,
|
|
991
849
|
_externalOpenGLTexture: false
|
|
992
|
-
};
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
// ----------------------------------------------------------------------------
|
|
993
853
|
|
|
994
854
|
function extend(publicAPI, model) {
|
|
995
|
-
|
|
996
|
-
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
855
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
856
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
997
857
|
|
|
858
|
+
// Inheritance
|
|
998
859
|
vtkViewNode.extend(publicAPI, model, initialValues);
|
|
999
860
|
vtkReplacementShaderMapper.implementReplaceShaderCoincidentOffset(publicAPI, model, initialValues);
|
|
1000
861
|
vtkReplacementShaderMapper.implementBuildShadersWithReplacements(publicAPI, model, initialValues);
|
|
@@ -1004,8 +865,9 @@ function extend(publicAPI, model) {
|
|
|
1004
865
|
model.pwfTexture = vtkOpenGLTexture.newInstance();
|
|
1005
866
|
model.VBOBuildTime = {};
|
|
1006
867
|
obj(model.VBOBuildTime);
|
|
1007
|
-
model.tmpMat4 = mat4.identity(new Float64Array(16));
|
|
868
|
+
model.tmpMat4 = mat4.identity(new Float64Array(16));
|
|
1008
869
|
|
|
870
|
+
// Implicit plane to polydata related cache:
|
|
1009
871
|
model.outlineFilter = vtkImageDataOutlineFilter.newInstance();
|
|
1010
872
|
model.outlineFilter.setGenerateFaces(true);
|
|
1011
873
|
model.outlineFilter.setGenerateLines(false);
|
|
@@ -1013,18 +875,24 @@ function extend(publicAPI, model) {
|
|
|
1013
875
|
model.cutter = vtkCutter.newInstance();
|
|
1014
876
|
model.lineToSurfaceFilter = vtkClosedPolyLineToSurfaceFilter.newInstance();
|
|
1015
877
|
model.transform = vtkTransform.newInstance();
|
|
1016
|
-
get(publicAPI, model, ['openGLTexture']);
|
|
878
|
+
get(publicAPI, model, ['openGLTexture']);
|
|
1017
879
|
|
|
880
|
+
// Object methods
|
|
1018
881
|
vtkOpenGLImageResliceMapper(publicAPI, model);
|
|
1019
|
-
}
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
// ----------------------------------------------------------------------------
|
|
885
|
+
|
|
886
|
+
const newInstance = newInstance$1(extend, 'vtkOpenGLImageResliceMapper');
|
|
1020
887
|
|
|
1021
|
-
|
|
888
|
+
// ----------------------------------------------------------------------------
|
|
1022
889
|
|
|
1023
890
|
var vtkImageResliceMapper = {
|
|
1024
|
-
newInstance
|
|
1025
|
-
extend
|
|
1026
|
-
};
|
|
891
|
+
newInstance,
|
|
892
|
+
extend
|
|
893
|
+
};
|
|
1027
894
|
|
|
895
|
+
// Register ourself to OpenGL backend if imported
|
|
1028
896
|
registerOverride('vtkImageResliceMapper', newInstance);
|
|
1029
897
|
|
|
1030
898
|
export { vtkImageResliceMapper as default, extend, newInstance };
|