@itwin/core-geometry 4.1.0-dev.70 → 4.1.0-dev.72
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 +6 -1
- package/lib/cjs/clipping/AlternatingConvexClipTree.d.ts +15 -17
- package/lib/cjs/clipping/AlternatingConvexClipTree.d.ts.map +1 -1
- package/lib/cjs/clipping/AlternatingConvexClipTree.js +24 -20
- package/lib/cjs/clipping/AlternatingConvexClipTree.js.map +1 -1
- package/lib/cjs/clipping/BooleanClipFactory.d.ts +28 -28
- package/lib/cjs/clipping/BooleanClipFactory.d.ts.map +1 -1
- package/lib/cjs/clipping/BooleanClipFactory.js +28 -28
- package/lib/cjs/clipping/BooleanClipFactory.js.map +1 -1
- package/lib/cjs/clipping/BooleanClipNode.d.ts +11 -11
- package/lib/cjs/clipping/BooleanClipNode.d.ts.map +1 -1
- package/lib/cjs/clipping/BooleanClipNode.js +11 -11
- package/lib/cjs/clipping/BooleanClipNode.js.map +1 -1
- package/lib/cjs/clipping/ClipPlane.d.ts +73 -76
- package/lib/cjs/clipping/ClipPlane.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipPlane.js +105 -86
- package/lib/cjs/clipping/ClipPlane.js.map +1 -1
- package/lib/cjs/clipping/ClipPrimitive.d.ts +78 -47
- package/lib/cjs/clipping/ClipPrimitive.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipPrimitive.js +110 -54
- package/lib/cjs/clipping/ClipPrimitive.js.map +1 -1
- package/lib/cjs/clipping/ClipUtils.d.ts +54 -44
- package/lib/cjs/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipUtils.js +33 -29
- package/lib/cjs/clipping/ClipUtils.js.map +1 -1
- package/lib/cjs/clipping/ClipVector.d.ts +39 -25
- package/lib/cjs/clipping/ClipVector.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipVector.js +35 -23
- package/lib/cjs/clipping/ClipVector.js.map +1 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts +61 -38
- package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.js +64 -41
- package/lib/cjs/clipping/ConvexClipPlaneSet.js.map +1 -1
- package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.d.ts +49 -30
- package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.d.ts.map +1 -1
- package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.js +50 -30
- package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
- package/lib/cjs/clipping/internalContexts/LineStringOffsetClipperContext.d.ts +2 -2
- package/lib/cjs/clipping/internalContexts/LineStringOffsetClipperContext.d.ts.map +1 -1
- package/lib/cjs/clipping/internalContexts/LineStringOffsetClipperContext.js +2 -2
- package/lib/cjs/clipping/internalContexts/LineStringOffsetClipperContext.js.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.d.ts +4 -2
- package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
- package/lib/cjs/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineSegment3d.js.map +1 -1
- package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineString3d.js.map +1 -1
- package/lib/esm/clipping/AlternatingConvexClipTree.d.ts +15 -17
- package/lib/esm/clipping/AlternatingConvexClipTree.d.ts.map +1 -1
- package/lib/esm/clipping/AlternatingConvexClipTree.js +24 -20
- package/lib/esm/clipping/AlternatingConvexClipTree.js.map +1 -1
- package/lib/esm/clipping/BooleanClipFactory.d.ts +28 -28
- package/lib/esm/clipping/BooleanClipFactory.d.ts.map +1 -1
- package/lib/esm/clipping/BooleanClipFactory.js +28 -28
- package/lib/esm/clipping/BooleanClipFactory.js.map +1 -1
- package/lib/esm/clipping/BooleanClipNode.d.ts +11 -11
- package/lib/esm/clipping/BooleanClipNode.d.ts.map +1 -1
- package/lib/esm/clipping/BooleanClipNode.js +11 -11
- package/lib/esm/clipping/BooleanClipNode.js.map +1 -1
- package/lib/esm/clipping/ClipPlane.d.ts +73 -76
- package/lib/esm/clipping/ClipPlane.d.ts.map +1 -1
- package/lib/esm/clipping/ClipPlane.js +105 -86
- package/lib/esm/clipping/ClipPlane.js.map +1 -1
- package/lib/esm/clipping/ClipPrimitive.d.ts +78 -47
- package/lib/esm/clipping/ClipPrimitive.d.ts.map +1 -1
- package/lib/esm/clipping/ClipPrimitive.js +110 -54
- package/lib/esm/clipping/ClipPrimitive.js.map +1 -1
- package/lib/esm/clipping/ClipUtils.d.ts +54 -44
- package/lib/esm/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/esm/clipping/ClipUtils.js +33 -29
- package/lib/esm/clipping/ClipUtils.js.map +1 -1
- package/lib/esm/clipping/ClipVector.d.ts +39 -25
- package/lib/esm/clipping/ClipVector.d.ts.map +1 -1
- package/lib/esm/clipping/ClipVector.js +35 -23
- package/lib/esm/clipping/ClipVector.js.map +1 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.d.ts +61 -38
- package/lib/esm/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.js +64 -41
- package/lib/esm/clipping/ConvexClipPlaneSet.js.map +1 -1
- package/lib/esm/clipping/UnionOfConvexClipPlaneSets.d.ts +49 -30
- package/lib/esm/clipping/UnionOfConvexClipPlaneSets.d.ts.map +1 -1
- package/lib/esm/clipping/UnionOfConvexClipPlaneSets.js +50 -30
- package/lib/esm/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
- package/lib/esm/clipping/internalContexts/LineStringOffsetClipperContext.d.ts +2 -2
- package/lib/esm/clipping/internalContexts/LineStringOffsetClipperContext.d.ts.map +1 -1
- package/lib/esm/clipping/internalContexts/LineStringOffsetClipperContext.js +2 -2
- package/lib/esm/clipping/internalContexts/LineStringOffsetClipperContext.js.map +1 -1
- package/lib/esm/curve/CurvePrimitive.d.ts +4 -2
- package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/esm/curve/CurvePrimitive.js.map +1 -1
- package/lib/esm/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/esm/curve/LineSegment3d.js.map +1 -1
- package/lib/esm/curve/LineString3d.d.ts.map +1 -1
- package/lib/esm/curve/LineString3d.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanClipFactory.js","sourceRoot":"","sources":["../../../src/clipping/BooleanClipFactory.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AACH,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC7G,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAW,aAAa,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,kBAAkB;IAC7B;;;;;;OAMG;IACI,MAAM,CAAC,kBAAkB,CAAC,QAA6B,EAAE,UAAmB;QACjF,MAAM,MAAM,GAAG,IAAI,oBAAoB,CAAC,UAAU,CAAC,CAAC;QACpD,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC9B,OAAO,MAAM,CAAC;IAChB,CAAC;IACD;;;;;;OAMG;IACI,MAAM,CAAC,yBAAyB,CAAC,QAA6B,EAAE,UAAmB;QACxF,MAAM,MAAM,GAAG,IAAI,2BAA2B,CAAC,UAAU,CAAC,CAAC;QAC3D,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC9B,OAAO,MAAM,CAAC;IAChB,CAAC;IACD;;;;;;OAMG;IACI,MAAM,CAAC,mBAAmB,CA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,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;SACnD;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,0DAA0D;IACnD,MAAM,CAAC,gBAAgB,CAAC,OAAY;QACzC,IAAI,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;YACpC,IAAI,OAAO,CAAC,MAAM;gBAChB,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC;SAC3B;QACD,OAAO,SAAS,CAAC;IAEnB,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\nimport { BooleanClipNodeIntersection, BooleanClipNodeParity, BooleanClipNodeUnion } from \"./BooleanClipNode\";\r\nimport { ClipPlane } from \"./ClipPlane\";\r\nimport { Clipper, ClipUtilities } from \"./ClipUtils\";\r\nimport { ConvexClipPlaneSet } from \"./ConvexClipPlaneSet\";\r\nimport { UnionOfConvexClipPlaneSets } from \"./UnionOfConvexClipPlaneSets\";\r\n\r\n/** A BooleanClipFactory is a factory to create objects that implement interior nodes of a tree of boolean clip operations.\r\n * * These methods create specific clip tree types:\r\n * * Union\r\n * * Intersection\r\n * * Parity\r\n * * Difference\r\n * * Each construction has a `keepInside` flag that optionally negates the initial result of the parity, intersection, parity, or difference:\r\n * * if `keepInside === true`, accept the \"inside\" of the initial result\r\n * * if `keepInside === false`, accept the \"outside\" of the initial result\r\n * * These methods create various other specialized clippers\r\n * *\r\n * @public\r\n */\r\nexport class BooleanClipFactory {\r\n /**\r\n * Create a boolean clipper which performs a union over its children\r\n * * if `keepInside === true`, accept the \"inside\" of the union result\r\n * * if `keepInside === false`, accept the \"outside\" of the union result\r\n * @param clippers clip objects to capture\r\n * @param keepInside flag to select results inside or outside the clippers.\r\n */\r\n public static createCaptureUnion(clippers: Clipper | Clipper[], keepInside: boolean): Clipper {\r\n const result = new BooleanClipNodeUnion(keepInside);\r\n result.captureChild(clippers);\r\n return result;\r\n }\r\n /**\r\n * Create a boolean clipper which performs an intersection over its children\r\n * * if `keepInside === true`, accept the \"inside\" of the intersection result\r\n * * if `keepInside === false`, accept the \"outside\" of the intersection result\r\n * @param clippers clip objects to capture\r\n * @param keepInside flag to select results inside or outside the clippers.\r\n */\r\n public static createCaptureIntersection(clippers: Clipper | Clipper[], keepInside: boolean): Clipper {\r\n const result = new BooleanClipNodeIntersection(keepInside);\r\n result.captureChild(clippers);\r\n return result;\r\n }\r\n /**\r\n * Create a boolean clipper which performs a parity over its children\r\n * * if `keepInside === true`, accept the \"inside\" of the parity result\r\n * * if `keepInside === false`, accept the \"outside\" of the parity result\r\n * @param clippers clip objects to capture\r\n * @param keepInside flag to select results inside or outside the clippers.\r\n */\r\n public static createCaptureParity(clippers: Clipper | Clipper[], keepInside: boolean): Clipper {\r\n const result = new BooleanClipNodeParity(keepInside);\r\n result.captureChild(clippers);\r\n return result;\r\n }\r\n /**\r\n * Create a boolean clipper which performs a difference operation for points \"inside `primaryClipper`\" and \"outside `excludedClipper`\"\r\n * * if `keepInside === true`, accept the \"inside\" of the difference\r\n * * if `keepInside === false`, accept the \"outside\" of the difference\r\n * @param primaryClipper any clip object whose output is treated as positive\r\n * @param excludeClip any clipper whose output is treated as negative.\r\n * @param keepInside flag to select results inside or outside the initial `primary minus excludeClipper` clippers.\r\n */\r\n public static createCaptureDifference(primaryClipper: Clipper, excludedClipper: Clipper, keepInside: boolean): Clipper {\r\n const mask = this.createCaptureUnion(excludedClipper, false);\r\n return this.createCaptureIntersection([primaryClipper, mask], keepInside);\r\n }\r\n /**\r\n * Create a boolean clipper which performs the reverse of that of `primaryClipper`\r\n * @param primaryClipper clip objects to capture\r\n * @param keepInside flag to select results inside or outside the clippers.\r\n */\r\n public static createCaptureClipOutside(primaryClipper: Clipper): Clipper {\r\n return this.createCaptureUnion([primaryClipper], false);\r\n }\r\n\r\n /**\r\n * convert `source` to an array of clipper objects.\r\n * * ANY TYPE OF Clipper is accepted.\r\n * * REMARK: This is normally called only from the primary public method `parseToClipper`.\r\n * @param source\r\n * @param internal\r\n */\r\n public static parseToClipperArray(source: any): Clipper[] | undefined {\r\n if (Array.isArray(source)) {\r\n const clippers = [];\r\n for (const c of source) {\r\n const c1 = this.parseToClipper(c);\r\n if (!c1)\r\n return undefined;\r\n clippers.push(c1);\r\n }\r\n if (clippers.length === 0)\r\n return undefined;\r\n return clippers;\r\n } else {\r\n // accept singleton to singleton array\r\n const c = this.parseToClipper(source);\r\n if (c)\r\n return [c];\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * look for content that represents a clipper.\r\n * * Possible outputs are\r\n * * `ClipPlane`\r\n * * `ConvexClipPlaneSet`\r\n * * `UnionOfConvexClipPlaneSets`\r\n * * One of the `ClipBoolean` derived classes\r\n * * `ClipBooleanXOR`\r\n * * `ClipBooleanOR`\r\n * * `ClipBooleanAND`\r\n * @param source json object\r\n * @public\r\n */\r\n public static parseToClipper(source?: object): Clipper | undefined {\r\n if (!source)\r\n return undefined;\r\n\r\n if (source.hasOwnProperty(\"normal\") && source.hasOwnProperty(\"dist\")) {\r\n return ClipPlane.fromJSON(source);\r\n } else if (Array.isArray(source)) {\r\n const clippers: Clipper[] = [];\r\n let numPlanes = 0;\r\n let numConvexSets = 0;\r\n for (const c of source) {\r\n const c1 = this.parseToClipper(c);\r\n if (!c1)\r\n return undefined;\r\n clippers.push(c1);\r\n if (c1 instanceof ClipPlane)\r\n numPlanes++;\r\n else if (c1 instanceof ConvexClipPlaneSet)\r\n numConvexSets++;\r\n else\r\n return undefined;\r\n }\r\n if (clippers.length === 0)\r\n return undefined;\r\n if (numPlanes === source.length) {\r\n // array of planes is a convex clip plane set.\r\n return ConvexClipPlaneSet.createPlanes(clippers as ClipPlane[]);\r\n } else if (numConvexSets === source.length) {\r\n return UnionOfConvexClipPlaneSets.createConvexSets(clippers as ConvexClipPlaneSet[]);\r\n }\r\n // array of mixed types should not occur. fall out to undefined.\r\n } else if (source.hasOwnProperty(\"OR\")) {\r\n const clippers = this.parseToClipperArray((source as any).OR);\r\n if (clippers)\r\n return this.createCaptureUnion(clippers, true);\r\n } else if (source.hasOwnProperty(\"NOR\")) {\r\n const clippers = this.parseToClipperArray((source as any).NOR);\r\n if (clippers)\r\n return this.createCaptureUnion(clippers, false);\r\n } else if (source.hasOwnProperty(\"AND\")) {\r\n const clippers = this.parseToClipperArray((source as any).AND);\r\n if (clippers)\r\n return this.createCaptureIntersection(clippers, true);\r\n } else if (source.hasOwnProperty(\"NAND\")) {\r\n const clippers = this.parseToClipperArray((source as any).NAND);\r\n if (clippers)\r\n return this.createCaptureIntersection(clippers, true);\r\n } else if (source.hasOwnProperty(\"XOR\")) {\r\n const clippers = this.parseToClipperArray((source as any).XOR);\r\n if (clippers)\r\n return this.createCaptureParity(clippers, true);\r\n } else if (source.hasOwnProperty(\"NXOR\")) {\r\n const clippers = this.parseToClipperArray((source as any).NXOR);\r\n if (clippers)\r\n return this.createCaptureParity(clippers, true);\r\n }\r\n return undefined;\r\n }\r\n /** Choose a `toJSON` method appropriate to the clipper */\r\n public static anyClipperToJSON(clipper: any): any | undefined {\r\n if (ClipUtilities.isClipper(clipper)) {\r\n if (clipper.toJSON)\r\n return clipper.toJSON();\r\n }\r\n return undefined;\r\n\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"BooleanClipFactory.js","sourceRoot":"","sources":["../../../src/clipping/BooleanClipFactory.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AACH,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC7G,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAW,aAAa,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sB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M,CAAC,EAAE;YACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAE,MAAc,CAAC,IAAI,CAAC,CAAC;YAChE,IAAI,QAAQ;gBACV,OAAO,IAAI,CAAC,yBAAyB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;SACzD;aAAM,IAAI,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;YACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAE,MAAc,CAAC,GAAG,CAAC,CAAC;YAC/D,IAAI,QAAQ;gBACV,OAAO,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;SACnD;aAAM,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;YACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAE,MAAc,CAAC,IAAI,CAAC,CAAC;YAChE,IAAI,QAAQ;gBACV,OAAO,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;SACnD;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,0DAA0D;IACnD,MAAM,CAAC,gBAAgB,CAAC,OAAY;QACzC,IAAI,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;YACpC,IAAI,OAAO,CAAC,MAAM;gBAChB,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC;SAC3B;QACD,OAAO,SAAS,CAAC;IACnB,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\nimport { BooleanClipNodeIntersection, BooleanClipNodeParity, BooleanClipNodeUnion } from \"./BooleanClipNode\";\r\nimport { ClipPlane } from \"./ClipPlane\";\r\nimport { Clipper, ClipUtilities } from \"./ClipUtils\";\r\nimport { ConvexClipPlaneSet } from \"./ConvexClipPlaneSet\";\r\nimport { UnionOfConvexClipPlaneSets } from \"./UnionOfConvexClipPlaneSets\";\r\n\r\n/**\r\n * A BooleanClipFactory is a factory to create objects that implement interior nodes of a tree of boolean clip operations.\r\n * * These methods create specific clip tree types:\r\n * * Union\r\n * * Intersection\r\n * * Parity\r\n * * Difference\r\n * * Each construction has a `keepInside` flag that optionally negates the initial result of the parity, intersection,\r\n * parity, or difference:\r\n * * if `keepInside === true`, accept the \"inside\" of the initial result.\r\n * * if `keepInside === false`, accept the \"outside\" of the initial result.\r\n * * These methods create various other specialized clippers.\r\n * @public\r\n */\r\nexport class BooleanClipFactory {\r\n /**\r\n * Create a boolean clipper which performs a union over its children.\r\n * * if `keepInside === true`, accept the \"inside\" of the union result.\r\n * * if `keepInside === false`, accept the \"outside\" of the union result.\r\n * @param clippers clip objects to capture.\r\n * @param keepInside flag to select results inside or outside the clippers.\r\n */\r\n public static createCaptureUnion(clippers: Clipper | Clipper[], keepInside: boolean): Clipper {\r\n const result = new BooleanClipNodeUnion(keepInside);\r\n result.captureChild(clippers);\r\n return result;\r\n }\r\n /**\r\n * Create a boolean clipper which performs an intersection over its children.\r\n * * if `keepInside === true`, accept the \"inside\" of the intersection result.\r\n * * if `keepInside === false`, accept the \"outside\" of the intersection result.\r\n * @param clippers clip objects to capture.\r\n * @param keepInside flag to select results inside or outside the clippers.\r\n */\r\n public static createCaptureIntersection(clippers: Clipper | Clipper[], keepInside: boolean): Clipper {\r\n const result = new BooleanClipNodeIntersection(keepInside);\r\n result.captureChild(clippers);\r\n return result;\r\n }\r\n /**\r\n * Create a boolean clipper which performs a parity over its children.\r\n * * if `keepInside === true`, accept the \"inside\" of the parity result.\r\n * * if `keepInside === false`, accept the \"outside\" of the parity result.\r\n * @param clippers clip objects to capture.\r\n * @param keepInside flag to select results inside or outside the clippers.\r\n */\r\n public static createCaptureParity(clippers: Clipper | Clipper[], keepInside: boolean): Clipper {\r\n const result = new BooleanClipNodeParity(keepInside);\r\n result.captureChild(clippers);\r\n return result;\r\n }\r\n /**\r\n * Create a boolean clipper which performs a difference operation for points \"inside `primaryClipper`\" and\r\n * \"outside `excludedClipper`\".\r\n * * if `keepInside === true`, accept the \"inside\" of the difference.\r\n * * if `keepInside === false`, accept the \"outside\" of the difference.\r\n * @param primaryClipper any clip object whose output is treated as positive.\r\n * @param excludeClip any clipper whose output is treated as negative.\r\n * @param keepInside flag to select results inside or outside the initial `primary minus excludeClipper` clippers.\r\n */\r\n public static createCaptureDifference(primaryClipper: Clipper, excludedClipper: Clipper, keepInside: boolean): Clipper {\r\n const mask = this.createCaptureUnion(excludedClipper, false);\r\n return this.createCaptureIntersection([primaryClipper, mask], keepInside);\r\n }\r\n /**\r\n * Create a boolean clipper which performs the reverse of that of `primaryClipper`.\r\n * @param primaryClipper clip objects to capture.\r\n * @param keepInside flag to select results inside or outside the clippers.\r\n */\r\n public static createCaptureClipOutside(primaryClipper: Clipper): Clipper {\r\n return this.createCaptureUnion([primaryClipper], false);\r\n }\r\n /**\r\n * Convert `source` to an array of clipper objects.\r\n * * ANY TYPE OF Clipper is accepted.\r\n * * REMARK: This is normally called only from the primary public method `parseToClipper`.\r\n */\r\n public static parseToClipperArray(source: any): Clipper[] | undefined {\r\n if (Array.isArray(source)) {\r\n const clippers = [];\r\n for (const c of source) {\r\n const c1 = this.parseToClipper(c);\r\n if (!c1)\r\n return undefined;\r\n clippers.push(c1);\r\n }\r\n if (clippers.length === 0)\r\n return undefined;\r\n return clippers;\r\n } else {\r\n // accept singleton to singleton array\r\n const c = this.parseToClipper(source);\r\n if (c)\r\n return [c];\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Look for content that represents a clipper.\r\n * * Possible outputs are\r\n * * `ClipPlane`\r\n * * `ConvexClipPlaneSet`\r\n * * `UnionOfConvexClipPlaneSets`\r\n * * One of the `ClipBoolean` derived classes\r\n * * `ClipBooleanXOR`\r\n * * `ClipBooleanOR`\r\n * * `ClipBooleanAND`\r\n * @param source json object\r\n * @public\r\n */\r\n public static parseToClipper(source?: object): Clipper | undefined {\r\n if (!source)\r\n return undefined;\r\n\r\n if (source.hasOwnProperty(\"normal\") && source.hasOwnProperty(\"dist\")) {\r\n return ClipPlane.fromJSON(source);\r\n } else if (Array.isArray(source)) {\r\n const clippers: Clipper[] = [];\r\n let numPlanes = 0;\r\n let numConvexSets = 0;\r\n for (const c of source) {\r\n const c1 = this.parseToClipper(c);\r\n if (!c1)\r\n return undefined;\r\n clippers.push(c1);\r\n if (c1 instanceof ClipPlane)\r\n numPlanes++;\r\n else if (c1 instanceof ConvexClipPlaneSet)\r\n numConvexSets++;\r\n else\r\n return undefined;\r\n }\r\n if (clippers.length === 0)\r\n return undefined;\r\n if (numPlanes === source.length) {\r\n // array of planes is a convex clip plane set.\r\n return ConvexClipPlaneSet.createPlanes(clippers as ClipPlane[]);\r\n } else if (numConvexSets === source.length) {\r\n return UnionOfConvexClipPlaneSets.createConvexSets(clippers as ConvexClipPlaneSet[]);\r\n }\r\n // array of mixed types should not occur. fall out to undefined.\r\n } else if (source.hasOwnProperty(\"OR\")) {\r\n const clippers = this.parseToClipperArray((source as any).OR);\r\n if (clippers)\r\n return this.createCaptureUnion(clippers, true);\r\n } else if (source.hasOwnProperty(\"NOR\")) {\r\n const clippers = this.parseToClipperArray((source as any).NOR);\r\n if (clippers)\r\n return this.createCaptureUnion(clippers, false);\r\n } else if (source.hasOwnProperty(\"AND\")) {\r\n const clippers = this.parseToClipperArray((source as any).AND);\r\n if (clippers)\r\n return this.createCaptureIntersection(clippers, true);\r\n } else if (source.hasOwnProperty(\"NAND\")) {\r\n const clippers = this.parseToClipperArray((source as any).NAND);\r\n if (clippers)\r\n return this.createCaptureIntersection(clippers, true);\r\n } else if (source.hasOwnProperty(\"XOR\")) {\r\n const clippers = this.parseToClipperArray((source as any).XOR);\r\n if (clippers)\r\n return this.createCaptureParity(clippers, true);\r\n } else if (source.hasOwnProperty(\"NXOR\")) {\r\n const clippers = this.parseToClipperArray((source as any).NXOR);\r\n if (clippers)\r\n return this.createCaptureParity(clippers, true);\r\n }\r\n return undefined;\r\n }\r\n /** Choose a `toJSON` method appropriate to the clipper */\r\n public static anyClipperToJSON(clipper: any): any | undefined {\r\n if (ClipUtilities.isClipper(clipper)) {\r\n if (clipper.toJSON)\r\n return clipper.toJSON();\r\n }\r\n return undefined;\r\n }\r\n}\r\n"]}
|
|
@@ -36,35 +36,35 @@ export declare abstract class BooleanClipNode implements Clipper {
|
|
|
36
36
|
toJSON(): any;
|
|
37
37
|
/** Capture a (reference to a) child node or nodes */
|
|
38
38
|
captureChild(child: Clipper | Clipper[]): void;
|
|
39
|
-
/**
|
|
39
|
+
/** Toggle the "keepInside" behavior. Return the prior value. */
|
|
40
40
|
toggleResult(): boolean;
|
|
41
41
|
/** Set the "keepInside" behavior */
|
|
42
42
|
selectResult(keepInside: boolean): boolean;
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* Conditionally (if a1 > a0 strictly) call announce (a0, a1).
|
|
45
45
|
* * Return 0 if not called, 1 if called.
|
|
46
46
|
*/
|
|
47
47
|
protected testedAnnounceNN(a0: number, a1: number, announce?: AnnounceNumberNumber): number;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* Conditionally (if a1 > a0 strictly) call announce (a0, a1, cp).
|
|
50
50
|
* * Return 0 if not called, 1 if called.
|
|
51
51
|
*/
|
|
52
52
|
protected testedAnnounceNNC(a0: number, a1: number, cp: CurvePrimitive, announce?: AnnounceNumberNumberCurvePrimitive): number;
|
|
53
53
|
/** Swap the _intervalsA and _intervalsB */
|
|
54
54
|
protected swapAB(): void;
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
57
|
-
* *
|
|
56
|
+
* Announce all "outside intervals" --not masked by intervals
|
|
57
|
+
* * Return true if any intervals announced.
|
|
58
58
|
*/
|
|
59
59
|
protected announcePartsNN(keepInside: boolean, intervals: Range1d[], f0: number, f1: number, announce?: AnnounceNumberNumber): boolean;
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
62
|
-
* *
|
|
61
|
+
* Announce all "outside intervals" --not masked by intervals
|
|
62
|
+
* * Return true if any intervals announced.
|
|
63
63
|
*/
|
|
64
64
|
protected announcePartsNNC(keepInside: boolean, intervals: Range1d[], f0: number, f1: number, cp: CurvePrimitive, announce?: AnnounceNumberNumberCurvePrimitive): boolean;
|
|
65
65
|
/** Invoke callback to test if a point is "in" this clipper */
|
|
66
66
|
isPointOnOrInside(point: Point3d): boolean;
|
|
67
|
-
/** Announce "in" portions of a line segment.
|
|
67
|
+
/** Announce "in" portions of a line segment. See `Clipper.announceClippedSegmentIntervals` */
|
|
68
68
|
announceClippedSegmentIntervals(f0: number, f1: number, pointA: Point3d, pointB: Point3d, announce?: AnnounceNumberNumber): boolean;
|
|
69
69
|
/** Announce "in" portions of a line segment. See `Clipper.announceClippedSegmentIntervals` */
|
|
70
70
|
announceClippedArcIntervals(arc: Arc3d, announce?: AnnounceNumberNumberCurvePrimitive): boolean;
|
|
@@ -76,7 +76,7 @@ export declare abstract class BooleanClipNode implements Clipper {
|
|
|
76
76
|
export declare class BooleanClipNodeUnion extends BooleanClipNode {
|
|
77
77
|
get operationName(): string;
|
|
78
78
|
constructor(keepInside: boolean);
|
|
79
|
-
/**
|
|
79
|
+
/** Return true if inside any child clipper */
|
|
80
80
|
isPointOnOrInsideChildren(point: Point3d): boolean;
|
|
81
81
|
combineIntervals(operandA: Range1d[], operandB: Range1d[]): Range1d[];
|
|
82
82
|
appendPolygonClip(xyz: GrowableXYZArray, insideFragments: GrowableXYZArray[], outsideFragments: GrowableXYZArray[], arrayCache: GrowableXYZArrayCache): void;
|
|
@@ -88,7 +88,7 @@ export declare class BooleanClipNodeUnion extends BooleanClipNode {
|
|
|
88
88
|
export declare class BooleanClipNodeParity extends BooleanClipNode {
|
|
89
89
|
get operationName(): string;
|
|
90
90
|
constructor(keepInside: boolean);
|
|
91
|
-
/**
|
|
91
|
+
/** Return true if inside an odd number of clippers child clipper */
|
|
92
92
|
isPointOnOrInsideChildren(point: Point3d): boolean;
|
|
93
93
|
combineIntervals(operandA: Range1d[], operandB: Range1d[]): Range1d[];
|
|
94
94
|
appendPolygonClip(xyz: GrowableXYZArray, insideFragments: GrowableXYZArray[], outsideFragments: GrowableXYZArray[], arrayCache: GrowableXYZArrayCache): void;
|
|
@@ -100,7 +100,7 @@ export declare class BooleanClipNodeParity extends BooleanClipNode {
|
|
|
100
100
|
export declare class BooleanClipNodeIntersection extends BooleanClipNode implements PolygonClipper {
|
|
101
101
|
get operationName(): string;
|
|
102
102
|
constructor(keepInside: boolean);
|
|
103
|
-
/**
|
|
103
|
+
/** Return false if outside of any child clipper */
|
|
104
104
|
isPointOnOrInsideChildren(point: Point3d): boolean;
|
|
105
105
|
combineIntervals(operandA: Range1d[], operandB: Range1d[]): Range1d[];
|
|
106
106
|
appendPolygonClip(xyz: GrowableXYZArray, insideFragments: GrowableXYZArray[], outsideFragments: GrowableXYZArray[], arrayCache: GrowableXYZArrayCache): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanClipNode.d.ts","sourceRoot":"","sources":["../../../src/clipping/BooleanClipNode.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,kCAAkC,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACnH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAiC,cAAc,EAAE,MAAM,aAAa,CAAC;AAErF;;;;;;;;;;;;;;;GAeG;AACH,8BAAsB,eAAgB,YA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IAAW,aAAa,IAAI,MAAM,CAA8C;gBAC7D,UAAU,EAAE,OAAO;IAGtC,mDAAmD;IAC5C,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAOlD,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE;IAGrE,iBAAiB,CACtB,GAAG,EAAE,gBAAgB,EACrB,eAAe,EAAE,gBAAgB,EAAE,EACnC,gBAAgB,EAAE,gBAAgB,EAAE,EACpC,UAAU,EAAE,qBAAqB;CAepC"}
|
|
@@ -51,7 +51,7 @@ export class BooleanClipNode {
|
|
|
51
51
|
this._clippers.push(child);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
/**
|
|
54
|
+
/** Toggle the "keepInside" behavior. Return the prior value. */
|
|
55
55
|
toggleResult() {
|
|
56
56
|
return this.selectResult(!this._keepInside);
|
|
57
57
|
}
|
|
@@ -62,7 +62,7 @@ export class BooleanClipNode {
|
|
|
62
62
|
return s;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* Conditionally (if a1 > a0 strictly) call announce (a0, a1).
|
|
66
66
|
* * Return 0 if not called, 1 if called.
|
|
67
67
|
*/
|
|
68
68
|
testedAnnounceNN(a0, a1, announce) {
|
|
@@ -74,7 +74,7 @@ export class BooleanClipNode {
|
|
|
74
74
|
return 0;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
|
-
*
|
|
77
|
+
* Conditionally (if a1 > a0 strictly) call announce (a0, a1, cp).
|
|
78
78
|
* * Return 0 if not called, 1 if called.
|
|
79
79
|
*/
|
|
80
80
|
testedAnnounceNNC(a0, a1, cp, announce) {
|
|
@@ -92,8 +92,8 @@ export class BooleanClipNode {
|
|
|
92
92
|
this._intervalsB = q;
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
|
-
*
|
|
96
|
-
* *
|
|
95
|
+
* Announce all "outside intervals" --not masked by intervals
|
|
96
|
+
* * Return true if any intervals announced.
|
|
97
97
|
*/
|
|
98
98
|
announcePartsNN(keepInside, intervals, f0, f1, announce) {
|
|
99
99
|
let numAnnounce = 0;
|
|
@@ -114,8 +114,8 @@ export class BooleanClipNode {
|
|
|
114
114
|
return numAnnounce > 0;
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
|
-
*
|
|
118
|
-
* *
|
|
117
|
+
* Announce all "outside intervals" --not masked by intervals
|
|
118
|
+
* * Return true if any intervals announced.
|
|
119
119
|
*/
|
|
120
120
|
announcePartsNNC(keepInside, intervals, f0, f1, cp, announce) {
|
|
121
121
|
let numAnnounce = 0;
|
|
@@ -140,7 +140,7 @@ export class BooleanClipNode {
|
|
|
140
140
|
const q = this.isPointOnOrInsideChildren(point);
|
|
141
141
|
return this._keepInside ? q : !q;
|
|
142
142
|
}
|
|
143
|
-
/** Announce "in" portions of a line segment.
|
|
143
|
+
/** Announce "in" portions of a line segment. See `Clipper.announceClippedSegmentIntervals` */
|
|
144
144
|
announceClippedSegmentIntervals(f0, f1, pointA, pointB, announce) {
|
|
145
145
|
this._intervalsA.length = 0;
|
|
146
146
|
const announceIntervalB = (a0, a1) => {
|
|
@@ -198,7 +198,7 @@ export class BooleanClipNodeUnion extends BooleanClipNode {
|
|
|
198
198
|
constructor(keepInside) {
|
|
199
199
|
super(keepInside);
|
|
200
200
|
}
|
|
201
|
-
/**
|
|
201
|
+
/** Return true if inside any child clipper */
|
|
202
202
|
isPointOnOrInsideChildren(point) {
|
|
203
203
|
for (const clipper of this._clippers) {
|
|
204
204
|
if (clipper.isPointOnOrInside(point))
|
|
@@ -222,7 +222,7 @@ export class BooleanClipNodeParity extends BooleanClipNode {
|
|
|
222
222
|
constructor(keepInside) {
|
|
223
223
|
super(keepInside);
|
|
224
224
|
}
|
|
225
|
-
/**
|
|
225
|
+
/** Return true if inside an odd number of clippers child clipper */
|
|
226
226
|
isPointOnOrInsideChildren(point) {
|
|
227
227
|
let q = false;
|
|
228
228
|
for (const clipper of this._clippers) {
|
|
@@ -247,7 +247,7 @@ export class BooleanClipNodeIntersection extends BooleanClipNode {
|
|
|
247
247
|
constructor(keepInside) {
|
|
248
248
|
super(keepInside);
|
|
249
249
|
}
|
|
250
|
-
/**
|
|
250
|
+
/** Return false if outside of any child clipper */
|
|
251
251
|
isPointOnOrInsideChildren(point) {
|
|
252
252
|
for (const clipper of this._clippers) {
|
|
253
253
|
if (!clipper.isPointOnOrInside(point))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanClipNode.js","sourceRoot":"","sources":["../../../src/clipping/BooleanClipNode.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAU/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;IAMnC,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;YAC9B,MAAM,EAAE,GAAG,CAAQ,CAAC;YACpB,IAAI,EAAE,CAAC,MAAM;gBACX,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;SAC1B;QACD,gCAAgC;QAChC,MAAM,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC;QAC7B,MAAM,IAAI,GAAgC,EAAE,CAAC;QAC7C,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CA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B;QAC9D,OAAO,YAAY,CAAC,eAAe,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC1D,CAAC;IACM,iBAAiB,CACtB,GAAqB,EACrB,eAAmC,EACnC,gBAAoC,EACpC,UAAiC;QAEjC,aAAa,CAAC,qBAAqB,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,EACrD,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,EAAE,cAAc,CAAC,SAAS,EAAE,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAChG,CAAC;CAEJ","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 { 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 }\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 /**\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(a0: number, a1: number, cp: CurvePrimitive, announce?: AnnounceNumberNumberCurvePrimitive): 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(keepInside: boolean, intervals: Range1d[], f0: number, f1: number, announce?: AnnounceNumberNumber): 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(keepInside: boolean, intervals: Range1d[], f0: number, f1: number, cp: CurvePrimitive, announce?: AnnounceNumberNumberCurvePrimitive): 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 }\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 }\r\n\r\n /** Announce \"in\" portions of a line segment. See `Clipper.announceClippedSegmentIntervals` */\r\n public announceClippedSegmentIntervals(f0: number, f1: number, pointA: Point3d, pointB: Point3d, announce?: AnnounceNumberNumber): 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: GrowableXYZArray,\r\n insideFragments: GrowableXYZArray[],\r\n outsideFragments: GrowableXYZArray[],\r\n arrayCache: GrowableXYZArrayCache) {\r\n ClipUtilities.doPolygonClipSequence(xyz, this._clippers,\r\n this._keepInside ? insideFragments : outsideFragments,\r\n this._keepInside ? outsideFragments : insideFragments,\r\n undefined,\r\n ClipStepAction.acceptIn, ClipStepAction.passToNextStep, ClipStepAction.acceptOut, arrayCache);\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: GrowableXYZArray,\r\n insideFragments: GrowableXYZArray[],\r\n outsideFragments: GrowableXYZArray[],\r\n arrayCache: GrowableXYZArrayCache) {\r\n ClipUtilities.doPolygonClipParitySequence(xyz, 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 * 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: GrowableXYZArray,\r\n insideFragments: GrowableXYZArray[],\r\n outsideFragments: GrowableXYZArray[],\r\n arrayCache: GrowableXYZArrayCache) {\r\n\r\n ClipUtilities.doPolygonClipSequence(xyz, this._clippers,\r\n this._keepInside ? insideFragments : outsideFragments,\r\n this._keepInside ? outsideFragments : insideFragments,\r\n undefined,\r\n ClipStepAction.passToNextStep, ClipStepAction.acceptOut, ClipStepAction.acceptIn, arrayCache);\r\n }\r\n\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"BooleanClipN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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 { 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: GrowableXYZArray,\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: GrowableXYZArray,\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: GrowableXYZArray,\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"]}
|
|
@@ -30,22 +30,24 @@ export interface ClipPlaneProps {
|
|
|
30
30
|
/** Defaults to `false`. */
|
|
31
31
|
interior?: boolean;
|
|
32
32
|
}
|
|
33
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* A ClipPlane is a single plane represented as
|
|
34
35
|
* * An inward unit normal (u,v,w)
|
|
35
36
|
* * A signedDistance
|
|
36
37
|
*
|
|
37
38
|
* Hence
|
|
38
|
-
* * The halfspace function evaluation for "point"
|
|
39
|
-
* * POSITIVE values of the halfspace function are "inside"
|
|
40
|
-
* * ZERO value of the halfspace function is "on"
|
|
41
|
-
* * NEGATIVE value of the halfspace function is "outside"
|
|
42
|
-
* * A representative point on the plane is (signedDistance*u, signedDistance * v, signedDistance *w)
|
|
43
|
-
* * Given a point and inward normal
|
|
39
|
+
* * The halfspace function evaluation for "point" (x,y,z) is `(x,y,z) DOT (u,v,w) - signedDistance`.
|
|
40
|
+
* * POSITIVE values of the halfspace function are "inside".
|
|
41
|
+
* * ZERO value of the halfspace function is "on".
|
|
42
|
+
* * NEGATIVE value of the halfspace function is "outside".
|
|
43
|
+
* * A representative point on the plane is (signedDistance * u, signedDistance * v, signedDistance * w).
|
|
44
|
+
* * Given a point on the plane and the inward normal of the plane, `signedDistance = point DOT normal`.
|
|
44
45
|
* @public
|
|
45
46
|
*/
|
|
46
47
|
export declare class ClipPlane extends Plane3d implements Clipper, PolygonClipper {
|
|
47
48
|
private _inwardNormal;
|
|
48
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Construct a parallel plane through the origin.
|
|
49
51
|
* * Move it to the actual position.
|
|
50
52
|
* * _distanceFromOrigin is the distance it moved, with the (inward) normal direction as positive
|
|
51
53
|
*/
|
|
@@ -58,63 +60,59 @@ export declare class ClipPlane extends Plane3d implements Clipper, PolygonClippe
|
|
|
58
60
|
* @param other clip plane to compare
|
|
59
61
|
*/
|
|
60
62
|
isAlmostEqual(other: ClipPlane): boolean;
|
|
61
|
-
/**
|
|
63
|
+
/** Return a cloned plane */
|
|
62
64
|
clone(): ClipPlane;
|
|
63
|
-
/**
|
|
65
|
+
/** Return a cloned plane with coordinate data negated. */
|
|
64
66
|
cloneNegated(): ClipPlane;
|
|
65
67
|
/** Create a ClipPlane from Plane3dByOriginAndUnitNormal. */
|
|
66
68
|
static createPlane(plane: Plane3dByOriginAndUnitNormal, invisible?: boolean, interior?: boolean, result?: ClipPlane): ClipPlane;
|
|
67
69
|
/**
|
|
68
|
-
*
|
|
70
|
+
* Create a ClipPlane with direct normal and signedDistance.
|
|
69
71
|
* * The vector is normalized for storage.
|
|
70
72
|
*/
|
|
71
73
|
static createNormalAndDistance(normal: Vector3d, distance: number, invisible?: boolean, interior?: boolean, result?: ClipPlane): ClipPlane | undefined;
|
|
72
|
-
/**
|
|
73
|
-
*
|
|
74
|
+
/**
|
|
75
|
+
* Create a ClipPlane
|
|
76
|
+
* * "normal" is the inward normal of the plane (it is internally normalized).
|
|
74
77
|
* * "point" is any point of the plane.
|
|
75
|
-
* * The stored distance for the plane is the dot product of the point with the normal (i.e. treat the point's xyz as
|
|
78
|
+
* * The stored distance for the plane is the dot product of the point with the normal (i.e. treat the point's xyz as
|
|
79
|
+
* a vector from the origin.)
|
|
76
80
|
*/
|
|
77
81
|
static createNormalAndPoint(normal: Vector3d, point: Point3d, invisible?: boolean, interior?: boolean, result?: ClipPlane): ClipPlane | undefined;
|
|
78
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* Create a clip plane
|
|
79
84
|
* @param origin any point on the plane.
|
|
80
85
|
* @param vectorA any vector in the plane
|
|
81
86
|
* @param vectorB any vector in the plane
|
|
82
|
-
*
|
|
87
|
+
* Returns undefined if the vectors are not independent.
|
|
83
88
|
* * The stored inward normal is vectorB.crossProduct(vectorA).
|
|
84
89
|
* * That is, the vectors are considered as a right-handed pair when viewed from the outside.
|
|
85
90
|
*/
|
|
86
91
|
static createOriginAndVectors(origin: Point3d, vectorA: Vector3d, vectorB: Vector3d, invisible?: boolean, interior?: boolean, result?: ClipPlane): ClipPlane | undefined;
|
|
87
|
-
/**
|
|
88
|
-
*
|
|
89
|
-
* *
|
|
90
|
-
* * "point" is any point of the plane.
|
|
91
|
-
* * The stored distance for the plane is the dot product of the point with the normal (i.e. treat the point's xyz
|
|
92
|
+
/**
|
|
93
|
+
* Create a ClipPlane
|
|
94
|
+
* * "normal" (normalX, normalY, normalZ) is the inward normal of the plane.
|
|
95
|
+
* * "point" (originX,originY,originZ) is any point of the plane.
|
|
96
|
+
* * The stored distance for the plane is the dot product of the point with the normal (i.e. treat the point's xyz
|
|
97
|
+
* as a vector from the origin.)
|
|
92
98
|
*/
|
|
93
99
|
static createNormalAndPointXYZXYZ(normalX: number, normalY: number, normalZ: number, originX: number, originY: number, originZ: number, invisible?: boolean, interior?: boolean, result?: ClipPlane): ClipPlane | undefined;
|
|
94
100
|
/**
|
|
95
|
-
*
|
|
101
|
+
* Return a json object of the form
|
|
96
102
|
* `{"normal":[u,v,w],"dist":signedDistanceValue,"interior":true,"invisible":true}`
|
|
97
103
|
*/
|
|
98
104
|
toJSON(): ClipPlaneProps;
|
|
99
|
-
/**
|
|
105
|
+
/** Parse json object to ClipPlane instance */
|
|
100
106
|
static fromJSON(json: ClipPlaneProps, result?: ClipPlane): ClipPlane | undefined;
|
|
101
107
|
/** Set both the invisible and interior flags. */
|
|
102
108
|
setFlags(invisible: boolean, interior: boolean): void;
|
|
103
|
-
/**
|
|
104
|
-
* Return the stored distanceFromOrigin property.
|
|
105
|
-
*/
|
|
109
|
+
/** Return the stored distanceFromOrigin property. */
|
|
106
110
|
get distance(): number;
|
|
107
|
-
/**
|
|
108
|
-
* Return the stored inward normal property.
|
|
109
|
-
*/
|
|
111
|
+
/** * Return the stored inward normal property. */
|
|
110
112
|
get inwardNormalRef(): Vector3d;
|
|
111
|
-
/**
|
|
112
|
-
* Return the "interior" property bit
|
|
113
|
-
*/
|
|
113
|
+
/** Return the "interior" property bit */
|
|
114
114
|
get interior(): boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Return the "invisible" property bit.
|
|
117
|
-
*/
|
|
115
|
+
/** Return the "invisible" property bit. */
|
|
118
116
|
get invisible(): boolean;
|
|
119
117
|
/**
|
|
120
118
|
* Create a plane defined by two points, an up vector, and a tilt angle relative to the up vector.
|
|
@@ -125,9 +123,7 @@ export declare class ClipPlane extends Plane3d implements Clipper, PolygonClippe
|
|
|
125
123
|
* @param result optional preallocated plane
|
|
126
124
|
*/
|
|
127
125
|
static createEdgeAndUpVector(point0: Point3d, point1: Point3d, upVector: Vector3d, tiltAngle?: Angle, result?: ClipPlane): ClipPlane | undefined;
|
|
128
|
-
/**
|
|
129
|
-
* Create a plane perpendicular to the edge between the xy parts of point0 and point1
|
|
130
|
-
*/
|
|
126
|
+
/** Create a plane perpendicular to the edge between the xy parts of point0 and point1. */
|
|
131
127
|
static createEdgeXY(point0: Point3d, point1: Point3d, result?: ClipPlane): ClipPlane | undefined;
|
|
132
128
|
/**
|
|
133
129
|
* Return the Plane3d form of the plane.
|
|
@@ -144,44 +140,44 @@ export declare class ClipPlane extends Plane3d implements Clipper, PolygonClippe
|
|
|
144
140
|
/**
|
|
145
141
|
* Set the plane from DPoint4d style plane.
|
|
146
142
|
* * The saved plane has its direction normalized.
|
|
147
|
-
* * This preserves the plane itself as a zero set but make plane evaluations act as true distances (even if the
|
|
148
|
-
*
|
|
143
|
+
* * This preserves the plane itself as a zero set but make plane evaluations act as true distances (even if the
|
|
144
|
+
* plane coefficients are scaled otherwise).
|
|
145
|
+
* @param plane the DPoint4d style plane.
|
|
149
146
|
*/
|
|
150
147
|
setPlane4d(plane: Point4d): void;
|
|
151
148
|
/**
|
|
152
|
-
* Evaluate the altitude in weighted space, i.e. (dot product with inward normal) minus distance, with point.w
|
|
153
|
-
*
|
|
149
|
+
* Evaluate the altitude in weighted space, i.e. (dot product with inward normal) minus distance, with point.w
|
|
150
|
+
* scale applied to distance.
|
|
151
|
+
* @param point space point to test.
|
|
154
152
|
*/
|
|
155
153
|
weightedAltitude(point: Point4d): number;
|
|
156
154
|
/**
|
|
157
|
-
* Evaluate the distance from the plane to a point in space, i.e. (dot product with inward normal) minus distance
|
|
158
|
-
* @param point space point to test
|
|
155
|
+
* Evaluate the distance from the plane to a point in space, i.e. (dot product with inward normal) minus distance.
|
|
156
|
+
* @param point space point to test.
|
|
159
157
|
*/
|
|
160
158
|
altitude(point: Point3d): number;
|
|
161
159
|
/**
|
|
162
|
-
* Evaluate the distance from the plane to a point in space with point given as x,y,z, i.e. (dot product with
|
|
163
|
-
*
|
|
160
|
+
* Evaluate the distance from the plane to a point in space with point given as x,y,z, i.e. (dot product with
|
|
161
|
+
* inward normal) minus distance.
|
|
162
|
+
* @param point space point to test.
|
|
164
163
|
*/
|
|
165
164
|
altitudeXYZ(x: number, y: number, z: number): number;
|
|
166
|
-
/**
|
|
167
|
-
* Return the x component of the normal used to evaluate altitude.
|
|
168
|
-
*/
|
|
165
|
+
/** Return the x component of the normal used to evaluate altitude. */
|
|
169
166
|
normalX(): number;
|
|
170
|
-
/**
|
|
171
|
-
* Return the x component of the normal used to evaluate altitude.
|
|
172
|
-
*/
|
|
167
|
+
/** Return the x component of the normal used to evaluate altitude. */
|
|
173
168
|
normalY(): number;
|
|
174
|
-
/**
|
|
175
|
-
* Return the z component of the normal used to evaluate altitude.
|
|
176
|
-
*/
|
|
169
|
+
/** Return the z component of the normal used to evaluate altitude. */
|
|
177
170
|
normalZ(): number;
|
|
178
|
-
/** Return the dot product of the plane normal with the vector (NOT using the plane's distanceFromOrigin).
|
|
179
|
-
*/
|
|
171
|
+
/** Return the dot product of the plane normal with the vector (NOT using the plane's distanceFromOrigin). */
|
|
180
172
|
velocity(vector: Vector3d): number;
|
|
181
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* Return the dot product of the plane normal with the x,yz, vector components (NOT using the plane's
|
|
175
|
+
* distanceFromOrigin).
|
|
182
176
|
*/
|
|
183
177
|
velocityXYZ(x: number, y: number, z: number): number;
|
|
184
|
-
/**
|
|
178
|
+
/**
|
|
179
|
+
* Return the dot product of the plane normal with the point (treating the point xyz as a vector, and NOT
|
|
180
|
+
* using the plane's distanceFromOrigin).
|
|
185
181
|
*/
|
|
186
182
|
dotProductPlaneNormalPoint(point: Point3d): number;
|
|
187
183
|
/**
|
|
@@ -209,22 +205,23 @@ export declare class ClipPlane extends Plane3d implements Clipper, PolygonClippe
|
|
|
209
205
|
*/
|
|
210
206
|
appendIntersectionRadians(arc: Arc3d, intersectionRadians: GrowableFloat64Array): void;
|
|
211
207
|
private static _clipArcFractionArray;
|
|
212
|
-
/**
|
|
208
|
+
/**
|
|
209
|
+
* Announce fractional intervals of arc clip.
|
|
213
210
|
* * Each call to `announce(fraction0, fraction1, arc)` announces one interval that is inside the clip plane.
|
|
214
211
|
*/
|
|
215
212
|
announceClippedArcIntervals(arc: Arc3d, announce?: AnnounceNumberNumberCurvePrimitive): boolean;
|
|
216
213
|
/**
|
|
217
|
-
*
|
|
214
|
+
* Compute intersection of (unbounded) segment with the plane.
|
|
218
215
|
* * If the ends are on the same side of the plane, return undefined.
|
|
219
216
|
* * If the intersection is an endpoint or interior to the segment return the fraction.
|
|
220
217
|
* * If both ends are on, return undefined.
|
|
221
218
|
*/
|
|
222
219
|
getBoundedSegmentSimpleIntersection(pointA: Point3d, pointB: Point3d): number | undefined;
|
|
223
|
-
/** Apply transform to the origin.
|
|
220
|
+
/** Apply transform to the origin. Apply inverse transpose of the matrix part to th normal vector. */
|
|
224
221
|
transformInPlace(transform: Transform): boolean;
|
|
225
|
-
/** Set the invisible flag.
|
|
222
|
+
/** Set the invisible flag. Interpretation of this is up to the use code algorithms. */
|
|
226
223
|
setInvisible(invisible: boolean): void;
|
|
227
|
-
/**
|
|
224
|
+
/** Reverse the sign of all coefficients, so outside and inside reverse */
|
|
228
225
|
negateInPlace(): void;
|
|
229
226
|
/**
|
|
230
227
|
* Move the plane INWARD by given distance
|
|
@@ -245,20 +242,21 @@ export declare class ClipPlane extends Plane3d implements Clipper, PolygonClippe
|
|
|
245
242
|
* @param matrix matrix to apply.
|
|
246
243
|
* @param invert if true, use in verse of the matrix.
|
|
247
244
|
* @param transpose if true, use the transpose of the matrix (or inverse, per invert parameter)
|
|
248
|
-
* * 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
|
|
249
|
-
* * Callers that will apply the same matrix to many planes should pre-invert the matrix for efficiency.
|
|
250
|
-
* * Both params default to true to get the full effect of transforming space.
|
|
251
245
|
* @param matrix matrix to apply
|
|
252
246
|
* @return false if unable to invert
|
|
247
|
+
* * Note that if matrixA is applied to all of space, the matrix to send to this method to get a corresponding
|
|
248
|
+
* effect on the plane is the inverse transpose of matrixA
|
|
249
|
+
* * Callers that will apply the same matrix to many planes should pre-invert the matrix for efficiency.
|
|
250
|
+
* * Both params default to true to get the full effect of transforming space.
|
|
253
251
|
*/
|
|
254
252
|
multiplyPlaneByMatrix4d(matrix: Matrix4d, invert?: boolean, transpose?: boolean): boolean;
|
|
255
|
-
/**
|
|
253
|
+
/** Announce the interval (if any) where a line is within the clip plane half space. */
|
|
256
254
|
announceClippedSegmentIntervals(f0: number, f1: number, pointA: Point3d, pointB: Point3d, announce?: (fraction0: number, fraction1: number) => void): boolean;
|
|
257
255
|
/**
|
|
258
256
|
* Return a coordinate frame with
|
|
259
257
|
* * origin at closest point to global origin
|
|
260
258
|
* * z axis points in
|
|
261
|
-
* x and y are "in plane"
|
|
259
|
+
* * x and y are "in plane"
|
|
262
260
|
*/
|
|
263
261
|
getFrame(): Transform;
|
|
264
262
|
/**
|
|
@@ -267,17 +265,16 @@ export declare class ClipPlane extends Plane3d implements Clipper, PolygonClippe
|
|
|
267
265
|
* @param xyzOut intersection polygon. This is convex.
|
|
268
266
|
*/
|
|
269
267
|
intersectRange(range: Range3d, addClosurePoint?: boolean): GrowableXYZArray | undefined;
|
|
270
|
-
/** Implement appendPolygonClip, as defined in interface PolygonClipper.
|
|
271
|
-
*
|
|
268
|
+
/** Implement appendPolygonClip, as defined in interface PolygonClipper.
|
|
272
269
|
* @param xyz input polygon. This is not changed.
|
|
273
|
-
* @param insideFragments Array to receive "inside" fragments.
|
|
274
|
-
*
|
|
270
|
+
* @param insideFragments Array to receive "inside" fragments. Each fragment is a GrowableXYZArray grabbed
|
|
271
|
+
* from the cache. This is NOT cleared.
|
|
272
|
+
* @param outsideFragments Array to receive "outside" fragments. Each fragment is a GrowableXYZArray grabbed
|
|
273
|
+
* from the cache. This is NOT cleared.
|
|
275
274
|
* @param arrayCache cache for reusable GrowableXYZArray.
|
|
276
275
|
*/
|
|
277
276
|
appendPolygonClip(xyz: GrowableXYZArray, insideFragments: GrowableXYZArray[], outsideFragments: GrowableXYZArray[], arrayCache: GrowableXYZArrayCache): void;
|
|
278
|
-
/**
|
|
279
|
-
* Project a point in space to the plane.
|
|
280
|
-
*/
|
|
277
|
+
/** Project a point in space to the plane. */
|
|
281
278
|
projectPointToPlane(spacePoint: Point3d, result?: Point3d): Point3d;
|
|
282
279
|
}
|
|
283
280
|
//# sourceMappingURL=ClipPlane.d.ts.map
|