@itwin/core-geometry 5.10.0-dev.6 → 5.10.0-dev.7
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/lib/cjs/clipping/BooleanClipNode.d.ts +28 -29
- package/lib/cjs/clipping/BooleanClipNode.d.ts.map +1 -1
- package/lib/cjs/clipping/BooleanClipNode.js +61 -29
- package/lib/cjs/clipping/BooleanClipNode.js.map +1 -1
- package/lib/cjs/clipping/ClipPlane.d.ts +12 -13
- package/lib/cjs/clipping/ClipPlane.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipPlane.js +19 -12
- package/lib/cjs/clipping/ClipPlane.js.map +1 -1
- package/lib/cjs/clipping/ClipPrimitive.d.ts +13 -8
- package/lib/cjs/clipping/ClipPrimitive.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipPrimitive.js +18 -7
- package/lib/cjs/clipping/ClipPrimitive.js.map +1 -1
- package/lib/cjs/clipping/ClipUtils.d.ts +13 -5
- package/lib/cjs/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipUtils.js.map +1 -1
- package/lib/cjs/clipping/ClipVector.d.ts +11 -5
- package/lib/cjs/clipping/ClipVector.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipVector.js +22 -7
- package/lib/cjs/clipping/ClipVector.js.map +1 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts +7 -20
- package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.js +16 -20
- package/lib/cjs/clipping/ConvexClipPlaneSet.js.map +1 -1
- package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.d.ts +8 -19
- package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.d.ts.map +1 -1
- package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.js +19 -22
- package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.d.ts +4 -4
- package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.js +5 -6
- package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
- package/lib/cjs/curve/LineString3d.d.ts +4 -4
- package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineString3d.js +4 -6
- package/lib/cjs/curve/LineString3d.js.map +1 -1
- package/lib/cjs/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.d.ts +2 -3
- package/lib/cjs/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js +5 -6
- package/lib/cjs/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js.map +1 -1
- package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/TransitionSpiral3d.js.map +1 -1
- package/lib/cjs/geometry3d/Ellipsoid.d.ts +4 -3
- package/lib/cjs/geometry3d/Ellipsoid.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Ellipsoid.js +7 -4
- package/lib/cjs/geometry3d/Ellipsoid.js.map +1 -1
- package/lib/cjs/geometry3d/Plane3d.d.ts +16 -11
- package/lib/cjs/geometry3d/Plane3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Plane3d.js +16 -11
- package/lib/cjs/geometry3d/Plane3d.js.map +1 -1
- package/lib/esm/clipping/BooleanClipNode.d.ts +28 -29
- package/lib/esm/clipping/BooleanClipNode.d.ts.map +1 -1
- package/lib/esm/clipping/BooleanClipNode.js +61 -29
- package/lib/esm/clipping/BooleanClipNode.js.map +1 -1
- package/lib/esm/clipping/ClipPlane.d.ts +12 -13
- package/lib/esm/clipping/ClipPlane.d.ts.map +1 -1
- package/lib/esm/clipping/ClipPlane.js +19 -12
- package/lib/esm/clipping/ClipPlane.js.map +1 -1
- package/lib/esm/clipping/ClipPrimitive.d.ts +13 -8
- package/lib/esm/clipping/ClipPrimitive.d.ts.map +1 -1
- package/lib/esm/clipping/ClipPrimitive.js +18 -7
- package/lib/esm/clipping/ClipPrimitive.js.map +1 -1
- package/lib/esm/clipping/ClipUtils.d.ts +13 -5
- package/lib/esm/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/esm/clipping/ClipUtils.js.map +1 -1
- package/lib/esm/clipping/ClipVector.d.ts +11 -5
- package/lib/esm/clipping/ClipVector.d.ts.map +1 -1
- package/lib/esm/clipping/ClipVector.js +22 -7
- package/lib/esm/clipping/ClipVector.js.map +1 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.d.ts +7 -20
- package/lib/esm/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.js +16 -20
- package/lib/esm/clipping/ConvexClipPlaneSet.js.map +1 -1
- package/lib/esm/clipping/UnionOfConvexClipPlaneSets.d.ts +8 -19
- package/lib/esm/clipping/UnionOfConvexClipPlaneSets.d.ts.map +1 -1
- package/lib/esm/clipping/UnionOfConvexClipPlaneSets.js +19 -22
- package/lib/esm/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
- package/lib/esm/curve/CurvePrimitive.d.ts +4 -4
- package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/esm/curve/CurvePrimitive.js +5 -6
- package/lib/esm/curve/CurvePrimitive.js.map +1 -1
- package/lib/esm/curve/LineString3d.d.ts +4 -4
- package/lib/esm/curve/LineString3d.d.ts.map +1 -1
- package/lib/esm/curve/LineString3d.js +4 -6
- package/lib/esm/curve/LineString3d.js.map +1 -1
- package/lib/esm/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.d.ts +2 -3
- package/lib/esm/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js +5 -6
- package/lib/esm/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js.map +1 -1
- package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
- package/lib/esm/curve/spiral/TransitionSpiral3d.js.map +1 -1
- package/lib/esm/geometry3d/Ellipsoid.d.ts +4 -3
- package/lib/esm/geometry3d/Ellipsoid.d.ts.map +1 -1
- package/lib/esm/geometry3d/Ellipsoid.js +7 -4
- package/lib/esm/geometry3d/Ellipsoid.js.map +1 -1
- package/lib/esm/geometry3d/Plane3d.d.ts +16 -11
- package/lib/esm/geometry3d/Plane3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Plane3d.js +16 -11
- package/lib/esm/geometry3d/Plane3d.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plane3d.js","sourceRoot":"","sources":["../../../src/geometry3d/Plane3d.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,0CAA+D;AAE/D,uDAAsD;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAsB,OAAO;IAM3B,4EAA4E;IACrE,cAAc,CAAC,UAAmB,EAAE,YAAoB,mBAAQ,CAAC,mBAAmB;QACzF,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,IAAI,SAAS,CAAC;IAC1D,CAAC;IACD;;;;OAIG;IACI,gBAAgB,CAAC,KAAc,EAAE,YAAoB,mBAAQ,CAAC,mBAAmB;QACtF,OAAO,mBAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC;IAC/D,CAAC;IACD;;;;OAIG;IACI,mBAAmB,CACxB,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,YAAoB,mBAAQ,CAAC,mBAAmB;QAEjF,OAAO,mBAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IACpE,CAAC;IAmBD;;;;;;OAMG;IACI,aAAa,CAAC,MAAiB;QACpC,OAAO,0BAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;IAC3F,CAAC;IACD;;;;;OAKG;IACI,kBAAkB,CAAC,MAAgB;QACxC,OAAO,IAAI,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC;IAgCD,uDAAuD;IAChD,iBAAiB,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,MAAgB;QACxE,MAAM,KAAK,GAAG,yBAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC;CACF;AArGD,0BAqGC","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\nimport { Geometry, PlaneAltitudeEvaluator } from \"../Geometry\";\r\nimport { Point4d } from \"../geometry4d/Point4d\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\n\r\n/**\r\n * Plane3d is the abstract base class for multiple 3d plane representations:\r\n * * [[Plane3dByOriginAndUnitNormal]] -- plane defined by origin and normal, with no preferred in-plane directions\r\n * * [[Plane3dByOriginAndVectors]] -- plane defined by origin and 2 vectors in the plane, with normal implied by the vectors' cross product\r\n * * [[Point4d]] -- homogeneous form of xyzw plane.\r\n * * [[ClipPlane]] -- implicit plane with additional markup as used by compound clip structures such as [[ConvexClipPlaneSet]] and [[UnionOfConvexClipPlaneSets]]\r\n *\r\n * As an abstract base class, Plane3d demands that its derived classes implement queries to answer questions\r\n * about the plane's normal and the altitude of points above or below the plane. (Altitude is measured perpendicular to the plane.)\r\n * These abstract methods are:\r\n * * altitude(Point3d), altitudeXYZ(x,y,z), and altitudeXYZW(Point4d) -- evaluate altitude\r\n * * normalX(), normalY(), normalZ() -- return components of the plane's normal vector.\r\n * * velocity(Vector3d), velocityXYZ(x,y,z) -- return dot product of the input vector with the plane normal.\r\n * * projectPointToPlane (spacePoint: Point3d) -- return projection of spacePoint into the plane.\r\n *\r\n * The Plane3d base class also provides implementations of several queries which it can implement by calling the abstract queries.\r\n * * Derived classes may choose to override these default implementations using private knowledge of what they have stored.\r\n * * isPointInPlane(spacePoint, tolerance?) -- test if spacePoint is in the plane with tolerance. Default tolerance is small metric distance\r\n * * classifyAltitude (spacePoint, tolerance?), classifyAltitudeXYZ (x,y,z,tolerance?) -- return -1,0,1 indicating if spacePoint's altitude\r\n * is negative, near zero, or positive.\r\n *\r\n * Notes about scaling and signs in methods that compute altitudes, normal components and velocities:\r\n * * The term \"altitude\" indicates a _signed_ distance from the plane.\r\n * * altitude zero is _on_ the plane\r\n * * positive altitudes are on one side\r\n * * negatives are on the other.\r\n * * Altitude values and normal components are not strictly required to be true cartesian distance. If the calling code happens to use \"distance scaled by 1000X\" it\r\n * understands that it can be OK for its plane implementation to have that scaling.\r\n * * By convention, derived classes whose definitions (normals and vectors in plane) are simple cartesian are expected\r\n * to return true distances. This applies to:\r\n * * [[Plane3dByOriginAndUnitNormal]] and [[ClipPlane]]\r\n * * These maintain a stored unit normal so the altitude calculations are inherently true cartesian distance.\r\n * * [[Plane3dByOriginAndVectors]] -- this is a bit expensive because\r\n * * the normal is the cross product of the defining vectors.\r\n * * that cross product is not typically unit\r\n * * normalization adds to the cost of computing off-plane distances\r\n * * Since a main purpose of using this class is often to navigate a skewed, non-unit grid, occasional off-plane queries are not likely to be important.\r\n * * \"4 dimensional\" (homogeneous coordinate planes) ([[Point4d]] and [[PlaneByOriginAndVectors4d]])\r\n * * typically do _not_ force their coefficients to any distance-based normalization\r\n * * are typically used for calculations in spaces with skewing effects do to perspective, and true distances are not required.\r\n * * In all classes, the `weightedAltitude` method is free to be scaled distance.\r\n * @public\r\n */\r\nexport abstract class Plane3d implements PlaneAltitudeEvaluator {\r\n /**\r\n * Return the altitude of spacePoint above or below the plane. (Below is negative)\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n */\r\n public abstract altitude(spacePoint: Point3d): number;\r\n /** Returns true if spacePoint is within distance tolerance of the plane. */\r\n public isPointInPlane(spacePoint: Point3d, tolerance: number = Geometry.smallMetricDistance): boolean {\r\n return Math.abs(this.altitude(spacePoint)) <= tolerance;\r\n }\r\n /**\r\n * Return a value -1, 0, 1 giving a signed indicator of whether the toleranced altitude of the point is\r\n * negative, near zero, or positive.\r\n *\r\n */\r\n public classifyAltitude(point: Point3d, tolerance: number = Geometry.smallMetricDistance): -1 | 0 | 1 {\r\n return Geometry.split3Way01(this.altitude(point), tolerance);\r\n }\r\n /**\r\n * Return a value -1, 0, 1 giving a signed indicator of whether the toleranced altitude of x,y,z is\r\n * negative, near zero, or positive.\r\n *\r\n */\r\n public classifyAltitudeXYZ(\r\n x: number, y: number, z: number, tolerance: number = Geometry.smallMetricDistance,\r\n ): -1 | 0 | 1 {\r\n return Geometry.split3Way01(this.altitudeXYZ(x, y, z), tolerance);\r\n }\r\n /**\r\n * Return the x component of the normal used to evaluate altitude.\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n * * See [[Plane3d]] note about scaling.\r\n */\r\n public abstract normalX(): number;\r\n /**\r\n * Return the y component of the normal used to evaluate altitude.\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n * * See [[Plane3d]] note about scaling.\r\n */\r\n public abstract normalY(): number;\r\n /**\r\n * Return the z component of the normal used to evaluate altitude.\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n * * See [[Plane3d]] note about scaling.\r\n */\r\n public abstract normalZ(): number;\r\n /**\r\n * Return the unit normal for the plane.\r\n * * The abstract base class implementation assembles the normal from normalX, normalY, normalZ calls.\r\n * * Derived classes should (but are not required to) override for maximum efficiency if the separate normal calls\r\n * cause repeated normalization.\r\n * @param result\r\n */\r\n public getUnitNormal(result?: Vector3d): Vector3d | undefined {\r\n return Vector3d.createNormalized(this.normalX(), this.normalY(), this.normalZ(), result);\r\n }\r\n /**\r\n * Return any point on the plane.\r\n * * Default implementation projects the origin (0,0,0) to the plane.\r\n * * Classes that have a preferred origin for their plane should override.\r\n * * Classes with a purely implicit equation of their plane can accept the default implementation\r\n */\r\n public getAnyPointOnPlane(result?: Point3d): Point3d {\r\n return this.projectXYZToPlane(0, 0, 0, result);\r\n }\r\n /**\r\n * Return the altitude of weighted spacePoint above or below the plane. (Below is negative)\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n * * See [[Plane3d]] note about scaling.\r\n */\r\n public abstract weightedAltitude(spacePoint: Point4d): number;\r\n /**\r\n * Return the dot product of spaceVector (x,y,z) with the plane's unit normal. This tells the rate of change of\r\n * altitude for a point moving at speed one along the spaceVector.\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n * * See [[Plane3d]] note about scaling.\r\n */\r\n public abstract velocityXYZ(x: number, y: number, z: number): number;\r\n /**\r\n * Return the dot product of spaceVector with the plane's unit normal. This tells the rate of change of altitude\r\n * for a point moving at speed one along the spaceVector.\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n * * See [[Plane3d]] note about scaling.\r\n */\r\n public abstract velocity(spaceVector: Vector3d): number;\r\n /**\r\n * Return the altitude of a point given as separate x,y,z components.\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n * * See [[Plane3d]] note about scaling.\r\n */\r\n public abstract altitudeXYZ(x: number, y: number, z: number): number;\r\n /**\r\n * Return the projection of spacePoint onto the plane.\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n */\r\n public abstract projectPointToPlane(spacePoint: Point3d, result?: Point3d): Point3d;\r\n /** Return the projection of (x,y,z) onto the plane. */\r\n public projectXYZToPlane(x: number, y: number, z: number, result?: Point3d): Point3d {\r\n const point = Point3d.create(x, y, z, result);\r\n return this.projectPointToPlane(point, point);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Plane3d.js","sourceRoot":"","sources":["../../../src/geometry3d/Plane3d.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,0CAA+D;AAE/D,uDAAsD;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAsB,OAAO;IAM3B,4EAA4E;IACrE,cAAc,CAAC,UAAmB,EAAE,YAAoB,mBAAQ,CAAC,mBAAmB;QACzF,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,IAAI,SAAS,CAAC;IAC1D,CAAC;IACD;;;;OAIG;IACI,gBAAgB,CAAC,KAAc,EAAE,YAAoB,mBAAQ,CAAC,mBAAmB;QACtF,OAAO,mBAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC;IAC/D,CAAC;IACD;;;;OAIG;IACI,mBAAmB,CACxB,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,YAAoB,mBAAQ,CAAC,mBAAmB;QAEjF,OAAO,mBAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IACpE,CAAC;IAmBD;;;;;;OAMG;IACI,aAAa,CAAC,MAAiB;QACpC,OAAO,0BAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;IAC3F,CAAC;IACD;;;;;OAKG;IACI,kBAAkB,CAAC,MAAgB;QACxC,OAAO,IAAI,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC;IAgCD,uDAAuD;IAChD,iBAAiB,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,MAAgB;QACxE,MAAM,KAAK,GAAG,yBAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC;CACF;AArGD,0BAqGC","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\nimport { Geometry, PlaneAltitudeEvaluator } from \"../Geometry\";\r\nimport { Point4d } from \"../geometry4d/Point4d\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\n\r\n/**\r\n * Plane3d is the abstract base class for multiple 3d plane representations:\r\n * * [[Plane3dByOriginAndUnitNormal]] -- plane defined by origin and normal, with no preferred in-plane directions.\r\n * * [[Plane3dByOriginAndVectors]] -- plane defined by origin and 2 vectors in the plane, with normal implied by the\r\n * vectors' cross product.\r\n * * [[Point4d]] -- homogeneous form of xyzw plane.\r\n * * [[ClipPlane]] -- implicit plane with additional markup as used by compound clip structures such as\r\n * [[ConvexClipPlaneSet]] and [[UnionOfConvexClipPlaneSets]].\r\n *\r\n * As an abstract base class, Plane3d demands that its derived classes implement queries to answer questions\r\n * about the plane's normal and the altitude of points above or below the plane (altitude is measured perpendicular\r\n * to the plane).\r\n * These abstract methods are:\r\n * * altitude(Point3d), altitudeXYZ(x,y,z), and altitudeXYZW(Point4d) -- evaluate altitude.\r\n * * normalX(), normalY(), normalZ() -- return components of the plane's normal vector.\r\n * * velocity(Vector3d), velocityXYZ(x,y,z) -- return dot product of the input vector with the plane normal.\r\n * * projectPointToPlane(spacePoint: Point3d) -- return projection of spacePoint into the plane.\r\n *\r\n * The Plane3d base class also provides implementations of several queries which it can implement by calling\r\n * the abstract queries.\r\n * * Derived classes may choose to override these default implementations using private knowledge of what they have stored.\r\n * * isPointInPlane(spacePoint, tolerance?) -- test if spacePoint is in the plane with tolerance. Default tolerance is\r\n * small metric distance.\r\n * * classifyAltitude(spacePoint, tolerance?), classifyAltitudeXYZ(x,y,z,tolerance?) -- return -1,0,1 indicating if\r\n * spacePoint's altitude is negative, near zero, or positive.\r\n *\r\n * Notes about scaling and signs in methods that compute altitudes, normal components and velocities:\r\n * * The term \"altitude\" indicates a _signed_ distance from the plane.\r\n * * altitude zero is _on_ the plane\r\n * * positive altitudes are on one side\r\n * * negatives are on the other.\r\n * * Altitude values and normal components are not strictly required to be true cartesian distance. If the calling code happens to use \"distance scaled by 1000X\" it\r\n * understands that it can be OK for its plane implementation to have that scaling.\r\n * * By convention, derived classes whose definitions (normals and vectors in plane) are simple cartesian are expected\r\n * to return true distances. This applies to:\r\n * * [[Plane3dByOriginAndUnitNormal]] and [[ClipPlane]]\r\n * * These maintain a stored unit normal so the altitude calculations are inherently true cartesian distance.\r\n * * [[Plane3dByOriginAndVectors]] -- this is a bit expensive because\r\n * * the normal is the cross product of the defining vectors.\r\n * * that cross product is not typically unit\r\n * * normalization adds to the cost of computing off-plane distances\r\n * * Since a main purpose of using this class is often to navigate a skewed, non-unit grid, occasional off-plane queries are not likely to be important.\r\n * * \"4 dimensional\" (homogeneous coordinate planes) ([[Point4d]] and [[PlaneByOriginAndVectors4d]])\r\n * * typically do _not_ force their coefficients to any distance-based normalization\r\n * * are typically used for calculations in spaces with skewing effects do to perspective, and true distances are not required.\r\n * * In all classes, the `weightedAltitude` method is free to be scaled distance.\r\n * @public\r\n */\r\nexport abstract class Plane3d implements PlaneAltitudeEvaluator {\r\n /**\r\n * Return the altitude of spacePoint above or below the plane. (Below is negative)\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n */\r\n public abstract altitude(spacePoint: Point3d): number;\r\n /** Returns true if spacePoint is within distance tolerance of the plane. */\r\n public isPointInPlane(spacePoint: Point3d, tolerance: number = Geometry.smallMetricDistance): boolean {\r\n return Math.abs(this.altitude(spacePoint)) <= tolerance;\r\n }\r\n /**\r\n * Return a value -1, 0, 1 giving a signed indicator of whether the toleranced altitude of the point is\r\n * negative, near zero, or positive.\r\n *\r\n */\r\n public classifyAltitude(point: Point3d, tolerance: number = Geometry.smallMetricDistance): -1 | 0 | 1 {\r\n return Geometry.split3Way01(this.altitude(point), tolerance);\r\n }\r\n /**\r\n * Return a value -1, 0, 1 giving a signed indicator of whether the toleranced altitude of x,y,z is\r\n * negative, near zero, or positive.\r\n *\r\n */\r\n public classifyAltitudeXYZ(\r\n x: number, y: number, z: number, tolerance: number = Geometry.smallMetricDistance,\r\n ): -1 | 0 | 1 {\r\n return Geometry.split3Way01(this.altitudeXYZ(x, y, z), tolerance);\r\n }\r\n /**\r\n * Return the x component of the normal used to evaluate altitude.\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n * * See [[Plane3d]] note about scaling.\r\n */\r\n public abstract normalX(): number;\r\n /**\r\n * Return the y component of the normal used to evaluate altitude.\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n * * See [[Plane3d]] note about scaling.\r\n */\r\n public abstract normalY(): number;\r\n /**\r\n * Return the z component of the normal used to evaluate altitude.\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n * * See [[Plane3d]] note about scaling.\r\n */\r\n public abstract normalZ(): number;\r\n /**\r\n * Return the unit normal for the plane.\r\n * * The abstract base class implementation assembles the normal from normalX, normalY, normalZ calls.\r\n * * Derived classes should (but are not required to) override for maximum efficiency if the separate normal calls\r\n * cause repeated normalization.\r\n * @param result\r\n */\r\n public getUnitNormal(result?: Vector3d): Vector3d | undefined {\r\n return Vector3d.createNormalized(this.normalX(), this.normalY(), this.normalZ(), result);\r\n }\r\n /**\r\n * Return any point on the plane.\r\n * * Default implementation projects the origin (0,0,0) to the plane.\r\n * * Classes that have a preferred origin for their plane should override.\r\n * * Classes with a purely implicit equation of their plane can accept the default implementation\r\n */\r\n public getAnyPointOnPlane(result?: Point3d): Point3d {\r\n return this.projectXYZToPlane(0, 0, 0, result);\r\n }\r\n /**\r\n * Return the altitude of weighted spacePoint above or below the plane. (Below is negative)\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n * * See [[Plane3d]] note about scaling.\r\n */\r\n public abstract weightedAltitude(spacePoint: Point4d): number;\r\n /**\r\n * Return the dot product of spaceVector (x,y,z) with the plane's unit normal. This tells the rate of change of\r\n * altitude for a point moving at speed one along the spaceVector.\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n * * See [[Plane3d]] note about scaling.\r\n */\r\n public abstract velocityXYZ(x: number, y: number, z: number): number;\r\n /**\r\n * Return the dot product of spaceVector with the plane's unit normal. This tells the rate of change of altitude\r\n * for a point moving at speed one along the spaceVector.\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n * * See [[Plane3d]] note about scaling.\r\n */\r\n public abstract velocity(spaceVector: Vector3d): number;\r\n /**\r\n * Return the altitude of a point given as separate x,y,z components.\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n * * See [[Plane3d]] note about scaling.\r\n */\r\n public abstract altitudeXYZ(x: number, y: number, z: number): number;\r\n /**\r\n * Return the projection of spacePoint onto the plane.\r\n * * MUST BE IMPLEMENTED BY DERIVED CLASSES\r\n */\r\n public abstract projectPointToPlane(spacePoint: Point3d, result?: Point3d): Point3d;\r\n /** Return the projection of (x,y,z) onto the plane. */\r\n public projectXYZToPlane(x: number, y: number, z: number, result?: Point3d): Point3d {\r\n const point = Point3d.create(x, y, z, result);\r\n return this.projectPointToPlane(point, point);\r\n }\r\n}\r\n"]}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module CartesianGeometry
|
|
3
|
-
*/
|
|
4
1
|
import { Arc3d } from "../curve/Arc3d";
|
|
5
2
|
import { AnnounceNumberNumber, AnnounceNumberNumberCurvePrimitive, CurvePrimitive } from "../curve/CurvePrimitive";
|
|
6
3
|
import { GrowableXYZArray } from "../geometry3d/GrowableXYZArray";
|
|
@@ -9,20 +6,21 @@ import { Point3d } from "../geometry3d/Point3dVector3d";
|
|
|
9
6
|
import { Range1d } from "../geometry3d/Range";
|
|
10
7
|
import { GrowableXYZArrayCache } from "../geometry3d/ReusableObjectCache";
|
|
11
8
|
import { Clipper, PolygonClipper } from "./ClipUtils";
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
9
|
+
/**
|
|
10
|
+
* BooleanClipNode is an abstract base class for boolean actions by an array of clippers.
|
|
11
|
+
* * Derived class must implement:
|
|
14
12
|
* * The single point test `isPointOnOrInsideChildren`
|
|
15
13
|
* * Boolean operation on 1d intervals `combineIntervals`
|
|
16
|
-
* * The `keepInside` flag controls an additional optional flip of the boolean result
|
|
17
|
-
* * if `keepInside === true`, accept the "inside" of the
|
|
14
|
+
* * The `keepInside` flag controls an additional optional flip of the boolean result:
|
|
15
|
+
* * if `keepInside === true`, accept the "inside" of the child clippers.
|
|
18
16
|
* * if `keepInside === false`, accept the "outside" of the child clippers.
|
|
19
|
-
* * Hence the combinations of derived classes for (OR, AND, XOR) and keepInside are
|
|
20
|
-
* * (OR, true) = simple union (OR), i.e
|
|
21
|
-
* * (OR, false) = complement of union (NOR), i.e
|
|
22
|
-
* * (AND, true) = simple intersection (AND), i.e
|
|
23
|
-
* * (AND, false) = complement of intersection (NAND), i.e
|
|
24
|
-
* * (XOR,true) = simple parity, i.e
|
|
25
|
-
* * (XOR,false) = complement of parity
|
|
17
|
+
* * Hence the combinations of derived classes for (OR, AND, XOR) and keepInside are:
|
|
18
|
+
* * (OR, true) = simple union (OR), i.e., "in" one or more clips.
|
|
19
|
+
* * (OR, false) = complement of union (NOR), i.e., "outside" all clips.
|
|
20
|
+
* * (AND, true) = simple intersection (AND), i.e., "in" all clips.
|
|
21
|
+
* * (AND, false) = complement of intersection (NAND), i.e., "outside" one or more clips.
|
|
22
|
+
* * (XOR, true) = simple parity, i.e., "in" an odd number of clips.
|
|
23
|
+
* * (XOR, false) = complement of parity, i.e., "in" an even number of clips.
|
|
26
24
|
* @internal
|
|
27
25
|
*/
|
|
28
26
|
export declare abstract class BooleanClipNode implements Clipper {
|
|
@@ -37,65 +35,66 @@ export declare abstract class BooleanClipNode implements Clipper {
|
|
|
37
35
|
toJSON(): any;
|
|
38
36
|
/** Capture a (reference to a) child node or nodes */
|
|
39
37
|
captureChild(child: Clipper | Clipper[]): void;
|
|
40
|
-
/** Toggle the "keepInside" behavior. Return the prior value.
|
|
38
|
+
/** Toggle the "keepInside" behavior. Return the prior value. */
|
|
41
39
|
toggleResult(): boolean;
|
|
42
|
-
/** Set the "keepInside" behavior
|
|
40
|
+
/** Set the "keepInside" behavior. */
|
|
43
41
|
selectResult(keepInside: boolean): boolean;
|
|
44
42
|
/**
|
|
45
|
-
* Conditionally (if a1 > a0 strictly) call announce
|
|
43
|
+
* Conditionally (if a1 > a0 strictly) call `announce(a0, a1)`.
|
|
46
44
|
* * Return 0 if not called, 1 if called.
|
|
47
45
|
*/
|
|
48
46
|
protected testedAnnounceNN(a0: number, a1: number, announce?: AnnounceNumberNumber): number;
|
|
49
47
|
/**
|
|
50
|
-
* Conditionally (if a1 > a0 strictly) call announce
|
|
48
|
+
* Conditionally (if a1 > a0 strictly) call `announce(a0, a1, cp)`.
|
|
51
49
|
* * Return 0 if not called, 1 if called.
|
|
52
50
|
*/
|
|
53
51
|
protected testedAnnounceNNC(a0: number, a1: number, cp: CurvePrimitive, announce?: AnnounceNumberNumberCurvePrimitive): number;
|
|
54
|
-
/** Swap the _intervalsA and _intervalsB */
|
|
52
|
+
/** Swap the `_intervalsA` and `_intervalsB`. */
|
|
55
53
|
protected swapAB(): void;
|
|
56
54
|
/**
|
|
57
|
-
* Announce all "outside intervals" --not masked by intervals
|
|
55
|
+
* Announce all "outside intervals" -- not masked by intervals.
|
|
58
56
|
* * Return true if any intervals announced.
|
|
59
57
|
*/
|
|
60
58
|
protected announcePartsNN(keepInside: boolean, intervals: Range1d[], f0: number, f1: number, announce?: AnnounceNumberNumber): boolean;
|
|
61
59
|
/**
|
|
62
|
-
* Announce all "outside intervals" --not masked by intervals
|
|
60
|
+
* Announce all "outside intervals" -- not masked by intervals.
|
|
63
61
|
* * Return true if any intervals announced.
|
|
64
62
|
*/
|
|
65
63
|
protected announcePartsNNC(keepInside: boolean, intervals: Range1d[], f0: number, f1: number, cp: CurvePrimitive, announce?: AnnounceNumberNumberCurvePrimitive): boolean;
|
|
66
|
-
/** Invoke callback to test if a point is "in" this clipper */
|
|
64
|
+
/** Invoke callback to test if a point is "in" this clipper. */
|
|
67
65
|
isPointOnOrInside(point: Point3d): boolean;
|
|
68
|
-
/**
|
|
66
|
+
/** Method from [[Clipper]] interface. */
|
|
69
67
|
announceClippedSegmentIntervals(f0: number, f1: number, pointA: Point3d, pointB: Point3d, announce?: AnnounceNumberNumber): boolean;
|
|
70
|
-
/**
|
|
68
|
+
/** Method from [[Clipper]] interface. */
|
|
71
69
|
announceClippedArcIntervals(arc: Arc3d, announce?: AnnounceNumberNumberCurvePrimitive): boolean;
|
|
70
|
+
announceClippedCurveIntervals(curve: CurvePrimitive, announce?: AnnounceNumberNumberCurvePrimitive): boolean;
|
|
72
71
|
}
|
|
73
72
|
/**
|
|
74
|
-
* Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children
|
|
73
|
+
* Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children.
|
|
75
74
|
* @internal
|
|
76
75
|
*/
|
|
77
76
|
export declare class BooleanClipNodeUnion extends BooleanClipNode {
|
|
78
77
|
get operationName(): string;
|
|
79
78
|
constructor(keepInside: boolean);
|
|
80
|
-
/** Return true if inside any child clipper */
|
|
79
|
+
/** Return true if inside any child clipper. */
|
|
81
80
|
isPointOnOrInsideChildren(point: Point3d): boolean;
|
|
82
81
|
combineIntervals(operandA: Range1d[], operandB: Range1d[]): Range1d[];
|
|
83
82
|
appendPolygonClip(xyz: IndexedXYZCollection, insideFragments: GrowableXYZArray[], outsideFragments: GrowableXYZArray[], arrayCache: GrowableXYZArrayCache): void;
|
|
84
83
|
}
|
|
85
84
|
/**
|
|
86
|
-
* Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children
|
|
85
|
+
* Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children.
|
|
87
86
|
* @internal
|
|
88
87
|
*/
|
|
89
88
|
export declare class BooleanClipNodeParity extends BooleanClipNode {
|
|
90
89
|
get operationName(): string;
|
|
91
90
|
constructor(keepInside: boolean);
|
|
92
|
-
/** Return true if inside an odd number of clippers child clipper */
|
|
91
|
+
/** Return true if inside an odd number of clippers child clipper. */
|
|
93
92
|
isPointOnOrInsideChildren(point: Point3d): boolean;
|
|
94
93
|
combineIntervals(operandA: Range1d[], operandB: Range1d[]): Range1d[];
|
|
95
94
|
appendPolygonClip(xyz: IndexedXYZCollection, insideFragments: GrowableXYZArray[], outsideFragments: GrowableXYZArray[], arrayCache: GrowableXYZArrayCache): void;
|
|
96
95
|
}
|
|
97
96
|
/**
|
|
98
|
-
* Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children
|
|
97
|
+
* Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children.
|
|
99
98
|
* @internal
|
|
100
99
|
*/
|
|
101
100
|
export declare class BooleanClipNodeIntersection extends BooleanClipNode implements PolygonClipper {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanClipNode.d.ts","sourceRoot":"","sources":["../../../src/clipping/BooleanClipNode.ts"],"names":[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BAAqB;CAepC"}
|
|
@@ -2,23 +2,28 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module CartesianGeometry
|
|
7
|
+
*/
|
|
8
|
+
import { assert } from "@itwin/core-bentley";
|
|
5
9
|
import { Range1d } from "../geometry3d/Range";
|
|
6
10
|
import { Range1dArray } from "../numerics/Range1dArray";
|
|
7
11
|
import { ClipStepAction, ClipUtilities } from "./ClipUtils";
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
12
|
+
/**
|
|
13
|
+
* BooleanClipNode is an abstract base class for boolean actions by an array of clippers.
|
|
14
|
+
* * Derived class must implement:
|
|
10
15
|
* * The single point test `isPointOnOrInsideChildren`
|
|
11
16
|
* * Boolean operation on 1d intervals `combineIntervals`
|
|
12
|
-
* * The `keepInside` flag controls an additional optional flip of the boolean result
|
|
13
|
-
* * if `keepInside === true`, accept the "inside" of the
|
|
17
|
+
* * The `keepInside` flag controls an additional optional flip of the boolean result:
|
|
18
|
+
* * if `keepInside === true`, accept the "inside" of the child clippers.
|
|
14
19
|
* * if `keepInside === false`, accept the "outside" of the child clippers.
|
|
15
|
-
* * Hence the combinations of derived classes for (OR, AND, XOR) and keepInside are
|
|
16
|
-
* * (OR, true) = simple union (OR), i.e
|
|
17
|
-
* * (OR, false) = complement of union (NOR), i.e
|
|
18
|
-
* * (AND, true) = simple intersection (AND), i.e
|
|
19
|
-
* * (AND, false) = complement of intersection (NAND), i.e
|
|
20
|
-
* * (XOR,true) = simple parity, i.e
|
|
21
|
-
* * (XOR,false) = complement of parity
|
|
20
|
+
* * Hence the combinations of derived classes for (OR, AND, XOR) and keepInside are:
|
|
21
|
+
* * (OR, true) = simple union (OR), i.e., "in" one or more clips.
|
|
22
|
+
* * (OR, false) = complement of union (NOR), i.e., "outside" all clips.
|
|
23
|
+
* * (AND, true) = simple intersection (AND), i.e., "in" all clips.
|
|
24
|
+
* * (AND, false) = complement of intersection (NAND), i.e., "outside" one or more clips.
|
|
25
|
+
* * (XOR, true) = simple parity, i.e., "in" an odd number of clips.
|
|
26
|
+
* * (XOR, false) = complement of parity, i.e., "in" an even number of clips.
|
|
22
27
|
* @internal
|
|
23
28
|
*/
|
|
24
29
|
export class BooleanClipNode {
|
|
@@ -55,18 +60,18 @@ export class BooleanClipNode {
|
|
|
55
60
|
this._clippers.push(child);
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
|
-
/** Toggle the "keepInside" behavior. Return the prior value.
|
|
63
|
+
/** Toggle the "keepInside" behavior. Return the prior value. */
|
|
59
64
|
toggleResult() {
|
|
60
65
|
return this.selectResult(!this._keepInside);
|
|
61
66
|
}
|
|
62
|
-
/** Set the "keepInside" behavior
|
|
67
|
+
/** Set the "keepInside" behavior. */
|
|
63
68
|
selectResult(keepInside) {
|
|
64
69
|
const s = this._keepInside;
|
|
65
70
|
this._keepInside = keepInside;
|
|
66
71
|
return s;
|
|
67
72
|
}
|
|
68
73
|
/**
|
|
69
|
-
* Conditionally (if a1 > a0 strictly) call announce
|
|
74
|
+
* Conditionally (if a1 > a0 strictly) call `announce(a0, a1)`.
|
|
70
75
|
* * Return 0 if not called, 1 if called.
|
|
71
76
|
*/
|
|
72
77
|
testedAnnounceNN(a0, a1, announce) {
|
|
@@ -78,7 +83,7 @@ export class BooleanClipNode {
|
|
|
78
83
|
return 0;
|
|
79
84
|
}
|
|
80
85
|
/**
|
|
81
|
-
* Conditionally (if a1 > a0 strictly) call announce
|
|
86
|
+
* Conditionally (if a1 > a0 strictly) call `announce(a0, a1, cp)`.
|
|
82
87
|
* * Return 0 if not called, 1 if called.
|
|
83
88
|
*/
|
|
84
89
|
testedAnnounceNNC(a0, a1, cp, announce) {
|
|
@@ -89,14 +94,14 @@ export class BooleanClipNode {
|
|
|
89
94
|
}
|
|
90
95
|
return 0;
|
|
91
96
|
}
|
|
92
|
-
/** Swap the _intervalsA and _intervalsB */
|
|
97
|
+
/** Swap the `_intervalsA` and `_intervalsB`. */
|
|
93
98
|
swapAB() {
|
|
94
99
|
const q = this._intervalsA;
|
|
95
100
|
this._intervalsA = this._intervalsB;
|
|
96
101
|
this._intervalsB = q;
|
|
97
102
|
}
|
|
98
103
|
/**
|
|
99
|
-
* Announce all "outside intervals" --not masked by intervals
|
|
104
|
+
* Announce all "outside intervals" -- not masked by intervals.
|
|
100
105
|
* * Return true if any intervals announced.
|
|
101
106
|
*/
|
|
102
107
|
announcePartsNN(keepInside, intervals, f0, f1, announce) {
|
|
@@ -118,7 +123,7 @@ export class BooleanClipNode {
|
|
|
118
123
|
return numAnnounce > 0;
|
|
119
124
|
}
|
|
120
125
|
/**
|
|
121
|
-
* Announce all "outside intervals" --not masked by intervals
|
|
126
|
+
* Announce all "outside intervals" -- not masked by intervals.
|
|
122
127
|
* * Return true if any intervals announced.
|
|
123
128
|
*/
|
|
124
129
|
announcePartsNNC(keepInside, intervals, f0, f1, cp, announce) {
|
|
@@ -139,12 +144,12 @@ export class BooleanClipNode {
|
|
|
139
144
|
}
|
|
140
145
|
return numAnnounce > 0;
|
|
141
146
|
}
|
|
142
|
-
/** Invoke callback to test if a point is "in" this clipper */
|
|
147
|
+
/** Invoke callback to test if a point is "in" this clipper. */
|
|
143
148
|
isPointOnOrInside(point) {
|
|
144
149
|
const q = this.isPointOnOrInsideChildren(point);
|
|
145
150
|
return this._keepInside ? q : !q;
|
|
146
151
|
}
|
|
147
|
-
/**
|
|
152
|
+
/** Method from [[Clipper]] interface. */
|
|
148
153
|
announceClippedSegmentIntervals(f0, f1, pointA, pointB, announce) {
|
|
149
154
|
this._intervalsA.length = 0;
|
|
150
155
|
const announceIntervalB = (a0, a1) => {
|
|
@@ -171,7 +176,7 @@ export class BooleanClipNode {
|
|
|
171
176
|
}
|
|
172
177
|
return this.announcePartsNN(this._keepInside, this._intervalsA, f0, f1, announce);
|
|
173
178
|
}
|
|
174
|
-
/**
|
|
179
|
+
/** Method from [[Clipper]] interface. */
|
|
175
180
|
announceClippedArcIntervals(arc, announce) {
|
|
176
181
|
this._intervalsA.length = 0;
|
|
177
182
|
const announceIntervalB = (a0, a1) => {
|
|
@@ -192,17 +197,40 @@ export class BooleanClipNode {
|
|
|
192
197
|
}
|
|
193
198
|
return this.announcePartsNNC(this._keepInside, this._intervalsA, 0, 1, arc, announce);
|
|
194
199
|
}
|
|
200
|
+
/* Method from [[Clipper]] interface. */
|
|
201
|
+
announceClippedCurveIntervals(curve, announce) {
|
|
202
|
+
this._intervalsA.length = 0;
|
|
203
|
+
const announceIntervalB = (a0, a1, _cp) => {
|
|
204
|
+
this._intervalsB.push(Range1d.createXX(a0, a1));
|
|
205
|
+
};
|
|
206
|
+
let i = 0;
|
|
207
|
+
for (const c of this._clippers) {
|
|
208
|
+
this._intervalsB.length = 0;
|
|
209
|
+
c.announceClippedCurveIntervals?.(curve, announceIntervalB) ?? assert(false, () => `Expect ${c.constructor.name} to implement announceClippedCurveIntervals`);
|
|
210
|
+
Range1dArray.simplifySortUnion(this._intervalsB);
|
|
211
|
+
if (i === 0) {
|
|
212
|
+
this.swapAB();
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
this._intervalsA = this.combineIntervals(this._intervalsA, this._intervalsB);
|
|
216
|
+
}
|
|
217
|
+
i++;
|
|
218
|
+
}
|
|
219
|
+
return this.announcePartsNNC(this._keepInside, this._intervalsA, 0, 1, curve, announce);
|
|
220
|
+
}
|
|
195
221
|
}
|
|
196
222
|
/**
|
|
197
|
-
* Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children
|
|
223
|
+
* Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children.
|
|
198
224
|
* @internal
|
|
199
225
|
*/
|
|
200
226
|
export class BooleanClipNodeUnion extends BooleanClipNode {
|
|
201
|
-
get operationName() {
|
|
227
|
+
get operationName() {
|
|
228
|
+
return this._keepInside ? "OR" : "NOR";
|
|
229
|
+
}
|
|
202
230
|
constructor(keepInside) {
|
|
203
231
|
super(keepInside);
|
|
204
232
|
}
|
|
205
|
-
/** Return true if inside any child clipper */
|
|
233
|
+
/** Return true if inside any child clipper. */
|
|
206
234
|
isPointOnOrInsideChildren(point) {
|
|
207
235
|
for (const clipper of this._clippers) {
|
|
208
236
|
if (clipper.isPointOnOrInside(point))
|
|
@@ -218,15 +246,17 @@ export class BooleanClipNodeUnion extends BooleanClipNode {
|
|
|
218
246
|
}
|
|
219
247
|
}
|
|
220
248
|
/**
|
|
221
|
-
* Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children
|
|
249
|
+
* Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children.
|
|
222
250
|
* @internal
|
|
223
251
|
*/
|
|
224
252
|
export class BooleanClipNodeParity extends BooleanClipNode {
|
|
225
|
-
get operationName() {
|
|
253
|
+
get operationName() {
|
|
254
|
+
return this._keepInside ? "XOR" : "NXOR";
|
|
255
|
+
}
|
|
226
256
|
constructor(keepInside) {
|
|
227
257
|
super(keepInside);
|
|
228
258
|
}
|
|
229
|
-
/** Return true if inside an odd number of clippers child clipper */
|
|
259
|
+
/** Return true if inside an odd number of clippers child clipper. */
|
|
230
260
|
isPointOnOrInsideChildren(point) {
|
|
231
261
|
let q = false;
|
|
232
262
|
for (const clipper of this._clippers) {
|
|
@@ -243,11 +273,13 @@ export class BooleanClipNodeParity extends BooleanClipNode {
|
|
|
243
273
|
}
|
|
244
274
|
}
|
|
245
275
|
/**
|
|
246
|
-
* Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children
|
|
276
|
+
* Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children.
|
|
247
277
|
* @internal
|
|
248
278
|
*/
|
|
249
279
|
export class BooleanClipNodeIntersection extends BooleanClipNode {
|
|
250
|
-
get operationName() {
|
|
280
|
+
get operationName() {
|
|
281
|
+
return this._keepInside ? "AND" : "NAND";
|
|
282
|
+
}
|
|
251
283
|
constructor(keepInside) {
|
|
252
284
|
super(keepInside);
|
|
253
285
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanClipNode.js","sourceRoot":"","sources":["../../../src/clipping/BooleanClipNode.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAW/F,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAW,cAAc,EAAE,aAAa,EAAkB,MAAM,aAAa,CAAC;AAErF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAgB,eAAe;IACzB,SAAS,CAAY;IACrB,WAAW,CAAY;IACvB,WAAW,CAAY;IACvB,WAAW,CAAU;IAE/B,YAAmB,UAAmB;QACpC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAIM,MAAM;QACX,MAAM,IAAI,GAAG,EAAE,CAAC;QAChB,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAC/B,MAAM,EAAE,GAAG,CAAQ,CAAC;YACpB,IAAI,EAAE,CAAC,MAAM;gBACX,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3B,CAAC;QACD,gCAAgC;QAChC,MAAM,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC;QAC7B,MAAM,IAAI,GAAgC,EAAE,CAAC;QAC7C,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IACD,qDAAqD;IAC9C,YAAY,CAAC,KAA0B;QAC5C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,KAAK,MAAM,CAA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K,CAAC;QACjB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACM,gBAAgB,CAAC,QAAmB,EAAE,QAAmB;QAC9D,OAAO,YAAY,CAAC,eAAe,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC1D,CAAC;IACM,iBAAiB,CACtB,GAAyB,EACzB,eAAmC,EACnC,gBAAoC,EACpC,UAAiC;QAGjC,aAAa,CAAC,qBAAqB,CACjC,GAAG,EACH,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,gBAAgB,EACrD,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,eAAe,EACrD,SAAS,EACT,cAAc,CAAC,cAAc,EAC7B,cAAc,CAAC,SAAS,EACxB,cAAc,CAAC,QAAQ,EACvB,UAAU,CACX,CAAC;IACJ,CAAC;CACF","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 { AnnounceNumberNumber, AnnounceNumberNumberCurvePrimitive, CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Range1d } from \"../geometry3d/Range\";\r\nimport { GrowableXYZArrayCache } from \"../geometry3d/ReusableObjectCache\";\r\nimport { Range1dArray } from \"../numerics/Range1dArray\";\r\nimport { Clipper, ClipStepAction, ClipUtilities, PolygonClipper } from \"./ClipUtils\";\r\n\r\n/** BooleanClipNode is an abstract base class for boolean actions by an array of clippers.\r\n * * Derived class must implement\r\n * * The single point test `isPointOnOrInsideChildren`\r\n * * Boolean operation on 1d intervals `combineIntervals`\r\n * * The `keepInside` flag controls an additional optional flip of the boolean result.\r\n * * if `keepInside === true`, accept the \"inside\" of the clip clippers\r\n * * if `keepInside === false`, accept the \"outside\" of the child clippers.\r\n * * Hence the combinations of derived classes for (OR, AND, XOR) and keepInside are\r\n * * (OR, true) = simple union (OR), i.e. \"in\" one or more clips\r\n * * (OR, false) = complement of union (NOR), i.e. \"outside\" all clips\r\n * * (AND, true) = simple intersection (AND), i.e. \"in\" all clips\r\n * * (AND, false) = complement of intersection (NAND), i.e. \"outside\" one or more clips\r\n * * (XOR,true) = simple parity, i.e. \"in\" an odd number of clips\r\n * * (XOR,false) = complement of parity ), i.e. \"in\" an even number of clips\r\n * @internal\r\n */\r\nexport abstract class BooleanClipNode implements Clipper {\r\n protected _clippers: Clipper[];\r\n protected _intervalsA: Range1d[];\r\n protected _intervalsB: Range1d[];\r\n protected _keepInside: boolean;\r\n\r\n public constructor(keepInside: boolean) {\r\n this._keepInside = keepInside;\r\n this._clippers = [];\r\n this._intervalsA = [];\r\n this._intervalsB = [];\r\n }\r\n protected abstract isPointOnOrInsideChildren(point: Point3d): boolean;\r\n protected abstract combineIntervals(operandA: Range1d[], operandB: Range1d[]): Range1d[];\r\n public abstract get operationName(): string;\r\n public toJSON(): any {\r\n const data = [];\r\n for (const c of this._clippers) {\r\n const c1 = c as any;\r\n if (c1.toJSON)\r\n data.push(c1.toJSON());\r\n }\r\n // return this.formatJSON(data);\r\n const s = this.operationName;\r\n const json: { [opType: string]: any[] } = {};\r\n json[s] = data;\r\n return json;\r\n }\r\n /** Capture a (reference to a) child node or nodes */\r\n public captureChild(child: Clipper | Clipper[]) {\r\n if (Array.isArray(child)) {\r\n for (const c of child) this.captureChild(c);\r\n } else {\r\n this._clippers.push(child);\r\n }\r\n }\r\n /** Toggle the \"keepInside\" behavior. Return the prior value. */\r\n public toggleResult(): boolean {\r\n return this.selectResult(!this._keepInside);\r\n }\r\n /** Set the \"keepInside\" behavior */\r\n public selectResult(keepInside: boolean): boolean {\r\n const s = this._keepInside;\r\n this._keepInside = keepInside;\r\n return s;\r\n }\r\n /**\r\n * Conditionally (if a1 > a0 strictly) call announce (a0, a1).\r\n * * Return 0 if not called, 1 if called.\r\n */\r\n protected testedAnnounceNN(a0: number, a1: number, announce?: AnnounceNumberNumber): number {\r\n if (a0 < a1) {\r\n if (announce)\r\n announce(a0, a1);\r\n return 1;\r\n }\r\n return 0;\r\n }\r\n /**\r\n * Conditionally (if a1 > a0 strictly) call announce (a0, a1, cp).\r\n * * Return 0 if not called, 1 if called.\r\n */\r\n protected testedAnnounceNNC(\r\n a0: number, a1: number, cp: CurvePrimitive, announce?: AnnounceNumberNumberCurvePrimitive,\r\n ): number {\r\n if (a0 < a1) {\r\n if (announce)\r\n announce(a0, a1, cp);\r\n return 1;\r\n }\r\n return 0;\r\n }\r\n /** Swap the _intervalsA and _intervalsB */\r\n protected swapAB(): void {\r\n const q = this._intervalsA;\r\n this._intervalsA = this._intervalsB;\r\n this._intervalsB = q;\r\n }\r\n /**\r\n * Announce all \"outside intervals\" --not masked by intervals\r\n * * Return true if any intervals announced.\r\n */\r\n protected announcePartsNN(\r\n keepInside: boolean, intervals: Range1d[], f0: number, f1: number, announce?: AnnounceNumberNumber,\r\n ): boolean {\r\n let numAnnounce = 0;\r\n if (!keepInside) {\r\n let lowFraction = f0;\r\n for (const interval of intervals) {\r\n numAnnounce += this.testedAnnounceNN(lowFraction, interval.low, announce);\r\n lowFraction = interval.high;\r\n }\r\n numAnnounce += this.testedAnnounceNN(lowFraction, f1, announce);\r\n } else {\r\n for (const interval of intervals) {\r\n // use f0..f1 ?\r\n numAnnounce += this.testedAnnounceNN(interval.low, interval.high, announce);\r\n }\r\n }\r\n return numAnnounce > 0;\r\n }\r\n /**\r\n * Announce all \"outside intervals\" --not masked by intervals\r\n * * Return true if any intervals announced.\r\n */\r\n protected announcePartsNNC(\r\n keepInside: boolean, intervals: Range1d[], f0: number, f1: number, cp: CurvePrimitive, announce?: AnnounceNumberNumberCurvePrimitive,\r\n ): boolean {\r\n let numAnnounce = 0;\r\n if (!keepInside) {\r\n let lowFraction = f0;\r\n for (const interval of intervals) {\r\n numAnnounce += this.testedAnnounceNNC(lowFraction, interval.low, cp, announce);\r\n lowFraction = interval.high;\r\n }\r\n numAnnounce += this.testedAnnounceNNC(lowFraction, f1, cp, announce);\r\n } else {\r\n for (const interval of intervals) {\r\n // use f0..f1 ?\r\n numAnnounce += this.testedAnnounceNNC(interval.low, interval.high, cp, announce);\r\n }\r\n }\r\n return numAnnounce > 0;\r\n }\r\n /** Invoke callback to test if a point is \"in\" this clipper */\r\n public isPointOnOrInside(point: Point3d): boolean {\r\n const q = this.isPointOnOrInsideChildren(point);\r\n return this._keepInside ? q : !q;\r\n }\r\n /** Announce \"in\" portions of a line segment. See `Clipper.announceClippedSegmentIntervals` */\r\n public announceClippedSegmentIntervals(\r\n f0: number, f1: number, pointA: Point3d, pointB: Point3d, announce?: AnnounceNumberNumber,\r\n ): boolean {\r\n this._intervalsA.length = 0;\r\n const announceIntervalB = (a0: number, a1: number) => {\r\n this._intervalsB.push(Range1d.createXX(a0, a1));\r\n };\r\n // Strategy:\r\n // _intervalsA is the accumulated UNION of from clippers\r\n // _intervalsB is the current clipper.\r\n // announceIntervalB appends single new interval to _intervalB\r\n // at end, output gaps in _intervalsA\r\n //\r\n let i = 0;\r\n for (const c of this._clippers) {\r\n this._intervalsB.length = 0;\r\n c.announceClippedSegmentIntervals(f0, f1, pointA, pointB, announceIntervalB);\r\n Range1dArray.simplifySortUnion(this._intervalsB);\r\n if (i === 0) {\r\n this.swapAB();\r\n } else {\r\n this._intervalsA = this.combineIntervals(this._intervalsA, this._intervalsB);\r\n }\r\n i++;\r\n }\r\n return this.announcePartsNN(this._keepInside, this._intervalsA, f0, f1, announce);\r\n }\r\n /** Announce \"in\" portions of a line segment. See `Clipper.announceClippedSegmentIntervals` */\r\n public announceClippedArcIntervals(arc: Arc3d, announce?: AnnounceNumberNumberCurvePrimitive): boolean {\r\n this._intervalsA.length = 0;\r\n const announceIntervalB = (a0: number, a1: number) => {\r\n this._intervalsB.push(Range1d.createXX(a0, a1));\r\n };\r\n let i = 0;\r\n for (const c of this._clippers) {\r\n this._intervalsB.length = 0;\r\n c.announceClippedArcIntervals(arc, announceIntervalB);\r\n Range1dArray.simplifySortUnion(this._intervalsB);\r\n if (i === 0) {\r\n this.swapAB();\r\n } else {\r\n this._intervalsA = this.combineIntervals(this._intervalsA, this._intervalsB);\r\n }\r\n i++;\r\n }\r\n return this.announcePartsNNC(this._keepInside, this._intervalsA, 0, 1, arc, announce);\r\n }\r\n}\r\n\r\n/**\r\n * Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children\r\n * @internal\r\n */\r\nexport class BooleanClipNodeUnion extends BooleanClipNode {\r\n public get operationName(): string { return this._keepInside ? \"OR\" : \"NOR\"; }\r\n public constructor(keepInside: boolean) {\r\n super(keepInside);\r\n }\r\n /** Return true if inside any child clipper */\r\n public isPointOnOrInsideChildren(point: Point3d): boolean {\r\n for (const clipper of this._clippers) {\r\n if (clipper.isPointOnOrInside(point))\r\n return true;\r\n }\r\n return false;\r\n }\r\n public combineIntervals(operandA: Range1d[], operandB: Range1d[]): Range1d[] {\r\n return Range1dArray.unionSorted(operandA, operandB);\r\n }\r\n public appendPolygonClip(\r\n xyz: IndexedXYZCollection,\r\n insideFragments: GrowableXYZArray[],\r\n outsideFragments: GrowableXYZArray[],\r\n arrayCache: GrowableXYZArrayCache,\r\n ) {\r\n ClipUtilities.doPolygonClipSequence(\r\n xyz,\r\n this._clippers,\r\n this._keepInside ? insideFragments : outsideFragments,\r\n this._keepInside ? outsideFragments : insideFragments,\r\n undefined,\r\n ClipStepAction.acceptIn,\r\n ClipStepAction.passToNextStep,\r\n ClipStepAction.acceptOut,\r\n arrayCache,\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children\r\n * @internal\r\n */\r\nexport class BooleanClipNodeParity extends BooleanClipNode {\r\n public get operationName(): string { return this._keepInside ? \"XOR\" : \"NXOR\"; }\r\n public constructor(keepInside: boolean) {\r\n super(keepInside);\r\n }\r\n /** Return true if inside an odd number of clippers child clipper */\r\n public isPointOnOrInsideChildren(point: Point3d): boolean {\r\n let q = false;\r\n for (const clipper of this._clippers) {\r\n if (clipper.isPointOnOrInside(point))\r\n q = !q;\r\n }\r\n return q;\r\n }\r\n public combineIntervals(operandA: Range1d[], operandB: Range1d[]): Range1d[] {\r\n return Range1dArray.paritySorted(operandA, operandB);\r\n }\r\n public appendPolygonClip(\r\n xyz: IndexedXYZCollection,\r\n insideFragments: GrowableXYZArray[],\r\n outsideFragments: GrowableXYZArray[],\r\n arrayCache: GrowableXYZArrayCache,\r\n ) {\r\n ClipUtilities.doPolygonClipParitySequence(\r\n xyz,\r\n this._clippers,\r\n this._keepInside ? insideFragments : outsideFragments,\r\n this._keepInside ? outsideFragments : insideFragments,\r\n arrayCache,\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children\r\n * @internal\r\n */\r\nexport class BooleanClipNodeIntersection extends BooleanClipNode implements PolygonClipper {\r\n public get operationName(): string { return this._keepInside ? \"AND\" : \"NAND\"; }\r\n public constructor(keepInside: boolean) {\r\n super(keepInside);\r\n }\r\n /** Return false if outside of any child clipper */\r\n public isPointOnOrInsideChildren(point: Point3d): boolean {\r\n for (const clipper of this._clippers) {\r\n if (!clipper.isPointOnOrInside(point))\r\n return false;\r\n }\r\n return true;\r\n }\r\n public combineIntervals(operandA: Range1d[], operandB: Range1d[]): Range1d[] {\r\n return Range1dArray.intersectSorted(operandA, operandB);\r\n }\r\n public appendPolygonClip(\r\n xyz: IndexedXYZCollection,\r\n insideFragments: GrowableXYZArray[],\r\n outsideFragments: GrowableXYZArray[],\r\n arrayCache: GrowableXYZArrayCache,\r\n ) {\r\n\r\n ClipUtilities.doPolygonClipSequence(\r\n xyz,\r\n this._clippers,\r\n this._keepInside ? insideFragments : outsideFragments,\r\n this._keepInside ? outsideFragments : insideFragments,\r\n undefined,\r\n ClipStepAction.passToNextStep,\r\n ClipStepAction.acceptOut,\r\n ClipStepAction.acceptIn,\r\n arrayCache,\r\n );\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"BooleanClipNode.js","sourceRoot":"","sources":["../../../src/clipping/BooleanClipNode.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAM7C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAW,cAAc,EAAE,aAAa,EAAkB,MAAM,aAAa,CAAC;AAErF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAgB,eAAe;IACzB,SAAS,CAAY;IACrB,WAAW,CAAY;IACvB,WAAW,CAAY;IACvB,WAAW,CAAU;IAC/B,YAAmB,UAAmB;QACpC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAIM,MAAM;QACX,MAAM,IAAI,GAAG,EAAE,CAAC;QAChB,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAC/B,MAAM,EAAE,GAAG,CAAQ,CAAC;YACpB,IAAI,EAAE,CAAC,MAAM;gBACX,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3B,CAAC;QACD,gCAAgC;QAChC,MAAM,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC;QAC7B,MAAM,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IAAI,CAAC,SAAS,EAAE,CAAC;YACrC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC;gBACnC,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACM,gBAAgB,CAAC,QAAmB,EAAE,QAAmB;QAC9D,OAAO,YAAY,CAAC,eAAe,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC1D,CAAC;IACM,iBAAiB,CACtB,GAAyB,EACzB,eAAmC,EACnC,gBAAoC,EACpC,UAAiC;QAGjC,aAAa,CAAC,qBAAqB,CACjC,GAAG,EACH,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,gBAAgB,EACrD,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,eAAe,EACrD,SAAS,EACT,cAAc,CAAC,cAAc,EAC7B,cAAc,CAAC,SAAS,EACxB,cAAc,CAAC,QAAQ,EACvB,UAAU,CACX,CAAC;IACJ,CAAC;CACF","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 { assert } from \"@itwin/core-bentley\";\r\nimport { Arc3d } from \"../curve/Arc3d\";\r\nimport { AnnounceNumberNumber, AnnounceNumberNumberCurvePrimitive, CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Range1d } from \"../geometry3d/Range\";\r\nimport { GrowableXYZArrayCache } from \"../geometry3d/ReusableObjectCache\";\r\nimport { Range1dArray } from \"../numerics/Range1dArray\";\r\nimport { Clipper, ClipStepAction, ClipUtilities, PolygonClipper } from \"./ClipUtils\";\r\n\r\n/**\r\n * BooleanClipNode is an abstract base class for boolean actions by an array of clippers.\r\n * * Derived class must implement:\r\n * * The single point test `isPointOnOrInsideChildren`\r\n * * Boolean operation on 1d intervals `combineIntervals`\r\n * * The `keepInside` flag controls an additional optional flip of the boolean result:\r\n * * if `keepInside === true`, accept the \"inside\" of the child clippers.\r\n * * if `keepInside === false`, accept the \"outside\" of the child clippers.\r\n * * Hence the combinations of derived classes for (OR, AND, XOR) and keepInside are:\r\n * * (OR, true) = simple union (OR), i.e., \"in\" one or more clips.\r\n * * (OR, false) = complement of union (NOR), i.e., \"outside\" all clips.\r\n * * (AND, true) = simple intersection (AND), i.e., \"in\" all clips.\r\n * * (AND, false) = complement of intersection (NAND), i.e., \"outside\" one or more clips.\r\n * * (XOR, true) = simple parity, i.e., \"in\" an odd number of clips.\r\n * * (XOR, false) = complement of parity, i.e., \"in\" an even number of clips.\r\n * @internal\r\n */\r\nexport abstract class BooleanClipNode implements Clipper {\r\n protected _clippers: Clipper[];\r\n protected _intervalsA: Range1d[];\r\n protected _intervalsB: Range1d[];\r\n protected _keepInside: boolean;\r\n public constructor(keepInside: boolean) {\r\n this._keepInside = keepInside;\r\n this._clippers = [];\r\n this._intervalsA = [];\r\n this._intervalsB = [];\r\n }\r\n protected abstract isPointOnOrInsideChildren(point: Point3d): boolean;\r\n protected abstract combineIntervals(operandA: Range1d[], operandB: Range1d[]): Range1d[];\r\n public abstract get operationName(): string;\r\n public toJSON(): any {\r\n const data = [];\r\n for (const c of this._clippers) {\r\n const c1 = c as any;\r\n if (c1.toJSON)\r\n data.push(c1.toJSON());\r\n }\r\n // return this.formatJSON(data);\r\n const s = this.operationName;\r\n const json: { [opType: string]: any[] } = {};\r\n json[s] = data;\r\n return json;\r\n }\r\n /** Capture a (reference to a) child node or nodes */\r\n public captureChild(child: Clipper | Clipper[]) {\r\n if (Array.isArray(child)) {\r\n for (const c of child) this.captureChild(c);\r\n } else {\r\n this._clippers.push(child);\r\n }\r\n }\r\n /** Toggle the \"keepInside\" behavior. Return the prior value. */\r\n public toggleResult(): boolean {\r\n return this.selectResult(!this._keepInside);\r\n }\r\n /** Set the \"keepInside\" behavior. */\r\n public selectResult(keepInside: boolean): boolean {\r\n const s = this._keepInside;\r\n this._keepInside = keepInside;\r\n return s;\r\n }\r\n /**\r\n * Conditionally (if a1 > a0 strictly) call `announce(a0, a1)`.\r\n * * Return 0 if not called, 1 if called.\r\n */\r\n protected testedAnnounceNN(a0: number, a1: number, announce?: AnnounceNumberNumber): number {\r\n if (a0 < a1) {\r\n if (announce)\r\n announce(a0, a1);\r\n return 1;\r\n }\r\n return 0;\r\n }\r\n /**\r\n * Conditionally (if a1 > a0 strictly) call `announce(a0, a1, cp)`.\r\n * * Return 0 if not called, 1 if called.\r\n */\r\n protected testedAnnounceNNC(\r\n a0: number, a1: number, cp: CurvePrimitive, announce?: AnnounceNumberNumberCurvePrimitive,\r\n ): number {\r\n if (a0 < a1) {\r\n if (announce)\r\n announce(a0, a1, cp);\r\n return 1;\r\n }\r\n return 0;\r\n }\r\n /** Swap the `_intervalsA` and `_intervalsB`. */\r\n protected swapAB(): void {\r\n const q = this._intervalsA;\r\n this._intervalsA = this._intervalsB;\r\n this._intervalsB = q;\r\n }\r\n /**\r\n * Announce all \"outside intervals\" -- not masked by intervals.\r\n * * Return true if any intervals announced.\r\n */\r\n protected announcePartsNN(\r\n keepInside: boolean, intervals: Range1d[], f0: number, f1: number, announce?: AnnounceNumberNumber,\r\n ): boolean {\r\n let numAnnounce = 0;\r\n if (!keepInside) {\r\n let lowFraction = f0;\r\n for (const interval of intervals) {\r\n numAnnounce += this.testedAnnounceNN(lowFraction, interval.low, announce);\r\n lowFraction = interval.high;\r\n }\r\n numAnnounce += this.testedAnnounceNN(lowFraction, f1, announce);\r\n } else {\r\n for (const interval of intervals) {\r\n // use f0..f1 ?\r\n numAnnounce += this.testedAnnounceNN(interval.low, interval.high, announce);\r\n }\r\n }\r\n return numAnnounce > 0;\r\n }\r\n /**\r\n * Announce all \"outside intervals\" -- not masked by intervals.\r\n * * Return true if any intervals announced.\r\n */\r\n protected announcePartsNNC(\r\n keepInside: boolean, intervals: Range1d[], f0: number, f1: number, cp: CurvePrimitive, announce?: AnnounceNumberNumberCurvePrimitive,\r\n ): boolean {\r\n let numAnnounce = 0;\r\n if (!keepInside) {\r\n let lowFraction = f0;\r\n for (const interval of intervals) {\r\n numAnnounce += this.testedAnnounceNNC(lowFraction, interval.low, cp, announce);\r\n lowFraction = interval.high;\r\n }\r\n numAnnounce += this.testedAnnounceNNC(lowFraction, f1, cp, announce);\r\n } else {\r\n for (const interval of intervals) {\r\n // use f0..f1 ?\r\n numAnnounce += this.testedAnnounceNNC(interval.low, interval.high, cp, announce);\r\n }\r\n }\r\n return numAnnounce > 0;\r\n }\r\n /** Invoke callback to test if a point is \"in\" this clipper. */\r\n public isPointOnOrInside(point: Point3d): boolean {\r\n const q = this.isPointOnOrInsideChildren(point);\r\n return this._keepInside ? q : !q;\r\n }\r\n /** Method from [[Clipper]] interface. */\r\n public announceClippedSegmentIntervals(\r\n f0: number, f1: number, pointA: Point3d, pointB: Point3d, announce?: AnnounceNumberNumber,\r\n ): boolean {\r\n this._intervalsA.length = 0;\r\n const announceIntervalB = (a0: number, a1: number) => {\r\n this._intervalsB.push(Range1d.createXX(a0, a1));\r\n };\r\n // Strategy:\r\n // _intervalsA is the accumulated UNION of from clippers\r\n // _intervalsB is the current clipper.\r\n // announceIntervalB appends single new interval to _intervalB\r\n // at end, output gaps in _intervalsA\r\n //\r\n let i = 0;\r\n for (const c of this._clippers) {\r\n this._intervalsB.length = 0;\r\n c.announceClippedSegmentIntervals(f0, f1, pointA, pointB, announceIntervalB);\r\n Range1dArray.simplifySortUnion(this._intervalsB);\r\n if (i === 0) {\r\n this.swapAB();\r\n } else {\r\n this._intervalsA = this.combineIntervals(this._intervalsA, this._intervalsB);\r\n }\r\n i++;\r\n }\r\n return this.announcePartsNN(this._keepInside, this._intervalsA, f0, f1, announce);\r\n }\r\n /** Method from [[Clipper]] interface. */\r\n public announceClippedArcIntervals(arc: Arc3d, announce?: AnnounceNumberNumberCurvePrimitive): boolean {\r\n this._intervalsA.length = 0;\r\n const announceIntervalB = (a0: number, a1: number) => {\r\n this._intervalsB.push(Range1d.createXX(a0, a1));\r\n };\r\n let i = 0;\r\n for (const c of this._clippers) {\r\n this._intervalsB.length = 0;\r\n c.announceClippedArcIntervals(arc, announceIntervalB);\r\n Range1dArray.simplifySortUnion(this._intervalsB);\r\n if (i === 0) {\r\n this.swapAB();\r\n } else {\r\n this._intervalsA = this.combineIntervals(this._intervalsA, this._intervalsB);\r\n }\r\n i++;\r\n }\r\n return this.announcePartsNNC(this._keepInside, this._intervalsA, 0, 1, arc, announce);\r\n }\r\n /* Method from [[Clipper]] interface. */\r\n public announceClippedCurveIntervals(curve: CurvePrimitive, announce?: AnnounceNumberNumberCurvePrimitive): boolean {\r\n this._intervalsA.length = 0;\r\n const announceIntervalB = (a0: number, a1: number, _cp: CurvePrimitive) => {\r\n this._intervalsB.push(Range1d.createXX(a0, a1));\r\n };\r\n let i = 0;\r\n for (const c of this._clippers) {\r\n this._intervalsB.length = 0;\r\n c.announceClippedCurveIntervals?.(curve, announceIntervalB) ?? assert(false, () => `Expect ${c.constructor.name} to implement announceClippedCurveIntervals`);\r\n Range1dArray.simplifySortUnion(this._intervalsB);\r\n if (i === 0) {\r\n this.swapAB();\r\n } else {\r\n this._intervalsA = this.combineIntervals(this._intervalsA, this._intervalsB);\r\n }\r\n i++;\r\n }\r\n return this.announcePartsNNC(this._keepInside, this._intervalsA, 0, 1, curve, announce);\r\n }\r\n}\r\n\r\n/**\r\n * Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children.\r\n * @internal\r\n */\r\nexport class BooleanClipNodeUnion extends BooleanClipNode {\r\n public get operationName(): string {\r\n return this._keepInside ? \"OR\" : \"NOR\";\r\n }\r\n public constructor(keepInside: boolean) {\r\n super(keepInside);\r\n }\r\n /** Return true if inside any child clipper. */\r\n public isPointOnOrInsideChildren(point: Point3d): boolean {\r\n for (const clipper of this._clippers) {\r\n if (clipper.isPointOnOrInside(point))\r\n return true;\r\n }\r\n return false;\r\n }\r\n public combineIntervals(operandA: Range1d[], operandB: Range1d[]): Range1d[] {\r\n return Range1dArray.unionSorted(operandA, operandB);\r\n }\r\n public appendPolygonClip(\r\n xyz: IndexedXYZCollection,\r\n insideFragments: GrowableXYZArray[],\r\n outsideFragments: GrowableXYZArray[],\r\n arrayCache: GrowableXYZArrayCache,\r\n ) {\r\n ClipUtilities.doPolygonClipSequence(\r\n xyz,\r\n this._clippers,\r\n this._keepInside ? insideFragments : outsideFragments,\r\n this._keepInside ? outsideFragments : insideFragments,\r\n undefined,\r\n ClipStepAction.acceptIn,\r\n ClipStepAction.passToNextStep,\r\n ClipStepAction.acceptOut,\r\n arrayCache,\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children.\r\n * @internal\r\n */\r\nexport class BooleanClipNodeParity extends BooleanClipNode {\r\n public get operationName(): string {\r\n return this._keepInside ? \"XOR\" : \"NXOR\";\r\n }\r\n public constructor(keepInside: boolean) {\r\n super(keepInside);\r\n }\r\n /** Return true if inside an odd number of clippers child clipper. */\r\n public isPointOnOrInsideChildren(point: Point3d): boolean {\r\n let q = false;\r\n for (const clipper of this._clippers) {\r\n if (clipper.isPointOnOrInside(point))\r\n q = !q;\r\n }\r\n return q;\r\n }\r\n public combineIntervals(operandA: Range1d[], operandB: Range1d[]): Range1d[] {\r\n return Range1dArray.paritySorted(operandA, operandB);\r\n }\r\n public appendPolygonClip(\r\n xyz: IndexedXYZCollection,\r\n insideFragments: GrowableXYZArray[],\r\n outsideFragments: GrowableXYZArray[],\r\n arrayCache: GrowableXYZArrayCache,\r\n ) {\r\n ClipUtilities.doPolygonClipParitySequence(\r\n xyz,\r\n this._clippers,\r\n this._keepInside ? insideFragments : outsideFragments,\r\n this._keepInside ? outsideFragments : insideFragments,\r\n arrayCache,\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Implement [BooleanClipNode] virtual methods for intersection (boolean OR) among children.\r\n * @internal\r\n */\r\nexport class BooleanClipNodeIntersection extends BooleanClipNode implements PolygonClipper {\r\n public get operationName(): string {\r\n return this._keepInside ? \"AND\" : \"NAND\";\r\n }\r\n public constructor(keepInside: boolean) {\r\n super(keepInside);\r\n }\r\n /** Return false if outside of any child clipper */\r\n public isPointOnOrInsideChildren(point: Point3d): boolean {\r\n for (const clipper of this._clippers) {\r\n if (!clipper.isPointOnOrInside(point))\r\n return false;\r\n }\r\n return true;\r\n }\r\n public combineIntervals(operandA: Range1d[], operandB: Range1d[]): Range1d[] {\r\n return Range1dArray.intersectSorted(operandA, operandB);\r\n }\r\n public appendPolygonClip(\r\n xyz: IndexedXYZCollection,\r\n insideFragments: GrowableXYZArray[],\r\n outsideFragments: GrowableXYZArray[],\r\n arrayCache: GrowableXYZArrayCache,\r\n ) {\r\n\r\n ClipUtilities.doPolygonClipSequence(\r\n xyz,\r\n this._clippers,\r\n this._keepInside ? insideFragments : outsideFragments,\r\n this._keepInside ? outsideFragments : insideFragments,\r\n undefined,\r\n ClipStepAction.passToNextStep,\r\n ClipStepAction.acceptOut,\r\n ClipStepAction.acceptIn,\r\n arrayCache,\r\n );\r\n }\r\n}\r\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Arc3d } from "../curve/Arc3d";
|
|
2
|
-
import { AnnounceNumberNumberCurvePrimitive } from "../curve/CurvePrimitive";
|
|
2
|
+
import { AnnounceNumberNumber, AnnounceNumberNumberCurvePrimitive, CurvePrimitive } from "../curve/CurvePrimitive";
|
|
3
3
|
import { Angle } from "../geometry3d/Angle";
|
|
4
4
|
import { GrowableFloat64Array } from "../geometry3d/GrowableFloat64Array";
|
|
5
5
|
import { GrowableXYZArray } from "../geometry3d/GrowableXYZArray";
|
|
@@ -36,7 +36,7 @@ export interface ClipPlaneProps {
|
|
|
36
36
|
* More details can be found at docs/learning/geometry/Clipping.md
|
|
37
37
|
*
|
|
38
38
|
* Hence
|
|
39
|
-
* * The halfspace function evaluation for
|
|
39
|
+
* * The halfspace function evaluation for point (x,y,z) is `(x,y,z) DOT (u,v,w) - signedDistance`.
|
|
40
40
|
* * POSITIVE values of the halfspace function are "inside".
|
|
41
41
|
* * ZERO value of the halfspace function is "on".
|
|
42
42
|
* * NEGATIVE value of the halfspace function is "outside".
|
|
@@ -49,7 +49,7 @@ export declare class ClipPlane extends Plane3d implements Clipper, PolygonClippe
|
|
|
49
49
|
/**
|
|
50
50
|
* Construct a parallel plane through the origin.
|
|
51
51
|
* * Move it to the actual position.
|
|
52
|
-
* * _distanceFromOrigin is the distance it moved, with the (inward) normal direction as positive
|
|
52
|
+
* * _distanceFromOrigin is the distance it moved, with the (inward) normal direction as positive.
|
|
53
53
|
*/
|
|
54
54
|
private _distanceFromOrigin;
|
|
55
55
|
private _invisible;
|
|
@@ -205,17 +205,16 @@ export declare class ClipPlane extends Plane3d implements Clipper, PolygonClippe
|
|
|
205
205
|
*/
|
|
206
206
|
isPointOn(point: Point3d, tolerance?: number): boolean;
|
|
207
207
|
/**
|
|
208
|
-
* Compute intersections of an (UNBOUNDED) arc with the plane.
|
|
209
|
-
* @param arc arc to test.
|
|
210
|
-
* @param intersectionRadians array to receive results
|
|
208
|
+
* Compute intersections of an (UNBOUNDED) arc with the plane. Append them (as radians) to a growing array.
|
|
209
|
+
* @param arc arc to test. The angle limits of the arc are NOT considered.
|
|
210
|
+
* @param intersectionRadians array to receive results.
|
|
211
211
|
*/
|
|
212
212
|
appendIntersectionRadians(arc: Arc3d, intersectionRadians: GrowableFloat64Array): void;
|
|
213
|
-
private static
|
|
214
|
-
/**
|
|
215
|
-
* Announce fractional intervals of arc clip.
|
|
216
|
-
* * Each call to `announce(fraction0, fraction1, arc)` announces one interval that is inside the clip plane.
|
|
217
|
-
*/
|
|
213
|
+
private static _clipFractionArray;
|
|
214
|
+
/** Method from [[Clipper]] interface. */
|
|
218
215
|
announceClippedArcIntervals(arc: Arc3d, announce?: AnnounceNumberNumberCurvePrimitive): boolean;
|
|
216
|
+
/** Method from [[Clipper]] interface. */
|
|
217
|
+
announceClippedCurveIntervals(curve: CurvePrimitive, announce?: AnnounceNumberNumberCurvePrimitive): boolean;
|
|
219
218
|
/**
|
|
220
219
|
* Compute intersection of (unbounded) segment with the plane.
|
|
221
220
|
* * If the ends are on the same side of the plane, return undefined.
|
|
@@ -262,8 +261,8 @@ export declare class ClipPlane extends Plane3d implements Clipper, PolygonClippe
|
|
|
262
261
|
* * Both params default to true to get the full effect of transforming space.
|
|
263
262
|
*/
|
|
264
263
|
multiplyPlaneByMatrix4d(matrix: Matrix4d, invert?: boolean, transpose?: boolean): boolean;
|
|
265
|
-
/**
|
|
266
|
-
announceClippedSegmentIntervals(f0: number, f1: number, pointA: Point3d, pointB: Point3d, announce?:
|
|
264
|
+
/** Method from [[Clipper]] interface. */
|
|
265
|
+
announceClippedSegmentIntervals(f0: number, f1: number, pointA: Point3d, pointB: Point3d, announce?: AnnounceNumberNumber): boolean;
|
|
267
266
|
/**
|
|
268
267
|
* Return a coordinate frame with
|
|
269
268
|
* * origin at closest point to global origin
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClipPlane.d.ts","sourceRoot":"","sources":["../../../src/clipping/ClipPlane.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ClipPlane.d.ts","sourceRoot":"","sources":["../../../src/clipping/ClipPlane.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EAAE,oBAAoB,EAAE,kCAAkC,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEnH,OAAO,EAAE,KA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