@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,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import macro from '../../macros.js';
|
|
1
|
+
import { m as macro } from '../../macros2.js';
|
|
3
2
|
import vtkCellArray from '../../Common/Core/CellArray.js';
|
|
4
3
|
import vtkLine from '../../Common/DataModel/Line.js';
|
|
5
4
|
import { d as dot, j as cross, n as norm, t as jacobi, l as normalize, k as add } from '../../Common/Core/Math/index.js';
|
|
@@ -12,14 +11,19 @@ import vtkTriangle from '../../Common/DataModel/Triangle.js';
|
|
|
12
11
|
import { pushArray, getCellTriangles } from './OBBTree/helper.js';
|
|
13
12
|
import { mat4, vec4 } from 'gl-matrix';
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const {
|
|
15
|
+
vtkErrorMacro
|
|
16
|
+
} = macro;
|
|
17
|
+
const VTK_DOUBLE_MAX = Number.MAX_SAFE_INTEGER;
|
|
18
|
+
|
|
19
|
+
// ----------------------------------------------------------------------------
|
|
17
20
|
// vtkOBBTree methods
|
|
18
21
|
// ----------------------------------------------------------------------------
|
|
19
22
|
|
|
20
23
|
function vtkOBBTree(publicAPI, model) {
|
|
21
24
|
// Set our classname
|
|
22
25
|
model.classHierarchy.push('vtkOBBTree');
|
|
26
|
+
|
|
23
27
|
/**
|
|
24
28
|
* Compute an OBB from the list of cells given. This used to be
|
|
25
29
|
* public but should not have been. A public call has been added
|
|
@@ -31,116 +35,108 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
31
35
|
* @param {Array[3]} min
|
|
32
36
|
* @param {Array[3]} size
|
|
33
37
|
*/
|
|
34
|
-
|
|
35
38
|
function computeOBB(cells, corner, max, mid, min, size) {
|
|
36
39
|
model.OBBCount++;
|
|
37
|
-
model.pointsList = [];
|
|
40
|
+
model.pointsList = [];
|
|
41
|
+
//
|
|
38
42
|
// Compute mean & moments
|
|
39
43
|
//
|
|
40
44
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
const numCells = cells.length;
|
|
46
|
+
const mean = [0, 0, 0];
|
|
47
|
+
let totMass = 0.0;
|
|
48
|
+
const a0 = [0, 0, 0];
|
|
49
|
+
const a1 = [0, 0, 0];
|
|
50
|
+
const a2 = [0, 0, 0];
|
|
51
|
+
let a = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
52
|
+
const dp0 = [0, 0, 0];
|
|
53
|
+
const dp1 = [0, 0, 0];
|
|
54
|
+
const c = [0, 0, 0];
|
|
55
|
+
let triMass = 0;
|
|
53
56
|
if (!model.dataset.getCells()) {
|
|
54
57
|
model.dataset.buildCells();
|
|
55
58
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var qId = cellsIds.ptId1;
|
|
67
|
-
var rId = cellsIds.ptId2;
|
|
68
|
-
|
|
59
|
+
for (let i = 0; i < numCells; i++) {
|
|
60
|
+
const cellId = cells[i];
|
|
61
|
+
const type = model.dataset.getCells().getCellType(cellId);
|
|
62
|
+
const ptIds = model.dataset.getCellPoints(cellId).cellPointIds;
|
|
63
|
+
const numPts = ptIds.length;
|
|
64
|
+
for (let j = 0; j < numPts - 2; j++) {
|
|
65
|
+
const cellsIds = getCellTriangles(ptIds, type, j);
|
|
66
|
+
const pId = cellsIds.ptId0;
|
|
67
|
+
const qId = cellsIds.ptId1;
|
|
68
|
+
const rId = cellsIds.ptId2;
|
|
69
69
|
if (pId < 0) {
|
|
70
70
|
// eslint-disable-next-line no-continue
|
|
71
71
|
continue;
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
var r = [];
|
|
73
|
+
const p = [];
|
|
74
|
+
const q = [];
|
|
75
|
+
const r = [];
|
|
77
76
|
model.dataset.getPoints().getPoint(pId, p);
|
|
78
77
|
model.dataset.getPoints().getPoint(qId, q);
|
|
79
|
-
model.dataset.getPoints().getPoint(rId, r);
|
|
80
|
-
// Compute the components of the moment of inertia tensor.
|
|
78
|
+
model.dataset.getPoints().getPoint(rId, r);
|
|
81
79
|
|
|
82
|
-
|
|
80
|
+
// p, q, and r are the oriented triangle points.
|
|
81
|
+
// Compute the components of the moment of inertia tensor.
|
|
82
|
+
for (let k = 0; k < 3; k++) {
|
|
83
83
|
// two edge vectors
|
|
84
84
|
dp0[k] = q[k] - p[k];
|
|
85
|
-
dp1[k] = r[k] - p[k];
|
|
86
|
-
|
|
85
|
+
dp1[k] = r[k] - p[k];
|
|
86
|
+
// centroid
|
|
87
87
|
c[k] = (p[k] + q[k] + r[k]) / 3;
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
var xp = cross(dp0, dp1, []);
|
|
89
|
+
const xp = cross(dp0, dp1, []);
|
|
91
90
|
triMass = 0.5 * norm(xp);
|
|
92
91
|
totMass += triMass;
|
|
92
|
+
for (let k = 0; k < 3; k++) {
|
|
93
|
+
mean[k] += triMass * c[k];
|
|
94
|
+
}
|
|
93
95
|
|
|
94
|
-
|
|
95
|
-
mean[_k] += triMass * c[_k];
|
|
96
|
-
} // on-diagonal terms
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
// on-diagonal terms
|
|
99
97
|
a0[0] += triMass * (9 * c[0] * c[0] + p[0] * p[0] + q[0] * q[0] + r[0] * r[0]) / 12;
|
|
100
98
|
a1[1] += triMass * (9 * c[1] * c[1] + p[1] * p[1] + q[1] * q[1] + r[1] * r[1]) / 12;
|
|
101
|
-
a2[2] += triMass * (9 * c[2] * c[2] + p[2] * p[2] + q[2] * q[2] + r[2] * r[2]) / 12;
|
|
99
|
+
a2[2] += triMass * (9 * c[2] * c[2] + p[2] * p[2] + q[2] * q[2] + r[2] * r[2]) / 12;
|
|
102
100
|
|
|
101
|
+
// off-diagonal terms
|
|
103
102
|
a0[1] += triMass * (9 * c[0] * c[1] + p[0] * p[1] + q[0] * q[1] + r[0] * r[1]) / 12;
|
|
104
103
|
a0[2] += triMass * (9 * c[0] * c[2] + p[0] * p[2] + q[0] * q[2] + r[0] * r[2]) / 12;
|
|
105
104
|
a1[2] += triMass * (9 * c[1] * c[2] + p[1] * p[2] + q[1] * q[2] + r[1] * r[2]) / 12;
|
|
106
105
|
} // end foreach triangle
|
|
106
|
+
|
|
107
107
|
// While computing cell moments, gather all the cell's
|
|
108
108
|
// point coordinates into a single list.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
model.
|
|
114
|
-
var pt = [];
|
|
115
|
-
model.dataset.getPoints().getPoint(ptIds[_j], pt);
|
|
109
|
+
for (let j = 0; j < numPts; j++) {
|
|
110
|
+
if (model.insertedPoints[ptIds[j]] !== model.OBBCount) {
|
|
111
|
+
model.insertedPoints[ptIds[j]] = model.OBBCount;
|
|
112
|
+
const pt = [];
|
|
113
|
+
model.dataset.getPoints().getPoint(ptIds[j], pt);
|
|
116
114
|
model.pointsList.push(pt);
|
|
117
115
|
}
|
|
118
116
|
} // for all points of this cell
|
|
119
|
-
|
|
120
117
|
} // end foreach cell
|
|
121
|
-
// normalize data
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
for (var _i = 0; _i < 3; _i++) {
|
|
125
|
-
mean[_i] /= totMass;
|
|
126
|
-
} // matrix is symmetric
|
|
127
118
|
|
|
119
|
+
// normalize data
|
|
120
|
+
for (let i = 0; i < 3; i++) {
|
|
121
|
+
mean[i] /= totMass;
|
|
122
|
+
}
|
|
128
123
|
|
|
124
|
+
// matrix is symmetric
|
|
129
125
|
a1[0] = a0[1];
|
|
130
126
|
a2[0] = a0[2];
|
|
131
127
|
a2[1] = a1[2];
|
|
132
|
-
a = [a0[0], a0[1], a0[2], a1[0], a1[1], a1[2], a2[0], a2[1], a2[2]];
|
|
133
|
-
|
|
134
|
-
for (
|
|
135
|
-
for (
|
|
136
|
-
a[
|
|
128
|
+
a = [a0[0], a0[1], a0[2], a1[0], a1[1], a1[2], a2[0], a2[1], a2[2]];
|
|
129
|
+
// get covariance from moments
|
|
130
|
+
for (let i = 0; i < 3; i++) {
|
|
131
|
+
for (let j = 0; j < 3; j++) {
|
|
132
|
+
a[i * 3 + j] = a[i * 3 + j] / totMass - mean[i] * mean[j];
|
|
137
133
|
}
|
|
138
|
-
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
//
|
|
139
137
|
// Extract axes (i.e., eigenvectors) from covariance matrix.
|
|
140
138
|
//
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
var v = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
139
|
+
const v = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
144
140
|
jacobi(a, size, v);
|
|
145
141
|
max[0] = v[0];
|
|
146
142
|
max[1] = v[3];
|
|
@@ -151,130 +147,116 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
151
147
|
min[0] = v[2];
|
|
152
148
|
min[1] = v[5];
|
|
153
149
|
min[2] = v[8];
|
|
150
|
+
for (let i = 0; i < 3; i++) {
|
|
151
|
+
a[i] = mean[i] + max[i];
|
|
152
|
+
a[3 + i] = mean[i] + mid[i];
|
|
153
|
+
a[6 + i] = mean[i] + min[i];
|
|
154
|
+
}
|
|
154
155
|
|
|
155
|
-
|
|
156
|
-
a[_i3] = mean[_i3] + max[_i3];
|
|
157
|
-
a[3 + _i3] = mean[_i3] + mid[_i3];
|
|
158
|
-
a[6 + _i3] = mean[_i3] + min[_i3];
|
|
159
|
-
} //
|
|
156
|
+
//
|
|
160
157
|
// Create oriented bounding box by projecting points onto eigenvectors.
|
|
161
158
|
//
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
for (var _i4 = 0; _i4 < 3; _i4++) {
|
|
172
|
-
var out = vtkLine.distanceToLine(_p, mean, a.slice(3 * _i4, 3 * (_i4 + 1)), []);
|
|
173
|
-
|
|
174
|
-
if (out.t < tMin[_i4]) {
|
|
175
|
-
tMin[_i4] = out.t;
|
|
159
|
+
const tMin = [VTK_DOUBLE_MAX, VTK_DOUBLE_MAX, VTK_DOUBLE_MAX];
|
|
160
|
+
const tMax = [-VTK_DOUBLE_MAX, -VTK_DOUBLE_MAX, -VTK_DOUBLE_MAX];
|
|
161
|
+
const numPts = model.pointsList.length;
|
|
162
|
+
for (let ptId = 0; ptId < numPts; ptId++) {
|
|
163
|
+
const p = model.pointsList[ptId];
|
|
164
|
+
for (let i = 0; i < 3; i++) {
|
|
165
|
+
const out = vtkLine.distanceToLine(p, mean, a.slice(3 * i, 3 * (i + 1)), []);
|
|
166
|
+
if (out.t < tMin[i]) {
|
|
167
|
+
tMin[i] = out.t;
|
|
176
168
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
tMax[_i4] = out.t;
|
|
169
|
+
if (out.t > tMax[i]) {
|
|
170
|
+
tMax[i] = out.t;
|
|
180
171
|
}
|
|
181
172
|
}
|
|
182
173
|
} // for all points
|
|
183
174
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
min[_i5] *= tMax[2] - tMin[2];
|
|
175
|
+
for (let i = 0; i < 3; i++) {
|
|
176
|
+
corner[i] = mean[i] + tMin[0] * max[i] + tMin[1] * mid[i] + tMin[2] * min[i];
|
|
177
|
+
max[i] *= tMax[0] - tMin[0];
|
|
178
|
+
mid[i] *= tMax[1] - tMin[1];
|
|
179
|
+
min[i] *= tMax[2] - tMin[2];
|
|
190
180
|
}
|
|
191
181
|
}
|
|
182
|
+
|
|
192
183
|
/**
|
|
193
184
|
* Build the OBB tree
|
|
194
185
|
* @param {Array} cells
|
|
195
186
|
* @param {vtkOBBNode} obbNode
|
|
196
187
|
* @param {Number} level
|
|
197
188
|
*/
|
|
198
|
-
|
|
199
|
-
|
|
200
189
|
function buildTree(cells, obbNode, level) {
|
|
201
|
-
|
|
202
|
-
|
|
190
|
+
const numCells = cells.length;
|
|
203
191
|
if (level > model.level) {
|
|
204
192
|
model.level = level;
|
|
205
193
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
var size = [0, 0, 0];
|
|
194
|
+
const axes = obbNode.getAxes();
|
|
195
|
+
const corner = obbNode.getCorner();
|
|
196
|
+
const size = [0, 0, 0];
|
|
210
197
|
computeOBB(cells, corner, axes[0], axes[1], axes[2], size);
|
|
211
198
|
obbNode.setAxes(axes);
|
|
212
|
-
obbNode.setCorner(corner);
|
|
213
|
-
// assign cells to appropriate child.
|
|
199
|
+
obbNode.setCorner(corner);
|
|
214
200
|
|
|
201
|
+
// Check whether to continue recursing; if so, create two children and
|
|
202
|
+
// assign cells to appropriate child.
|
|
215
203
|
if (level < model.maxLevel && numCells > model.numberOfCellsPerNode) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
204
|
+
let LHlist = [];
|
|
205
|
+
let RHlist = [];
|
|
206
|
+
const p = [0, 0, 0];
|
|
207
|
+
const n = [0, 0, 0];
|
|
220
208
|
|
|
221
|
-
|
|
209
|
+
// loop over three split planes to find acceptable one
|
|
210
|
+
for (let i = 0; i < 3; i++) {
|
|
222
211
|
// compute split point
|
|
223
212
|
p[i] = corner[i] + axes[0][i] / 2 + axes[1][i] / 2 + axes[2][i] / 2;
|
|
224
213
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
var bestPlane = 0;
|
|
231
|
-
|
|
214
|
+
let splitPlane = 0;
|
|
215
|
+
let splitAcceptable = 0;
|
|
216
|
+
let bestRatio = 1;
|
|
217
|
+
let foundBestSplit = 0;
|
|
218
|
+
let bestPlane = 0;
|
|
232
219
|
for (; !splitAcceptable && splitPlane < 3;) {
|
|
233
220
|
// compute split normal
|
|
234
|
-
for (
|
|
235
|
-
n[
|
|
221
|
+
for (let i = 0; i < 3; i++) {
|
|
222
|
+
n[i] = axes[splitPlane][i];
|
|
236
223
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
pointsIDs.forEach(
|
|
245
|
-
|
|
224
|
+
normalize(n);
|
|
225
|
+
|
|
226
|
+
// traverse cells, assigning to appropriate child list as necessary
|
|
227
|
+
for (let i = 0; i < numCells; i++) {
|
|
228
|
+
const cellId = cells[i];
|
|
229
|
+
const pointsIDs = model.dataset.getCellPoints(cellId).cellPointIds;
|
|
230
|
+
const cellPts = [];
|
|
231
|
+
pointsIDs.forEach(id => {
|
|
232
|
+
const pt = [];
|
|
246
233
|
model.dataset.getPoints().getPoint(pointsIDs[id], pt);
|
|
247
234
|
cellPts.push(pt);
|
|
248
235
|
});
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
var val = n[0] * (x[0] - p[0]) + n[1] * (x[1] - p[1]) + n[2] * (x[2] - p[2]);
|
|
236
|
+
const c = [0, 0, 0];
|
|
237
|
+
const numPts = cellPts.length;
|
|
238
|
+
let negative = 0;
|
|
239
|
+
let positive = 0;
|
|
240
|
+
for (let j = 0; j < numPts; j++) {
|
|
241
|
+
const ptId = pointsIDs[j];
|
|
242
|
+
const x = model.dataset.getPoints().getPoint(ptId);
|
|
243
|
+
const val = n[0] * (x[0] - p[0]) + n[1] * (x[1] - p[1]) + n[2] * (x[2] - p[2]);
|
|
258
244
|
c[0] += x[0];
|
|
259
245
|
c[1] += x[1];
|
|
260
246
|
c[2] += x[2];
|
|
261
|
-
|
|
262
247
|
if (val < 0.0) {
|
|
263
248
|
negative = 1;
|
|
264
249
|
} else {
|
|
265
250
|
positive = 1;
|
|
266
251
|
}
|
|
267
252
|
}
|
|
268
|
-
|
|
269
253
|
if (negative && positive) {
|
|
270
254
|
// Use centroid to decide straddle cases
|
|
271
255
|
c[0] /= numPts;
|
|
272
256
|
c[1] /= numPts;
|
|
273
257
|
c[2] /= numPts;
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
if (_val < 0.0) {
|
|
258
|
+
const val = n[0] * (c[0] - p[0]) + n[1] * (c[1] - p[1]) + n[2] * (c[2] - p[2]);
|
|
259
|
+
if (val < 0.0) {
|
|
278
260
|
LHlist.push(cellId);
|
|
279
261
|
} else {
|
|
280
262
|
RHlist.push(cellId);
|
|
@@ -284,18 +266,14 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
284
266
|
} else {
|
|
285
267
|
RHlist.push(cellId);
|
|
286
268
|
}
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
for (var _i7 = 0; _i7 < numCells; _i7++) {
|
|
290
|
-
_loop(_i7);
|
|
291
269
|
} // for all cells
|
|
292
|
-
// evaluate this split
|
|
293
270
|
|
|
271
|
+
// evaluate this split
|
|
272
|
+
const numInLHnode = LHlist.length;
|
|
273
|
+
const numInRHnode = RHlist.length;
|
|
274
|
+
const ratio = Math.abs((numInRHnode - numInLHnode) / numCells);
|
|
294
275
|
|
|
295
|
-
|
|
296
|
-
var numInRHnode = RHlist.length;
|
|
297
|
-
var ratio = Math.abs((numInRHnode - numInLHnode) / numCells); // see whether we've found acceptable split plane
|
|
298
|
-
|
|
276
|
+
// see whether we've found acceptable split plane
|
|
299
277
|
if (ratio < 0.6 || foundBestSplit) {
|
|
300
278
|
// accept right off the bat
|
|
301
279
|
splitAcceptable = 1;
|
|
@@ -303,26 +281,22 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
303
281
|
// not a great split try another
|
|
304
282
|
LHlist = [];
|
|
305
283
|
RHlist = [];
|
|
306
|
-
|
|
307
284
|
if (ratio < bestRatio) {
|
|
308
285
|
bestRatio = ratio;
|
|
309
286
|
bestPlane = splitPlane;
|
|
310
287
|
}
|
|
311
|
-
|
|
312
288
|
if (++splitPlane === 3 && bestRatio < 0.95) {
|
|
313
289
|
// at closing time, even the ugly ones look good
|
|
314
290
|
splitPlane = bestPlane;
|
|
315
291
|
foundBestSplit = 1;
|
|
316
292
|
}
|
|
317
293
|
} // try another split
|
|
318
|
-
|
|
319
294
|
} // for each split
|
|
320
295
|
|
|
321
|
-
|
|
322
296
|
if (splitAcceptable) {
|
|
323
297
|
// otherwise recursion terminates
|
|
324
|
-
|
|
325
|
-
|
|
298
|
+
const LHnode = vtkOBBNode.newInstance();
|
|
299
|
+
const RHnode = vtkOBBNode.newInstance();
|
|
326
300
|
obbNode.setKids([LHnode, RHnode]);
|
|
327
301
|
LHnode.setParent(obbNode);
|
|
328
302
|
RHnode.setParent(obbNode);
|
|
@@ -336,42 +310,40 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
336
310
|
}
|
|
337
311
|
} // if should build tree
|
|
338
312
|
|
|
339
|
-
|
|
340
313
|
if (cells && model.retainCellLists) {
|
|
341
314
|
obbNode.setCells(cells);
|
|
342
315
|
} else if (cells) {
|
|
343
316
|
cells.length = 0;
|
|
344
317
|
}
|
|
345
318
|
}
|
|
346
|
-
|
|
347
319
|
function generatePolygons(obbNode, level, repLevel, points, cells) {
|
|
348
320
|
if (level === repLevel || repLevel < 0 && obbNode.getKids()) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
newPoints.push
|
|
321
|
+
let nbPoints = points.getNumberOfPoints();
|
|
322
|
+
const newPoints = [];
|
|
323
|
+
const newCells = [];
|
|
324
|
+
const cubeIds = [];
|
|
325
|
+
newPoints.push(...obbNode.getCorner());
|
|
354
326
|
cubeIds[0] = nbPoints++;
|
|
355
|
-
|
|
356
|
-
newPoints.push
|
|
327
|
+
const x = [];
|
|
328
|
+
newPoints.push(...add(obbNode.getCorner(), obbNode.getAxis(0), x));
|
|
357
329
|
cubeIds[1] = nbPoints++;
|
|
358
|
-
|
|
359
|
-
newPoints.push
|
|
330
|
+
const y = [];
|
|
331
|
+
newPoints.push(...add(obbNode.getCorner(), obbNode.getAxis(1), y));
|
|
360
332
|
cubeIds[2] = nbPoints++;
|
|
361
|
-
|
|
362
|
-
newPoints.push
|
|
333
|
+
const xy = [];
|
|
334
|
+
newPoints.push(...add(x, obbNode.getAxis(1), xy));
|
|
363
335
|
cubeIds[3] = nbPoints++;
|
|
364
|
-
|
|
365
|
-
newPoints.push
|
|
336
|
+
const z = [];
|
|
337
|
+
newPoints.push(...add(obbNode.getCorner(), obbNode.getAxis(2), z));
|
|
366
338
|
cubeIds[4] = nbPoints++;
|
|
367
|
-
|
|
368
|
-
newPoints.push
|
|
339
|
+
const xz = [];
|
|
340
|
+
newPoints.push(...add(x, obbNode.getAxis(2), xz));
|
|
369
341
|
cubeIds[5] = nbPoints++;
|
|
370
|
-
|
|
371
|
-
newPoints.push
|
|
342
|
+
const yz = [];
|
|
343
|
+
newPoints.push(...add(y, obbNode.getAxis(2), yz));
|
|
372
344
|
cubeIds[6] = nbPoints++;
|
|
373
|
-
|
|
374
|
-
newPoints.push
|
|
345
|
+
const xyz = [];
|
|
346
|
+
newPoints.push(...add(xy, obbNode.getAxis(2), xyz));
|
|
375
347
|
cubeIds[7] = nbPoints++;
|
|
376
348
|
newCells.push(4, cubeIds[0], cubeIds[2], cubeIds[3], cubeIds[1]);
|
|
377
349
|
newCells.push(4, cubeIds[0], cubeIds[1], cubeIds[5], cubeIds[4]);
|
|
@@ -386,39 +358,36 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
386
358
|
generatePolygons(obbNode.getKids()[1], level + 1, repLevel, points, cells);
|
|
387
359
|
}
|
|
388
360
|
}
|
|
361
|
+
|
|
389
362
|
/**
|
|
390
363
|
* Transform the whole OBB tree by using input transform
|
|
391
364
|
* @param {Transform} transform vtkjs Transform object
|
|
392
365
|
*/
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
publicAPI.transform = function (transform) {
|
|
366
|
+
publicAPI.transform = transform => {
|
|
396
367
|
// Setup matrix used to transform vectors
|
|
397
|
-
|
|
368
|
+
const matrix = mat4.create();
|
|
398
369
|
mat4.copy(matrix, transform.getMatrix());
|
|
399
370
|
matrix[12] = 0;
|
|
400
371
|
matrix[13] = 0;
|
|
401
372
|
matrix[14] = 0;
|
|
402
373
|
matrix[15] = 1;
|
|
403
|
-
|
|
404
|
-
|
|
374
|
+
const transformVector = vtkMatrixBuilder.buildFromRadian().setMatrix(matrix);
|
|
375
|
+
const obbStack = new Array(model.level + 1);
|
|
405
376
|
obbStack[0] = model.tree;
|
|
406
|
-
|
|
407
|
-
|
|
377
|
+
let depth = 1;
|
|
408
378
|
while (depth > 0) {
|
|
409
379
|
depth -= 1;
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
380
|
+
const node = obbStack[depth];
|
|
381
|
+
const corner = node.getCorner();
|
|
382
|
+
const max = node.getAxis(0);
|
|
383
|
+
const mid = node.getAxis(1);
|
|
384
|
+
const min = node.getAxis(2);
|
|
415
385
|
transform.apply(corner);
|
|
416
386
|
transformVector.apply(max);
|
|
417
387
|
transformVector.apply(mid);
|
|
418
388
|
transformVector.apply(min);
|
|
419
389
|
node.setCorner(corner);
|
|
420
390
|
node.setAxes([max, mid, min]);
|
|
421
|
-
|
|
422
391
|
if (node.getKids() !== null) {
|
|
423
392
|
// push kids onto stack
|
|
424
393
|
obbStack[depth] = node.getKids()[0];
|
|
@@ -427,31 +396,29 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
427
396
|
}
|
|
428
397
|
}
|
|
429
398
|
};
|
|
399
|
+
|
|
430
400
|
/**
|
|
431
401
|
* Deep copy input node into class attribute tree
|
|
432
402
|
* @param {vtkOBBNode} tree
|
|
433
403
|
* @returns
|
|
434
404
|
*/
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
publicAPI.deepCopy = function (tree) {
|
|
405
|
+
publicAPI.deepCopy = tree => {
|
|
438
406
|
if (!tree) {
|
|
439
407
|
return;
|
|
440
408
|
}
|
|
441
|
-
|
|
442
409
|
publicAPI.setLevel(tree.getLevel());
|
|
443
410
|
publicAPI.setRetainCellLists(tree.getRetainCellLists());
|
|
444
411
|
publicAPI.setDataset(tree.getDataset());
|
|
445
412
|
publicAPI.setAutomatic(tree.getAutomatic());
|
|
446
413
|
publicAPI.setNumberOfCellsPerNode(tree.getNumberOfCellsPerNode());
|
|
447
414
|
publicAPI.setTolerance(tree.getTolerance());
|
|
448
|
-
|
|
449
|
-
|
|
415
|
+
const root = tree.getTree();
|
|
450
416
|
if (root) {
|
|
451
417
|
model.tree = vtkOBBNode.newInstance();
|
|
452
418
|
model.tree.deepCopy(root);
|
|
453
419
|
}
|
|
454
420
|
};
|
|
421
|
+
|
|
455
422
|
/**
|
|
456
423
|
* A method to compute the OBB of a dataset without having to go through the
|
|
457
424
|
* Execute method; It does set
|
|
@@ -462,36 +429,28 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
462
429
|
* @param {Array[3]} min
|
|
463
430
|
* @param {Array[3]} size
|
|
464
431
|
*/
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
publicAPI.computeOBBFromDataset = function (input, corner, max, mid, min, size) {
|
|
432
|
+
publicAPI.computeOBBFromDataset = (input, corner, max, mid, min, size) => {
|
|
468
433
|
if (!input) {
|
|
469
434
|
return;
|
|
470
435
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
var numCells = input.getNumberOfCells();
|
|
474
|
-
|
|
436
|
+
const numPts = input.getPoints().getNumberOfPoints();
|
|
437
|
+
const numCells = input.getNumberOfCells();
|
|
475
438
|
if (numPts < 1 || numCells < 1) {
|
|
476
439
|
vtkErrorMacro("Can't compute OBB - no data available!");
|
|
477
440
|
return;
|
|
478
441
|
}
|
|
479
|
-
|
|
480
442
|
model.dataset = input;
|
|
481
443
|
model.OBBCount = 0;
|
|
482
444
|
model.insertedPoints = Array.from({
|
|
483
445
|
length: numPts
|
|
484
|
-
},
|
|
485
|
-
return 0;
|
|
486
|
-
});
|
|
446
|
+
}, _ => 0);
|
|
487
447
|
model.pointsList = [];
|
|
488
|
-
|
|
448
|
+
const cellList = Array.from({
|
|
489
449
|
length: numCells
|
|
490
|
-
},
|
|
491
|
-
return i;
|
|
492
|
-
});
|
|
450
|
+
}, (_, i) => i);
|
|
493
451
|
computeOBB(cellList, corner, max, mid, min, size);
|
|
494
452
|
};
|
|
453
|
+
|
|
495
454
|
/**
|
|
496
455
|
* Returns true if nodeB and nodeA are disjoint after optional
|
|
497
456
|
* transformation of nodeB with matrix XformBtoA
|
|
@@ -499,20 +458,17 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
499
458
|
* @param {vtkOBBNode} nodeB
|
|
500
459
|
* @param {mat4} XformBtoA
|
|
501
460
|
*/
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
publicAPI.disjointOBBNodes = function (nodeA, nodeB, XformBtoA) {
|
|
461
|
+
publicAPI.disjointOBBNodes = (nodeA, nodeB, XformBtoA) => {
|
|
505
462
|
if (!nodeA || !nodeB) {
|
|
506
463
|
return 5; // A and B are disjoint
|
|
507
464
|
}
|
|
508
465
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
466
|
+
const input = new Array(4);
|
|
467
|
+
const output = new Array(4);
|
|
468
|
+
const eps = model.tolerance;
|
|
469
|
+
const pA = nodeA;
|
|
470
|
+
let pB = vtkOBBNode.newInstance();
|
|
471
|
+
const dotAB = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
516
472
|
if (XformBtoA) {
|
|
517
473
|
// Here we assume that XformBtoA is an orthogonal matrix
|
|
518
474
|
input[0] = nodeB.getCorner()[0];
|
|
@@ -520,171 +476,155 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
520
476
|
input[2] = nodeB.getCorner()[2];
|
|
521
477
|
input[3] = 1.0;
|
|
522
478
|
vec4.transformMat4(output, input, XformBtoA);
|
|
523
|
-
pB.setCorner([output[0] / output[3], output[1] / output[3], output[2] / output[3]]);
|
|
524
|
-
|
|
525
|
-
for (
|
|
479
|
+
pB.setCorner([output[0] / output[3], output[1] / output[3], output[2] / output[3]]);
|
|
480
|
+
// Clean this up when the bug input MultiplyVectors is fixed!
|
|
481
|
+
for (let ii = 0; ii < 3; ii++) {
|
|
526
482
|
pB.getAxis(0)[ii] = nodeB.getCorner()[ii] + nodeB.getAxis(0)[ii];
|
|
527
483
|
pB.getAxis(1)[ii] = nodeB.getCorner()[ii] + nodeB.getAxis(1)[ii];
|
|
528
484
|
pB.getAxis(2)[ii] = nodeB.getCorner()[ii] + nodeB.getAxis(2)[ii];
|
|
529
485
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
input[
|
|
533
|
-
input[
|
|
534
|
-
input[2] = pB.getAxis(_ii)[2];
|
|
486
|
+
for (let ii = 0; ii < 3; ii++) {
|
|
487
|
+
input[0] = pB.getAxis(ii)[0];
|
|
488
|
+
input[1] = pB.getAxis(ii)[1];
|
|
489
|
+
input[2] = pB.getAxis(ii)[2];
|
|
535
490
|
input[3] = 1.0;
|
|
536
491
|
vec4.transformMat4(output, input, XformBtoA);
|
|
537
|
-
pB.getAxis(
|
|
538
|
-
pB.getAxis(
|
|
539
|
-
pB.getAxis(
|
|
492
|
+
pB.getAxis(ii)[0] = output[0] / output[3];
|
|
493
|
+
pB.getAxis(ii)[1] = output[1] / output[3];
|
|
494
|
+
pB.getAxis(ii)[2] = output[2] / output[3];
|
|
540
495
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
pB.getAxis(
|
|
544
|
-
pB.getAxis(
|
|
545
|
-
pB.getAxis(2)[_ii2] = pB.getAxis(2)[_ii2] - pB.getCorner()[_ii2];
|
|
496
|
+
for (let ii = 0; ii < 3; ii++) {
|
|
497
|
+
pB.getAxis(0)[ii] = pB.getAxis(0)[ii] - pB.getCorner()[ii];
|
|
498
|
+
pB.getAxis(1)[ii] = pB.getAxis(1)[ii] - pB.getCorner()[ii];
|
|
499
|
+
pB.getAxis(2)[ii] = pB.getAxis(2)[ii] - pB.getCorner()[ii];
|
|
546
500
|
}
|
|
547
501
|
} else {
|
|
548
502
|
pB = nodeB;
|
|
549
503
|
}
|
|
504
|
+
const centerA = [0, 0, 0];
|
|
505
|
+
const centerB = [0, 0, 0];
|
|
506
|
+
const AtoB = [0, 0, 0];
|
|
507
|
+
for (let ii = 0; ii < 3; ii++) {
|
|
508
|
+
centerA[ii] = pA.getCorner()[ii] + 0.5 * (pA.getAxis(0)[ii] + pA.getAxis(1)[ii] + pA.getAxis(2)[ii]);
|
|
509
|
+
centerB[ii] = pB.getCorner()[ii] + 0.5 * (pB.getAxis(0)[ii] + pB.getAxis(1)[ii] + pB.getAxis(2)[ii]);
|
|
510
|
+
AtoB[ii] = centerB[ii] - centerA[ii];
|
|
511
|
+
}
|
|
550
512
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
} // Project maximal and minimal corners onto line between centers
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
var rangeAmin = dot(pA.getCorner(), AtoB);
|
|
563
|
-
var rangeAmax = rangeAmin;
|
|
564
|
-
var rangeBmin = dot(pB.getCorner(), AtoB);
|
|
565
|
-
var rangeBmax = rangeBmin;
|
|
566
|
-
var dotA = 0;
|
|
567
|
-
var dotB = 0;
|
|
568
|
-
|
|
569
|
-
for (var _ii4 = 0; _ii4 < 3; _ii4++) {
|
|
513
|
+
// Project maximal and minimal corners onto line between centers
|
|
514
|
+
let rangeAmin = dot(pA.getCorner(), AtoB);
|
|
515
|
+
let rangeAmax = rangeAmin;
|
|
516
|
+
let rangeBmin = dot(pB.getCorner(), AtoB);
|
|
517
|
+
let rangeBmax = rangeBmin;
|
|
518
|
+
let dotA = 0;
|
|
519
|
+
let dotB = 0;
|
|
520
|
+
for (let ii = 0; ii < 3; ii++) {
|
|
570
521
|
// compute A range
|
|
571
|
-
dotA = dot(pA.getAxis(
|
|
572
|
-
|
|
522
|
+
dotA = dot(pA.getAxis(ii), AtoB);
|
|
573
523
|
if (dotA > 0) {
|
|
574
524
|
rangeAmax += dotA;
|
|
575
525
|
} else {
|
|
576
526
|
rangeAmin += dotA;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
dotB = dot(pB.getAxis(_ii4), AtoB);
|
|
527
|
+
}
|
|
581
528
|
|
|
529
|
+
// compute B range
|
|
530
|
+
dotB = dot(pB.getAxis(ii), AtoB);
|
|
582
531
|
if (dotB > 0) {
|
|
583
532
|
rangeBmax += dotB;
|
|
584
533
|
} else {
|
|
585
534
|
rangeBmin += dotB;
|
|
586
535
|
}
|
|
587
536
|
}
|
|
588
|
-
|
|
589
537
|
if (rangeAmax + eps < rangeBmin || rangeBmax + eps < rangeAmin) {
|
|
590
538
|
return 1; // A and B are Disjoint by the 1st test.
|
|
591
|
-
}
|
|
592
|
-
|
|
539
|
+
}
|
|
593
540
|
|
|
594
|
-
for
|
|
541
|
+
// now check for a separation plane parallel to the faces of B
|
|
542
|
+
for (let ii = 0; ii < 3; ii++) {
|
|
595
543
|
// plane is normal to pB.getAxis(ii)
|
|
596
544
|
// computing B range is easy...
|
|
597
|
-
rangeBmin = dot(pB.getCorner(), pB.getAxis(
|
|
545
|
+
rangeBmin = dot(pB.getCorner(), pB.getAxis(ii));
|
|
598
546
|
rangeBmax = rangeBmin;
|
|
599
|
-
rangeBmax += dot(pB.getAxis(
|
|
547
|
+
rangeBmax += dot(pB.getAxis(ii), pB.getAxis(ii));
|
|
600
548
|
|
|
601
|
-
|
|
549
|
+
// compute A range...
|
|
550
|
+
rangeAmin = dot(pA.getCorner(), pB.getAxis(ii));
|
|
602
551
|
rangeAmax = rangeAmin;
|
|
603
|
-
|
|
604
|
-
for (var jj = 0; jj < 3; jj++) {
|
|
552
|
+
for (let jj = 0; jj < 3; jj++) {
|
|
605
553
|
// (note: we are saving all 9 dotproducts for future use)
|
|
606
|
-
dotA = dot(pB.getAxis(
|
|
607
|
-
dotAB[
|
|
608
|
-
|
|
554
|
+
dotA = dot(pB.getAxis(ii), pA.getAxis(jj));
|
|
555
|
+
dotAB[ii * 3 + jj] = dotA;
|
|
609
556
|
if (dotA > 0) {
|
|
610
557
|
rangeAmax += dotA;
|
|
611
558
|
} else {
|
|
612
559
|
rangeAmin += dotA;
|
|
613
560
|
}
|
|
614
561
|
}
|
|
615
|
-
|
|
616
562
|
if (rangeAmax + eps < rangeBmin || rangeBmax + eps < rangeAmin) {
|
|
617
563
|
return 2; // A and B are Disjoint by the 3rd test.
|
|
618
564
|
}
|
|
619
|
-
}
|
|
620
|
-
|
|
565
|
+
}
|
|
621
566
|
|
|
622
|
-
for
|
|
567
|
+
// now check for a separation plane parallel to the faces of A
|
|
568
|
+
for (let ii = 0; ii < 3; ii++) {
|
|
623
569
|
// plane is normal to pA.getAxis(ii)
|
|
624
570
|
// computing A range is easy...
|
|
625
|
-
rangeAmin = dot(pA.getCorner(), pA.getAxis(
|
|
571
|
+
rangeAmin = dot(pA.getCorner(), pA.getAxis(ii));
|
|
626
572
|
rangeAmax = rangeAmin;
|
|
627
|
-
rangeAmax += dot(pA.getAxis(
|
|
573
|
+
rangeAmax += dot(pA.getAxis(ii), pA.getAxis(ii));
|
|
628
574
|
|
|
629
|
-
|
|
575
|
+
// compute B range...
|
|
576
|
+
rangeBmin = dot(pB.getCorner(), pA.getAxis(ii));
|
|
630
577
|
rangeBmax = rangeBmin;
|
|
631
|
-
|
|
632
|
-
for (var _jj = 0; _jj < 3; _jj++) {
|
|
578
|
+
for (let jj = 0; jj < 3; jj++) {
|
|
633
579
|
// (note: we are using the 9 dotproducts computed earlier)
|
|
634
|
-
dotB = dotAB[
|
|
635
|
-
|
|
580
|
+
dotB = dotAB[jj * 3 + ii];
|
|
636
581
|
if (dotB > 0) {
|
|
637
582
|
rangeBmax += dotB;
|
|
638
583
|
} else {
|
|
639
584
|
rangeBmin += dotB;
|
|
640
585
|
}
|
|
641
586
|
}
|
|
642
|
-
|
|
643
587
|
if (rangeAmax + eps < rangeBmin || rangeBmax + eps < rangeAmin) {
|
|
644
588
|
return 3; // A and B are Disjoint by the 2nd test.
|
|
645
589
|
}
|
|
646
|
-
}
|
|
647
|
-
// to one edge from A and one edge from B.
|
|
648
|
-
|
|
590
|
+
}
|
|
649
591
|
|
|
650
|
-
|
|
651
|
-
|
|
592
|
+
// Bad luck: now we must look for a separation plane parallel
|
|
593
|
+
// to one edge from A and one edge from B.
|
|
594
|
+
for (let ii = 0; ii < 3; ii++) {
|
|
595
|
+
for (let jj = 0; jj < 3; jj++) {
|
|
652
596
|
// the plane is normal to pA.getAxis(ii) X pB.getAxis(jj)
|
|
653
|
-
cross(pA.getAxis(
|
|
597
|
+
cross(pA.getAxis(ii), pB.getAxis(jj), AtoB);
|
|
654
598
|
rangeAmin = dot(pA.getCorner(), AtoB);
|
|
655
599
|
rangeAmax = rangeAmin;
|
|
656
600
|
rangeBmin = dot(pB.getCorner(), AtoB);
|
|
657
601
|
rangeBmax = rangeBmin;
|
|
658
|
-
|
|
659
|
-
for (var kk = 0; kk < 3; kk++) {
|
|
602
|
+
for (let kk = 0; kk < 3; kk++) {
|
|
660
603
|
// compute A range
|
|
661
604
|
dotA = dot(pA.getAxis(kk), AtoB);
|
|
662
|
-
|
|
663
605
|
if (dotA > 0) {
|
|
664
606
|
rangeAmax += dotA;
|
|
665
607
|
} else {
|
|
666
608
|
rangeAmin += dotA;
|
|
667
|
-
}
|
|
668
|
-
|
|
609
|
+
}
|
|
669
610
|
|
|
611
|
+
// compute B range
|
|
670
612
|
dotB = dot(pB.getAxis(kk), AtoB);
|
|
671
|
-
|
|
672
613
|
if (dotB > 0) {
|
|
673
614
|
rangeBmax += dotB;
|
|
674
615
|
} else {
|
|
675
616
|
rangeBmin += dotB;
|
|
676
617
|
}
|
|
677
618
|
}
|
|
678
|
-
|
|
679
619
|
if (rangeAmax + eps < rangeBmin || rangeBmax + eps < rangeAmin) {
|
|
680
620
|
return 4; // A and B are Disjoint by the 4th test.
|
|
681
621
|
}
|
|
682
622
|
}
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
|
|
623
|
+
}
|
|
624
|
+
// if we fall through to here, the OBB's overlap
|
|
686
625
|
return 0;
|
|
687
626
|
};
|
|
627
|
+
|
|
688
628
|
/**
|
|
689
629
|
* Intersect this OBBTree with OBBTreeB (as transformed) and
|
|
690
630
|
* call processing function for each intersecting leaf node pair.
|
|
@@ -696,34 +636,27 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
696
636
|
* @param {function|null|undefined} callback Compared function that takes in argument:
|
|
697
637
|
* nodeA (vtkOBBNode), nodeB (vtkOBBNode), XForm (mat4), arg
|
|
698
638
|
*/
|
|
699
|
-
|
|
700
|
-
|
|
701
639
|
publicAPI.intersectWithOBBTree = function (obbTreeB, XformBtoA) {
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
var maxDepth = model.level;
|
|
706
|
-
var minDepth = obbTreeB.getLevel();
|
|
707
|
-
|
|
640
|
+
let onIntersect = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => -1;
|
|
641
|
+
let maxDepth = model.level;
|
|
642
|
+
let minDepth = obbTreeB.getLevel();
|
|
708
643
|
if (minDepth > maxDepth) {
|
|
709
644
|
minDepth = maxDepth;
|
|
710
645
|
maxDepth = obbTreeB.getLevel();
|
|
711
646
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
var OBBStackB = new Array(maxStackDepth);
|
|
647
|
+
const maxStackDepth = 3 * minDepth + 2 * (maxDepth - minDepth) + 1;
|
|
648
|
+
const OBBStackA = new Array(maxStackDepth);
|
|
649
|
+
const OBBStackB = new Array(maxStackDepth);
|
|
716
650
|
OBBStackA[0] = model.tree;
|
|
717
651
|
OBBStackB[0] = obbTreeB.getTree();
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
652
|
+
let depth = 1;
|
|
653
|
+
let count = 0;
|
|
654
|
+
let returnValue = 0;
|
|
655
|
+
// simulate recursion without overhead of real recursion.
|
|
722
656
|
while (depth > 0 && returnValue > -1) {
|
|
723
657
|
depth--;
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
658
|
+
const nodeA = OBBStackA[depth];
|
|
659
|
+
const nodeB = OBBStackB[depth];
|
|
727
660
|
if (!publicAPI.disjointOBBNodes(nodeA, nodeB, XformBtoA)) {
|
|
728
661
|
// Collision
|
|
729
662
|
if (!nodeA.getKids()) {
|
|
@@ -759,21 +692,17 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
759
692
|
}
|
|
760
693
|
}
|
|
761
694
|
}
|
|
762
|
-
|
|
763
695
|
return count;
|
|
764
696
|
};
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
var pB = [_toConsumableArray(p0), _toConsumableArray(p1), _toConsumableArray(p2)];
|
|
770
|
-
|
|
697
|
+
publicAPI.triangleIntersectsNode = (nodeA, p0, p1, p2, XformBtoA) => {
|
|
698
|
+
const eps = model.tolerance;
|
|
699
|
+
const pA = nodeA;
|
|
700
|
+
const pB = [[...p0], [...p1], [...p2]];
|
|
771
701
|
if (XformBtoA) {
|
|
772
702
|
// Here we assume that XformBtoA is an orthogonal matrix
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
for (var ii = 0; ii < 3; ii++) {
|
|
703
|
+
const input = [0, 0, 0, 1];
|
|
704
|
+
const output = [];
|
|
705
|
+
for (let ii = 0; ii < 3; ii++) {
|
|
777
706
|
input[0] = pB[ii][0];
|
|
778
707
|
input[1] = pB[ii][1];
|
|
779
708
|
input[2] = pB[ii][2];
|
|
@@ -782,119 +711,105 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
782
711
|
pB[ii][1] = output[1] / output[3];
|
|
783
712
|
pB[ii][2] = output[2] / output[3];
|
|
784
713
|
}
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
var v0 = [];
|
|
789
|
-
var v1 = [];
|
|
714
|
+
}
|
|
790
715
|
|
|
791
|
-
|
|
716
|
+
// now check for a separation plane parallel to the triangle
|
|
717
|
+
const v0 = [];
|
|
718
|
+
const v1 = [];
|
|
719
|
+
for (let ii = 0; ii < 3; ii++) {
|
|
792
720
|
// plane is normal to the triangle
|
|
793
|
-
v0[
|
|
794
|
-
v1[
|
|
721
|
+
v0[ii] = pB[1][ii] - pB[0][ii];
|
|
722
|
+
v1[ii] = pB[2][ii] - pB[0][ii];
|
|
795
723
|
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
for (var jj = 0; jj < 3; jj++) {
|
|
724
|
+
const xprod = cross(v0, v1, []);
|
|
725
|
+
// computing B range is easy...
|
|
726
|
+
let rangeBmax = dot(pB[0], xprod);
|
|
727
|
+
let rangeBmin = rangeBmax;
|
|
728
|
+
// compute A range...
|
|
729
|
+
let rangeAmax = dot(pA.getCorner(), xprod);
|
|
730
|
+
let rangeAmin = rangeAmax;
|
|
731
|
+
let dotA;
|
|
732
|
+
for (let jj = 0; jj < 3; jj++) {
|
|
807
733
|
dotA = dot(xprod, pA.getAxis(jj));
|
|
808
|
-
|
|
809
734
|
if (dotA > 0) {
|
|
810
735
|
rangeAmax += dotA;
|
|
811
736
|
} else {
|
|
812
737
|
rangeAmin += dotA;
|
|
813
738
|
}
|
|
814
739
|
}
|
|
815
|
-
|
|
816
740
|
if (rangeAmax + eps < rangeBmin || rangeBmax + eps < rangeAmin) {
|
|
817
741
|
return 0; // A and B are Disjoint by the 1st test.
|
|
818
|
-
}
|
|
819
|
-
|
|
742
|
+
}
|
|
820
743
|
|
|
821
|
-
for
|
|
744
|
+
// now check for a separation plane parallel to the faces of A
|
|
745
|
+
for (let ii = 0; ii < 3; ii++) {
|
|
822
746
|
// plane is normal to pA->Axes[ii]
|
|
823
747
|
// computing A range is easy...
|
|
824
|
-
rangeAmax = dot(pA.getCorner(), pA.getAxis(
|
|
748
|
+
rangeAmax = dot(pA.getCorner(), pA.getAxis(ii));
|
|
825
749
|
rangeAmin = rangeAmax;
|
|
826
|
-
rangeAmax += dot(pA.getAxis(
|
|
750
|
+
rangeAmax += dot(pA.getAxis(ii), pA.getAxis(ii));
|
|
827
751
|
|
|
828
|
-
|
|
752
|
+
// compute B range...
|
|
753
|
+
rangeBmax = dot(pB[0], pA.getAxis(ii));
|
|
829
754
|
rangeBmin = rangeBmax;
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
if (_dotB > rangeBmax) {
|
|
834
|
-
rangeBmax = _dotB;
|
|
755
|
+
let dotB = dot(pB[1], pA.getAxis(ii));
|
|
756
|
+
if (dotB > rangeBmax) {
|
|
757
|
+
rangeBmax = dotB;
|
|
835
758
|
} else {
|
|
836
|
-
rangeBmin =
|
|
759
|
+
rangeBmin = dotB;
|
|
837
760
|
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
if (
|
|
842
|
-
|
|
843
|
-
} else if (_dotB < rangeBmin) {
|
|
844
|
-
rangeBmin = _dotB;
|
|
761
|
+
dotB = dot(pB[2], pA.getAxis(ii));
|
|
762
|
+
if (dotB > rangeBmax) {
|
|
763
|
+
rangeBmax = dotB;
|
|
764
|
+
} else if (dotB < rangeBmin) {
|
|
765
|
+
rangeBmin = dotB;
|
|
845
766
|
}
|
|
846
|
-
|
|
847
767
|
if (rangeAmax + eps < rangeBmin || rangeBmax + eps < rangeAmin) {
|
|
848
768
|
return 0; // A and B are Disjoint by the 2nd test.
|
|
849
769
|
}
|
|
850
|
-
}
|
|
851
|
-
// to one edge from A and one edge from B.
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
var AtoB = [];
|
|
855
|
-
var dotB;
|
|
770
|
+
}
|
|
856
771
|
|
|
857
|
-
|
|
858
|
-
|
|
772
|
+
// Bad luck: now we must look for a separation plane parallel
|
|
773
|
+
// to one edge from A and one edge from B.
|
|
774
|
+
const AtoB = [];
|
|
775
|
+
let dotB;
|
|
776
|
+
for (let ii = 0; ii < 3; ii++) {
|
|
777
|
+
for (let jj = 0; jj < 3; jj++) {
|
|
859
778
|
// the plane is normal to pA->Axes[ii] X (pB[jj+1]-pB[jj])
|
|
860
|
-
v0[0] = pB[(
|
|
861
|
-
v0[1] = pB[(
|
|
862
|
-
v0[2] = pB[(
|
|
863
|
-
cross(pA.getAxis(
|
|
779
|
+
v0[0] = pB[(jj + 1) % 3][0] - pB[jj][0];
|
|
780
|
+
v0[1] = pB[(jj + 1) % 3][1] - pB[jj][1];
|
|
781
|
+
v0[2] = pB[(jj + 1) % 3][2] - pB[jj][2];
|
|
782
|
+
cross(pA.getAxis(ii), v0, AtoB);
|
|
864
783
|
rangeAmax = dot(pA.getCorner(), AtoB);
|
|
865
784
|
rangeAmin = rangeAmax;
|
|
866
|
-
rangeBmax = dot(pB[
|
|
785
|
+
rangeBmax = dot(pB[jj], AtoB);
|
|
867
786
|
rangeBmin = rangeBmax;
|
|
868
|
-
|
|
869
|
-
for (var kk = 0; kk < 3; kk++) {
|
|
787
|
+
for (let kk = 0; kk < 3; kk++) {
|
|
870
788
|
// compute A range
|
|
871
789
|
dotA = dot(pA.getAxis(kk), AtoB);
|
|
872
|
-
|
|
873
790
|
if (dotA > 0) {
|
|
874
791
|
rangeAmax += dotA;
|
|
875
792
|
} else {
|
|
876
793
|
rangeAmin += dotA;
|
|
877
794
|
}
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
dotB = dot(pB[(_jj3 + 2) % 3], AtoB);
|
|
882
|
-
|
|
795
|
+
}
|
|
796
|
+
// compute B range
|
|
797
|
+
dotB = dot(pB[(jj + 2) % 3], AtoB);
|
|
883
798
|
if (dotB > rangeBmax) {
|
|
884
799
|
rangeBmax = dotB;
|
|
885
800
|
} else {
|
|
886
801
|
rangeBmin = dotB;
|
|
887
802
|
}
|
|
888
|
-
|
|
889
803
|
if (rangeAmax + eps < rangeBmin || rangeBmax + eps < rangeAmin) {
|
|
890
804
|
return 0; // A and B are Disjoint by the 3rd test.
|
|
891
805
|
}
|
|
892
806
|
}
|
|
893
|
-
}
|
|
894
|
-
|
|
807
|
+
}
|
|
895
808
|
|
|
809
|
+
// if we fall through to here, the OBB overlaps the triangle.
|
|
896
810
|
return 1;
|
|
897
811
|
};
|
|
812
|
+
|
|
898
813
|
/**
|
|
899
814
|
*
|
|
900
815
|
* @param {*} info must be an object with { obbTree1, intersectionLines }
|
|
@@ -903,9 +818,7 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
903
818
|
* @param {*} transform
|
|
904
819
|
* @returns the number of intersection lines found
|
|
905
820
|
*/
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
publicAPI.findTriangleIntersections = function (info, node0, node1, transform) {
|
|
821
|
+
publicAPI.findTriangleIntersections = (info, node0, node1, transform) => {
|
|
909
822
|
// Set up local structures to hold Impl array information
|
|
910
823
|
// vtkOBBTree* obbTree1 = info->OBBTree1;
|
|
911
824
|
// vtkCellArray* intersectionLines = info->IntersectionLines;
|
|
@@ -914,61 +827,58 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
914
827
|
// vtkIdTypeArray* intersectionCellIds1 = info->CellIds[1];
|
|
915
828
|
// vtkPointLocator* pointMerger = info->PointMerger;
|
|
916
829
|
// double tolerance = info->Tolerance;
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
for (
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
830
|
+
const mesh0 = publicAPI.getDataset();
|
|
831
|
+
const mesh1 = info.obbTree1.getDataset();
|
|
832
|
+
const pointOffset = info.intersectionLines.getPoints().getNumberOfPoints();
|
|
833
|
+
const intersectionPoints = [];
|
|
834
|
+
const intersectionLines = [];
|
|
835
|
+
|
|
836
|
+
// The number of cells in OBBTree
|
|
837
|
+
const numCells0 = node0.getCells().length;
|
|
838
|
+
for (let id0 = 0; id0 < numCells0; id0++) {
|
|
839
|
+
const cellId0 = node0.getCells()[id0];
|
|
840
|
+
const type0 = mesh0.getCellType(cellId0);
|
|
841
|
+
|
|
842
|
+
// Make sure the cell is a triangle
|
|
929
843
|
if (type0 === CellType.VTK_TRIANGLE) {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
for (var id = 0; id < triPtIds0.length; id++) {
|
|
844
|
+
const {
|
|
845
|
+
cellPointIds: triPtIds0
|
|
846
|
+
} = mesh0.getCellPoints(cellId0);
|
|
847
|
+
const triPts0 = [[], [], []];
|
|
848
|
+
for (let id = 0; id < triPtIds0.length; id++) {
|
|
936
849
|
mesh0.getPoints().getPoint(triPtIds0[id], triPts0[id]);
|
|
937
850
|
}
|
|
938
|
-
|
|
939
851
|
if (info.obbTree1.triangleIntersectsNode(node1, triPts0[0], triPts0[1], triPts0[2], transform)) {
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
var type1 = mesh1.getCellType(cellId1);
|
|
945
|
-
|
|
852
|
+
const numCells1 = node1.getCells().length;
|
|
853
|
+
for (let id1 = 0; id1 < numCells1; id1++) {
|
|
854
|
+
const cellId1 = node1.getCells()[id1];
|
|
855
|
+
const type1 = mesh1.getCellType(cellId1);
|
|
946
856
|
if (type1 === CellType.VTK_TRIANGLE) {
|
|
947
857
|
// See if the two cells actually intersect. If they do,
|
|
948
858
|
// add an entry into the intersection maps and add an
|
|
949
859
|
// intersection line.
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
mesh1.getPoints().getPoint(triPtIds1[_id], triPts1[_id]);
|
|
860
|
+
const {
|
|
861
|
+
cellPointIds: triPtIds1
|
|
862
|
+
} = mesh1.getCellPoints(cellId1);
|
|
863
|
+
const triPts1 = [[], [], []];
|
|
864
|
+
for (let id = 0; id < triPtIds1.length; id++) {
|
|
865
|
+
mesh1.getPoints().getPoint(triPtIds1[id], triPts1[id]);
|
|
957
866
|
}
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
867
|
+
const {
|
|
868
|
+
intersect,
|
|
869
|
+
coplanar,
|
|
870
|
+
pt1: outpt0,
|
|
871
|
+
pt2: outpt1
|
|
872
|
+
// surfaceId,
|
|
873
|
+
} = vtkTriangle.intersectWithTriangle(...triPts0, ...triPts1, model.tolerance);
|
|
965
874
|
if (intersect && !coplanar) {
|
|
966
|
-
|
|
967
|
-
intersectionPoints.push
|
|
875
|
+
const pointId = intersectionPoints.length / 3;
|
|
876
|
+
intersectionPoints.push(...outpt0, ...outpt1);
|
|
968
877
|
intersectionLines.push(2, pointOffset + pointId, pointOffset + pointId + 1);
|
|
969
|
-
}
|
|
970
|
-
// and surface maps!
|
|
878
|
+
}
|
|
971
879
|
|
|
880
|
+
// If actual intersection, add point and cell to edge, line,
|
|
881
|
+
// and surface maps!
|
|
972
882
|
/*
|
|
973
883
|
if (coplanar) {
|
|
974
884
|
// Coplanar triangle intersection is not handled.
|
|
@@ -1125,7 +1035,6 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
1125
1035
|
}
|
|
1126
1036
|
}
|
|
1127
1037
|
*/
|
|
1128
|
-
|
|
1129
1038
|
}
|
|
1130
1039
|
}
|
|
1131
1040
|
}
|
|
@@ -1133,16 +1042,16 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
1133
1042
|
}
|
|
1134
1043
|
|
|
1135
1044
|
if (intersectionPoints.length) {
|
|
1136
|
-
|
|
1045
|
+
const points = vtkPoints.newInstance();
|
|
1137
1046
|
points.setData(pushArray(info.intersectionLines.getPoints().getData(), intersectionPoints));
|
|
1138
1047
|
info.intersectionLines.setPoints(points);
|
|
1139
|
-
|
|
1048
|
+
const lines = vtkCellArray.newInstance();
|
|
1140
1049
|
lines.setData(pushArray(info.intersectionLines.getLines().getData(), intersectionLines));
|
|
1141
1050
|
info.intersectionLines.setLines(lines);
|
|
1142
1051
|
}
|
|
1143
|
-
|
|
1144
1052
|
return intersectionLines.length / 3;
|
|
1145
1053
|
};
|
|
1054
|
+
|
|
1146
1055
|
/**
|
|
1147
1056
|
* Create polygonal representation for OBB tree at specified level. If
|
|
1148
1057
|
* level < 0, then the leaf OBB nodes will be gathered. The aspect ratio (ar)
|
|
@@ -1154,50 +1063,39 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
1154
1063
|
* @param {Number} level Level of the representation
|
|
1155
1064
|
* @returns {vtkPolyData}
|
|
1156
1065
|
*/
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
publicAPI.generateRepresentation = function (level) {
|
|
1066
|
+
publicAPI.generateRepresentation = level => {
|
|
1160
1067
|
if (!model.tree) {
|
|
1161
1068
|
vtkErrorMacro('No tree to generate representation for');
|
|
1162
1069
|
return null;
|
|
1163
1070
|
}
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
var polys = vtkCellArray.newInstance();
|
|
1071
|
+
const points = vtkPoints.newInstance();
|
|
1072
|
+
const polys = vtkCellArray.newInstance();
|
|
1167
1073
|
generatePolygons(model.tree, 0, level, points, polys);
|
|
1168
|
-
|
|
1074
|
+
const output = vtkPolyData.newInstance();
|
|
1169
1075
|
output.setPoints(points);
|
|
1170
1076
|
output.setPolys(polys);
|
|
1171
1077
|
return output;
|
|
1172
1078
|
};
|
|
1173
|
-
|
|
1174
|
-
publicAPI.buildLocator = function () {
|
|
1079
|
+
publicAPI.buildLocator = () => {
|
|
1175
1080
|
if (model.dataset === null) {
|
|
1176
1081
|
vtkErrorMacro("Can't build OBB tree - no data available!");
|
|
1177
1082
|
return;
|
|
1178
1083
|
}
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
var numCells = model.dataset.getNumberOfCells();
|
|
1182
|
-
|
|
1084
|
+
const numPts = model.dataset.getPoints().getNumberOfPoints();
|
|
1085
|
+
const numCells = model.dataset.getNumberOfCells();
|
|
1183
1086
|
if (numPts < 1 || numCells < 1) {
|
|
1184
1087
|
vtkErrorMacro("Can't build OBB tree - no data available!");
|
|
1185
1088
|
return;
|
|
1186
1089
|
}
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1090
|
+
model.OBBCount = 0;
|
|
1091
|
+
// Initialize an array of numPts elements set to value 0
|
|
1190
1092
|
model.insertedPoints = Array.from({
|
|
1191
1093
|
length: numPts
|
|
1192
|
-
},
|
|
1193
|
-
return 0;
|
|
1194
|
-
});
|
|
1094
|
+
}, _ => 0);
|
|
1195
1095
|
model.pointsList = [];
|
|
1196
|
-
|
|
1096
|
+
const cellList = Array.from({
|
|
1197
1097
|
length: numCells
|
|
1198
|
-
},
|
|
1199
|
-
return i;
|
|
1200
|
-
});
|
|
1098
|
+
}, (_, i) => i);
|
|
1201
1099
|
model.tree = vtkOBBNode.newInstance();
|
|
1202
1100
|
model.level = 0;
|
|
1203
1101
|
buildTree(cellList, model.tree, 0);
|
|
@@ -1205,10 +1103,11 @@ function vtkOBBTree(publicAPI, model) {
|
|
|
1205
1103
|
model.pointsList = [];
|
|
1206
1104
|
publicAPI.modified();
|
|
1207
1105
|
};
|
|
1208
|
-
}
|
|
1106
|
+
}
|
|
1209
1107
|
|
|
1108
|
+
// ----------------------------------------------------------------------------
|
|
1210
1109
|
|
|
1211
|
-
|
|
1110
|
+
const DEFAULT_VALUES = {
|
|
1212
1111
|
tolerance: 0.01,
|
|
1213
1112
|
automatic: true,
|
|
1214
1113
|
numberOfCellsPerNode: 32,
|
|
@@ -1220,24 +1119,33 @@ var DEFAULT_VALUES = {
|
|
|
1220
1119
|
level: 8,
|
|
1221
1120
|
maxLevel: 8,
|
|
1222
1121
|
retainCellLists: 1
|
|
1223
|
-
};
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1124
|
+
// ----------------------------------------------------------------------------
|
|
1224
1125
|
|
|
1225
1126
|
function extend(publicAPI, model) {
|
|
1226
|
-
|
|
1227
|
-
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
1127
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1128
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
1228
1129
|
|
|
1229
|
-
|
|
1130
|
+
// Build VTK API
|
|
1131
|
+
macro.setGet(publicAPI, model, ['tolerance', 'automatic', 'numberOfCellsPerNode', 'dataset', 'tree', 'maxLevel', 'level', 'retainCellLists']);
|
|
1230
1132
|
|
|
1231
|
-
|
|
1133
|
+
// Make this a VTK object
|
|
1134
|
+
macro.obj(publicAPI, model);
|
|
1232
1135
|
|
|
1136
|
+
// Object specific methods
|
|
1233
1137
|
vtkOBBTree(publicAPI, model);
|
|
1234
|
-
}
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
// ----------------------------------------------------------------------------
|
|
1141
|
+
|
|
1142
|
+
const newInstance = macro.newInstance(extend, 'vtkOBBTree');
|
|
1235
1143
|
|
|
1236
|
-
|
|
1144
|
+
// ----------------------------------------------------------------------------
|
|
1237
1145
|
|
|
1238
1146
|
var vtkOBBTree$1 = {
|
|
1239
|
-
newInstance
|
|
1240
|
-
extend
|
|
1147
|
+
newInstance,
|
|
1148
|
+
extend
|
|
1241
1149
|
};
|
|
1242
1150
|
|
|
1243
1151
|
export { vtkOBBTree$1 as default, extend, newInstance };
|