@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 macro from '../../macros.js';
|
|
1
|
+
import { m as macro } from '../../macros2.js';
|
|
4
2
|
import { mat4, vec3 } from 'gl-matrix';
|
|
5
3
|
import vtkViewNode from '../SceneGraph/ViewNode.js';
|
|
6
4
|
import vtkHelper from './Helper.js';
|
|
@@ -16,32 +14,31 @@ import { v as vtkPolyDataVS } from './glsl/vtkPolyDataVS.glsl.js';
|
|
|
16
14
|
import { v as vtkPolyDataFS } from './glsl/vtkPolyDataFS.glsl.js';
|
|
17
15
|
import { registerOverride } from './ViewNodeFactory.js';
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
const {
|
|
18
|
+
vtkErrorMacro
|
|
19
|
+
} = macro;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
var vtkErrorMacro = macro.vtkErrorMacro; // ----------------------------------------------------------------------------
|
|
21
|
+
// ----------------------------------------------------------------------------
|
|
23
22
|
// helper methods
|
|
24
23
|
// ----------------------------------------------------------------------------
|
|
25
24
|
|
|
26
25
|
function computeFnToString(property, fn, numberOfComponents) {
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const pwfun = fn.apply(property);
|
|
29
27
|
if (pwfun) {
|
|
30
|
-
|
|
31
|
-
return
|
|
28
|
+
const iComps = property.getIndependentComponents();
|
|
29
|
+
return `${property.getMTime()}-${iComps}-${numberOfComponents}`;
|
|
32
30
|
}
|
|
33
|
-
|
|
34
31
|
return '0';
|
|
35
|
-
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ----------------------------------------------------------------------------
|
|
36
35
|
// vtkOpenGLImageCPRMapper methods
|
|
37
36
|
// ----------------------------------------------------------------------------
|
|
38
37
|
|
|
39
|
-
|
|
40
38
|
function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
41
39
|
// Set our className
|
|
42
40
|
model.classHierarchy.push('vtkOpenGLImageCPRMapper');
|
|
43
|
-
|
|
44
|
-
publicAPI.buildPass = function (prepass) {
|
|
41
|
+
publicAPI.buildPass = prepass => {
|
|
45
42
|
if (prepass) {
|
|
46
43
|
model.currentRenderPass = null;
|
|
47
44
|
model.openGLImageSlice = publicAPI.getFirstAncestorOfType('vtkOpenGLImageSlice');
|
|
@@ -55,15 +52,13 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
55
52
|
model.pwfTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
56
53
|
}
|
|
57
54
|
};
|
|
58
|
-
|
|
59
|
-
publicAPI.opaquePass = function (prepass, renderPass) {
|
|
55
|
+
publicAPI.opaquePass = (prepass, renderPass) => {
|
|
60
56
|
if (prepass) {
|
|
61
57
|
model.currentRenderPass = renderPass;
|
|
62
58
|
publicAPI.render();
|
|
63
59
|
}
|
|
64
60
|
};
|
|
65
|
-
|
|
66
|
-
publicAPI.opaqueZBufferPass = function (prepass) {
|
|
61
|
+
publicAPI.opaqueZBufferPass = prepass => {
|
|
67
62
|
if (prepass) {
|
|
68
63
|
model.haveSeenDepthRequest = true;
|
|
69
64
|
model.renderDepth = true;
|
|
@@ -71,93 +66,81 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
71
66
|
model.renderDepth = false;
|
|
72
67
|
}
|
|
73
68
|
};
|
|
74
|
-
|
|
75
|
-
publicAPI.getCoincidentParameters = function (ren, actor) {
|
|
69
|
+
publicAPI.getCoincidentParameters = (ren, actor) => {
|
|
76
70
|
if (model.renderable.getResolveCoincidentTopology()) {
|
|
77
71
|
return model.renderable.getCoincidentTopologyPolygonOffsetParameters();
|
|
78
72
|
}
|
|
79
|
-
|
|
80
73
|
return null;
|
|
81
74
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
var ren = model._openGLRenderer.getRenderable();
|
|
87
|
-
|
|
75
|
+
publicAPI.render = () => {
|
|
76
|
+
const prop = model.openGLImageSlice.getRenderable();
|
|
77
|
+
const ren = model._openGLRenderer.getRenderable();
|
|
88
78
|
publicAPI.renderPiece(ren, prop);
|
|
89
79
|
};
|
|
90
|
-
|
|
91
|
-
publicAPI.renderPiece = function (ren, prop) {
|
|
80
|
+
publicAPI.renderPiece = (ren, prop) => {
|
|
92
81
|
publicAPI.invokeEvent({
|
|
93
82
|
type: 'StartEvent'
|
|
94
83
|
});
|
|
95
84
|
model.renderable.update();
|
|
96
85
|
publicAPI.invokeEvent({
|
|
97
86
|
type: 'EndEvent'
|
|
98
|
-
});
|
|
87
|
+
});
|
|
99
88
|
|
|
89
|
+
// Check if the ImageCPRMapper has everything it needs to render
|
|
100
90
|
if (!model.renderable.preRenderCheck()) {
|
|
101
91
|
return;
|
|
102
92
|
}
|
|
103
|
-
|
|
104
93
|
model.currentImageDataInput = model.renderable.getInputData(0);
|
|
105
94
|
model.currentCenterlineInput = model.renderable.getOrientedCenterline();
|
|
106
95
|
publicAPI.renderPieceStart(ren, prop);
|
|
107
96
|
publicAPI.renderPieceDraw(ren, prop);
|
|
108
97
|
publicAPI.renderPieceFinish(ren, prop);
|
|
109
98
|
};
|
|
110
|
-
|
|
111
|
-
publicAPI.renderPieceStart = function (ren, actor) {
|
|
99
|
+
publicAPI.renderPieceStart = (ren, actor) => {
|
|
112
100
|
// make sure the BOs are up to date
|
|
113
101
|
publicAPI.updateBufferObjects(ren, actor);
|
|
114
102
|
};
|
|
103
|
+
publicAPI.renderPieceDraw = (ren, actor) => {
|
|
104
|
+
const gl = model.context;
|
|
115
105
|
|
|
116
|
-
|
|
117
|
-
var gl = model.context; // activate the texture
|
|
118
|
-
|
|
106
|
+
// activate the texture
|
|
119
107
|
model.volumeTexture.activate();
|
|
120
108
|
model.colorTexture.activate();
|
|
121
|
-
model.pwfTexture.activate();
|
|
109
|
+
model.pwfTexture.activate();
|
|
122
110
|
|
|
111
|
+
// draw polygons
|
|
123
112
|
if (model.tris.getCABO().getElementCount()) {
|
|
124
113
|
// First we do the triangles, update the shader, set uniforms, etc.
|
|
125
114
|
publicAPI.updateShaders(model.tris, ren, actor);
|
|
126
115
|
gl.drawArrays(gl.TRIANGLES, 0, model.tris.getCABO().getElementCount());
|
|
127
116
|
model.tris.getVAO().release();
|
|
128
117
|
}
|
|
129
|
-
|
|
130
118
|
model.volumeTexture.deactivate();
|
|
131
119
|
model.colorTexture.deactivate();
|
|
132
120
|
model.pwfTexture.deactivate();
|
|
133
121
|
};
|
|
134
|
-
|
|
135
|
-
publicAPI.
|
|
136
|
-
|
|
137
|
-
publicAPI.updateBufferObjects = function (ren, actor) {
|
|
122
|
+
publicAPI.renderPieceFinish = (ren, actor) => {};
|
|
123
|
+
publicAPI.updateBufferObjects = (ren, actor) => {
|
|
138
124
|
// Rebuild buffers if needed
|
|
139
125
|
if (publicAPI.getNeedToRebuildBufferObjects(ren, actor)) {
|
|
140
126
|
publicAPI.buildBufferObjects(ren, actor);
|
|
141
127
|
}
|
|
142
128
|
};
|
|
143
|
-
|
|
144
|
-
publicAPI.getNeedToRebuildBufferObjects = function (ren, actor) {
|
|
129
|
+
publicAPI.getNeedToRebuildBufferObjects = (ren, actor) => {
|
|
145
130
|
// first do a coarse check
|
|
146
131
|
// Note that the actor's mtime includes it's properties mtime
|
|
147
|
-
|
|
148
|
-
|
|
132
|
+
const vmtime = model.VBOBuildTime.getMTime();
|
|
149
133
|
if (vmtime < publicAPI.getMTime() || vmtime < model.renderable.getMTime() || vmtime < actor.getMTime() || vmtime < model.currentImageDataInput.getMTime() || vmtime < model.currentCenterlineInput.getMTime()) {
|
|
150
134
|
return true;
|
|
151
135
|
}
|
|
152
|
-
|
|
153
136
|
return false;
|
|
154
137
|
};
|
|
138
|
+
publicAPI.buildBufferObjects = (ren, actor) => {
|
|
139
|
+
const image = model.currentImageDataInput;
|
|
140
|
+
const centerline = model.currentCenterlineInput;
|
|
141
|
+
const actorProperty = actor.getProperty();
|
|
155
142
|
|
|
156
|
-
|
|
157
|
-
var image = model.currentImageDataInput;
|
|
158
|
-
var centerline = model.currentCenterlineInput;
|
|
159
|
-
var actorProperty = actor.getProperty(); // Set interpolation on the texture based on property setting
|
|
160
|
-
|
|
143
|
+
// Set interpolation on the texture based on property setting
|
|
161
144
|
if (actorProperty.getInterpolationType() === InterpolationType.NEAREST) {
|
|
162
145
|
model.volumeTexture.setMinificationFilter(Filter.NEAREST);
|
|
163
146
|
model.volumeTexture.setMagnificationFilter(Filter.NEAREST);
|
|
@@ -172,281 +155,258 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
172
155
|
model.colorTexture.setMagnificationFilter(Filter.LINEAR);
|
|
173
156
|
model.pwfTexture.setMinificationFilter(Filter.LINEAR);
|
|
174
157
|
model.pwfTexture.setMagnificationFilter(Filter.LINEAR);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
var imageTime = image.getMTime();
|
|
158
|
+
}
|
|
179
159
|
|
|
160
|
+
// Rebuild the volumeTexture if the data has changed
|
|
161
|
+
const imageTime = image.getMTime();
|
|
180
162
|
if (model.volumeTextureTime !== imageTime) {
|
|
181
163
|
// Build the textures
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (!_scalars) {
|
|
164
|
+
const dims = image.getDimensions();
|
|
165
|
+
const scalars = image.getPointData().getScalars();
|
|
166
|
+
if (!scalars) {
|
|
187
167
|
return;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
168
|
+
}
|
|
169
|
+
// Use norm16 for scalar texture if the extension is available
|
|
191
170
|
model.volumeTexture.setOglNorm16Ext(model.context.getExtension('EXT_texture_norm16'));
|
|
192
171
|
model.volumeTexture.releaseGraphicsResources(model._openGLRenderWindow);
|
|
193
172
|
model.volumeTexture.resetFormatAndType();
|
|
194
|
-
model.volumeTexture.create3DFilterableFromRaw(dims[0], dims[1], dims[2],
|
|
173
|
+
model.volumeTexture.create3DFilterableFromRaw(dims[0], dims[1], dims[2], scalars.getNumberOfComponents(), scalars.getDataType(), scalars.getData(), model.renderable.getPreferSizeOverAccuracy());
|
|
195
174
|
model.volumeTextureTime = imageTime;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
var scalars = image.getPointData() && image.getPointData().getScalars();
|
|
175
|
+
}
|
|
200
176
|
|
|
177
|
+
// Rebuild the color texture if needed
|
|
178
|
+
const scalars = image.getPointData() && image.getPointData().getScalars();
|
|
201
179
|
if (!scalars) {
|
|
202
180
|
return;
|
|
203
181
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
var cfunToString = computeFnToString(ppty, ppty.getRGBTransferFunction, numIComps);
|
|
211
|
-
|
|
182
|
+
const numComp = scalars.getNumberOfComponents();
|
|
183
|
+
const ppty = actor.getProperty();
|
|
184
|
+
const iComps = ppty.getIndependentComponents();
|
|
185
|
+
const numIComps = iComps ? numComp : 1;
|
|
186
|
+
const textureHeight = iComps ? 2 * numIComps : 1;
|
|
187
|
+
const cfunToString = computeFnToString(ppty, ppty.getRGBTransferFunction, numIComps);
|
|
212
188
|
if (model.colorTextureString !== cfunToString) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
189
|
+
const cWidth = 1024;
|
|
190
|
+
const cSize = cWidth * textureHeight * 3;
|
|
191
|
+
const cTable = new Uint8Array(cSize);
|
|
192
|
+
let cfun = ppty.getRGBTransferFunction();
|
|
218
193
|
if (cfun) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
for (var c = 0; c < numIComps; c++) {
|
|
194
|
+
const tmpTable = new Float32Array(cWidth * 3);
|
|
195
|
+
for (let c = 0; c < numIComps; c++) {
|
|
222
196
|
cfun = ppty.getRGBTransferFunction(c);
|
|
223
|
-
|
|
197
|
+
const cRange = cfun.getRange();
|
|
224
198
|
cfun.getTable(cRange[0], cRange[1], cWidth, tmpTable, 1);
|
|
225
|
-
|
|
226
199
|
if (iComps) {
|
|
227
|
-
for (
|
|
200
|
+
for (let i = 0; i < cWidth * 3; i++) {
|
|
228
201
|
cTable[c * cWidth * 6 + i] = 255.0 * tmpTable[i];
|
|
229
202
|
cTable[c * cWidth * 6 + i + cWidth * 3] = 255.0 * tmpTable[i];
|
|
230
203
|
}
|
|
231
204
|
} else {
|
|
232
|
-
for (
|
|
233
|
-
cTable[c * cWidth * 6 +
|
|
205
|
+
for (let i = 0; i < cWidth * 3; i++) {
|
|
206
|
+
cTable[c * cWidth * 6 + i] = 255.0 * tmpTable[i];
|
|
234
207
|
}
|
|
235
208
|
}
|
|
236
209
|
}
|
|
237
|
-
|
|
238
210
|
model.colorTexture.releaseGraphicsResources(model._openGLRenderWindow);
|
|
239
211
|
model.colorTexture.resetFormatAndType();
|
|
240
212
|
model.colorTexture.create2DFromRaw(cWidth, textureHeight, 3, VtkDataTypes.UNSIGNED_CHAR, cTable);
|
|
241
213
|
} else {
|
|
242
|
-
for (
|
|
243
|
-
cTable[
|
|
244
|
-
cTable[
|
|
245
|
-
cTable[
|
|
214
|
+
for (let i = 0; i < cWidth * 3; ++i) {
|
|
215
|
+
cTable[i] = 255.0 * i / ((cWidth - 1) * 3);
|
|
216
|
+
cTable[i + 1] = 255.0 * i / ((cWidth - 1) * 3);
|
|
217
|
+
cTable[i + 2] = 255.0 * i / ((cWidth - 1) * 3);
|
|
246
218
|
}
|
|
247
|
-
|
|
248
219
|
model.colorTexture.create2DFromRaw(cWidth, 1, 3, VtkDataTypes.UNSIGNED_CHAR, cTable);
|
|
249
220
|
}
|
|
250
|
-
|
|
251
221
|
model.colorTextureString = cfunToString;
|
|
252
|
-
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Build piecewise function buffer. This buffer is used either
|
|
253
225
|
// for component weighting or opacity, depending on whether we're
|
|
254
226
|
// rendering components independently or not.
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
var pwfunToString = computeFnToString(ppty, ppty.getPiecewiseFunction, numIComps);
|
|
258
|
-
|
|
227
|
+
const pwfunToString = computeFnToString(ppty, ppty.getPiecewiseFunction, numIComps);
|
|
259
228
|
if (model.pwfTextureString !== pwfunToString) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
229
|
+
const pwfWidth = 1024;
|
|
230
|
+
const pwfSize = pwfWidth * textureHeight;
|
|
231
|
+
const pwfTable = new Uint8Array(pwfSize);
|
|
232
|
+
let pwfun = ppty.getPiecewiseFunction();
|
|
233
|
+
// support case where pwfun is added/removed
|
|
265
234
|
model.pwfTexture.releaseGraphicsResources(model._openGLRenderWindow);
|
|
266
235
|
model.pwfTexture.resetFormatAndType();
|
|
267
|
-
|
|
268
236
|
if (pwfun) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
for (var _c = 0; _c < numIComps; ++_c) {
|
|
274
|
-
pwfun = ppty.getPiecewiseFunction(_c);
|
|
275
|
-
|
|
237
|
+
const pwfFloatTable = new Float32Array(pwfSize);
|
|
238
|
+
const tmpTable = new Float32Array(pwfWidth);
|
|
239
|
+
for (let c = 0; c < numIComps; ++c) {
|
|
240
|
+
pwfun = ppty.getPiecewiseFunction(c);
|
|
276
241
|
if (pwfun === null) {
|
|
277
242
|
// Piecewise constant max if no function supplied for this component
|
|
278
243
|
pwfFloatTable.fill(1.0);
|
|
279
244
|
} else {
|
|
280
|
-
|
|
281
|
-
pwfun.getTable(pwfRange[0], pwfRange[1], pwfWidth,
|
|
282
|
-
|
|
245
|
+
const pwfRange = pwfun.getRange();
|
|
246
|
+
pwfun.getTable(pwfRange[0], pwfRange[1], pwfWidth, tmpTable, 1);
|
|
247
|
+
// adjust for sample distance etc
|
|
283
248
|
if (iComps) {
|
|
284
|
-
for (
|
|
285
|
-
pwfFloatTable[
|
|
286
|
-
pwfFloatTable[
|
|
249
|
+
for (let i = 0; i < pwfWidth; i++) {
|
|
250
|
+
pwfFloatTable[c * pwfWidth * 2 + i] = tmpTable[i];
|
|
251
|
+
pwfFloatTable[c * pwfWidth * 2 + i + pwfWidth] = tmpTable[i];
|
|
287
252
|
}
|
|
288
253
|
} else {
|
|
289
|
-
for (
|
|
290
|
-
pwfFloatTable[
|
|
254
|
+
for (let i = 0; i < pwfWidth; i++) {
|
|
255
|
+
pwfFloatTable[c * pwfWidth * 2 + i] = tmpTable[i];
|
|
291
256
|
}
|
|
292
257
|
}
|
|
293
258
|
}
|
|
294
259
|
}
|
|
295
|
-
|
|
296
260
|
model.pwfTexture.create2DFromRaw(pwfWidth, textureHeight, 1, VtkDataTypes.FLOAT, pwfFloatTable);
|
|
297
261
|
} else {
|
|
298
262
|
// default is opaque
|
|
299
263
|
pwfTable.fill(255.0);
|
|
300
264
|
model.pwfTexture.create2DFromRaw(pwfWidth, 1, 1, VtkDataTypes.UNSIGNED_CHAR, pwfTable);
|
|
301
265
|
}
|
|
302
|
-
|
|
303
266
|
model.pwfTextureString = pwfunToString;
|
|
304
|
-
}
|
|
305
|
-
|
|
267
|
+
}
|
|
306
268
|
|
|
269
|
+
// Rebuild the image vertices if needed
|
|
307
270
|
if (model.VBOBuildTime.getMTime() < model.renderable.getMTime() || model.VBOBuildTime.getMTime() < centerline.getMTime()) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
for (
|
|
271
|
+
const nPoints = centerline.getNumberOfPoints();
|
|
272
|
+
const nLines = nPoints <= 1 ? 0 : nPoints - 1;
|
|
273
|
+
const distances = centerline.getDistancesToFirstPoint();
|
|
274
|
+
const totalHeight = model.renderable.getHeight();
|
|
275
|
+
const nPts = 4 * nLines;
|
|
276
|
+
|
|
277
|
+
// Create the array of point: 4 points per segment
|
|
278
|
+
const ptsArray = new Float32Array(3 * nPts);
|
|
279
|
+
const widthMC = model.renderable.getWidth();
|
|
280
|
+
for (let lineIdx = 0, offset = 0; lineIdx < nLines; ++lineIdx) {
|
|
318
281
|
// Use model coordinates
|
|
319
282
|
// See "setCameraShaderParameters" to see how MCPCMatrix is built
|
|
283
|
+
|
|
320
284
|
// Top left
|
|
321
285
|
ptsArray.set([0, totalHeight - distances[lineIdx], 0], offset);
|
|
322
|
-
offset += 3;
|
|
323
|
-
|
|
286
|
+
offset += 3;
|
|
287
|
+
// Top right
|
|
324
288
|
ptsArray.set([widthMC, totalHeight - distances[lineIdx], 0], offset);
|
|
325
|
-
offset += 3;
|
|
326
|
-
|
|
289
|
+
offset += 3;
|
|
290
|
+
// Bottom right
|
|
327
291
|
ptsArray.set([widthMC, totalHeight - distances[lineIdx + 1], 0], offset);
|
|
328
|
-
offset += 3;
|
|
329
|
-
|
|
292
|
+
offset += 3;
|
|
293
|
+
// Bottom left
|
|
330
294
|
ptsArray.set([0, totalHeight - distances[lineIdx + 1], 0], offset);
|
|
331
295
|
offset += 3;
|
|
332
296
|
}
|
|
333
|
-
|
|
334
|
-
var points = vtkDataArray.newInstance({
|
|
297
|
+
const points = vtkDataArray.newInstance({
|
|
335
298
|
numberOfComponents: 3,
|
|
336
299
|
values: ptsArray
|
|
337
300
|
});
|
|
338
|
-
points.setName('points');
|
|
339
|
-
|
|
340
|
-
var cellArray = new Uint16Array(5 * nLines);
|
|
301
|
+
points.setName('points');
|
|
341
302
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
303
|
+
// Create the array of cells: a quad per segment
|
|
304
|
+
const cellArray = new Uint16Array(5 * nLines);
|
|
305
|
+
for (let lineIdx = 0, offset = 0, ptIdx = 0; lineIdx < nLines; ++lineIdx) {
|
|
306
|
+
cellArray.set([4, ptIdx + 3, ptIdx + 2, ptIdx + 1, ptIdx], offset);
|
|
307
|
+
offset += 5;
|
|
345
308
|
ptIdx += 4;
|
|
346
309
|
}
|
|
347
|
-
|
|
348
|
-
var cells = vtkDataArray.newInstance({
|
|
310
|
+
const cells = vtkDataArray.newInstance({
|
|
349
311
|
numberOfComponents: 1,
|
|
350
312
|
values: cellArray
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
var pointsDataArray = centerline.getPoints();
|
|
354
|
-
var centerlinePositionArray = new Float32Array(3 * nPts);
|
|
355
|
-
var pa = new Array(3);
|
|
356
|
-
var pb = new Array(3);
|
|
357
|
-
|
|
358
|
-
for (var _lineIdx2 = 0, _offset2 = 0; _lineIdx2 < nLines; ++_lineIdx2) {
|
|
359
|
-
pointsDataArray.getPoint(_lineIdx2, pa);
|
|
360
|
-
pointsDataArray.getPoint(_lineIdx2 + 1, pb); // Top left
|
|
361
|
-
|
|
362
|
-
centerlinePositionArray.set(pa, _offset2);
|
|
363
|
-
_offset2 += 3; // Top right
|
|
364
|
-
|
|
365
|
-
centerlinePositionArray.set(pa, _offset2);
|
|
366
|
-
_offset2 += 3; // Bottom right
|
|
313
|
+
});
|
|
367
314
|
|
|
368
|
-
|
|
369
|
-
|
|
315
|
+
// Create the array of centerline positions (VBO custom attribute)
|
|
316
|
+
const pointsDataArray = centerline.getPoints();
|
|
317
|
+
const centerlinePositionArray = new Float32Array(3 * nPts);
|
|
318
|
+
const pa = new Array(3);
|
|
319
|
+
const pb = new Array(3);
|
|
320
|
+
for (let lineIdx = 0, offset = 0; lineIdx < nLines; ++lineIdx) {
|
|
321
|
+
pointsDataArray.getPoint(lineIdx, pa);
|
|
322
|
+
pointsDataArray.getPoint(lineIdx + 1, pb);
|
|
370
323
|
|
|
371
|
-
|
|
372
|
-
|
|
324
|
+
// Top left
|
|
325
|
+
centerlinePositionArray.set(pa, offset);
|
|
326
|
+
offset += 3;
|
|
327
|
+
// Top right
|
|
328
|
+
centerlinePositionArray.set(pa, offset);
|
|
329
|
+
offset += 3;
|
|
330
|
+
// Bottom right
|
|
331
|
+
centerlinePositionArray.set(pb, offset);
|
|
332
|
+
offset += 3;
|
|
333
|
+
// Bottom left
|
|
334
|
+
centerlinePositionArray.set(pb, offset);
|
|
335
|
+
offset += 3;
|
|
373
336
|
}
|
|
374
|
-
|
|
375
|
-
var centerlinePosition = vtkDataArray.newInstance({
|
|
337
|
+
const centerlinePosition = vtkDataArray.newInstance({
|
|
376
338
|
numberOfComponents: 3,
|
|
377
339
|
values: centerlinePositionArray,
|
|
378
340
|
name: 'centerlinePosition'
|
|
379
|
-
});
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
// Create the array of quad index:
|
|
380
344
|
// 0 ____ 1
|
|
381
345
|
// | |
|
|
382
346
|
// |____|
|
|
383
347
|
// 2 3
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
3,
|
|
348
|
+
const quadIndexArray = new Float32Array(nPts);
|
|
349
|
+
for (let lineIdx = 0, offset = 0; lineIdx < nLines; ++lineIdx) {
|
|
350
|
+
quadIndexArray.set([0,
|
|
351
|
+
// Top left
|
|
352
|
+
1,
|
|
353
|
+
// Top right
|
|
354
|
+
3,
|
|
355
|
+
// Bottom right
|
|
391
356
|
2 // Bottom left
|
|
392
|
-
],
|
|
393
|
-
|
|
357
|
+
], offset);
|
|
358
|
+
offset += 4;
|
|
394
359
|
}
|
|
395
|
-
|
|
396
|
-
var quadIndex = vtkDataArray.newInstance({
|
|
360
|
+
const quadIndex = vtkDataArray.newInstance({
|
|
397
361
|
numberOfComponents: 1,
|
|
398
362
|
values: quadIndexArray,
|
|
399
363
|
name: 'quadIndex'
|
|
400
364
|
});
|
|
401
|
-
|
|
402
|
-
|
|
365
|
+
const customAttributes = [centerlinePosition, quadIndex];
|
|
403
366
|
if (!model.renderable.getUseUniformOrientation()) {
|
|
404
367
|
// For each {quad / centerline segment}, two vectors in directionDataArray give the orientation of the centerline
|
|
405
368
|
// Send these two vectors to each vertex and use flat interpolation to get them as is in the fragment shader
|
|
406
369
|
// The interpolation will occur in the fragment shader (slerp)
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
370
|
+
const directions = model.renderable.getCenterlineTangentDirections();
|
|
371
|
+
const centerlineTopDirectionArray = new Float32Array(3 * nPts);
|
|
372
|
+
const centerlineBotDirectionArray = new Float32Array(3 * nPts);
|
|
373
|
+
for (let lineIdx = 0, offset = 0; lineIdx < nLines; ++lineIdx) {
|
|
374
|
+
const baseDirectionIdx = 3 * lineIdx;
|
|
410
375
|
|
|
411
|
-
|
|
412
|
-
var baseDirectionIdx = 3 * _lineIdx4; // Every vertex of each quad/segment have the same topDir and botDir
|
|
376
|
+
// Every vertex of each quad/segment have the same topDir and botDir
|
|
413
377
|
// Top left, Top right, Bottom right, Bottom left
|
|
414
|
-
|
|
415
|
-
for (var _i5 = 0; _i5 < 4; ++_i5) {
|
|
378
|
+
for (let i = 0; i < 4; ++i) {
|
|
416
379
|
// Top array
|
|
417
|
-
centerlineTopDirectionArray[
|
|
418
|
-
centerlineTopDirectionArray[
|
|
419
|
-
centerlineTopDirectionArray[
|
|
420
|
-
|
|
421
|
-
centerlineBotDirectionArray[
|
|
422
|
-
centerlineBotDirectionArray[
|
|
423
|
-
centerlineBotDirectionArray[
|
|
424
|
-
|
|
380
|
+
centerlineTopDirectionArray[offset + 0] = directions[baseDirectionIdx + 0];
|
|
381
|
+
centerlineTopDirectionArray[offset + 1] = directions[baseDirectionIdx + 1];
|
|
382
|
+
centerlineTopDirectionArray[offset + 2] = directions[baseDirectionIdx + 2];
|
|
383
|
+
// Bot array
|
|
384
|
+
centerlineBotDirectionArray[offset + 0] = directions[baseDirectionIdx + 3];
|
|
385
|
+
centerlineBotDirectionArray[offset + 1] = directions[baseDirectionIdx + 4];
|
|
386
|
+
centerlineBotDirectionArray[offset + 2] = directions[baseDirectionIdx + 5];
|
|
387
|
+
offset += 3;
|
|
425
388
|
}
|
|
426
389
|
}
|
|
427
|
-
|
|
428
|
-
var centerlineTopDirection = vtkDataArray.newInstance({
|
|
390
|
+
const centerlineTopDirection = vtkDataArray.newInstance({
|
|
429
391
|
numberOfComponents: 3,
|
|
430
392
|
values: centerlineTopDirectionArray,
|
|
431
393
|
name: 'centerlineTopDirection'
|
|
432
394
|
});
|
|
433
|
-
|
|
395
|
+
const centerlineBotDirection = vtkDataArray.newInstance({
|
|
434
396
|
numberOfComponents: 3,
|
|
435
397
|
values: centerlineBotDirectionArray,
|
|
436
398
|
name: 'centerlineBotDirection'
|
|
437
399
|
});
|
|
438
400
|
customAttributes.push(centerlineTopDirection, centerlineBotDirection);
|
|
439
401
|
}
|
|
440
|
-
|
|
441
402
|
model.tris.getCABO().createVBO(cells, 'polys', Representation.SURFACE, {
|
|
442
|
-
points
|
|
443
|
-
customAttributes
|
|
403
|
+
points,
|
|
404
|
+
customAttributes
|
|
444
405
|
});
|
|
445
406
|
model.VBOBuildTime.modified();
|
|
446
407
|
}
|
|
447
408
|
};
|
|
448
|
-
|
|
449
|
-
publicAPI.getNeedToRebuildShaders = function (cellBO, ren, actor) {
|
|
409
|
+
publicAPI.getNeedToRebuildShaders = (cellBO, ren, actor) => {
|
|
450
410
|
// has something changed that would require us to recreate the shader?
|
|
451
411
|
// candidates are
|
|
452
412
|
// presence of centerPoint
|
|
@@ -455,11 +415,11 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
455
415
|
// input modified
|
|
456
416
|
// light complexity changed
|
|
457
417
|
// render pass shader replacement changed
|
|
458
|
-
var tNumComp = model.volumeTexture.getComponents();
|
|
459
|
-
var iComp = actor.getProperty().getIndependentComponents();
|
|
460
|
-
var useCenterPoint = !!model.renderable.getCenterPoint();
|
|
461
|
-
var useUniformOrientation = model.renderable.getUseUniformOrientation();
|
|
462
418
|
|
|
419
|
+
const tNumComp = model.volumeTexture.getComponents();
|
|
420
|
+
const iComp = actor.getProperty().getIndependentComponents();
|
|
421
|
+
const useCenterPoint = !!model.renderable.getCenterPoint();
|
|
422
|
+
const useUniformOrientation = model.renderable.getUseUniformOrientation();
|
|
463
423
|
if (cellBO.getProgram() === 0 || model.lastUseCenterPoint !== useCenterPoint || model.lastUseUniformOrientation !== useUniformOrientation || model.lastHaveSeenDepthRequest !== model.haveSeenDepthRequest || model.lastTextureComponents !== tNumComp || model.lastIndependentComponents !== iComp) {
|
|
464
424
|
model.lastUseCenterPoint = useCenterPoint;
|
|
465
425
|
model.lastUseUniformOrientation = useUniformOrientation;
|
|
@@ -468,108 +428,103 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
468
428
|
model.lastIndependentComponents = iComp;
|
|
469
429
|
return true;
|
|
470
430
|
}
|
|
471
|
-
|
|
472
431
|
return false;
|
|
473
432
|
};
|
|
474
|
-
|
|
475
|
-
publicAPI.buildShaders = function (shaders, ren, actor) {
|
|
433
|
+
publicAPI.buildShaders = (shaders, ren, actor) => {
|
|
476
434
|
publicAPI.getShaderTemplate(shaders, ren, actor);
|
|
477
435
|
publicAPI.replaceShaderValues(shaders, ren, actor);
|
|
478
436
|
};
|
|
437
|
+
publicAPI.replaceShaderValues = (shaders, ren, actor) => {
|
|
438
|
+
let VSSource = shaders.Vertex;
|
|
439
|
+
let FSSource = shaders.Fragment;
|
|
479
440
|
|
|
480
|
-
|
|
481
|
-
var VSSource = shaders.Vertex;
|
|
482
|
-
var FSSource = shaders.Fragment; // Vertex shader main replacements
|
|
483
|
-
|
|
441
|
+
// Vertex shader main replacements
|
|
484
442
|
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Camera::Dec', ['uniform mat4 MCPCMatrix;']).result;
|
|
485
443
|
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::PositionVC::Impl', [' gl_Position = MCPCMatrix * vertexMC;']).result;
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
444
|
+
const vsColorDec = ['attribute vec3 centerlinePosition;', 'attribute float quadIndex;', 'uniform float width;', 'out vec2 quadOffsetVSOutput;', 'out vec3 centerlinePosVSOutput;'];
|
|
445
|
+
const isDirectionUniform = model.renderable.getUseUniformOrientation();
|
|
489
446
|
if (isDirectionUniform) {
|
|
490
447
|
vsColorDec.push('out vec3 centerlineDirVSOutput;', 'uniform vec3 centerlineDirection;');
|
|
491
448
|
} else {
|
|
492
449
|
vsColorDec.push('out vec3 centerlineTopDirVSOutput;', 'out vec3 centerlineBotDirVSOutput;', 'out float centerlineAngleVSOutput;', 'attribute vec3 centerlineTopDirection;', 'attribute vec3 centerlineBotDirection;');
|
|
493
450
|
}
|
|
494
|
-
|
|
495
451
|
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Color::Dec', vsColorDec).result;
|
|
496
|
-
|
|
452
|
+
const vsColorImpl = [
|
|
453
|
+
// quadOffsetVSOutput.x: left = -0.5* width; right = 0.5 * width
|
|
497
454
|
// quadOffsetVSOutput.y: bottom = 0.0; top = 1.0;
|
|
498
455
|
'quadOffsetVSOutput = vec2(width * (mod(quadIndex, 2.0) == 0.0 ? -0.5 : 0.5), quadIndex > 1.0 ? 0.0 : 1.0);', 'centerlinePosVSOutput = centerlinePosition;'];
|
|
499
|
-
|
|
500
456
|
if (isDirectionUniform) {
|
|
501
457
|
vsColorImpl.push('centerlineDirVSOutput = centerlineDirection;');
|
|
502
458
|
} else {
|
|
503
|
-
vsColorImpl.push(
|
|
459
|
+
vsColorImpl.push(
|
|
460
|
+
// When u and v are unit vectors: uvAngle = 2 * atan2(|| u - v ||, || u + v ||)
|
|
504
461
|
// When u != -v: || u + v || > 0
|
|
505
462
|
// When x > 0: atan2(y, x) = atan(y/x)
|
|
506
463
|
// Thus: dirAngle = 2 * atan(|| topDir - botDir || / || topDir + botDir ||)
|
|
507
464
|
// This is more stable and should not be to slow compared to acos(dot(u, v))
|
|
508
465
|
'vec3 sumVec = centerlineTopDirection + centerlineBotDirection;', 'float sumLen2 = dot(sumVec, sumVec);', 'float diffLen2 = 4.0 - sumLen2;', 'if (diffLen2 < 0.001) {', ' // vectors are too close to each other, use lerp', ' centerlineAngleVSOutput = -1.0; // use negative angle as a flag for lerp', ' centerlineTopDirVSOutput = centerlineTopDirection;', ' centerlineBotDirVSOutput = centerlineBotDirection;', '} else if (sumLen2 == 0.0) {', " // vector are opposite to each other, don't make a choice for the user", ' // use slerp without direction, it will display the centerline color on each row of pixel', ' centerlineAngleVSOutput = 0.0;', ' centerlineTopDirVSOutput = vec3(0.0);', ' centerlineBotDirVSOutput = vec3(0.0);', '} else {', ' // use slerp', ' centerlineAngleVSOutput = 2.0 * atan(sqrt(diffLen2/sumLen2));', ' float sinAngle = sin(centerlineAngleVSOutput);', ' centerlineTopDirVSOutput = centerlineTopDirection / sinAngle;', ' centerlineBotDirVSOutput = centerlineBotDirection / sinAngle;', '}');
|
|
509
466
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
'uniform
|
|
518
|
-
|
|
519
|
-
'uniform
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
467
|
+
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Color::Impl', vsColorImpl).result;
|
|
468
|
+
|
|
469
|
+
// Fragment shader main replacements
|
|
470
|
+
const tNumComp = model.volumeTexture.getComponents();
|
|
471
|
+
const iComps = actor.getProperty().getIndependentComponents();
|
|
472
|
+
let tcoordFSDec = [
|
|
473
|
+
// used to compute texture coordinates of the sample
|
|
474
|
+
'uniform mat4 MCTCMatrix; // Model coordinates to texture coordinates', 'in vec2 quadOffsetVSOutput;', 'in vec3 centerlinePosVSOutput;',
|
|
475
|
+
// volume texture
|
|
476
|
+
'uniform highp sampler3D volumeTexture;',
|
|
477
|
+
// color and pwf textures
|
|
478
|
+
'uniform sampler2D colorTexture1;', 'uniform sampler2D pwfTexture1;',
|
|
479
|
+
// opacity
|
|
480
|
+
'uniform float opacity;',
|
|
481
|
+
// background color (out of volume samples)
|
|
482
|
+
'uniform vec4 backgroundColor;',
|
|
483
|
+
// color shift and scale
|
|
484
|
+
`uniform float cshift0;`, `uniform float cscale0;`,
|
|
485
|
+
// weighting shift and scale
|
|
486
|
+
`uniform float pwfshift0;`, `uniform float pwfscale0;`];
|
|
524
487
|
if (isDirectionUniform) {
|
|
525
488
|
tcoordFSDec.push('in vec3 centerlineDirVSOutput;');
|
|
526
489
|
} else {
|
|
527
490
|
tcoordFSDec.push('in vec3 centerlineTopDirVSOutput;', 'in vec3 centerlineBotDirVSOutput;', 'in float centerlineAngleVSOutput;');
|
|
528
491
|
}
|
|
529
|
-
|
|
530
|
-
var centerPoint = model.renderable.getCenterPoint();
|
|
531
|
-
|
|
492
|
+
const centerPoint = model.renderable.getCenterPoint();
|
|
532
493
|
if (centerPoint) {
|
|
533
494
|
tcoordFSDec.push('uniform vec3 globalCenterPoint;');
|
|
534
495
|
}
|
|
535
|
-
|
|
536
496
|
if (iComps) {
|
|
537
|
-
for (
|
|
538
|
-
tcoordFSDec = tcoordFSDec.concat([
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
497
|
+
for (let comp = 1; comp < tNumComp; comp++) {
|
|
498
|
+
tcoordFSDec = tcoordFSDec.concat([
|
|
499
|
+
// color shift and scale
|
|
500
|
+
`uniform float cshift${comp};`, `uniform float cscale${comp};`,
|
|
501
|
+
// weighting shift and scale
|
|
502
|
+
`uniform float pwfshift${comp};`, `uniform float pwfscale${comp};`]);
|
|
503
|
+
}
|
|
504
|
+
// the heights defined below are the locations
|
|
542
505
|
// for the up to four components of the tfuns
|
|
543
506
|
// the tfuns have a height of 2XnumComps pixels so the
|
|
544
507
|
// values are computed to hit the middle of the two rows
|
|
545
508
|
// for that component
|
|
546
|
-
|
|
547
|
-
|
|
548
509
|
switch (tNumComp) {
|
|
549
510
|
case 1:
|
|
550
511
|
tcoordFSDec = tcoordFSDec.concat(['uniform float mix0;', '#define height0 0.5']);
|
|
551
512
|
break;
|
|
552
|
-
|
|
553
513
|
case 2:
|
|
554
514
|
tcoordFSDec = tcoordFSDec.concat(['uniform float mix0;', 'uniform float mix1;', '#define height0 0.25', '#define height1 0.75']);
|
|
555
515
|
break;
|
|
556
|
-
|
|
557
516
|
case 3:
|
|
558
517
|
tcoordFSDec = tcoordFSDec.concat(['uniform float mix0;', 'uniform float mix1;', 'uniform float mix2;', '#define height0 0.17', '#define height1 0.5', '#define height2 0.83']);
|
|
559
518
|
break;
|
|
560
|
-
|
|
561
519
|
case 4:
|
|
562
520
|
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']);
|
|
563
521
|
break;
|
|
564
|
-
|
|
565
522
|
default:
|
|
566
523
|
vtkErrorMacro('Unsupported number of independent coordinates.');
|
|
567
524
|
}
|
|
568
525
|
}
|
|
569
|
-
|
|
570
526
|
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Dec', tcoordFSDec).result;
|
|
571
|
-
|
|
572
|
-
|
|
527
|
+
let tcoordFSImpl = [];
|
|
573
528
|
if (isDirectionUniform) {
|
|
574
529
|
tcoordFSImpl.push('vec3 interpolatedCenterlineDir = centerlineDirVSOutput;');
|
|
575
530
|
} else {
|
|
@@ -577,39 +532,30 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
577
532
|
// We use quadOffsetVSOutput.y: bottom = 0.0; top = 1.0;
|
|
578
533
|
tcoordFSImpl.push('vec3 interpolatedCenterlineDir;', 'if (centerlineAngleVSOutput < 0.0) {', ' // Lerp', ' interpolatedCenterlineDir = quadOffsetVSOutput.y * centerlineTopDirVSOutput + (1.0 - quadOffsetVSOutput.y) * centerlineBotDirVSOutput;', '} else {', ' // Slerp', ' float topInterpolationAngle = quadOffsetVSOutput.y * centerlineAngleVSOutput;', ' float botInterpolationAngle = centerlineAngleVSOutput - topInterpolationAngle;', ' interpolatedCenterlineDir = sin(topInterpolationAngle) * centerlineTopDirVSOutput + sin(botInterpolationAngle) * centerlineBotDirVSOutput;', '}', '// Slerp should give a normalized vector but when sin(angle) is small, rounding error occurs', '// Normalize for both lerp and slerp', 'interpolatedCenterlineDir = normalize(interpolatedCenterlineDir);');
|
|
579
534
|
}
|
|
580
|
-
|
|
581
535
|
if (centerPoint) {
|
|
582
536
|
tcoordFSImpl.push('float baseOffset = dot(interpolatedCenterlineDir, globalCenterPoint - centerlinePosVSOutput);', 'float horizontalOffset = quadOffsetVSOutput.x + baseOffset;');
|
|
583
537
|
} else {
|
|
584
538
|
tcoordFSImpl.push('float horizontalOffset = quadOffsetVSOutput.x;');
|
|
585
539
|
}
|
|
586
|
-
|
|
587
540
|
tcoordFSImpl.push('vec3 volumePosMC = centerlinePosVSOutput + horizontalOffset * interpolatedCenterlineDir;', 'vec3 volumePosTC = (MCTCMatrix * vec4(volumePosMC, 1.0)).xyz;', 'if (any(lessThan(volumePosTC, vec3(0.0))) || any(greaterThan(volumePosTC, vec3(1.0))))', '{', ' // set the background color and exit', ' gl_FragData[0] = backgroundColor;', ' return;', '}', 'vec4 tvalue = texture(volumeTexture, volumePosTC);');
|
|
588
|
-
|
|
589
541
|
if (iComps) {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
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;")]);
|
|
542
|
+
const rgba = ['r', 'g', 'b', 'a'];
|
|
543
|
+
for (let comp = 0; comp < tNumComp; ++comp) {
|
|
544
|
+
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;`]);
|
|
594
545
|
}
|
|
595
|
-
|
|
596
546
|
switch (tNumComp) {
|
|
597
547
|
case 1:
|
|
598
548
|
tcoordFSImpl = tcoordFSImpl.concat(['gl_FragData[0] = vec4(tcolor0.rgb, compWeight0 * opacity);']);
|
|
599
549
|
break;
|
|
600
|
-
|
|
601
550
|
case 2:
|
|
602
551
|
tcoordFSImpl = tcoordFSImpl.concat(['float weightSum = compWeight0 + compWeight1;', 'gl_FragData[0] = vec4(vec3((tcolor0.rgb * (compWeight0 / weightSum)) + (tcolor1.rgb * (compWeight1 / weightSum))), opacity);']);
|
|
603
552
|
break;
|
|
604
|
-
|
|
605
553
|
case 3:
|
|
606
554
|
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);']);
|
|
607
555
|
break;
|
|
608
|
-
|
|
609
556
|
case 4:
|
|
610
557
|
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);']);
|
|
611
558
|
break;
|
|
612
|
-
|
|
613
559
|
default:
|
|
614
560
|
vtkErrorMacro('Unsupported number of independent coordinates.');
|
|
615
561
|
}
|
|
@@ -619,278 +565,239 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
619
565
|
case 1:
|
|
620
566
|
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);']);
|
|
621
567
|
break;
|
|
622
|
-
|
|
623
568
|
case 2:
|
|
624
569
|
tcoordFSImpl = tcoordFSImpl.concat(['float intensity = tvalue.r*cscale0 + cshift0;', 'gl_FragData[0] = vec4(texture2D(colorTexture1, vec2(intensity, 0.5)).rgb, pwfscale0*tvalue.g + pwfshift0);']);
|
|
625
570
|
break;
|
|
626
|
-
|
|
627
571
|
case 3:
|
|
628
572
|
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);']);
|
|
629
573
|
break;
|
|
630
|
-
|
|
631
574
|
default:
|
|
632
575
|
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);']);
|
|
633
576
|
}
|
|
634
577
|
}
|
|
578
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Impl', tcoordFSImpl).result;
|
|
635
579
|
|
|
636
|
-
|
|
637
|
-
|
|
580
|
+
// Picking shader replacements
|
|
638
581
|
if (model.haveSeenDepthRequest) {
|
|
639
582
|
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ZBuffer::Dec', 'uniform int depthRequest;').result;
|
|
640
583
|
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;
|
|
641
584
|
}
|
|
642
|
-
|
|
643
585
|
shaders.Vertex = VSSource;
|
|
644
586
|
shaders.Fragment = FSSource;
|
|
645
587
|
publicAPI.replaceShaderClip(shaders, ren, actor);
|
|
646
588
|
publicAPI.replaceShaderCoincidentOffset(shaders, ren, actor);
|
|
647
589
|
};
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
var FSSource = shaders.Fragment;
|
|
652
|
-
|
|
590
|
+
publicAPI.replaceShaderClip = (shaders, ren, actor) => {
|
|
591
|
+
let VSSource = shaders.Vertex;
|
|
592
|
+
let FSSource = shaders.Fragment;
|
|
653
593
|
if (model.renderable.getNumberOfClippingPlanes()) {
|
|
654
|
-
|
|
655
|
-
|
|
594
|
+
let numClipPlanes = model.renderable.getNumberOfClippingPlanes();
|
|
656
595
|
if (numClipPlanes > 6) {
|
|
657
596
|
macro.vtkErrorMacro('OpenGL has a limit of 6 clipping planes');
|
|
658
597
|
numClipPlanes = 6;
|
|
659
598
|
}
|
|
660
|
-
|
|
661
599
|
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Dec', ['uniform int numClipPlanes;', 'uniform vec4 clipPlanes[6];', 'varying float clipDistancesVSOutput[6];']).result;
|
|
662
600
|
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Impl', ['for (int planeNum = 0; planeNum < 6; planeNum++)', ' {', ' if (planeNum >= numClipPlanes)', ' {', ' break;', ' }', ' clipDistancesVSOutput[planeNum] = dot(clipPlanes[planeNum], vertexMC);', ' }']).result;
|
|
663
601
|
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Dec', ['uniform int numClipPlanes;', 'varying float clipDistancesVSOutput[6];']).result;
|
|
664
602
|
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Impl', ['for (int planeNum = 0; planeNum < 6; planeNum++)', ' {', ' if (planeNum >= numClipPlanes)', ' {', ' break;', ' }', ' if (clipDistancesVSOutput[planeNum] < 0.0) discard;', ' }']).result;
|
|
665
603
|
}
|
|
666
|
-
|
|
667
604
|
shaders.Vertex = VSSource;
|
|
668
605
|
shaders.Fragment = FSSource;
|
|
669
606
|
};
|
|
670
|
-
|
|
671
|
-
publicAPI.getShaderTemplate = function (shaders, ren, actor) {
|
|
607
|
+
publicAPI.getShaderTemplate = (shaders, ren, actor) => {
|
|
672
608
|
shaders.Vertex = vtkPolyDataVS;
|
|
673
609
|
shaders.Fragment = vtkPolyDataFS;
|
|
674
610
|
shaders.Geometry = '';
|
|
675
611
|
};
|
|
676
|
-
|
|
677
|
-
publicAPI.setMapperShaderParameters = function (cellBO, ren, actor) {
|
|
678
|
-
var _cellBO$getProgram;
|
|
679
|
-
|
|
612
|
+
publicAPI.setMapperShaderParameters = (cellBO, ren, actor) => {
|
|
680
613
|
if (cellBO.getCABO().getElementCount() && (model.VBOBuildTime.getMTime() > cellBO.getAttributeUpdateTime().getMTime() || cellBO.getShaderSourceTime().getMTime() > cellBO.getAttributeUpdateTime().getMTime())) {
|
|
681
614
|
if (cellBO.getProgram().isAttributeUsed('vertexMC')) {
|
|
682
615
|
if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), cellBO.getCABO(), 'vertexMC', cellBO.getCABO().getVertexOffset(), cellBO.getCABO().getStride(), model.context.FLOAT, 3, model.context.FALSE)) {
|
|
683
616
|
vtkErrorMacro('Error setting vertexMC in shader VAO.');
|
|
684
617
|
}
|
|
685
|
-
}
|
|
618
|
+
}
|
|
619
|
+
// Custom data of the CABO (centerlinePosition, centerlineTopDirection,
|
|
686
620
|
// centerlineBotDirection, quadIndex and user defined custom data)
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
cellBO.getCABO().getCustomData().forEach(function (data) {
|
|
621
|
+
cellBO.getCABO().getCustomData().forEach(data => {
|
|
690
622
|
if (data && cellBO.getProgram().isAttributeUsed(data.name) && !cellBO.getVAO().addAttributeArray(cellBO.getProgram(), cellBO.getCABO(), data.name, data.offset, cellBO.getCABO().getStride(), model.context.FLOAT, data.components, model.context.FALSE)) {
|
|
691
|
-
vtkErrorMacro(
|
|
623
|
+
vtkErrorMacro(`Error setting ${data.name} in shader VAO.`);
|
|
692
624
|
}
|
|
693
625
|
});
|
|
694
626
|
cellBO.getAttributeUpdateTime().modified();
|
|
695
627
|
}
|
|
696
|
-
|
|
697
|
-
var texUnit = model.volumeTexture.getTextureUnit();
|
|
628
|
+
const texUnit = model.volumeTexture.getTextureUnit();
|
|
698
629
|
cellBO.getProgram().setUniformi('volumeTexture', texUnit);
|
|
699
630
|
cellBO.getProgram().setUniformf('width', model.renderable.getWidth());
|
|
700
|
-
|
|
701
|
-
(_cellBO$getProgram = cellBO.getProgram()).setUniform4f.apply(_cellBO$getProgram, ['backgroundColor'].concat(_toConsumableArray(model.renderable.getBackgroundColor())));
|
|
702
|
-
|
|
631
|
+
cellBO.getProgram().setUniform4f('backgroundColor', ...model.renderable.getBackgroundColor());
|
|
703
632
|
if (cellBO.getProgram().isUniformUsed('centerlineDirection')) {
|
|
704
|
-
|
|
633
|
+
const uniformDirection = model.renderable.getUniformDirection();
|
|
705
634
|
cellBO.getProgram().setUniform3fArray('centerlineDirection', uniformDirection);
|
|
706
635
|
}
|
|
707
|
-
|
|
708
636
|
if (cellBO.getProgram().isUniformUsed('globalCenterPoint')) {
|
|
709
|
-
|
|
637
|
+
const centerPoint = model.renderable.getCenterPoint();
|
|
710
638
|
cellBO.getProgram().setUniform3fArray('globalCenterPoint', centerPoint);
|
|
711
|
-
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
// Model coordinates to image space
|
|
712
642
|
// getWorldToIndex is badly named and is in fact modelToIndex
|
|
713
643
|
// MCIC -> Model coordinates to index coordinates
|
|
714
644
|
// MCTC -> Model coordinates to texture coordinates
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
var ICTCMatrix = mat4.fromScaling(new Float32Array(16), vec3.inverse([], image.getDimensions()));
|
|
720
|
-
var MCTCMatrix = mat4.mul(ICTCMatrix, ICTCMatrix, MCICMatrix);
|
|
645
|
+
const image = model.currentImageDataInput;
|
|
646
|
+
const MCICMatrix = image.getWorldToIndex();
|
|
647
|
+
const ICTCMatrix = mat4.fromScaling(new Float32Array(16), vec3.inverse([], image.getDimensions()));
|
|
648
|
+
const MCTCMatrix = mat4.mul(ICTCMatrix, ICTCMatrix, MCICMatrix);
|
|
721
649
|
cellBO.getProgram().setUniformMatrix('MCTCMatrix', MCTCMatrix);
|
|
722
|
-
|
|
723
650
|
if (model.haveSeenDepthRequest) {
|
|
724
651
|
cellBO.getProgram().setUniformi('depthRequest', model.renderDepth ? 1 : 0);
|
|
725
652
|
}
|
|
726
|
-
|
|
727
653
|
if (model.renderable.getNumberOfClippingPlanes()) {
|
|
728
654
|
// add all the clipping planes
|
|
729
|
-
|
|
730
|
-
|
|
655
|
+
let numClipPlanes = model.renderable.getNumberOfClippingPlanes();
|
|
731
656
|
if (numClipPlanes > 6) {
|
|
732
657
|
macro.vtkErrorMacro('OpenGL has a limit of 6 clipping planes');
|
|
733
658
|
numClipPlanes = 6;
|
|
734
659
|
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
var mat = inverseShiftScaleMatrix ? mat4.copy(model.imagematinv, actor.getMatrix()) : actor.getMatrix();
|
|
739
|
-
|
|
660
|
+
const shiftScaleEnabled = cellBO.getCABO().getCoordShiftAndScaleEnabled();
|
|
661
|
+
const inverseShiftScaleMatrix = shiftScaleEnabled ? cellBO.getCABO().getInverseShiftAndScaleMatrix() : null;
|
|
662
|
+
const mat = inverseShiftScaleMatrix ? mat4.copy(model.imagematinv, actor.getMatrix()) : actor.getMatrix();
|
|
740
663
|
if (inverseShiftScaleMatrix) {
|
|
741
664
|
mat4.transpose(mat, mat);
|
|
742
665
|
mat4.multiply(mat, mat, inverseShiftScaleMatrix);
|
|
743
666
|
mat4.transpose(mat, mat);
|
|
744
|
-
}
|
|
745
|
-
|
|
667
|
+
}
|
|
746
668
|
|
|
669
|
+
// transform crop plane normal with transpose(inverse(worldToIndex))
|
|
747
670
|
mat4.transpose(model.imagemat, model.currentImageDataInput.getIndexToWorld());
|
|
748
671
|
mat4.multiply(model.imagematinv, mat, model.imagemat);
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
var planeEquation = [];
|
|
672
|
+
const planeEquations = [];
|
|
673
|
+
for (let i = 0; i < numClipPlanes; i++) {
|
|
674
|
+
const planeEquation = [];
|
|
753
675
|
model.renderable.getClippingPlaneInDataCoords(model.imagematinv, i, planeEquation);
|
|
754
|
-
|
|
755
|
-
for (var j = 0; j < 4; j++) {
|
|
676
|
+
for (let j = 0; j < 4; j++) {
|
|
756
677
|
planeEquations.push(planeEquation[j]);
|
|
757
678
|
}
|
|
758
679
|
}
|
|
759
|
-
|
|
760
680
|
cellBO.getProgram().setUniformi('numClipPlanes', numClipPlanes);
|
|
761
681
|
cellBO.getProgram().setUniform4fv('clipPlanes', planeEquations);
|
|
762
|
-
}
|
|
763
|
-
|
|
682
|
+
}
|
|
764
683
|
|
|
684
|
+
// handle coincident
|
|
765
685
|
if (cellBO.getProgram().isUniformUsed('coffset')) {
|
|
766
|
-
|
|
767
|
-
cellBO.getProgram().setUniformf('coffset', cp.offset);
|
|
768
|
-
|
|
686
|
+
const cp = publicAPI.getCoincidentParameters(ren, actor);
|
|
687
|
+
cellBO.getProgram().setUniformf('coffset', cp.offset);
|
|
688
|
+
// cfactor isn't always used when coffset is.
|
|
769
689
|
if (cellBO.getProgram().isUniformUsed('cfactor')) {
|
|
770
690
|
cellBO.getProgram().setUniformf('cfactor', cp.factor);
|
|
771
691
|
}
|
|
772
692
|
}
|
|
773
693
|
};
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
var WCPCMatrix = model.openGLCamera.getKeyMatrices(ren).wcpc;
|
|
694
|
+
publicAPI.setCameraShaderParameters = (cellBO, ren, actor) => {
|
|
695
|
+
const MCWCMatrix = model.openGLImageSlice.getKeyMatrices().mcwc;
|
|
696
|
+
const WCPCMatrix = model.openGLCamera.getKeyMatrices(ren).wcpc;
|
|
778
697
|
mat4.multiply(model.imagemat, WCPCMatrix, MCWCMatrix);
|
|
779
|
-
|
|
780
698
|
if (cellBO.getCABO().getCoordShiftAndScaleEnabled()) {
|
|
781
|
-
|
|
699
|
+
const inverseShiftScaleMat = cellBO.getCABO().getInverseShiftAndScaleMatrix();
|
|
782
700
|
mat4.multiply(model.imagemat, model.imagemat, inverseShiftScaleMat);
|
|
783
701
|
}
|
|
784
|
-
|
|
785
702
|
cellBO.getProgram().setUniformMatrix('MCPCMatrix', model.imagemat);
|
|
786
703
|
};
|
|
704
|
+
publicAPI.setPropertyShaderParameters = (cellBO, ren, actor) => {
|
|
705
|
+
const program = cellBO.getProgram();
|
|
706
|
+
const ppty = actor.getProperty();
|
|
707
|
+
const opacity = ppty.getOpacity();
|
|
708
|
+
program.setUniformf('opacity', opacity);
|
|
787
709
|
|
|
788
|
-
|
|
789
|
-
var program = cellBO.getProgram();
|
|
790
|
-
var ppty = actor.getProperty();
|
|
791
|
-
var opacity = ppty.getOpacity();
|
|
792
|
-
program.setUniformf('opacity', opacity); // Component mix
|
|
710
|
+
// Component mix
|
|
793
711
|
// Independent components: Mixed according to component weights
|
|
794
712
|
// Dependent components: Mixed using the following logic:
|
|
795
713
|
// - 2 comps => LA
|
|
796
714
|
// - 3 comps => RGB + opacity from pwf
|
|
797
715
|
// - 4 comps => RGBA
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
var iComps = ppty.getIndependentComponents();
|
|
801
|
-
|
|
716
|
+
const numComp = model.volumeTexture.getComponents();
|
|
717
|
+
const iComps = ppty.getIndependentComponents();
|
|
802
718
|
if (iComps) {
|
|
803
|
-
for (
|
|
804
|
-
program.setUniformf(
|
|
719
|
+
for (let i = 0; i < numComp; ++i) {
|
|
720
|
+
program.setUniformf(`mix${i}`, ppty.getComponentWeight(i));
|
|
805
721
|
}
|
|
806
|
-
}
|
|
722
|
+
}
|
|
807
723
|
|
|
724
|
+
// Color opacity map
|
|
725
|
+
const volInfo = model.volumeTexture.getVolumeInfo();
|
|
808
726
|
|
|
809
|
-
|
|
727
|
+
// three levels of shift scale combined into one
|
|
810
728
|
// for performance in the fragment shader
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
var cfun = ppty.getRGBTransferFunction(target);
|
|
817
|
-
|
|
729
|
+
for (let i = 0; i < numComp; i++) {
|
|
730
|
+
let cw = ppty.getColorWindow();
|
|
731
|
+
let cl = ppty.getColorLevel();
|
|
732
|
+
const target = iComps ? i : 0;
|
|
733
|
+
const cfun = ppty.getRGBTransferFunction(target);
|
|
818
734
|
if (cfun && ppty.getUseLookupTableScalarRange()) {
|
|
819
|
-
|
|
735
|
+
const cRange = cfun.getRange();
|
|
820
736
|
cw = cRange[1] - cRange[0];
|
|
821
737
|
cl = 0.5 * (cRange[1] + cRange[0]);
|
|
822
738
|
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
program.setUniformf(
|
|
827
|
-
program.setUniformf("cscale".concat(_i6), scale);
|
|
739
|
+
const scale = volInfo.scale[i] / cw;
|
|
740
|
+
const shift = (volInfo.offset[i] - cl) / cw + 0.5;
|
|
741
|
+
program.setUniformf(`cshift${i}`, shift);
|
|
742
|
+
program.setUniformf(`cscale${i}`, scale);
|
|
828
743
|
}
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
var _target = iComps ? _i7 : 0;
|
|
839
|
-
|
|
840
|
-
var pwfun = ppty.getPiecewiseFunction(_target);
|
|
841
|
-
|
|
744
|
+
const texColorUnit = model.colorTexture.getTextureUnit(); // TODO
|
|
745
|
+
program.setUniformi('colorTexture1', texColorUnit);
|
|
746
|
+
|
|
747
|
+
// pwf shift/scale
|
|
748
|
+
for (let i = 0; i < numComp; i++) {
|
|
749
|
+
let pwfScale = 1.0;
|
|
750
|
+
let pwfShift = 0.0;
|
|
751
|
+
const target = iComps ? i : 0;
|
|
752
|
+
const pwfun = ppty.getPiecewiseFunction(target);
|
|
842
753
|
if (pwfun) {
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
pwfScale = volInfo.scale[
|
|
847
|
-
pwfShift = (volInfo.offset[
|
|
754
|
+
const pwfRange = pwfun.getRange();
|
|
755
|
+
const length = pwfRange[1] - pwfRange[0];
|
|
756
|
+
const mid = 0.5 * (pwfRange[0] + pwfRange[1]);
|
|
757
|
+
pwfScale = volInfo.scale[i] / length;
|
|
758
|
+
pwfShift = (volInfo.offset[i] - mid) / length + 0.5;
|
|
848
759
|
}
|
|
849
|
-
|
|
850
|
-
program.setUniformf(
|
|
851
|
-
program.setUniformf("pwfscale".concat(_i7), pwfScale);
|
|
760
|
+
program.setUniformf(`pwfshift${i}`, pwfShift);
|
|
761
|
+
program.setUniformf(`pwfscale${i}`, pwfScale);
|
|
852
762
|
}
|
|
853
|
-
|
|
854
|
-
var texOpacityUnit = model.pwfTexture.getTextureUnit(); // TODO
|
|
855
|
-
|
|
763
|
+
const texOpacityUnit = model.pwfTexture.getTextureUnit(); // TODO
|
|
856
764
|
program.setUniformi('pwfTexture1', texOpacityUnit);
|
|
857
765
|
};
|
|
858
|
-
|
|
859
|
-
publicAPI.updateShaders = function (cellBO, ren, actor) {
|
|
766
|
+
publicAPI.updateShaders = (cellBO, ren, actor) => {
|
|
860
767
|
// has something changed that would require us to recreate the shader?
|
|
861
768
|
if (publicAPI.getNeedToRebuildShaders(cellBO, ren, actor)) {
|
|
862
|
-
|
|
769
|
+
const shaders = {
|
|
863
770
|
Vertex: null,
|
|
864
771
|
Fragment: null,
|
|
865
772
|
Geometry: null
|
|
866
773
|
};
|
|
867
|
-
publicAPI.buildShaders(shaders, ren, actor);
|
|
868
|
-
|
|
869
|
-
var newShader = model._openGLRenderWindow.getShaderCache().readyShaderProgramArray(shaders.Vertex, shaders.Fragment, shaders.Geometry); // if the shader changed reinitialize the VAO
|
|
774
|
+
publicAPI.buildShaders(shaders, ren, actor);
|
|
870
775
|
|
|
776
|
+
// compile and bind the program if needed
|
|
777
|
+
const newShader = model._openGLRenderWindow.getShaderCache().readyShaderProgramArray(shaders.Vertex, shaders.Fragment, shaders.Geometry);
|
|
871
778
|
|
|
779
|
+
// if the shader changed reinitialize the VAO
|
|
872
780
|
if (newShader !== cellBO.getProgram()) {
|
|
873
|
-
cellBO.setProgram(newShader);
|
|
874
|
-
|
|
781
|
+
cellBO.setProgram(newShader);
|
|
782
|
+
// reset the VAO as the shader has changed
|
|
875
783
|
cellBO.getVAO().releaseGraphicsResources();
|
|
876
784
|
}
|
|
877
|
-
|
|
878
785
|
cellBO.getShaderSourceTime().modified();
|
|
879
786
|
} else {
|
|
880
787
|
model._openGLRenderWindow.getShaderCache().readyShaderProgram(cellBO.getProgram());
|
|
881
788
|
}
|
|
882
|
-
|
|
883
789
|
cellBO.getVAO().bind();
|
|
884
790
|
publicAPI.setMapperShaderParameters(cellBO, ren, actor);
|
|
885
791
|
publicAPI.setCameraShaderParameters(cellBO, ren, actor);
|
|
886
792
|
publicAPI.setPropertyShaderParameters(cellBO, ren, actor);
|
|
887
793
|
};
|
|
888
|
-
}
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
// ----------------------------------------------------------------------------
|
|
889
797
|
// Object factory
|
|
890
798
|
// ----------------------------------------------------------------------------
|
|
891
799
|
|
|
892
|
-
|
|
893
|
-
var DEFAULT_VALUES = {
|
|
800
|
+
const DEFAULT_VALUES = {
|
|
894
801
|
currentRenderPass: null,
|
|
895
802
|
volumeTexture: null,
|
|
896
803
|
volumeTextureTime: 0,
|
|
@@ -905,15 +812,19 @@ var DEFAULT_VALUES = {
|
|
|
905
812
|
lastIndependentComponents: 0,
|
|
906
813
|
imagemat: null,
|
|
907
814
|
imagematinv: null
|
|
908
|
-
};
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
// ----------------------------------------------------------------------------
|
|
909
818
|
|
|
910
819
|
function extend(publicAPI, model) {
|
|
911
|
-
|
|
912
|
-
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
820
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
821
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
913
822
|
|
|
823
|
+
// Inheritance
|
|
914
824
|
vtkViewNode.extend(publicAPI, model, initialValues);
|
|
915
|
-
vtkReplacementShaderMapper.implementReplaceShaderCoincidentOffset(publicAPI, model, initialValues);
|
|
825
|
+
vtkReplacementShaderMapper.implementReplaceShaderCoincidentOffset(publicAPI, model, initialValues);
|
|
916
826
|
|
|
827
|
+
// Two inputs: one for the ImageData/Texture and one for the PolyData (centerline)
|
|
917
828
|
macro.algo(publicAPI, model, 2, 0);
|
|
918
829
|
model.tris = vtkHelper.newInstance();
|
|
919
830
|
model.volumeTexture = vtkOpenGLTexture.newInstance();
|
|
@@ -924,19 +835,26 @@ function extend(publicAPI, model) {
|
|
|
924
835
|
model.VBOBuildTime = {};
|
|
925
836
|
macro.obj(model.VBOBuildTime, {
|
|
926
837
|
mtime: 0
|
|
927
|
-
});
|
|
838
|
+
});
|
|
928
839
|
|
|
840
|
+
// Object methods
|
|
929
841
|
vtkOpenGLImageCPRMapper(publicAPI, model);
|
|
930
|
-
}
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
// ----------------------------------------------------------------------------
|
|
845
|
+
|
|
846
|
+
const newInstance = macro.newInstance(extend, 'vtkOpenGLImageCPRMapper');
|
|
847
|
+
const STATIC = {};
|
|
931
848
|
|
|
932
|
-
|
|
933
|
-
var STATIC = {}; // ----------------------------------------------------------------------------
|
|
849
|
+
// ----------------------------------------------------------------------------
|
|
934
850
|
|
|
935
|
-
var index =
|
|
936
|
-
newInstance
|
|
937
|
-
extend
|
|
938
|
-
|
|
851
|
+
var index = {
|
|
852
|
+
newInstance,
|
|
853
|
+
extend,
|
|
854
|
+
...STATIC
|
|
855
|
+
};
|
|
939
856
|
|
|
857
|
+
// Register ourself to OpenGL backend if imported
|
|
940
858
|
registerOverride('vtkImageCPRMapper', newInstance);
|
|
941
859
|
|
|
942
860
|
export { STATIC, index as default, extend, newInstance };
|