@itwin/core-geometry 3.0.0-dev.99 → 3.1.0-dev.1
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 +80 -1
- package/LICENSE.md +1 -1
- package/lib/cjs/Geometry.d.ts +6 -0
- package/lib/cjs/Geometry.d.ts.map +1 -1
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/bspline/BSplineCurve.d.ts +4 -0
- package/lib/cjs/bspline/BSplineCurve.d.ts.map +1 -1
- package/lib/cjs/bspline/BSplineCurve.js +39 -0
- package/lib/cjs/bspline/BSplineCurve.js.map +1 -1
- package/lib/cjs/bspline/BSplineCurveOps.d.ts +7 -0
- package/lib/cjs/bspline/BSplineCurveOps.d.ts.map +1 -1
- package/lib/cjs/bspline/BSplineCurveOps.js +21 -6
- package/lib/cjs/bspline/BSplineCurveOps.js.map +1 -1
- package/lib/cjs/bspline/BezierCurve3dH.d.ts.map +1 -1
- package/lib/cjs/bspline/BezierCurve3dH.js +7 -3
- package/lib/cjs/bspline/BezierCurve3dH.js.map +1 -1
- package/lib/cjs/bspline/InterpolationCurve3d.d.ts.map +1 -1
- package/lib/cjs/bspline/InterpolationCurve3d.js +12 -5
- package/lib/cjs/bspline/InterpolationCurve3d.js.map +1 -1
- package/lib/cjs/bspline/KnotVector.d.ts +2 -2
- package/lib/cjs/bspline/KnotVector.d.ts.map +1 -1
- package/lib/cjs/bspline/KnotVector.js +2 -2
- package/lib/cjs/bspline/KnotVector.js.map +1 -1
- package/lib/cjs/clipping/ClipPlane.d.ts +12 -0
- package/lib/cjs/clipping/ClipPlane.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipPlane.js +12 -0
- package/lib/cjs/clipping/ClipPlane.js.map +1 -1
- package/lib/cjs/clipping/ClipUtils.d.ts +5 -0
- package/lib/cjs/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipUtils.js +34 -0
- package/lib/cjs/clipping/ClipUtils.js.map +1 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts +1 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.js +4 -3
- package/lib/cjs/clipping/ConvexClipPlaneSet.js.map +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js +2 -3
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/cjs/curve/CurveFactory.d.ts +12 -0
- package/lib/cjs/curve/CurveFactory.d.ts.map +1 -1
- package/lib/cjs/curve/CurveFactory.js +25 -0
- package/lib/cjs/curve/CurveFactory.js.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.js +3 -0
- package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
- package/lib/cjs/curve/spiral/DirectSpiral3d.js +2 -2
- package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
- package/lib/cjs/curve/spiral/NormalizedTransition.d.ts +0 -1
- package/lib/cjs/curve/spiral/NormalizedTransition.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/NormalizedTransition.js +0 -1
- package/lib/cjs/curve/spiral/NormalizedTransition.js.map +1 -1
- package/lib/cjs/geometry3d/FrameBuilder.d.ts.map +1 -1
- package/lib/cjs/geometry3d/FrameBuilder.js +20 -1
- package/lib/cjs/geometry3d/FrameBuilder.js.map +1 -1
- package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.d.ts +12 -0
- package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.js +12 -0
- package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +1 -11
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +5 -25
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/Ray3d.d.ts +10 -0
- package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Ray3d.js +23 -0
- package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
- package/lib/cjs/geometry3d/Transform.d.ts +5 -0
- package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Transform.js +7 -0
- package/lib/cjs/geometry3d/Transform.js.map +1 -1
- package/lib/cjs/geometry4d/Point4d.d.ts +12 -0
- package/lib/cjs/geometry4d/Point4d.d.ts.map +1 -1
- package/lib/cjs/geometry4d/Point4d.js +12 -0
- package/lib/cjs/geometry4d/Point4d.js.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.d.ts +7 -0
- package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.js +27 -0
- package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
- package/lib/cjs/topology/HalfEdgeNodeXYZUV.d.ts +2 -0
- package/lib/cjs/topology/HalfEdgeNodeXYZUV.d.ts.map +1 -1
- package/lib/cjs/topology/HalfEdgeNodeXYZUV.js +4 -0
- package/lib/cjs/topology/HalfEdgeNodeXYZUV.js.map +1 -1
- package/lib/cjs/topology/HalfEdgePointInGraphSearch.js +1 -0
- package/lib/cjs/topology/HalfEdgePointInGraphSearch.js.map +1 -1
- package/lib/cjs/topology/HalfEdgePositionDetail.d.ts +17 -4
- package/lib/cjs/topology/HalfEdgePositionDetail.d.ts.map +1 -1
- package/lib/cjs/topology/HalfEdgePositionDetail.js +26 -5
- package/lib/cjs/topology/HalfEdgePositionDetail.js.map +1 -1
- package/lib/cjs/topology/InsertAndRetriangulateContext.d.ts.map +1 -1
- package/lib/cjs/topology/InsertAndRetriangulateContext.js +28 -2
- package/lib/cjs/topology/InsertAndRetriangulateContext.js.map +1 -1
- package/lib/esm/Geometry.d.ts +6 -0
- package/lib/esm/Geometry.d.ts.map +1 -1
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/bspline/BSplineCurve.d.ts +4 -0
- package/lib/esm/bspline/BSplineCurve.d.ts.map +1 -1
- package/lib/esm/bspline/BSplineCurve.js +39 -0
- package/lib/esm/bspline/BSplineCurve.js.map +1 -1
- package/lib/esm/bspline/BSplineCurveOps.d.ts +7 -0
- package/lib/esm/bspline/BSplineCurveOps.d.ts.map +1 -1
- package/lib/esm/bspline/BSplineCurveOps.js +21 -6
- package/lib/esm/bspline/BSplineCurveOps.js.map +1 -1
- package/lib/esm/bspline/BezierCurve3dH.d.ts.map +1 -1
- package/lib/esm/bspline/BezierCurve3dH.js +7 -3
- package/lib/esm/bspline/BezierCurve3dH.js.map +1 -1
- package/lib/esm/bspline/InterpolationCurve3d.d.ts.map +1 -1
- package/lib/esm/bspline/InterpolationCurve3d.js +12 -5
- package/lib/esm/bspline/InterpolationCurve3d.js.map +1 -1
- package/lib/esm/bspline/KnotVector.d.ts +2 -2
- package/lib/esm/bspline/KnotVector.d.ts.map +1 -1
- package/lib/esm/bspline/KnotVector.js +2 -2
- package/lib/esm/bspline/KnotVector.js.map +1 -1
- package/lib/esm/clipping/ClipPlane.d.ts +12 -0
- package/lib/esm/clipping/ClipPlane.d.ts.map +1 -1
- package/lib/esm/clipping/ClipPlane.js +12 -0
- package/lib/esm/clipping/ClipPlane.js.map +1 -1
- package/lib/esm/clipping/ClipUtils.d.ts +5 -0
- package/lib/esm/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/esm/clipping/ClipUtils.js +35 -1
- package/lib/esm/clipping/ClipUtils.js.map +1 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.d.ts +1 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.js +4 -3
- package/lib/esm/clipping/ConvexClipPlaneSet.js.map +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.js +2 -3
- package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/esm/curve/CurveFactory.d.ts +12 -0
- package/lib/esm/curve/CurveFactory.d.ts.map +1 -1
- package/lib/esm/curve/CurveFactory.js +25 -0
- package/lib/esm/curve/CurveFactory.js.map +1 -1
- package/lib/esm/curve/CurvePrimitive.js +3 -0
- package/lib/esm/curve/CurvePrimitive.js.map +1 -1
- package/lib/esm/curve/spiral/DirectSpiral3d.js +2 -2
- package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
- package/lib/esm/curve/spiral/NormalizedTransition.d.ts +0 -1
- package/lib/esm/curve/spiral/NormalizedTransition.d.ts.map +1 -1
- package/lib/esm/curve/spiral/NormalizedTransition.js +0 -1
- package/lib/esm/curve/spiral/NormalizedTransition.js.map +1 -1
- package/lib/esm/geometry3d/FrameBuilder.d.ts.map +1 -1
- package/lib/esm/geometry3d/FrameBuilder.js +20 -1
- package/lib/esm/geometry3d/FrameBuilder.js.map +1 -1
- package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.d.ts +12 -0
- package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.d.ts.map +1 -1
- package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.js +12 -0
- package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +1 -11
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +5 -25
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/Ray3d.d.ts +10 -0
- package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Ray3d.js +23 -0
- package/lib/esm/geometry3d/Ray3d.js.map +1 -1
- package/lib/esm/geometry3d/Transform.d.ts +5 -0
- package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
- package/lib/esm/geometry3d/Transform.js +7 -0
- package/lib/esm/geometry3d/Transform.js.map +1 -1
- package/lib/esm/geometry4d/Point4d.d.ts +12 -0
- package/lib/esm/geometry4d/Point4d.d.ts.map +1 -1
- package/lib/esm/geometry4d/Point4d.js +12 -0
- package/lib/esm/geometry4d/Point4d.js.map +1 -1
- package/lib/esm/serialization/GeometrySamples.d.ts +7 -0
- package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/esm/serialization/GeometrySamples.js +27 -0
- package/lib/esm/serialization/GeometrySamples.js.map +1 -1
- package/lib/esm/topology/HalfEdgeNodeXYZUV.d.ts +2 -0
- package/lib/esm/topology/HalfEdgeNodeXYZUV.d.ts.map +1 -1
- package/lib/esm/topology/HalfEdgeNodeXYZUV.js +4 -0
- package/lib/esm/topology/HalfEdgeNodeXYZUV.js.map +1 -1
- package/lib/esm/topology/HalfEdgePointInGraphSearch.js +1 -0
- package/lib/esm/topology/HalfEdgePointInGraphSearch.js.map +1 -1
- package/lib/esm/topology/HalfEdgePositionDetail.d.ts +17 -4
- package/lib/esm/topology/HalfEdgePositionDetail.d.ts.map +1 -1
- package/lib/esm/topology/HalfEdgePositionDetail.js +26 -5
- package/lib/esm/topology/HalfEdgePositionDetail.js.map +1 -1
- package/lib/esm/topology/InsertAndRetriangulateContext.d.ts.map +1 -1
- package/lib/esm/topology/InsertAndRetriangulateContext.js +28 -2
- package/lib/esm/topology/InsertAndRetriangulateContext.js.map +1 -1
- package/package.json +8 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClipPlane.js","sourceRoot":"","sources":["../../../src/clipping/ClipPlane.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAQ/F,0CAA0E;AAG1E,6EAA0E;AAC1E,qEAAk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,CACtB,GAAqB,EACrB,eAAmC,EACnC,gBAAoC,EACpC,UAAiC;QACjC,MAAM,kBAAkB,GAAG,eAAO,CAAC,UAAU,EAAE,CAAC;QAChD,MAAM,SAAS,GAAG,UAAU,CAAC,aAAa,EAAE,CAAC;QAC7C,MAAM,UAAU,GAAG,UAAU,CAAC,aAAa,EAAE,CAAC;QAC9C,2CAA8B,CAAC,oCAAoC,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,kBAAkB,CAAC,CAAC;QAC1H,yBAAa,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;QACvE,yBAAa,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC,EAAE,gBAAgB,EAAE,UAAU,CAAC,CAAC;IAC3E,CAAC;;AAxfH,8BAyfC;AA3LgB,+BAAqB,GAAG,IAAI,2CAAoB,EAAE,CAAC","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\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { Arc3d } from \"../curve/Arc3d\";\r\nimport { AnnounceNumberNumberCurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { AxisOrder, Geometry, PlaneAltitudeEvaluator } from \"../Geometry\";\r\nimport { Angle } from \"../geometry3d/Angle\";\r\nimport { XYZProps } from \"../geometry3d/XYZProps\";\r\nimport { GrowableFloat64Array } from \"../geometry3d/GrowableFloat64Array\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { Matrix3d } from \"../geometry3d/Matrix3d\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { IndexedXYZCollectionPolygonOps } from \"../geometry3d/PolygonOps\";\r\nimport { Range1d, Range3d } from \"../geometry3d/Range\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { Matrix4d } from \"../geometry4d/Matrix4d\";\r\nimport { Point4d } from \"../geometry4d/Point4d\";\r\nimport { AnalyticRoots } from \"../numerics/Polynomials\";\r\nimport { Clipper, ClipUtilities, PolygonClipper } from \"./ClipUtils\";\r\nimport { GrowableXYZArrayCache } from \"../geometry3d/ReusableObjectCache\";\r\n\r\n/** Wire format describing a [[ClipPlane]].\r\n * If either [[normal]] or [[dist]] are omitted, defaults to a normal of [[Vector3d.unitZ]] and a distance of zero.\r\n * @public\r\n */\r\nexport interface ClipPlaneProps {\r\n /** The plane's inward normal. */\r\n normal?: XYZProps;\r\n /** The plane's distance from the origin. */\r\n dist?: number;\r\n /** Defaults to `false`. */\r\n invisible?: boolean;\r\n /** Defaults to `false`. */\r\n interior?: boolean;\r\n}\r\n\r\n/** A ClipPlane is a single plane represented as\r\n * * An inward unit normal (u,v,w)\r\n * * A signedDistance\r\n *\r\n * Hence\r\n * * The halfspace function evaluation for \"point\" [x,y,z,] is: ([x,y,z] DOT (u,v,w)l - signedDistance)\r\n * * POSITIVE values of the halfspace function are \"inside\"\r\n * * ZERO value of the halfspace function is \"on\"\r\n * * NEGATIVE value of the halfspace function is \"outside\"\r\n * * A representative point on the plane is (signedDistance*u, signedDistance * v, signedDistance *w)\r\n * * Given a point and inward normal, the signedDistance is (point DOT normal)\r\n * @public\r\n */\r\nexport class ClipPlane implements Clipper, PlaneAltitudeEvaluator, PolygonClipper {\r\n private _inwardNormal: Vector3d;\r\n /** Construct a parallel plane through the origin.\r\n * * Move it to the actual position.\r\n * * _distanceFromOrigin is the distance it moved, with the (inward) normal direction as positive\r\n */\r\n private _distanceFromOrigin: number;\r\n private _invisible: boolean;\r\n private _interior: boolean;\r\n\r\n private constructor(normal: Vector3d, distance: number, invisible: boolean, interior: boolean) {\r\n this._invisible = invisible;\r\n this._interior = interior;\r\n this._inwardNormal = normal;\r\n this._distanceFromOrigin = distance;\r\n }\r\n /*\r\n private safeSetXYZDistance(nx: number, ny: number, nz: number, d: number) {\r\n this._inwardNormal.set(nx, ny, nz);\r\n this._distanceFromOrigin = d;\r\n }\r\n */\r\n /**\r\n * Return true if all members are almostEqual to corresponding members of other.\r\n * @param other clip plane to compare\r\n */\r\n public isAlmostEqual(other: ClipPlane): boolean {\r\n return Geometry.isSameCoordinate(this._distanceFromOrigin, other._distanceFromOrigin)\r\n && this._inwardNormal.isAlmostEqual(other._inwardNormal)\r\n && this._interior === other._interior\r\n && this._invisible === other._invisible;\r\n }\r\n /** return a cloned plane */\r\n public clone(): ClipPlane {\r\n const result = new ClipPlane(this._inwardNormal.clone(), this._distanceFromOrigin, this._invisible, this._interior);\r\n return result;\r\n }\r\n /** return Return a cloned plane with coordinate data negated. */\r\n public cloneNegated(): ClipPlane {\r\n const plane = new ClipPlane(this._inwardNormal.clone(), this._distanceFromOrigin, this._invisible, this._interior);\r\n plane.negateInPlace();\r\n return plane;\r\n }\r\n /** Create a ClipPlane from Plane3dByOriginAndUnitNormal. */\r\n public static createPlane(plane: Plane3dByOriginAndUnitNormal, invisible: boolean = false, interior: boolean = false, result?: ClipPlane): ClipPlane {\r\n const distance = plane.getNormalRef().dotProduct(plane.getOriginRef());\r\n if (result) {\r\n result._invisible = invisible;\r\n result._interior = interior;\r\n result._inwardNormal = plane.getNormalRef().clone();\r\n result._distanceFromOrigin = distance;\r\n return result;\r\n }\r\n return new ClipPlane(plane.getNormalRef().clone(), distance, invisible, interior);\r\n }\r\n /**\r\n * * Create a ClipPlane with direct normal and signedDistance.\r\n * * The vector is normalized for storage.\r\n */\r\n public static createNormalAndDistance(normal: Vector3d, distance: number, invisible: boolean = false, interior: boolean = false, result?: ClipPlane): ClipPlane | undefined {\r\n const normalized = normal.normalize();\r\n if (normalized) {\r\n if (result) {\r\n result._invisible = invisible;\r\n result._interior = interior;\r\n result._inwardNormal = normalized;\r\n result._distanceFromOrigin = distance;\r\n }\r\n return new ClipPlane(normalized, distance, invisible, interior);\r\n }\r\n return undefined;\r\n }\r\n /** Create a ClipPlane\r\n * * \"normal\" is the inward normal of the plane. (It is internally normalized)\r\n * * \"point\" is any point of the plane.\r\n * * The stored distance for the plane is the dot product of the point with the normal (i.e. treat the point's xyz as a vector from the origin.)\r\n */\r\n public static createNormalAndPoint(normal: Vector3d, point: Point3d, invisible: boolean = false, interior: boolean = false, result?: ClipPlane): ClipPlane | undefined {\r\n const normalized = normal.normalize();\r\n if (normalized) {\r\n const distance = normalized.dotProduct(point);\r\n if (result) {\r\n result._invisible = invisible;\r\n result._interior = interior;\r\n result._inwardNormal = normalized;\r\n result._distanceFromOrigin = distance;\r\n }\r\n return new ClipPlane(normalized, distance, invisible, interior);\r\n }\r\n return undefined;\r\n }\r\n\r\n /** Create a ClipPlane\r\n * * \"normal\" (normalX, normalY, nz) is the inward normal of the plane.\r\n * * The given (normalX,normalY,normalZ)\r\n * * \"point\" is any point of the plane.\r\n * * The stored distance for the plane is the dot product of the point with the normal (i.e. treat the point's xyz as a vector from the origin.)\r\n */\r\n public static createNormalAndPointXYZXYZ(normalX: number, normalY: number, normalZ: number,\r\n originX: number, originY: number, originZ: number,\r\n invisible: boolean = false, interior: boolean = false, result?: ClipPlane): ClipPlane | undefined {\r\n const q = Geometry.hypotenuseXYZ(normalX, normalY, normalZ);\r\n const r = Geometry.conditionalDivideFraction(1, q);\r\n if (r !== undefined) {\r\n if (result) {\r\n result._inwardNormal.set(normalX * r, normalY * r, normalZ * r);\r\n result._distanceFromOrigin = result._inwardNormal.dotProductXYZ(originX, originY, originZ);\r\n result._invisible = invisible;\r\n result._interior = interior;\r\n return result;\r\n }\r\n const normal = Vector3d.create(normalX * r, normalY * r, normalZ * r);\r\n return new ClipPlane(normal, normal.dotProductXYZ(originX, originY, originZ), invisible, interior);\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * return a json object of the form\r\n * `{\"normal\":[u,v,w],\"dist\":signedDistanceValue,\"interior\":true,\"invisible\":true}`\r\n */\r\n public toJSON(): ClipPlaneProps {\r\n const props: ClipPlaneProps = {\r\n normal: this.inwardNormalRef.toJSON(),\r\n dist: this.distance,\r\n };\r\n\r\n if (this.interior)\r\n props.interior = true;\r\n\r\n if (this.invisible)\r\n props.invisible = true;\r\n\r\n return props;\r\n }\r\n\r\n /** parse json object to ClipPlane instance */\r\n public static fromJSON(json: ClipPlaneProps, result?: ClipPlane): ClipPlane | undefined {\r\n if (json && json.normal && undefined !== json.dist && Number.isFinite(json.dist))\r\n return ClipPlane.createNormalAndDistance(Vector3d.fromJSON(json.normal), json.dist, !!json.invisible, !!json.interior);\r\n\r\n return ClipPlane.createNormalAndDistance(Vector3d.unitZ(), 0, false, false, result);\r\n }\r\n\r\n /** Set both the invisible and interior flags. */\r\n public setFlags(invisible: boolean, interior: boolean) {\r\n this._invisible = invisible;\r\n this._interior = interior;\r\n }\r\n\r\n /**\r\n * Return the stored distanceFromOrigin property.\r\n */\r\n public get distance() { return this._distanceFromOrigin; }\r\n /**\r\n * Return the stored inward normal property.\r\n */\r\n public get inwardNormalRef(): Vector3d { return this._inwardNormal; }\r\n /**\r\n * Return the \"interior\" property bit\r\n */\r\n public get interior() { return this._interior; }\r\n /**\r\n * Return the \"invisible\" property bit.\r\n */\r\n public get invisible() { return this._invisible; }\r\n\r\n /**\r\n * Create a plane defined by two points, an up vector, and a tilt angle relative to the up vector.\r\n * @param point0 start point of the edge\r\n * @param point1 end point of the edge\r\n * @param upVector vector perpendicular to the plane\r\n * @param tiltAngle angle to tilt the plane around the edge in the direction of the up vector.\r\n * @param result optional preallocated plane\r\n */\r\n public static createEdgeAndUpVector(point0: Point3d, point1: Point3d, upVector: Vector3d, tiltAngle?: Angle, result?: ClipPlane): ClipPlane | undefined {\r\n const edgeVector = Vector3d.createFrom(point1.minus(point0));\r\n let normal = (upVector.crossProduct(edgeVector)).normalize();\r\n\r\n if (normal) {\r\n if (tiltAngle !== undefined && !tiltAngle.isAlmostZero) {\r\n const tiltNormal = Vector3d.createRotateVectorAroundVector(normal, edgeVector, tiltAngle);\r\n if (tiltNormal) {\r\n normal = tiltNormal.clone();\r\n }\r\n }\r\n normal.negate(normal);\r\n return ClipPlane.createNormalAndPoint(normal, point0, false, false, result);\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Create a plane perpendicular to the edge between the xy parts of point0 and point1\r\n */\r\n public static createEdgeXY(point0: Point3d, point1: Point3d, result?: ClipPlane): ClipPlane | undefined {\r\n const normal = Vector3d.create(point0.y - point1.y, point1.x - point0.x);\r\n if (normal.normalizeInPlace())\r\n return ClipPlane.createNormalAndPoint(normal, point0, false, false, result);\r\n return undefined;\r\n }\r\n /**\r\n * Return the Plane3d form of the plane.\r\n * * The plane origin is the point `distance * inwardNormal`\r\n * * The plane normal is the inward normal of the ClipPlane.\r\n */\r\n public getPlane3d(): Plane3dByOriginAndUnitNormal {\r\n const d = this._distanceFromOrigin;\r\n // Normal should be normalized, will not return undefined\r\n return Plane3dByOriginAndUnitNormal.create(Point3d.create(this._inwardNormal.x * d, this._inwardNormal.y * d, this._inwardNormal.z * d), this._inwardNormal)!;\r\n }\r\n\r\n /**\r\n * Return the Point4d d form of the plane.\r\n * * The homogeneous xyz are the inward normal xyz.\r\n * * The homogeneous weight is the negated ClipPlane distance.\r\n */\r\n public getPlane4d(): Point4d {\r\n return Point4d.create(this._inwardNormal.x, this._inwardNormal.y, this._inwardNormal.z, - this._distanceFromOrigin);\r\n }\r\n /**\r\n * Set the plane from DPoint4d style plane.\r\n * * The saved plane has its direction normalized.\r\n * * This preserves the plane itself as a zero set but make plane evaluations act as true distances (even if the plane coefficients are scaled otherwise)\r\n * @param plane\r\n */\r\n public setPlane4d(plane: Point4d) {\r\n const a = Math.sqrt(plane.x * plane.x + plane.y * plane.y + plane.z * plane.z);\r\n const r = a === 0.0 ? 1.0 : 1.0 / a;\r\n this._inwardNormal.x = r * plane.x;\r\n this._inwardNormal.y = r * plane.y;\r\n this._inwardNormal.z = r * plane.z;\r\n this._distanceFromOrigin = -r * plane.w;\r\n }\r\n\r\n /**\r\n * Evaluate the altitude in weighted space, i.e. (dot product with inward normal) minus distance, with point.w scale applied to distance)\r\n * @param point space point to test\r\n */\r\n public weightedAltitude(point: Point4d): number {\r\n return point.x * this._inwardNormal.x + point.y * this._inwardNormal.y + point.z * this._inwardNormal.z - point.w * this._distanceFromOrigin;\r\n }\r\n\r\n /**\r\n * Evaluate the distance from the plane to a point in space, i.e. (dot product with inward normal) minus distance\r\n * @param point space point to test\r\n */\r\n public altitude(point: Point3d): number {\r\n return point.x * this._inwardNormal.x + point.y * this._inwardNormal.y + point.z * this._inwardNormal.z - this._distanceFromOrigin;\r\n }\r\n\r\n /**\r\n * Evaluate the distance from the plane to a point in space with point given as x,y,z, i.e. (dot product with inward normal) minus distance\r\n * @param point space point to test\r\n */\r\n public altitudeXYZ(x: number, y: number, z: number): number {\r\n return x * this._inwardNormal.x + y * this._inwardNormal.y + z * this._inwardNormal.z - this._distanceFromOrigin;\r\n }\r\n\r\n /** Return the dot product of the plane normal with the vector (NOT using the plane's distanceFromOrigin).\r\n */\r\n public velocity(vector: Vector3d): number {\r\n return vector.x * this._inwardNormal.x + vector.y * this._inwardNormal.y + vector.z * this._inwardNormal.z;\r\n }\r\n\r\n /** Return the dot product of the plane normal with the x,yz, vector components (NOT using the plane's distanceFromOrigin).\r\n */\r\n public velocityXYZ(x: number, y: number, z: number): number {\r\n return x * this._inwardNormal.x + y * this._inwardNormal.y + z * this._inwardNormal.z;\r\n }\r\n\r\n /** Return the dot product of the plane normal with the point (treating the point xyz as a vector, and NOT using the plane's distanceFromOrigin).\r\n */\r\n public dotProductPlaneNormalPoint(point: Point3d): number {\r\n return point.x * this._inwardNormal.x + point.y * this._inwardNormal.y + point.z * this._inwardNormal.z;\r\n }\r\n /**\r\n * Return true if spacePoint is inside or on the plane, with tolerance applied to \"on\".\r\n * @param spacePoint point to test.\r\n * @param tolerance tolerance for considering \"near plane\" to be \"on plane\"\r\n */\r\n public isPointOnOrInside(spacePoint: Point3d, tolerance: number = Geometry.smallMetricDistance): boolean {\r\n let value = this.altitude(spacePoint);\r\n if (tolerance) { value += tolerance; }\r\n return value >= 0.0;\r\n }\r\n\r\n /**\r\n * Return true if spacePoint is strictly inside the halfspace, with tolerance applied to \"on\".\r\n * @param spacePoint point to test.\r\n * @param tolerance tolerance for considering \"near plane\" to be \"on plane\"\r\n */\r\n public isPointInside(point: Point3d, tolerance: number = Geometry.smallMetricDistance): boolean {\r\n let value = this.altitude(point);\r\n if (tolerance) { value -= tolerance; }\r\n return value > 0.0;\r\n }\r\n\r\n /**\r\n * Return true if spacePoint is strictly on the plane, within tolerance\r\n * @param spacePoint point to test.\r\n * @param tolerance tolerance for considering \"near plane\" to be \"on plane\"\r\n */\r\n public isPointOn(point: Point3d, tolerance: number = Geometry.smallMetricDistance): boolean {\r\n return Math.abs(this.altitude(point)) <= tolerance;\r\n }\r\n /**\r\n * Compute intersections of an (UNBOUNDED) arc with the plane. Append them (as radians) to a growing array.\r\n * @param arc arc to test. The angle limits of the arc are NOT considered.\r\n * @param intersectionRadians array to receive results\r\n */\r\n public appendIntersectionRadians(arc: Arc3d, intersectionRadians: GrowableFloat64Array) {\r\n const arcVectors = arc.toVectors();\r\n const alpha = this.altitude(arc.center);\r\n const beta = this.velocity(arcVectors.vector0);\r\n const gamma = this.velocity(arcVectors.vector90);\r\n AnalyticRoots.appendImplicitLineUnitCircleIntersections(alpha, beta, gamma, undefined, undefined, intersectionRadians);\r\n }\r\n\r\n private static _clipArcFractionArray = new GrowableFloat64Array();\r\n /** Announce fractional intervals of arc clip.\r\n * * Each call to `announce(fraction0, fraction1, arc)` announces one interval that is inside the clip plane.\r\n */\r\n public announceClippedArcIntervals(arc: Arc3d, announce?: AnnounceNumberNumberCurvePrimitive): boolean {\r\n const breaks = ClipPlane._clipArcFractionArray;\r\n breaks.clear();\r\n this.appendIntersectionRadians(arc, breaks);\r\n arc.sweep.radiansArrayToPositivePeriodicFractions(breaks);\r\n return ClipUtilities.selectIntervals01(arc, breaks, this, announce);\r\n }\r\n /**\r\n * * Compute intersection of (unbounded) segment with the plane.\r\n * * If the ends are on the same side of the plane, return undefined.\r\n * * If the intersection is an endpoint or interior to the segment return the fraction.\r\n * * If both ends are on, return undefined.\r\n */\r\n public getBoundedSegmentSimpleIntersection(pointA: Point3d, pointB: Point3d): number | undefined {\r\n const h0 = this.altitude(pointA);\r\n const h1 = this.altitude(pointB);\r\n if (h0 * h1 > 0.0)\r\n return undefined;\r\n if (h0 === 0.0 && h1 === 0.0) {\r\n return undefined;\r\n }\r\n return - h0 / (h1 - h0);\r\n }\r\n\r\n /** Apply transform to the origin. Apply inverse transpose of the matrix part to th normal vector. */\r\n public transformInPlace(transform: Transform): boolean {\r\n const plane: Plane3dByOriginAndUnitNormal = this.getPlane3d();\r\n const matrix: Matrix3d = transform.matrix;\r\n const newPoint = transform.multiplyPoint3d(plane.getOriginRef());\r\n // Normal transforms as the inverse transpose of the matrix part\r\n // BTW: If the matrix is orthogonal, this is a long way to multiply by the matrix part (mumble grumble)\r\n const newNormal = matrix.multiplyInverseTranspose(plane.getNormalRef());\r\n if (!newNormal)\r\n return false;\r\n\r\n plane.set(newPoint, newNormal);\r\n const normalized = (plane.getNormalRef()).normalize();\r\n if (!normalized)\r\n return false;\r\n this._inwardNormal = normalized;\r\n this._distanceFromOrigin = this._inwardNormal.dotProduct(plane.getOriginRef());\r\n return true;\r\n }\r\n /** Set the invisible flag. Interpretation of this is up to the use code algorithms. */\r\n public setInvisible(invisible: boolean) {\r\n this._invisible = invisible;\r\n }\r\n\r\n /** reverse the sign of all coefficients, so outside and inside reverse */\r\n public negateInPlace() {\r\n this._inwardNormal = this._inwardNormal.negate();\r\n this._distanceFromOrigin = - this._distanceFromOrigin;\r\n }\r\n /**\r\n * Move the plane INWARD by given distance\r\n * @param offset distance of shift inwards\r\n */\r\n public offsetDistance(offset: number) {\r\n this._distanceFromOrigin += offset;\r\n }\r\n\r\n /**\r\n * Clip a polygon to the inside or outside of the plane.\r\n * * Results with 2 or fewer points are ignored.\r\n * * Other than ensuring capacity in the arrays, there are no object allocations during execution of this function.\r\n * @param xyz input points.\r\n * @param work work buffer\r\n * @param tolerance tolerance for \"on plane\" decision.\r\n */\r\n public clipConvexPolygonInPlace(xyz: GrowableXYZArray, work: GrowableXYZArray, inside: boolean = true, tolerance: number = Geometry.smallMetricDistance) {\r\n return IndexedXYZCollectionPolygonOps.clipConvexPolygonInPlace(this, xyz, work, inside, tolerance);\r\n }\r\n\r\n /**\r\n * Multiply the ClipPlane's DPoint4d by matrix.\r\n * @param matrix matrix to apply.\r\n * @param invert if true, use in verse of the matrix.\r\n * @param transpose if true, use the transpose of the matrix (or inverse, per invert parameter)\r\n * * Note that if matrixA is applied to all of space, the matrix to send to this method to get a corresponding effect on the plane is the inverse transpose of matrixA\r\n * * Callers that will apply the same matrix to many planes should pre-invert the matrix for efficiency.\r\n * * Both params default to true to get the full effect of transforming space.\r\n * @param matrix matrix to apply\r\n * @return false if unable to invert\r\n */\r\n public multiplyPlaneByMatrix4d(matrix: Matrix4d, invert: boolean = true, transpose: boolean = true): boolean {\r\n const plane: Point4d = this.getPlane4d();\r\n if (invert) {\r\n const inverse = matrix.createInverse();\r\n if (inverse)\r\n return this.multiplyPlaneByMatrix4d(inverse, false, transpose);\r\n return false;\r\n }\r\n if (transpose)\r\n matrix.multiplyTransposePoint4d(plane, plane);\r\n else\r\n matrix.multiplyPoint4d(plane, plane);\r\n this.setPlane4d(plane);\r\n return true;\r\n }\r\n\r\n /** announce the interval (if any) where a line is within the clip plane half space. */\r\n public announceClippedSegmentIntervals(f0: number, f1: number, pointA: Point3d, pointB: Point3d, announce?: (fraction0: number, fraction1: number) => void): boolean {\r\n if (f1 < f0)\r\n return false;\r\n const h0 = - this.altitude(pointA);\r\n const h1 = - this.altitude(pointB);\r\n const delta = h1 - h0;\r\n const f = Geometry.conditionalDivideFraction(-h0, delta);\r\n if (f === undefined) { // The segment is parallel to the plane.\r\n if (h0 <= 0.0) { if (announce) announce(f0, f1); return true; }\r\n return false;\r\n }\r\n if (delta > 0) { // segment aims OUT\r\n if (f < f1) f1 = f;\r\n } else {\r\n // segment aims IN\r\n if (f > f0)\r\n f0 = f;\r\n }\r\n if (f1 < f0)\r\n return false;\r\n if (announce) announce(f0, f1);\r\n return true;\r\n }\r\n /**\r\n * Return a coordinate frame with\r\n * * origin at closest point to global origin\r\n * * z axis points in\r\n * x and y are \"in plane\"\r\n */\r\n public getFrame(): Transform {\r\n const d = this._distanceFromOrigin;\r\n const origin = Point3d.create(this._inwardNormal.x * d, this._inwardNormal.y * d, this._inwardNormal.z * d);\r\n const matrix = Matrix3d.createRigidHeadsUp(this._inwardNormal, AxisOrder.ZXY);\r\n return Transform.createOriginAndMatrix(origin, matrix);\r\n }\r\n /**\r\n * Return the intersection of the plane with a range cube.\r\n * @param range\r\n * @param xyzOut intersection polygon. This is convex.\r\n */\r\n public intersectRange(range: Range3d, addClosurePoint: boolean = false): GrowableXYZArray | undefined {\r\n if (range.isNull)\r\n return undefined;\r\n const corners = range.corners();\r\n const frameOnPlane = this.getFrame();\r\n frameOnPlane.multiplyInversePoint3dArrayInPlace(corners);\r\n const localRange = Range3d.createArray(corners);\r\n if (localRange.low.z * localRange.high.z > 0.0)\r\n return undefined;\r\n // oversized polygon on local z= 0\r\n const xyzOut = new GrowableXYZArray();\r\n xyzOut.pushXYZ(localRange.low.x, localRange.low.y, 0);\r\n xyzOut.pushXYZ(localRange.high.x, localRange.low.y, 0);\r\n xyzOut.pushXYZ(localRange.high.x, localRange.high.y, 0);\r\n xyzOut.pushXYZ(localRange.low.x, localRange.high.y, 0);\r\n xyzOut.multiplyTransformInPlace(frameOnPlane);\r\n IndexedXYZCollectionPolygonOps.intersectRangeConvexPolygonInPlace(range, xyzOut);\r\n if (xyzOut.length === 0)\r\n return undefined;\r\n if (addClosurePoint)\r\n xyzOut.pushWrap(1);\r\n return xyzOut;\r\n }\r\n /** Implement appendPolygonClip, as defined in interface PolygonClipper. /**\r\n *\r\n * @param xyz input polygon. This is not changed.\r\n * @param insideFragments Array to receive \"inside\" fragments. Each fragment is a GrowableXYZArray grabbed from the cache. This is NOT cleared.\r\n * @param outsideFragments Array to receive \"outside\" fragments. Each fragment is a GrowableXYZArray grabbed from the cache. This is NOT cleared.\r\n * @param arrayCache cache for reusable GrowableXYZArray.\r\n */\r\n public appendPolygonClip(\r\n xyz: GrowableXYZArray,\r\n insideFragments: GrowableXYZArray[],\r\n outsideFragments: GrowableXYZArray[],\r\n arrayCache: GrowableXYZArrayCache): void {\r\n const perpendicularRange = Range1d.createNull();\r\n const newInside = arrayCache.grabFromCache();\r\n const newOutside = arrayCache.grabFromCache();\r\n IndexedXYZCollectionPolygonOps.splitConvexPolygonInsideOutsidePlane(this, xyz, newInside, newOutside, perpendicularRange);\r\n ClipUtilities.captureOrDrop(newInside, 3, insideFragments, arrayCache);\r\n ClipUtilities.captureOrDrop(newOutside, 3, outsideFragments, arrayCache);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ClipPlane.js","sourceRoot":"","sources":["../../../src/clipping/ClipPlane.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAQ/F,0CAA0E;AAG1E,6EAA0E;AAC1E,qEAAkE;AAClE,qDAAkD;AAClD,6FAA0F;AAC1F,mEAAkE;AAClE,yDAA0E;AAC1E,+CAAuD;AACvD,uDAAoD;AAEpD,mDAAgD;AAChD,yDAAwD;AACxD,2CAAqE;AAkBrE;;;;;;;;;;;;GAYG;AACH,MAAa,SAAS;IAUpB,YAAoB,MAAgB,EAAE,QAAgB,EAAE,SAAkB,EAAE,QAAiB;QAC3F,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;QAC5B,IAAI,CAAC,mBAAmB,GAAG,QA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AAE,CAAC;QAC7C,MAAM,UAAU,GAAG,UAAU,CAAC,aAAa,EAAE,CAAC;QAC9C,2CAA8B,CAAC,oCAAoC,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,kBAAkB,CAAC,CAAC;QAC1H,yBAAa,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;QACvE,yBAAa,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC,EAAE,gBAAgB,EAAE,UAAU,CAAC,CAAC;IAC3E,CAAC;;AArgBH,8BAsgBC;AA3LgB,+BAAqB,GAAG,IAAI,2CAAoB,EAAE,CAAC","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\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { Arc3d } from \"../curve/Arc3d\";\r\nimport { AnnounceNumberNumberCurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { AxisOrder, Geometry, PlaneAltitudeEvaluator } from \"../Geometry\";\r\nimport { Angle } from \"../geometry3d/Angle\";\r\nimport { XYZProps } from \"../geometry3d/XYZProps\";\r\nimport { GrowableFloat64Array } from \"../geometry3d/GrowableFloat64Array\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { Matrix3d } from \"../geometry3d/Matrix3d\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { IndexedXYZCollectionPolygonOps } from \"../geometry3d/PolygonOps\";\r\nimport { Range1d, Range3d } from \"../geometry3d/Range\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { Matrix4d } from \"../geometry4d/Matrix4d\";\r\nimport { Point4d } from \"../geometry4d/Point4d\";\r\nimport { AnalyticRoots } from \"../numerics/Polynomials\";\r\nimport { Clipper, ClipUtilities, PolygonClipper } from \"./ClipUtils\";\r\nimport { GrowableXYZArrayCache } from \"../geometry3d/ReusableObjectCache\";\r\n\r\n/** Wire format describing a [[ClipPlane]].\r\n * If either [[normal]] or [[dist]] are omitted, defaults to a normal of [[Vector3d.unitZ]] and a distance of zero.\r\n * @public\r\n */\r\nexport interface ClipPlaneProps {\r\n /** The plane's inward normal. */\r\n normal?: XYZProps;\r\n /** The plane's distance from the origin. */\r\n dist?: number;\r\n /** Defaults to `false`. */\r\n invisible?: boolean;\r\n /** Defaults to `false`. */\r\n interior?: boolean;\r\n}\r\n\r\n/** A ClipPlane is a single plane represented as\r\n * * An inward unit normal (u,v,w)\r\n * * A signedDistance\r\n *\r\n * Hence\r\n * * The halfspace function evaluation for \"point\" [x,y,z,] is: ([x,y,z] DOT (u,v,w)l - signedDistance)\r\n * * POSITIVE values of the halfspace function are \"inside\"\r\n * * ZERO value of the halfspace function is \"on\"\r\n * * NEGATIVE value of the halfspace function is \"outside\"\r\n * * A representative point on the plane is (signedDistance*u, signedDistance * v, signedDistance *w)\r\n * * Given a point and inward normal, the signedDistance is (point DOT normal)\r\n * @public\r\n */\r\nexport class ClipPlane implements Clipper, PlaneAltitudeEvaluator, PolygonClipper {\r\n private _inwardNormal: Vector3d;\r\n /** Construct a parallel plane through the origin.\r\n * * Move it to the actual position.\r\n * * _distanceFromOrigin is the distance it moved, with the (inward) normal direction as positive\r\n */\r\n private _distanceFromOrigin: number;\r\n private _invisible: boolean;\r\n private _interior: boolean;\r\n\r\n private constructor(normal: Vector3d, distance: number, invisible: boolean, interior: boolean) {\r\n this._invisible = invisible;\r\n this._interior = interior;\r\n this._inwardNormal = normal;\r\n this._distanceFromOrigin = distance;\r\n }\r\n /*\r\n private safeSetXYZDistance(nx: number, ny: number, nz: number, d: number) {\r\n this._inwardNormal.set(nx, ny, nz);\r\n this._distanceFromOrigin = d;\r\n }\r\n */\r\n /**\r\n * Return true if all members are almostEqual to corresponding members of other.\r\n * @param other clip plane to compare\r\n */\r\n public isAlmostEqual(other: ClipPlane): boolean {\r\n return Geometry.isSameCoordinate(this._distanceFromOrigin, other._distanceFromOrigin)\r\n && this._inwardNormal.isAlmostEqual(other._inwardNormal)\r\n && this._interior === other._interior\r\n && this._invisible === other._invisible;\r\n }\r\n /** return a cloned plane */\r\n public clone(): ClipPlane {\r\n const result = new ClipPlane(this._inwardNormal.clone(), this._distanceFromOrigin, this._invisible, this._interior);\r\n return result;\r\n }\r\n /** return Return a cloned plane with coordinate data negated. */\r\n public cloneNegated(): ClipPlane {\r\n const plane = new ClipPlane(this._inwardNormal.clone(), this._distanceFromOrigin, this._invisible, this._interior);\r\n plane.negateInPlace();\r\n return plane;\r\n }\r\n /** Create a ClipPlane from Plane3dByOriginAndUnitNormal. */\r\n public static createPlane(plane: Plane3dByOriginAndUnitNormal, invisible: boolean = false, interior: boolean = false, result?: ClipPlane): ClipPlane {\r\n const distance = plane.getNormalRef().dotProduct(plane.getOriginRef());\r\n if (result) {\r\n result._invisible = invisible;\r\n result._interior = interior;\r\n result._inwardNormal = plane.getNormalRef().clone();\r\n result._distanceFromOrigin = distance;\r\n return result;\r\n }\r\n return new ClipPlane(plane.getNormalRef().clone(), distance, invisible, interior);\r\n }\r\n /**\r\n * * Create a ClipPlane with direct normal and signedDistance.\r\n * * The vector is normalized for storage.\r\n */\r\n public static createNormalAndDistance(normal: Vector3d, distance: number, invisible: boolean = false, interior: boolean = false, result?: ClipPlane): ClipPlane | undefined {\r\n const normalized = normal.normalize();\r\n if (normalized) {\r\n if (result) {\r\n result._invisible = invisible;\r\n result._interior = interior;\r\n result._inwardNormal = normalized;\r\n result._distanceFromOrigin = distance;\r\n }\r\n return new ClipPlane(normalized, distance, invisible, interior);\r\n }\r\n return undefined;\r\n }\r\n /** Create a ClipPlane\r\n * * \"normal\" is the inward normal of the plane. (It is internally normalized)\r\n * * \"point\" is any point of the plane.\r\n * * The stored distance for the plane is the dot product of the point with the normal (i.e. treat the point's xyz as a vector from the origin.)\r\n */\r\n public static createNormalAndPoint(normal: Vector3d, point: Point3d, invisible: boolean = false, interior: boolean = false, result?: ClipPlane): ClipPlane | undefined {\r\n const normalized = normal.normalize();\r\n if (normalized) {\r\n const distance = normalized.dotProduct(point);\r\n if (result) {\r\n result._invisible = invisible;\r\n result._interior = interior;\r\n result._inwardNormal = normalized;\r\n result._distanceFromOrigin = distance;\r\n }\r\n return new ClipPlane(normalized, distance, invisible, interior);\r\n }\r\n return undefined;\r\n }\r\n\r\n /** Create a ClipPlane\r\n * * \"normal\" (normalX, normalY, nz) is the inward normal of the plane.\r\n * * The given (normalX,normalY,normalZ)\r\n * * \"point\" is any point of the plane.\r\n * * The stored distance for the plane is the dot product of the point with the normal (i.e. treat the point's xyz as a vector from the origin.)\r\n */\r\n public static createNormalAndPointXYZXYZ(normalX: number, normalY: number, normalZ: number,\r\n originX: number, originY: number, originZ: number,\r\n invisible: boolean = false, interior: boolean = false, result?: ClipPlane): ClipPlane | undefined {\r\n const q = Geometry.hypotenuseXYZ(normalX, normalY, normalZ);\r\n const r = Geometry.conditionalDivideFraction(1, q);\r\n if (r !== undefined) {\r\n if (result) {\r\n result._inwardNormal.set(normalX * r, normalY * r, normalZ * r);\r\n result._distanceFromOrigin = result._inwardNormal.dotProductXYZ(originX, originY, originZ);\r\n result._invisible = invisible;\r\n result._interior = interior;\r\n return result;\r\n }\r\n const normal = Vector3d.create(normalX * r, normalY * r, normalZ * r);\r\n return new ClipPlane(normal, normal.dotProductXYZ(originX, originY, originZ), invisible, interior);\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * return a json object of the form\r\n * `{\"normal\":[u,v,w],\"dist\":signedDistanceValue,\"interior\":true,\"invisible\":true}`\r\n */\r\n public toJSON(): ClipPlaneProps {\r\n const props: ClipPlaneProps = {\r\n normal: this.inwardNormalRef.toJSON(),\r\n dist: this.distance,\r\n };\r\n\r\n if (this.interior)\r\n props.interior = true;\r\n\r\n if (this.invisible)\r\n props.invisible = true;\r\n\r\n return props;\r\n }\r\n\r\n /** parse json object to ClipPlane instance */\r\n public static fromJSON(json: ClipPlaneProps, result?: ClipPlane): ClipPlane | undefined {\r\n if (json && json.normal && undefined !== json.dist && Number.isFinite(json.dist))\r\n return ClipPlane.createNormalAndDistance(Vector3d.fromJSON(json.normal), json.dist, !!json.invisible, !!json.interior);\r\n\r\n return ClipPlane.createNormalAndDistance(Vector3d.unitZ(), 0, false, false, result);\r\n }\r\n\r\n /** Set both the invisible and interior flags. */\r\n public setFlags(invisible: boolean, interior: boolean) {\r\n this._invisible = invisible;\r\n this._interior = interior;\r\n }\r\n\r\n /**\r\n * Return the stored distanceFromOrigin property.\r\n */\r\n public get distance() { return this._distanceFromOrigin; }\r\n /**\r\n * Return the stored inward normal property.\r\n */\r\n public get inwardNormalRef(): Vector3d { return this._inwardNormal; }\r\n /**\r\n * Return the \"interior\" property bit\r\n */\r\n public get interior() { return this._interior; }\r\n /**\r\n * Return the \"invisible\" property bit.\r\n */\r\n public get invisible() { return this._invisible; }\r\n\r\n /**\r\n * Create a plane defined by two points, an up vector, and a tilt angle relative to the up vector.\r\n * @param point0 start point of the edge\r\n * @param point1 end point of the edge\r\n * @param upVector vector perpendicular to the plane\r\n * @param tiltAngle angle to tilt the plane around the edge in the direction of the up vector.\r\n * @param result optional preallocated plane\r\n */\r\n public static createEdgeAndUpVector(point0: Point3d, point1: Point3d, upVector: Vector3d, tiltAngle?: Angle, result?: ClipPlane): ClipPlane | undefined {\r\n const edgeVector = Vector3d.createFrom(point1.minus(point0));\r\n let normal = (upVector.crossProduct(edgeVector)).normalize();\r\n\r\n if (normal) {\r\n if (tiltAngle !== undefined && !tiltAngle.isAlmostZero) {\r\n const tiltNormal = Vector3d.createRotateVectorAroundVector(normal, edgeVector, tiltAngle);\r\n if (tiltNormal) {\r\n normal = tiltNormal.clone();\r\n }\r\n }\r\n normal.negate(normal);\r\n return ClipPlane.createNormalAndPoint(normal, point0, false, false, result);\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Create a plane perpendicular to the edge between the xy parts of point0 and point1\r\n */\r\n public static createEdgeXY(point0: Point3d, point1: Point3d, result?: ClipPlane): ClipPlane | undefined {\r\n const normal = Vector3d.create(point0.y - point1.y, point1.x - point0.x);\r\n if (normal.normalizeInPlace())\r\n return ClipPlane.createNormalAndPoint(normal, point0, false, false, result);\r\n return undefined;\r\n }\r\n /**\r\n * Return the Plane3d form of the plane.\r\n * * The plane origin is the point `distance * inwardNormal`\r\n * * The plane normal is the inward normal of the ClipPlane.\r\n */\r\n public getPlane3d(): Plane3dByOriginAndUnitNormal {\r\n const d = this._distanceFromOrigin;\r\n // Normal should be normalized, will not return undefined\r\n return Plane3dByOriginAndUnitNormal.create(Point3d.create(this._inwardNormal.x * d, this._inwardNormal.y * d, this._inwardNormal.z * d), this._inwardNormal)!;\r\n }\r\n\r\n /**\r\n * Return the Point4d d form of the plane.\r\n * * The homogeneous xyz are the inward normal xyz.\r\n * * The homogeneous weight is the negated ClipPlane distance.\r\n */\r\n public getPlane4d(): Point4d {\r\n return Point4d.create(this._inwardNormal.x, this._inwardNormal.y, this._inwardNormal.z, - this._distanceFromOrigin);\r\n }\r\n /**\r\n * Set the plane from DPoint4d style plane.\r\n * * The saved plane has its direction normalized.\r\n * * This preserves the plane itself as a zero set but make plane evaluations act as true distances (even if the plane coefficients are scaled otherwise)\r\n * @param plane\r\n */\r\n public setPlane4d(plane: Point4d) {\r\n const a = Math.sqrt(plane.x * plane.x + plane.y * plane.y + plane.z * plane.z);\r\n const r = a === 0.0 ? 1.0 : 1.0 / a;\r\n this._inwardNormal.x = r * plane.x;\r\n this._inwardNormal.y = r * plane.y;\r\n this._inwardNormal.z = r * plane.z;\r\n this._distanceFromOrigin = -r * plane.w;\r\n }\r\n\r\n /**\r\n * Evaluate the altitude in weighted space, i.e. (dot product with inward normal) minus distance, with point.w scale applied to distance)\r\n * @param point space point to test\r\n */\r\n public weightedAltitude(point: Point4d): number {\r\n return point.x * this._inwardNormal.x + point.y * this._inwardNormal.y + point.z * this._inwardNormal.z - point.w * this._distanceFromOrigin;\r\n }\r\n\r\n /**\r\n * Evaluate the distance from the plane to a point in space, i.e. (dot product with inward normal) minus distance\r\n * @param point space point to test\r\n */\r\n public altitude(point: Point3d): number {\r\n return point.x * this._inwardNormal.x + point.y * this._inwardNormal.y + point.z * this._inwardNormal.z - this._distanceFromOrigin;\r\n }\r\n\r\n /**\r\n * Evaluate the distance from the plane to a point in space with point given as x,y,z, i.e. (dot product with inward normal) minus distance\r\n * @param point space point to test\r\n */\r\n public altitudeXYZ(x: number, y: number, z: number): number {\r\n return x * this._inwardNormal.x + y * this._inwardNormal.y + z * this._inwardNormal.z - this._distanceFromOrigin;\r\n }\r\n\r\n /**\r\n * Return the x component of the normal used to evaluate altitude.\r\n */\r\n public normalX(): number {return this._inwardNormal.x; }\r\n /**\r\n * Return the x component of the normal used to evaluate altitude.\r\n */\r\n public normalY(): number {return this._inwardNormal.y; }\r\n /**\r\n * Return the z component of the normal used to evaluate altitude.\r\n */\r\n public normalZ(): number {return this._inwardNormal.z; }\r\n\r\n /** Return the dot product of the plane normal with the vector (NOT using the plane's distanceFromOrigin).\r\n */\r\n public velocity(vector: Vector3d): number {\r\n return vector.x * this._inwardNormal.x + vector.y * this._inwardNormal.y + vector.z * this._inwardNormal.z;\r\n }\r\n\r\n /** Return the dot product of the plane normal with the x,yz, vector components (NOT using the plane's distanceFromOrigin).\r\n */\r\n public velocityXYZ(x: number, y: number, z: number): number {\r\n return x * this._inwardNormal.x + y * this._inwardNormal.y + z * this._inwardNormal.z;\r\n }\r\n\r\n /** Return the dot product of the plane normal with the point (treating the point xyz as a vector, and NOT using the plane's distanceFromOrigin).\r\n */\r\n public dotProductPlaneNormalPoint(point: Point3d): number {\r\n return point.x * this._inwardNormal.x + point.y * this._inwardNormal.y + point.z * this._inwardNormal.z;\r\n }\r\n /**\r\n * Return true if spacePoint is inside or on the plane, with tolerance applied to \"on\".\r\n * @param spacePoint point to test.\r\n * @param tolerance tolerance for considering \"near plane\" to be \"on plane\"\r\n */\r\n public isPointOnOrInside(spacePoint: Point3d, tolerance: number = Geometry.smallMetricDistance): boolean {\r\n let value = this.altitude(spacePoint);\r\n if (tolerance) { value += tolerance; }\r\n return value >= 0.0;\r\n }\r\n\r\n /**\r\n * Return true if spacePoint is strictly inside the halfspace, with tolerance applied to \"on\".\r\n * @param spacePoint point to test.\r\n * @param tolerance tolerance for considering \"near plane\" to be \"on plane\"\r\n */\r\n public isPointInside(point: Point3d, tolerance: number = Geometry.smallMetricDistance): boolean {\r\n let value = this.altitude(point);\r\n if (tolerance) { value -= tolerance; }\r\n return value > 0.0;\r\n }\r\n\r\n /**\r\n * Return true if spacePoint is strictly on the plane, within tolerance\r\n * @param spacePoint point to test.\r\n * @param tolerance tolerance for considering \"near plane\" to be \"on plane\"\r\n */\r\n public isPointOn(point: Point3d, tolerance: number = Geometry.smallMetricDistance): boolean {\r\n return Math.abs(this.altitude(point)) <= tolerance;\r\n }\r\n /**\r\n * Compute intersections of an (UNBOUNDED) arc with the plane. Append them (as radians) to a growing array.\r\n * @param arc arc to test. The angle limits of the arc are NOT considered.\r\n * @param intersectionRadians array to receive results\r\n */\r\n public appendIntersectionRadians(arc: Arc3d, intersectionRadians: GrowableFloat64Array) {\r\n const arcVectors = arc.toVectors();\r\n const alpha = this.altitude(arc.center);\r\n const beta = this.velocity(arcVectors.vector0);\r\n const gamma = this.velocity(arcVectors.vector90);\r\n AnalyticRoots.appendImplicitLineUnitCircleIntersections(alpha, beta, gamma, undefined, undefined, intersectionRadians);\r\n }\r\n\r\n private static _clipArcFractionArray = new GrowableFloat64Array();\r\n /** Announce fractional intervals of arc clip.\r\n * * Each call to `announce(fraction0, fraction1, arc)` announces one interval that is inside the clip plane.\r\n */\r\n public announceClippedArcIntervals(arc: Arc3d, announce?: AnnounceNumberNumberCurvePrimitive): boolean {\r\n const breaks = ClipPlane._clipArcFractionArray;\r\n breaks.clear();\r\n this.appendIntersectionRadians(arc, breaks);\r\n arc.sweep.radiansArrayToPositivePeriodicFractions(breaks);\r\n return ClipUtilities.selectIntervals01(arc, breaks, this, announce);\r\n }\r\n /**\r\n * * Compute intersection of (unbounded) segment with the plane.\r\n * * If the ends are on the same side of the plane, return undefined.\r\n * * If the intersection is an endpoint or interior to the segment return the fraction.\r\n * * If both ends are on, return undefined.\r\n */\r\n public getBoundedSegmentSimpleIntersection(pointA: Point3d, pointB: Point3d): number | undefined {\r\n const h0 = this.altitude(pointA);\r\n const h1 = this.altitude(pointB);\r\n if (h0 * h1 > 0.0)\r\n return undefined;\r\n if (h0 === 0.0 && h1 === 0.0) {\r\n return undefined;\r\n }\r\n return - h0 / (h1 - h0);\r\n }\r\n\r\n /** Apply transform to the origin. Apply inverse transpose of the matrix part to th normal vector. */\r\n public transformInPlace(transform: Transform): boolean {\r\n const plane: Plane3dByOriginAndUnitNormal = this.getPlane3d();\r\n const matrix: Matrix3d = transform.matrix;\r\n const newPoint = transform.multiplyPoint3d(plane.getOriginRef());\r\n // Normal transforms as the inverse transpose of the matrix part\r\n // BTW: If the matrix is orthogonal, this is a long way to multiply by the matrix part (mumble grumble)\r\n const newNormal = matrix.multiplyInverseTranspose(plane.getNormalRef());\r\n if (!newNormal)\r\n return false;\r\n\r\n plane.set(newPoint, newNormal);\r\n const normalized = (plane.getNormalRef()).normalize();\r\n if (!normalized)\r\n return false;\r\n this._inwardNormal = normalized;\r\n this._distanceFromOrigin = this._inwardNormal.dotProduct(plane.getOriginRef());\r\n return true;\r\n }\r\n /** Set the invisible flag. Interpretation of this is up to the use code algorithms. */\r\n public setInvisible(invisible: boolean) {\r\n this._invisible = invisible;\r\n }\r\n\r\n /** reverse the sign of all coefficients, so outside and inside reverse */\r\n public negateInPlace() {\r\n this._inwardNormal = this._inwardNormal.negate();\r\n this._distanceFromOrigin = - this._distanceFromOrigin;\r\n }\r\n /**\r\n * Move the plane INWARD by given distance\r\n * @param offset distance of shift inwards\r\n */\r\n public offsetDistance(offset: number) {\r\n this._distanceFromOrigin += offset;\r\n }\r\n\r\n /**\r\n * Clip a polygon to the inside or outside of the plane.\r\n * * Results with 2 or fewer points are ignored.\r\n * * Other than ensuring capacity in the arrays, there are no object allocations during execution of this function.\r\n * @param xyz input points.\r\n * @param work work buffer\r\n * @param tolerance tolerance for \"on plane\" decision.\r\n */\r\n public clipConvexPolygonInPlace(xyz: GrowableXYZArray, work: GrowableXYZArray, inside: boolean = true, tolerance: number = Geometry.smallMetricDistance) {\r\n return IndexedXYZCollectionPolygonOps.clipConvexPolygonInPlace(this, xyz, work, inside, tolerance);\r\n }\r\n\r\n /**\r\n * Multiply the ClipPlane's DPoint4d by matrix.\r\n * @param matrix matrix to apply.\r\n * @param invert if true, use in verse of the matrix.\r\n * @param transpose if true, use the transpose of the matrix (or inverse, per invert parameter)\r\n * * Note that if matrixA is applied to all of space, the matrix to send to this method to get a corresponding effect on the plane is the inverse transpose of matrixA\r\n * * Callers that will apply the same matrix to many planes should pre-invert the matrix for efficiency.\r\n * * Both params default to true to get the full effect of transforming space.\r\n * @param matrix matrix to apply\r\n * @return false if unable to invert\r\n */\r\n public multiplyPlaneByMatrix4d(matrix: Matrix4d, invert: boolean = true, transpose: boolean = true): boolean {\r\n const plane: Point4d = this.getPlane4d();\r\n if (invert) {\r\n const inverse = matrix.createInverse();\r\n if (inverse)\r\n return this.multiplyPlaneByMatrix4d(inverse, false, transpose);\r\n return false;\r\n }\r\n if (transpose)\r\n matrix.multiplyTransposePoint4d(plane, plane);\r\n else\r\n matrix.multiplyPoint4d(plane, plane);\r\n this.setPlane4d(plane);\r\n return true;\r\n }\r\n\r\n /** announce the interval (if any) where a line is within the clip plane half space. */\r\n public announceClippedSegmentIntervals(f0: number, f1: number, pointA: Point3d, pointB: Point3d, announce?: (fraction0: number, fraction1: number) => void): boolean {\r\n if (f1 < f0)\r\n return false;\r\n const h0 = - this.altitude(pointA);\r\n const h1 = - this.altitude(pointB);\r\n const delta = h1 - h0;\r\n const f = Geometry.conditionalDivideFraction(-h0, delta);\r\n if (f === undefined) { // The segment is parallel to the plane.\r\n if (h0 <= 0.0) { if (announce) announce(f0, f1); return true; }\r\n return false;\r\n }\r\n if (delta > 0) { // segment aims OUT\r\n if (f < f1) f1 = f;\r\n } else {\r\n // segment aims IN\r\n if (f > f0)\r\n f0 = f;\r\n }\r\n if (f1 < f0)\r\n return false;\r\n if (announce) announce(f0, f1);\r\n return true;\r\n }\r\n /**\r\n * Return a coordinate frame with\r\n * * origin at closest point to global origin\r\n * * z axis points in\r\n * x and y are \"in plane\"\r\n */\r\n public getFrame(): Transform {\r\n const d = this._distanceFromOrigin;\r\n const origin = Point3d.create(this._inwardNormal.x * d, this._inwardNormal.y * d, this._inwardNormal.z * d);\r\n const matrix = Matrix3d.createRigidHeadsUp(this._inwardNormal, AxisOrder.ZXY);\r\n return Transform.createOriginAndMatrix(origin, matrix);\r\n }\r\n /**\r\n * Return the intersection of the plane with a range cube.\r\n * @param range\r\n * @param xyzOut intersection polygon. This is convex.\r\n */\r\n public intersectRange(range: Range3d, addClosurePoint: boolean = false): GrowableXYZArray | undefined {\r\n if (range.isNull)\r\n return undefined;\r\n const corners = range.corners();\r\n const frameOnPlane = this.getFrame();\r\n frameOnPlane.multiplyInversePoint3dArrayInPlace(corners);\r\n const localRange = Range3d.createArray(corners);\r\n if (localRange.low.z * localRange.high.z > 0.0)\r\n return undefined;\r\n // oversized polygon on local z= 0\r\n const xyzOut = new GrowableXYZArray();\r\n xyzOut.pushXYZ(localRange.low.x, localRange.low.y, 0);\r\n xyzOut.pushXYZ(localRange.high.x, localRange.low.y, 0);\r\n xyzOut.pushXYZ(localRange.high.x, localRange.high.y, 0);\r\n xyzOut.pushXYZ(localRange.low.x, localRange.high.y, 0);\r\n xyzOut.multiplyTransformInPlace(frameOnPlane);\r\n IndexedXYZCollectionPolygonOps.intersectRangeConvexPolygonInPlace(range, xyzOut);\r\n if (xyzOut.length === 0)\r\n return undefined;\r\n if (addClosurePoint)\r\n xyzOut.pushWrap(1);\r\n return xyzOut;\r\n }\r\n /** Implement appendPolygonClip, as defined in interface PolygonClipper. /**\r\n *\r\n * @param xyz input polygon. This is not changed.\r\n * @param insideFragments Array to receive \"inside\" fragments. Each fragment is a GrowableXYZArray grabbed from the cache. This is NOT cleared.\r\n * @param outsideFragments Array to receive \"outside\" fragments. Each fragment is a GrowableXYZArray grabbed from the cache. This is NOT cleared.\r\n * @param arrayCache cache for reusable GrowableXYZArray.\r\n */\r\n public appendPolygonClip(\r\n xyz: GrowableXYZArray,\r\n insideFragments: GrowableXYZArray[],\r\n outsideFragments: GrowableXYZArray[],\r\n arrayCache: GrowableXYZArrayCache): void {\r\n const perpendicularRange = Range1d.createNull();\r\n const newInside = arrayCache.grabFromCache();\r\n const newOutside = arrayCache.grabFromCache();\r\n IndexedXYZCollectionPolygonOps.splitConvexPolygonInsideOutsidePlane(this, xyz, newInside, newOutside, perpendicularRange);\r\n ClipUtilities.captureOrDrop(newInside, 3, insideFragments, arrayCache);\r\n ClipUtilities.captureOrDrop(newOutside, 3, outsideFragments, arrayCache);\r\n }\r\n}\r\n"]}
|
|
@@ -329,6 +329,11 @@ export declare class ClipUtilities {
|
|
|
329
329
|
* Pass polygon `xyz` through a sequence of PolygonClip steps with "parity" rules
|
|
330
330
|
*/
|
|
331
331
|
static doPolygonClipParitySequence(xyz: GrowableXYZArray, clippers: Clipper[], acceptedIn: GrowableXYZArray[] | undefined, acceptedOut: GrowableXYZArray[] | undefined, arrayCache: GrowableXYZArrayCache | undefined): void;
|
|
332
|
+
/** For each plane of clipper, construct a UnionOfConvexClipPlaneSets for an outer (infinite) convex volume that
|
|
333
|
+
* abuts the outer volume of the neighbor faces.
|
|
334
|
+
*
|
|
335
|
+
*/
|
|
336
|
+
static createComplementaryClips(clipper: ConvexClipPlaneSet): UnionOfConvexClipPlaneSets;
|
|
332
337
|
}
|
|
333
338
|
export {};
|
|
334
339
|
//# sourceMappingURL=ClipUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClipUtils.d.ts","sourceRoot":"","sources":["../../../src/clipping/ClipUtils.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,kCAAkC,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACnH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,OAAO,EAAY,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAG1E,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"ClipUtils.d.ts","sourceRoot":"","sources":["../../../src/clipping/ClipUtils.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,kCAAkC,EAAE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;;;;;;;OAUG;WACW,wBAAwB,CAAC,MAAM,EAAE,4BAA4B,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAChI,cAAc,GAAE,MAAgB;IAMlC;;;;;OAKG;WACW,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI;IAQ5H;;;;OAIG;WACW,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;IASvE;;;;;;;;;;;;;;;;;OAiBG;WACW,qBAAqB,CACjC,GAAG,EAAE,gBAAgB,EACrB,QAAQ,EAAE,OAAO,EAAE,EACnB,UAAU,EAAE,gBAAgB,EAAE,GAAG,SAAS,EAC1C,WAAW,EAAE,gBAAgB,EAAE,GAAG,SAAS,EAC3C,eAAe,EAAE,gBAAgB,EAAE,GAAG,SAAS,EAC/C,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,cAAc,EACzB,mBAAmB,EAAE,cAAc,EACnC,UAAU,EAAE,qBAAqB,GAAG,SAAS;IAmC/C;;OAEG;WACW,2BAA2B,CACvC,GAAG,EAAE,gBAAgB,EACrB,QAAQ,EAAE,OAAO,EAAE,EACnB,UAAU,EAAE,gBAAgB,EAAE,GAAG,SAAS,EAC1C,WAAW,EAAE,gBAAgB,EAAE,GAAG,SAAS,EAC3C,UAAU,EAAE,qBAAqB,GAAG,SAAS;IA6C/C;;;OAGG;WACW,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,GAAG,0BAA0B;CA6BhG"}
|
|
@@ -22,6 +22,7 @@ const UnionOfConvexClipPlaneSets_1 = require("./UnionOfConvexClipPlaneSets");
|
|
|
22
22
|
const ReusableObjectCache_1 = require("../geometry3d/ReusableObjectCache");
|
|
23
23
|
const LineStringOffsetClipperContext_1 = require("./internalContexts/LineStringOffsetClipperContext");
|
|
24
24
|
const Point3dArrayCarrier_1 = require("../geometry3d/Point3dArrayCarrier");
|
|
25
|
+
const CurveFactory_1 = require("../curve/CurveFactory");
|
|
25
26
|
/** Enumerated type for describing where geometry lies with respect to clipping planes.
|
|
26
27
|
* @public
|
|
27
28
|
*/
|
|
@@ -736,6 +737,39 @@ class ClipUtilities {
|
|
|
736
737
|
moveFragments(candidatesOut, acceptedOut, arrayCache);
|
|
737
738
|
}
|
|
738
739
|
}
|
|
740
|
+
/** For each plane of clipper, construct a UnionOfConvexClipPlaneSets for an outer (infinite) convex volume that
|
|
741
|
+
* abuts the outer volume of the neighbor faces.
|
|
742
|
+
*
|
|
743
|
+
*/
|
|
744
|
+
static createComplementaryClips(clipper) {
|
|
745
|
+
const planes = clipper.planes;
|
|
746
|
+
const interval = Range_1.Range1d.createNull();
|
|
747
|
+
const n = planes.length;
|
|
748
|
+
const newClippers = [];
|
|
749
|
+
for (const p of planes) {
|
|
750
|
+
const outerSet = ConvexClipPlaneSet_1.ConvexClipPlaneSet.createEmpty();
|
|
751
|
+
outerSet.addPlaneToConvexSet(p.cloneNegated());
|
|
752
|
+
newClippers.push(outerSet);
|
|
753
|
+
}
|
|
754
|
+
for (let i = 0; i < n; i++) {
|
|
755
|
+
for (let j = i + 1; j < n; j++) {
|
|
756
|
+
const ray = CurveFactory_1.CurveFactory.planePlaneIntersectionRay(planes[i], planes[j]);
|
|
757
|
+
if (ray) {
|
|
758
|
+
if (clipper.hasIntersectionWithRay(ray, interval)) {
|
|
759
|
+
// the normal-to-normal vector is bisector (or close to bisector?)
|
|
760
|
+
const newNormal = planes[j].inwardNormalRef.minus(planes[i].inwardNormalRef);
|
|
761
|
+
const plane1 = ClipPlane_1.ClipPlane.createNormalAndPoint(newNormal, ray.origin);
|
|
762
|
+
if (plane1) {
|
|
763
|
+
const plane2 = plane1.cloneNegated();
|
|
764
|
+
newClippers[i].addPlaneToConvexSet(plane1);
|
|
765
|
+
newClippers[j].addPlaneToConvexSet(plane2);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
return UnionOfConvexClipPlaneSets_1.UnionOfConvexClipPlaneSets.createConvexSets(newClippers);
|
|
772
|
+
}
|
|
739
773
|
}
|
|
740
774
|
exports.ClipUtilities = ClipUtilities;
|
|
741
775
|
ClipUtilities._selectIntervals01TestPoint = Point3dVector3d_1.Point3d.create();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClipUtils.js","sourceRoot":"","sources":["../../../src/clipping/ClipUtils.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAKH,wDAAqD;AACrD,wCAAqC;AACrC,0CAAuC;AAEvC,qEAAkE;AAClE,mEAAkE;AAClE,+CAAuD;AACvD,2CAAwC;AACxC,mDAAgD;AAChD,6CAA0C;AAC1C,6DAA0D;AAC1D,6EAA0E;AAC1E,2EAA0E;AAE1E,sGAAmG;AACnG,2EAAwE;AAIxE;;GAEG;AACH,IAAY,oBAOX;AAPD,WAAY,oBAAoB;IAC9B,wBAAwB;IACxB,mFAAkB,CAAA;IAClB,oCAAoC;IACpC,yEAAa,CAAA;IACb,yBAAyB;IACzB,qFAAmB,CAAA;AACrB,CAAC,EAPW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAO/B;AACD;;;GAGG;AACH,IAAY,cAOT;AAPH,WAAY,cAAc;IACxB,2DAA2D;IAC3D,2DAAY,CAAA;IACZ,4DAA4D;IAC5D,8DAAc,CAAA;IAChB,6CAA6C;IAC3C,uEAAkB,CAAA;AAClB,CAAC,EAPS,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAOvB;AAEH;;GAEG;AACH,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,kDAAkD;IAClD,2DAAY,CAAA;IACZ,kCAAkC;IAClC,6DAAa,CAAA;IACb,iCAAiC;IACjC,6DAAa,CAAA;AACf,CA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AC,CAAC;AACvB,CAAC","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 CartesianGeometry\r\n */\r\n\r\nimport { Arc3d } from \"../curve/Arc3d\";\r\nimport { AnnounceNumberNumber, AnnounceNumberNumberCurvePrimitive, CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { GeometryQuery } from \"../curve/GeometryQuery\";\r\nimport { LineString3d } from \"../curve/LineString3d\";\r\nimport { Loop } from \"../curve/Loop\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GrowableFloat64Array } from \"../geometry3d/GrowableFloat64Array\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Range1d, Range3d } from \"../geometry3d/Range\";\r\nimport { ClipPlane } from \"./ClipPlane\";\r\nimport { ClipPrimitive } from \"./ClipPrimitive\";\r\nimport { ClipVector } from \"./ClipVector\";\r\nimport { ConvexClipPlaneSet } from \"./ConvexClipPlaneSet\";\r\nimport { UnionOfConvexClipPlaneSets } from \"./UnionOfConvexClipPlaneSets\";\r\nimport { GrowableXYZArrayCache } from \"../geometry3d/ReusableObjectCache\";\r\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { LineStringOffsetClipperContext } from \"./internalContexts/LineStringOffsetClipperContext\";\r\nimport { Point3dArrayCarrier } from \"../geometry3d/Point3dArrayCarrier\";\r\nimport { XAndY } from \"../geometry3d/XYZProps\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\n\r\n/** Enumerated type for describing where geometry lies with respect to clipping planes.\r\n * @public\r\n */\r\nexport enum ClipPlaneContainment {\r\n /** All points inside */\r\n StronglyInside = 1,\r\n /** Inside/outside state unknown. */\r\n Ambiguous = 2,\r\n /** All points outside */\r\n StronglyOutside = 3,\r\n}\r\n/**\r\n * Enumeration of ways to handle an intermediate fragment from a clipping step\r\n * @public\r\n */\r\nexport enum ClipStepAction {\r\n /** Pass fragments directly to final accepted \"in\" state */\r\n acceptIn = 1,\r\n /** Pass fragments directly to final accepted \"out\" state */\r\n acceptOut = -1,\r\n/** forward fragments to subsequent steps. */\r\n passToNextStep = 0\r\n }\r\n\r\n/** Enumerated type for describing what must yet be done to clip a piece of geometry.\r\n * @public\r\n */\r\nexport enum ClipStatus {\r\n /** some geometry may cross the clip boundaries */\r\n ClipRequired,\r\n /** geometry is clearly outside */\r\n TrivialReject,\r\n /** geometry is clearly inside */\r\n TrivialAccept,\r\n}\r\n\r\n/** An object containing clipping planes that can be used to clip geometry.\r\n * @public\r\n */\r\nexport interface Clipper {\r\n /** test if `point` is on or inside the Clipper's volume. */\r\n isPointOnOrInside(point: Point3d, tolerance?: number): boolean;\r\n /** Find the parts of the line segment (if any) that is within the convex clip volume.\r\n * * The input fractional interval from fraction0 to fraction1 (increasing!!) is the active part to consider.\r\n * * To clip to the usual bounded line segment, start with fractions (0,1).\r\n * If the clip volume is unbounded, the line interval may also be unbounded.\r\n * * An unbounded line portion will have fraction coordinates positive or negative Number.MAX_VALUE.\r\n * @param f0 fraction that is the initial lower fraction of the active interval. (e.g. 0.0 for bounded segment)\r\n * @param f1 fraction that is the initial upper fraction of the active interval. (e.g. 1.0 for bounded segment)\r\n * @param pointA segment start (fraction 0)\r\n * @param pointB segment end (fraction 1)\r\n * @param announce function to be called to announce a fraction interval that is within the convex clip volume.\r\n * @returns true if a segment was announced, false if entirely outside.\r\n */\r\n announceClippedSegmentIntervals(f0: number, f1: number, pointA: Point3d, pointB: Point3d, announce?: AnnounceNumberNumber): boolean;\r\n /** Find the portion (or portions) of the arc (if any) that are within the convex clip volume.\r\n * * The input fractional interval from fraction0 to fraction1 (increasing!!) is the active part to consider.\r\n * @param announce function to be called to announce a fraction interval that is within the convex clip volume.\r\n * @returns true if one or more arcs portions were announced, false if entirely outside.\r\n */\r\n announceClippedArcIntervals(arc: Arc3d, announce?: AnnounceNumberNumberCurvePrimitive): boolean;\r\n/** Optional polygon clip method.\r\n * * This is expected to be implemented by planar clip structures.\r\n * * This is unimplemented for curve clippers (e.g. sphere) for which polygon clip result has\r\n * curved edges.\r\n */\r\n appendPolygonClip?: AppendPolygonClipFunction;\r\n}\r\n /**\r\n * Signature of method to execute polygon clip, distributing fragments of xyz among insideFragments and outsideFragments\r\n * @param xyz input polygon. This is not changed.\r\n * @param insideFragments Array to receive \"inside\" fragments. Each fragment is a GrowableXYZArray grabbed from the cache. This is NOT cleared.\r\n * @param outsideFragments Array to receive \"outside\" fragments. Each fragment is a GrowableXYZArray grabbed from the cache. This is NOT cleared.\r\n * @param arrayCache cache for reusable GrowableXYZArray.\r\n */\r\n type AppendPolygonClipFunction = (\r\n xyz: GrowableXYZArray,\r\n insideFragments: GrowableXYZArray[],\r\n outsideFragments: GrowableXYZArray[],\r\n arrayCache: GrowableXYZArrayCache) => void;\r\n\r\n/**\r\n * Interface for clipping polygons.\r\n * Supported by:\r\n * * AlternatingCCTreeNode\r\n * * ConvexClipPlaneSet\r\n * @public\r\n */\r\nexport interface PolygonClipper {\r\n appendPolygonClip: AppendPolygonClipFunction;\r\n}\r\n/** Static class whose various methods are functions for clipping geometry\r\n * @public\r\n */\r\nexport class ClipUtilities {\r\n private static _selectIntervals01TestPoint = Point3d.create();\r\n /**\r\n * * Augment the unsortedFractionsArray with 0 and 1\r\n * * sort\r\n * * test the midpoint of each interval with `clipper.isPointOnOrInside`\r\n * * pass accepted intervals to `announce(f0,f1,curve)`\r\n */\r\n public static selectIntervals01(curve: CurvePrimitive, unsortedFractions: GrowableFloat64Array, clipper: Clipper, announce?: AnnounceNumberNumberCurvePrimitive): boolean {\r\n unsortedFractions.push(0);\r\n unsortedFractions.push(1);\r\n unsortedFractions.sort();\r\n let f0 = unsortedFractions.atUncheckedIndex(0);\r\n let f1;\r\n let fMid;\r\n const testPoint = ClipUtilities._selectIntervals01TestPoint;\r\n const n = unsortedFractions.length;\r\n for (let i = 1; i < n; i++) {\r\n f1 = unsortedFractions.atUncheckedIndex(i);\r\n if (f1 > f0 + Geometry.smallFraction) {\r\n fMid = 0.5 * (f0 + f1);\r\n if (fMid >= 0.0 && fMid <= 1.0) {\r\n curve.fractionToPoint(fMid, testPoint);\r\n if (clipper.isPointOnOrInside(testPoint)) {\r\n if (announce)\r\n announce(f0, f1, curve);\r\n else\r\n return true;\r\n }\r\n }\r\n f0 = f1;\r\n }\r\n }\r\n return false;\r\n }\r\n /**\r\n * Announce triples of (low, high, cp) for each entry in intervals\r\n * @param intervals source array\r\n * @param cp CurvePrimitive for announcement\r\n * @param announce function to receive data\r\n */\r\n public static announceNNC(intervals: Range1d[], cp: CurvePrimitive, announce?: AnnounceNumberNumberCurvePrimitive): boolean {\r\n if (announce) {\r\n for (const ab of intervals) {\r\n announce(ab.low, ab.high, cp);\r\n }\r\n }\r\n return intervals.length > 0;\r\n }\r\n\r\n /** Find portions of the curve that are within the clipper.\r\n * Collect them into an array of curve primitives.\r\n */\r\n public static collectClippedCurves(curve: CurvePrimitive, clipper: Clipper): CurvePrimitive[] {\r\n const result: CurvePrimitive[] = [];\r\n curve.announceClipIntervals(clipper,\r\n (fraction0: number, fraction1: number, curveA: CurvePrimitive) => {\r\n if (fraction1 !== fraction0) {\r\n const partialCurve = curveA.clonePartialCurve(fraction0, fraction1);\r\n if (partialCurve)\r\n result.push(partialCurve);\r\n }\r\n });\r\n return result;\r\n }\r\n\r\n /**\r\n * Clip a polygon down to regions defined by each shape of a ClipShape.\r\n * @return An multidimensional array of points, where each array is the boundary of part of the remaining polygon.\r\n */\r\n public static clipPolygonToClipShape(polygon: Point3d[], clipShape: ClipPrimitive): Point3d[][] {\r\n const outputA = this.clipPolygonToClipShapeReturnGrowableXYZArrays(polygon, clipShape);\r\n const output = [];\r\n for (const g of outputA)\r\n output.push(g.getPoint3dArray());\r\n return output;\r\n }\r\n\r\n /**\r\n * Clip a polygon down to regions defined by each shape of a ClipShape.\r\n * @return An multidimensional array of points, where each array is the boundary of part of the remaining polygon.\r\n */\r\n public static clipPolygonToClipShapeReturnGrowableXYZArrays(polygon: Point3d[], clipShape: ClipPrimitive): GrowableXYZArray[] {\r\n const output: GrowableXYZArray[] = [];\r\n const clipper = clipShape.fetchClipPlanesRef();\r\n // NEEDS WORK -- what if it is a mask !!!!\r\n if (clipper) {\r\n clipper.polygonClip(polygon, output);\r\n }\r\n return output;\r\n }\r\n\r\n /** Given an array of points, test for trivial containment conditions.\r\n * * ClipStatus.TrivialAccept if all points are in any one of the convexSet's.\r\n * * ClipStatus.ClipRequired if (in any single convexSet) there were points on both sides of any single plane.\r\n * * ClipStatus.TrivialReject if neither of those occurred.\r\n */\r\n public static pointSetSingleClipStatus(points: GrowableXYZArray, planeSet: UnionOfConvexClipPlaneSets, tolerance: number): ClipStatus {\r\n if (planeSet.convexSets.length === 0)\r\n return ClipStatus.TrivialAccept;\r\n\r\n for (const convexSet of planeSet.convexSets) {\r\n let allOutsideSinglePlane = false, anyOutside = false;\r\n\r\n for (const plane of convexSet.planes) {\r\n let numInside = 0, numOutside = 0;\r\n const planeDistance = plane.distance - tolerance;\r\n\r\n const currPt = Point3d.create();\r\n const currVec = Vector3d.create();\r\n for (let i = 0; i < points.length; i++) {\r\n points.getPoint3dAtUncheckedPointIndex(i, currPt);\r\n currVec.setFrom(currPt);\r\n currVec.dotProduct(plane.inwardNormalRef) > planeDistance ? numInside++ : numOutside++;\r\n }\r\n\r\n anyOutside = (numOutside !== 0) ? true : anyOutside;\r\n if (numInside === 0) {\r\n allOutsideSinglePlane = true;\r\n break;\r\n }\r\n }\r\n\r\n if (!anyOutside) // totally inside this set - no clip required\r\n return ClipStatus.TrivialAccept;\r\n if (!allOutsideSinglePlane)\r\n return ClipStatus.ClipRequired;\r\n }\r\n return ClipStatus.TrivialReject;\r\n }\r\n\r\n /**\r\n * Emit point loops for intersection of a convex set with a range.\r\n * * return zero length array for (a) null range or (b) no intersections\r\n * @param range range to intersect\r\n * @param includeConvexSetFaces if false, do not compute facets originating as convex set planes.\r\n * @param includeRangeFaces if false, do not compute facets originating as range faces\r\n * @param ignoreInvisiblePlanes if true, do NOT compute a facet for convex set faces marked invisible.\r\n */\r\n public static announceLoopsOfConvexClipPlaneSetIntersectRange(convexSet: ConvexClipPlaneSet | ClipPlane, range: Range3d, loopFunction: (loopPoints: GrowableXYZArray) => void,\r\n includeConvexSetFaces: boolean = true, includeRangeFaces: boolean = true, ignoreInvisiblePlanes = false) {\r\n const work = new GrowableXYZArray();\r\n if (includeConvexSetFaces) {\r\n // Clip convexSet planes to the range and to the rest of the convexSet . .\r\n if (convexSet instanceof ConvexClipPlaneSet) {\r\n for (const plane of convexSet.planes) {\r\n if (ignoreInvisiblePlanes && plane.invisible)\r\n continue;\r\n const pointsClippedToRange = plane.intersectRange(range, true);\r\n const finalPoints = new GrowableXYZArray();\r\n if (pointsClippedToRange) {\r\n convexSet.polygonClip(pointsClippedToRange, finalPoints, work, plane);\r\n if (finalPoints.length > 0)\r\n loopFunction(finalPoints);\r\n }\r\n }\r\n } else { // `convexSet` is just one plane ...\r\n if (ignoreInvisiblePlanes && convexSet.invisible) {\r\n // skip it !\r\n } else {\r\n const pointsClippedToRange = convexSet.intersectRange(range, true);\r\n if (pointsClippedToRange)\r\n loopFunction(pointsClippedToRange);\r\n }\r\n }\r\n }\r\n\r\n if (includeRangeFaces) {\r\n // clip range faces to the convex set . . .\r\n const corners = range.corners();\r\n for (let i = 0; i < 6; i++) {\r\n const indices = Range3d.faceCornerIndices(i);\r\n const finalPoints = new GrowableXYZArray();\r\n const lineString = LineString3d.createIndexedPoints(corners, indices);\r\n if (convexSet instanceof ConvexClipPlaneSet) {\r\n convexSet.polygonClip(lineString.packedPoints, finalPoints, work);\r\n if (finalPoints.length > 0)\r\n loopFunction(finalPoints);\r\n } else {\r\n convexSet.clipConvexPolygonInPlace(lineString.packedPoints, work);\r\n if (lineString.packedPoints.length > 0)\r\n loopFunction(lineString.packedPoints);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Return a (possibly empty) array of geometry (Loops !!) which are facets of the intersection of the convex set intersecting a range.\r\n * * return zero length array for (a) null range or (b) no intersections\r\n * @param allClippers convex or union clipper\r\n * @param range range to intersect\r\n * @param includeConvexSetFaces if false, do not compute facets originating as convex set planes.\r\n * @param includeRangeFaces if false, do not compute facets originating as range faces\r\n * @param ignoreInvisiblePlanes if true, do NOT compute a facet for convex set faces marked invisible.\r\n */\r\n public static loopsOfConvexClipPlaneIntersectionWithRange(allClippers: ConvexClipPlaneSet | UnionOfConvexClipPlaneSets | ClipPlane, range: Range3d,\r\n includeConvexSetFaces: boolean = true, includeRangeFaces: boolean = true, ignoreInvisiblePlanes = false): GeometryQuery[] {\r\n const result: GeometryQuery[] = [];\r\n if (allClippers instanceof UnionOfConvexClipPlaneSets) {\r\n for (const clipper of allClippers.convexSets) {\r\n this.announceLoopsOfConvexClipPlaneSetIntersectRange(clipper, range,\r\n (points: GrowableXYZArray) => {\r\n if (points.length > 0) result.push(Loop.createPolygon(points));\r\n },\r\n includeConvexSetFaces, includeRangeFaces, ignoreInvisiblePlanes);\r\n }\r\n } else if (allClippers instanceof ConvexClipPlaneSet || allClippers instanceof ClipPlane) {\r\n this.announceLoopsOfConvexClipPlaneSetIntersectRange(allClippers, range,\r\n (points: GrowableXYZArray) => {\r\n if (points.length > 0) result.push(Loop.createPolygon(points));\r\n },\r\n includeConvexSetFaces, includeRangeFaces, ignoreInvisiblePlanes);\r\n }\r\n return result;\r\n }\r\n /**\r\n * Return the (possibly null) range of the intersection of the convex set with a range.\r\n * * The convex set is permitted to be unbounded (e.g. a single plane). The range parameter provides bounds.\r\n * @param convexSet convex set for intersection.\r\n * @param range range to intersect\r\n */\r\n public static rangeOfConvexClipPlaneSetIntersectionWithRange(convexSet: ConvexClipPlaneSet, range: Range3d): Range3d {\r\n const result = Range3d.createNull();\r\n this.announceLoopsOfConvexClipPlaneSetIntersectRange(convexSet, range,\r\n (points: GrowableXYZArray) => {\r\n if (points.length > 0) result.extendArray(points);\r\n },\r\n true, true, false);\r\n return result;\r\n }\r\n /**\r\n * Return the range of various types of clippers\r\n * * `ConvexClipPlaneSet` -- dispatch to `rangeOfConvexClipPlaneSetIntersectionWithRange`\r\n * * `UnionOfConvexClipPlaneSet` -- union of ranges of member `ConvexClipPlaneSet`\r\n * * `ClipPrimitive` -- access its `UnionOfConvexClipPlaneSet`.\r\n * * `ClipVector` -- intersection of the ranges of its `ClipPrimitive`.\r\n * * `undefined` -- entire input range.\r\n * * If `observeInvisibleFlag` is false, the \"invisible\" properties are ignored, and this effectively returns the range of the edge work of the members\r\n * * If `observeInvisibleFlag` is false, the \"invisible\" properties are observed, and \"invisible\" parts do not restrict the range.\r\n * @param clipper\r\n * @param range non-null range.\r\n * @param observeInvisibleFlag indicates how \"invisible\" bit is applied for ClipPrimitive.\r\n */\r\n public static rangeOfClipperIntersectionWithRange(clipper: ConvexClipPlaneSet | UnionOfConvexClipPlaneSets | ClipPrimitive | ClipVector | undefined, range: Range3d, observeInvisibleFlag: boolean = true): Range3d {\r\n if (clipper === undefined)\r\n return range.clone();\r\n if (clipper instanceof ConvexClipPlaneSet)\r\n return this.rangeOfConvexClipPlaneSetIntersectionWithRange(clipper, range);\r\n if (clipper instanceof UnionOfConvexClipPlaneSets) {\r\n const rangeUnion = Range3d.createNull();\r\n for (const c of clipper.convexSets) {\r\n const rangeC = this.rangeOfConvexClipPlaneSetIntersectionWithRange(c, range);\r\n rangeUnion.extendRange(rangeC);\r\n }\r\n return rangeUnion;\r\n }\r\n if (clipper instanceof ClipPrimitive) {\r\n if (observeInvisibleFlag && clipper.invisible)\r\n return range.clone();\r\n return this.rangeOfClipperIntersectionWithRange(clipper.fetchClipPlanesRef(), range);\r\n }\r\n if (clipper instanceof ClipVector) {\r\n const rangeIntersection = range.clone();\r\n for (const c of clipper.clips) {\r\n if (observeInvisibleFlag && c.invisible) {\r\n // trivial range tests do not expose the effects. Assume the hole allows everything.\r\n } else {\r\n const rangeC = this.rangeOfClipperIntersectionWithRange(c, range, observeInvisibleFlag);\r\n rangeIntersection.intersect(rangeC, rangeIntersection);\r\n }\r\n }\r\n return rangeIntersection;\r\n\r\n }\r\n return range.clone();\r\n }\r\n /**\r\n * Test if various types of clippers have any intersection with a range.\r\n * * This follows the same logic as `rangeOfClipperIntersectionWithRange` but attempts to exit at earliest point of confirmed intersection\r\n * * `ConvexClipPlaneSet` -- dispatch to `doesConvexClipPlaneSetIntersectRange`\r\n * * `UnionOfConvexClipPlaneSet` -- union of ranges of member `ConvexClipPlaneSet`\r\n * * `ClipPrimitive` -- access its `UnionOfConvexClipPlaneSet`.\r\n * * `ClipVector` -- intersection of the ranges of its `ClipPrimitive`.\r\n * * `undefined` -- entire input range.\r\n * * If `observeInvisibleFlag` is false, the \"invisible\" properties are ignored, and holes do not affect the result.\r\n * * If `observeInvisibleFlag` is true, the \"invisible\" properties are observed, and may affect the result.\r\n * @param clipper\r\n * @param range non-null range.\r\n * @param observeInvisibleFlag indicates how \"invisible\" bit is applied for ClipPrimitive.\r\n */\r\n public static doesClipperIntersectRange(clipper: ConvexClipPlaneSet | UnionOfConvexClipPlaneSets | ClipPrimitive | ClipVector | undefined, range: Range3d, observeInvisibleFlag: boolean = true): boolean {\r\n if (clipper === undefined)\r\n return true;\r\n\r\n if (clipper instanceof ConvexClipPlaneSet)\r\n return this.doesConvexClipPlaneSetIntersectRange(clipper, range);\r\n\r\n if (clipper instanceof UnionOfConvexClipPlaneSets) {\r\n for (const c of clipper.convexSets) {\r\n if (this.doesConvexClipPlaneSetIntersectRange(c, range))\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n if (clipper instanceof ClipPrimitive) {\r\n if (observeInvisibleFlag && clipper.invisible) // um is there an easy way to detect range-completely-inside?\r\n return true;\r\n return this.doesClipperIntersectRange(clipper.fetchClipPlanesRef(), range);\r\n }\r\n\r\n if (clipper instanceof ClipVector) {\r\n const rangeIntersection = range.clone();\r\n for (const c of clipper.clips) {\r\n if (observeInvisibleFlag && c.invisible) {\r\n // trivial range tests do not expose the effects. Assume the hole allows everything.\r\n } else {\r\n const rangeC = this.rangeOfClipperIntersectionWithRange(c, range, observeInvisibleFlag);\r\n rangeIntersection.intersect(rangeC, rangeIntersection);\r\n }\r\n }\r\n return !rangeIntersection.isNull;\r\n }\r\n /** If the case statement above is complete for the variant inputs, this is unreachable .. */\r\n return false;\r\n }\r\n /**\r\n * Emit point loops for intersection of a convex set with a range.\r\n * * return zero length array for (a) null range or (b) no intersections\r\n * @param range range to intersect\r\n * @param includeConvexSetFaces if false, do not compute facets originating as convex set planes.\r\n * @param includeRangeFaces if false, do not compute facets originating as range faces\r\n * @param ignoreInvisiblePlanes if true, do NOT compute a facet for convex set faces marked invisible.\r\n */\r\n public static doesConvexClipPlaneSetIntersectRange(convexSet: ConvexClipPlaneSet, range: Range3d,\r\n includeConvexSetFaces: boolean = true, includeRangeFaces: boolean = true, ignoreInvisiblePlanes = false): boolean {\r\n const work = new GrowableXYZArray();\r\n if (includeConvexSetFaces) {\r\n // Clip convexSet planes to the range and to the rest of the convexSet . .\r\n for (const plane of convexSet.planes) {\r\n if (ignoreInvisiblePlanes && plane.invisible)\r\n continue;\r\n const pointsClippedToRange = plane.intersectRange(range, true);\r\n if (pointsClippedToRange) {\r\n const finalPoints = new GrowableXYZArray();\r\n convexSet.polygonClip(pointsClippedToRange, finalPoints, work, plane);\r\n if (finalPoints.length > 0)\r\n return true;\r\n }\r\n }\r\n }\r\n\r\n if (includeRangeFaces) {\r\n // clip range faces to the convex set . . .\r\n const corners = range.corners();\r\n for (let i = 0; i < 6; i++) {\r\n const indices = Range3d.faceCornerIndices(i);\r\n const finalPoints = new GrowableXYZArray();\r\n const lineString = LineString3d.createIndexedPoints(corners, indices);\r\n convexSet.polygonClip(lineString.packedPoints, finalPoints, work);\r\n if (finalPoints.length > 0)\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n /**\r\n * Test if `obj` is a `Clipper` object.\r\n * * This is implemented by testing for each of the methods in the `Clipper` interface.\r\n */\r\n public static isClipper(obj: any): boolean {\r\n if (obj) {\r\n if (obj.isPointOnOrInside\r\n && obj.announceClippedSegmentIntervals\r\n && obj.announceClippedArcIntervals)\r\n return true;\r\n }\r\n return false;\r\n }\r\n /**\r\n * Specialized logic for replacing clip fragments by an equivalent singleton.\r\n * * If there are baseCount + 1 or fewer fragments, do nothing.\r\n * * If there are more than baseCount+1 fragments:\r\n * * drop them all to the cache\r\n * * push a copy of the singleton.\r\n * * The use case for this is that a multi-step clipper (e.g. UnionOfConvexClipPlaneSets) may produce many fragments, and then be able to determine\r\n * that they really are the original pre-clip polygon unchanged.\r\n * * The baseCount+1 case is the case where the entire original singleton is still a singleton and can be left alone.\r\n * * Calling this replacer shuffles the original back into the fragment array, and drops the fragments.\r\n * * This determination is solely within the logic of the caller.\r\n * @param shards array of fragments\r\n * @param baseCount original count\r\n * @param singleton single array which may be a replacement for multiple fragments\r\n * @param cache cache for array management\r\n */\r\n public static restoreSingletonInPlaceOfMultipleShards(fragments: GrowableXYZArray[] | undefined, baseCount: number, singleton: GrowableXYZArray, arrayCache: GrowableXYZArrayCache) {\r\n if (fragments && fragments.length > baseCount + 1) {\r\n while (fragments.length > baseCount) {\r\n const f = fragments.pop();\r\n arrayCache.dropToCache(f);\r\n }\r\n fragments.push(arrayCache.grabAndFill(singleton));\r\n }\r\n }\r\n\r\n /**\r\n * Create a UnionOfConvexClipPlaneSets for a volume defined by a path and offsets.\r\n * @param points points along the path.\r\n * @param positiveOffsetLeft offset to left. 0 is clip on the path.\r\n * @param positiveOffsetRight offset to the right. 0 is clip on the path.\r\n * @param z0 z for lower clipping plane. If undefined, unbounded in positive z\r\n * @param z1 z for upper clipping plane. If undefined, unbounded in negative z.\r\n * @alpha\r\n */\r\n public static createXYOffsetClipFromLineString(points: Point3d[] | IndexedXYZCollection,\r\n leftOffset: number, rightOffset: number, z0: number, z1: number): UnionOfConvexClipPlaneSets {\r\n if (Array.isArray(points)) {\r\n return LineStringOffsetClipperContext.createClipBetweenOffsets(\r\n new Point3dArrayCarrier(points), leftOffset, rightOffset, z0, z1);\r\n }\r\n return LineStringOffsetClipperContext.createClipBetweenOffsets(points, leftOffset, rightOffset, z0, z1);\r\n }\r\n /** if data.length >= minLength threshold, push it to destination; if smaller drop it back to the cache.\r\n */\r\n public static captureOrDrop(data: GrowableXYZArray, minLength: number, destination: GrowableXYZArray[], cache: GrowableXYZArrayCache) {\r\n if (data.length >= minLength)\r\n destination.push(data);\r\n else\r\n cache.dropToCache(data);\r\n }\r\n /**\r\n * Find the portion of a line within a half-plane clip.\r\n * * The half-plane clip is to the left of the line from clipA to clipB.\r\n * * The original clipped segment has fractions 0 and 1 at respective segment points.\r\n * * Caller initializes the interval\r\n * * This method reduces the interval size.\r\n * * See clipSegmentToCCWTriangleXY for typical use.\r\n * @param linePointA First point of clip line\r\n * @param linePointB Second point of clip line\r\n * @param segmentPoint0 First point of clipped segment\r\n * @param segmentPoint1 Second point of clipped segment\r\n * @param interval Live interval.\r\n * @param absoluteTolerance absolute tolerance for both cross product values to indicate \"on\" the line\r\n */\r\n public static clipSegmentToLLeftOfLineXY(linePointA: XAndY, linePointB: XAndY, segmentPoint0: XAndY, segmentPoint1: XAndY, interval: Range1d,\r\n absoluteTolerance: number = 1.0e-14) {\r\n const ux = linePointB.x - linePointA.x;\r\n const uy = linePointB.y - linePointA.y;\r\n // negative is in positive is out ...\r\n const h0 = -(ux * (segmentPoint0.y - linePointA.y) - uy * (segmentPoint0.x - linePointA.x));\r\n const h1 = -(ux * (segmentPoint1.y - linePointA.y) - uy * (segmentPoint1.x - linePointA.x));\r\n if (h0 < absoluteTolerance && h1 < absoluteTolerance) {\r\n // The entire segment is in .....\r\n return;\r\n }\r\n if (h0 * h1 > 0.0) {\r\n if (h0 > 0.0)\r\n interval.setNull();\r\n } else if (h0 * h1 < 0.0) {\r\n // strict crossing with safe fraction . . .\r\n const fraction = -h0 / (h1 - h0);\r\n if (h0 < 0.0) {\r\n return interval.intersectRangeXXInPlace(0.0, fraction);\r\n } else {\r\n return interval.intersectRangeXXInPlace(fraction, 1.0);\r\n }\r\n } else {\r\n // There is an exact hit at one end, possibly non-zero at the other ... the sign of either determines which side is in play\r\n // A zero and a zero or negative is entirely in, which does not alter the prior clip.\r\n if (h0 > 0.0) {\r\n interval.intersectRangeXXInPlace(1.0, 1.0);\r\n } else if (h1 > 0.0) {\r\n interval.intersectRangeXXInPlace(0.0, 0.0);\r\n }\r\n }\r\n }\r\n /**\r\n * Clip an interval of a line segment to a triangle.\r\n * * Triangle is assumed CCW\r\n * @param pointA point of triangle.\r\n * @param pointB point of triangle.\r\n * @param pointC point of triangle.\r\n * @param segment0 start of segment\r\n * @param segment1 end of segment\r\n * @param interval Pre-initialized interval of live part of segment\r\n * @param absoluteTolerance absolute tolerance for begin \"on a line\"\r\n */\r\n public static clipSegmentToCCWTriangleXY(pointA: XAndY, pointB: XAndY, pointC: XAndY, segment0: XAndY, segment1: XAndY, interval: Range1d,\r\n absoluteTolerance: number = 1.0e-14) {\r\n if (!interval.isNull) {\r\n this.clipSegmentToLLeftOfLineXY(pointA, pointB, segment0, segment1, interval, absoluteTolerance);\r\n if (!interval.isNull) {\r\n this.clipSegmentToLLeftOfLineXY(pointB, pointC, segment0, segment1, interval, absoluteTolerance);\r\n if (!interval.isNull) {\r\n this.clipSegmentToLLeftOfLineXY(pointC, pointA, segment0, segment1, interval, absoluteTolerance);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Find the portion of a line within a half-plane clip.\r\n * * The half-plane clip is to the left of the line from clipA to clipB.\r\n * * The original clipped segment has fractions 0 and 1 at respective segment points.\r\n * * Caller initializes the interval\r\n * * This method reduces the interval size.\r\n * * See clipSegmentToCCWTriangleXY for typical use.\r\n * @param linePointA First point of clip line\r\n * @param linePointB Second point of clip line\r\n * @param segmentPoint0 First point of clipped segment\r\n * @param segmentPoint1 Second point of clipped segment\r\n * @param interval Live interval.\r\n * @param absoluteTolerance absolute tolerance for both cross product values to indicate \"on\" the line\r\n */\r\n public static clipSegmentBelowPlaneXY(plane: Plane3dByOriginAndUnitNormal, segmentPoint0: XAndY, segmentPoint1: XAndY, interval: Range1d,\r\n absoluteTolerance: number = 1.0e-14) {\r\n // negative is in positive is out ...\r\n const h0 = plane.altitudeXY(segmentPoint0.x, segmentPoint0.y);\r\n const h1 = plane.altitudeXY(segmentPoint1.x, segmentPoint1.y);\r\n if (h0 < absoluteTolerance && h1 < absoluteTolerance) {\r\n // The entire segment is in ..... the interval is unaffected.\r\n return;\r\n }\r\n if (h0 * h1 > 0.0) {\r\n if (h0 > 0.0)\r\n interval.setNull();\r\n } else if (h0 * h1 < 0.0) {\r\n // strict crossing with safe fraction . . .\r\n const fraction = -h0 / (h1 - h0);\r\n if (h0 < 0.0) {\r\n return interval.intersectRangeXXInPlace(0.0, fraction);\r\n } else {\r\n return interval.intersectRangeXXInPlace(fraction, 1.0);\r\n }\r\n } else {\r\n // There is an exact hit at one end, possibly non-zero at the other ... the sign of either determines which side is in play\r\n // A zero and a zero or negative is entirely in, which does not alter the prior clip.\r\n if (h0 > 0.0) {\r\n interval.intersectRangeXXInPlace(1.0, 1.0);\r\n } else if (h1 > 0.0) {\r\n interval.intersectRangeXXInPlace(0.0, 0.0);\r\n }\r\n }\r\n }\r\n /**\r\n * Clip an interval of a line segment to an array of planes\r\n * * plane normals assumed OUTWARD\r\n * * planeAltitude is typically a tolerance a tolerance distance.\r\n * * positive altitude makes tha plane move in the direction of the unit normal.\r\n * @param planes array of planes\r\n * @param segment0 start of segment\r\n * @param segment1 end of segment\r\n * @param interval Pre-initialized interval of live part of segment\r\n * @param absoluteTolerance absolute tolerance for begin \"on a line\"\r\n */\r\n public static clipSegmentBelowPlanesXY(planes: Plane3dByOriginAndUnitNormal[], segment0: XAndY, segment1: XAndY, interval: Range1d,\r\n signedAltitude: number = 1.0e-14) {\r\n const numPlanes = planes.length;\r\n for (let i = 0; (!interval.isNull) && i < numPlanes; i++) {\r\n this.clipSegmentBelowPlaneXY(planes[i], segment0, segment1, interval, signedAltitude);\r\n }\r\n }\r\n /**\r\n * Pass line segments from a polyline to the clipper. Resolve the fractional clips to simple points for announcement.\r\n * @param clipper clipper to call\r\n * @param points polyline whose segments are passed to the clipper\r\n * @param announce caller's handler for simple point pairs.\r\n */\r\n public static announcePolylineClip(clipper: Clipper, points: Point3d[], announce: (point0: Point3d, point1: Point3d) => void) {\r\n for (let i = 0; i + 1 < points.length; i++) {\r\n clipper.announceClippedSegmentIntervals(0, 1, points[i], points[i + 1],\r\n (f0: number, f1: number) => {\r\n announce(points[i].interpolate(f0, points[i + 1]), points[i].interpolate(f1, points[i + 1]));\r\n });\r\n }\r\n }\r\n /**\r\n * Pass line segments from a polyline to the clipper. Sum the lengths of the clipped pieces. Return the sum.\r\n * @param clipper clipper to call\r\n * @param points polyline whose segments are passed to the clipper\r\n */\r\n public static sumPolylineClipLength(clipper: Clipper, points: Point3d[]) {\r\n let s = 0;\r\n for (let i = 0; i + 1 < points.length; i++) {\r\n const a = points[i].distance(points[i + 1]);\r\n clipper.announceClippedSegmentIntervals(0, 1, points[i], points[i + 1],\r\n (f0: number, f1: number) => { s += Math.abs(f1 - f0) * a; });\r\n }\r\n return s;\r\n }\r\n /**\r\n * Pass polygon `xyz` through a sequence of PolygonClip steps.\r\n * * At the outset, `xyz` is the (only) entry in a set of candidates.\r\n * * For each clipper, each candidate is presented for appendPolygon to inside and outside parts.\r\n * * Each (in,out) result is distributed among (acceptedIn, acceptedOut, candidates) according to\r\n * (inAction, outAction)\r\n * * At the end, all remaining candidates are distributed among (acceptedIn, acceptedOut, finalUnknown)\r\n * according to finalAction\r\n * * Any clipper that does not have an appendPolygonClip method is skipped.\r\n * @param xyz\r\n * @param clippers\r\n * @param acceptedIn\r\n * @param acceptedOut\r\n * @param finalCandidates\r\n * @param inAction\r\n * @param outAction\r\n * @param finalCandidateAction\r\n */\r\n public static doPolygonClipSequence(\r\n xyz: GrowableXYZArray,\r\n clippers: Clipper[],\r\n acceptedIn: GrowableXYZArray[] | undefined,\r\n acceptedOut: GrowableXYZArray[] | undefined,\r\n finalCandidates: GrowableXYZArray[] | undefined,\r\n inAction: ClipStepAction,\r\n outAction: ClipStepAction,\r\n finalFragmentAction: ClipStepAction,\r\n arrayCache: GrowableXYZArrayCache | undefined\r\n ) {\r\n if (arrayCache === undefined)\r\n arrayCache = new GrowableXYZArrayCache();\r\n let candidates = [arrayCache.grabAndFill(xyz)];\r\n let nextCandidates: GrowableXYZArray[] = [];\r\n const intermediateIn: GrowableXYZArray[] = [];\r\n const intermediateOut: GrowableXYZArray[] = [];\r\n const oldInsideCount = acceptedIn ? acceptedIn.length : 0;\r\n const oldOutsideCount = acceptedOut ? acceptedOut.length : 0;\r\n let shard;\r\n // At each convex set, carryForwardA is all the fragments that have been outside all previous convex sets.\r\n // Clip each such fragment to the current set, sending the outside parts to carryForwardB, which will got to the next clipper\r\n // The final surviving carryForward really is out.\r\n for (const c of clippers) {\r\n if (c.appendPolygonClip) {\r\n while (undefined !== (shard = candidates.pop())) {\r\n c.appendPolygonClip(shard, intermediateIn, intermediateOut, arrayCache);\r\n distributeFragments(inAction, intermediateIn, acceptedIn, acceptedOut, nextCandidates, arrayCache);\r\n distributeFragments(outAction, intermediateOut, acceptedIn, acceptedOut, nextCandidates, arrayCache);\r\n arrayCache.dropToCache(shard);\r\n }\r\n // candidates is empty !!\r\n const temp = candidates; candidates = nextCandidates; nextCandidates = temp;\r\n }\r\n }\r\n distributeFragments(finalFragmentAction, candidates, acceptedIn, acceptedOut, finalCandidates, arrayCache);\r\n // Note: The following assumes that there were no residual candidates ... need to track if that happened?\r\n // If nothing was out, the inside fragments can be replaced by the original.\r\n if (acceptedOut?.length === oldOutsideCount)\r\n ClipUtilities.restoreSingletonInPlaceOfMultipleShards(acceptedIn, oldInsideCount, xyz, arrayCache);\r\n // If nothing was in, the outside fragments can be replaced by the original.\r\n if (acceptedIn?.length === oldInsideCount)\r\n ClipUtilities.restoreSingletonInPlaceOfMultipleShards(acceptedOut, oldOutsideCount, xyz, arrayCache);\r\n }\r\n /**\r\n * Pass polygon `xyz` through a sequence of PolygonClip steps with \"parity\" rules\r\n */\r\n public static doPolygonClipParitySequence(\r\n xyz: GrowableXYZArray,\r\n clippers: Clipper[],\r\n acceptedIn: GrowableXYZArray[] | undefined,\r\n acceptedOut: GrowableXYZArray[] | undefined,\r\n arrayCache: GrowableXYZArrayCache | undefined\r\n ) {\r\n if (arrayCache === undefined)\r\n arrayCache = new GrowableXYZArrayCache();\r\n let candidatesOut = [arrayCache.grabAndFill(xyz)];\r\n let candidatesIn: GrowableXYZArray[] = [];\r\n let nextCandidatesIn: GrowableXYZArray[] = [];\r\n let nextCandidatesOut: GrowableXYZArray[] = [];\r\n const intermediateIn: GrowableXYZArray[] = [];\r\n const intermediateOut: GrowableXYZArray[] = [];\r\n let shard;\r\n // at each step ..\r\n // candidatesIn and candidatesOut are evolved in and out\r\n // nextCandidatesIn and nextCandidatesOut are EMPTY\r\n for (const c of clippers) {\r\n if (c.appendPolygonClip) {\r\n // (IN,OUT) parts of IN parts distribute to (OUT,IN)\r\n while (undefined !== (shard = candidatesIn.pop())) {\r\n c.appendPolygonClip(shard, intermediateIn, intermediateOut, arrayCache);\r\n distributeFragments(ClipStepAction.acceptOut, intermediateIn, nextCandidatesIn, nextCandidatesOut, undefined, arrayCache);\r\n distributeFragments(ClipStepAction.acceptIn, intermediateOut, nextCandidatesIn, nextCandidatesOut, undefined, arrayCache);\r\n arrayCache.dropToCache(shard);\r\n }\r\n // (IN,OUT) parts of IN parts distribute to (OUT,IN)\r\n while (undefined !== (shard = candidatesOut.pop())) {\r\n c.appendPolygonClip(shard, intermediateIn, intermediateOut, arrayCache);\r\n distributeFragments(ClipStepAction.acceptIn, intermediateIn, nextCandidatesIn, nextCandidatesOut, undefined, arrayCache);\r\n distributeFragments(ClipStepAction.acceptOut, intermediateOut, nextCandidatesIn, nextCandidatesOut, undefined, arrayCache);\r\n arrayCache.dropToCache(shard);\r\n }\r\n // reload each candidate step\r\n const tempA = candidatesIn; candidatesIn = nextCandidatesIn; nextCandidatesIn = tempA;\r\n const tempB = candidatesOut; candidatesOut = nextCandidatesOut; nextCandidatesOut = tempB;\r\n }\r\n }\r\n // candidatesIn and candidatesOut are final ....\r\n if (candidatesOut.length === 0)\r\n acceptedIn?.push(arrayCache.grabAndFill(xyz));\r\n else if (candidatesOut.length === 0)\r\n acceptedOut?.push(arrayCache.grabAndFill(xyz));\r\n else {\r\n moveFragments(candidatesIn, acceptedIn, arrayCache);\r\n moveFragments(candidatesOut, acceptedOut, arrayCache);\r\n }\r\n }\r\n}\r\nfunction moveFragments(\r\n fragments: GrowableXYZArray[],\r\n destination: GrowableXYZArray[] | undefined,\r\n arrayCache: GrowableXYZArrayCache) {\r\n if (destination === undefined)\r\n arrayCache.dropAllToCache(fragments);\r\n else {\r\n for (const f of fragments)\r\n destination.push(f);\r\n }\r\n fragments.length = 0;\r\n}\r\n/**\r\n * Distribute fragments among acceptedIn, acceptedOut, and passToNextStep as directed by action.\r\n * * If the indicated destination is unknown, drop the fragments to the arrayCache.\r\n * @param action destination selector\r\n * @param fragments fragments to be distributed\r\n * @param acceptedIn destination for \"in\"\r\n * @param acceptedOut destination for \"out\"\r\n * @param passToNextStep destination for fragments to be passed to a later step\r\n * @param arrayCache destination for un-distributed fragments.\r\n */\r\nfunction distributeFragments(\r\n action: ClipStepAction,\r\n fragments: GrowableXYZArray[],\r\n acceptedIn: GrowableXYZArray[] | undefined,\r\n acceptedOut: GrowableXYZArray[] | undefined,\r\n passToNextStep: GrowableXYZArray[] | undefined,\r\n arrayCache: GrowableXYZArrayCache) {\r\n let destination;\r\n if (action === ClipStepAction.acceptIn)\r\n destination = acceptedIn;\r\n else if (action === ClipStepAction.acceptOut)\r\n destination = acceptedOut;\r\n else if (action === ClipStepAction.passToNextStep)\r\n destination = passToNextStep;\r\n// remark: if action is other than the enum values, destination is undefined\r\n if (destination === undefined)\r\n arrayCache.dropAllToCache(fragments);\r\n else {\r\n for (const f of fragments)\r\n destination.push(f);\r\n }\r\n fragments.length = 0;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ClipUtils.js","sourceRoot":"","sources":["../../../src/clipping/ClipUtils.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAKH,wDAAqD;AACrD,wCAAqC;AACrC,0CAAuC;AAEvC,qEAAkE;AAClE,mEAAkE;AAClE,+CAAuD;AACvD,2CAAwC;AACxC,mDAAgD;AAChD,6CAA0C;AAC1C,6DAA0D;AAC1D,6EAA0E;AAC1E,2EAA0E;AAE1E,sGAAmG;AACnG,2EAAwE;AAGxE,wDAAqD;AAErD;;GAEG;AACH,IAAY,oBAOX;AAPD,WAAY,oBAAoB;IAC9B,wBAAwB;IACxB,mFAAkB,CAAA;IAClB,oCAAoC;IACpC,yEAAa,CAAA;IACb,yBAAyB;IACzB,qFAAmB,CAAA;AACrB,CAAC,EAPW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAO/B;AACD;;;GAGG;AACH,IAAY,cAOT;AAPH,WAAY,cAAc;IACxB,2DAA2D;IAC3D,2DAAY,CAAA;IACZ,4DAA4D;IAC5D,8DAAc,CAAA;IAChB,6CAA6C;IAC3C,uEAAkB,CAAA;AAClB,CAAC,EAPS,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAOvB;AAEH;;GAEG;AACH,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,kDAAkD;IAClD,2DAAY,CAAA;IACZ,kCAAkC;IAClC,6DAAa,CAAA;IACb,iCAAiC;IACjC,6DAAa,CAAA;AACf,CAAC,EAPW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAOrB;AAyDD;;GAEG;AACH,MAAa,aAAa;IAExB;;;;;OAKG;IACI,MAAM,CAAC,iBAAi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CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACvB;IACD,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;AACvB,CAAC","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 CartesianGeometry\r\n */\r\n\r\nimport { Arc3d } from \"../curve/Arc3d\";\r\nimport { AnnounceNumberNumber, AnnounceNumberNumberCurvePrimitive, CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { GeometryQuery } from \"../curve/GeometryQuery\";\r\nimport { LineString3d } from \"../curve/LineString3d\";\r\nimport { Loop } from \"../curve/Loop\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GrowableFloat64Array } from \"../geometry3d/GrowableFloat64Array\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Range1d, Range3d } from \"../geometry3d/Range\";\r\nimport { ClipPlane } from \"./ClipPlane\";\r\nimport { ClipPrimitive } from \"./ClipPrimitive\";\r\nimport { ClipVector } from \"./ClipVector\";\r\nimport { ConvexClipPlaneSet } from \"./ConvexClipPlaneSet\";\r\nimport { UnionOfConvexClipPlaneSets } from \"./UnionOfConvexClipPlaneSets\";\r\nimport { GrowableXYZArrayCache } from \"../geometry3d/ReusableObjectCache\";\r\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { LineStringOffsetClipperContext } from \"./internalContexts/LineStringOffsetClipperContext\";\r\nimport { Point3dArrayCarrier } from \"../geometry3d/Point3dArrayCarrier\";\r\nimport { XAndY } from \"../geometry3d/XYZProps\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport { CurveFactory } from \"../curve/CurveFactory\";\r\n\r\n/** Enumerated type for describing where geometry lies with respect to clipping planes.\r\n * @public\r\n */\r\nexport enum ClipPlaneContainment {\r\n /** All points inside */\r\n StronglyInside = 1,\r\n /** Inside/outside state unknown. */\r\n Ambiguous = 2,\r\n /** All points outside */\r\n StronglyOutside = 3,\r\n}\r\n/**\r\n * Enumeration of ways to handle an intermediate fragment from a clipping step\r\n * @public\r\n */\r\nexport enum ClipStepAction {\r\n /** Pass fragments directly to final accepted \"in\" state */\r\n acceptIn = 1,\r\n /** Pass fragments directly to final accepted \"out\" state */\r\n acceptOut = -1,\r\n/** forward fragments to subsequent steps. */\r\n passToNextStep = 0\r\n }\r\n\r\n/** Enumerated type for describing what must yet be done to clip a piece of geometry.\r\n * @public\r\n */\r\nexport enum ClipStatus {\r\n /** some geometry may cross the clip boundaries */\r\n ClipRequired,\r\n /** geometry is clearly outside */\r\n TrivialReject,\r\n /** geometry is clearly inside */\r\n TrivialAccept,\r\n}\r\n\r\n/** An object containing clipping planes that can be used to clip geometry.\r\n * @public\r\n */\r\nexport interface Clipper {\r\n /** test if `point` is on or inside the Clipper's volume. */\r\n isPointOnOrInside(point: Point3d, tolerance?: number): boolean;\r\n /** Find the parts of the line segment (if any) that is within the convex clip volume.\r\n * * The input fractional interval from fraction0 to fraction1 (increasing!!) is the active part to consider.\r\n * * To clip to the usual bounded line segment, start with fractions (0,1).\r\n * If the clip volume is unbounded, the line interval may also be unbounded.\r\n * * An unbounded line portion will have fraction coordinates positive or negative Number.MAX_VALUE.\r\n * @param f0 fraction that is the initial lower fraction of the active interval. (e.g. 0.0 for bounded segment)\r\n * @param f1 fraction that is the initial upper fraction of the active interval. (e.g. 1.0 for bounded segment)\r\n * @param pointA segment start (fraction 0)\r\n * @param pointB segment end (fraction 1)\r\n * @param announce function to be called to announce a fraction interval that is within the convex clip volume.\r\n * @returns true if a segment was announced, false if entirely outside.\r\n */\r\n announceClippedSegmentIntervals(f0: number, f1: number, pointA: Point3d, pointB: Point3d, announce?: AnnounceNumberNumber): boolean;\r\n /** Find the portion (or portions) of the arc (if any) that are within the convex clip volume.\r\n * * The input fractional interval from fraction0 to fraction1 (increasing!!) is the active part to consider.\r\n * @param announce function to be called to announce a fraction interval that is within the convex clip volume.\r\n * @returns true if one or more arcs portions were announced, false if entirely outside.\r\n */\r\n announceClippedArcIntervals(arc: Arc3d, announce?: AnnounceNumberNumberCurvePrimitive): boolean;\r\n/** Optional polygon clip method.\r\n * * This is expected to be implemented by planar clip structures.\r\n * * This is unimplemented for curve clippers (e.g. sphere) for which polygon clip result has\r\n * curved edges.\r\n */\r\n appendPolygonClip?: AppendPolygonClipFunction;\r\n}\r\n /**\r\n * Signature of method to execute polygon clip, distributing fragments of xyz among insideFragments and outsideFragments\r\n * @param xyz input polygon. This is not changed.\r\n * @param insideFragments Array to receive \"inside\" fragments. Each fragment is a GrowableXYZArray grabbed from the cache. This is NOT cleared.\r\n * @param outsideFragments Array to receive \"outside\" fragments. Each fragment is a GrowableXYZArray grabbed from the cache. This is NOT cleared.\r\n * @param arrayCache cache for reusable GrowableXYZArray.\r\n */\r\n type AppendPolygonClipFunction = (\r\n xyz: GrowableXYZArray,\r\n insideFragments: GrowableXYZArray[],\r\n outsideFragments: GrowableXYZArray[],\r\n arrayCache: GrowableXYZArrayCache) => void;\r\n\r\n/**\r\n * Interface for clipping polygons.\r\n * Supported by:\r\n * * AlternatingCCTreeNode\r\n * * ConvexClipPlaneSet\r\n * @public\r\n */\r\nexport interface PolygonClipper {\r\n appendPolygonClip: AppendPolygonClipFunction;\r\n}\r\n/** Static class whose various methods are functions for clipping geometry\r\n * @public\r\n */\r\nexport class ClipUtilities {\r\n private static _selectIntervals01TestPoint = Point3d.create();\r\n /**\r\n * * Augment the unsortedFractionsArray with 0 and 1\r\n * * sort\r\n * * test the midpoint of each interval with `clipper.isPointOnOrInside`\r\n * * pass accepted intervals to `announce(f0,f1,curve)`\r\n */\r\n public static selectIntervals01(curve: CurvePrimitive, unsortedFractions: GrowableFloat64Array, clipper: Clipper, announce?: AnnounceNumberNumberCurvePrimitive): boolean {\r\n unsortedFractions.push(0);\r\n unsortedFractions.push(1);\r\n unsortedFractions.sort();\r\n let f0 = unsortedFractions.atUncheckedIndex(0);\r\n let f1;\r\n let fMid;\r\n const testPoint = ClipUtilities._selectIntervals01TestPoint;\r\n const n = unsortedFractions.length;\r\n for (let i = 1; i < n; i++) {\r\n f1 = unsortedFractions.atUncheckedIndex(i);\r\n if (f1 > f0 + Geometry.smallFraction) {\r\n fMid = 0.5 * (f0 + f1);\r\n if (fMid >= 0.0 && fMid <= 1.0) {\r\n curve.fractionToPoint(fMid, testPoint);\r\n if (clipper.isPointOnOrInside(testPoint)) {\r\n if (announce)\r\n announce(f0, f1, curve);\r\n else\r\n return true;\r\n }\r\n }\r\n f0 = f1;\r\n }\r\n }\r\n return false;\r\n }\r\n /**\r\n * Announce triples of (low, high, cp) for each entry in intervals\r\n * @param intervals source array\r\n * @param cp CurvePrimitive for announcement\r\n * @param announce function to receive data\r\n */\r\n public static announceNNC(intervals: Range1d[], cp: CurvePrimitive, announce?: AnnounceNumberNumberCurvePrimitive): boolean {\r\n if (announce) {\r\n for (const ab of intervals) {\r\n announce(ab.low, ab.high, cp);\r\n }\r\n }\r\n return intervals.length > 0;\r\n }\r\n\r\n /** Find portions of the curve that are within the clipper.\r\n * Collect them into an array of curve primitives.\r\n */\r\n public static collectClippedCurves(curve: CurvePrimitive, clipper: Clipper): CurvePrimitive[] {\r\n const result: CurvePrimitive[] = [];\r\n curve.announceClipIntervals(clipper,\r\n (fraction0: number, fraction1: number, curveA: CurvePrimitive) => {\r\n if (fraction1 !== fraction0) {\r\n const partialCurve = curveA.clonePartialCurve(fraction0, fraction1);\r\n if (partialCurve)\r\n result.push(partialCurve);\r\n }\r\n });\r\n return result;\r\n }\r\n\r\n /**\r\n * Clip a polygon down to regions defined by each shape of a ClipShape.\r\n * @return An multidimensional array of points, where each array is the boundary of part of the remaining polygon.\r\n */\r\n public static clipPolygonToClipShape(polygon: Point3d[], clipShape: ClipPrimitive): Point3d[][] {\r\n const outputA = this.clipPolygonToClipShapeReturnGrowableXYZArrays(polygon, clipShape);\r\n const output = [];\r\n for (const g of outputA)\r\n output.push(g.getPoint3dArray());\r\n return output;\r\n }\r\n\r\n /**\r\n * Clip a polygon down to regions defined by each shape of a ClipShape.\r\n * @return An multidimensional array of points, where each array is the boundary of part of the remaining polygon.\r\n */\r\n public static clipPolygonToClipShapeReturnGrowableXYZArrays(polygon: Point3d[], clipShape: ClipPrimitive): GrowableXYZArray[] {\r\n const output: GrowableXYZArray[] = [];\r\n const clipper = clipShape.fetchClipPlanesRef();\r\n // NEEDS WORK -- what if it is a mask !!!!\r\n if (clipper) {\r\n clipper.polygonClip(polygon, output);\r\n }\r\n return output;\r\n }\r\n\r\n /** Given an array of points, test for trivial containment conditions.\r\n * * ClipStatus.TrivialAccept if all points are in any one of the convexSet's.\r\n * * ClipStatus.ClipRequired if (in any single convexSet) there were points on both sides of any single plane.\r\n * * ClipStatus.TrivialReject if neither of those occurred.\r\n */\r\n public static pointSetSingleClipStatus(points: GrowableXYZArray, planeSet: UnionOfConvexClipPlaneSets, tolerance: number): ClipStatus {\r\n if (planeSet.convexSets.length === 0)\r\n return ClipStatus.TrivialAccept;\r\n\r\n for (const convexSet of planeSet.convexSets) {\r\n let allOutsideSinglePlane = false, anyOutside = false;\r\n\r\n for (const plane of convexSet.planes) {\r\n let numInside = 0, numOutside = 0;\r\n const planeDistance = plane.distance - tolerance;\r\n\r\n const currPt = Point3d.create();\r\n const currVec = Vector3d.create();\r\n for (let i = 0; i < points.length; i++) {\r\n points.getPoint3dAtUncheckedPointIndex(i, currPt);\r\n currVec.setFrom(currPt);\r\n currVec.dotProduct(plane.inwardNormalRef) > planeDistance ? numInside++ : numOutside++;\r\n }\r\n\r\n anyOutside = (numOutside !== 0) ? true : anyOutside;\r\n if (numInside === 0) {\r\n allOutsideSinglePlane = true;\r\n break;\r\n }\r\n }\r\n\r\n if (!anyOutside) // totally inside this set - no clip required\r\n return ClipStatus.TrivialAccept;\r\n if (!allOutsideSinglePlane)\r\n return ClipStatus.ClipRequired;\r\n }\r\n return ClipStatus.TrivialReject;\r\n }\r\n\r\n /**\r\n * Emit point loops for intersection of a convex set with a range.\r\n * * return zero length array for (a) null range or (b) no intersections\r\n * @param range range to intersect\r\n * @param includeConvexSetFaces if false, do not compute facets originating as convex set planes.\r\n * @param includeRangeFaces if false, do not compute facets originating as range faces\r\n * @param ignoreInvisiblePlanes if true, do NOT compute a facet for convex set faces marked invisible.\r\n */\r\n public static announceLoopsOfConvexClipPlaneSetIntersectRange(convexSet: ConvexClipPlaneSet | ClipPlane, range: Range3d, loopFunction: (loopPoints: GrowableXYZArray) => void,\r\n includeConvexSetFaces: boolean = true, includeRangeFaces: boolean = true, ignoreInvisiblePlanes = false) {\r\n const work = new GrowableXYZArray();\r\n if (includeConvexSetFaces) {\r\n // Clip convexSet planes to the range and to the rest of the convexSet . .\r\n if (convexSet instanceof ConvexClipPlaneSet) {\r\n for (const plane of convexSet.planes) {\r\n if (ignoreInvisiblePlanes && plane.invisible)\r\n continue;\r\n const pointsClippedToRange = plane.intersectRange(range, true);\r\n const finalPoints = new GrowableXYZArray();\r\n if (pointsClippedToRange) {\r\n convexSet.polygonClip(pointsClippedToRange, finalPoints, work, plane);\r\n if (finalPoints.length > 0)\r\n loopFunction(finalPoints);\r\n }\r\n }\r\n } else { // `convexSet` is just one plane ...\r\n if (ignoreInvisiblePlanes && convexSet.invisible) {\r\n // skip it !\r\n } else {\r\n const pointsClippedToRange = convexSet.intersectRange(range, true);\r\n if (pointsClippedToRange)\r\n loopFunction(pointsClippedToRange);\r\n }\r\n }\r\n }\r\n\r\n if (includeRangeFaces) {\r\n // clip range faces to the convex set . . .\r\n const corners = range.corners();\r\n for (let i = 0; i < 6; i++) {\r\n const indices = Range3d.faceCornerIndices(i);\r\n const finalPoints = new GrowableXYZArray();\r\n const lineString = LineString3d.createIndexedPoints(corners, indices);\r\n if (convexSet instanceof ConvexClipPlaneSet) {\r\n convexSet.polygonClip(lineString.packedPoints, finalPoints, work);\r\n if (finalPoints.length > 0)\r\n loopFunction(finalPoints);\r\n } else {\r\n convexSet.clipConvexPolygonInPlace(lineString.packedPoints, work);\r\n if (lineString.packedPoints.length > 0)\r\n loopFunction(lineString.packedPoints);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Return a (possibly empty) array of geometry (Loops !!) which are facets of the intersection of the convex set intersecting a range.\r\n * * return zero length array for (a) null range or (b) no intersections\r\n * @param allClippers convex or union clipper\r\n * @param range range to intersect\r\n * @param includeConvexSetFaces if false, do not compute facets originating as convex set planes.\r\n * @param includeRangeFaces if false, do not compute facets originating as range faces\r\n * @param ignoreInvisiblePlanes if true, do NOT compute a facet for convex set faces marked invisible.\r\n */\r\n public static loopsOfConvexClipPlaneIntersectionWithRange(allClippers: ConvexClipPlaneSet | UnionOfConvexClipPlaneSets | ClipPlane, range: Range3d,\r\n includeConvexSetFaces: boolean = true, includeRangeFaces: boolean = true, ignoreInvisiblePlanes = false): GeometryQuery[] {\r\n const result: GeometryQuery[] = [];\r\n if (allClippers instanceof UnionOfConvexClipPlaneSets) {\r\n for (const clipper of allClippers.convexSets) {\r\n this.announceLoopsOfConvexClipPlaneSetIntersectRange(clipper, range,\r\n (points: GrowableXYZArray) => {\r\n if (points.length > 0) result.push(Loop.createPolygon(points));\r\n },\r\n includeConvexSetFaces, includeRangeFaces, ignoreInvisiblePlanes);\r\n }\r\n } else if (allClippers instanceof ConvexClipPlaneSet || allClippers instanceof ClipPlane) {\r\n this.announceLoopsOfConvexClipPlaneSetIntersectRange(allClippers, range,\r\n (points: GrowableXYZArray) => {\r\n if (points.length > 0) result.push(Loop.createPolygon(points));\r\n },\r\n includeConvexSetFaces, includeRangeFaces, ignoreInvisiblePlanes);\r\n }\r\n return result;\r\n }\r\n /**\r\n * Return the (possibly null) range of the intersection of the convex set with a range.\r\n * * The convex set is permitted to be unbounded (e.g. a single plane). The range parameter provides bounds.\r\n * @param convexSet convex set for intersection.\r\n * @param range range to intersect\r\n */\r\n public static rangeOfConvexClipPlaneSetIntersectionWithRange(convexSet: ConvexClipPlaneSet, range: Range3d): Range3d {\r\n const result = Range3d.createNull();\r\n this.announceLoopsOfConvexClipPlaneSetIntersectRange(convexSet, range,\r\n (points: GrowableXYZArray) => {\r\n if (points.length > 0) result.extendArray(points);\r\n },\r\n true, true, false);\r\n return result;\r\n }\r\n /**\r\n * Return the range of various types of clippers\r\n * * `ConvexClipPlaneSet` -- dispatch to `rangeOfConvexClipPlaneSetIntersectionWithRange`\r\n * * `UnionOfConvexClipPlaneSet` -- union of ranges of member `ConvexClipPlaneSet`\r\n * * `ClipPrimitive` -- access its `UnionOfConvexClipPlaneSet`.\r\n * * `ClipVector` -- intersection of the ranges of its `ClipPrimitive`.\r\n * * `undefined` -- entire input range.\r\n * * If `observeInvisibleFlag` is false, the \"invisible\" properties are ignored, and this effectively returns the range of the edge work of the members\r\n * * If `observeInvisibleFlag` is false, the \"invisible\" properties are observed, and \"invisible\" parts do not restrict the range.\r\n * @param clipper\r\n * @param range non-null range.\r\n * @param observeInvisibleFlag indicates how \"invisible\" bit is applied for ClipPrimitive.\r\n */\r\n public static rangeOfClipperIntersectionWithRange(clipper: ConvexClipPlaneSet | UnionOfConvexClipPlaneSets | ClipPrimitive | ClipVector | undefined, range: Range3d, observeInvisibleFlag: boolean = true): Range3d {\r\n if (clipper === undefined)\r\n return range.clone();\r\n if (clipper instanceof ConvexClipPlaneSet)\r\n return this.rangeOfConvexClipPlaneSetIntersectionWithRange(clipper, range);\r\n if (clipper instanceof UnionOfConvexClipPlaneSets) {\r\n const rangeUnion = Range3d.createNull();\r\n for (const c of clipper.convexSets) {\r\n const rangeC = this.rangeOfConvexClipPlaneSetIntersectionWithRange(c, range);\r\n rangeUnion.extendRange(rangeC);\r\n }\r\n return rangeUnion;\r\n }\r\n if (clipper instanceof ClipPrimitive) {\r\n if (observeInvisibleFlag && clipper.invisible)\r\n return range.clone();\r\n return this.rangeOfClipperIntersectionWithRange(clipper.fetchClipPlanesRef(), range);\r\n }\r\n if (clipper instanceof ClipVector) {\r\n const rangeIntersection = range.clone();\r\n for (const c of clipper.clips) {\r\n if (observeInvisibleFlag && c.invisible) {\r\n // trivial range tests do not expose the effects. Assume the hole allows everything.\r\n } else {\r\n const rangeC = this.rangeOfClipperIntersectionWithRange(c, range, observeInvisibleFlag);\r\n rangeIntersection.intersect(rangeC, rangeIntersection);\r\n }\r\n }\r\n return rangeIntersection;\r\n\r\n }\r\n return range.clone();\r\n }\r\n /**\r\n * Test if various types of clippers have any intersection with a range.\r\n * * This follows the same logic as `rangeOfClipperIntersectionWithRange` but attempts to exit at earliest point of confirmed intersection\r\n * * `ConvexClipPlaneSet` -- dispatch to `doesConvexClipPlaneSetIntersectRange`\r\n * * `UnionOfConvexClipPlaneSet` -- union of ranges of member `ConvexClipPlaneSet`\r\n * * `ClipPrimitive` -- access its `UnionOfConvexClipPlaneSet`.\r\n * * `ClipVector` -- intersection of the ranges of its `ClipPrimitive`.\r\n * * `undefined` -- entire input range.\r\n * * If `observeInvisibleFlag` is false, the \"invisible\" properties are ignored, and holes do not affect the result.\r\n * * If `observeInvisibleFlag` is true, the \"invisible\" properties are observed, and may affect the result.\r\n * @param clipper\r\n * @param range non-null range.\r\n * @param observeInvisibleFlag indicates how \"invisible\" bit is applied for ClipPrimitive.\r\n */\r\n public static doesClipperIntersectRange(clipper: ConvexClipPlaneSet | UnionOfConvexClipPlaneSets | ClipPrimitive | ClipVector | undefined, range: Range3d, observeInvisibleFlag: boolean = true): boolean {\r\n if (clipper === undefined)\r\n return true;\r\n\r\n if (clipper instanceof ConvexClipPlaneSet)\r\n return this.doesConvexClipPlaneSetIntersectRange(clipper, range);\r\n\r\n if (clipper instanceof UnionOfConvexClipPlaneSets) {\r\n for (const c of clipper.convexSets) {\r\n if (this.doesConvexClipPlaneSetIntersectRange(c, range))\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n if (clipper instanceof ClipPrimitive) {\r\n if (observeInvisibleFlag && clipper.invisible) // um is there an easy way to detect range-completely-inside?\r\n return true;\r\n return this.doesClipperIntersectRange(clipper.fetchClipPlanesRef(), range);\r\n }\r\n\r\n if (clipper instanceof ClipVector) {\r\n const rangeIntersection = range.clone();\r\n for (const c of clipper.clips) {\r\n if (observeInvisibleFlag && c.invisible) {\r\n // trivial range tests do not expose the effects. Assume the hole allows everything.\r\n } else {\r\n const rangeC = this.rangeOfClipperIntersectionWithRange(c, range, observeInvisibleFlag);\r\n rangeIntersection.intersect(rangeC, rangeIntersection);\r\n }\r\n }\r\n return !rangeIntersection.isNull;\r\n }\r\n /** If the case statement above is complete for the variant inputs, this is unreachable .. */\r\n return false;\r\n }\r\n /**\r\n * Emit point loops for intersection of a convex set with a range.\r\n * * return zero length array for (a) null range or (b) no intersections\r\n * @param range range to intersect\r\n * @param includeConvexSetFaces if false, do not compute facets originating as convex set planes.\r\n * @param includeRangeFaces if false, do not compute facets originating as range faces\r\n * @param ignoreInvisiblePlanes if true, do NOT compute a facet for convex set faces marked invisible.\r\n */\r\n public static doesConvexClipPlaneSetIntersectRange(convexSet: ConvexClipPlaneSet, range: Range3d,\r\n includeConvexSetFaces: boolean = true, includeRangeFaces: boolean = true, ignoreInvisiblePlanes = false): boolean {\r\n const work = new GrowableXYZArray();\r\n if (includeConvexSetFaces) {\r\n // Clip convexSet planes to the range and to the rest of the convexSet . .\r\n for (const plane of convexSet.planes) {\r\n if (ignoreInvisiblePlanes && plane.invisible)\r\n continue;\r\n const pointsClippedToRange = plane.intersectRange(range, true);\r\n if (pointsClippedToRange) {\r\n const finalPoints = new GrowableXYZArray();\r\n convexSet.polygonClip(pointsClippedToRange, finalPoints, work, plane);\r\n if (finalPoints.length > 0)\r\n return true;\r\n }\r\n }\r\n }\r\n\r\n if (includeRangeFaces) {\r\n // clip range faces to the convex set . . .\r\n const corners = range.corners();\r\n for (let i = 0; i < 6; i++) {\r\n const indices = Range3d.faceCornerIndices(i);\r\n const finalPoints = new GrowableXYZArray();\r\n const lineString = LineString3d.createIndexedPoints(corners, indices);\r\n convexSet.polygonClip(lineString.packedPoints, finalPoints, work);\r\n if (finalPoints.length > 0)\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n /**\r\n * Test if `obj` is a `Clipper` object.\r\n * * This is implemented by testing for each of the methods in the `Clipper` interface.\r\n */\r\n public static isClipper(obj: any): boolean {\r\n if (obj) {\r\n if (obj.isPointOnOrInside\r\n && obj.announceClippedSegmentIntervals\r\n && obj.announceClippedArcIntervals)\r\n return true;\r\n }\r\n return false;\r\n }\r\n /**\r\n * Specialized logic for replacing clip fragments by an equivalent singleton.\r\n * * If there are baseCount + 1 or fewer fragments, do nothing.\r\n * * If there are more than baseCount+1 fragments:\r\n * * drop them all to the cache\r\n * * push a copy of the singleton.\r\n * * The use case for this is that a multi-step clipper (e.g. UnionOfConvexClipPlaneSets) may produce many fragments, and then be able to determine\r\n * that they really are the original pre-clip polygon unchanged.\r\n * * The baseCount+1 case is the case where the entire original singleton is still a singleton and can be left alone.\r\n * * Calling this replacer shuffles the original back into the fragment array, and drops the fragments.\r\n * * This determination is solely within the logic of the caller.\r\n * @param shards array of fragments\r\n * @param baseCount original count\r\n * @param singleton single array which may be a replacement for multiple fragments\r\n * @param cache cache for array management\r\n */\r\n public static restoreSingletonInPlaceOfMultipleShards(fragments: GrowableXYZArray[] | undefined, baseCount: number, singleton: GrowableXYZArray, arrayCache: GrowableXYZArrayCache) {\r\n if (fragments && fragments.length > baseCount + 1) {\r\n while (fragments.length > baseCount) {\r\n const f = fragments.pop();\r\n arrayCache.dropToCache(f);\r\n }\r\n fragments.push(arrayCache.grabAndFill(singleton));\r\n }\r\n }\r\n\r\n /**\r\n * Create a UnionOfConvexClipPlaneSets for a volume defined by a path and offsets.\r\n * @param points points along the path.\r\n * @param positiveOffsetLeft offset to left. 0 is clip on the path.\r\n * @param positiveOffsetRight offset to the right. 0 is clip on the path.\r\n * @param z0 z for lower clipping plane. If undefined, unbounded in positive z\r\n * @param z1 z for upper clipping plane. If undefined, unbounded in negative z.\r\n * @alpha\r\n */\r\n public static createXYOffsetClipFromLineString(points: Point3d[] | IndexedXYZCollection,\r\n leftOffset: number, rightOffset: number, z0: number, z1: number): UnionOfConvexClipPlaneSets {\r\n if (Array.isArray(points)) {\r\n return LineStringOffsetClipperContext.createClipBetweenOffsets(\r\n new Point3dArrayCarrier(points), leftOffset, rightOffset, z0, z1);\r\n }\r\n return LineStringOffsetClipperContext.createClipBetweenOffsets(points, leftOffset, rightOffset, z0, z1);\r\n }\r\n /** if data.length >= minLength threshold, push it to destination; if smaller drop it back to the cache.\r\n */\r\n public static captureOrDrop(data: GrowableXYZArray, minLength: number, destination: GrowableXYZArray[], cache: GrowableXYZArrayCache) {\r\n if (data.length >= minLength)\r\n destination.push(data);\r\n else\r\n cache.dropToCache(data);\r\n }\r\n /**\r\n * Find the portion of a line within a half-plane clip.\r\n * * The half-plane clip is to the left of the line from clipA to clipB.\r\n * * The original clipped segment has fractions 0 and 1 at respective segment points.\r\n * * Caller initializes the interval\r\n * * This method reduces the interval size.\r\n * * See clipSegmentToCCWTriangleXY for typical use.\r\n * @param linePointA First point of clip line\r\n * @param linePointB Second point of clip line\r\n * @param segmentPoint0 First point of clipped segment\r\n * @param segmentPoint1 Second point of clipped segment\r\n * @param interval Live interval.\r\n * @param absoluteTolerance absolute tolerance for both cross product values to indicate \"on\" the line\r\n */\r\n public static clipSegmentToLLeftOfLineXY(linePointA: XAndY, linePointB: XAndY, segmentPoint0: XAndY, segmentPoint1: XAndY, interval: Range1d,\r\n absoluteTolerance: number = 1.0e-14) {\r\n const ux = linePointB.x - linePointA.x;\r\n const uy = linePointB.y - linePointA.y;\r\n // negative is in positive is out ...\r\n const h0 = -(ux * (segmentPoint0.y - linePointA.y) - uy * (segmentPoint0.x - linePointA.x));\r\n const h1 = -(ux * (segmentPoint1.y - linePointA.y) - uy * (segmentPoint1.x - linePointA.x));\r\n if (h0 < absoluteTolerance && h1 < absoluteTolerance) {\r\n // The entire segment is in .....\r\n return;\r\n }\r\n if (h0 * h1 > 0.0) {\r\n if (h0 > 0.0)\r\n interval.setNull();\r\n } else if (h0 * h1 < 0.0) {\r\n // strict crossing with safe fraction . . .\r\n const fraction = -h0 / (h1 - h0);\r\n if (h0 < 0.0) {\r\n return interval.intersectRangeXXInPlace(0.0, fraction);\r\n } else {\r\n return interval.intersectRangeXXInPlace(fraction, 1.0);\r\n }\r\n } else {\r\n // There is an exact hit at one end, possibly non-zero at the other ... the sign of either determines which side is in play\r\n // A zero and a zero or negative is entirely in, which does not alter the prior clip.\r\n if (h0 > 0.0) {\r\n interval.intersectRangeXXInPlace(1.0, 1.0);\r\n } else if (h1 > 0.0) {\r\n interval.intersectRangeXXInPlace(0.0, 0.0);\r\n }\r\n }\r\n }\r\n /**\r\n * Clip an interval of a line segment to a triangle.\r\n * * Triangle is assumed CCW\r\n * @param pointA point of triangle.\r\n * @param pointB point of triangle.\r\n * @param pointC point of triangle.\r\n * @param segment0 start of segment\r\n * @param segment1 end of segment\r\n * @param interval Pre-initialized interval of live part of segment\r\n * @param absoluteTolerance absolute tolerance for begin \"on a line\"\r\n */\r\n public static clipSegmentToCCWTriangleXY(pointA: XAndY, pointB: XAndY, pointC: XAndY, segment0: XAndY, segment1: XAndY, interval: Range1d,\r\n absoluteTolerance: number = 1.0e-14) {\r\n if (!interval.isNull) {\r\n this.clipSegmentToLLeftOfLineXY(pointA, pointB, segment0, segment1, interval, absoluteTolerance);\r\n if (!interval.isNull) {\r\n this.clipSegmentToLLeftOfLineXY(pointB, pointC, segment0, segment1, interval, absoluteTolerance);\r\n if (!interval.isNull) {\r\n this.clipSegmentToLLeftOfLineXY(pointC, pointA, segment0, segment1, interval, absoluteTolerance);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Find the portion of a line within a half-plane clip.\r\n * * The half-plane clip is to the left of the line from clipA to clipB.\r\n * * The original clipped segment has fractions 0 and 1 at respective segment points.\r\n * * Caller initializes the interval\r\n * * This method reduces the interval size.\r\n * * See clipSegmentToCCWTriangleXY for typical use.\r\n * @param linePointA First point of clip line\r\n * @param linePointB Second point of clip line\r\n * @param segmentPoint0 First point of clipped segment\r\n * @param segmentPoint1 Second point of clipped segment\r\n * @param interval Live interval.\r\n * @param absoluteTolerance absolute tolerance for both cross product values to indicate \"on\" the line\r\n */\r\n public static clipSegmentBelowPlaneXY(plane: Plane3dByOriginAndUnitNormal, segmentPoint0: XAndY, segmentPoint1: XAndY, interval: Range1d,\r\n absoluteTolerance: number = 1.0e-14) {\r\n // negative is in positive is out ...\r\n const h0 = plane.altitudeXY(segmentPoint0.x, segmentPoint0.y);\r\n const h1 = plane.altitudeXY(segmentPoint1.x, segmentPoint1.y);\r\n if (h0 < absoluteTolerance && h1 < absoluteTolerance) {\r\n // The entire segment is in ..... the interval is unaffected.\r\n return;\r\n }\r\n if (h0 * h1 > 0.0) {\r\n if (h0 > 0.0)\r\n interval.setNull();\r\n } else if (h0 * h1 < 0.0) {\r\n // strict crossing with safe fraction . . .\r\n const fraction = -h0 / (h1 - h0);\r\n if (h0 < 0.0) {\r\n return interval.intersectRangeXXInPlace(0.0, fraction);\r\n } else {\r\n return interval.intersectRangeXXInPlace(fraction, 1.0);\r\n }\r\n } else {\r\n // There is an exact hit at one end, possibly non-zero at the other ... the sign of either determines which side is in play\r\n // A zero and a zero or negative is entirely in, which does not alter the prior clip.\r\n if (h0 > 0.0) {\r\n interval.intersectRangeXXInPlace(1.0, 1.0);\r\n } else if (h1 > 0.0) {\r\n interval.intersectRangeXXInPlace(0.0, 0.0);\r\n }\r\n }\r\n }\r\n /**\r\n * Clip an interval of a line segment to an array of planes\r\n * * plane normals assumed OUTWARD\r\n * * planeAltitude is typically a tolerance a tolerance distance.\r\n * * positive altitude makes tha plane move in the direction of the unit normal.\r\n * @param planes array of planes\r\n * @param segment0 start of segment\r\n * @param segment1 end of segment\r\n * @param interval Pre-initialized interval of live part of segment\r\n * @param absoluteTolerance absolute tolerance for begin \"on a line\"\r\n */\r\n public static clipSegmentBelowPlanesXY(planes: Plane3dByOriginAndUnitNormal[], segment0: XAndY, segment1: XAndY, interval: Range1d,\r\n signedAltitude: number = 1.0e-14) {\r\n const numPlanes = planes.length;\r\n for (let i = 0; (!interval.isNull) && i < numPlanes; i++) {\r\n this.clipSegmentBelowPlaneXY(planes[i], segment0, segment1, interval, signedAltitude);\r\n }\r\n }\r\n /**\r\n * Pass line segments from a polyline to the clipper. Resolve the fractional clips to simple points for announcement.\r\n * @param clipper clipper to call\r\n * @param points polyline whose segments are passed to the clipper\r\n * @param announce caller's handler for simple point pairs.\r\n */\r\n public static announcePolylineClip(clipper: Clipper, points: Point3d[], announce: (point0: Point3d, point1: Point3d) => void) {\r\n for (let i = 0; i + 1 < points.length; i++) {\r\n clipper.announceClippedSegmentIntervals(0, 1, points[i], points[i + 1],\r\n (f0: number, f1: number) => {\r\n announce(points[i].interpolate(f0, points[i + 1]), points[i].interpolate(f1, points[i + 1]));\r\n });\r\n }\r\n }\r\n /**\r\n * Pass line segments from a polyline to the clipper. Sum the lengths of the clipped pieces. Return the sum.\r\n * @param clipper clipper to call\r\n * @param points polyline whose segments are passed to the clipper\r\n */\r\n public static sumPolylineClipLength(clipper: Clipper, points: Point3d[]) {\r\n let s = 0;\r\n for (let i = 0; i + 1 < points.length; i++) {\r\n const a = points[i].distance(points[i + 1]);\r\n clipper.announceClippedSegmentIntervals(0, 1, points[i], points[i + 1],\r\n (f0: number, f1: number) => { s += Math.abs(f1 - f0) * a; });\r\n }\r\n return s;\r\n }\r\n /**\r\n * Pass polygon `xyz` through a sequence of PolygonClip steps.\r\n * * At the outset, `xyz` is the (only) entry in a set of candidates.\r\n * * For each clipper, each candidate is presented for appendPolygon to inside and outside parts.\r\n * * Each (in,out) result is distributed among (acceptedIn, acceptedOut, candidates) according to\r\n * (inAction, outAction)\r\n * * At the end, all remaining candidates are distributed among (acceptedIn, acceptedOut, finalUnknown)\r\n * according to finalAction\r\n * * Any clipper that does not have an appendPolygonClip method is skipped.\r\n * @param xyz\r\n * @param clippers\r\n * @param acceptedIn\r\n * @param acceptedOut\r\n * @param finalCandidates\r\n * @param inAction\r\n * @param outAction\r\n * @param finalCandidateAction\r\n */\r\n public static doPolygonClipSequence(\r\n xyz: GrowableXYZArray,\r\n clippers: Clipper[],\r\n acceptedIn: GrowableXYZArray[] | undefined,\r\n acceptedOut: GrowableXYZArray[] | undefined,\r\n finalCandidates: GrowableXYZArray[] | undefined,\r\n inAction: ClipStepAction,\r\n outAction: ClipStepAction,\r\n finalFragmentAction: ClipStepAction,\r\n arrayCache: GrowableXYZArrayCache | undefined\r\n ) {\r\n if (arrayCache === undefined)\r\n arrayCache = new GrowableXYZArrayCache();\r\n let candidates = [arrayCache.grabAndFill(xyz)];\r\n let nextCandidates: GrowableXYZArray[] = [];\r\n const intermediateIn: GrowableXYZArray[] = [];\r\n const intermediateOut: GrowableXYZArray[] = [];\r\n const oldInsideCount = acceptedIn ? acceptedIn.length : 0;\r\n const oldOutsideCount = acceptedOut ? acceptedOut.length : 0;\r\n let shard;\r\n // At each convex set, carryForwardA is all the fragments that have been outside all previous convex sets.\r\n // Clip each such fragment to the current set, sending the outside parts to carryForwardB, which will got to the next clipper\r\n // The final surviving carryForward really is out.\r\n for (const c of clippers) {\r\n if (c.appendPolygonClip) {\r\n while (undefined !== (shard = candidates.pop())) {\r\n c.appendPolygonClip(shard, intermediateIn, intermediateOut, arrayCache);\r\n distributeFragments(inAction, intermediateIn, acceptedIn, acceptedOut, nextCandidates, arrayCache);\r\n distributeFragments(outAction, intermediateOut, acceptedIn, acceptedOut, nextCandidates, arrayCache);\r\n arrayCache.dropToCache(shard);\r\n }\r\n // candidates is empty !!\r\n const temp = candidates; candidates = nextCandidates; nextCandidates = temp;\r\n }\r\n }\r\n distributeFragments(finalFragmentAction, candidates, acceptedIn, acceptedOut, finalCandidates, arrayCache);\r\n // Note: The following assumes that there were no residual candidates ... need to track if that happened?\r\n // If nothing was out, the inside fragments can be replaced by the original.\r\n if (acceptedOut?.length === oldOutsideCount)\r\n ClipUtilities.restoreSingletonInPlaceOfMultipleShards(acceptedIn, oldInsideCount, xyz, arrayCache);\r\n // If nothing was in, the outside fragments can be replaced by the original.\r\n if (acceptedIn?.length === oldInsideCount)\r\n ClipUtilities.restoreSingletonInPlaceOfMultipleShards(acceptedOut, oldOutsideCount, xyz, arrayCache);\r\n }\r\n /**\r\n * Pass polygon `xyz` through a sequence of PolygonClip steps with \"parity\" rules\r\n */\r\n public static doPolygonClipParitySequence(\r\n xyz: GrowableXYZArray,\r\n clippers: Clipper[],\r\n acceptedIn: GrowableXYZArray[] | undefined,\r\n acceptedOut: GrowableXYZArray[] | undefined,\r\n arrayCache: GrowableXYZArrayCache | undefined\r\n ) {\r\n if (arrayCache === undefined)\r\n arrayCache = new GrowableXYZArrayCache();\r\n let candidatesOut = [arrayCache.grabAndFill(xyz)];\r\n let candidatesIn: GrowableXYZArray[] = [];\r\n let nextCandidatesIn: GrowableXYZArray[] = [];\r\n let nextCandidatesOut: GrowableXYZArray[] = [];\r\n const intermediateIn: GrowableXYZArray[] = [];\r\n const intermediateOut: GrowableXYZArray[] = [];\r\n let shard;\r\n // at each step ..\r\n // candidatesIn and candidatesOut are evolved in and out\r\n // nextCandidatesIn and nextCandidatesOut are EMPTY\r\n for (const c of clippers) {\r\n if (c.appendPolygonClip) {\r\n // (IN,OUT) parts of IN parts distribute to (OUT,IN)\r\n while (undefined !== (shard = candidatesIn.pop())) {\r\n c.appendPolygonClip(shard, intermediateIn, intermediateOut, arrayCache);\r\n distributeFragments(ClipStepAction.acceptOut, intermediateIn, nextCandidatesIn, nextCandidatesOut, undefined, arrayCache);\r\n distributeFragments(ClipStepAction.acceptIn, intermediateOut, nextCandidatesIn, nextCandidatesOut, undefined, arrayCache);\r\n arrayCache.dropToCache(shard);\r\n }\r\n // (IN,OUT) parts of IN parts distribute to (OUT,IN)\r\n while (undefined !== (shard = candidatesOut.pop())) {\r\n c.appendPolygonClip(shard, intermediateIn, intermediateOut, arrayCache);\r\n distributeFragments(ClipStepAction.acceptIn, intermediateIn, nextCandidatesIn, nextCandidatesOut, undefined, arrayCache);\r\n distributeFragments(ClipStepAction.acceptOut, intermediateOut, nextCandidatesIn, nextCandidatesOut, undefined, arrayCache);\r\n arrayCache.dropToCache(shard);\r\n }\r\n // reload each candidate step\r\n const tempA = candidatesIn; candidatesIn = nextCandidatesIn; nextCandidatesIn = tempA;\r\n const tempB = candidatesOut; candidatesOut = nextCandidatesOut; nextCandidatesOut = tempB;\r\n }\r\n }\r\n // candidatesIn and candidatesOut are final ....\r\n if (candidatesOut.length === 0)\r\n acceptedIn?.push(arrayCache.grabAndFill(xyz));\r\n else if (candidatesOut.length === 0)\r\n acceptedOut?.push(arrayCache.grabAndFill(xyz));\r\n else {\r\n moveFragments(candidatesIn, acceptedIn, arrayCache);\r\n moveFragments(candidatesOut, acceptedOut, arrayCache);\r\n }\r\n }\r\n /** For each plane of clipper, construct a UnionOfConvexClipPlaneSets for an outer (infinite) convex volume that\r\n * abuts the outer volume of the neighbor faces.\r\n *\r\n */\r\n public static createComplementaryClips(clipper: ConvexClipPlaneSet): UnionOfConvexClipPlaneSets {\r\n const planes = clipper.planes;\r\n const interval = Range1d.createNull();\r\n const n = planes.length;\r\n const newClippers: ConvexClipPlaneSet[] = [];\r\n for (const p of planes){\r\n const outerSet = ConvexClipPlaneSet.createEmpty();\r\n outerSet.addPlaneToConvexSet(p.cloneNegated());\r\n newClippers.push(outerSet);\r\n }\r\n for (let i = 0; i < n; i++) {\r\n for (let j = i + 1; j < n; j++) {\r\n const ray = CurveFactory.planePlaneIntersectionRay(planes[i], planes[j]);\r\n if (ray) {\r\n if (clipper.hasIntersectionWithRay(ray, interval)) {\r\n // the normal-to-normal vector is bisector (or close to bisector?)\r\n const newNormal = planes[j].inwardNormalRef.minus(planes[i].inwardNormalRef);\r\n const plane1 = ClipPlane.createNormalAndPoint(newNormal, ray.origin);\r\n if (plane1) {\r\n const plane2 = plane1.cloneNegated();\r\n newClippers[i].addPlaneToConvexSet(plane1);\r\n newClippers[j].addPlaneToConvexSet(plane2);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n return UnionOfConvexClipPlaneSets.createConvexSets(newClippers);\r\n }\r\n}\r\nfunction moveFragments(\r\n fragments: GrowableXYZArray[],\r\n destination: GrowableXYZArray[] | undefined,\r\n arrayCache: GrowableXYZArrayCache) {\r\n if (destination === undefined)\r\n arrayCache.dropAllToCache(fragments);\r\n else {\r\n for (const f of fragments)\r\n destination.push(f);\r\n }\r\n fragments.length = 0;\r\n}\r\n/**\r\n * Distribute fragments among acceptedIn, acceptedOut, and passToNextStep as directed by action.\r\n * * If the indicated destination is unknown, drop the fragments to the arrayCache.\r\n * @param action destination selector\r\n * @param fragments fragments to be distributed\r\n * @param acceptedIn destination for \"in\"\r\n * @param acceptedOut destination for \"out\"\r\n * @param passToNextStep destination for fragments to be passed to a later step\r\n * @param arrayCache destination for un-distributed fragments.\r\n */\r\nfunction distributeFragments(\r\n action: ClipStepAction,\r\n fragments: GrowableXYZArray[],\r\n acceptedIn: GrowableXYZArray[] | undefined,\r\n acceptedOut: GrowableXYZArray[] | undefined,\r\n passToNextStep: GrowableXYZArray[] | undefined,\r\n arrayCache: GrowableXYZArrayCache) {\r\n let destination;\r\n if (action === ClipStepAction.acceptIn)\r\n destination = acceptedIn;\r\n else if (action === ClipStepAction.acceptOut)\r\n destination = acceptedOut;\r\n else if (action === ClipStepAction.passToNextStep)\r\n destination = passToNextStep;\r\n// remark: if action is other than the enum values, destination is undefined\r\n if (destination === undefined)\r\n arrayCache.dropAllToCache(fragments);\r\n else {\r\n for (const f of fragments)\r\n destination.push(f);\r\n }\r\n fragments.length = 0;\r\n}\r\n"]}
|
|
@@ -95,7 +95,7 @@ export declare class ConvexClipPlaneSet implements Clipper, PolygonClipper {
|
|
|
95
95
|
* * If no result is provide, there are no object allocations.
|
|
96
96
|
* @param result optional Range1d to receive parameters along the ray.
|
|
97
97
|
*/
|
|
98
|
-
hasIntersectionWithRay(ray: Ray3d, result?: Range1d): boolean;
|
|
98
|
+
hasIntersectionWithRay(ray: Ray3d, result?: Range1d, tolerance?: number): boolean;
|
|
99
99
|
/**
|
|
100
100
|
* Multiply all the ClipPlanes DPoint4d by matrix.
|
|
101
101
|
* @param matrix matrix to apply.
|