@kitware/vtk.js 28.10.2 → 28.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +754 -942
- package/Common/Core/Math.js +2 -4
- package/Common/Core/MatrixBuilder.js +99 -151
- package/Common/Core/Points.js +43 -43
- package/Common/Core/PriorityQueue.js +30 -28
- package/Common/Core/ProgressHandler.js +31 -32
- package/Common/Core/ScalarsToColors/Constants.js +4 -4
- package/Common/Core/ScalarsToColors.js +196 -253
- package/Common/Core/StringArray.js +48 -73
- package/Common/Core/URLExtract.js +10 -29
- package/Common/Core/VariantArray.js +48 -73
- package/Common/Core.js +11 -11
- package/Common/DataModel/AbstractPointLocator.js +19 -17
- package/Common/DataModel/BoundingBox.js +322 -490
- package/Common/DataModel/Box.js +46 -63
- package/Common/DataModel/CardinalSpline1D.js +92 -102
- package/Common/DataModel/Cell.js +41 -61
- package/Common/DataModel/CellLinks.js +91 -127
- package/Common/DataModel/CellTypes/Constants.js +7 -6
- package/Common/DataModel/CellTypes.js +55 -74
- package/Common/DataModel/Collection.js +45 -61
- package/Common/DataModel/Cone.js +28 -20
- package/Common/DataModel/Cylinder.js +41 -35
- package/Common/DataModel/DataSet/Constants.js +11 -5
- package/Common/DataModel/DataSet.js +37 -25
- package/Common/DataModel/DataSetAttributes/Constants.js +18 -18
- package/Common/DataModel/DataSetAttributes/FieldData.js +103 -194
- package/Common/DataModel/DataSetAttributes.js +96 -138
- package/Common/DataModel/EdgeLocator.js +45 -70
- package/Common/DataModel/ITKHelper.js +67 -137
- package/Common/DataModel/ImageData.js +115 -172
- package/Common/DataModel/ImplicitBoolean/Constants.js +2 -2
- package/Common/DataModel/ImplicitBoolean.js +66 -96
- package/Common/DataModel/IncrementalOctreeNode.js +201 -231
- package/Common/DataModel/IncrementalOctreePointLocator.js +160 -198
- package/Common/DataModel/KochanekSpline1D.js +78 -81
- package/Common/DataModel/Line/Constants.js +2 -2
- package/Common/DataModel/Line.js +82 -105
- package/Common/DataModel/Locator.js +17 -10
- package/Common/DataModel/Molecule.js +26 -17
- package/Common/DataModel/PiecewiseFunction.js +218 -239
- package/Common/DataModel/Plane.js +90 -113
- package/Common/DataModel/PointSet.js +30 -26
- package/Common/DataModel/PolyData/Constants.js +2 -2
- package/Common/DataModel/PolyData.js +95 -120
- package/Common/DataModel/PolyLine.js +44 -61
- package/Common/DataModel/Polygon/Constants.js +4 -4
- package/Common/DataModel/Polygon.js +128 -169
- package/Common/DataModel/Quad/Constants.js +2 -2
- package/Common/DataModel/Quad.js +61 -100
- package/Common/DataModel/SelectionNode/Constants.js +5 -4
- package/Common/DataModel/SelectionNode.js +25 -21
- package/Common/DataModel/Sphere.js +40 -35
- package/Common/DataModel/Spline1D/Constants.js +3 -2
- package/Common/DataModel/Spline1D.js +34 -18
- package/Common/DataModel/Spline3D/Constants.js +2 -2
- package/Common/DataModel/Spline3D.js +46 -41
- package/Common/DataModel/StructuredData/Constants.js +2 -2
- package/Common/DataModel/StructuredData.js +9 -20
- package/Common/DataModel/Triangle.js +207 -250
- package/Common/DataModel.js +19 -19
- package/Common/System/MobileVR.js +56 -61
- package/Common/System/TimerLog.js +1 -1
- package/Common/System.js +2 -2
- package/Common/Transform/LandmarkTransform/Constants.js +2 -2
- package/Common/Transform/LandmarkTransform.js +133 -117
- package/Common/Transform/Transform.js +42 -57
- package/Common/Transform.js +2 -2
- package/Common/index.js +4 -4
- package/Filters/Core/Cutter.js +134 -146
- package/Filters/Core/PolyDataNormals.js +44 -50
- package/Filters/Core.js +2 -2
- package/Filters/Cornerstone/ImageDataToCornerstoneImage.js +45 -33
- package/Filters/Cornerstone.js +1 -1
- package/Filters/General/AppendPolyData.js +84 -100
- package/Filters/General/Calculator.js +95 -163
- package/Filters/General/ClipClosedSurface/Constants.js +2 -2
- package/Filters/General/ClipClosedSurface.js +341 -416
- package/Filters/General/ClosedPolyLineToSurfaceFilter.js +141 -156
- package/Filters/General/ContourTriangulator/Constants.js +2 -2
- package/Filters/General/ContourTriangulator/helper.js +684 -812
- package/Filters/General/ContourTriangulator.js +92 -89
- package/Filters/General/ImageCropFilter.js +77 -78
- package/Filters/General/ImageDataOutlineFilter.js +42 -36
- package/Filters/General/ImageMarchingCubes/caseTable.js +9 -521
- package/Filters/General/ImageMarchingCubes.js +99 -112
- package/Filters/General/ImageMarchingSquares/caseTable.js +9 -41
- package/Filters/General/ImageMarchingSquares.js +93 -118
- package/Filters/General/ImageOutlineFilter.js +53 -54
- package/Filters/General/ImageSliceFilter.js +39 -30
- package/Filters/General/ImageStreamline.js +107 -124
- package/Filters/General/LineFilter.js +26 -15
- package/Filters/General/MoleculeToRepresentation.js +136 -149
- package/Filters/General/OBBTree/OBBNode.js +36 -34
- package/Filters/General/OBBTree/helper.js +19 -24
- package/Filters/General/OBBTree.js +396 -488
- package/Filters/General/OutlineFilter.js +52 -34
- package/Filters/General/PaintFilter/PaintFilter.worker.js +93 -130
- package/Filters/General/PaintFilter.js +150 -162
- package/Filters/General/ScalarToRGBA.js +38 -33
- package/Filters/General/TriangleFilter.js +65 -62
- package/Filters/General/TubeFilter/Constants.js +4 -4
- package/Filters/General/TubeFilter.js +376 -496
- package/Filters/General/WarpScalar.js +58 -60
- package/Filters/General/WindowedSincPolyDataFilter.js +258 -330
- package/Filters/General.js +21 -21
- package/Filters/Sources/Arrow2DSource/Constants.js +2 -2
- package/Filters/Sources/Arrow2DSource.js +56 -56
- package/Filters/Sources/ArrowSource.js +39 -29
- package/Filters/Sources/CircleSource.js +43 -43
- package/Filters/Sources/ConcentricCylinderSource.js +151 -174
- package/Filters/Sources/ConeSource.js +51 -42
- package/Filters/Sources/CubeSource.js +75 -96
- package/Filters/Sources/Cursor3D.js +94 -109
- package/Filters/Sources/CylinderSource.js +90 -90
- package/Filters/Sources/ImageGridSource.js +43 -43
- package/Filters/Sources/LineSource.js +49 -39
- package/Filters/Sources/PlaneSource.js +97 -104
- package/Filters/Sources/PointSource.js +46 -37
- package/Filters/Sources/RTAnalyticSource.js +50 -48
- package/Filters/Sources/SLICSource.js +63 -73
- package/Filters/Sources/SphereSource.js +88 -78
- package/Filters/Sources/ViewFinderSource.js +26 -23
- package/Filters/Sources.js +14 -14
- package/Filters/Texture/TextureMapToPlane.js +95 -97
- package/Filters/Texture/TextureMapToSphere.js +46 -54
- package/Filters/Texture.js +2 -2
- package/Filters/index.js +5 -5
- package/IO/Core/BinaryHelper.js +12 -18
- package/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js +43 -59
- package/IO/Core/DataAccessHelper/HttpDataAccessHelper.js +76 -113
- package/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js +62 -112
- package/IO/Core/DataAccessHelper/LiteHttpDataAccessHelper.js +76 -113
- package/IO/Core/DataAccessHelper.js +6 -6
- package/IO/Core/HttpDataSetReader.js +136 -139
- package/IO/Core/HttpDataSetSeriesReader.js +64 -75
- package/IO/Core/HttpSceneLoader.js +130 -179
- package/IO/Core/ImageStream/DefaultProtocol.js +29 -43
- package/IO/Core/ImageStream/ViewStream.js +100 -103
- package/IO/Core/ImageStream.js +62 -54
- package/IO/Core/ResourceLoader.js +10 -9
- package/IO/Core/Serializer/ArraySerializer.js +40 -40
- package/IO/Core/Serializer/FieldDataSerializer.js +18 -28
- package/IO/Core/Serializer/ImageDataSerializer.js +22 -23
- package/IO/Core/Serializer/PolyDataSerializer.js +17 -21
- package/IO/Core/Serializer.js +6 -13
- package/IO/Core/WSLinkClient.js +90 -76
- package/IO/Core/ZipMultiDataSetReader.js +46 -44
- package/IO/Core/ZipMultiDataSetWriter.js +43 -34
- package/IO/Core.js +7 -7
- package/IO/Geometry/DracoReader.js +118 -121
- package/IO/Geometry/PLYReader.js +163 -223
- package/IO/Geometry/PLYWriter/Constants.js +5 -5
- package/IO/Geometry/PLYWriter.js +139 -154
- package/IO/Geometry/STLReader.js +123 -146
- package/IO/Geometry/STLWriter/Constants.js +2 -2
- package/IO/Geometry/STLWriter.js +83 -82
- package/IO/Geometry.js +5 -5
- package/IO/Legacy/LegacyAsciiParser.js +78 -139
- package/IO/Legacy/PolyDataReader.js +48 -36
- package/IO/Legacy.js +2 -2
- package/IO/Misc/ElevationReader.js +67 -60
- package/IO/Misc/HttpDataSetLODsLoader.js +41 -38
- package/IO/Misc/ITKImageReader.js +58 -45
- package/IO/Misc/ITKPolyDataReader.js +50 -38
- package/IO/Misc/JSONNucleoReader.js +49 -42
- package/IO/Misc/JSONReader.js +38 -33
- package/IO/Misc/MTLReader.js +74 -119
- package/IO/Misc/OBJReader.js +153 -206
- package/IO/Misc/PDBReader.js +70 -68
- package/IO/Misc/SkyboxReader.js +77 -82
- package/IO/Misc.js +9 -9
- package/IO/XML/XMLImageDataReader.js +36 -38
- package/IO/XML/XMLImageDataWriter.js +28 -21
- package/IO/XML/XMLPolyDataReader.js +49 -46
- package/IO/XML/XMLPolyDataWriter.js +43 -42
- package/IO/XML/XMLReader.js +262 -304
- package/IO/XML/XMLWriter/Constants.js +3 -3
- package/IO/XML/XMLWriter.js +70 -84
- package/IO/XML.js +6 -6
- package/IO/index.js +5 -5
- package/Imaging/Core/AbstractImageInterpolator/Constants.js +4 -4
- package/Imaging/Core/AbstractImageInterpolator/InterpolationInfo.js +30 -27
- package/Imaging/Core/AbstractImageInterpolator.js +74 -87
- package/Imaging/Core/ImageInterpolator.js +201 -252
- package/Imaging/Core/ImagePointDataIterator.js +96 -122
- package/Imaging/Core/ImageReslice/Constants.js +2 -2
- package/Imaging/Core/ImageReslice.js +327 -464
- package/Imaging/Core.js +4 -4
- package/Imaging/Hybrid/SampleFunction.js +58 -51
- package/Imaging/Hybrid.js +1 -1
- package/Imaging/index.js +2 -2
- package/Interaction/Animations/TimeStepBasedAnimationHandler.js +39 -54
- package/Interaction/Manipulators/CompositeCameraManipulator.js +22 -13
- package/Interaction/Manipulators/CompositeGestureManipulator.js +31 -43
- package/Interaction/Manipulators/CompositeKeyboardManipulator.js +15 -11
- package/Interaction/Manipulators/CompositeMouseManipulator.js +27 -33
- package/Interaction/Manipulators/CompositeVRManipulator.js +22 -15
- package/Interaction/Manipulators/GestureCameraManipulator.js +54 -36
- package/Interaction/Manipulators/KeyboardCameraManipulator.js +95 -97
- package/Interaction/Manipulators/MouseBoxSelectorManipulator.js +70 -89
- package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +67 -54
- package/Interaction/Manipulators/MouseCameraSliceManipulator.js +40 -38
- package/Interaction/Manipulators/MouseCameraTrackballFirstPersonManipulator.js +83 -68
- package/Interaction/Manipulators/MouseCameraTrackballMultiRotateManipulator.js +32 -28
- package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.js +47 -40
- package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +55 -43
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +56 -46
- package/Interaction/Manipulators/MouseCameraTrackballZoomManipulator.js +41 -46
- package/Interaction/Manipulators/MouseCameraTrackballZoomToMouseManipulator.js +29 -27
- package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +123 -146
- package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +144 -166
- package/Interaction/Manipulators/MouseRangeManipulator.js +127 -132
- package/Interaction/Manipulators/VRButtonPanManipulator.js +33 -23
- package/Interaction/Manipulators.js +21 -21
- package/Interaction/Misc/DeviceOrientationToCamera.js +25 -47
- package/Interaction/Misc.js +1 -1
- package/Interaction/Style/InteractorStyleImage.js +101 -121
- package/Interaction/Style/InteractorStyleMPRSlice.js +111 -128
- package/Interaction/Style/InteractorStyleManipulator/Presets.js +9 -17
- package/Interaction/Style/InteractorStyleManipulator.js +254 -329
- package/Interaction/Style/InteractorStyleRemoteMouse.js +195 -180
- package/Interaction/Style/InteractorStyleTrackballCamera.js +154 -157
- package/Interaction/Style/InteractorStyleUnicam.js +30 -38
- package/Interaction/Style.js +5 -5
- package/Interaction/UI/CornerAnnotation/CornerAnnotation.module.css.js +1 -1
- package/Interaction/UI/CornerAnnotation.js +65 -48
- package/Interaction/UI/FPSMonitor.js +104 -105
- package/Interaction/UI/Icons.js +1 -1
- package/Interaction/UI/Slider/Constants.js +2 -2
- package/Interaction/UI/Slider.js +78 -95
- package/Interaction/UI/VolumeController.js +104 -97
- package/Interaction/UI.js +5 -5
- package/Interaction/Widgets/OrientationMarkerWidget/Constants.js +2 -2
- package/Interaction/Widgets/OrientationMarkerWidget.js +90 -135
- package/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +0 -3
- package/Interaction/Widgets/PiecewiseGaussianWidget.js +381 -498
- package/Interaction/Widgets.js +2 -2
- package/Interaction/index.js +5 -5
- package/Proxy/Animation/AbstractAnimationProxy.js +22 -15
- package/Proxy/Animation/AnimationProxyManager.js +43 -51
- package/Proxy/Animation/TimeStepBasedAnimationHandlerProxy.js +26 -19
- package/Proxy/Core/AbstractRepresentationProxy.js +97 -151
- package/Proxy/Core/LookupTableProxy/Constants.js +4 -4
- package/Proxy/Core/LookupTableProxy.js +49 -52
- package/Proxy/Core/PiecewiseFunctionProxy/Constants.js +4 -4
- package/Proxy/Core/PiecewiseFunctionProxy.js +63 -72
- package/Proxy/Core/ProxyManager/core.js +83 -106
- package/Proxy/Core/ProxyManager/properties.js +53 -76
- package/Proxy/Core/ProxyManager/state.js +100 -110
- package/Proxy/Core/ProxyManager/view.js +45 -55
- package/Proxy/Core/ProxyManager.js +16 -8
- package/Proxy/Core/SourceProxy.js +41 -38
- package/Proxy/Core/View2DProxy.js +143 -199
- package/Proxy/Core/ViewProxy.js +223 -269
- package/Proxy/Core.js +7 -7
- package/Proxy/Representations/GeometryRepresentationProxy.js +34 -20
- package/Proxy/Representations/GlyphRepresentationProxy.js +42 -41
- package/Proxy/Representations/MoleculeRepresentationProxy.js +32 -22
- package/Proxy/Representations/ResliceRepresentationProxy.js +48 -32
- package/Proxy/Representations/SkyboxRepresentationProxy.js +30 -29
- package/Proxy/Representations/SliceRepresentationProxy.js +93 -112
- package/Proxy/Representations/SlicedGeometryRepresentationProxy.js +46 -42
- package/Proxy/Representations/VolumeRepresentationProxy.js +108 -133
- package/Proxy/Representations.js +7 -7
- package/Proxy/index.js +2 -2
- package/Rendering/Core/AbstractImageMapper/helper.js +44 -49
- package/Rendering/Core/AbstractImageMapper.js +18 -19
- package/Rendering/Core/AbstractMapper.js +39 -55
- package/Rendering/Core/AbstractMapper3D.js +26 -31
- package/Rendering/Core/AbstractPicker.js +25 -21
- package/Rendering/Core/Actor.js +71 -93
- package/Rendering/Core/Actor2D.js +64 -78
- package/Rendering/Core/AnnotatedCubeActor/Presets.js +5 -11
- package/Rendering/Core/AnnotatedCubeActor.js +94 -79
- package/Rendering/Core/AxesActor.js +65 -87
- package/Rendering/Core/Camera.js +246 -271
- package/Rendering/Core/CellPicker.js +125 -148
- package/Rendering/Core/ColorTransferFunction/ColorMaps.js +20 -21
- package/Rendering/Core/ColorTransferFunction/ColorMapsLite.js +20 -21
- package/Rendering/Core/ColorTransferFunction/Constants.js +4 -4
- package/Rendering/Core/ColorTransferFunction.js +460 -546
- package/Rendering/Core/Coordinate/Constants.js +2 -2
- package/Rendering/Core/Coordinate.js +119 -198
- package/Rendering/Core/CubeAxesActor.js +294 -320
- package/Rendering/Core/Follower.js +46 -45
- package/Rendering/Core/Glyph3DMapper/Constants.js +4 -4
- package/Rendering/Core/Glyph3DMapper.js +96 -148
- package/Rendering/Core/HardwareSelector.js +36 -69
- package/Rendering/Core/ImageArrayMapper.js +87 -126
- package/Rendering/Core/ImageCPRMapper.js +134 -209
- package/Rendering/Core/ImageMapper/Constants.js +2 -2
- package/Rendering/Core/ImageMapper.js +85 -144
- package/Rendering/Core/ImageProperty/Constants.js +2 -2
- package/Rendering/Core/ImageProperty.js +66 -81
- package/Rendering/Core/ImageResliceMapper/Constants.js +2 -2
- package/Rendering/Core/ImageResliceMapper.js +36 -29
- package/Rendering/Core/ImageSlice.js +85 -127
- package/Rendering/Core/InteractorObserver.js +82 -73
- package/Rendering/Core/InteractorStyle/Constants.js +2 -2
- package/Rendering/Core/InteractorStyle.js +56 -58
- package/Rendering/Core/Light.js +43 -49
- package/Rendering/Core/Mapper/CoincidentTopologyHelper.js +37 -48
- package/Rendering/Core/Mapper/Constants.js +6 -6
- package/Rendering/Core/Mapper/Static.js +15 -12
- package/Rendering/Core/Mapper.js +194 -259
- package/Rendering/Core/Mapper2D.js +61 -100
- package/Rendering/Core/Picker.js +124 -143
- package/Rendering/Core/PixelSpaceCallbackMapper.js +40 -37
- package/Rendering/Core/PointPicker.js +68 -79
- package/Rendering/Core/Prop/Constants.js +2 -2
- package/Rendering/Core/Prop.js +58 -106
- package/Rendering/Core/Prop3D.js +54 -83
- package/Rendering/Core/Property/Constants.js +6 -6
- package/Rendering/Core/Property.js +45 -74
- package/Rendering/Core/Property2D/Constants.js +2 -2
- package/Rendering/Core/Property2D.js +33 -42
- package/Rendering/Core/RenderWindow.js +70 -82
- package/Rendering/Core/RenderWindowInteractor/Constants.js +7 -7
- package/Rendering/Core/RenderWindowInteractor.js +324 -439
- package/Rendering/Core/Renderer.js +192 -256
- package/Rendering/Core/ScalarBarActor.js +267 -272
- package/Rendering/Core/Skybox.js +26 -24
- package/Rendering/Core/SphereMapper.js +22 -12
- package/Rendering/Core/StickMapper.js +22 -12
- package/Rendering/Core/SurfaceLICInterface/Constants.js +6 -6
- package/Rendering/Core/SurfaceLICInterface.js +13 -9
- package/Rendering/Core/SurfaceLICMapper.js +23 -15
- package/Rendering/Core/Texture.js +99 -141
- package/Rendering/Core/Viewport.js +60 -88
- package/Rendering/Core/Volume.js +55 -77
- package/Rendering/Core/VolumeMapper/Constants.js +4 -4
- package/Rendering/Core/VolumeMapper.js +59 -91
- package/Rendering/Core/VolumeProperty/Constants.js +4 -4
- package/Rendering/Core/VolumeProperty.js +78 -115
- package/Rendering/Core.js +47 -49
- package/Rendering/Misc/CanvasView.js +62 -61
- package/Rendering/Misc/FullScreenRenderWindow.js +60 -62
- package/Rendering/Misc/GenericRenderWindow.js +48 -37
- package/Rendering/Misc/RemoteView.js +86 -80
- package/Rendering/Misc/RenderWindowWithControlBar.js +54 -48
- package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/CameraSynchronizer.js +43 -51
- package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager.js +52 -82
- package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.js +258 -308
- package/Rendering/Misc/SynchronizableRenderWindow.js +133 -163
- package/Rendering/Misc/TextureLODsDownloader.js +72 -74
- package/Rendering/Misc.js +7 -7
- package/Rendering/OpenGL/Actor.js +57 -68
- package/Rendering/OpenGL/Actor2D.js +56 -56
- package/Rendering/OpenGL/BufferObject/Constants.js +2 -2
- package/Rendering/OpenGL/BufferObject.js +50 -65
- package/Rendering/OpenGL/Camera.js +35 -29
- package/Rendering/OpenGL/CellArrayBufferObject.js +119 -149
- package/Rendering/OpenGL/Convolution2DPass.js +87 -81
- package/Rendering/OpenGL/CubeAxesActor.js +28 -21
- package/Rendering/OpenGL/ForwardPass.js +53 -64
- package/Rendering/OpenGL/Framebuffer.js +61 -101
- package/Rendering/OpenGL/Glyph3DMapper.js +165 -196
- package/Rendering/OpenGL/HardwareSelector/Constants.js +2 -2
- package/Rendering/OpenGL/HardwareSelector.js +272 -397
- package/Rendering/OpenGL/Helper.js +58 -73
- package/Rendering/OpenGL/ImageCPRMapper.js +339 -421
- package/Rendering/OpenGL/ImageMapper.js +268 -361
- package/Rendering/OpenGL/ImageResliceMapper.js +306 -438
- package/Rendering/OpenGL/ImageSlice.js +48 -54
- package/Rendering/OpenGL/OrderIndependentTranslucentPass.js +102 -84
- package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +43 -42
- package/Rendering/OpenGL/PolyDataMapper.js +358 -492
- package/Rendering/OpenGL/PolyDataMapper2D.js +153 -205
- package/Rendering/OpenGL/RadialDistortionPass.js +86 -89
- package/Rendering/OpenGL/RenderWindow/Constants.js +2 -2
- package/Rendering/OpenGL/RenderWindow/ContextProxy.js +20 -29
- package/Rendering/OpenGL/RenderWindow.js +356 -510
- package/Rendering/OpenGL/Renderer.js +77 -89
- package/Rendering/OpenGL/ReplacementShaderMapper.js +28 -46
- package/Rendering/OpenGL/ScalarBarActor.js +28 -21
- package/Rendering/OpenGL/Shader.js +37 -31
- package/Rendering/OpenGL/ShaderCache.js +67 -74
- package/Rendering/OpenGL/ShaderProgram.js +136 -248
- package/Rendering/OpenGL/Skybox.js +99 -60
- package/Rendering/OpenGL/SphereMapper.js +94 -108
- package/Rendering/OpenGL/StickMapper.js +110 -114
- package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +91 -157
- package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +142 -151
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +142 -216
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +79 -100
- package/Rendering/OpenGL/SurfaceLIC.js +2 -2
- package/Rendering/OpenGL/Texture/Constants.js +4 -4
- package/Rendering/OpenGL/Texture.js +443 -608
- package/Rendering/OpenGL/TextureUnitManager.js +47 -43
- package/Rendering/OpenGL/VertexArrayObject.js +92 -131
- package/Rendering/OpenGL/ViewNodeFactory.js +25 -13
- package/Rendering/OpenGL/Volume.js +38 -34
- package/Rendering/OpenGL/VolumeMapper.js +437 -547
- package/Rendering/OpenGL.js +28 -28
- package/Rendering/SceneGraph/RenderPass.js +34 -31
- package/Rendering/SceneGraph/RenderWindowViewNode.js +68 -94
- package/Rendering/SceneGraph/ViewNode.js +82 -111
- package/Rendering/SceneGraph/ViewNodeFactory.js +31 -26
- package/Rendering/SceneGraph.js +4 -4
- package/Rendering/WebGPU/Actor.js +49 -49
- package/Rendering/WebGPU/Actor2D.js +45 -44
- package/Rendering/WebGPU/BindGroup.js +43 -50
- package/Rendering/WebGPU/Buffer.js +41 -50
- package/Rendering/WebGPU/BufferManager/Constants.js +4 -4
- package/Rendering/WebGPU/BufferManager.js +111 -141
- package/Rendering/WebGPU/Camera.js +65 -67
- package/Rendering/WebGPU/CellArrayMapper.js +621 -388
- package/Rendering/WebGPU/CubeAxesActor.js +28 -19
- package/Rendering/WebGPU/Device.js +78 -133
- package/Rendering/WebGPU/ForwardPass.js +75 -72
- package/Rendering/WebGPU/FullScreenQuad.js +25 -18
- package/Rendering/WebGPU/Glyph3DMapper.js +62 -74
- package/Rendering/WebGPU/HardwareSelectionPass.js +45 -38
- package/Rendering/WebGPU/HardwareSelector.js +200 -276
- package/Rendering/WebGPU/ImageMapper.js +180 -171
- package/Rendering/WebGPU/ImageSlice.js +45 -44
- package/Rendering/WebGPU/IndexBuffer.js +166 -200
- package/Rendering/WebGPU/OpaquePass.js +37 -36
- package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +72 -45
- package/Rendering/WebGPU/Pipeline.js +37 -51
- package/Rendering/WebGPU/PixelSpaceCallbackMapper.js +27 -19
- package/Rendering/WebGPU/PolyDataMapper.js +50 -53
- package/Rendering/WebGPU/PolyDataMapper2D.js +39 -39
- package/Rendering/WebGPU/RenderEncoder.js +68 -88
- package/Rendering/WebGPU/RenderWindow.js +262 -376
- package/Rendering/WebGPU/Renderer.js +224 -208
- package/Rendering/WebGPU/Sampler.js +27 -21
- package/Rendering/WebGPU/ScalarBarActor.js +28 -19
- package/Rendering/WebGPU/ShaderCache.js +43 -41
- package/Rendering/WebGPU/ShaderDescription.js +52 -59
- package/Rendering/WebGPU/ShaderModule.js +26 -17
- package/Rendering/WebGPU/SimpleMapper.js +185 -121
- package/Rendering/WebGPU/SphereMapper.js +200 -130
- package/Rendering/WebGPU/StickMapper.js +289 -152
- package/Rendering/WebGPU/StorageBuffer.js +100 -115
- package/Rendering/WebGPU/Texture.js +79 -99
- package/Rendering/WebGPU/TextureManager.js +52 -54
- package/Rendering/WebGPU/TextureView.js +40 -43
- package/Rendering/WebGPU/Types.js +53 -70
- package/Rendering/WebGPU/UniformBuffer.js +158 -184
- package/Rendering/WebGPU/VertexInput.js +64 -90
- package/Rendering/WebGPU/ViewNodeFactory.js +25 -13
- package/Rendering/WebGPU/Volume.js +52 -51
- package/Rendering/WebGPU/VolumePass.js +218 -239
- package/Rendering/WebGPU/VolumePassFSQ.js +625 -306
- package/Rendering/WebGPU.js +1 -1
- package/Rendering/index.js +5 -5
- package/Widgets/Core/AbstractWidget/Constants.js +2 -2
- package/Widgets/Core/AbstractWidget.js +49 -58
- package/Widgets/Core/AbstractWidgetFactory.js +101 -122
- package/Widgets/Core/StateBuilder/boundsMixin.js +23 -28
- package/Widgets/Core/StateBuilder/color3Mixin.js +10 -7
- package/Widgets/Core/StateBuilder/colorMixin.js +10 -6
- package/Widgets/Core/StateBuilder/cornerMixin.js +16 -15
- package/Widgets/Core/StateBuilder/directionMixin.js +20 -18
- package/Widgets/Core/StateBuilder/manipulatorMixin.js +26 -18
- package/Widgets/Core/StateBuilder/nameMixin.js +10 -6
- package/Widgets/Core/StateBuilder/orientationMixin.js +19 -16
- package/Widgets/Core/StateBuilder/originMixin.js +25 -32
- package/Widgets/Core/StateBuilder/scale1Mixin.js +10 -6
- package/Widgets/Core/StateBuilder/scale3Mixin.js +10 -6
- package/Widgets/Core/StateBuilder/shapeMixin.js +12 -6
- package/Widgets/Core/StateBuilder/textMixin.js +10 -6
- package/Widgets/Core/StateBuilder/visibleMixin.js +10 -6
- package/Widgets/Core/StateBuilder.js +120 -149
- package/Widgets/Core/WidgetManager/Constants.js +7 -7
- package/Widgets/Core/WidgetManager.js +249 -421
- package/Widgets/Core/WidgetState.js +48 -57
- package/Widgets/Core.js +5 -5
- package/Widgets/Manipulators/AbstractManipulator.js +20 -14
- package/Widgets/Manipulators/CPRManipulator.js +55 -71
- package/Widgets/Manipulators/LineManipulator.js +31 -28
- package/Widgets/Manipulators/PickerManipulator.d.ts +48 -0
- package/Widgets/Manipulators/PickerManipulator.js +65 -0
- package/Widgets/Manipulators/PlaneManipulator.js +26 -23
- package/Widgets/Manipulators/TrackballManipulator.js +39 -35
- package/Widgets/Manipulators.js +4 -2
- package/Widgets/Representations/ArrowHandleRepresentation.js +148 -162
- package/Widgets/Representations/CircleContextRepresentation.js +44 -38
- package/Widgets/Representations/ContextRepresentation.js +17 -14
- package/Widgets/Representations/ConvexFaceContextRepresentation.js +50 -47
- package/Widgets/Representations/CroppingOutlineRepresentation.js +38 -27
- package/Widgets/Representations/CubeHandleRepresentation.js +21 -18
- package/Widgets/Representations/GlyphRepresentation.js +107 -152
- package/Widgets/Representations/HandleRepresentation.js +17 -14
- package/Widgets/Representations/ImplicitPlaneRepresentation.js +97 -91
- package/Widgets/Representations/LineHandleRepresentation.js +44 -41
- package/Widgets/Representations/OutlineContextRepresentation.js +42 -36
- package/Widgets/Representations/PolyLineRepresentation.js +60 -75
- package/Widgets/Representations/RectangleContextRepresentation.js +42 -37
- package/Widgets/Representations/SphereContextRepresentation.js +19 -27
- package/Widgets/Representations/SphereHandleRepresentation.js +31 -27
- package/Widgets/Representations/SplineContextRepresentation.js +46 -70
- package/Widgets/Representations/WidgetRepresentation/Constants.js +2 -2
- package/Widgets/Representations/WidgetRepresentation.js +99 -134
- package/Widgets/Representations.js +13 -13
- package/Widgets/Widgets3D/AngleWidget/behavior.js +41 -63
- package/Widgets/Widgets3D/AngleWidget.js +40 -38
- package/Widgets/Widgets3D/DistanceWidget/behavior.js +40 -61
- package/Widgets/Widgets3D/DistanceWidget.js +38 -36
- package/Widgets/Widgets3D/EllipseWidget/behavior.js +14 -19
- package/Widgets/Widgets3D/EllipseWidget/state.js +4 -2
- package/Widgets/Widgets3D/EllipseWidget.js +37 -26
- package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +26 -56
- package/Widgets/Widgets3D/ImageCroppingWidget/helpers.js +14 -17
- package/Widgets/Widgets3D/ImageCroppingWidget/state.js +20 -16
- package/Widgets/Widgets3D/ImageCroppingWidget.js +80 -98
- package/Widgets/Widgets3D/ImplicitPlaneWidget.js +55 -77
- package/Widgets/Widgets3D/InteractiveOrientationWidget/behavior.js +17 -18
- package/Widgets/Widgets3D/InteractiveOrientationWidget/state.js +15 -7
- package/Widgets/Widgets3D/InteractiveOrientationWidget.js +30 -29
- package/Widgets/Widgets3D/LabelWidget/behavior.js +37 -62
- package/Widgets/Widgets3D/LabelWidget.js +31 -25
- package/Widgets/Widgets3D/LineWidget/Constants.js +8 -8
- package/Widgets/Widgets3D/LineWidget/behavior.js +77 -114
- package/Widgets/Widgets3D/LineWidget/helpers.js +13 -20
- package/Widgets/Widgets3D/LineWidget/state.js +2 -1
- package/Widgets/Widgets3D/LineWidget.js +39 -35
- package/Widgets/Widgets3D/PaintWidget/behavior.js +24 -59
- package/Widgets/Widgets3D/PaintWidget.js +39 -37
- package/Widgets/Widgets3D/PolyLineWidget/behavior.js +44 -68
- package/Widgets/Widgets3D/PolyLineWidget.js +36 -31
- package/Widgets/Widgets3D/RectangleWidget/behavior.js +6 -11
- package/Widgets/Widgets3D/RectangleWidget/state.js +4 -2
- package/Widgets/Widgets3D/RectangleWidget.js +37 -25
- package/Widgets/Widgets3D/ResliceCursorWidget/Constants.js +35 -21
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +133 -209
- package/Widgets/Widgets3D/ResliceCursorWidget/cprBehavior.js +26 -41
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +89 -116
- package/Widgets/Widgets3D/ResliceCursorWidget/state.js +33 -40
- package/Widgets/Widgets3D/ResliceCursorWidget.js +186 -227
- package/Widgets/Widgets3D/SeedWidget/behavior.js +82 -0
- package/Widgets/Widgets3D/SeedWidget/state.js +18 -0
- package/Widgets/Widgets3D/SeedWidget.d.ts +44 -0
- package/Widgets/Widgets3D/SeedWidget.js +43 -0
- package/Widgets/Widgets3D/ShapeWidget/Constants.js +19 -19
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +150 -252
- package/Widgets/Widgets3D/ShapeWidget.js +24 -27
- package/Widgets/Widgets3D/SphereWidget/behavior.js +35 -69
- package/Widgets/Widgets3D/SphereWidget/state.js +9 -5
- package/Widgets/Widgets3D/SphereWidget.js +34 -44
- package/Widgets/Widgets3D/SplineWidget/behavior.js +85 -120
- package/Widgets/Widgets3D/SplineWidget.js +43 -39
- package/Widgets/Widgets3D.js +15 -15
- package/Widgets/index.js +4 -4
- package/_virtual/rollup-plugin-worker-loader__module_Sources/Filters/General/PaintFilter/PaintFilter.worker.js +95 -207
- package/_virtual/rollup-plugin-worker-loader__module_Sources/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +0 -3
- package/favicon.js +5 -6
- package/index.d.ts +4 -2
- package/index.js +4 -3
- package/macros.js +4 -1931
- package/macros2.js +1684 -0
- package/package.json +6 -6
- package/vtk.js +18 -31
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
1
|
import { mat4, vec4 } from 'gl-matrix';
|
|
3
|
-
import macro,
|
|
2
|
+
import { m as macro, v as vtkWarningMacro } from '../../macros2.js';
|
|
4
3
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
5
4
|
import { f as vtkMath } from '../../Common/Core/Math/index.js';
|
|
6
5
|
import vtkMatrixBuilder from '../../Common/Core/MatrixBuilder.js';
|
|
@@ -10,177 +9,147 @@ import vtkImageData from '../../Common/DataModel/ImageData.js';
|
|
|
10
9
|
import vtkImageInterpolator from './ImageInterpolator.js';
|
|
11
10
|
import vtkImagePointDataIterator from './ImagePointDataIterator.js';
|
|
12
11
|
import { InterpolationMode, ImageBorderMode } from './AbstractImageInterpolator/Constants.js';
|
|
13
|
-
import {
|
|
12
|
+
import { vtkInterpolationMathClamp, vtkInterpolationMathFloor, vtkInterpolationMathRound } from './AbstractImageInterpolator/InterpolationInfo.js';
|
|
14
13
|
import Constants from './ImageReslice/Constants.js';
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
const {
|
|
16
|
+
SlabMode
|
|
17
|
+
} = Constants;
|
|
18
|
+
const {
|
|
19
|
+
vtkErrorMacro
|
|
20
|
+
} = macro;
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
var SlabMode = Constants.SlabMode;
|
|
20
|
-
var vtkErrorMacro = macro.vtkErrorMacro; // ----------------------------------------------------------------------------
|
|
22
|
+
// ----------------------------------------------------------------------------
|
|
21
23
|
// vtkImageReslice methods
|
|
22
24
|
// ----------------------------------------------------------------------------
|
|
23
25
|
|
|
24
26
|
function vtkImageReslice(publicAPI, model) {
|
|
25
27
|
// Set our className
|
|
26
28
|
model.classHierarchy.push('vtkImageReslice');
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const superClass = {
|
|
30
|
+
...publicAPI
|
|
31
|
+
};
|
|
32
|
+
let indexMatrix = null;
|
|
33
|
+
let optimizedTransform = null;
|
|
33
34
|
function getImageResliceSlabTrap(tmpPtr, inComponents, sampleCount, f) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
for (var j = 1; j < n; j += 1) {
|
|
35
|
+
const n = sampleCount - 1;
|
|
36
|
+
for (let i = 0; i < inComponents; i += 1) {
|
|
37
|
+
let result = tmpPtr[i] * 0.5;
|
|
38
|
+
for (let j = 1; j < n; j += 1) {
|
|
40
39
|
result += tmpPtr[i + j * inComponents];
|
|
41
40
|
}
|
|
42
|
-
|
|
43
41
|
result += tmpPtr[i + n * inComponents] * 0.5;
|
|
44
42
|
tmpPtr[i] = result * f;
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
|
-
|
|
48
45
|
function getImageResliceSlabSum(tmpPtr, inComponents, sampleCount, f) {
|
|
49
|
-
for (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
for (var j = 1; j < sampleCount; j += 1) {
|
|
46
|
+
for (let i = 0; i < inComponents; i += 1) {
|
|
47
|
+
let result = tmpPtr[i];
|
|
48
|
+
for (let j = 1; j < sampleCount; j += 1) {
|
|
53
49
|
result += tmpPtr[i + j * inComponents];
|
|
54
50
|
}
|
|
55
|
-
|
|
56
51
|
tmpPtr[i] = result * f;
|
|
57
52
|
}
|
|
58
53
|
}
|
|
59
|
-
|
|
60
54
|
function getImageResliceCompositeMinValue(tmpPtr, inComponents, sampleCount) {
|
|
61
|
-
for (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
for (var j = 1; j < sampleCount; j += 1) {
|
|
55
|
+
for (let i = 0; i < inComponents; i += 1) {
|
|
56
|
+
let result = tmpPtr[i];
|
|
57
|
+
for (let j = 1; j < sampleCount; j += 1) {
|
|
65
58
|
result = Math.min(result, tmpPtr[i + j * inComponents]);
|
|
66
59
|
}
|
|
67
|
-
|
|
68
60
|
tmpPtr[i] = result;
|
|
69
61
|
}
|
|
70
62
|
}
|
|
71
|
-
|
|
72
63
|
function getImageResliceCompositeMaxValue(tmpPtr, inComponents, sampleCount) {
|
|
73
|
-
for (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
for (var j = 1; j < sampleCount; j += 1) {
|
|
64
|
+
for (let i = 0; i < inComponents; i += 1) {
|
|
65
|
+
let result = tmpPtr[i];
|
|
66
|
+
for (let j = 1; j < sampleCount; j += 1) {
|
|
77
67
|
result = Math.max(result, tmpPtr[i + j * inComponents]);
|
|
78
68
|
}
|
|
79
|
-
|
|
80
69
|
tmpPtr[i] = result;
|
|
81
70
|
}
|
|
82
71
|
}
|
|
83
|
-
|
|
84
72
|
function getImageResliceCompositeMeanValue(tmpPtr, inComponents, sampleCount) {
|
|
85
|
-
|
|
73
|
+
const f = 1.0 / sampleCount;
|
|
86
74
|
getImageResliceSlabSum(tmpPtr, inComponents, sampleCount, f);
|
|
87
75
|
}
|
|
88
|
-
|
|
89
76
|
function getImageResliceCompositeMeanTrap(tmpPtr, inComponents, sampleCount) {
|
|
90
|
-
|
|
77
|
+
const f = 1.0 / (sampleCount - 1);
|
|
91
78
|
getImageResliceSlabTrap(tmpPtr, inComponents, sampleCount, f);
|
|
92
79
|
}
|
|
93
|
-
|
|
94
80
|
function getImageResliceCompositeSumValue(tmpPtr, inComponents, sampleCount) {
|
|
95
|
-
|
|
81
|
+
const f = 1.0;
|
|
96
82
|
getImageResliceSlabSum(tmpPtr, inComponents, sampleCount, f);
|
|
97
83
|
}
|
|
98
|
-
|
|
99
84
|
function getImageResliceCompositeSumTrap(tmpPtr, inComponents, sampleCount) {
|
|
100
|
-
|
|
85
|
+
const f = 1.0;
|
|
101
86
|
getImageResliceSlabTrap(tmpPtr, inComponents, sampleCount, f);
|
|
102
87
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
var mTime = superClass.getMTime();
|
|
106
|
-
|
|
88
|
+
publicAPI.getMTime = () => {
|
|
89
|
+
let mTime = superClass.getMTime();
|
|
107
90
|
if (model.resliceTransform) {
|
|
108
91
|
mTime = Math.max(mTime, model.resliceTransform.getMTime());
|
|
109
92
|
}
|
|
110
|
-
|
|
111
93
|
return mTime;
|
|
112
94
|
};
|
|
113
|
-
|
|
114
|
-
publicAPI.setResliceAxes = function (resliceAxes) {
|
|
95
|
+
publicAPI.setResliceAxes = resliceAxes => {
|
|
115
96
|
if (!model.resliceAxes) {
|
|
116
97
|
model.resliceAxes = mat4.identity(new Float64Array(16));
|
|
117
98
|
}
|
|
118
|
-
|
|
119
99
|
if (!mat4.exactEquals(model.resliceAxes, resliceAxes)) {
|
|
120
100
|
mat4.copy(model.resliceAxes, resliceAxes);
|
|
121
101
|
publicAPI.modified();
|
|
122
102
|
return true;
|
|
123
103
|
}
|
|
124
|
-
|
|
125
104
|
return null;
|
|
126
105
|
};
|
|
127
|
-
|
|
128
|
-
publicAPI.requestData = function (inData, outData) {
|
|
106
|
+
publicAPI.requestData = (inData, outData) => {
|
|
129
107
|
// implement requestData
|
|
130
|
-
|
|
131
|
-
|
|
108
|
+
const input = inData[0];
|
|
132
109
|
if (!input) {
|
|
133
110
|
vtkErrorMacro('Invalid or missing input');
|
|
134
111
|
return;
|
|
135
|
-
}
|
|
136
|
-
// Retrieve output and volume data
|
|
137
|
-
|
|
112
|
+
}
|
|
138
113
|
|
|
139
|
-
|
|
140
|
-
var inSpacing = input.getSpacing();
|
|
141
|
-
var dims = input.getDimensions();
|
|
142
|
-
var inScalars = input.getPointData().getScalars();
|
|
143
|
-
var inWholeExt = [0, dims[0] - 1, 0, dims[1] - 1, 0, dims[2] - 1];
|
|
144
|
-
var outOrigin = [0, 0, 0];
|
|
145
|
-
var outSpacing = [1, 1, 1];
|
|
146
|
-
var outWholeExt = [0, 0, 0, 0, 0, 0];
|
|
147
|
-
var outDims = [0, 0, 0];
|
|
148
|
-
var matrix = mat4.identity(new Float64Array(16));
|
|
114
|
+
// console.time('reslice');
|
|
149
115
|
|
|
116
|
+
// Retrieve output and volume data
|
|
117
|
+
const origin = input.getOrigin();
|
|
118
|
+
const inSpacing = input.getSpacing();
|
|
119
|
+
const dims = input.getDimensions();
|
|
120
|
+
const inScalars = input.getPointData().getScalars();
|
|
121
|
+
const inWholeExt = [0, dims[0] - 1, 0, dims[1] - 1, 0, dims[2] - 1];
|
|
122
|
+
const outOrigin = [0, 0, 0];
|
|
123
|
+
const outSpacing = [1, 1, 1];
|
|
124
|
+
const outWholeExt = [0, 0, 0, 0, 0, 0];
|
|
125
|
+
const outDims = [0, 0, 0];
|
|
126
|
+
const matrix = mat4.identity(new Float64Array(16));
|
|
150
127
|
if (model.resliceAxes) {
|
|
151
128
|
mat4.multiply(matrix, matrix, model.resliceAxes);
|
|
152
129
|
}
|
|
153
|
-
|
|
154
|
-
var imatrix = new Float64Array(16);
|
|
130
|
+
const imatrix = new Float64Array(16);
|
|
155
131
|
mat4.invert(imatrix, matrix);
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
132
|
+
const inCenter = [origin[0] + 0.5 * (inWholeExt[0] + inWholeExt[1]) * inSpacing[0], origin[1] + 0.5 * (inWholeExt[2] + inWholeExt[3]) * inSpacing[1], origin[2] + 0.5 * (inWholeExt[4] + inWholeExt[5]) * inSpacing[2]];
|
|
133
|
+
let maxBounds = null;
|
|
159
134
|
if (model.autoCropOutput) {
|
|
160
135
|
maxBounds = publicAPI.getAutoCroppedOutputBounds(input);
|
|
161
136
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
var e = 0; // default extent start
|
|
169
|
-
|
|
170
|
-
var c = 0; // transformed center-of-volume
|
|
137
|
+
for (let i = 0; i < 3; i++) {
|
|
138
|
+
let s = 0; // default output spacing
|
|
139
|
+
let d = 0; // default linear dimension
|
|
140
|
+
let e = 0; // default extent start
|
|
141
|
+
let c = 0; // transformed center-of-volume
|
|
171
142
|
|
|
172
143
|
if (model.transformInputSampling) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
for (var j = 0; j < 3; j++) {
|
|
144
|
+
let r = 0.0;
|
|
145
|
+
for (let j = 0; j < 3; j++) {
|
|
176
146
|
c += imatrix[4 * j + i] * (inCenter[j] - matrix[4 * 3 + j]);
|
|
177
|
-
|
|
147
|
+
const tmp = matrix[4 * i + j] * matrix[4 * i + j];
|
|
178
148
|
s += tmp * Math.abs(inSpacing[j]);
|
|
179
149
|
d += tmp * (inWholeExt[2 * j + 1] - inWholeExt[2 * j]) * Math.abs(inSpacing[j]);
|
|
180
150
|
e += tmp * inWholeExt[2 * j];
|
|
181
151
|
r += tmp;
|
|
182
152
|
}
|
|
183
|
-
|
|
184
153
|
s /= r;
|
|
185
154
|
d /= r * Math.sqrt(r);
|
|
186
155
|
e /= r;
|
|
@@ -190,13 +159,11 @@ function vtkImageReslice(publicAPI, model) {
|
|
|
190
159
|
d = (inWholeExt[2 * i + 1] - inWholeExt[2 * i]) * s;
|
|
191
160
|
e = inWholeExt[2 * i];
|
|
192
161
|
}
|
|
193
|
-
|
|
194
162
|
if (model.outputSpacing == null) {
|
|
195
163
|
outSpacing[i] = s;
|
|
196
164
|
} else {
|
|
197
165
|
outSpacing[i] = model.outputSpacing[i];
|
|
198
166
|
}
|
|
199
|
-
|
|
200
167
|
if (i >= model.outputDimensionality) {
|
|
201
168
|
outWholeExt[2 * i] = 0;
|
|
202
169
|
outWholeExt[2 * i + 1] = 0;
|
|
@@ -204,14 +171,12 @@ function vtkImageReslice(publicAPI, model) {
|
|
|
204
171
|
if (model.autoCropOutput) {
|
|
205
172
|
d = maxBounds[2 * i + 1] - maxBounds[2 * i];
|
|
206
173
|
}
|
|
207
|
-
|
|
208
174
|
outWholeExt[2 * i] = Math.round(e);
|
|
209
175
|
outWholeExt[2 * i + 1] = Math.round(outWholeExt[2 * i] + Math.abs(d / outSpacing[i]));
|
|
210
176
|
} else {
|
|
211
177
|
outWholeExt[2 * i] = model.outputExtent[2 * i];
|
|
212
178
|
outWholeExt[2 * i + 1] = model.outputExtent[2 * i + 1];
|
|
213
179
|
}
|
|
214
|
-
|
|
215
180
|
if (i >= model.outputDimensionality) {
|
|
216
181
|
outOrigin[i] = 0;
|
|
217
182
|
} else if (model.outputOrigin == null) {
|
|
@@ -225,180 +190,173 @@ function vtkImageReslice(publicAPI, model) {
|
|
|
225
190
|
} else {
|
|
226
191
|
outOrigin[i] = model.outputOrigin[i];
|
|
227
192
|
}
|
|
228
|
-
|
|
229
193
|
outDims[i] = outWholeExt[2 * i + 1] - outWholeExt[2 * i] + 1;
|
|
230
194
|
}
|
|
231
|
-
|
|
232
|
-
var dataType = inScalars.getDataType();
|
|
233
|
-
|
|
195
|
+
let dataType = inScalars.getDataType();
|
|
234
196
|
if (model.outputScalarType) {
|
|
235
197
|
dataType = model.outputScalarType;
|
|
236
198
|
}
|
|
199
|
+
const numComponents = input.getPointData().getScalars().getNumberOfComponents(); // or s.numberOfComponents;
|
|
237
200
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
var outScalarsData = macro.newTypedArray(dataType, outDims[0] * outDims[1] * outDims[2] * numComponents);
|
|
241
|
-
var outScalars = vtkDataArray.newInstance({
|
|
201
|
+
const outScalarsData = macro.newTypedArray(dataType, outDims[0] * outDims[1] * outDims[2] * numComponents);
|
|
202
|
+
const outScalars = vtkDataArray.newInstance({
|
|
242
203
|
name: 'Scalars',
|
|
243
204
|
values: outScalarsData,
|
|
244
205
|
numberOfComponents: numComponents
|
|
245
|
-
});
|
|
206
|
+
});
|
|
246
207
|
|
|
247
|
-
|
|
208
|
+
// Update output
|
|
209
|
+
const output = vtkImageData.newInstance();
|
|
248
210
|
output.setDimensions(outDims);
|
|
249
211
|
output.setOrigin(outOrigin);
|
|
250
212
|
output.setSpacing(outSpacing);
|
|
251
|
-
|
|
252
213
|
if (model.outputDirection) {
|
|
253
214
|
output.setDirection(model.outputDirection);
|
|
254
215
|
}
|
|
255
|
-
|
|
256
216
|
output.getPointData().setScalars(outScalars);
|
|
257
217
|
publicAPI.getIndexMatrix(input, output);
|
|
258
|
-
|
|
218
|
+
let interpolationMode = model.interpolationMode;
|
|
259
219
|
model.usePermuteExecute = false;
|
|
260
|
-
|
|
261
220
|
if (model.optimization) {
|
|
262
221
|
if (model.slabSliceSpacingFraction === 1.0 && model.interpolator.isSeparable() && publicAPI.isPermutationMatrix(indexMatrix)) {
|
|
263
222
|
model.usePermuteExecute = true;
|
|
264
|
-
|
|
265
223
|
if (publicAPI.canUseNearestNeighbor(indexMatrix, outWholeExt)) {
|
|
266
224
|
interpolationMode = InterpolationMode.NEAREST;
|
|
267
225
|
}
|
|
268
226
|
}
|
|
269
227
|
}
|
|
270
|
-
|
|
271
228
|
model.interpolator.setInterpolationMode(interpolationMode);
|
|
272
|
-
|
|
229
|
+
let borderMode = ImageBorderMode.CLAMP;
|
|
273
230
|
borderMode = model.wrap ? ImageBorderMode.REPEAT : borderMode;
|
|
274
231
|
borderMode = model.mirror ? ImageBorderMode.MIRROR : borderMode;
|
|
275
232
|
model.interpolator.setBorderMode(borderMode);
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
233
|
+
const mintol = 7.62939453125e-6;
|
|
234
|
+
const maxtol = 2.0 * 2147483647;
|
|
235
|
+
let tol = 0.5 * model.border;
|
|
279
236
|
tol = borderMode === ImageBorderMode.CLAMP ? tol : maxtol;
|
|
280
237
|
tol = tol > mintol ? tol : mintol;
|
|
281
238
|
model.interpolator.setTolerance(tol);
|
|
282
239
|
model.interpolator.initialize(input);
|
|
283
240
|
publicAPI.vtkImageResliceExecute(input, output);
|
|
284
241
|
model.interpolator.releaseData();
|
|
285
|
-
outData[0] = output;
|
|
242
|
+
outData[0] = output;
|
|
243
|
+
|
|
244
|
+
// console.timeEnd('reslice');
|
|
286
245
|
};
|
|
287
246
|
|
|
288
|
-
publicAPI.vtkImageResliceExecute =
|
|
247
|
+
publicAPI.vtkImageResliceExecute = (input, output) => {
|
|
289
248
|
// const outDims = output.getDimensions();
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
249
|
+
const inScalars = input.getPointData().getScalars();
|
|
250
|
+
const outScalars = output.getPointData().getScalars();
|
|
251
|
+
let outPtr = outScalars.getData();
|
|
252
|
+
const outExt = output.getExtent();
|
|
253
|
+
const newmat = indexMatrix;
|
|
254
|
+
|
|
255
|
+
// multiple samples for thick slabs
|
|
256
|
+
const nsamples = Math.max(model.slabNumberOfSlices, 1);
|
|
257
|
+
|
|
258
|
+
// spacing between slab samples (as a fraction of slice spacing).
|
|
259
|
+
const slabSampleSpacing = model.slabSliceSpacingFraction;
|
|
260
|
+
|
|
261
|
+
// check for perspective transformation
|
|
262
|
+
const perspective = publicAPI.isPerspectiveMatrix(newmat);
|
|
263
|
+
|
|
264
|
+
// extra scalar info for nearest-neighbor optimization
|
|
265
|
+
let inPtr = inScalars.getData();
|
|
266
|
+
const inputScalarSize = 1; // inScalars.getElementComponentSize(); // inScalars.getDataTypeSize();
|
|
267
|
+
const inputScalarType = inScalars.getDataType();
|
|
268
|
+
const inComponents = inScalars.getNumberOfComponents(); // interpolator.GetNumberOfComponents();
|
|
269
|
+
const componentOffset = model.interpolator.getComponentOffset();
|
|
270
|
+
const borderMode = model.interpolator.getBorderMode();
|
|
271
|
+
const inDims = input.getDimensions();
|
|
272
|
+
const inExt = [0, inDims[0] - 1, 0, inDims[1] - 1, 0, inDims[2] - 1]; // interpolator->GetExtent();
|
|
273
|
+
const inInc = [0, 0, 0];
|
|
314
274
|
inInc[0] = inScalars.getNumberOfComponents();
|
|
315
275
|
inInc[1] = inInc[0] * inDims[0];
|
|
316
276
|
inInc[2] = inInc[1] * inDims[1];
|
|
317
|
-
|
|
318
|
-
|
|
277
|
+
const fullSize = inDims[0] * inDims[1] * inDims[2];
|
|
319
278
|
if (componentOffset > 0 && componentOffset + inComponents < inInc[0]) {
|
|
320
279
|
inPtr = inPtr.subarray(inputScalarSize * componentOffset);
|
|
321
280
|
}
|
|
322
|
-
|
|
323
|
-
var interpolationMode = InterpolationMode.NEAREST;
|
|
324
|
-
|
|
281
|
+
let interpolationMode = InterpolationMode.NEAREST;
|
|
325
282
|
if (model.interpolator.isA('vtkImageInterpolator')) {
|
|
326
283
|
interpolationMode = model.interpolator.getInterpolationMode();
|
|
327
284
|
}
|
|
285
|
+
const convertScalars = null;
|
|
286
|
+
const rescaleScalars = model.scalarShift !== 0.0 || model.scalarScale !== 1.0;
|
|
328
287
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
var optimizeNearest = interpolationMode === InterpolationMode.NEAREST && borderMode === ImageBorderMode.CLAMP && !(perspective || convertScalars != null || rescaleScalars) && inputScalarType === outScalars.getDataType() && fullSize === inScalars.getNumberOfTuples() && model.border === true && nsamples <= 1; // get pixel information
|
|
288
|
+
// is nearest neighbor optimization possible?
|
|
289
|
+
const optimizeNearest = interpolationMode === InterpolationMode.NEAREST && borderMode === ImageBorderMode.CLAMP && !(perspective || convertScalars != null || rescaleScalars) && inputScalarType === outScalars.getDataType() && fullSize === inScalars.getNumberOfTuples() && model.border === true && nsamples <= 1;
|
|
333
290
|
|
|
334
|
-
|
|
335
|
-
|
|
291
|
+
// get pixel information
|
|
292
|
+
const scalarType = outScalars.getDataType();
|
|
293
|
+
const scalarSize = 1; // outScalars.getElementComponentSize() // outScalars.scalarSize;
|
|
294
|
+
const outComponents = outScalars.getNumberOfComponents();
|
|
336
295
|
|
|
337
|
-
|
|
296
|
+
// break matrix into a set of axes plus an origin
|
|
338
297
|
// (this allows us to calculate the transform Incrementally)
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
for (var i = 0; i < 4; ++i) {
|
|
298
|
+
const xAxis = [0, 0, 0, 0];
|
|
299
|
+
const yAxis = [0, 0, 0, 0];
|
|
300
|
+
const zAxis = [0, 0, 0, 0];
|
|
301
|
+
const origin = [0, 0, 0, 0];
|
|
302
|
+
for (let i = 0; i < 4; ++i) {
|
|
346
303
|
xAxis[i] = newmat[4 * 0 + i];
|
|
347
304
|
yAxis[i] = newmat[4 * 1 + i];
|
|
348
305
|
zAxis[i] = newmat[4 * 2 + i];
|
|
349
306
|
origin[i] = newmat[4 * 3 + i];
|
|
350
|
-
}
|
|
351
|
-
|
|
307
|
+
}
|
|
352
308
|
|
|
309
|
+
// get the input origin and spacing for conversion purposes
|
|
353
310
|
model.interpolator.getOrigin();
|
|
354
|
-
|
|
355
|
-
[1.0 / inSpacing[0], 1.0 / inSpacing[1], 1.0 / inSpacing[2]];
|
|
356
|
-
|
|
357
|
-
var floatPtr = null;
|
|
311
|
+
const inSpacing = model.interpolator.getSpacing();
|
|
312
|
+
[1.0 / inSpacing[0], 1.0 / inSpacing[1], 1.0 / inSpacing[2]];
|
|
358
313
|
|
|
314
|
+
// allocate an output row of type double
|
|
315
|
+
let floatPtr = null;
|
|
359
316
|
if (!optimizeNearest) {
|
|
360
317
|
floatPtr = new Float64Array(inComponents * (outExt[1] - outExt[0] + nsamples));
|
|
361
318
|
}
|
|
319
|
+
const background = macro.newTypedArray(inputScalarType, model.backgroundColor);
|
|
362
320
|
|
|
363
|
-
|
|
321
|
+
// set color for area outside of input volume extent
|
|
364
322
|
// void *background;
|
|
365
323
|
// vtkAllocBackgroundPixel(&background,
|
|
366
324
|
// self->GetBackgroundColor(), scalarType, scalarSize, outComponents);
|
|
367
|
-
// get various helper functions
|
|
368
|
-
|
|
369
|
-
var forceClamping = interpolationMode > InterpolationMode.LINEAR || nsamples > 1 && model.slabMode === SlabMode.SUM;
|
|
370
|
-
var convertpixels = publicAPI.getConversionFunc(inputScalarType, scalarType, model.scalarShift, model.scalarScale, forceClamping);
|
|
371
|
-
var setpixels = publicAPI.getSetPixelsFunc(scalarType, scalarSize, outComponents, outPtr);
|
|
372
|
-
var composite = publicAPI.getCompositeFunc(model.slabMode, model.slabTrapezoidIntegration); // create some variables for when we march through the data
|
|
373
|
-
|
|
374
|
-
var idY = outExt[2] - 1;
|
|
375
|
-
var idZ = outExt[4] - 1;
|
|
376
|
-
var inPoint0 = [0.0, 0.0, 0.0, 0.0];
|
|
377
|
-
var inPoint1 = [0.0, 0.0, 0.0, 0.0]; // create an iterator to march through the data
|
|
378
325
|
|
|
379
|
-
|
|
326
|
+
// get various helper functions
|
|
327
|
+
const forceClamping = interpolationMode > InterpolationMode.LINEAR || nsamples > 1 && model.slabMode === SlabMode.SUM;
|
|
328
|
+
const convertpixels = publicAPI.getConversionFunc(inputScalarType, scalarType, model.scalarShift, model.scalarScale, forceClamping);
|
|
329
|
+
const setpixels = publicAPI.getSetPixelsFunc(scalarType, scalarSize, outComponents, outPtr);
|
|
330
|
+
const composite = publicAPI.getCompositeFunc(model.slabMode, model.slabTrapezoidIntegration);
|
|
331
|
+
|
|
332
|
+
// create some variables for when we march through the data
|
|
333
|
+
let idY = outExt[2] - 1;
|
|
334
|
+
let idZ = outExt[4] - 1;
|
|
335
|
+
const inPoint0 = [0.0, 0.0, 0.0, 0.0];
|
|
336
|
+
const inPoint1 = [0.0, 0.0, 0.0, 0.0];
|
|
337
|
+
|
|
338
|
+
// create an iterator to march through the data
|
|
339
|
+
const iter = vtkImagePointDataIterator.newInstance();
|
|
380
340
|
iter.initialize(output, outExt, model.stencil, null);
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
341
|
+
const outPtr0 = iter.getScalars(output, 0);
|
|
342
|
+
let outPtrIndex = 0;
|
|
343
|
+
const outTmp = macro.newTypedArray(scalarType, vtkBoundingBox.getDiagonalLength(outExt) * outComponents * 2);
|
|
344
|
+
const interpolatedPtr = new Float64Array(inComponents * nsamples);
|
|
345
|
+
const interpolatedPoint = new Float64Array(inComponents);
|
|
387
346
|
for (; !iter.isAtEnd(); iter.nextSpan()) {
|
|
388
|
-
|
|
347
|
+
const span = iter.spanEndId() - iter.getId();
|
|
389
348
|
outPtrIndex = iter.getId() * scalarSize * outComponents;
|
|
390
|
-
|
|
391
349
|
if (!iter.isInStencil()) {
|
|
392
350
|
// clear any regions that are outside the stencil
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
outPtr0[outPtrIndex++] = outTmp[_i];
|
|
351
|
+
const n = setpixels(outTmp, background, outComponents, span);
|
|
352
|
+
for (let i = 0; i < n; ++i) {
|
|
353
|
+
outPtr0[outPtrIndex++] = outTmp[i];
|
|
397
354
|
}
|
|
398
355
|
} else {
|
|
399
356
|
// get output index, and compute position in input image
|
|
400
|
-
|
|
357
|
+
const outIndex = iter.getIndex();
|
|
401
358
|
|
|
359
|
+
// if Z index increased, then advance position along Z axis
|
|
402
360
|
if (outIndex[2] > idZ) {
|
|
403
361
|
idZ = outIndex[2];
|
|
404
362
|
inPoint0[0] = origin[0] + idZ * zAxis[0];
|
|
@@ -406,40 +364,37 @@ function vtkImageReslice(publicAPI, model) {
|
|
|
406
364
|
inPoint0[2] = origin[2] + idZ * zAxis[2];
|
|
407
365
|
inPoint0[3] = origin[3] + idZ * zAxis[3];
|
|
408
366
|
idY = outExt[2] - 1;
|
|
409
|
-
}
|
|
410
|
-
|
|
367
|
+
}
|
|
411
368
|
|
|
369
|
+
// if Y index increased, then advance position along Y axis
|
|
412
370
|
if (outIndex[1] > idY) {
|
|
413
371
|
idY = outIndex[1];
|
|
414
372
|
inPoint1[0] = inPoint0[0] + idY * yAxis[0];
|
|
415
373
|
inPoint1[1] = inPoint0[1] + idY * yAxis[1];
|
|
416
374
|
inPoint1[2] = inPoint0[2] + idY * yAxis[2];
|
|
417
375
|
inPoint1[3] = inPoint0[3] + idY * yAxis[3];
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
var idXmin = outIndex[0];
|
|
422
|
-
var idXmax = idXmin + span - 1;
|
|
376
|
+
}
|
|
423
377
|
|
|
378
|
+
// march through one row of the output image
|
|
379
|
+
const idXmin = outIndex[0];
|
|
380
|
+
const idXmax = idXmin + span - 1;
|
|
424
381
|
if (!optimizeNearest) {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
382
|
+
let wasInBounds = 1;
|
|
383
|
+
let isInBounds = 1;
|
|
384
|
+
let startIdX = idXmin;
|
|
385
|
+
let idX = idXmin;
|
|
386
|
+
const tmpPtr = floatPtr;
|
|
387
|
+
let pixelIndex = 0;
|
|
432
388
|
while (startIdX <= idXmax) {
|
|
433
389
|
for (; idX <= idXmax && isInBounds === wasInBounds; idX++) {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
390
|
+
const inPoint2 = [inPoint1[0] + idX * xAxis[0], inPoint1[1] + idX * xAxis[1], inPoint1[2] + idX * xAxis[2], inPoint1[3] + idX * xAxis[3]];
|
|
391
|
+
const inPoint3 = [0, 0, 0, 0];
|
|
392
|
+
let inPoint = inPoint2;
|
|
437
393
|
isInBounds = false;
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
for (var sample = 0; sample < nsamples; ++sample) {
|
|
394
|
+
let interpolatedPtrIndex = 0;
|
|
395
|
+
for (let sample = 0; sample < nsamples; ++sample) {
|
|
441
396
|
if (nsamples > 1) {
|
|
442
|
-
|
|
397
|
+
let s = sample - 0.5 * (nsamples - 1);
|
|
443
398
|
s *= slabSampleSpacing;
|
|
444
399
|
inPoint3[0] = inPoint2[0] + s * zAxis[0];
|
|
445
400
|
inPoint3[1] = inPoint2[1] + s * zAxis[1];
|
|
@@ -447,148 +402,126 @@ function vtkImageReslice(publicAPI, model) {
|
|
|
447
402
|
inPoint3[3] = inPoint2[3] + s * zAxis[3];
|
|
448
403
|
inPoint = inPoint3;
|
|
449
404
|
}
|
|
450
|
-
|
|
451
405
|
if (perspective) {
|
|
452
406
|
// only do perspective if necessary
|
|
453
|
-
|
|
407
|
+
const f = 1 / inPoint[3];
|
|
454
408
|
inPoint[0] *= f;
|
|
455
409
|
inPoint[1] *= f;
|
|
456
410
|
inPoint[2] *= f;
|
|
457
411
|
}
|
|
458
|
-
|
|
459
412
|
if (model.interpolator.checkBoundsIJK(inPoint)) {
|
|
460
413
|
// do the interpolation
|
|
461
414
|
isInBounds = 1;
|
|
462
415
|
model.interpolator.interpolateIJK(inPoint, interpolatedPoint);
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
interpolatedPtr[interpolatedPtrIndex++] = interpolatedPoint[_i2];
|
|
416
|
+
for (let i = 0; i < inComponents; ++i) {
|
|
417
|
+
interpolatedPtr[interpolatedPtrIndex++] = interpolatedPoint[i];
|
|
466
418
|
}
|
|
467
419
|
}
|
|
468
420
|
}
|
|
469
|
-
|
|
470
421
|
if (interpolatedPtrIndex > inComponents) {
|
|
471
422
|
composite(interpolatedPtr, inComponents, interpolatedPtrIndex / inComponents);
|
|
472
423
|
}
|
|
424
|
+
for (let i = 0; i < inComponents; ++i) {
|
|
425
|
+
tmpPtr[pixelIndex++] = interpolatedPtr[i];
|
|
426
|
+
}
|
|
473
427
|
|
|
474
|
-
|
|
475
|
-
tmpPtr[pixelIndex++] = interpolatedPtr[_i3];
|
|
476
|
-
} // set "was in" to "is in" if first pixel
|
|
477
|
-
|
|
478
|
-
|
|
428
|
+
// set "was in" to "is in" if first pixel
|
|
479
429
|
wasInBounds = idX > idXmin ? wasInBounds : isInBounds;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
var endIdX = idX - 1 - (isInBounds !== wasInBounds);
|
|
484
|
-
var numpixels = endIdX - startIdX + 1;
|
|
485
|
-
var _n = 0;
|
|
430
|
+
}
|
|
486
431
|
|
|
432
|
+
// write a segment to the output
|
|
433
|
+
const endIdX = idX - 1 - (isInBounds !== wasInBounds);
|
|
434
|
+
const numpixels = endIdX - startIdX + 1;
|
|
435
|
+
let n = 0;
|
|
487
436
|
if (wasInBounds) {
|
|
488
|
-
|
|
489
437
|
if (rescaleScalars) {
|
|
490
438
|
publicAPI.rescaleScalars(floatPtr, inComponents, idXmax - idXmin + 1, model.scalarShift, model.scalarScale);
|
|
491
439
|
}
|
|
492
|
-
|
|
493
440
|
{
|
|
494
|
-
|
|
441
|
+
n = convertpixels(outTmp, floatPtr.subarray(startIdX * inComponents), outComponents, numpixels);
|
|
495
442
|
}
|
|
496
443
|
} else {
|
|
497
|
-
|
|
444
|
+
n = setpixels(outTmp, background, outComponents, numpixels);
|
|
498
445
|
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
outPtr0[outPtrIndex++] = outTmp[_i4];
|
|
446
|
+
for (let i = 0; i < n; ++i) {
|
|
447
|
+
outPtr0[outPtrIndex++] = outTmp[i];
|
|
502
448
|
}
|
|
503
|
-
|
|
504
449
|
startIdX += numpixels;
|
|
505
450
|
wasInBounds = isInBounds;
|
|
506
451
|
}
|
|
507
452
|
} else {
|
|
508
453
|
// optimize for nearest-neighbor interpolation
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
var inIdX = vtkInterpolationMathRound(_inPoint[0]) - inExt[0];
|
|
527
|
-
var inIdY = vtkInterpolationMathRound(_inPoint[1]) - inExt[2];
|
|
528
|
-
var inIdZ = vtkInterpolationMathRound(_inPoint[2]) - inExt[4];
|
|
529
|
-
|
|
454
|
+
const inPtrTmp0 = inPtr;
|
|
455
|
+
const outPtrTmp = outPtr;
|
|
456
|
+
const inIncX = inInc[0] * inputScalarSize;
|
|
457
|
+
const inIncY = inInc[1] * inputScalarSize;
|
|
458
|
+
const inIncZ = inInc[2] * inputScalarSize;
|
|
459
|
+
const inExtX = inExt[1] - inExt[0] + 1;
|
|
460
|
+
const inExtY = inExt[3] - inExt[2] + 1;
|
|
461
|
+
const inExtZ = inExt[5] - inExt[4] + 1;
|
|
462
|
+
let startIdX = idXmin;
|
|
463
|
+
let endIdX = idXmin - 1;
|
|
464
|
+
let isInBounds = false;
|
|
465
|
+
const bytesPerPixel = inputScalarSize * inComponents;
|
|
466
|
+
for (let iidX = idXmin; iidX <= idXmax; iidX++) {
|
|
467
|
+
const inPoint = [inPoint1[0] + iidX * xAxis[0], inPoint1[1] + iidX * xAxis[1], inPoint1[2] + iidX * xAxis[2]];
|
|
468
|
+
const inIdX = vtkInterpolationMathRound(inPoint[0]) - inExt[0];
|
|
469
|
+
const inIdY = vtkInterpolationMathRound(inPoint[1]) - inExt[2];
|
|
470
|
+
const inIdZ = vtkInterpolationMathRound(inPoint[2]) - inExt[4];
|
|
530
471
|
if (inIdX >= 0 && inIdX < inExtX && inIdY >= 0 && inIdY < inExtY && inIdZ >= 0 && inIdZ < inExtZ) {
|
|
531
|
-
if (!
|
|
472
|
+
if (!isInBounds) {
|
|
532
473
|
// clear leading out-of-bounds pixels
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
for (var _i5 = 0; _i5 < _n3; ++_i5) {
|
|
539
|
-
outPtr0[outPtrIndex++] = outTmp[_i5];
|
|
474
|
+
startIdX = iidX;
|
|
475
|
+
isInBounds = true;
|
|
476
|
+
const n = setpixels(outTmp, background, outComponents, startIdX - idXmin);
|
|
477
|
+
for (let i = 0; i < n; ++i) {
|
|
478
|
+
outPtr0[outPtrIndex++] = outTmp[i];
|
|
540
479
|
}
|
|
541
|
-
}
|
|
542
|
-
|
|
480
|
+
}
|
|
481
|
+
// set the final index that was within input bounds
|
|
482
|
+
endIdX = iidX;
|
|
543
483
|
|
|
544
|
-
|
|
484
|
+
// perform nearest-neighbor interpolation via pixel copy
|
|
485
|
+
let offset = inIdX * inIncX + inIdY * inIncY + inIdZ * inIncZ;
|
|
545
486
|
|
|
546
|
-
|
|
487
|
+
// when memcpy is used with a constant size, the compiler will
|
|
547
488
|
// optimize away the function call and use the minimum number
|
|
548
489
|
// of instructions necessary to perform the copy
|
|
549
|
-
|
|
550
490
|
switch (bytesPerPixel) {
|
|
551
491
|
case 1:
|
|
552
492
|
outPtr0[outPtrIndex++] = inPtrTmp0[offset];
|
|
553
493
|
break;
|
|
554
|
-
|
|
555
494
|
case 2:
|
|
556
495
|
case 3:
|
|
557
496
|
case 4:
|
|
558
497
|
case 8:
|
|
559
498
|
case 12:
|
|
560
499
|
case 16:
|
|
561
|
-
for (
|
|
562
|
-
outPtr0[outPtrIndex++] = inPtrTmp0[offset +
|
|
500
|
+
for (let i = 0; i < bytesPerPixel; ++i) {
|
|
501
|
+
outPtr0[outPtrIndex++] = inPtrTmp0[offset + i];
|
|
563
502
|
}
|
|
564
|
-
|
|
565
503
|
break;
|
|
566
|
-
|
|
567
504
|
default:
|
|
568
505
|
{
|
|
569
506
|
// TODO: check bytes
|
|
570
|
-
|
|
571
|
-
|
|
507
|
+
let oc = 0;
|
|
572
508
|
do {
|
|
573
509
|
outPtr0[outPtrIndex++] = inPtrTmp0[offset++];
|
|
574
510
|
} while (++oc !== bytesPerPixel);
|
|
575
|
-
|
|
576
511
|
break;
|
|
577
512
|
}
|
|
578
513
|
}
|
|
579
|
-
} else if (
|
|
514
|
+
} else if (isInBounds) {
|
|
580
515
|
// leaving input bounds
|
|
581
516
|
break;
|
|
582
517
|
}
|
|
583
|
-
}
|
|
584
|
-
|
|
518
|
+
}
|
|
585
519
|
|
|
520
|
+
// clear trailing out-of-bounds pixels
|
|
586
521
|
outPtr = outPtrTmp;
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
for (var _i7 = 0; _i7 < _n2; ++_i7) {
|
|
591
|
-
outPtr0[outPtrIndex++] = outTmp[_i7];
|
|
522
|
+
const n = setpixels(outTmp, background, outComponents, idXmax - endIdX);
|
|
523
|
+
for (let i = 0; i < n; ++i) {
|
|
524
|
+
outPtr0[outPtrIndex++] = outTmp[i];
|
|
592
525
|
}
|
|
593
526
|
}
|
|
594
527
|
}
|
|
@@ -607,27 +540,22 @@ function vtkImageReslice(publicAPI, model) {
|
|
|
607
540
|
* @param {vtkPolyData} output
|
|
608
541
|
* @returns
|
|
609
542
|
*/
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
publicAPI.getIndexMatrix = function (input, output) {
|
|
543
|
+
publicAPI.getIndexMatrix = (input, output) => {
|
|
613
544
|
// first verify that we have to update the matrix
|
|
614
545
|
if (indexMatrix === null) {
|
|
615
546
|
indexMatrix = mat4.identity(new Float64Array(16));
|
|
616
547
|
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
var outMatrix = mat4.identity(new Float64Array(16));
|
|
626
|
-
|
|
548
|
+
const inOrigin = input.getOrigin();
|
|
549
|
+
const inSpacing = input.getSpacing();
|
|
550
|
+
const inDirection = input.getDirection();
|
|
551
|
+
const outOrigin = output.getOrigin();
|
|
552
|
+
const outSpacing = output.getSpacing();
|
|
553
|
+
const transform = mat4.identity(new Float64Array(16));
|
|
554
|
+
const inMatrix = mat4.identity(new Float64Array(16));
|
|
555
|
+
const outMatrix = mat4.identity(new Float64Array(16));
|
|
627
556
|
if (model.resliceAxes) {
|
|
628
557
|
mat4.copy(transform, model.resliceAxes);
|
|
629
558
|
}
|
|
630
|
-
|
|
631
559
|
if (model.resliceTransform) {
|
|
632
560
|
if (model.resliceTransform.isA('vtkHomogeneousTransform')) {
|
|
633
561
|
// transform->PostMultiply();
|
|
@@ -639,151 +567,127 @@ function vtkImageReslice(publicAPI, model) {
|
|
|
639
567
|
vtkWarningMacro('Non homogeneous transform have not yet been ported');
|
|
640
568
|
}
|
|
641
569
|
}
|
|
642
|
-
|
|
643
570
|
if (!vtkMath.isIdentity3x3(inDirection)) {
|
|
644
|
-
|
|
571
|
+
const imageTransform = vtkMatrixBuilder.buildFromRadian().translate(inOrigin[0], inOrigin[1], inOrigin[2]).multiply3x3(inDirection).translate(-inOrigin[0], -inOrigin[1], -inOrigin[2]);
|
|
645
572
|
mat4.multiply(transform, imageTransform.getMatrix(), transform);
|
|
646
|
-
}
|
|
573
|
+
}
|
|
647
574
|
|
|
575
|
+
// check to see if we have an identity matrix
|
|
576
|
+
let isIdentity = vtkMath.isIdentity(transform);
|
|
648
577
|
|
|
649
|
-
|
|
578
|
+
// the outMatrix takes OutputData indices to OutputData coordinates,
|
|
650
579
|
// the inMatrix takes InputData coordinates to InputData indices
|
|
651
|
-
|
|
652
|
-
for (var i = 0; i < 3; i++) {
|
|
580
|
+
for (let i = 0; i < 3; i++) {
|
|
653
581
|
if ((inSpacing[i] !== outSpacing[i] || inOrigin[i] !== outOrigin[i]) || optimizedTransform != null ) {
|
|
654
582
|
isIdentity = false;
|
|
655
583
|
}
|
|
656
|
-
|
|
657
584
|
inMatrix[4 * i + i] = 1.0 / inSpacing[i];
|
|
658
585
|
inMatrix[4 * 3 + i] = -inOrigin[i] / inSpacing[i];
|
|
659
586
|
outMatrix[4 * i + i] = outSpacing[i];
|
|
660
587
|
outMatrix[4 * 3 + i] = outOrigin[i];
|
|
661
588
|
}
|
|
662
|
-
|
|
663
589
|
if (!isIdentity) {
|
|
664
590
|
// transform.PreMultiply();
|
|
665
591
|
// transform.Concatenate(outMatrix);
|
|
666
|
-
mat4.multiply(transform, transform, outMatrix);
|
|
667
|
-
// index coords, as its input
|
|
592
|
+
mat4.multiply(transform, transform, outMatrix);
|
|
668
593
|
|
|
594
|
+
// the optimizedTransform requires data coords, not
|
|
595
|
+
// index coords, as its input
|
|
669
596
|
{
|
|
670
597
|
// transform->PostMultiply();
|
|
671
598
|
// transform->Concatenate(inMatrix);
|
|
672
599
|
mat4.multiply(transform, inMatrix, transform);
|
|
673
600
|
}
|
|
674
601
|
}
|
|
675
|
-
|
|
676
602
|
mat4.copy(indexMatrix, transform);
|
|
677
603
|
return indexMatrix;
|
|
678
604
|
};
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
var matrix = new Float64Array(16);
|
|
687
|
-
|
|
605
|
+
publicAPI.getAutoCroppedOutputBounds = input => {
|
|
606
|
+
const inOrigin = input.getOrigin();
|
|
607
|
+
const inSpacing = input.getSpacing();
|
|
608
|
+
const inDirection = input.getDirection();
|
|
609
|
+
const dims = input.getDimensions();
|
|
610
|
+
const inWholeExt = [0, dims[0] - 1, 0, dims[1] - 1, 0, dims[2] - 1];
|
|
611
|
+
const matrix = new Float64Array(16);
|
|
688
612
|
if (model.resliceAxes) {
|
|
689
613
|
mat4.invert(matrix, model.resliceAxes);
|
|
690
614
|
} else {
|
|
691
615
|
mat4.identity(matrix);
|
|
692
616
|
}
|
|
693
|
-
|
|
694
|
-
var transform = null;
|
|
695
|
-
|
|
617
|
+
let transform = null;
|
|
696
618
|
if (model.resliceTransform) {
|
|
697
619
|
transform = model.resliceTransform.getInverse();
|
|
698
620
|
}
|
|
699
|
-
|
|
700
|
-
var imageTransform = null;
|
|
701
|
-
|
|
621
|
+
let imageTransform = null;
|
|
702
622
|
if (!vtkMath.isIdentity3x3(inDirection)) {
|
|
703
623
|
imageTransform = vtkMatrixBuilder.buildFromRadian().translate(inOrigin[0], inOrigin[1], inOrigin[2]).multiply3x3(inDirection).translate(-inOrigin[0], -inOrigin[1], -inOrigin[2]).invert().getMatrix();
|
|
704
624
|
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
for (var i = 0; i < 8; ++i) {
|
|
625
|
+
const bounds = [Number.MAX_VALUE, -Number.MAX_VALUE, Number.MAX_VALUE, -Number.MAX_VALUE, Number.MAX_VALUE, -Number.MAX_VALUE];
|
|
626
|
+
const point = [0, 0, 0, 0];
|
|
627
|
+
for (let i = 0; i < 8; ++i) {
|
|
710
628
|
point[0] = inOrigin[0] + inWholeExt[i % 2] * inSpacing[0];
|
|
711
629
|
point[1] = inOrigin[1] + inWholeExt[2 + Math.floor(i / 2) % 2] * inSpacing[1];
|
|
712
630
|
point[2] = inOrigin[2] + inWholeExt[4 + Math.floor(i / 4) % 2] * inSpacing[2];
|
|
713
631
|
point[3] = 1.0;
|
|
714
|
-
|
|
715
632
|
if (imageTransform) {
|
|
716
633
|
vec4.transformMat4(point, point, imageTransform);
|
|
717
634
|
}
|
|
718
|
-
|
|
719
635
|
if (model.resliceTransform) {
|
|
720
636
|
transform.transformPoint(point, point);
|
|
721
637
|
}
|
|
722
|
-
|
|
723
638
|
vec4.transformMat4(point, point, matrix);
|
|
724
|
-
|
|
639
|
+
const f = 1.0 / point[3];
|
|
725
640
|
point[0] *= f;
|
|
726
641
|
point[1] *= f;
|
|
727
642
|
point[2] *= f;
|
|
728
|
-
|
|
729
|
-
for (var j = 0; j < 3; ++j) {
|
|
643
|
+
for (let j = 0; j < 3; ++j) {
|
|
730
644
|
if (point[j] > bounds[2 * j + 1]) {
|
|
731
645
|
bounds[2 * j + 1] = point[j];
|
|
732
646
|
}
|
|
733
|
-
|
|
734
647
|
if (point[j] < bounds[2 * j]) {
|
|
735
648
|
bounds[2 * j] = point[j];
|
|
736
649
|
}
|
|
737
650
|
}
|
|
738
651
|
}
|
|
739
|
-
|
|
740
652
|
return bounds;
|
|
741
653
|
};
|
|
742
|
-
|
|
743
|
-
publicAPI.getDataTypeMinMax = function (dataType) {
|
|
654
|
+
publicAPI.getDataTypeMinMax = dataType => {
|
|
744
655
|
switch (dataType) {
|
|
745
656
|
case 'Int8Array':
|
|
746
657
|
return {
|
|
747
658
|
min: -128,
|
|
748
659
|
max: 127
|
|
749
660
|
};
|
|
750
|
-
|
|
751
661
|
case 'Int16Array':
|
|
752
662
|
return {
|
|
753
663
|
min: -32768,
|
|
754
664
|
max: 32767
|
|
755
665
|
};
|
|
756
|
-
|
|
757
666
|
case 'Uint16Array':
|
|
758
667
|
return {
|
|
759
668
|
min: 0,
|
|
760
669
|
max: 65535
|
|
761
670
|
};
|
|
762
|
-
|
|
763
671
|
case 'Int32Array':
|
|
764
672
|
return {
|
|
765
673
|
min: -2147483648,
|
|
766
674
|
max: 2147483647
|
|
767
675
|
};
|
|
768
|
-
|
|
769
676
|
case 'Uint32Array':
|
|
770
677
|
return {
|
|
771
678
|
min: 0,
|
|
772
679
|
max: 4294967295
|
|
773
680
|
};
|
|
774
|
-
|
|
775
681
|
case 'Float32Array':
|
|
776
682
|
return {
|
|
777
683
|
min: -1.2e38,
|
|
778
684
|
max: 1.2e38
|
|
779
685
|
};
|
|
780
|
-
|
|
781
686
|
case 'Float64Array':
|
|
782
687
|
return {
|
|
783
688
|
min: -1.2e38,
|
|
784
689
|
max: 1.2e38
|
|
785
690
|
};
|
|
786
|
-
|
|
787
691
|
case 'Uint8Array':
|
|
788
692
|
case 'Uint8ClampedArray':
|
|
789
693
|
default:
|
|
@@ -793,114 +697,83 @@ function vtkImageReslice(publicAPI, model) {
|
|
|
793
697
|
};
|
|
794
698
|
}
|
|
795
699
|
};
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
for (var i = 0; i < count; ++i) {
|
|
700
|
+
publicAPI.clamp = (outPtr, inPtr, numscalars, n, min, max) => {
|
|
701
|
+
const count = n * numscalars;
|
|
702
|
+
for (let i = 0; i < count; ++i) {
|
|
801
703
|
outPtr[i] = vtkInterpolationMathClamp(inPtr[i], min, max);
|
|
802
704
|
}
|
|
803
|
-
|
|
804
705
|
return count;
|
|
805
706
|
};
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
for (var i = 0; i < count; ++i) {
|
|
707
|
+
publicAPI.convert = (outPtr, inPtr, numscalars, n) => {
|
|
708
|
+
const count = n * numscalars;
|
|
709
|
+
for (let i = 0; i < count; ++i) {
|
|
811
710
|
outPtr[i] = Math.round(inPtr[i]);
|
|
812
711
|
}
|
|
813
|
-
|
|
814
712
|
return count;
|
|
815
713
|
};
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
var useClamping = forceClamping;
|
|
819
|
-
|
|
714
|
+
publicAPI.getConversionFunc = (inputType, dataType, scalarShift, scalarScale, forceClamping) => {
|
|
715
|
+
let useClamping = forceClamping;
|
|
820
716
|
if (dataType !== VtkDataTypes.FLOAT && dataType !== VtkDataTypes.DOUBLE && !forceClamping) {
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
717
|
+
const inMinMax = publicAPI.getDataTypeMinMax(inputType);
|
|
718
|
+
let checkMin = (inMinMax.min + scalarShift) * scalarScale;
|
|
719
|
+
let checkMax = (inMinMax.max + scalarShift) * scalarScale;
|
|
720
|
+
const outMinMax = publicAPI.getDataTypeMinMax(dataType);
|
|
721
|
+
const outputMin = outMinMax.min;
|
|
722
|
+
const outputMax = outMinMax.max;
|
|
828
723
|
if (checkMin > checkMax) {
|
|
829
|
-
|
|
724
|
+
const tmp = checkMax;
|
|
830
725
|
checkMax = checkMin;
|
|
831
726
|
checkMin = tmp;
|
|
832
727
|
}
|
|
833
|
-
|
|
834
728
|
useClamping = checkMin < outputMin || checkMax > outputMax;
|
|
835
729
|
}
|
|
836
|
-
|
|
837
730
|
if (useClamping && dataType !== VtkDataTypes.FLOAT && dataType !== VtkDataTypes.DOUBLE) {
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
var clamp = function clamp(outPtr, inPtr, numscalars, n) {
|
|
841
|
-
return publicAPI.clamp(outPtr, inPtr, numscalars, n, minMax.min, minMax.max);
|
|
842
|
-
};
|
|
843
|
-
|
|
731
|
+
const minMax = publicAPI.getDataTypeMinMax(dataType);
|
|
732
|
+
const clamp = (outPtr, inPtr, numscalars, n) => publicAPI.clamp(outPtr, inPtr, numscalars, n, minMax.min, minMax.max);
|
|
844
733
|
return clamp;
|
|
845
734
|
}
|
|
846
|
-
|
|
847
735
|
return publicAPI.convert;
|
|
848
736
|
};
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
for (var i = 0; i < n; ++i) {
|
|
737
|
+
publicAPI.set = (outPtr, inPtr, numscalars, n) => {
|
|
738
|
+
const count = numscalars * n;
|
|
739
|
+
for (let i = 0; i < n; ++i) {
|
|
854
740
|
outPtr[i] = inPtr[i];
|
|
855
741
|
}
|
|
856
|
-
|
|
857
742
|
return count;
|
|
858
743
|
};
|
|
859
|
-
|
|
860
|
-
publicAPI.set1 = function (outPtr, inPtr, numscalars, n) {
|
|
744
|
+
publicAPI.set1 = (outPtr, inPtr, numscalars, n) => {
|
|
861
745
|
outPtr.fill(inPtr[0], 0, n);
|
|
862
746
|
return n;
|
|
863
747
|
};
|
|
864
|
-
|
|
865
|
-
publicAPI.
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
publicAPI.getCompositeFunc = function (slabMode, slabTrapezoidIntegration) {
|
|
870
|
-
var composite = null; // eslint-disable-next-line default-case
|
|
871
|
-
|
|
748
|
+
publicAPI.getSetPixelsFunc = (dataType, dataSize, numscalars, dataPtr) => numscalars === 1 ? publicAPI.set1 : publicAPI.set;
|
|
749
|
+
publicAPI.getCompositeFunc = (slabMode, slabTrapezoidIntegration) => {
|
|
750
|
+
let composite = null;
|
|
751
|
+
// eslint-disable-next-line default-case
|
|
872
752
|
switch (slabMode) {
|
|
873
753
|
case SlabMode.MIN:
|
|
874
754
|
composite = getImageResliceCompositeMinValue;
|
|
875
755
|
break;
|
|
876
|
-
|
|
877
756
|
case SlabMode.MAX:
|
|
878
757
|
composite = getImageResliceCompositeMaxValue;
|
|
879
758
|
break;
|
|
880
|
-
|
|
881
759
|
case SlabMode.MEAN:
|
|
882
760
|
if (slabTrapezoidIntegration) {
|
|
883
761
|
composite = getImageResliceCompositeMeanTrap;
|
|
884
762
|
} else {
|
|
885
763
|
composite = getImageResliceCompositeMeanValue;
|
|
886
764
|
}
|
|
887
|
-
|
|
888
765
|
break;
|
|
889
|
-
|
|
890
766
|
case SlabMode.SUM:
|
|
891
767
|
if (slabTrapezoidIntegration) {
|
|
892
768
|
composite = getImageResliceCompositeSumTrap;
|
|
893
769
|
} else {
|
|
894
770
|
composite = getImageResliceCompositeSumValue;
|
|
895
771
|
}
|
|
896
|
-
|
|
897
772
|
break;
|
|
898
773
|
}
|
|
899
|
-
|
|
900
774
|
return composite;
|
|
901
775
|
};
|
|
902
|
-
|
|
903
|
-
publicAPI.applyTransform = function (newTrans, inPoint, inOrigin, inInvSpacing) {
|
|
776
|
+
publicAPI.applyTransform = (newTrans, inPoint, inOrigin, inInvSpacing) => {
|
|
904
777
|
inPoint[3] = 1;
|
|
905
778
|
vec4.transformMat4(inPoint, inPoint, newTrans);
|
|
906
779
|
inPoint[0] -= inOrigin[0];
|
|
@@ -910,99 +783,80 @@ function vtkImageReslice(publicAPI, model) {
|
|
|
910
783
|
inPoint[1] *= inInvSpacing[1];
|
|
911
784
|
inPoint[2] *= inInvSpacing[2];
|
|
912
785
|
};
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
for (var i = 0; i < m; ++i) {
|
|
786
|
+
publicAPI.rescaleScalars = (floatData, components, n, scalarShift, scalarScale) => {
|
|
787
|
+
const m = n * components;
|
|
788
|
+
for (let i = 0; i < m; ++i) {
|
|
918
789
|
floatData[i] = (floatData[i] + scalarShift) * scalarScale;
|
|
919
790
|
}
|
|
920
791
|
};
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
for (var i = 0; i < 3; i++) {
|
|
792
|
+
publicAPI.isPermutationMatrix = matrix => {
|
|
793
|
+
for (let i = 0; i < 3; i++) {
|
|
924
794
|
if (matrix[4 * i + 3] !== 0) {
|
|
925
795
|
return false;
|
|
926
796
|
}
|
|
927
797
|
}
|
|
928
|
-
|
|
929
798
|
if (matrix[4 * 3 + 3] !== 1) {
|
|
930
799
|
return false;
|
|
931
800
|
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
for (var _i8 = 0; _i8 < 3; _i8++) {
|
|
937
|
-
if (matrix[4 * j + _i8] !== 0) {
|
|
801
|
+
for (let j = 0; j < 3; j++) {
|
|
802
|
+
let k = 0;
|
|
803
|
+
for (let i = 0; i < 3; i++) {
|
|
804
|
+
if (matrix[4 * j + i] !== 0) {
|
|
938
805
|
k++;
|
|
939
806
|
}
|
|
940
807
|
}
|
|
941
|
-
|
|
942
808
|
if (k !== 1) {
|
|
943
809
|
return 0;
|
|
944
810
|
}
|
|
945
811
|
}
|
|
946
|
-
|
|
947
812
|
return 1;
|
|
948
|
-
};
|
|
949
|
-
|
|
813
|
+
};
|
|
950
814
|
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
815
|
+
// TODO: to move in vtkMath and add tolerance
|
|
816
|
+
publicAPI.isIdentityMatrix = matrix => {
|
|
817
|
+
for (let i = 0; i < 4; ++i) {
|
|
818
|
+
for (let j = 0; j < 4; ++j) {
|
|
954
819
|
if ((i === j ? 1.0 : 0.0) !== matrix[4 * j + i]) {
|
|
955
820
|
return false;
|
|
956
821
|
}
|
|
957
822
|
}
|
|
958
823
|
}
|
|
959
|
-
|
|
960
824
|
return true;
|
|
961
825
|
};
|
|
962
|
-
|
|
963
|
-
publicAPI.
|
|
964
|
-
return matrix[4 * 0 + 3] !== 0 || matrix[4 * 1 + 3] !== 0 || matrix[4 * 2 + 3] !== 0 || matrix[4 * 3 + 3] !== 1;
|
|
965
|
-
};
|
|
966
|
-
|
|
967
|
-
publicAPI.canUseNearestNeighbor = function (matrix, outExt) {
|
|
826
|
+
publicAPI.isPerspectiveMatrix = matrix => matrix[4 * 0 + 3] !== 0 || matrix[4 * 1 + 3] !== 0 || matrix[4 * 2 + 3] !== 0 || matrix[4 * 3 + 3] !== 1;
|
|
827
|
+
publicAPI.canUseNearestNeighbor = (matrix, outExt) => {
|
|
968
828
|
// loop through dimensions
|
|
969
|
-
for (
|
|
970
|
-
|
|
971
|
-
|
|
829
|
+
for (let i = 0; i < 3; i++) {
|
|
830
|
+
let j;
|
|
972
831
|
for (j = 0; j < 3; j++) {
|
|
973
832
|
if (matrix[4 * j + i] !== 0) {
|
|
974
833
|
break;
|
|
975
834
|
}
|
|
976
835
|
}
|
|
977
|
-
|
|
978
836
|
if (j >= 3) {
|
|
979
837
|
return 0;
|
|
980
838
|
}
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
var y = matrix[4 * 3 + i];
|
|
984
|
-
|
|
839
|
+
let x = matrix[4 * j + i];
|
|
840
|
+
let y = matrix[4 * 3 + i];
|
|
985
841
|
if (outExt[2 * j] === outExt[2 * j + 1]) {
|
|
986
842
|
y += x * outExt[2 * i];
|
|
987
843
|
x = 0;
|
|
988
844
|
}
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
var fy = vtkInterpolationMathFloor(y).error;
|
|
992
|
-
|
|
845
|
+
const fx = vtkInterpolationMathFloor(x).error;
|
|
846
|
+
const fy = vtkInterpolationMathFloor(y).error;
|
|
993
847
|
if (fx !== 0 || fy !== 0) {
|
|
994
848
|
return 0;
|
|
995
849
|
}
|
|
996
850
|
}
|
|
997
|
-
|
|
998
851
|
return 1;
|
|
999
852
|
};
|
|
1000
|
-
}
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
// ----------------------------------------------------------------------------
|
|
1001
856
|
// Object factory
|
|
1002
857
|
// ----------------------------------------------------------------------------
|
|
1003
858
|
|
|
1004
|
-
|
|
1005
|
-
var DEFAULT_VALUES = {
|
|
859
|
+
const DEFAULT_VALUES = {
|
|
1006
860
|
transformInputSampling: true,
|
|
1007
861
|
autoCropOutput: false,
|
|
1008
862
|
outputDimensionality: 3,
|
|
@@ -1037,32 +891,41 @@ var DEFAULT_VALUES = {
|
|
|
1037
891
|
// resliceTransform: null,
|
|
1038
892
|
interpolator: vtkImageInterpolator.newInstance(),
|
|
1039
893
|
usePermuteExecute: false // no supported yet
|
|
894
|
+
};
|
|
1040
895
|
|
|
1041
|
-
|
|
896
|
+
// ----------------------------------------------------------------------------
|
|
1042
897
|
|
|
1043
898
|
function extend(publicAPI, model) {
|
|
1044
|
-
|
|
1045
|
-
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
899
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
900
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
1046
901
|
|
|
1047
|
-
|
|
902
|
+
// Make this a VTK object
|
|
903
|
+
macro.obj(publicAPI, model);
|
|
1048
904
|
|
|
905
|
+
// Also make it an algorithm with one input and one output
|
|
1049
906
|
macro.algo(publicAPI, model, 1, 1);
|
|
1050
907
|
macro.setGet(publicAPI, model, ['outputDimensionality', 'outputScalarType', 'scalarShift', 'scalarScale', 'transformInputSampling', 'autoCropOutput', 'wrap', 'mirror', 'border', 'interpolationMode', 'resliceTransform', 'slabMode', 'slabTrapezoidIntegration', 'slabNumberOfSlices', 'slabSliceSpacingFraction']);
|
|
1051
908
|
macro.setGetArray(publicAPI, model, ['outputOrigin', 'outputSpacing'], 3);
|
|
1052
909
|
macro.setGetArray(publicAPI, model, ['outputExtent'], 6);
|
|
1053
910
|
macro.setGetArray(publicAPI, model, ['outputDirection'], 9);
|
|
1054
911
|
macro.setGetArray(publicAPI, model, ['backgroundColor'], 4);
|
|
1055
|
-
macro.get(publicAPI, model, ['resliceAxes']);
|
|
912
|
+
macro.get(publicAPI, model, ['resliceAxes']);
|
|
1056
913
|
|
|
914
|
+
// Object specific methods
|
|
1057
915
|
macro.algo(publicAPI, model, 1, 1);
|
|
1058
916
|
vtkImageReslice(publicAPI, model);
|
|
1059
|
-
}
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
// ----------------------------------------------------------------------------
|
|
920
|
+
|
|
921
|
+
const newInstance = macro.newInstance(extend, 'vtkImageReslice');
|
|
1060
922
|
|
|
1061
|
-
|
|
923
|
+
// ----------------------------------------------------------------------------
|
|
1062
924
|
|
|
1063
|
-
var vtkImageReslice$1 =
|
|
1064
|
-
newInstance
|
|
1065
|
-
extend
|
|
1066
|
-
|
|
925
|
+
var vtkImageReslice$1 = {
|
|
926
|
+
newInstance,
|
|
927
|
+
extend,
|
|
928
|
+
...Constants
|
|
929
|
+
};
|
|
1067
930
|
|
|
1068
931
|
export { vtkImageReslice$1 as default, extend, newInstance };
|