@itwin/core-geometry 4.3.0-dev.2 → 4.3.0-dev.20
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/CHANGELOG.md +41 -1
- package/lib/cjs/Geometry.d.ts.map +1 -1
- package/lib/cjs/Geometry.js +2 -4
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/bspline/BSpline1dNd.d.ts +12 -2
- package/lib/cjs/bspline/BSpline1dNd.d.ts.map +1 -1
- package/lib/cjs/bspline/BSpline1dNd.js +27 -17
- package/lib/cjs/bspline/BSpline1dNd.js.map +1 -1
- package/lib/cjs/bspline/BSplineCurve.d.ts +30 -16
- package/lib/cjs/bspline/BSplineCurve.d.ts.map +1 -1
- package/lib/cjs/bspline/BSplineCurve.js +68 -44
- package/lib/cjs/bspline/BSplineCurve.js.map +1 -1
- package/lib/cjs/bspline/BSplineCurve3dH.d.ts +27 -20
- package/lib/cjs/bspline/BSplineCurve3dH.d.ts.map +1 -1
- package/lib/cjs/bspline/BSplineCurve3dH.js +136 -87
- package/lib/cjs/bspline/BSplineCurve3dH.js.map +1 -1
- package/lib/cjs/bspline/BSplineSurface.d.ts +138 -74
- package/lib/cjs/bspline/BSplineSurface.d.ts.map +1 -1
- package/lib/cjs/bspline/BSplineSurface.js +242 -119
- package/lib/cjs/bspline/BSplineSurface.js.map +1 -1
- package/lib/cjs/bspline/Bezier1dNd.d.ts +18 -4
- package/lib/cjs/bspline/Bezier1dNd.d.ts.map +1 -1
- package/lib/cjs/bspline/Bezier1dNd.js +19 -5
- package/lib/cjs/bspline/Bezier1dNd.js.map +1 -1
- package/lib/cjs/bspline/BezierCurve3dH.d.ts.map +1 -1
- package/lib/cjs/bspline/BezierCurve3dH.js +2 -1
- package/lib/cjs/bspline/BezierCurve3dH.js.map +1 -1
- package/lib/cjs/bspline/KnotVector.d.ts +30 -33
- package/lib/cjs/bspline/KnotVector.d.ts.map +1 -1
- package/lib/cjs/bspline/KnotVector.js +76 -69
- package/lib/cjs/bspline/KnotVector.js.map +1 -1
- package/lib/cjs/clipping/AlternatingConvexClipTree.js.map +1 -1
- package/lib/cjs/clipping/ClipUtils.d.ts +32 -5
- package/lib/cjs/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipUtils.js +92 -11
- package/lib/cjs/clipping/ClipUtils.js.map +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +18 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js +47 -0
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/cjs/curve/CurveCollection.d.ts +9 -9
- package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCollection.js +7 -10
- package/lib/cjs/curve/CurveCollection.js.map +1 -1
- package/lib/cjs/curve/CurveCurve.d.ts +2 -2
- package/lib/cjs/curve/CurveCurve.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCurve.js +3 -16
- package/lib/cjs/curve/CurveCurve.js.map +1 -1
- package/lib/cjs/curve/CurveLocationDetail.d.ts +17 -4
- package/lib/cjs/curve/CurveLocationDetail.d.ts.map +1 -1
- package/lib/cjs/curve/CurveLocationDetail.js +32 -10
- package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
- package/lib/cjs/curve/CurveOps.d.ts +4 -5
- package/lib/cjs/curve/CurveOps.d.ts.map +1 -1
- package/lib/cjs/curve/CurveOps.js +1 -1
- package/lib/cjs/curve/CurveOps.js.map +1 -1
- package/lib/cjs/curve/CurveTypes.d.ts +14 -2
- package/lib/cjs/curve/CurveTypes.d.ts.map +1 -1
- package/lib/cjs/curve/CurveTypes.js.map +1 -1
- package/lib/cjs/curve/CurveWireMomentsXYZ.d.ts.map +1 -1
- package/lib/cjs/curve/CurveWireMomentsXYZ.js +2 -4
- package/lib/cjs/curve/CurveWireMomentsXYZ.js.map +1 -1
- package/lib/cjs/curve/LineString3d.d.ts +3 -6
- package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineString3d.js +1 -4
- package/lib/cjs/curve/LineString3d.js.map +1 -1
- package/lib/cjs/curve/PointString3d.d.ts +2 -1
- package/lib/cjs/curve/PointString3d.d.ts.map +1 -1
- package/lib/cjs/curve/PointString3d.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +7 -12
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +2 -1
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +0 -9
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +16 -35
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts +12 -6
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +80 -18
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts +11 -5
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js +73 -8
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
- package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts +2 -3
- package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/MultiChainCollector.js +2 -3
- package/lib/cjs/curve/internalContexts/MultiChainCollector.js.map +1 -1
- package/lib/cjs/curve/internalContexts/PolygonOffsetContext.d.ts +4 -4
- package/lib/cjs/curve/internalContexts/PolygonOffsetContext.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/PolygonOffsetContext.js +38 -36
- package/lib/cjs/curve/internalContexts/PolygonOffsetContext.js.map +1 -1
- package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts +21 -5
- package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/CoincidentGeometryOps.js +71 -45
- package/lib/cjs/geometry3d/CoincidentGeometryOps.js.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.d.ts +20 -13
- package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.js +28 -21
- package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +11 -2
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +16 -5
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts +58 -20
- package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.js +213 -62
- package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
- package/lib/cjs/geometry3d/Segment1d.d.ts +5 -1
- package/lib/cjs/geometry3d/Segment1d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Segment1d.js +11 -7
- package/lib/cjs/geometry3d/Segment1d.js.map +1 -1
- package/lib/cjs/geometry3d/Transform.d.ts +2 -3
- package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Transform.js +2 -3
- package/lib/cjs/geometry3d/Transform.js.map +1 -1
- package/lib/cjs/geometry4d/Point4d.d.ts +14 -1
- package/lib/cjs/geometry4d/Point4d.d.ts.map +1 -1
- package/lib/cjs/geometry4d/Point4d.js +22 -1
- package/lib/cjs/geometry4d/Point4d.js.map +1 -1
- package/lib/cjs/numerics/BezierPolynomials.d.ts +91 -68
- package/lib/cjs/numerics/BezierPolynomials.d.ts.map +1 -1
- package/lib/cjs/numerics/BezierPolynomials.js +100 -79
- package/lib/cjs/numerics/BezierPolynomials.js.map +1 -1
- package/lib/cjs/numerics/Newton.d.ts +115 -60
- package/lib/cjs/numerics/Newton.d.ts.map +1 -1
- package/lib/cjs/numerics/Newton.js +120 -62
- package/lib/cjs/numerics/Newton.js.map +1 -1
- package/lib/cjs/numerics/PascalCoefficients.d.ts +8 -12
- package/lib/cjs/numerics/PascalCoefficients.d.ts.map +1 -1
- package/lib/cjs/numerics/PascalCoefficients.js +10 -12
- package/lib/cjs/numerics/PascalCoefficients.js.map +1 -1
- package/lib/cjs/numerics/Polynomials.d.ts +2 -2
- package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
- package/lib/cjs/numerics/Polynomials.js +2 -2
- package/lib/cjs/numerics/Polynomials.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts +3 -0
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.js +13 -2
- package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceClip.d.ts +1 -1
- package/lib/cjs/polyface/PolyfaceClip.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceClip.js +6 -3
- package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceData.d.ts +1 -1
- package/lib/cjs/polyface/PolyfaceData.js +1 -1
- package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.d.ts +39 -12
- package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js +94 -17
- package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/cjs/serialization/BGFBReader.d.ts +10 -10
- package/lib/cjs/serialization/BGFBReader.d.ts.map +1 -1
- package/lib/cjs/serialization/BGFBReader.js +69 -42
- package/lib/cjs/serialization/BGFBReader.js.map +1 -1
- package/lib/cjs/serialization/BGFBWriter.d.ts +8 -8
- package/lib/cjs/serialization/BGFBWriter.d.ts.map +1 -1
- package/lib/cjs/serialization/BGFBWriter.js +80 -55
- package/lib/cjs/serialization/BGFBWriter.js.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.js +6 -8
- package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.d.ts +8 -14
- package/lib/cjs/serialization/IModelJsonSchema.d.ts.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.js +85 -259
- package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/cjs/serialization/SerializationHelpers.d.ts +109 -0
- package/lib/cjs/serialization/SerializationHelpers.d.ts.map +1 -0
- package/lib/cjs/serialization/SerializationHelpers.js +591 -0
- package/lib/cjs/serialization/SerializationHelpers.js.map +1 -0
- package/lib/cjs/solid/SweepContour.d.ts +4 -2
- package/lib/cjs/solid/SweepContour.d.ts.map +1 -1
- package/lib/cjs/solid/SweepContour.js +4 -2
- package/lib/cjs/solid/SweepContour.js.map +1 -1
- package/lib/esm/Geometry.d.ts.map +1 -1
- package/lib/esm/Geometry.js +2 -4
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/bspline/BSpline1dNd.d.ts +12 -2
- package/lib/esm/bspline/BSpline1dNd.d.ts.map +1 -1
- package/lib/esm/bspline/BSpline1dNd.js +27 -17
- package/lib/esm/bspline/BSpline1dNd.js.map +1 -1
- package/lib/esm/bspline/BSplineCurve.d.ts +30 -16
- package/lib/esm/bspline/BSplineCurve.d.ts.map +1 -1
- package/lib/esm/bspline/BSplineCurve.js +68 -44
- package/lib/esm/bspline/BSplineCurve.js.map +1 -1
- package/lib/esm/bspline/BSplineCurve3dH.d.ts +27 -20
- package/lib/esm/bspline/BSplineCurve3dH.d.ts.map +1 -1
- package/lib/esm/bspline/BSplineCurve3dH.js +137 -88
- package/lib/esm/bspline/BSplineCurve3dH.js.map +1 -1
- package/lib/esm/bspline/BSplineSurface.d.ts +138 -74
- package/lib/esm/bspline/BSplineSurface.d.ts.map +1 -1
- package/lib/esm/bspline/BSplineSurface.js +242 -119
- package/lib/esm/bspline/BSplineSurface.js.map +1 -1
- package/lib/esm/bspline/Bezier1dNd.d.ts +18 -4
- package/lib/esm/bspline/Bezier1dNd.d.ts.map +1 -1
- package/lib/esm/bspline/Bezier1dNd.js +19 -5
- package/lib/esm/bspline/Bezier1dNd.js.map +1 -1
- package/lib/esm/bspline/BezierCurve3dH.d.ts.map +1 -1
- package/lib/esm/bspline/BezierCurve3dH.js +2 -1
- package/lib/esm/bspline/BezierCurve3dH.js.map +1 -1
- package/lib/esm/bspline/KnotVector.d.ts +30 -33
- package/lib/esm/bspline/KnotVector.d.ts.map +1 -1
- package/lib/esm/bspline/KnotVector.js +76 -69
- package/lib/esm/bspline/KnotVector.js.map +1 -1
- package/lib/esm/clipping/AlternatingConvexClipTree.js.map +1 -1
- package/lib/esm/clipping/ClipUtils.d.ts +32 -5
- package/lib/esm/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/esm/clipping/ClipUtils.js +92 -11
- package/lib/esm/clipping/ClipUtils.js.map +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +18 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.js +48 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/esm/curve/CurveCollection.d.ts +9 -9
- package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
- package/lib/esm/curve/CurveCollection.js +7 -10
- package/lib/esm/curve/CurveCollection.js.map +1 -1
- package/lib/esm/curve/CurveCurve.d.ts +2 -2
- package/lib/esm/curve/CurveCurve.d.ts.map +1 -1
- package/lib/esm/curve/CurveCurve.js +3 -16
- package/lib/esm/curve/CurveCurve.js.map +1 -1
- package/lib/esm/curve/CurveLocationDetail.d.ts +17 -4
- package/lib/esm/curve/CurveLocationDetail.d.ts.map +1 -1
- package/lib/esm/curve/CurveLocationDetail.js +32 -10
- package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
- package/lib/esm/curve/CurveOps.d.ts +4 -5
- package/lib/esm/curve/CurveOps.d.ts.map +1 -1
- package/lib/esm/curve/CurveOps.js +1 -1
- package/lib/esm/curve/CurveOps.js.map +1 -1
- package/lib/esm/curve/CurveTypes.d.ts +14 -2
- package/lib/esm/curve/CurveTypes.d.ts.map +1 -1
- package/lib/esm/curve/CurveTypes.js.map +1 -1
- package/lib/esm/curve/CurveWireMomentsXYZ.d.ts.map +1 -1
- package/lib/esm/curve/CurveWireMomentsXYZ.js +2 -4
- package/lib/esm/curve/CurveWireMomentsXYZ.js.map +1 -1
- package/lib/esm/curve/LineString3d.d.ts +3 -6
- package/lib/esm/curve/LineString3d.d.ts.map +1 -1
- package/lib/esm/curve/LineString3d.js +1 -4
- package/lib/esm/curve/LineString3d.js.map +1 -1
- package/lib/esm/curve/PointString3d.d.ts +2 -1
- package/lib/esm/curve/PointString3d.d.ts.map +1 -1
- package/lib/esm/curve/PointString3d.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +7 -12
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +2 -1
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +0 -9
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +16 -35
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts +12 -6
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +81 -19
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts +11 -5
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js +74 -9
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
- package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts +2 -3
- package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/MultiChainCollector.js +2 -3
- package/lib/esm/curve/internalContexts/MultiChainCollector.js.map +1 -1
- package/lib/esm/curve/internalContexts/PolygonOffsetContext.d.ts +4 -4
- package/lib/esm/curve/internalContexts/PolygonOffsetContext.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/PolygonOffsetContext.js +38 -36
- package/lib/esm/curve/internalContexts/PolygonOffsetContext.js.map +1 -1
- package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts +21 -5
- package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/CoincidentGeometryOps.js +71 -45
- package/lib/esm/geometry3d/CoincidentGeometryOps.js.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.d.ts +20 -13
- package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.js +28 -21
- package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +11 -2
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +16 -5
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts +58 -20
- package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.js +213 -62
- package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
- package/lib/esm/geometry3d/Segment1d.d.ts +5 -1
- package/lib/esm/geometry3d/Segment1d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Segment1d.js +11 -7
- package/lib/esm/geometry3d/Segment1d.js.map +1 -1
- package/lib/esm/geometry3d/Transform.d.ts +2 -3
- package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
- package/lib/esm/geometry3d/Transform.js +2 -3
- package/lib/esm/geometry3d/Transform.js.map +1 -1
- package/lib/esm/geometry4d/Point4d.d.ts +14 -1
- package/lib/esm/geometry4d/Point4d.d.ts.map +1 -1
- package/lib/esm/geometry4d/Point4d.js +22 -1
- package/lib/esm/geometry4d/Point4d.js.map +1 -1
- package/lib/esm/numerics/BezierPolynomials.d.ts +91 -68
- package/lib/esm/numerics/BezierPolynomials.d.ts.map +1 -1
- package/lib/esm/numerics/BezierPolynomials.js +100 -79
- package/lib/esm/numerics/BezierPolynomials.js.map +1 -1
- package/lib/esm/numerics/Newton.d.ts +115 -60
- package/lib/esm/numerics/Newton.d.ts.map +1 -1
- package/lib/esm/numerics/Newton.js +120 -62
- package/lib/esm/numerics/Newton.js.map +1 -1
- package/lib/esm/numerics/PascalCoefficients.d.ts +8 -12
- package/lib/esm/numerics/PascalCoefficients.d.ts.map +1 -1
- package/lib/esm/numerics/PascalCoefficients.js +10 -12
- package/lib/esm/numerics/PascalCoefficients.js.map +1 -1
- package/lib/esm/numerics/Polynomials.d.ts +2 -2
- package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
- package/lib/esm/numerics/Polynomials.js +2 -2
- package/lib/esm/numerics/Polynomials.js.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.d.ts +3 -0
- package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.js +13 -2
- package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/esm/polyface/PolyfaceClip.d.ts +1 -1
- package/lib/esm/polyface/PolyfaceClip.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceClip.js +6 -3
- package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
- package/lib/esm/polyface/PolyfaceData.d.ts +1 -1
- package/lib/esm/polyface/PolyfaceData.js +1 -1
- package/lib/esm/polyface/PolyfaceData.js.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.d.ts +39 -12
- package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js +94 -17
- package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/esm/serialization/BGFBReader.d.ts +10 -10
- package/lib/esm/serialization/BGFBReader.d.ts.map +1 -1
- package/lib/esm/serialization/BGFBReader.js +69 -42
- package/lib/esm/serialization/BGFBReader.js.map +1 -1
- package/lib/esm/serialization/BGFBWriter.d.ts +8 -8
- package/lib/esm/serialization/BGFBWriter.d.ts.map +1 -1
- package/lib/esm/serialization/BGFBWriter.js +80 -55
- package/lib/esm/serialization/BGFBWriter.js.map +1 -1
- package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/esm/serialization/GeometrySamples.js +7 -9
- package/lib/esm/serialization/GeometrySamples.js.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.d.ts +8 -14
- package/lib/esm/serialization/IModelJsonSchema.d.ts.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.js +86 -260
- package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/esm/serialization/SerializationHelpers.d.ts +109 -0
- package/lib/esm/serialization/SerializationHelpers.d.ts.map +1 -0
- package/lib/esm/serialization/SerializationHelpers.js +588 -0
- package/lib/esm/serialization/SerializationHelpers.js.map +1 -0
- package/lib/esm/solid/SweepContour.d.ts +4 -2
- package/lib/esm/solid/SweepContour.d.ts.map +1 -1
- package/lib/esm/solid/SweepContour.js +4 -2
- package/lib/esm/solid/SweepContour.js.map +1 -1
- package/package.json +3 -3
|
@@ -11,39 +11,35 @@ exports.KnotVector = exports.BSplineWrapMode = void 0;
|
|
|
11
11
|
const Geometry_1 = require("../Geometry");
|
|
12
12
|
const PointHelpers_1 = require("../geometry3d/PointHelpers");
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* OpenByAddingControlPoints (1) ==> wrapped by adding poles
|
|
17
|
-
* OpenByRemovingKnots (2) ==> wrapped by deleting extreme knots.
|
|
14
|
+
* B-spline curve and surface types in this library are non-periodic. But they can be created from legacy periodic data.
|
|
15
|
+
* This enumeration lists the possible ways a B-spline object can have been created from legacy periodic data.
|
|
18
16
|
* @public
|
|
19
17
|
*/
|
|
20
18
|
var BSplineWrapMode;
|
|
21
19
|
(function (BSplineWrapMode) {
|
|
22
|
-
/** No conversion
|
|
20
|
+
/** No conversion performed. */
|
|
23
21
|
BSplineWrapMode[BSplineWrapMode["None"] = 0] = "None";
|
|
24
|
-
/**
|
|
25
|
-
* *
|
|
26
|
-
* *
|
|
22
|
+
/** The B-spline was opened up by adding degree wrap-around control points to the legacy periodic data.
|
|
23
|
+
* * This is typical of B-splines constructed with maximum (degree - 1) continuity.
|
|
24
|
+
* * Knots are unaffected by this conversion.
|
|
27
25
|
*/
|
|
28
26
|
BSplineWrapMode[BSplineWrapMode["OpenByAddingControlPoints"] = 1] = "OpenByAddingControlPoints";
|
|
29
|
-
/**
|
|
30
|
-
* *
|
|
31
|
-
* *
|
|
27
|
+
/** The B-spline was opened up by removing degree extreme knots from the legacy periodic data.
|
|
28
|
+
* * This is typical of rational B-spline curves representing full circles and ellipses.
|
|
29
|
+
* * Poles are unaffected by this conversion.
|
|
32
30
|
*/
|
|
33
31
|
BSplineWrapMode[BSplineWrapMode["OpenByRemovingKnots"] = 2] = "OpenByRemovingKnots";
|
|
34
32
|
})(BSplineWrapMode = exports.BSplineWrapMode || (exports.BSplineWrapMode = {}));
|
|
35
33
|
/**
|
|
36
|
-
* Array of non-decreasing numbers acting as a knot array for
|
|
34
|
+
* Array of non-decreasing numbers acting as a knot array for B-splines.
|
|
37
35
|
*
|
|
38
36
|
* * Essential identity: numKnots = numPoles + order - 2 = numPoles + degree - 1
|
|
39
|
-
* * Various
|
|
40
|
-
*
|
|
41
|
-
* * This class uses the "order-1" convention.
|
|
42
|
-
* * This class provides queries to convert among spanIndex and knotIndex
|
|
37
|
+
* * Various B-spline libraries have confusion over how many "end knots" are needed. Many libraries (including MicroStation and Parasolid)
|
|
38
|
+
* demand order knots at each end for clamping. But only order-1 are really needed. This class uses the order-1 convention.
|
|
43
39
|
* * A span is a single interval of the knots.
|
|
44
|
-
* * The left knot of span {k} is knot {k+degree-1}
|
|
45
|
-
* * This class provides queries to convert among spanFraction, fraction of knot range, and knot
|
|
46
|
-
* *
|
|
40
|
+
* * The left knot of span {k} is knot {k+degree-1}.
|
|
41
|
+
* * This class provides queries to convert among spanIndex, knotIndex, spanFraction, fraction of knot range, and knot.
|
|
42
|
+
* * Core computations (evaluateBasisFunctions) have leftKnotIndex and global knot value as inputs. Callers need to
|
|
47
43
|
* know their primary values (global knot, spanFraction).
|
|
48
44
|
* @public
|
|
49
45
|
*/
|
|
@@ -56,7 +52,7 @@ class KnotVector {
|
|
|
56
52
|
get leftKnotIndex() { return this.degree - 1; }
|
|
57
53
|
/** Return the index of the rightmost knot of the active interval */
|
|
58
54
|
get rightKnotIndex() { return this.knots.length - this.degree; }
|
|
59
|
-
/** Whether
|
|
55
|
+
/** Whether this KnotVector was created by converting legacy periodic data during deserialization. The conversion used is specified by BSplineWrapMode, and is reversed at serialization time. */
|
|
60
56
|
get wrappable() { return this._wrapMode === undefined ? BSplineWrapMode.None : this._wrapMode; }
|
|
61
57
|
set wrappable(value) { this._wrapMode = value; }
|
|
62
58
|
/** Return the number of bezier spans. Note that this includes zero-length spans if there are repeated knots. */
|
|
@@ -71,7 +67,7 @@ class KnotVector {
|
|
|
71
67
|
constructor(knots, degree, wrapMode) {
|
|
72
68
|
this.degree = degree;
|
|
73
69
|
this._wrapMode = wrapMode;
|
|
74
|
-
// default values to satisfy compiler -- real values
|
|
70
|
+
// default values to satisfy compiler -- real values happen in setupFixedValues, or final else defers to user
|
|
75
71
|
this._knot0 = 0.0;
|
|
76
72
|
this._knot1 = 1.0;
|
|
77
73
|
// satisfy the initialize checker ..
|
|
@@ -91,43 +87,43 @@ class KnotVector {
|
|
|
91
87
|
/** copy degree and knots to a new KnotVector. */
|
|
92
88
|
clone() { return new KnotVector(this.knots, this.degree, this.wrappable); }
|
|
93
89
|
setupFixedValues() {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
if (this.degree > 0 && this.knots.length > this.degree) {
|
|
91
|
+
this._knot0 = this.knots[this.degree - 1];
|
|
92
|
+
this._knot1 = this.knots[this.knots.length - this.degree];
|
|
93
|
+
}
|
|
97
94
|
}
|
|
98
95
|
/** Return the total knot distance from beginning to end. */
|
|
99
96
|
get knotLength01() { return this._knot1 - this._knot0; }
|
|
100
97
|
/**
|
|
101
|
-
* Returns true if all numeric values have wraparound conditions
|
|
102
|
-
* @param mode optional test mode. If undefined, use
|
|
98
|
+
* Returns true if all numeric values have wraparound conditions that allow the knots to be closed with specified wrap mode.
|
|
99
|
+
* @param mode optional test mode. If undefined, use this.wrappable.
|
|
103
100
|
*/
|
|
104
101
|
testClosable(mode) {
|
|
105
102
|
if (mode === undefined)
|
|
106
103
|
mode = this.wrappable;
|
|
104
|
+
const degree = this.degree;
|
|
107
105
|
const leftKnotIndex = this.leftKnotIndex;
|
|
108
106
|
const rightKnotIndex = this.rightKnotIndex;
|
|
109
|
-
const period = this.rightKnot - this.leftKnot;
|
|
110
|
-
const degree = this.degree;
|
|
111
|
-
const indexDelta = rightKnotIndex - leftKnotIndex;
|
|
112
|
-
// maximum continuity mode . . .
|
|
113
107
|
if (mode === BSplineWrapMode.OpenByAddingControlPoints) {
|
|
114
|
-
|
|
108
|
+
// maximum continuity mode: we expect degree periodically extended knots at each end
|
|
109
|
+
const period = this.rightKnot - this.leftKnot;
|
|
110
|
+
const indexDelta = rightKnotIndex - leftKnotIndex;
|
|
111
|
+
for (let k0 = 0; k0 < leftKnotIndex + degree; k0++) {
|
|
115
112
|
const k1 = k0 + indexDelta;
|
|
116
|
-
if (
|
|
113
|
+
if (Math.abs(this.knots[k0] + period - this.knots[k1]) >= KnotVector.knotTolerance)
|
|
117
114
|
return false;
|
|
118
115
|
}
|
|
119
116
|
return true;
|
|
120
117
|
}
|
|
121
|
-
// arc mode ...
|
|
122
118
|
if (mode === BSplineWrapMode.OpenByRemovingKnots) {
|
|
123
|
-
// we expect
|
|
119
|
+
// legacy periodic mode: we expect multiplicity degree knots at each end
|
|
124
120
|
const numRepeated = degree - 1;
|
|
125
|
-
const leftKnot = this.
|
|
126
|
-
const rightKnot = this.
|
|
121
|
+
const leftKnot = this.leftKnot;
|
|
122
|
+
const rightKnot = this.rightKnot;
|
|
127
123
|
for (let i = 0; i < numRepeated; i++) {
|
|
128
|
-
if (
|
|
124
|
+
if (Math.abs(leftKnot - this.knots[leftKnotIndex - i - 1]) >= KnotVector.knotTolerance)
|
|
129
125
|
return false;
|
|
130
|
-
if (
|
|
126
|
+
if (Math.abs(rightKnot - this.knots[rightKnotIndex + i + 1]) >= KnotVector.knotTolerance)
|
|
131
127
|
return false;
|
|
132
128
|
}
|
|
133
129
|
return true;
|
|
@@ -209,7 +205,7 @@ class KnotVector {
|
|
|
209
205
|
}
|
|
210
206
|
this.setupFixedValues();
|
|
211
207
|
}
|
|
212
|
-
/**
|
|
208
|
+
/** Set knots to input array (CAPTURED) */
|
|
213
209
|
setKnotsCapture(knots) {
|
|
214
210
|
this.knots = knots;
|
|
215
211
|
this.setupFixedValues();
|
|
@@ -303,19 +299,22 @@ class KnotVector {
|
|
|
303
299
|
* Evaluate basis functions f[] at knot value u.
|
|
304
300
|
*
|
|
305
301
|
* @param u knot value for evaluation
|
|
306
|
-
* @param f array of order basis function values
|
|
302
|
+
* @param f preallocated output array of order basis function values
|
|
303
|
+
* @returns true if and only if output array is sufficiently sized
|
|
307
304
|
*/
|
|
308
305
|
evaluateBasisFunctions(knotIndex0, u, f) {
|
|
306
|
+
if (f.length < this.degree + 1)
|
|
307
|
+
return false;
|
|
309
308
|
f[0] = 1.0;
|
|
310
309
|
if (this.degree < 1)
|
|
311
|
-
return;
|
|
310
|
+
return true;
|
|
312
311
|
// direct compute for linear part ...
|
|
313
312
|
const u0 = this.knots[knotIndex0];
|
|
314
313
|
const u1 = this.knots[knotIndex0 + 1];
|
|
315
314
|
f[1] = (u - u0) / (u1 - u0);
|
|
316
315
|
f[0] = 1.0 - f[1];
|
|
317
316
|
if (this.degree < 2)
|
|
318
|
-
return;
|
|
317
|
+
return true;
|
|
319
318
|
for (let depth = 1; depth < this.degree; depth++) {
|
|
320
319
|
let kLeft = knotIndex0 - depth;
|
|
321
320
|
let kRight = kLeft + depth + 1;
|
|
@@ -331,20 +330,28 @@ class KnotVector {
|
|
|
331
330
|
}
|
|
332
331
|
f[depth + 1] = gCarry;
|
|
333
332
|
}
|
|
333
|
+
return true;
|
|
334
334
|
}
|
|
335
335
|
/**
|
|
336
336
|
* Evaluate basis functions f[], derivatives df[], and optional second derivatives ddf[] at knot value u.
|
|
337
337
|
*
|
|
338
338
|
* @param u knot value for evaluation
|
|
339
|
-
* @param f array of order basis function values
|
|
340
|
-
* @param df array of order basis derivative values
|
|
341
|
-
* @param ddf array of order basis second derivative values
|
|
339
|
+
* @param f preallocated output array of order basis function values
|
|
340
|
+
* @param df preallocated output array of order basis derivative values
|
|
341
|
+
* @param ddf optional preallocated output array of order basis second derivative values
|
|
342
|
+
* @returns true if and only if output arrays are sufficiently sized
|
|
342
343
|
*/
|
|
343
344
|
evaluateBasisFunctions1(knotIndex0, u, f, df, ddf) {
|
|
345
|
+
if (f.length < this.degree + 1)
|
|
346
|
+
return false;
|
|
347
|
+
if (df.length < this.degree + 1)
|
|
348
|
+
return false;
|
|
349
|
+
if (ddf && ddf.length < this.degree + 1)
|
|
350
|
+
return false;
|
|
344
351
|
f[0] = 1.0;
|
|
345
352
|
df[0] = 0.0;
|
|
346
353
|
if (this.degree < 1)
|
|
347
|
-
return;
|
|
354
|
+
return true;
|
|
348
355
|
// direct compute for linear part ...
|
|
349
356
|
const u0 = this.knots[knotIndex0];
|
|
350
357
|
const u1 = this.knots[knotIndex0 + 1];
|
|
@@ -360,7 +367,7 @@ class KnotVector {
|
|
|
360
367
|
ddf[1] = 0.0;
|
|
361
368
|
}
|
|
362
369
|
if (this.degree < 2)
|
|
363
|
-
return;
|
|
370
|
+
return true;
|
|
364
371
|
for (let depth = 1; depth < this.degree; depth++) {
|
|
365
372
|
let kLeft = knotIndex0 - depth;
|
|
366
373
|
let kRight = kLeft + depth + 1;
|
|
@@ -402,6 +409,7 @@ class KnotVector {
|
|
|
402
409
|
if (ddf)
|
|
403
410
|
ddf[depth + 1] = ddgCarry;
|
|
404
411
|
}
|
|
412
|
+
return true;
|
|
405
413
|
}
|
|
406
414
|
/** Find the knot span bracketing knots[i] <= u < knots[i+1] and return i.
|
|
407
415
|
* * If u has no such bracket, return the smaller index of the closest nontrivial bracket.
|
|
@@ -453,38 +461,37 @@ class KnotVector {
|
|
|
453
461
|
this.knots[i] = a + (b - this.knots[i]);
|
|
454
462
|
this.knots.reverse();
|
|
455
463
|
}
|
|
456
|
-
/**
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
const
|
|
462
|
-
const
|
|
463
|
-
const rightIndex = this.rightKnotIndex;
|
|
464
|
-
const a0 = this.leftKnot;
|
|
465
|
-
const a1 = this.rightKnot;
|
|
464
|
+
/** Return a simple array form of the knots. Optionally replicate the first and last in classic over-clamped manner. */
|
|
465
|
+
static copyKnots(knots, degree, includeExtraEndKnot, wrapMode) {
|
|
466
|
+
const isExtraEndKnotPeriodic = (includeExtraEndKnot && wrapMode === BSplineWrapMode.OpenByAddingControlPoints);
|
|
467
|
+
const leftIndex = degree - 1;
|
|
468
|
+
const rightIndex = knots.length - degree;
|
|
469
|
+
const a0 = knots[leftIndex];
|
|
470
|
+
const a1 = knots[rightIndex];
|
|
466
471
|
const delta = a1 - a0;
|
|
467
|
-
const degree = this.degree;
|
|
468
472
|
const values = [];
|
|
469
473
|
if (includeExtraEndKnot) {
|
|
470
|
-
if (
|
|
471
|
-
values.push(
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
values.push(this.knots[0]);
|
|
475
|
-
}
|
|
474
|
+
if (isExtraEndKnotPeriodic)
|
|
475
|
+
values.push(knots[rightIndex - degree] - delta);
|
|
476
|
+
else
|
|
477
|
+
values.push(knots[0]);
|
|
476
478
|
}
|
|
477
|
-
for (const u of
|
|
479
|
+
for (const u of knots) {
|
|
478
480
|
values.push(u);
|
|
481
|
+
}
|
|
479
482
|
if (includeExtraEndKnot) {
|
|
480
|
-
if (
|
|
481
|
-
values.push(
|
|
482
|
-
}
|
|
483
|
+
if (isExtraEndKnotPeriodic)
|
|
484
|
+
values.push(knots[leftIndex + degree] + delta);
|
|
483
485
|
else
|
|
484
|
-
values.push(
|
|
486
|
+
values.push(knots[knots.length - 1]);
|
|
485
487
|
}
|
|
486
488
|
return values;
|
|
487
489
|
}
|
|
490
|
+
/** Return a simple array form of the knots. Optionally replicate the first and last in classic over-clamped manner. */
|
|
491
|
+
copyKnots(includeExtraEndKnot) {
|
|
492
|
+
const wrapMode = (includeExtraEndKnot && this.testClosable()) ? this.wrappable : undefined;
|
|
493
|
+
return KnotVector.copyKnots(this.knots, this.degree, includeExtraEndKnot, wrapMode);
|
|
494
|
+
}
|
|
488
495
|
}
|
|
489
496
|
/** tolerance for considering two knots to be the same. */
|
|
490
497
|
KnotVector.knotTolerance = 1.0e-9;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnotVector.js","sourceRoot":"","sources":["../../../src/bspline/KnotVector.ts"],"names":[],"mappings":";AAAA;;;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AAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;aACrD;;gBACC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;SAC1C;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;;AA7aD,0DAA0D;AACnC,wBAAa,GAAG,MAAM,CAAC;AAVnC,gCAAU","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Bspline\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { NumberArray } from \"../geometry3d/PointHelpers\";\r\n\r\n/**\r\n * Enumeration of the possible ways of converting a \"periodic\" knot vector to an open knot vector.\r\n * None (0) ==> no wrap possible\r\n * OpenByAddingControlPoints (1) ==> wrapped by adding poles\r\n * OpenByRemovingKnots (2) ==> wrapped by deleting extreme knots.\r\n * @public\r\n */\r\nexport enum BSplineWrapMode {\r\n /** No conversion to periodic */\r\n None = 0,\r\n /** Convert to periodic by removing control points. This is typical for closed bcurve constructed by control points with maximum continuity.\r\n * * Knots stay the same in open and periodic form.\r\n * * Periodic form omits {degree} control points.\r\n */\r\n OpenByAddingControlPoints = 1,\r\n /** Convert to periodic by adding special knots. This is typical of closed bcurve constructed as exact circular or elliptic arc\r\n * * 2 knots on each end are omitted in open form\r\n * * poles stay the same.\r\n */\r\n OpenByRemovingKnots = 2,\r\n}\r\n/**\r\n * Array of non-decreasing numbers acting as a knot array for bsplines.\r\n *\r\n * * Essential identity: numKnots = numPoles + order - 2 = numPoles + degree - 1\r\n * * Various bspline libraries have confusion over how many \"end knots\" are needed. \"Many\" libraries (including MicroStation)\r\n * incorrectly demand \"order\" knots at each end for clamping. But only \"order - 1\" are really needed.\r\n * * This class uses the \"order-1\" convention.\r\n * * This class provides queries to convert among spanIndex and knotIndex\r\n * * A span is a single interval of the knots.\r\n * * The left knot of span {k} is knot {k+degree-1}\r\n * * This class provides queries to convert among spanFraction, fraction of knot range, and knot\r\n * * core computations (evaluateBasisFunctions) have leftKnotIndex and global knot value as inputs. Callers need to\r\n * know their primary values (global knot, spanFraction).\r\n * @public\r\n */\r\nexport class KnotVector {\r\n /** The simple array of knot values. */\r\n public knots: Float64Array;\r\n /** Return the degree of basis functions defined in these knots. */\r\n public degree: number;\r\n private _knot0: number;\r\n private _knot1: number;\r\n\r\n private _wrapMode?: BSplineWrapMode;\r\n /** tolerance for considering two knots to be the same. */\r\n public static readonly knotTolerance = 1.0e-9;\r\n /** Return the leftmost knot value (of the active interval, ignoring unclamped leading knots)*/\r\n public get leftKnot() { return this._knot0; }\r\n /** Return the rightmost knot value (of the active interval, ignoring unclamped leading knots)*/\r\n public get rightKnot() { return this._knot1; }\r\n /** Return the index of the leftmost knot of the active interval */\r\n public get leftKnotIndex() { return this.degree - 1; }\r\n /** Return the index of the rightmost knot of the active interval */\r\n public get rightKnotIndex() { return this.knots.length - this.degree; }\r\n /** Whether the bspline was created by adding poles into \"closed\" structure. This is used by serialize/deserialize to mark knotVector's that were converted from periodic style. */\r\n public get wrappable() { return this._wrapMode === undefined ? BSplineWrapMode.None : this._wrapMode; }\r\n public set wrappable(value: BSplineWrapMode) { this._wrapMode = value; }\r\n /** Return the number of bezier spans. Note that this includes zero-length spans if there are repeated knots. */\r\n public get numSpans() { return this.rightKnotIndex - this.leftKnotIndex; }\r\n /**\r\n *\r\n * * If knots is a number array or Float64Array, the those values become the local knot array.\r\n * * If knots is a simple number, the local knot array is allocated to that size but left as zeros.\r\n * @param knots\r\n * @param degree\r\n */\r\n private constructor(knots: number[] | Float64Array | number, degree: number, wrapMode?: BSplineWrapMode) {\r\n this.degree = degree;\r\n this._wrapMode = wrapMode;\r\n // default values to satisfy compiler -- real values hapn setupFixedValues or final else defers to user\r\n this._knot0 = 0.0;\r\n this._knot1 = 1.0;\r\n // satisfy the initialize checker ..\r\n if (Array.isArray(knots)) { // remark: This ctor is private. The callers (as of April 2019) do not use this path.\r\n this.knots = new Float64Array(knots.length);\r\n this.setKnots(knots);\r\n this.setupFixedValues();\r\n } else if (knots instanceof Float64Array) {\r\n this.knots = knots.slice();\r\n this.setupFixedValues();\r\n } else { // caller is responsible for filling array separately ...\r\n this.knots = new Float64Array(knots);\r\n }\r\n }\r\n /** copy degree and knots to a new KnotVector. */\r\n public clone(): KnotVector { return new KnotVector(this.knots, this.degree, this.wrappable); }\r\n private setupFixedValues() {\r\n // These should be read-only . ..\r\n this._knot0 = this.knots[this.degree - 1];\r\n this._knot1 = this.knots[this.knots.length - this.degree];\r\n }\r\n /** Return the total knot distance from beginning to end. */\r\n public get knotLength01(): number { return this._knot1 - this._knot0; }\r\n /**\r\n * Returns true if all numeric values have wraparound conditions for \"closed\" knotVector with specified wrap mode\r\n * @param mode optional test mode. If undefined, use the this.wrappable.\r\n */\r\n public testClosable(mode?: BSplineWrapMode): boolean {\r\n if (mode === undefined)\r\n mode = this.wrappable;\r\n const leftKnotIndex = this.leftKnotIndex;\r\n const rightKnotIndex = this.rightKnotIndex;\r\n const period = this.rightKnot - this.leftKnot;\r\n const degree = this.degree;\r\n const indexDelta = rightKnotIndex - leftKnotIndex;\r\n // maximum continuity mode . . .\r\n if (mode === BSplineWrapMode.OpenByAddingControlPoints) {\r\n for (let k0 = leftKnotIndex - degree + 1; k0 < leftKnotIndex + degree - 1; k0++) {\r\n const k1 = k0 + indexDelta;\r\n if (!Geometry.isSameCoordinate(this.knots[k0] + period, this.knots[k1]))\r\n return false;\r\n }\r\n return true;\r\n }\r\n // arc mode ...\r\n if (mode === BSplineWrapMode.OpenByRemovingKnots) {\r\n // we expect {degree} replicated knots at each end . . .\r\n const numRepeated = degree - 1;\r\n const leftKnot = this.knots[leftKnotIndex];\r\n const rightKnot = this.knots[rightKnotIndex];\r\n for (let i = 0; i < numRepeated; i++) {\r\n if (!Geometry.isSameCoordinate(leftKnot, this.knots[leftKnotIndex - i - 1]))\r\n return false;\r\n if (!Geometry.isSameCoordinate(rightKnot, this.knots[rightKnotIndex + i + 1]))\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n /** Test matching degree and knot values */\r\n public isAlmostEqual(other: KnotVector): boolean {\r\n if (this.degree !== other.degree) return false;\r\n return NumberArray.isAlmostEqual(this.knots, other.knots, KnotVector.knotTolerance);\r\n }\r\n\r\n /** Compute the multiplicity of the input knot, or zero if not a knot. */\r\n public getKnotMultiplicity(knot: number): number {\r\n let m = 0;\r\n for (const k of this.knots) {\r\n if (Math.abs(k - knot) < KnotVector.knotTolerance)\r\n ++m;\r\n else if (knot < k)\r\n break;\r\n }\r\n return m;\r\n }\r\n\r\n /** Compute the multiplicity of the knot at the given index. */\r\n public getKnotMultiplicityAtIndex(knotIndex: number): number {\r\n let m = 0;\r\n if (knotIndex >= 0 && knotIndex < this.knots.length) {\r\n const knot = this.knots[knotIndex];\r\n ++m; // count this knot\r\n for (let i = knotIndex - 1; i >= 0; --i) {\r\n const k = this.knots[i];\r\n if (Math.abs(k - knot) < KnotVector.knotTolerance)\r\n ++m; // found multiple to left of knot\r\n else if (knot > k)\r\n break;\r\n }\r\n for (let i = knotIndex + 1; i < this.knots.length; ++i) {\r\n const k = this.knots[i];\r\n if (Math.abs(k - knot) < KnotVector.knotTolerance)\r\n ++m; // found multiple to right of knot\r\n else if (knot < k)\r\n break;\r\n }\r\n }\r\n return m;\r\n }\r\n\r\n /** Transform knots to span [0,1].\r\n * @returns false if and only if this.knotLength01 is trivial\r\n */\r\n public normalize(): boolean {\r\n if (this.knotLength01 < KnotVector.knotTolerance)\r\n return false;\r\n const divisor = 1.0 / this.knotLength01;\r\n const leftKnot = this.leftKnot;\r\n for (let i = 0; i < this.knots.length; ++i)\r\n this.knots[i] = (this.knots[i] - leftKnot) * divisor;\r\n // explicitly set rightKnot and its multiples to 1.0 to avoid round-off\r\n for (let i = this.rightKnotIndex - 1; i > this.leftKnotIndex && (this.knots[i] === this.knots[this.rightKnotIndex]); --i) this.knots[i] = 1.0;\r\n for (let i = this.rightKnotIndex + 1; i < this.knots.length && (this.knots[i] === this.knots[this.rightKnotIndex]); ++i) this.knots[i] = 1.0;\r\n this.knots[this.rightKnotIndex] = 1.0;\r\n this.setupFixedValues();\r\n return true;\r\n }\r\n\r\n /** install knot values from an array, optionally ignoring first and last.\r\n */\r\n public setKnots(knots: number[] | Float64Array, skipFirstAndLast?: boolean) {\r\n const numAllocate = skipFirstAndLast ? knots.length - 2 : knots.length;\r\n if (numAllocate !== this.knots.length)\r\n this.knots = new Float64Array(numAllocate);\r\n if (skipFirstAndLast) {\r\n for (let i = 1; i + 1 < knots.length; i++)\r\n this.knots[i - 1] = knots[i];\r\n\r\n } else {\r\n for (let i = 0; i < knots.length; i++)\r\n this.knots[i] = knots[i];\r\n }\r\n this.setupFixedValues();\r\n }\r\n\r\n /** install knot values from an array, optionally ignoring first and last. */\r\n public setKnotsCapture(knots: Float64Array) {\r\n this.knots = knots;\r\n this.setupFixedValues();\r\n }\r\n\r\n /**\r\n * Create knot vector with {degree-1} replicated knots at start and end, and uniform knots between.\r\n * @param numPoles Number of poles\r\n * @param degree degree of polynomial\r\n * @param a0 left knot value for active interval\r\n * @param a1 right knot value for active interval\r\n */\r\n public static createUniformClamped(numPoles: number, degree: number, a0: number, a1: number): KnotVector {\r\n const knots = new KnotVector(numPoles + degree - 1, degree);\r\n let k = 0;\r\n for (let m = 0; m < degree; m++)knots.knots[k++] = a0;\r\n const du = 1.0 / (numPoles - degree);\r\n for (let i = 1; i + degree < numPoles; i++)\r\n knots.knots[k++] = a0 + i * du * (a1 - a0);\r\n for (let m = 0; m < degree; m++)knots.knots[k++] = a1;\r\n knots.setupFixedValues();\r\n return knots;\r\n }\r\n /**\r\n * Create knot vector with wraparound knots at start and end, and uniform knots between.\r\n * @param numInterval number of intervals in knot space. (NOT POLE COUNT)\r\n * @param degree degree of polynomial\r\n * @param a0 left knot value for active interval\r\n * @param a1 right knot value for active interval\r\n */\r\n public static createUniformWrapped(numInterval: number, degree: number, a0: number, a1: number): KnotVector {\r\n const knots = new KnotVector(numInterval + 2 * degree - 1, degree);\r\n const du = 1.0 / numInterval;\r\n for (let i = 1 - degree, k = 0; i < numInterval + degree; i++, k++) {\r\n knots.knots[k] = Geometry.interpolate(a0, i * du, a1);\r\n }\r\n knots.setupFixedValues();\r\n return knots;\r\n }\r\n\r\n /**\r\n * Create knot vector with given knot values and degree.\r\n * @param knotArray knot values\r\n * @param degree degree of polynomial\r\n * @param skipFirstAndLast true to skip copying the first and last knot values.\r\n */\r\n public static create(knotArray: number[] | Float64Array, degree: number, skipFirstAndLast?: boolean): KnotVector {\r\n const numAllocate = skipFirstAndLast ? knotArray.length - 2 : knotArray.length;\r\n const knots = new KnotVector(numAllocate, degree);\r\n knots.setKnots(knotArray, skipFirstAndLast);\r\n return knots;\r\n }\r\n\r\n /**\r\n * Return the average of degree consecutive knots beginning at knotIndex.\r\n */\r\n public grevilleKnot(knotIndex: number): number {\r\n if (knotIndex < 0) return this.leftKnot;\r\n if (knotIndex > this.rightKnotIndex) return this.rightKnot;\r\n let sum = 0.0;\r\n for (let i = knotIndex; i < knotIndex + this.degree; i++)\r\n sum += this.knots[i];\r\n return sum / this.degree;\r\n }\r\n /** Return an array sized for a set of the basis function values. */\r\n public createBasisArray(): Float64Array { return new Float64Array(this.degree + 1); }\r\n /** Convert localFraction within the interval following an indexed knot to a knot value. */\r\n public baseKnotFractionToKnot(knotIndex0: number, localFraction: number): number {\r\n const knot0 = this.knots[knotIndex0];\r\n localFraction = Geometry.clamp(localFraction, 0, 1);\r\n return knot0 + localFraction * (this.knots[knotIndex0 + 1] - knot0);\r\n }\r\n /** Convert localFraction within an indexed bezier span to a knot value. */\r\n public spanFractionToKnot(spanIndex: number, localFraction: number): number {\r\n const k = this.spanIndexToLeftKnotIndex(spanIndex);\r\n localFraction = Geometry.clamp(localFraction, 0, 1);\r\n return this.knots[k] + localFraction * (this.knots[k + 1] - this.knots[k]);\r\n }\r\n /** Convert localFraction within an indexed bezier span to fraction of active knot range. */\r\n public spanFractionToFraction(spanIndex: number, localFraction: number): number {\r\n const knot = this.spanFractionToKnot(spanIndex, localFraction);\r\n return (knot - this.leftKnot) / (this.rightKnot - this.leftKnot);\r\n }\r\n /** Return fraction of active knot range to knot value. */\r\n public fractionToKnot(fraction: number): number {\r\n fraction = Geometry.clamp(fraction, 0, 1); // B-splines are not extendable\r\n return Geometry.interpolate(this.knots[this.degree - 1], fraction, this.knots[this.knots.length - this.degree]);\r\n }\r\n /**\r\n * Evaluate basis functions f[] at knot value u.\r\n *\r\n * @param u knot value for evaluation\r\n * @param f array of order basis function values\r\n */\r\n public evaluateBasisFunctions(knotIndex0: number, u: number, f: Float64Array) {\r\n f[0] = 1.0;\r\n if (this.degree < 1) return;\r\n // direct compute for linear part ...\r\n const u0 = this.knots[knotIndex0];\r\n const u1 = this.knots[knotIndex0 + 1];\r\n f[1] = (u - u0) / (u1 - u0);\r\n f[0] = 1.0 - f[1];\r\n if (this.degree < 2) return;\r\n\r\n for (let depth = 1; depth < this.degree; depth++) {\r\n let kLeft = knotIndex0 - depth;\r\n let kRight = kLeft + depth + 1;\r\n let gCarry = 0.0;\r\n for (let step = 0; step <= depth; step++) {\r\n const tLeft = this.knots[kLeft++];\r\n const tRight = this.knots[kRight++];\r\n const fraction = (u - tLeft) / (tRight - tLeft);\r\n const g1 = f[step] * fraction;\r\n const g0 = f[step] * (1.0 - fraction);\r\n f[step] = gCarry + g0;\r\n gCarry = g1;\r\n }\r\n f[depth + 1] = gCarry;\r\n }\r\n }\r\n\r\n /**\r\n * Evaluate basis functions f[], derivatives df[], and optional second derivatives ddf[] at knot value u.\r\n *\r\n * @param u knot value for evaluation\r\n * @param f array of order basis function values\r\n * @param df array of order basis derivative values\r\n * @param ddf array of order basis second derivative values\r\n */\r\n public evaluateBasisFunctions1(knotIndex0: number, u: number, f: Float64Array, df: Float64Array, ddf?: Float64Array) {\r\n f[0] = 1.0; df[0] = 0.0;\r\n if (this.degree < 1) return;\r\n // direct compute for linear part ...\r\n const u0 = this.knots[knotIndex0];\r\n const u1 = this.knots[knotIndex0 + 1];\r\n // ah = 1/(u1-u0) is the derivative of fraction0\r\n // (-ah) is the derivative of fraction1.\r\n let ah = 1.0 / (u1 - u0);\r\n f[1] = (u - u0) * ah;\r\n f[0] = 1.0 - f[1];\r\n df[0] = -ah; df[1] = ah;\r\n if (ddf) { // first derivative started constant, second derivative started zero.\r\n ddf[0] = 0.0; ddf[1] = 0.0;\r\n }\r\n if (this.degree < 2) return;\r\n for (let depth = 1; depth < this.degree; depth++) {\r\n let kLeft = knotIndex0 - depth;\r\n let kRight = kLeft + depth + 1;\r\n let gCarry = 0.0;\r\n let dgCarry = 0.0;\r\n let ddgCarry = 0.0;\r\n // f, df, ddf, are each row vectors with product of `step` linear terms.\r\n // f is multiplied on the right by matrix V. Each row has 2 nonzero entries (which sum to 1) (0,0,1-fraction, fraction,0,0,0)\r\n // Each row of the derivative dV is two entries (0,0, -1/h, 1/h,0,0,0)\r\n // Hence fnew = f * V\r\n // dfnew = df * V + f * dV\r\n // ddfnew = ddf * V + df*dV + df * dV + f * ddV\r\n // but ddV is zero so\r\n // ddfnew = ddf * V + 2 * df * dV\r\n for (let step = 0; step <= depth; step++) {\r\n const tLeft = this.knots[kLeft++];\r\n const tRight = this.knots[kRight++];\r\n ah = 1.0 / (tRight - tLeft);\r\n const fraction = (u - tLeft) * ah;\r\n const fraction1 = 1.0 - fraction;\r\n const g1 = f[step] * fraction;\r\n const g0 = f[step] * fraction1;\r\n const dg1 = df[step] * fraction + f[step] * ah;\r\n const dg0 = df[step] * fraction1 - f[step] * ah;\r\n const dfSave = 2.0 * df[step] * ah;\r\n f[step] = gCarry + g0;\r\n df[step] = dgCarry + dg0;\r\n gCarry = g1;\r\n dgCarry = dg1;\r\n if (ddf) { // do the backward reference to df before rewriting df !!!\r\n const ddg1 = ddf[step] * fraction + dfSave;\r\n const ddg0 = ddf[step] * fraction1 - dfSave;\r\n ddf[step] = ddgCarry + ddg0;\r\n ddgCarry = ddg1;\r\n }\r\n }\r\n f[depth + 1] = gCarry;\r\n df[depth + 1] = dgCarry;\r\n if (ddf)\r\n ddf[depth + 1] = ddgCarry;\r\n }\r\n }\r\n /** Find the knot span bracketing knots[i] <= u < knots[i+1] and return i.\r\n * * If u has no such bracket, return the smaller index of the closest nontrivial bracket.\r\n * @param u value to bracket\r\n */\r\n public knotToLeftKnotIndex(u: number): number {\r\n for (let i = this.leftKnotIndex; i < this.rightKnotIndex; ++i) {\r\n if (u < this.knots[i + 1])\r\n return i;\r\n }\r\n // for u >= rightKnot, return left index of last nontrivial span\r\n for (let i = this.rightKnotIndex; i > this.leftKnotIndex; --i) {\r\n if (this.knots[i] - this.knots[i - 1] >= KnotVector.knotTolerance)\r\n return i - 1;\r\n }\r\n return this.rightKnotIndex - 1; // shouldn't get here\r\n }\r\n /**\r\n * Given a span index, return the index of the knot at its left.\r\n * @param spanIndex index of span\r\n */\r\n public spanIndexToLeftKnotIndex(spanIndex: number): number {\r\n const d = this.degree;\r\n if (spanIndex <= 0.0) return d - 1;\r\n return Math.min(spanIndex + d - 1, this.knots.length - d - 1);\r\n }\r\n /** Return the knot interval length of indexed bezier span. */\r\n public spanIndexToSpanLength(spanIndex: number): number {\r\n const k = this.spanIndexToLeftKnotIndex(spanIndex);\r\n return this.knots[k + 1] - this.knots[k];\r\n }\r\n /**\r\n * Given a span index, test if it is within range and has nonzero length.\r\n * * note that a false return does not imply there are no more spans. This may be a double knot (zero length span) followed by more real spans\r\n * @param spanIndex index of span to test.\r\n */\r\n public isIndexOfRealSpan(spanIndex: number): boolean {\r\n if (spanIndex >= 0 && spanIndex < this.numSpans)\r\n return !Geometry.isSmallMetricDistance(this.spanIndexToSpanLength(spanIndex));\r\n return false;\r\n }\r\n /** Reflect all knots so `leftKnot` and `rightKnot` are maintained but interval lengths reverse. */\r\n public reflectKnots() {\r\n const a = this.leftKnot;\r\n const b = this.rightKnot;\r\n const numKnots = this.knots.length;\r\n for (let i = 0; i < numKnots; i++)\r\n this.knots[i] = a + (b - this.knots[i]);\r\n this.knots.reverse();\r\n }\r\n /**\r\n * return a simple array form of the knots. optionally replicate the first and last\r\n * in classic over-clamped manner\r\n */\r\n public copyKnots(includeExtraEndKnot: boolean): number[] {\r\n const wrap = this.wrappable === BSplineWrapMode.OpenByAddingControlPoints && this.testClosable();\r\n const leftIndex = this.leftKnotIndex;\r\n const rightIndex = this.rightKnotIndex;\r\n const a0 = this.leftKnot;\r\n const a1 = this.rightKnot;\r\n const delta = a1 - a0;\r\n const degree = this.degree;\r\n const values: number[] = [];\r\n if (includeExtraEndKnot) {\r\n if (wrap) {\r\n values.push(this.knots[rightIndex - degree] - delta);\r\n } else {\r\n values.push(this.knots[0]);\r\n }\r\n }\r\n for (const u of this.knots) values.push(u);\r\n if (includeExtraEndKnot) {\r\n if (wrap) {\r\n values.push(this.knots[leftIndex + degree] + delta);\r\n } else\r\n values.push(values[values.length - 1]);\r\n }\r\n return values;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"KnotVector.js","sourceRoot":"","sources":["../../../src/bspline/KnotVector.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,0CAAuC;AACvC,6DAAyD;AAEzD;;;;GAIG;AACH,IAAY,eAaX;AAbD,WAAY,eAAe;IACzB,+BAA+B;IAC/B,qDAAQ,CAAA;IACR;;;OAGG;IACH,+FAA6B,CAAA;IAC7B;;;OAGG;IACH,mFAAuB,CAAA;AACzB,CAAC,EAbW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAa1B;AACD;;;;;;;;;;;;GAYG;AACH,MAAa,UAAU;IAWrB,+FAA+F;IAC/F,IAAW,QAAQ,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7C,gGAAgG;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AAC;SAChB;QACD,IAAI,mBAAmB,EAAE;YACvB,IAAI,sBAAsB;gBACxB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;;gBAE/C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;SACxC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,uHAAuH;IAChH,SAAS,CAAC,mBAA4B;QAC3C,MAAM,QAAQ,GAAG,CAAC,mBAAmB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3F,OAAO,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;IACtF,CAAC;;AA/bD,0DAA0D;AACnC,wBAAa,GAAG,MAAM,CAAC;AAVnC,gCAAU","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Bspline\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { NumberArray } from \"../geometry3d/PointHelpers\";\r\n\r\n/**\r\n * B-spline curve and surface types in this library are non-periodic. But they can be created from legacy periodic data.\r\n * This enumeration lists the possible ways a B-spline object can have been created from legacy periodic data.\r\n * @public\r\n */\r\nexport enum BSplineWrapMode {\r\n /** No conversion performed. */\r\n None = 0,\r\n /** The B-spline was opened up by adding degree wrap-around control points to the legacy periodic data.\r\n * * This is typical of B-splines constructed with maximum (degree - 1) continuity.\r\n * * Knots are unaffected by this conversion.\r\n */\r\n OpenByAddingControlPoints = 1,\r\n /** The B-spline was opened up by removing degree extreme knots from the legacy periodic data.\r\n * * This is typical of rational B-spline curves representing full circles and ellipses.\r\n * * Poles are unaffected by this conversion.\r\n */\r\n OpenByRemovingKnots = 2,\r\n}\r\n/**\r\n * Array of non-decreasing numbers acting as a knot array for B-splines.\r\n *\r\n * * Essential identity: numKnots = numPoles + order - 2 = numPoles + degree - 1\r\n * * Various B-spline libraries have confusion over how many \"end knots\" are needed. Many libraries (including MicroStation and Parasolid)\r\n * demand order knots at each end for clamping. But only order-1 are really needed. This class uses the order-1 convention.\r\n * * A span is a single interval of the knots.\r\n * * The left knot of span {k} is knot {k+degree-1}.\r\n * * This class provides queries to convert among spanIndex, knotIndex, spanFraction, fraction of knot range, and knot.\r\n * * Core computations (evaluateBasisFunctions) have leftKnotIndex and global knot value as inputs. Callers need to\r\n * know their primary values (global knot, spanFraction).\r\n * @public\r\n */\r\nexport class KnotVector {\r\n /** The simple array of knot values. */\r\n public knots: Float64Array;\r\n /** Return the degree of basis functions defined in these knots. */\r\n public degree: number;\r\n private _knot0: number;\r\n private _knot1: number;\r\n\r\n private _wrapMode?: BSplineWrapMode;\r\n /** tolerance for considering two knots to be the same. */\r\n public static readonly knotTolerance = 1.0e-9;\r\n /** Return the leftmost knot value (of the active interval, ignoring unclamped leading knots)*/\r\n public get leftKnot() { return this._knot0; }\r\n /** Return the rightmost knot value (of the active interval, ignoring unclamped leading knots)*/\r\n public get rightKnot() { return this._knot1; }\r\n /** Return the index of the leftmost knot of the active interval */\r\n public get leftKnotIndex() { return this.degree - 1; }\r\n /** Return the index of the rightmost knot of the active interval */\r\n public get rightKnotIndex() { return this.knots.length - this.degree; }\r\n /** Whether this KnotVector was created by converting legacy periodic data during deserialization. The conversion used is specified by BSplineWrapMode, and is reversed at serialization time. */\r\n public get wrappable() { return this._wrapMode === undefined ? BSplineWrapMode.None : this._wrapMode; }\r\n public set wrappable(value: BSplineWrapMode) { this._wrapMode = value; }\r\n /** Return the number of bezier spans. Note that this includes zero-length spans if there are repeated knots. */\r\n public get numSpans() { return this.rightKnotIndex - this.leftKnotIndex; }\r\n /**\r\n *\r\n * * If knots is a number array or Float64Array, the those values become the local knot array.\r\n * * If knots is a simple number, the local knot array is allocated to that size but left as zeros.\r\n * @param knots\r\n * @param degree\r\n */\r\n private constructor(knots: number[] | Float64Array | number, degree: number, wrapMode?: BSplineWrapMode) {\r\n this.degree = degree;\r\n this._wrapMode = wrapMode;\r\n // default values to satisfy compiler -- real values happen in setupFixedValues, or final else defers to user\r\n this._knot0 = 0.0;\r\n this._knot1 = 1.0;\r\n // satisfy the initialize checker ..\r\n if (Array.isArray(knots)) { // remark: This ctor is private. The callers (as of April 2019) do not use this path.\r\n this.knots = new Float64Array(knots.length);\r\n this.setKnots(knots);\r\n this.setupFixedValues();\r\n } else if (knots instanceof Float64Array) {\r\n this.knots = knots.slice();\r\n this.setupFixedValues();\r\n } else { // caller is responsible for filling array separately ...\r\n this.knots = new Float64Array(knots);\r\n }\r\n }\r\n /** copy degree and knots to a new KnotVector. */\r\n public clone(): KnotVector { return new KnotVector(this.knots, this.degree, this.wrappable); }\r\n private setupFixedValues() {\r\n if (this.degree > 0 && this.knots.length > this.degree) {\r\n this._knot0 = this.knots[this.degree - 1];\r\n this._knot1 = this.knots[this.knots.length - this.degree];\r\n }\r\n }\r\n /** Return the total knot distance from beginning to end. */\r\n public get knotLength01(): number { return this._knot1 - this._knot0; }\r\n /**\r\n * Returns true if all numeric values have wraparound conditions that allow the knots to be closed with specified wrap mode.\r\n * @param mode optional test mode. If undefined, use this.wrappable.\r\n */\r\n public testClosable(mode?: BSplineWrapMode): boolean {\r\n if (mode === undefined)\r\n mode = this.wrappable;\r\n const degree = this.degree;\r\n const leftKnotIndex = this.leftKnotIndex;\r\n const rightKnotIndex = this.rightKnotIndex;\r\n if (mode === BSplineWrapMode.OpenByAddingControlPoints) {\r\n // maximum continuity mode: we expect degree periodically extended knots at each end\r\n const period = this.rightKnot - this.leftKnot;\r\n const indexDelta = rightKnotIndex - leftKnotIndex;\r\n for (let k0 = 0; k0 < leftKnotIndex + degree; k0++) {\r\n const k1 = k0 + indexDelta;\r\n if (Math.abs(this.knots[k0] + period - this.knots[k1]) >= KnotVector.knotTolerance)\r\n return false;\r\n }\r\n return true;\r\n }\r\n if (mode === BSplineWrapMode.OpenByRemovingKnots) {\r\n // legacy periodic mode: we expect multiplicity degree knots at each end\r\n const numRepeated = degree - 1;\r\n const leftKnot = this.leftKnot;\r\n const rightKnot = this.rightKnot;\r\n for (let i = 0; i < numRepeated; i++) {\r\n if (Math.abs(leftKnot - this.knots[leftKnotIndex - i - 1]) >= KnotVector.knotTolerance)\r\n return false;\r\n if (Math.abs(rightKnot - this.knots[rightKnotIndex + i + 1]) >= KnotVector.knotTolerance)\r\n return false;\r\n }\r\n return true;\r\n }\r\n return false;\r\n }\r\n /** Test matching degree and knot values */\r\n public isAlmostEqual(other: KnotVector): boolean {\r\n if (this.degree !== other.degree) return false;\r\n return NumberArray.isAlmostEqual(this.knots, other.knots, KnotVector.knotTolerance);\r\n }\r\n\r\n /** Compute the multiplicity of the input knot, or zero if not a knot. */\r\n public getKnotMultiplicity(knot: number): number {\r\n let m = 0;\r\n for (const k of this.knots) {\r\n if (Math.abs(k - knot) < KnotVector.knotTolerance)\r\n ++m;\r\n else if (knot < k)\r\n break;\r\n }\r\n return m;\r\n }\r\n\r\n /** Compute the multiplicity of the knot at the given index. */\r\n public getKnotMultiplicityAtIndex(knotIndex: number): number {\r\n let m = 0;\r\n if (knotIndex >= 0 && knotIndex < this.knots.length) {\r\n const knot = this.knots[knotIndex];\r\n ++m; // count this knot\r\n for (let i = knotIndex - 1; i >= 0; --i) {\r\n const k = this.knots[i];\r\n if (Math.abs(k - knot) < KnotVector.knotTolerance)\r\n ++m; // found multiple to left of knot\r\n else if (knot > k)\r\n break;\r\n }\r\n for (let i = knotIndex + 1; i < this.knots.length; ++i) {\r\n const k = this.knots[i];\r\n if (Math.abs(k - knot) < KnotVector.knotTolerance)\r\n ++m; // found multiple to right of knot\r\n else if (knot < k)\r\n break;\r\n }\r\n }\r\n return m;\r\n }\r\n\r\n /** Transform knots to span [0,1].\r\n * @returns false if and only if this.knotLength01 is trivial\r\n */\r\n public normalize(): boolean {\r\n if (this.knotLength01 < KnotVector.knotTolerance)\r\n return false;\r\n const divisor = 1.0 / this.knotLength01;\r\n const leftKnot = this.leftKnot;\r\n for (let i = 0; i < this.knots.length; ++i)\r\n this.knots[i] = (this.knots[i] - leftKnot) * divisor;\r\n // explicitly set rightKnot and its multiples to 1.0 to avoid round-off\r\n for (let i = this.rightKnotIndex - 1; i > this.leftKnotIndex && (this.knots[i] === this.knots[this.rightKnotIndex]); --i) this.knots[i] = 1.0;\r\n for (let i = this.rightKnotIndex + 1; i < this.knots.length && (this.knots[i] === this.knots[this.rightKnotIndex]); ++i) this.knots[i] = 1.0;\r\n this.knots[this.rightKnotIndex] = 1.0;\r\n this.setupFixedValues();\r\n return true;\r\n }\r\n\r\n /** install knot values from an array, optionally ignoring first and last.\r\n */\r\n public setKnots(knots: number[] | Float64Array, skipFirstAndLast?: boolean) {\r\n const numAllocate = skipFirstAndLast ? knots.length - 2 : knots.length;\r\n if (numAllocate !== this.knots.length)\r\n this.knots = new Float64Array(numAllocate);\r\n if (skipFirstAndLast) {\r\n for (let i = 1; i + 1 < knots.length; i++)\r\n this.knots[i - 1] = knots[i];\r\n\r\n } else {\r\n for (let i = 0; i < knots.length; i++)\r\n this.knots[i] = knots[i];\r\n }\r\n this.setupFixedValues();\r\n }\r\n\r\n /** Set knots to input array (CAPTURED) */\r\n public setKnotsCapture(knots: Float64Array) {\r\n this.knots = knots;\r\n this.setupFixedValues();\r\n }\r\n\r\n /**\r\n * Create knot vector with {degree-1} replicated knots at start and end, and uniform knots between.\r\n * @param numPoles Number of poles\r\n * @param degree degree of polynomial\r\n * @param a0 left knot value for active interval\r\n * @param a1 right knot value for active interval\r\n */\r\n public static createUniformClamped(numPoles: number, degree: number, a0: number, a1: number): KnotVector {\r\n const knots = new KnotVector(numPoles + degree - 1, degree);\r\n let k = 0;\r\n for (let m = 0; m < degree; m++)knots.knots[k++] = a0;\r\n const du = 1.0 / (numPoles - degree);\r\n for (let i = 1; i + degree < numPoles; i++)\r\n knots.knots[k++] = a0 + i * du * (a1 - a0);\r\n for (let m = 0; m < degree; m++)knots.knots[k++] = a1;\r\n knots.setupFixedValues();\r\n return knots;\r\n }\r\n /**\r\n * Create knot vector with wraparound knots at start and end, and uniform knots between.\r\n * @param numInterval number of intervals in knot space. (NOT POLE COUNT)\r\n * @param degree degree of polynomial\r\n * @param a0 left knot value for active interval\r\n * @param a1 right knot value for active interval\r\n */\r\n public static createUniformWrapped(numInterval: number, degree: number, a0: number, a1: number): KnotVector {\r\n const knots = new KnotVector(numInterval + 2 * degree - 1, degree);\r\n const du = 1.0 / numInterval;\r\n for (let i = 1 - degree, k = 0; i < numInterval + degree; i++, k++) {\r\n knots.knots[k] = Geometry.interpolate(a0, i * du, a1);\r\n }\r\n knots.setupFixedValues();\r\n return knots;\r\n }\r\n\r\n /**\r\n * Create knot vector with given knot values and degree.\r\n * @param knotArray knot values\r\n * @param degree degree of polynomial\r\n * @param skipFirstAndLast true to skip copying the first and last knot values.\r\n */\r\n public static create(knotArray: number[] | Float64Array, degree: number, skipFirstAndLast?: boolean): KnotVector {\r\n const numAllocate = skipFirstAndLast ? knotArray.length - 2 : knotArray.length;\r\n const knots = new KnotVector(numAllocate, degree);\r\n knots.setKnots(knotArray, skipFirstAndLast);\r\n return knots;\r\n }\r\n\r\n /**\r\n * Return the average of degree consecutive knots beginning at knotIndex.\r\n */\r\n public grevilleKnot(knotIndex: number): number {\r\n if (knotIndex < 0) return this.leftKnot;\r\n if (knotIndex > this.rightKnotIndex) return this.rightKnot;\r\n let sum = 0.0;\r\n for (let i = knotIndex; i < knotIndex + this.degree; i++)\r\n sum += this.knots[i];\r\n return sum / this.degree;\r\n }\r\n /** Return an array sized for a set of the basis function values. */\r\n public createBasisArray(): Float64Array { return new Float64Array(this.degree + 1); }\r\n /** Convert localFraction within the interval following an indexed knot to a knot value. */\r\n public baseKnotFractionToKnot(knotIndex0: number, localFraction: number): number {\r\n const knot0 = this.knots[knotIndex0];\r\n localFraction = Geometry.clamp(localFraction, 0, 1);\r\n return knot0 + localFraction * (this.knots[knotIndex0 + 1] - knot0);\r\n }\r\n /** Convert localFraction within an indexed bezier span to a knot value. */\r\n public spanFractionToKnot(spanIndex: number, localFraction: number): number {\r\n const k = this.spanIndexToLeftKnotIndex(spanIndex);\r\n localFraction = Geometry.clamp(localFraction, 0, 1);\r\n return this.knots[k] + localFraction * (this.knots[k + 1] - this.knots[k]);\r\n }\r\n /** Convert localFraction within an indexed bezier span to fraction of active knot range. */\r\n public spanFractionToFraction(spanIndex: number, localFraction: number): number {\r\n const knot = this.spanFractionToKnot(spanIndex, localFraction);\r\n return (knot - this.leftKnot) / (this.rightKnot - this.leftKnot);\r\n }\r\n /** Return fraction of active knot range to knot value. */\r\n public fractionToKnot(fraction: number): number {\r\n fraction = Geometry.clamp(fraction, 0, 1); // B-splines are not extendable\r\n return Geometry.interpolate(this.knots[this.degree - 1], fraction, this.knots[this.knots.length - this.degree]);\r\n }\r\n /**\r\n * Evaluate basis functions f[] at knot value u.\r\n *\r\n * @param u knot value for evaluation\r\n * @param f preallocated output array of order basis function values\r\n * @returns true if and only if output array is sufficiently sized\r\n */\r\n public evaluateBasisFunctions(knotIndex0: number, u: number, f: Float64Array): boolean {\r\n if (f.length < this.degree + 1)\r\n return false;\r\n f[0] = 1.0;\r\n if (this.degree < 1)\r\n return true;\r\n // direct compute for linear part ...\r\n const u0 = this.knots[knotIndex0];\r\n const u1 = this.knots[knotIndex0 + 1];\r\n f[1] = (u - u0) / (u1 - u0);\r\n f[0] = 1.0 - f[1];\r\n if (this.degree < 2)\r\n return true;\r\n for (let depth = 1; depth < this.degree; depth++) {\r\n let kLeft = knotIndex0 - depth;\r\n let kRight = kLeft + depth + 1;\r\n let gCarry = 0.0;\r\n for (let step = 0; step <= depth; step++) {\r\n const tLeft = this.knots[kLeft++];\r\n const tRight = this.knots[kRight++];\r\n const fraction = (u - tLeft) / (tRight - tLeft);\r\n const g1 = f[step] * fraction;\r\n const g0 = f[step] * (1.0 - fraction);\r\n f[step] = gCarry + g0;\r\n gCarry = g1;\r\n }\r\n f[depth + 1] = gCarry;\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Evaluate basis functions f[], derivatives df[], and optional second derivatives ddf[] at knot value u.\r\n *\r\n * @param u knot value for evaluation\r\n * @param f preallocated output array of order basis function values\r\n * @param df preallocated output array of order basis derivative values\r\n * @param ddf optional preallocated output array of order basis second derivative values\r\n * @returns true if and only if output arrays are sufficiently sized\r\n */\r\n public evaluateBasisFunctions1(knotIndex0: number, u: number, f: Float64Array, df: Float64Array, ddf?: Float64Array): boolean {\r\n if (f.length < this.degree + 1)\r\n return false;\r\n if (df.length < this.degree + 1)\r\n return false;\r\n if (ddf && ddf.length < this.degree + 1)\r\n return false;\r\n f[0] = 1.0; df[0] = 0.0;\r\n if (this.degree < 1)\r\n return true;\r\n // direct compute for linear part ...\r\n const u0 = this.knots[knotIndex0];\r\n const u1 = this.knots[knotIndex0 + 1];\r\n // ah = 1/(u1-u0) is the derivative of fraction0\r\n // (-ah) is the derivative of fraction1.\r\n let ah = 1.0 / (u1 - u0);\r\n f[1] = (u - u0) * ah;\r\n f[0] = 1.0 - f[1];\r\n df[0] = -ah; df[1] = ah;\r\n if (ddf) { // first derivative started constant, second derivative started zero.\r\n ddf[0] = 0.0; ddf[1] = 0.0;\r\n }\r\n if (this.degree < 2)\r\n return true;\r\n for (let depth = 1; depth < this.degree; depth++) {\r\n let kLeft = knotIndex0 - depth;\r\n let kRight = kLeft + depth + 1;\r\n let gCarry = 0.0;\r\n let dgCarry = 0.0;\r\n let ddgCarry = 0.0;\r\n // f, df, ddf, are each row vectors with product of `step` linear terms.\r\n // f is multiplied on the right by matrix V. Each row has 2 nonzero entries (which sum to 1) (0,0,1-fraction, fraction,0,0,0)\r\n // Each row of the derivative dV is two entries (0,0, -1/h, 1/h,0,0,0)\r\n // Hence fnew = f * V\r\n // dfnew = df * V + f * dV\r\n // ddfnew = ddf * V + df*dV + df * dV + f * ddV\r\n // but ddV is zero so\r\n // ddfnew = ddf * V + 2 * df * dV\r\n for (let step = 0; step <= depth; step++) {\r\n const tLeft = this.knots[kLeft++];\r\n const tRight = this.knots[kRight++];\r\n ah = 1.0 / (tRight - tLeft);\r\n const fraction = (u - tLeft) * ah;\r\n const fraction1 = 1.0 - fraction;\r\n const g1 = f[step] * fraction;\r\n const g0 = f[step] * fraction1;\r\n const dg1 = df[step] * fraction + f[step] * ah;\r\n const dg0 = df[step] * fraction1 - f[step] * ah;\r\n const dfSave = 2.0 * df[step] * ah;\r\n f[step] = gCarry + g0;\r\n df[step] = dgCarry + dg0;\r\n gCarry = g1;\r\n dgCarry = dg1;\r\n if (ddf) { // do the backward reference to df before rewriting df !!!\r\n const ddg1 = ddf[step] * fraction + dfSave;\r\n const ddg0 = ddf[step] * fraction1 - dfSave;\r\n ddf[step] = ddgCarry + ddg0;\r\n ddgCarry = ddg1;\r\n }\r\n }\r\n f[depth + 1] = gCarry;\r\n df[depth + 1] = dgCarry;\r\n if (ddf)\r\n ddf[depth + 1] = ddgCarry;\r\n }\r\n return true;\r\n }\r\n /** Find the knot span bracketing knots[i] <= u < knots[i+1] and return i.\r\n * * If u has no such bracket, return the smaller index of the closest nontrivial bracket.\r\n * @param u value to bracket\r\n */\r\n public knotToLeftKnotIndex(u: number): number {\r\n for (let i = this.leftKnotIndex; i < this.rightKnotIndex; ++i) {\r\n if (u < this.knots[i + 1])\r\n return i;\r\n }\r\n // for u >= rightKnot, return left index of last nontrivial span\r\n for (let i = this.rightKnotIndex; i > this.leftKnotIndex; --i) {\r\n if (this.knots[i] - this.knots[i - 1] >= KnotVector.knotTolerance)\r\n return i - 1;\r\n }\r\n return this.rightKnotIndex - 1; // shouldn't get here\r\n }\r\n /**\r\n * Given a span index, return the index of the knot at its left.\r\n * @param spanIndex index of span\r\n */\r\n public spanIndexToLeftKnotIndex(spanIndex: number): number {\r\n const d = this.degree;\r\n if (spanIndex <= 0.0) return d - 1;\r\n return Math.min(spanIndex + d - 1, this.knots.length - d - 1);\r\n }\r\n /** Return the knot interval length of indexed bezier span. */\r\n public spanIndexToSpanLength(spanIndex: number): number {\r\n const k = this.spanIndexToLeftKnotIndex(spanIndex);\r\n return this.knots[k + 1] - this.knots[k];\r\n }\r\n /**\r\n * Given a span index, test if it is within range and has nonzero length.\r\n * * note that a false return does not imply there are no more spans. This may be a double knot (zero length span) followed by more real spans\r\n * @param spanIndex index of span to test.\r\n */\r\n public isIndexOfRealSpan(spanIndex: number): boolean {\r\n if (spanIndex >= 0 && spanIndex < this.numSpans)\r\n return !Geometry.isSmallMetricDistance(this.spanIndexToSpanLength(spanIndex));\r\n return false;\r\n }\r\n /** Reflect all knots so `leftKnot` and `rightKnot` are maintained but interval lengths reverse. */\r\n public reflectKnots() {\r\n const a = this.leftKnot;\r\n const b = this.rightKnot;\r\n const numKnots = this.knots.length;\r\n for (let i = 0; i < numKnots; i++)\r\n this.knots[i] = a + (b - this.knots[i]);\r\n this.knots.reverse();\r\n }\r\n\r\n /** Return a simple array form of the knots. Optionally replicate the first and last in classic over-clamped manner. */\r\n public static copyKnots(knots: number[] | Float64Array, degree: number, includeExtraEndKnot?: boolean, wrapMode?: BSplineWrapMode): number[] {\r\n const isExtraEndKnotPeriodic = (includeExtraEndKnot && wrapMode === BSplineWrapMode.OpenByAddingControlPoints);\r\n const leftIndex = degree - 1;\r\n const rightIndex = knots.length - degree;\r\n const a0 = knots[leftIndex];\r\n const a1 = knots[rightIndex];\r\n const delta = a1 - a0;\r\n const values: number[] = [];\r\n if (includeExtraEndKnot) {\r\n if (isExtraEndKnotPeriodic)\r\n values.push(knots[rightIndex - degree] - delta);\r\n else\r\n values.push(knots[0]);\r\n }\r\n for (const u of knots) {\r\n values.push(u);\r\n }\r\n if (includeExtraEndKnot) {\r\n if (isExtraEndKnotPeriodic)\r\n values.push(knots[leftIndex + degree] + delta);\r\n else\r\n values.push(knots[knots.length - 1]);\r\n }\r\n return values;\r\n }\r\n\r\n /** Return a simple array form of the knots. Optionally replicate the first and last in classic over-clamped manner. */\r\n public copyKnots(includeExtraEndKnot: boolean): number[] {\r\n const wrapMode = (includeExtraEndKnot && this.testClosable()) ? this.wrappable : undefined;\r\n return KnotVector.copyKnots(this.knots, this.degree, includeExtraEndKnot, wrapMode);\r\n }\r\n}\r\n"]}
|