@itwin/core-geometry 4.0.0-dev.24 → 4.0.0-dev.30
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 +7 -2
- package/lib/cjs/bspline/BSplineCurveOps.js +4 -5
- package/lib/cjs/bspline/BSplineCurveOps.js.map +1 -1
- package/lib/cjs/bspline/InterpolationCurve3d.js +7 -10
- package/lib/cjs/bspline/InterpolationCurve3d.js.map +1 -1
- package/lib/cjs/clipping/ClipPrimitive.js +2 -2
- package/lib/cjs/clipping/ClipPrimitive.js.map +1 -1
- package/lib/cjs/clipping/ClipUtils.js +4 -4
- package/lib/cjs/clipping/ClipUtils.js.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/CurveChainWithDistanceIndex.js +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/cjs/curve/CurveCollection.js +1 -1
- package/lib/cjs/curve/CurveCollection.js.map +1 -1
- package/lib/cjs/curve/Loop.d.ts +2 -2
- package/lib/cjs/curve/Loop.d.ts.map +1 -1
- package/lib/cjs/curve/Loop.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +2 -1
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +3 -2
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +2 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js +3 -2
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/cjs/curve/StrokeOptions.js +1 -2
- package/lib/cjs/curve/StrokeOptions.js.map +1 -1
- package/lib/cjs/curve/spiral/DirectSpiral3d.js +1 -2
- package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
- package/lib/cjs/curve/spiral/IntegratedSpiral3d.js +1 -2
- package/lib/cjs/curve/spiral/IntegratedSpiral3d.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableFloat64Array.js +2 -2
- package/lib/cjs/geometry3d/GrowableFloat64Array.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.js +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.js +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.js +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/cjs/geometry3d/Point2dVector2d.js +4 -6
- package/lib/cjs/geometry3d/Point2dVector2d.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +37 -39
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +41 -45
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.js +1 -1
- package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
- package/lib/cjs/geometry3d/Ray3d.js +1 -1
- package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
- package/lib/cjs/polyface/AuxData.js +1 -1
- package/lib/cjs/polyface/AuxData.js.map +1 -1
- package/lib/cjs/polyface/FacetLocationDetail.js +5 -7
- package/lib/cjs/polyface/FacetLocationDetail.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceClip.js +6 -7
- package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js +11 -11
- package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/cjs/serialization/BGFBReader.js +4 -4
- package/lib/cjs/serialization/BGFBReader.js.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.js +1 -2
- package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/cjs/solid/SweepContour.js +1 -1
- package/lib/cjs/solid/SweepContour.js.map +1 -1
- package/lib/cjs/topology/Triangulation.js +1 -1
- package/lib/cjs/topology/Triangulation.js.map +1 -1
- package/lib/esm/bspline/BSplineCurveOps.js +4 -5
- package/lib/esm/bspline/BSplineCurveOps.js.map +1 -1
- package/lib/esm/bspline/InterpolationCurve3d.js +7 -10
- package/lib/esm/bspline/InterpolationCurve3d.js.map +1 -1
- package/lib/esm/clipping/ClipPrimitive.js +2 -2
- package/lib/esm/clipping/ClipPrimitive.js.map +1 -1
- package/lib/esm/clipping/ClipUtils.js +4 -4
- package/lib/esm/clipping/ClipUtils.js.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/CurveChainWithDistanceIndex.js +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/esm/curve/CurveCollection.js +1 -1
- package/lib/esm/curve/CurveCollection.js.map +1 -1
- package/lib/esm/curve/Loop.d.ts +2 -2
- package/lib/esm/curve/Loop.d.ts.map +1 -1
- package/lib/esm/curve/Loop.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +2 -1
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +3 -2
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +2 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.js +3 -2
- package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/esm/curve/StrokeOptions.js +1 -2
- package/lib/esm/curve/StrokeOptions.js.map +1 -1
- package/lib/esm/curve/spiral/DirectSpiral3d.js +1 -2
- package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
- package/lib/esm/curve/spiral/IntegratedSpiral3d.js +1 -2
- package/lib/esm/curve/spiral/IntegratedSpiral3d.js.map +1 -1
- package/lib/esm/geometry3d/GrowableFloat64Array.js +2 -2
- package/lib/esm/geometry3d/GrowableFloat64Array.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.js +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.js +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.js +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/esm/geometry3d/Point2dVector2d.js +4 -6
- package/lib/esm/geometry3d/Point2dVector2d.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +37 -39
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +41 -45
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.js +1 -1
- package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
- package/lib/esm/geometry3d/Ray3d.js +1 -1
- package/lib/esm/geometry3d/Ray3d.js.map +1 -1
- package/lib/esm/polyface/AuxData.js +1 -1
- package/lib/esm/polyface/AuxData.js.map +1 -1
- package/lib/esm/polyface/FacetLocationDetail.js +5 -7
- package/lib/esm/polyface/FacetLocationDetail.js.map +1 -1
- package/lib/esm/polyface/PolyfaceClip.js +6 -7
- package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js +11 -11
- package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/esm/serialization/BGFBReader.js +4 -4
- package/lib/esm/serialization/BGFBReader.js.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.js +1 -2
- package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/esm/solid/SweepContour.js +1 -1
- package/lib/esm/solid/SweepContour.js.map +1 -1
- package/lib/esm/topology/Triangulation.js +1 -1
- package/lib/esm/topology/Triangulation.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegionOps.js","sourceRoot":"","sources":["../../../src/curve/RegionOps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AACvC,qEAAkE;AAClE,6EAA0E;AAC1E,2EAAwE;AACxE,mEAAwD;AACxD,mGAA2F;AAC3F,+CAA8C;AAC9C,mEAAgE;AAChE,uDAAoD;AACpD,yDAAsD;AAEtD,iEAA8D;AAC9D,6CAA0E;AAC1E,6DAA4G;AAC5G,mEAAgE;AAEhE,uDAAwH;AACxH,6CAA0C;AAC1C,qDAAkD;AAClD,+DAA4D;AAC5D,kFAA6I;AAC7I,iDAA8C;AAC9C,iCAA2C;AAC3C,iCAA8B;AAC9B,uGAAyG;AACzG,iEAA8D;AAC9D,mDAAyD;AACzD,iEAA8D;AAC9D,uDAAoD;AACpD,gFAAuE;AACvE,mDAAgD;AAChD,mFAAqH;AACrH,+CAA4C;AAC5C,yEAAsE;AACtE,iDAA8C;AAgB9C;;;GAGG;AACH,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC5B,6DAAS,CAAA;IACT,+DAAU,CAAA;IACV,2EAAgB,CAAA;IAChB,iEAAW,CAAA;IACX,iEAAW,CAAA;AACb,CAAC,EANW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAM7B;AAED;;;;;;;;GAQG;AACH,MAAa,SAAS;IACpB;;;;;OAKG;IACI,MAAM,CAAC,oBAAoB,CAAC,IAAe;QAChD,MAAM,OAAO,GAAG,IAAI,iCAAe,EAAE,CAAC;QACtC,MAAM,MAAM,GAAG,IAAI,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;QACvD,IA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AGG;IACI,MAAM,CAAC,eAAe,CAAC,IAAS,EAAE,YAAwB;QAC/D,MAAM,KAAK,GAAG,eAAO,CAAC,MAAM,EAAE,CAAC;QAC/B,IAAI,IAAI,YAAY,6BAAa;YAC/B,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;aACnC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC5B,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE;gBACpB,IAAI,CAAC,YAAY,6BAAa;oBAC5B,CAAC,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;qBAChC,IAAI,CAAC,YAAY,yBAAO;oBAC3B,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;qBAChC,IAAI,CAAC,YAAY,mCAAgB;oBACpC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;qBACzC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;oBACvB,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC;aAC5D;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AArlBD,8BAqlBC;AAED,SAAS,mBAAmB,CAAC,KAAe,EAAE,MAAc,EAAE,aAAyB,EAAE,MAAkB,EAAE,aAAyB;IACpI,IAAI,MAAM,GAAG,CAAC;QACZ,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACvB,IAAI,MAAM,GAAG,CAAC;QACjB,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;;QAE1B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { Point3dArrayCarrier } from \"../geometry3d/Point3dArrayCarrier\";\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { PolylineCompressionContext } from \"../geometry3d/PolylineCompressionByEdgeOffset\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { SortablePolygon } from \"../geometry3d/SortablePolygon\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { MomentData } from \"../geometry4d/MomentData\";\r\nimport { Polyface } from \"../polyface/Polyface\";\r\nimport { PolyfaceBuilder } from \"../polyface/PolyfaceBuilder\";\r\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask } from \"../topology/Graph\";\r\nimport { LineStringDataVariant, MultiLineStringDataVariant, Triangulator } from \"../topology/Triangulation\";\r\nimport { ChainCollectorContext } from \"./ChainCollectorContext\";\r\nimport { AnyCurve, AnyRegion } from \"./CurveChain\";\r\nimport { BagOfCurves, ConsolidateAdjacentCurvePrimitivesOptions, CurveChain, CurveCollection } from \"./CurveCollection\";\r\nimport { CurveCurve } from \"./CurveCurve\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { CurveWireMomentsXYZ } from \"./CurveWireMomentsXYZ\";\r\nimport { CurveChainWireOffsetContext, JointOptions, OffsetOptions, PolygonWireOffsetContext } from \"./internalContexts/PolygonOffsetContext\";\r\nimport { LineString3d } from \"./LineString3d\";\r\nimport { Loop, SignedLoops } from \"./Loop\";\r\nimport { Path } from \"./Path\";\r\nimport { ConsolidateAdjacentCurvePrimitivesContext } from \"./Query/ConsolidateAdjacentPrimitivesContext\";\r\nimport { CurveSplitContext } from \"./Query/CurveSplitContext\";\r\nimport { PointInOnOutContext } from \"./Query/InOutTests\";\r\nimport { PlanarSubdivision } from \"./Query/PlanarSubdivision\";\r\nimport { RegionMomentsXY } from \"./RegionMomentsXY\";\r\nimport { OffsetHelpers } from \"./internalContexts/MultiChainCollector\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\nimport { RegionBooleanContext, RegionGroupOpType, RegionOpsFaceToFaceSearch } from \"./RegionOpsClassificationSweeps\";\r\nimport { UnionRegion } from \"./UnionRegion\";\r\nimport { HalfEdgeGraphSearch } from \"../topology/HalfEdgeGraphSearch\";\r\nimport { ParityRegion } from \"./ParityRegion\";\r\n/**\r\n * Possible return types from\r\n * @public\r\n */\r\nexport type ChainTypes = CurvePrimitive | Path | BagOfCurves | Loop | undefined;\r\n\r\n/**\r\n * * `properties` is a string with special characters indicating\r\n * * \"U\" -- contains unmerged stick data\r\n * * \"M\" -- merged\r\n * * \"R\" -- regularized\r\n * * \"X\" -- has exterior markup\r\n * @internal\r\n */\r\nexport type GraphCheckPointFunction = (name: string, graph: HalfEdgeGraph, properties: string, extraData?: any) => any;\r\n/**\r\n * Enumeration of the binary operation types for a booleans among regions\r\n * @public\r\n */\r\nexport enum RegionBinaryOpType {\r\n Union = 0,\r\n Parity = 1,\r\n Intersection = 2,\r\n AMinusB = 3,\r\n BMinusA = 4,\r\n}\r\n\r\n/**\r\n * class `RegionOps` has static members for calculations on regions (areas).\r\n * * Regions are represented by these `CurveCollection` subclasses:\r\n * * `Loop` -- a single loop\r\n * * `ParityRegion` -- a collection of loops, interpreted by parity rules.\r\n * * The common \"One outer loop and many Inner loops\" is a parity region.\r\n * * `UnionRegion` -- a collection of `Loop` and `ParityRegion` objects understood as a (probably disjoint) union.\r\n * @beta\r\n */\r\nexport class RegionOps {\r\n /**\r\n * Return moment sums for a loop, parity region, or union region.\r\n * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with\r\n * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`\r\n * @param root any Loop, ParityRegion, or UnionRegion.\r\n */\r\n public static computeXYAreaMoments(root: AnyRegion): MomentData | undefined {\r\n const handler = new RegionMomentsXY();\r\n const result = root.dispatchToGeometryHandler(handler);\r\n if (result instanceof MomentData) {\r\n result.shiftOriginAndSumsToCentroidOfSums();\r\n return result;\r\n }\r\n return undefined;\r\n }\r\n /** Return an area tolerance for a given xy-range and optional distance tolerance.\r\n * @param range range of planar region to tolerance\r\n * @param distanceTolerance optional absolute distance tolerance\r\n */\r\n public static computeXYAreaTolerance(range: Range3d, distanceTolerance: number=Geometry.smallMetricDistance): number {\r\n // if A = bh and e is distance tolerance, then A' := (b+e/2)(h+e/2) = A + e/2(b+h+e/2), so A'-A = e/2(b+h+e/2).\r\n const halfDistTol = 0.5 * distanceTolerance;\r\n return halfDistTol * (range.xLength() + range.yLength() + halfDistTol);\r\n }\r\n /**\r\n * Return an xy area for a loop, parity region, or union region.\r\n * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with\r\n * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`\r\n * @param root any Loop, ParityRegion, or UnionRegion.\r\n */\r\n public static computeXYArea(root: AnyRegion): number | undefined {\r\n const handler = new RegionMomentsXY();\r\n const result = root.dispatchToGeometryHandler(handler);\r\n if (result instanceof MomentData) {\r\n return result.quantitySum;\r\n }\r\n return undefined;\r\n }\r\n /** Return MomentData with the sums of wire moments.\r\n * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with\r\n * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`\r\n */\r\n public static computeXYZWireMomentSums(root: AnyCurve): MomentData | undefined {\r\n const handler = new CurveWireMomentsXYZ();\r\n handler.visitLeaves(root);\r\n const result = handler.momentData;\r\n result.shiftOriginAndSumsToCentroidOfSums();\r\n return result;\r\n }\r\n\r\n /**\r\n * * create loops in the graph.\r\n * @internal\r\n */\r\n public static addLoopsToGraph(graph: HalfEdgeGraph, data: MultiLineStringDataVariant, announceIsolatedLoop: (graph: HalfEdgeGraph, seed: HalfEdge) => void) {\r\n if (data instanceof Loop) {\r\n const points = data.getPackedStrokes();\r\n if (points)\r\n this.addLoopsToGraph(graph, points, announceIsolatedLoop);\r\n } else if (data instanceof ParityRegion) {\r\n for (const child of data.children) {\r\n const points = child.getPackedStrokes();\r\n if (points)\r\n this.addLoopsToGraph(graph, points, announceIsolatedLoop);\r\n }\r\n } else if (data instanceof IndexedXYZCollection) {\r\n const loopSeed = Triangulator.directCreateFaceLoopFromCoordinates(graph, data);\r\n if (loopSeed !== undefined)\r\n announceIsolatedLoop(graph, loopSeed);\r\n } else if (Array.isArray(data)) {\r\n if (data.length > 0) {\r\n if (Point3d.isAnyImmediatePointType(data[0])) {\r\n const loopSeed = Triangulator.directCreateFaceLoopFromCoordinates(graph, data as LineStringDataVariant);\r\n if (loopSeed !== undefined)\r\n announceIsolatedLoop(graph, loopSeed);\r\n\r\n } else if (data[0] instanceof IndexedXYZCollection) {\r\n for (const loop of data) {\r\n const loopSeed = Triangulator.directCreateFaceLoopFromCoordinates(graph, loop as IndexedXYZCollection);\r\n if (loopSeed !== undefined)\r\n announceIsolatedLoop(graph, loopSeed);\r\n }\r\n } else {\r\n for (const child of data) {\r\n if (Array.isArray(child))\r\n this.addLoopsToGraph(graph, child as MultiLineStringDataVariant, announceIsolatedLoop);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n /** Add multiple loops to a graph.\r\n * * Apply edgeTag and mask to each edge.\r\n * @internal\r\n */\r\n public static addLoopsWithEdgeTagToGraph(graph: HalfEdgeGraph, data: MultiLineStringDataVariant, mask: HalfEdgeMask, edgeTag: any): HalfEdge[] | undefined {\r\n const loopSeeds: HalfEdge[] = [];\r\n this.addLoopsToGraph(graph, data, (_graph: HalfEdgeGraph, seed: HalfEdge) => {\r\n if (seed) {\r\n loopSeeds.push(seed);\r\n seed.setMaskAndEdgeTagAroundFace(mask, edgeTag, true);\r\n }\r\n });\r\n if (loopSeeds.length > 0)\r\n return loopSeeds;\r\n return undefined;\r\n }\r\n /**\r\n * Given a graph just produced by booleans, convert to a polyface\r\n * * \"just produced\" implies exterior face markup.\r\n *\r\n * @param graph\r\n * @param triangulate\r\n */\r\n private static finishGraphToPolyface(graph: HalfEdgeGraph | undefined, triangulate: boolean): Polyface | undefined {\r\n if (graph) {\r\n if (triangulate) {\r\n Triangulator.triangulateAllPositiveAreaFaces(graph);\r\n Triangulator.flipTriangles(graph);\r\n }\r\n return PolyfaceBuilder.graphToPolyface(graph);\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * return a polyface containing the area union of two XY regions.\r\n * * Within each region, in and out is determined by parity rules.\r\n * * Any face that is an odd number of crossings from the far outside is IN\r\n * * Any face that is an even number of crossings from the far outside is OUT\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n */\r\n public static polygonXYAreaIntersectLoopsToPolyface(loopsA: MultiLineStringDataVariant, loopsB: MultiLineStringDataVariant, triangulate: boolean = false): Polyface | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doPolygonBoolean(loopsA, loopsB,\r\n (inA: boolean, inB: boolean) => (inA && inB),\r\n this._graphCheckPointFunction);\r\n return this.finishGraphToPolyface(graph, triangulate);\r\n }\r\n\r\n /**\r\n * return a polyface containing the area union of two XY regions.\r\n * * Within each region, in and out is determined by parity rules.\r\n * * Any face that is an odd number of crossings from the far outside is IN\r\n * * Any face that is an even number of crossings from the far outside is OUT\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n */\r\n public static polygonXYAreaUnionLoopsToPolyface(loopsA: MultiLineStringDataVariant, loopsB: MultiLineStringDataVariant, triangulate: boolean = false): Polyface | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doPolygonBoolean(loopsA, loopsB,\r\n (inA: boolean, inB: boolean) => (inA || inB),\r\n this._graphCheckPointFunction);\r\n return this.finishGraphToPolyface(graph, triangulate);\r\n }\r\n /**\r\n * return a polyface containing the area difference of two XY regions.\r\n * * Within each region, in and out is determined by parity rules.\r\n * * Any face that is an odd number of crossings from the far outside is IN\r\n * * Any face that is an even number of crossings from the far outside is OUT\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n */\r\n public static polygonXYAreaDifferenceLoopsToPolyface(loopsA: MultiLineStringDataVariant, loopsB: MultiLineStringDataVariant, triangulate: boolean = false): Polyface | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doPolygonBoolean(loopsA, loopsB,\r\n (inA: boolean, inB: boolean) => (inA && !inB),\r\n this._graphCheckPointFunction);\r\n return this.finishGraphToPolyface(graph, triangulate);\r\n }\r\n\r\n /**\r\n * return areas defined by a boolean operation.\r\n * * If there are multiple regions in loopsA, they are treated as a union.\r\n * * If there are multiple regions in loopsB, they are treated as a union.\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n * @param operation indicates Union, Intersection, Parity, AMinusB, or BMinusA\r\n * @alpha\r\n */\r\n public static regionBooleanXY(loopsA: AnyRegion | AnyRegion[] | undefined, loopsB: AnyRegion | AnyRegion[] | undefined, operation: RegionBinaryOpType): AnyRegion | undefined {\r\n const result = UnionRegion.create();\r\n const context = RegionBooleanContext.create(RegionGroupOpType.Union, RegionGroupOpType.Union);\r\n context.addMembers(loopsA, loopsB);\r\n context.annotateAndMergeCurvesInGraph();\r\n const range = context.groupA.range().union(context.groupB.range());\r\n const areaTol = this.computeXYAreaTolerance(range);\r\n context.runClassificationSweep(operation, (_graph: HalfEdgeGraph, face: HalfEdge, faceType: -1 | 0 | 1, area: number) => {\r\n // ignore danglers and null faces, but not 2-edge \"banana\" faces with nonzero area\r\n if (face.countEdgesAroundFace() < 2)\r\n return;\r\n if (Math.abs(area) < areaTol)\r\n return;\r\n if (faceType === 1) {\r\n const loop = PlanarSubdivision.createLoopInFace(face);\r\n if (loop)\r\n result.tryAddChild(loop);\r\n }\r\n });\r\n return result;\r\n }\r\n\r\n /**\r\n * return a polyface whose facets area a boolean operation between the input regions.\r\n * * Each of the two inputs is an array of multiple loops or parity regions.\r\n * * Within each of these input arrays, the various entries (loop or set of loops) are interpreted as a union.\r\n * * In each \"array of loops and parity regions\", each entry inputA[i] or inputB[i] is one of:\r\n * * A simple loop, e.g. array of Point3d.\r\n * * Several simple loops, each of which is an array of Point3d.\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n */\r\n public static polygonBooleanXYToPolyface(inputA: MultiLineStringDataVariant[], operation: RegionBinaryOpType,\r\n inputB: MultiLineStringDataVariant[], triangulate: boolean = false): Polyface | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doBinaryBooleanBetweenMultiLoopInputs(\r\n inputA, RegionGroupOpType.Union,\r\n operation,\r\n inputB, RegionGroupOpType.Union, true);\r\n return this.finishGraphToPolyface(graph, triangulate);\r\n }\r\n /**\r\n * return loops of linestrings around areas of a boolean operation between the input regions.\r\n * * Each of the two inputs is an array of multiple loops or parity regions.\r\n * * Within each of these input arrays, the various entries (loop or set of loops) are interpreted as a union.\r\n * * In each \"array of loops and parity regions\", each entry inputA[i] or inputB[i] is one of:\r\n * * A simple loop, e.g. array of Point3d.\r\n * * Several simple loops, each of which is an array of Point3d.\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n */\r\n public static polygonBooleanXYToLoops(\r\n inputA: MultiLineStringDataVariant[],\r\n operation: RegionBinaryOpType,\r\n inputB: MultiLineStringDataVariant[]): AnyRegion | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doBinaryBooleanBetweenMultiLoopInputs(\r\n inputA, RegionGroupOpType.Union,\r\n operation,\r\n inputB, RegionGroupOpType.Union, true);\r\n if (!graph)\r\n return undefined;\r\n const loopEdges = HalfEdgeGraphSearch.collectExtendedBoundaryLoopsInGraph(graph, HalfEdgeMask.EXTERIOR);\r\n const allLoops: Loop[] = [];\r\n for (const graphLoop of loopEdges) {\r\n const points = new GrowableXYZArray();\r\n for (const edge of graphLoop)\r\n points.pushXYZ(edge.x, edge.y, edge.z);\r\n points.pushWrap(1);\r\n const loop = Loop.create();\r\n loop.tryAddChild(LineString3d.createCapture(points));\r\n allLoops.push(loop);\r\n }\r\n return RegionOps.sortOuterAndHoleLoopsXY(allLoops);\r\n }\r\n\r\n /** Construct a wire (not area!!) that is offset from given polyline or polygon.\r\n * * This is a simple wire offset, not an area.\r\n * * The construction algorithm attempts to eliminate some self-intersections within the offsets, but does not guarantee a simple area offset.\r\n * * The construction algorithm is subject to being changed, resulting in different (hopefully better) self-intersection behavior on the future.\r\n * @param points a single loop or path\r\n * @param wrap true to include wraparound\r\n * @param offsetDistance distance of offset from wire. Positive is left.\r\n */\r\n public static constructPolygonWireXYOffset(points: Point3d[], wrap: boolean, offsetDistance: number): CurveCollection | undefined {\r\n const context = new PolygonWireOffsetContext();\r\n return context.constructPolygonWireXYOffset(points, wrap, offsetDistance);\r\n }\r\n /**\r\n * Construct curves that are offset from a Path or Loop as viewed in xy-plane (ignoring z).\r\n * * The construction will remove \"some\" local effects of features smaller than the offset distance, but will not detect self intersection among widely separated edges.\r\n * * If offsetDistance is given as a number, default OffsetOptions are applied.\r\n * * When the offset needs to do an \"outside\" turn, the first applicable construction is applied:\r\n * * If the turn is larger than `options.minArcDegrees`, a circular arc is constructed.\r\n * * If the turn is less than or equal to `options.maxChamferTurnDegrees`, extend curves along tangent to single intersection point.\r\n * * If the turn is larger than `options.maxChamferDegrees`, the turn is constructed as a sequence of straight lines that are:\r\n * * outside the arc\r\n * * have uniform turn angle less than `options.maxChamferDegrees`\r\n * * each line segment (except first and last) touches the arc at its midpoint.\r\n * @param curves base curves.\r\n * @param offsetDistanceOrOptions offset distance (positive to left of curve, negative to right) or options object.\r\n */\r\n public static constructCurveXYOffset(curves: Path | Loop, offsetDistanceOrOptions: number | JointOptions | OffsetOptions): CurveCollection | undefined {\r\n return CurveChainWireOffsetContext.constructCurveXYOffset(curves, offsetDistanceOrOptions);\r\n }\r\n /**\r\n * Test if point (x,y) is IN, OUT or ON a polygon.\r\n * @return (1) for in, (-1) for OUT, (0) for ON\r\n * @param x x coordinate\r\n * @param y y coordinate\r\n * @param points array of xy coordinates.\r\n */\r\n public static testPointInOnOutRegionXY(curves: AnyRegion, x: number, y: number): number {\r\n return PointInOnOutContext.testPointInOnOutRegionXY(curves, x, y);\r\n }\r\n /** Create curve collection of subtype determined by gaps between the input curves.\r\n * * If (a) wrap is requested and (b) all curves connect head-to-tail (including wraparound), assemble as a `loop`.\r\n * * If all curves connect head-to-tail except for closure, return a `Path`.\r\n * * If there are internal gaps, return a `BagOfCurves`\r\n * * If input array has zero length, return undefined.\r\n */\r\n public static createLoopPathOrBagOfCurves(curves: CurvePrimitive[], wrap: boolean = true, consolidateAdjacentPrimitives: boolean = false): CurveCollection | undefined {\r\n const n = curves.length;\r\n if (n === 0)\r\n return undefined;\r\n let maxGap = 0.0;\r\n let isPath = false;\r\n if (wrap)\r\n maxGap = Geometry.maxXY(maxGap, curves[0].startPoint().distance(curves[n - 1].endPoint()));\r\n for (let i = 0; i + 1 < n; i++)\r\n maxGap = Geometry.maxXY(maxGap, curves[i].endPoint().distance(curves[i + 1].startPoint()));\r\n let collection: Loop | Path | BagOfCurves;\r\n if (Geometry.isSmallMetricDistance(maxGap)) {\r\n collection = wrap ? Loop.create() : Path.create();\r\n isPath = true;\r\n } else {\r\n collection = BagOfCurves.create();\r\n }\r\n for (const c of curves)\r\n collection.tryAddChild(c);\r\n if (isPath && consolidateAdjacentPrimitives)\r\n RegionOps.consolidateAdjacentPrimitives(collection);\r\n return collection;\r\n }\r\n\r\n private static _graphCheckPointFunction?: GraphCheckPointFunction;\r\n /**\r\n * Announce Checkpoint function for use during booleans\r\n * @internal\r\n */\r\n public static setCheckPointFunction(f?: GraphCheckPointFunction) { this._graphCheckPointFunction = f; }\r\n /**\r\n * * Find all intersections among curves in `curvesToCut` and `cutterCurves`\r\n * * Return fragments of `curvesToCut`.\r\n * * For a `Loop`, `ParityRegion`, or `UnionRegion` in `curvesToCut`\r\n * * if it is never cut by any `cutter` curve, it will be left unchanged.\r\n * * if cut, the input is downgraded to a set of `Path` curves joining at the cut points.\r\n * * All cutting is \"as viewed in the xy plane\"\r\n */\r\n public static cloneCurvesWithXYSplitFlags(curvesToCut: CurvePrimitive | CurveCollection | undefined, cutterCurves: CurveCollection): CurveCollection | CurvePrimitive | undefined {\r\n return CurveSplitContext.cloneCurvesWithXYSplitFlags(curvesToCut, cutterCurves);\r\n\r\n }\r\n /**\r\n * Create paths assembled from many curves.\r\n * * Assemble consecutive curves NOT separated by either end flags or gaps into paths.\r\n * * Return simplest form -- single primitive, single path, or bag of curves.\r\n * @param curves\r\n */\r\n public static splitToPathsBetweenFlagBreaks(source: CurveCollection | CurvePrimitive | undefined,\r\n makeClones: boolean): BagOfCurves | Path | CurvePrimitive | Loop | undefined {\r\n if (source === undefined)\r\n return undefined;\r\n if (source instanceof CurvePrimitive)\r\n return source;\r\n // source is a collection . ..\r\n const primitives = source.collectCurvePrimitives();\r\n const chainCollector = new ChainCollectorContext(makeClones);\r\n for (const primitive of primitives) {\r\n chainCollector.announceCurvePrimitive(primitive);\r\n }\r\n return chainCollector.grabResult();\r\n }\r\n /**\r\n * * Restructure curve fragments as chains and offsets\r\n * * Return object with named chains, insideOffsets, outsideOffsets\r\n * * BEWARE that if the input is not a loop the classification of outputs is suspect.\r\n * @param fragments fragments to be chained\r\n * @param offsetDistance offset distance.\r\n */\r\n public static collectInsideAndOutsideOffsets(fragments: GeometryQuery[], offsetDistance: number, gapTolerance: number): { insideOffsets: GeometryQuery[], outsideOffsets: GeometryQuery[], chains: ChainTypes } {\r\n return OffsetHelpers.collectInsideAndOutsideOffsets(fragments, offsetDistance, gapTolerance);\r\n }\r\n /**\r\n * * Restructure curve fragments as chains\r\n * * Return the chains, possibly wrapped in BagOfCurves if there multiple chains.\r\n * @param fragments fragments to be chained\r\n * @param offsetDistance offset distance.\r\n */\r\n public static collectChains(fragments: GeometryQuery[], gapTolerance: number = Geometry.smallMetricDistance): ChainTypes {\r\n return OffsetHelpers.collectChains(fragments, gapTolerance);\r\n }\r\n\r\n /**\r\n * * Find intersections of `curvesToCut` with boundaries of `region`.\r\n * * Break `curvesToCut` into parts inside, outside, and coincident.\r\n * * Return all fragments, split among `insideParts`, `outsideParts`, and `coincidentParts` in the output object.\r\n */\r\n public static splitPathsByRegionInOnOutXY(curvesToCut: CurveCollection | CurvePrimitive | undefined, region: AnyRegion): { insideParts: AnyCurve[], outsideParts: AnyCurve[], coincidentParts: AnyCurve[] } {\r\n const result = { insideParts: [], outsideParts: [], coincidentParts: [] };\r\n const pathWithIntersectionMarkup = RegionOps.cloneCurvesWithXYSplitFlags(curvesToCut, region);\r\n const splitPaths = RegionOps.splitToPathsBetweenFlagBreaks(pathWithIntersectionMarkup, true);\r\n if (splitPaths instanceof CurveCollection) {\r\n for (const child of splitPaths.children) {\r\n const pointOnChild = CurveCollection.createCurveLocationDetailOnAnyCurvePrimitive(child);\r\n if (pointOnChild) {\r\n const inOnOut = RegionOps.testPointInOnOutRegionXY(region, pointOnChild.point.x, pointOnChild.point.y);\r\n pushToInOnOutArrays(child, inOnOut, result.outsideParts, result.coincidentParts, result.insideParts);\r\n }\r\n }\r\n } else if (splitPaths instanceof CurvePrimitive) {\r\n const pointOnChild = CurveCollection.createCurveLocationDetailOnAnyCurvePrimitive(splitPaths);\r\n if (pointOnChild) {\r\n const inOnOut = RegionOps.testPointInOnOutRegionXY(region, pointOnChild.point.x, pointOnChild.point.y);\r\n pushToInOnOutArrays(splitPaths, inOnOut, result.outsideParts, result.coincidentParts, result.insideParts);\r\n }\r\n }\r\n return result;\r\n }\r\n /** Test if `data` is one of several forms of a rectangle.\r\n * * If so, return transform with\r\n * * origin at one corner\r\n * * x and y columns extend along two adjacent sides\r\n * * z column is unit normal.\r\n * * The recognized data forms for simple analysis of points are:\r\n * * LineString\r\n * * Loop containing rectangle content\r\n * * Path containing rectangle content\r\n * * Array of Point3d[]\r\n * * IndexedXYZCollection\r\n * * Points are considered a rectangle if\r\n * * Within the first 4 points\r\n * * vectors from 0 to 1 and 0 to 3 are perpendicular and have a non-zero cross product\r\n * * vectors from 0 to 3 and 1 to 2 are the same\r\n * * optionally require a 5th point that closes back to point0\r\n * * If there are other than the basic number of points (4 or 5) the data\r\n */\r\n public static rectangleEdgeTransform(data: AnyCurve | Point3d[] | IndexedXYZCollection, requireClosurePoint: boolean = true): Transform | undefined {\r\n if (data instanceof LineString3d) {\r\n return this.rectangleEdgeTransform(data.packedPoints);\r\n } else if (data instanceof IndexedXYZCollection) {\r\n let dataToUse;\r\n if (requireClosurePoint && data.length === 5) {\r\n if (!Geometry.isSmallMetricDistance(data.distanceIndexIndex(0, 4)!))\r\n return undefined;\r\n dataToUse = data;\r\n } else if (!requireClosurePoint && data.length === 4)\r\n dataToUse = data;\r\n else if (data.length < (requireClosurePoint ? 5 : 4)) {\r\n return undefined;\r\n } else {\r\n dataToUse = GrowableXYZArray.create(data);\r\n PolylineCompressionContext.compressInPlaceByShortEdgeLength(dataToUse, Geometry.smallMetricDistance);\r\n }\r\n\r\n const vector01 = dataToUse.vectorIndexIndex(0, 1)!;\r\n const vector03 = dataToUse.vectorIndexIndex(0, 3)!;\r\n const vector12 = dataToUse.vectorIndexIndex(1, 2)!;\r\n const normalVector = vector01.crossProduct(vector03);\r\n if (normalVector.normalizeInPlace()\r\n && vector12.isAlmostEqual(vector03)\r\n && vector01.isPerpendicularTo(vector03)) {\r\n return Transform.createOriginAndMatrixColumns(dataToUse.getPoint3dAtUncheckedPointIndex(0), vector01, vector03, normalVector);\r\n }\r\n } else if (Array.isArray(data)) {\r\n return this.rectangleEdgeTransform(new Point3dArrayCarrier(data), requireClosurePoint);\r\n } else if (data instanceof Loop && data.children.length === 1 && data.children[0] instanceof LineString3d) {\r\n return this.rectangleEdgeTransform(data.children[0].packedPoints, true);\r\n } else if (data instanceof Path && data.children.length === 1 && data.children[0] instanceof LineString3d) {\r\n return this.rectangleEdgeTransform(data.children[0].packedPoints, requireClosurePoint);\r\n } else if (data instanceof CurveChain) {\r\n if (!data.checkForNonLinearPrimitives()) {\r\n // const linestring = LineString3d.create();\r\n const strokes = data.getPackedStrokes();\r\n if (strokes) {\r\n return this.rectangleEdgeTransform(strokes);\r\n }\r\n }\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Look for and simplify:\r\n * * Contiguous `LineSegment3d` and `LineString3d` objects.\r\n * * collect all points\r\n * * eliminate duplicated points\r\n * * eliminate points colinear with surrounding points.\r\n * * Contiguous concentric circular or elliptic arcs\r\n * * combine angular ranges\r\n * @param curves Path or loop (or larger collection containing paths and loops) to be simplified\r\n * @param options options for tolerance and selective simplification.\r\n */\r\n public static consolidateAdjacentPrimitives(curves: CurveCollection, options?: ConsolidateAdjacentCurvePrimitivesOptions) {\r\n const context = new ConsolidateAdjacentCurvePrimitivesContext(options);\r\n curves.dispatchToGeometryHandler(context);\r\n }\r\n /**\r\n * If reverse loops as necessary to make them all have CCW orientation for given outward normal.\r\n * * Return an array of arrays which capture the input pointers.\r\n * * In each first level array:\r\n * * The first loop is an outer loop.\r\n * * all subsequent loops are holes\r\n * * The outer loop is CCW\r\n * * The holes are CW.\r\n * * Call PolygonOps.sortOuterAndHoleLoopsXY to have the result returned as an array of arrays of polygons.\r\n * @param loops multiple loops to sort and reverse.\r\n */\r\n public static sortOuterAndHoleLoopsXY(loops: Array<Loop | IndexedXYZCollection>): AnyRegion {\r\n const loopAndArea: SortablePolygon[] = [];\r\n for (const candidate of loops) {\r\n if (candidate instanceof Loop)\r\n SortablePolygon.pushLoop(loopAndArea, candidate);\r\n else if (candidate instanceof IndexedXYZCollection) {\r\n const loop = Loop.createPolygon(candidate);\r\n SortablePolygon.pushLoop(loopAndArea, loop);\r\n }\r\n }\r\n return SortablePolygon.sortAsAnyRegion(loopAndArea);\r\n }\r\n /**\r\n * Find all areas bounded by the unstructured, possibly intersecting curves.\r\n * * In `curvesAndRegions`, Loop/ParityRegion/UnionRegion contribute curve primitives.\r\n * * Each returned [[SignedLoops]] object describes faces in a single connected component.\r\n * * Within the [[SignedLoops]]:\r\n * * positiveAreaLoops contains typical \"interior\" loops with positive area loop ordered counterclockwise\r\n * * negativeAreaLoops contains (probably just one) \"exterior\" loop which is ordered clockwise and\r\n * * slivers contains sliver areas such as appear between coincident curves.\r\n * * edges contains [[LoopCurveLoopCurve]] about each edge within the component. In each edge object\r\n * * loopA = a loop on one side of the edge\r\n * * curveA = a curve that appears as one of loopA.children.\r\n * * loopB = the loop on the other side\r\n * * curveB = a curve that appears as one of loopB.children\r\n * @param curvesAndRegions Any collection of curves.\r\n * @alpha\r\n */\r\n public static constructAllXYRegionLoops(curvesAndRegions: AnyCurve | AnyCurve[]): SignedLoops[] {\r\n const primitivesA = RegionOps.collectCurvePrimitives(curvesAndRegions, undefined, true);\r\n const primitivesB = this.expandLineStrings(primitivesA);\r\n const range = this.curveArrayRange(primitivesB);\r\n const areaTol = this.computeXYAreaTolerance(range);\r\n const intersections = CurveCurve.allIntersectionsAmongPrimitivesXY(primitivesB);\r\n const graph = PlanarSubdivision.assembleHalfEdgeGraph(primitivesB, intersections);\r\n return PlanarSubdivision.collectSignedLoopSetsInHalfEdgeGraph(graph, areaTol);\r\n }\r\n\r\n /**\r\n * collect all `CurvePrimitives` in loosely typed input.\r\n * * This (always) recurses into primitives within collections (Path, Loop, ParityRegion, UnionRegion)\r\n * * It (optionally) recurses to hidden primitives within primitives (i.e. CurveChainWithDistanceIndex)\r\n * * If collectorArray is given, it is NOT cleared -- primitives are appended.\r\n * @param candidates array of various CurvePrimitive and CurveCollection\r\n * @param smallestPossiblePrimitives if false, leave CurveChainWithDistanceIndex as single primitives. If true, recurse to their children.\r\n */\r\n public static collectCurvePrimitives(candidates: AnyCurve | AnyCurve[], collectorArray?: CurvePrimitive[],\r\n smallestPossiblePrimitives: boolean = false,\r\n explodeLinestrings: boolean = false): CurvePrimitive[] {\r\n const results: CurvePrimitive[] = collectorArray === undefined ? [] : collectorArray;\r\n if (candidates instanceof CurvePrimitive) {\r\n candidates.collectCurvePrimitives(results, smallestPossiblePrimitives, explodeLinestrings);\r\n } else if (candidates instanceof CurveCollection) {\r\n candidates.collectCurvePrimitives(results, smallestPossiblePrimitives, explodeLinestrings);\r\n } else if (Array.isArray(candidates)) {\r\n for (const c of candidates) {\r\n this.collectCurvePrimitives(c, results, smallestPossiblePrimitives, explodeLinestrings);\r\n }\r\n }\r\n return results;\r\n }\r\n /**\r\n * Copy primitive pointers from candidates to result array.\r\n * * replace LineString3d by individual LineSegment3d.\r\n * * all others unchanged.\r\n * @param candidates\r\n */\r\n public static expandLineStrings(candidates: CurvePrimitive[]): CurvePrimitive[] {\r\n const result: CurvePrimitive[] = [];\r\n for (const c of candidates) {\r\n if (c instanceof LineString3d) {\r\n for (let i = 0; i + 1 < c.packedPoints.length; i++) {\r\n const q = c.getIndexedSegment(i);\r\n if (q !== undefined)\r\n result.push(q);\r\n }\r\n } else {\r\n result.push(c);\r\n }\r\n }\r\n return result;\r\n }\r\n /**\r\n * Return the overall range of given curves.\r\n * @param curves candidate curves\r\n */\r\n public static curveArrayRange(data: any, worldToLocal?: Transform): Range3d {\r\n const range = Range3d.create();\r\n if (data instanceof GeometryQuery)\r\n data.extendRange(range, worldToLocal);\r\n else if (Array.isArray(data)) {\r\n for (const c of data) {\r\n if (c instanceof GeometryQuery)\r\n c.extendRange(range, worldToLocal);\r\n else if (c instanceof Point3d)\r\n range.extendPoint(c, worldToLocal);\r\n else if (c instanceof GrowableXYZArray)\r\n range.extendRange(c.getRange(worldToLocal));\r\n else if (Array.isArray(c))\r\n range.extendRange(this.curveArrayRange(c, worldToLocal));\r\n }\r\n }\r\n return range;\r\n }\r\n}\r\n\r\nfunction pushToInOnOutArrays(curve: AnyCurve, select: number, arrayNegative: AnyCurve[], array0: AnyCurve[], arrayPositive: AnyCurve[]) {\r\n if (select > 0)\r\n arrayPositive.push(curve);\r\n else if (select < 0)\r\n arrayNegative.push(curve);\r\n else\r\n array0.push(curve);\r\n}\r\n"]}
|
|
1
|
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AAI,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;aACnC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC5B,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE;gBACpB,IAAI,CAAC,YAAY,6BAAa;oBAC5B,CAAC,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;qBAChC,IAAI,CAAC,YAAY,yBAAO;oBAC3B,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;qBAChC,IAAI,CAAC,YAAY,mCAAgB;oBACpC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;qBACzC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;oBACvB,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC;aAC5D;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAtlBD,8BAslBC;AAED,SAAS,mBAAmB,CAAC,KAAe,EAAE,MAAc,EAAE,aAAyB,EAAE,MAAkB,EAAE,aAAyB;IACpI,IAAI,MAAM,GAAG,CAAC;QACZ,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACvB,IAAI,MAAM,GAAG,CAAC;QACjB,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;;QAE1B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { Point3dArrayCarrier } from \"../geometry3d/Point3dArrayCarrier\";\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { PolylineCompressionContext } from \"../geometry3d/PolylineCompressionByEdgeOffset\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { SortablePolygon } from \"../geometry3d/SortablePolygon\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { MomentData } from \"../geometry4d/MomentData\";\r\nimport { Polyface } from \"../polyface/Polyface\";\r\nimport { PolyfaceBuilder } from \"../polyface/PolyfaceBuilder\";\r\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask } from \"../topology/Graph\";\r\nimport { LineStringDataVariant, MultiLineStringDataVariant, Triangulator } from \"../topology/Triangulation\";\r\nimport { ChainCollectorContext } from \"./ChainCollectorContext\";\r\nimport { AnyCurve, AnyRegion } from \"./CurveChain\";\r\nimport { BagOfCurves, ConsolidateAdjacentCurvePrimitivesOptions, CurveChain, CurveCollection } from \"./CurveCollection\";\r\nimport { CurveCurve } from \"./CurveCurve\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { CurveWireMomentsXYZ } from \"./CurveWireMomentsXYZ\";\r\nimport { CurveChainWireOffsetContext, JointOptions, OffsetOptions, PolygonWireOffsetContext } from \"./internalContexts/PolygonOffsetContext\";\r\nimport { LineString3d } from \"./LineString3d\";\r\nimport { Loop, SignedLoops } from \"./Loop\";\r\nimport { Path } from \"./Path\";\r\nimport { ConsolidateAdjacentCurvePrimitivesContext } from \"./Query/ConsolidateAdjacentPrimitivesContext\";\r\nimport { CurveSplitContext } from \"./Query/CurveSplitContext\";\r\nimport { PointInOnOutContext } from \"./Query/InOutTests\";\r\nimport { PlanarSubdivision } from \"./Query/PlanarSubdivision\";\r\nimport { RegionMomentsXY } from \"./RegionMomentsXY\";\r\nimport { OffsetHelpers } from \"./internalContexts/MultiChainCollector\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\nimport { RegionBooleanContext, RegionGroupOpType, RegionOpsFaceToFaceSearch } from \"./RegionOpsClassificationSweeps\";\r\nimport { UnionRegion } from \"./UnionRegion\";\r\nimport { HalfEdgeGraphSearch } from \"../topology/HalfEdgeGraphSearch\";\r\nimport { ParityRegion } from \"./ParityRegion\";\r\n/**\r\n * Possible return types from\r\n * @public\r\n */\r\nexport type ChainTypes = CurvePrimitive | Path | BagOfCurves | Loop | undefined;\r\n\r\n/**\r\n * * `properties` is a string with special characters indicating\r\n * * \"U\" -- contains unmerged stick data\r\n * * \"M\" -- merged\r\n * * \"R\" -- regularized\r\n * * \"X\" -- has exterior markup\r\n * @internal\r\n */\r\nexport type GraphCheckPointFunction = (name: string, graph: HalfEdgeGraph, properties: string, extraData?: any) => any;\r\n/**\r\n * Enumeration of the binary operation types for a booleans among regions\r\n * @public\r\n */\r\nexport enum RegionBinaryOpType {\r\n Union = 0,\r\n Parity = 1,\r\n Intersection = 2,\r\n AMinusB = 3,\r\n BMinusA = 4,\r\n}\r\n\r\n/**\r\n * class `RegionOps` has static members for calculations on regions (areas).\r\n * * Regions are represented by these `CurveCollection` subclasses:\r\n * * `Loop` -- a single loop\r\n * * `ParityRegion` -- a collection of loops, interpreted by parity rules.\r\n * * The common \"One outer loop and many Inner loops\" is a parity region.\r\n * * `UnionRegion` -- a collection of `Loop` and `ParityRegion` objects understood as a (probably disjoint) union.\r\n * @beta\r\n */\r\nexport class RegionOps {\r\n /**\r\n * Return moment sums for a loop, parity region, or union region.\r\n * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with\r\n * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`\r\n * @param root any Loop, ParityRegion, or UnionRegion.\r\n */\r\n public static computeXYAreaMoments(root: AnyRegion): MomentData | undefined {\r\n const handler = new RegionMomentsXY();\r\n const result = root.dispatchToGeometryHandler(handler);\r\n if (result instanceof MomentData) {\r\n result.shiftOriginAndSumsToCentroidOfSums();\r\n return result;\r\n }\r\n return undefined;\r\n }\r\n /** Return an area tolerance for a given xy-range and optional distance tolerance.\r\n * @param range range of planar region to tolerance\r\n * @param distanceTolerance optional absolute distance tolerance\r\n */\r\n public static computeXYAreaTolerance(range: Range3d, distanceTolerance: number=Geometry.smallMetricDistance): number {\r\n // if A = bh and e is distance tolerance, then A' := (b+e/2)(h+e/2) = A + e/2(b+h+e/2), so A'-A = e/2(b+h+e/2).\r\n const halfDistTol = 0.5 * distanceTolerance;\r\n return halfDistTol * (range.xLength() + range.yLength() + halfDistTol);\r\n }\r\n /**\r\n * Return an xy area for a loop, parity region, or union region.\r\n * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with\r\n * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`\r\n * @param root any Loop, ParityRegion, or UnionRegion.\r\n */\r\n public static computeXYArea(root: AnyRegion): number | undefined {\r\n const handler = new RegionMomentsXY();\r\n const result = root.dispatchToGeometryHandler(handler);\r\n if (result instanceof MomentData) {\r\n return result.quantitySum;\r\n }\r\n return undefined;\r\n }\r\n /** Return MomentData with the sums of wire moments.\r\n * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with\r\n * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`\r\n */\r\n public static computeXYZWireMomentSums(root: AnyCurve): MomentData | undefined {\r\n const handler = new CurveWireMomentsXYZ();\r\n handler.visitLeaves(root);\r\n const result = handler.momentData;\r\n result.shiftOriginAndSumsToCentroidOfSums();\r\n return result;\r\n }\r\n\r\n /**\r\n * * create loops in the graph.\r\n * @internal\r\n */\r\n public static addLoopsToGraph(graph: HalfEdgeGraph, data: MultiLineStringDataVariant, announceIsolatedLoop: (graph: HalfEdgeGraph, seed: HalfEdge) => void) {\r\n if (data instanceof Loop) {\r\n const points = data.getPackedStrokes();\r\n if (points)\r\n this.addLoopsToGraph(graph, points, announceIsolatedLoop);\r\n } else if (data instanceof ParityRegion) {\r\n for (const child of data.children) {\r\n const points = child.getPackedStrokes();\r\n if (points)\r\n this.addLoopsToGraph(graph, points, announceIsolatedLoop);\r\n }\r\n } else if (data instanceof IndexedXYZCollection) {\r\n const loopSeed = Triangulator.directCreateFaceLoopFromCoordinates(graph, data);\r\n if (loopSeed !== undefined)\r\n announceIsolatedLoop(graph, loopSeed);\r\n } else if (Array.isArray(data)) {\r\n if (data.length > 0) {\r\n if (Point3d.isAnyImmediatePointType(data[0])) {\r\n const loopSeed = Triangulator.directCreateFaceLoopFromCoordinates(graph, data as LineStringDataVariant);\r\n if (loopSeed !== undefined)\r\n announceIsolatedLoop(graph, loopSeed);\r\n\r\n } else if (data[0] instanceof IndexedXYZCollection) {\r\n for (const loop of data) {\r\n const loopSeed = Triangulator.directCreateFaceLoopFromCoordinates(graph, loop as IndexedXYZCollection);\r\n if (loopSeed !== undefined)\r\n announceIsolatedLoop(graph, loopSeed);\r\n }\r\n } else {\r\n for (const child of data) {\r\n if (Array.isArray(child))\r\n this.addLoopsToGraph(graph, child as MultiLineStringDataVariant, announceIsolatedLoop);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n /** Add multiple loops to a graph.\r\n * * Apply edgeTag and mask to each edge.\r\n * @internal\r\n */\r\n public static addLoopsWithEdgeTagToGraph(graph: HalfEdgeGraph, data: MultiLineStringDataVariant, mask: HalfEdgeMask, edgeTag: any): HalfEdge[] | undefined {\r\n const loopSeeds: HalfEdge[] = [];\r\n this.addLoopsToGraph(graph, data, (_graph: HalfEdgeGraph, seed: HalfEdge) => {\r\n if (seed) {\r\n loopSeeds.push(seed);\r\n seed.setMaskAndEdgeTagAroundFace(mask, edgeTag, true);\r\n }\r\n });\r\n if (loopSeeds.length > 0)\r\n return loopSeeds;\r\n return undefined;\r\n }\r\n /**\r\n * Given a graph just produced by booleans, convert to a polyface\r\n * * \"just produced\" implies exterior face markup.\r\n *\r\n * @param graph\r\n * @param triangulate\r\n */\r\n private static finishGraphToPolyface(graph: HalfEdgeGraph | undefined, triangulate: boolean): Polyface | undefined {\r\n if (graph) {\r\n if (triangulate) {\r\n Triangulator.triangulateAllPositiveAreaFaces(graph);\r\n Triangulator.flipTriangles(graph);\r\n }\r\n return PolyfaceBuilder.graphToPolyface(graph);\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * return a polyface containing the area union of two XY regions.\r\n * * Within each region, in and out is determined by parity rules.\r\n * * Any face that is an odd number of crossings from the far outside is IN\r\n * * Any face that is an even number of crossings from the far outside is OUT\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n */\r\n public static polygonXYAreaIntersectLoopsToPolyface(loopsA: MultiLineStringDataVariant, loopsB: MultiLineStringDataVariant, triangulate: boolean = false): Polyface | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doPolygonBoolean(loopsA, loopsB,\r\n (inA: boolean, inB: boolean) => (inA && inB),\r\n this._graphCheckPointFunction);\r\n return this.finishGraphToPolyface(graph, triangulate);\r\n }\r\n\r\n /**\r\n * return a polyface containing the area union of two XY regions.\r\n * * Within each region, in and out is determined by parity rules.\r\n * * Any face that is an odd number of crossings from the far outside is IN\r\n * * Any face that is an even number of crossings from the far outside is OUT\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n */\r\n public static polygonXYAreaUnionLoopsToPolyface(loopsA: MultiLineStringDataVariant, loopsB: MultiLineStringDataVariant, triangulate: boolean = false): Polyface | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doPolygonBoolean(loopsA, loopsB,\r\n (inA: boolean, inB: boolean) => (inA || inB),\r\n this._graphCheckPointFunction);\r\n return this.finishGraphToPolyface(graph, triangulate);\r\n }\r\n /**\r\n * return a polyface containing the area difference of two XY regions.\r\n * * Within each region, in and out is determined by parity rules.\r\n * * Any face that is an odd number of crossings from the far outside is IN\r\n * * Any face that is an even number of crossings from the far outside is OUT\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n */\r\n public static polygonXYAreaDifferenceLoopsToPolyface(loopsA: MultiLineStringDataVariant, loopsB: MultiLineStringDataVariant, triangulate: boolean = false): Polyface | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doPolygonBoolean(loopsA, loopsB,\r\n (inA: boolean, inB: boolean) => (inA && !inB),\r\n this._graphCheckPointFunction);\r\n return this.finishGraphToPolyface(graph, triangulate);\r\n }\r\n\r\n /**\r\n * return areas defined by a boolean operation.\r\n * * If there are multiple regions in loopsA, they are treated as a union.\r\n * * If there are multiple regions in loopsB, they are treated as a union.\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n * @param operation indicates Union, Intersection, Parity, AMinusB, or BMinusA\r\n * @param mergeTolerance absolute distance tolerance for merging loops\r\n * @alpha\r\n */\r\n public static regionBooleanXY(loopsA: AnyRegion | AnyRegion[] | undefined, loopsB: AnyRegion | AnyRegion[] | undefined, operation: RegionBinaryOpType, mergeTolerance: number = Geometry.smallMetricDistance): AnyRegion | undefined {\r\n const result = UnionRegion.create();\r\n const context = RegionBooleanContext.create(RegionGroupOpType.Union, RegionGroupOpType.Union);\r\n context.addMembers(loopsA, loopsB);\r\n context.annotateAndMergeCurvesInGraph(mergeTolerance);\r\n const range = context.groupA.range().union(context.groupB.range());\r\n const areaTol = this.computeXYAreaTolerance(range);\r\n context.runClassificationSweep(operation, (_graph: HalfEdgeGraph, face: HalfEdge, faceType: -1 | 0 | 1, area: number) => {\r\n // ignore danglers and null faces, but not 2-edge \"banana\" faces with nonzero area\r\n if (face.countEdgesAroundFace() < 2)\r\n return;\r\n if (Math.abs(area) < areaTol)\r\n return;\r\n if (faceType === 1) {\r\n const loop = PlanarSubdivision.createLoopInFace(face);\r\n if (loop)\r\n result.tryAddChild(loop);\r\n }\r\n });\r\n return result;\r\n }\r\n\r\n /**\r\n * return a polyface whose facets area a boolean operation between the input regions.\r\n * * Each of the two inputs is an array of multiple loops or parity regions.\r\n * * Within each of these input arrays, the various entries (loop or set of loops) are interpreted as a union.\r\n * * In each \"array of loops and parity regions\", each entry inputA[i] or inputB[i] is one of:\r\n * * A simple loop, e.g. array of Point3d.\r\n * * Several simple loops, each of which is an array of Point3d.\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n */\r\n public static polygonBooleanXYToPolyface(inputA: MultiLineStringDataVariant[], operation: RegionBinaryOpType,\r\n inputB: MultiLineStringDataVariant[], triangulate: boolean = false): Polyface | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doBinaryBooleanBetweenMultiLoopInputs(\r\n inputA, RegionGroupOpType.Union,\r\n operation,\r\n inputB, RegionGroupOpType.Union, true);\r\n return this.finishGraphToPolyface(graph, triangulate);\r\n }\r\n /**\r\n * return loops of linestrings around areas of a boolean operation between the input regions.\r\n * * Each of the two inputs is an array of multiple loops or parity regions.\r\n * * Within each of these input arrays, the various entries (loop or set of loops) are interpreted as a union.\r\n * * In each \"array of loops and parity regions\", each entry inputA[i] or inputB[i] is one of:\r\n * * A simple loop, e.g. array of Point3d.\r\n * * Several simple loops, each of which is an array of Point3d.\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n */\r\n public static polygonBooleanXYToLoops(\r\n inputA: MultiLineStringDataVariant[],\r\n operation: RegionBinaryOpType,\r\n inputB: MultiLineStringDataVariant[]): AnyRegion | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doBinaryBooleanBetweenMultiLoopInputs(\r\n inputA, RegionGroupOpType.Union,\r\n operation,\r\n inputB, RegionGroupOpType.Union, true);\r\n if (!graph)\r\n return undefined;\r\n const loopEdges = HalfEdgeGraphSearch.collectExtendedBoundaryLoopsInGraph(graph, HalfEdgeMask.EXTERIOR);\r\n const allLoops: Loop[] = [];\r\n for (const graphLoop of loopEdges) {\r\n const points = new GrowableXYZArray();\r\n for (const edge of graphLoop)\r\n points.pushXYZ(edge.x, edge.y, edge.z);\r\n points.pushWrap(1);\r\n const loop = Loop.create();\r\n loop.tryAddChild(LineString3d.createCapture(points));\r\n allLoops.push(loop);\r\n }\r\n return RegionOps.sortOuterAndHoleLoopsXY(allLoops);\r\n }\r\n\r\n /** Construct a wire (not area!!) that is offset from given polyline or polygon.\r\n * * This is a simple wire offset, not an area.\r\n * * The construction algorithm attempts to eliminate some self-intersections within the offsets, but does not guarantee a simple area offset.\r\n * * The construction algorithm is subject to being changed, resulting in different (hopefully better) self-intersection behavior on the future.\r\n * @param points a single loop or path\r\n * @param wrap true to include wraparound\r\n * @param offsetDistance distance of offset from wire. Positive is left.\r\n */\r\n public static constructPolygonWireXYOffset(points: Point3d[], wrap: boolean, offsetDistance: number): CurveCollection | undefined {\r\n const context = new PolygonWireOffsetContext();\r\n return context.constructPolygonWireXYOffset(points, wrap, offsetDistance);\r\n }\r\n /**\r\n * Construct curves that are offset from a Path or Loop as viewed in xy-plane (ignoring z).\r\n * * The construction will remove \"some\" local effects of features smaller than the offset distance, but will not detect self intersection among widely separated edges.\r\n * * If offsetDistance is given as a number, default OffsetOptions are applied.\r\n * * When the offset needs to do an \"outside\" turn, the first applicable construction is applied:\r\n * * If the turn is larger than `options.minArcDegrees`, a circular arc is constructed.\r\n * * If the turn is less than or equal to `options.maxChamferTurnDegrees`, extend curves along tangent to single intersection point.\r\n * * If the turn is larger than `options.maxChamferDegrees`, the turn is constructed as a sequence of straight lines that are:\r\n * * outside the arc\r\n * * have uniform turn angle less than `options.maxChamferDegrees`\r\n * * each line segment (except first and last) touches the arc at its midpoint.\r\n * @param curves base curves.\r\n * @param offsetDistanceOrOptions offset distance (positive to left of curve, negative to right) or options object.\r\n */\r\n public static constructCurveXYOffset(curves: Path | Loop, offsetDistanceOrOptions: number | JointOptions | OffsetOptions): CurveCollection | undefined {\r\n return CurveChainWireOffsetContext.constructCurveXYOffset(curves, offsetDistanceOrOptions);\r\n }\r\n /**\r\n * Test if point (x,y) is IN, OUT or ON a polygon.\r\n * @return (1) for in, (-1) for OUT, (0) for ON\r\n * @param x x coordinate\r\n * @param y y coordinate\r\n * @param points array of xy coordinates.\r\n */\r\n public static testPointInOnOutRegionXY(curves: AnyRegion, x: number, y: number): number {\r\n return PointInOnOutContext.testPointInOnOutRegionXY(curves, x, y);\r\n }\r\n /** Create curve collection of subtype determined by gaps between the input curves.\r\n * * If (a) wrap is requested and (b) all curves connect head-to-tail (including wraparound), assemble as a `loop`.\r\n * * If all curves connect head-to-tail except for closure, return a `Path`.\r\n * * If there are internal gaps, return a `BagOfCurves`\r\n * * If input array has zero length, return undefined.\r\n */\r\n public static createLoopPathOrBagOfCurves(curves: CurvePrimitive[], wrap: boolean = true, consolidateAdjacentPrimitives: boolean = false): CurveCollection | undefined {\r\n const n = curves.length;\r\n if (n === 0)\r\n return undefined;\r\n let maxGap = 0.0;\r\n let isPath = false;\r\n if (wrap)\r\n maxGap = Geometry.maxXY(maxGap, curves[0].startPoint().distance(curves[n - 1].endPoint()));\r\n for (let i = 0; i + 1 < n; i++)\r\n maxGap = Geometry.maxXY(maxGap, curves[i].endPoint().distance(curves[i + 1].startPoint()));\r\n let collection: Loop | Path | BagOfCurves;\r\n if (Geometry.isSmallMetricDistance(maxGap)) {\r\n collection = wrap ? Loop.create() : Path.create();\r\n isPath = true;\r\n } else {\r\n collection = BagOfCurves.create();\r\n }\r\n for (const c of curves)\r\n collection.tryAddChild(c);\r\n if (isPath && consolidateAdjacentPrimitives)\r\n RegionOps.consolidateAdjacentPrimitives(collection);\r\n return collection;\r\n }\r\n\r\n private static _graphCheckPointFunction?: GraphCheckPointFunction;\r\n /**\r\n * Announce Checkpoint function for use during booleans\r\n * @internal\r\n */\r\n public static setCheckPointFunction(f?: GraphCheckPointFunction) { this._graphCheckPointFunction = f; }\r\n /**\r\n * * Find all intersections among curves in `curvesToCut` and `cutterCurves`\r\n * * Return fragments of `curvesToCut`.\r\n * * For a `Loop`, `ParityRegion`, or `UnionRegion` in `curvesToCut`\r\n * * if it is never cut by any `cutter` curve, it will be left unchanged.\r\n * * if cut, the input is downgraded to a set of `Path` curves joining at the cut points.\r\n * * All cutting is \"as viewed in the xy plane\"\r\n */\r\n public static cloneCurvesWithXYSplitFlags(curvesToCut: CurvePrimitive | CurveCollection | undefined, cutterCurves: CurveCollection): CurveCollection | CurvePrimitive | undefined {\r\n return CurveSplitContext.cloneCurvesWithXYSplitFlags(curvesToCut, cutterCurves);\r\n\r\n }\r\n /**\r\n * Create paths assembled from many curves.\r\n * * Assemble consecutive curves NOT separated by either end flags or gaps into paths.\r\n * * Return simplest form -- single primitive, single path, or bag of curves.\r\n * @param curves\r\n */\r\n public static splitToPathsBetweenFlagBreaks(source: CurveCollection | CurvePrimitive | undefined,\r\n makeClones: boolean): BagOfCurves | Path | CurvePrimitive | Loop | undefined {\r\n if (source === undefined)\r\n return undefined;\r\n if (source instanceof CurvePrimitive)\r\n return source;\r\n // source is a collection . ..\r\n const primitives = source.collectCurvePrimitives();\r\n const chainCollector = new ChainCollectorContext(makeClones);\r\n for (const primitive of primitives) {\r\n chainCollector.announceCurvePrimitive(primitive);\r\n }\r\n return chainCollector.grabResult();\r\n }\r\n /**\r\n * * Restructure curve fragments as chains and offsets\r\n * * Return object with named chains, insideOffsets, outsideOffsets\r\n * * BEWARE that if the input is not a loop the classification of outputs is suspect.\r\n * @param fragments fragments to be chained\r\n * @param offsetDistance offset distance.\r\n */\r\n public static collectInsideAndOutsideOffsets(fragments: GeometryQuery[], offsetDistance: number, gapTolerance: number): { insideOffsets: GeometryQuery[], outsideOffsets: GeometryQuery[], chains: ChainTypes } {\r\n return OffsetHelpers.collectInsideAndOutsideOffsets(fragments, offsetDistance, gapTolerance);\r\n }\r\n /**\r\n * * Restructure curve fragments as chains\r\n * * Return the chains, possibly wrapped in BagOfCurves if there multiple chains.\r\n * @param fragments fragments to be chained\r\n * @param offsetDistance offset distance.\r\n */\r\n public static collectChains(fragments: GeometryQuery[], gapTolerance: number = Geometry.smallMetricDistance): ChainTypes {\r\n return OffsetHelpers.collectChains(fragments, gapTolerance);\r\n }\r\n\r\n /**\r\n * * Find intersections of `curvesToCut` with boundaries of `region`.\r\n * * Break `curvesToCut` into parts inside, outside, and coincident.\r\n * * Return all fragments, split among `insideParts`, `outsideParts`, and `coincidentParts` in the output object.\r\n */\r\n public static splitPathsByRegionInOnOutXY(curvesToCut: CurveCollection | CurvePrimitive | undefined, region: AnyRegion): { insideParts: AnyCurve[], outsideParts: AnyCurve[], coincidentParts: AnyCurve[] } {\r\n const result = { insideParts: [], outsideParts: [], coincidentParts: [] };\r\n const pathWithIntersectionMarkup = RegionOps.cloneCurvesWithXYSplitFlags(curvesToCut, region);\r\n const splitPaths = RegionOps.splitToPathsBetweenFlagBreaks(pathWithIntersectionMarkup, true);\r\n if (splitPaths instanceof CurveCollection) {\r\n for (const child of splitPaths.children) {\r\n const pointOnChild = CurveCollection.createCurveLocationDetailOnAnyCurvePrimitive(child);\r\n if (pointOnChild) {\r\n const inOnOut = RegionOps.testPointInOnOutRegionXY(region, pointOnChild.point.x, pointOnChild.point.y);\r\n pushToInOnOutArrays(child, inOnOut, result.outsideParts, result.coincidentParts, result.insideParts);\r\n }\r\n }\r\n } else if (splitPaths instanceof CurvePrimitive) {\r\n const pointOnChild = CurveCollection.createCurveLocationDetailOnAnyCurvePrimitive(splitPaths);\r\n if (pointOnChild) {\r\n const inOnOut = RegionOps.testPointInOnOutRegionXY(region, pointOnChild.point.x, pointOnChild.point.y);\r\n pushToInOnOutArrays(splitPaths, inOnOut, result.outsideParts, result.coincidentParts, result.insideParts);\r\n }\r\n }\r\n return result;\r\n }\r\n /** Test if `data` is one of several forms of a rectangle.\r\n * * If so, return transform with\r\n * * origin at one corner\r\n * * x and y columns extend along two adjacent sides\r\n * * z column is unit normal.\r\n * * The recognized data forms for simple analysis of points are:\r\n * * LineString\r\n * * Loop containing rectangle content\r\n * * Path containing rectangle content\r\n * * Array of Point3d[]\r\n * * IndexedXYZCollection\r\n * * Points are considered a rectangle if\r\n * * Within the first 4 points\r\n * * vectors from 0 to 1 and 0 to 3 are perpendicular and have a non-zero cross product\r\n * * vectors from 0 to 3 and 1 to 2 are the same\r\n * * optionally require a 5th point that closes back to point0\r\n * * If there are other than the basic number of points (4 or 5) the data\r\n */\r\n public static rectangleEdgeTransform(data: AnyCurve | Point3d[] | IndexedXYZCollection, requireClosurePoint: boolean = true): Transform | undefined {\r\n if (data instanceof LineString3d) {\r\n return this.rectangleEdgeTransform(data.packedPoints);\r\n } else if (data instanceof IndexedXYZCollection) {\r\n let dataToUse;\r\n if (requireClosurePoint && data.length === 5) {\r\n if (!Geometry.isSmallMetricDistance(data.distanceIndexIndex(0, 4)!))\r\n return undefined;\r\n dataToUse = data;\r\n } else if (!requireClosurePoint && data.length === 4)\r\n dataToUse = data;\r\n else if (data.length < (requireClosurePoint ? 5 : 4)) {\r\n return undefined;\r\n } else {\r\n dataToUse = GrowableXYZArray.create(data);\r\n PolylineCompressionContext.compressInPlaceByShortEdgeLength(dataToUse, Geometry.smallMetricDistance);\r\n }\r\n\r\n const vector01 = dataToUse.vectorIndexIndex(0, 1)!;\r\n const vector03 = dataToUse.vectorIndexIndex(0, 3)!;\r\n const vector12 = dataToUse.vectorIndexIndex(1, 2)!;\r\n const normalVector = vector01.crossProduct(vector03);\r\n if (normalVector.normalizeInPlace()\r\n && vector12.isAlmostEqual(vector03)\r\n && vector01.isPerpendicularTo(vector03)) {\r\n return Transform.createOriginAndMatrixColumns(dataToUse.getPoint3dAtUncheckedPointIndex(0), vector01, vector03, normalVector);\r\n }\r\n } else if (Array.isArray(data)) {\r\n return this.rectangleEdgeTransform(new Point3dArrayCarrier(data), requireClosurePoint);\r\n } else if (data instanceof Loop && data.children.length === 1 && data.children[0] instanceof LineString3d) {\r\n return this.rectangleEdgeTransform(data.children[0].packedPoints, true);\r\n } else if (data instanceof Path && data.children.length === 1 && data.children[0] instanceof LineString3d) {\r\n return this.rectangleEdgeTransform(data.children[0].packedPoints, requireClosurePoint);\r\n } else if (data instanceof CurveChain) {\r\n if (!data.checkForNonLinearPrimitives()) {\r\n // const linestring = LineString3d.create();\r\n const strokes = data.getPackedStrokes();\r\n if (strokes) {\r\n return this.rectangleEdgeTransform(strokes);\r\n }\r\n }\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Look for and simplify:\r\n * * Contiguous `LineSegment3d` and `LineString3d` objects.\r\n * * collect all points\r\n * * eliminate duplicated points\r\n * * eliminate points colinear with surrounding points.\r\n * * Contiguous concentric circular or elliptic arcs\r\n * * combine angular ranges\r\n * @param curves Path or loop (or larger collection containing paths and loops) to be simplified\r\n * @param options options for tolerance and selective simplification.\r\n */\r\n public static consolidateAdjacentPrimitives(curves: CurveCollection, options?: ConsolidateAdjacentCurvePrimitivesOptions) {\r\n const context = new ConsolidateAdjacentCurvePrimitivesContext(options);\r\n curves.dispatchToGeometryHandler(context);\r\n }\r\n /**\r\n * If reverse loops as necessary to make them all have CCW orientation for given outward normal.\r\n * * Return an array of arrays which capture the input pointers.\r\n * * In each first level array:\r\n * * The first loop is an outer loop.\r\n * * all subsequent loops are holes\r\n * * The outer loop is CCW\r\n * * The holes are CW.\r\n * * Call PolygonOps.sortOuterAndHoleLoopsXY to have the result returned as an array of arrays of polygons.\r\n * @param loops multiple loops to sort and reverse.\r\n */\r\n public static sortOuterAndHoleLoopsXY(loops: Array<Loop | IndexedXYZCollection>): AnyRegion {\r\n const loopAndArea: SortablePolygon[] = [];\r\n for (const candidate of loops) {\r\n if (candidate instanceof Loop)\r\n SortablePolygon.pushLoop(loopAndArea, candidate);\r\n else if (candidate instanceof IndexedXYZCollection) {\r\n const loop = Loop.createPolygon(candidate);\r\n SortablePolygon.pushLoop(loopAndArea, loop);\r\n }\r\n }\r\n return SortablePolygon.sortAsAnyRegion(loopAndArea);\r\n }\r\n /**\r\n * Find all areas bounded by the unstructured, possibly intersecting curves.\r\n * * In `curvesAndRegions`, Loop/ParityRegion/UnionRegion contribute curve primitives.\r\n * * Each returned [[SignedLoops]] object describes faces in a single connected component.\r\n * * Within the [[SignedLoops]]:\r\n * * positiveAreaLoops contains typical \"interior\" loops with positive area loop ordered counterclockwise\r\n * * negativeAreaLoops contains (probably just one) \"exterior\" loop which is ordered clockwise and\r\n * * slivers contains sliver areas such as appear between coincident curves.\r\n * * edges contains [[LoopCurveLoopCurve]] about each edge within the component. In each edge object\r\n * * loopA = a loop on one side of the edge\r\n * * curveA = a curve that appears as one of loopA.children.\r\n * * loopB = the loop on the other side\r\n * * curveB = a curve that appears as one of loopB.children\r\n * @param curvesAndRegions Any collection of curves.\r\n * @alpha\r\n */\r\n public static constructAllXYRegionLoops(curvesAndRegions: AnyCurve | AnyCurve[]): SignedLoops[] {\r\n const primitivesA = RegionOps.collectCurvePrimitives(curvesAndRegions, undefined, true);\r\n const primitivesB = this.expandLineStrings(primitivesA);\r\n const range = this.curveArrayRange(primitivesB);\r\n const areaTol = this.computeXYAreaTolerance(range);\r\n const intersections = CurveCurve.allIntersectionsAmongPrimitivesXY(primitivesB);\r\n const graph = PlanarSubdivision.assembleHalfEdgeGraph(primitivesB, intersections);\r\n return PlanarSubdivision.collectSignedLoopSetsInHalfEdgeGraph(graph, areaTol);\r\n }\r\n\r\n /**\r\n * collect all `CurvePrimitives` in loosely typed input.\r\n * * This (always) recurses into primitives within collections (Path, Loop, ParityRegion, UnionRegion)\r\n * * It (optionally) recurses to hidden primitives within primitives (i.e. CurveChainWithDistanceIndex)\r\n * * If collectorArray is given, it is NOT cleared -- primitives are appended.\r\n * @param candidates array of various CurvePrimitive and CurveCollection\r\n * @param smallestPossiblePrimitives if false, leave CurveChainWithDistanceIndex as single primitives. If true, recurse to their children.\r\n */\r\n public static collectCurvePrimitives(candidates: AnyCurve | AnyCurve[], collectorArray?: CurvePrimitive[],\r\n smallestPossiblePrimitives: boolean = false,\r\n explodeLinestrings: boolean = false): CurvePrimitive[] {\r\n const results: CurvePrimitive[] = collectorArray === undefined ? [] : collectorArray;\r\n if (candidates instanceof CurvePrimitive) {\r\n candidates.collectCurvePrimitives(results, smallestPossiblePrimitives, explodeLinestrings);\r\n } else if (candidates instanceof CurveCollection) {\r\n candidates.collectCurvePrimitives(results, smallestPossiblePrimitives, explodeLinestrings);\r\n } else if (Array.isArray(candidates)) {\r\n for (const c of candidates) {\r\n this.collectCurvePrimitives(c, results, smallestPossiblePrimitives, explodeLinestrings);\r\n }\r\n }\r\n return results;\r\n }\r\n /**\r\n * Copy primitive pointers from candidates to result array.\r\n * * replace LineString3d by individual LineSegment3d.\r\n * * all others unchanged.\r\n * @param candidates\r\n */\r\n public static expandLineStrings(candidates: CurvePrimitive[]): CurvePrimitive[] {\r\n const result: CurvePrimitive[] = [];\r\n for (const c of candidates) {\r\n if (c instanceof LineString3d) {\r\n for (let i = 0; i + 1 < c.packedPoints.length; i++) {\r\n const q = c.getIndexedSegment(i);\r\n if (q !== undefined)\r\n result.push(q);\r\n }\r\n } else {\r\n result.push(c);\r\n }\r\n }\r\n return result;\r\n }\r\n /**\r\n * Return the overall range of given curves.\r\n * @param curves candidate curves\r\n */\r\n public static curveArrayRange(data: any, worldToLocal?: Transform): Range3d {\r\n const range = Range3d.create();\r\n if (data instanceof GeometryQuery)\r\n data.extendRange(range, worldToLocal);\r\n else if (Array.isArray(data)) {\r\n for (const c of data) {\r\n if (c instanceof GeometryQuery)\r\n c.extendRange(range, worldToLocal);\r\n else if (c instanceof Point3d)\r\n range.extendPoint(c, worldToLocal);\r\n else if (c instanceof GrowableXYZArray)\r\n range.extendRange(c.getRange(worldToLocal));\r\n else if (Array.isArray(c))\r\n range.extendRange(this.curveArrayRange(c, worldToLocal));\r\n }\r\n }\r\n return range;\r\n }\r\n}\r\n\r\nfunction pushToInOnOutArrays(curve: AnyCurve, select: number, arrayNegative: AnyCurve[], array0: AnyCurve[], arrayPositive: AnyCurve[]) {\r\n if (select > 0)\r\n arrayPositive.push(curve);\r\n else if (select < 0)\r\n arrayNegative.push(curve);\r\n else\r\n array0.push(curve);\r\n}\r\n"]}
|
|
@@ -190,8 +190,9 @@ export declare class RegionBooleanContext implements RegionOpsFaceToFaceSearchCa
|
|
|
190
190
|
* * groups with point data but no curves get no further annotation.
|
|
191
191
|
* * compute intersections.
|
|
192
192
|
* * assemble and merge the HalfEdgeGraph.
|
|
193
|
+
* @param mergeTolerance absolute distance tolerance for merging loops
|
|
193
194
|
*/
|
|
194
|
-
annotateAndMergeCurvesInGraph(): void;
|
|
195
|
+
annotateAndMergeCurvesInGraph(mergeTolerance?: number): void;
|
|
195
196
|
private _announceFaceFunction?;
|
|
196
197
|
/**
|
|
197
198
|
* Sweep through the graph to assign in/out classifications to all faces.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegionOpsClassificationSweeps.d.ts","sourceRoot":"","sources":["../../../src/curve/RegionOpsClassificationSweeps.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAIhG,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAa,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIlD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAMvD;;;;;;;;;;;;;;GAcG;AACH,uBAAe,kCAAkC;IAC/C,sEAAsE;IAC/D,cAAc,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO;IAC/C,oCAAoC;IAC7B,eAAe,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO;IAChD,0BAA0B;IACnB,SAAS,CAAC,cAAc,EAAE,QAAQ,EAAE,EAAE,YAAY,EAAE,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0BAA0B;IAyBlC,sEAAsE;IAC/D,cAAc,CAAC,aAAa,EAAE,QAAQ,GAAG,OAAO;IAMvD,oCAAoC;IAC7B,eAAe,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO;IAGhD;;;;;OAKG;IACI,SAAS,CAAC,cAAc,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,QAAQ,GAAG,OAAO;IAS5E,yBAAyB;IAClB,SAAS,CAAC,cAAc,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,QAAQ,GAAG,OAAO;CAI7E;AAiCD;;;;GAIG;AACH,oBAAY,oBAAoB,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAC5E;;;GAGG;AACH,qBAAa,cAAc;IAClB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;gBACH,KAAK,EAAE,QAAQ,EAAE;IAKpC;;;;;OAKG;IACI,aAAa,CAAC,kBAAkB,EAAE,oBAAoB,GAAG,SAAS,EAAE,gBAAgB,EAAE,oBAAoB,GAAG,SAAS;CAmB9H;AACD;;GAEG;AACH,qBAAa,mBAAmB;IACvB,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,KAAK,EAAE,aAAa,CAAC;IAC5B,OAAO;WAIO,MAAM,CAAC,KAAK,EAAE,aAAa,EAAE,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,mBAAmB;CAU/H"}
|
|
@@ -480,8 +480,9 @@ class RegionBooleanContext {
|
|
|
480
480
|
* * groups with point data but no curves get no further annotation.
|
|
481
481
|
* * compute intersections.
|
|
482
482
|
* * assemble and merge the HalfEdgeGraph.
|
|
483
|
+
* @param mergeTolerance absolute distance tolerance for merging loops
|
|
483
484
|
*/
|
|
484
|
-
annotateAndMergeCurvesInGraph() {
|
|
485
|
+
annotateAndMergeCurvesInGraph(mergeTolerance = Geometry_1.Geometry.smallMetricDistance) {
|
|
485
486
|
const allPrimitives = [];
|
|
486
487
|
// ASSUME loops have fine-grained types -- no linestrings !!
|
|
487
488
|
for (const group of [this.groupA, this.groupB, this.extraGeometry]) {
|
|
@@ -495,7 +496,7 @@ class RegionBooleanContext {
|
|
|
495
496
|
}
|
|
496
497
|
}
|
|
497
498
|
// const range = RegionOps.curveArrayRange(allPrimitives);
|
|
498
|
-
const intersections = CurveCurve_1.CurveCurve.allIntersectionsAmongPrimitivesXY(allPrimitives);
|
|
499
|
+
const intersections = CurveCurve_1.CurveCurve.allIntersectionsAmongPrimitivesXY(allPrimitives, mergeTolerance);
|
|
499
500
|
const graph = PlanarSubdivision_1.PlanarSubdivision.assembleHalfEdgeGraph(allPrimitives, intersections);
|
|
500
501
|
this.graph = graph;
|
|
501
502
|
this.faceAreaFunction = faceAreaFromCurvedEdgeData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegionOpsClassificationSweeps.js","sourceRoot":"","sources":["../../../src/curve/RegionOpsClassificationSweeps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,6CAAgG;AAChG,yEAAsE;AACtE,iDAAyD;AACzD,+DAAmE;AAEnE,2CAAqF;AACrF,iDAA8C;AAC9C,iCAA8B;AAE9B,6CAA0C;AAC1C,iEAA8D;AAC9D,0CAAuC;AAEvC,+CAA4C;AAC5C,+DAA4D;AAE5D,mDAAgD;AAChD,mCAAgC;AAChC,+CAAuD;AACvD,mEAAkE;AAClE,4FAAyF;AACzF,mDAAgD;AAChD,+CAA4C;AAE5C;;;;;;;;;;;;;;GAcG;AACH,MAAe,kCAAkC;IAC/C,sEAAsE;IAC/D,cAAc,CAAC,KAAe,IAAa,OAAO,IAAI,CAAC,CAAC,CAAC;IAChE,oCAAoC;IAC7B,eAAe,CAAC,KAAe,IAAa,OAAO,IAAI,CAAC,CAAC,CA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AC;CACF;AAlCD,wCAkCC;AACD;;GAEG;AACH,MAAa,mBAAmB;IAG9B,YAAoB,KAAoB;QACtC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;IACM,MAAM,CAAC,MAAM,CAAC,KAAoB,EAAE,kBAA6D;QACtG,MAAM,MAAM,GAAG,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC9C,MAAM,eAAe,GAAG,yCAAmB,CAAC,iDAAiD,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAChH,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE;YAC5C,MAAM,SAAS,GAAG,IAAI,cAAc,CAAC,cAAc,CAAC,CAAC;YACrD,SAAS,CAAC,aAAa,CAAC,kBAAkB,EAAE,0BAA0B,CAAC,CAAC;YACxE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACnC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAjBD,kDAiBC","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 Curve\r\n */\r\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask, NodeToNumberFunction } from \"../topology/Graph\";\r\nimport { HalfEdgeGraphSearch } from \"../topology/HalfEdgeGraphSearch\";\r\nimport { HalfEdgeGraphMerge } from \"../topology/Merging\";\r\nimport { RegularizationContext } from \"../topology/RegularizeFace\";\r\nimport { MultiLineStringDataVariant } from \"../topology/Triangulation\";\r\nimport { GraphCheckPointFunction, RegionBinaryOpType, RegionOps } from \"./RegionOps\";\r\nimport { ParityRegion } from \"./ParityRegion\";\r\nimport { Loop } from \"./Loop\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { CurveCurve } from \"./CurveCurve\";\r\nimport { PlanarSubdivision } from \"./Query/PlanarSubdivision\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { AnyRegion } from \"./CurveChain\";\r\nimport { UnionRegion } from \"./UnionRegion\";\r\nimport { CurveLocationDetail } from \"./CurveLocationDetail\";\r\nimport { XAndY } from \"../geometry3d/XYZProps\";\r\nimport { LineSegment3d } from \"./LineSegment3d\";\r\nimport { Arc3d } from \"./Arc3d\";\r\nimport { Range2d, Range3d } from \"../geometry3d/Range\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { PlaneAltitudeRangeContext } from \"./internalContexts/PlaneAltitudeRangeContext\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\n\r\n/**\r\n * base class for callbacks during region sweeps.\r\n * * At start of a component, `startComponent(node)` is called announcing a representative node on the outermost face.\r\n * * A Component in this usage is a component that is edge connected when ignoring \"exterior bridge edges\".\r\n * * As each face is entered, `enterFace(facePathStack, newFaceNode)` is called\r\n * * facePathStack[0] is the outermost node of the path from the outer face.\r\n * * facePathStack[1] is its inside mate.\r\n * * facePathStack[2k] is the outside node at crossing to face at depth k.\r\n * * facePathStack[2k+1] is the node where face at depth k was entered.\r\n * * newFaceNode is the entry node (redundant of stack tip)\r\n * * On retreat from a face, `leaveFace(facePathStack, faceNode)` is called.\r\n * * At end of component, `finishComponent (node)` is called.\r\n * * The base class is fully implemented to do nothing during the sweep.\r\n * @internal\r\n */\r\nabstract class RegionOpsFaceToFaceSearchCallbacks {\r\n /** Announce a representative node on the outer face of a component */\r\n public startComponent(_node: HalfEdge): boolean { return true; }\r\n /** Announce return to outer face */\r\n public finishComponent(_node: HalfEdge): boolean { return true; }\r\n /** Announce face entry */\r\n public enterFace(_facePathStack: HalfEdge[], _newFaceNode: HalfEdge): boolean { return true; }\r\n /** Announce face exit */\r\n public leaveFace(_facePathStack: HalfEdge[], _newFaceNode: HalfEdge): boolean { return true; }\r\n}\r\n/** Function signature to test if a pair of boolean states is to be accepted by area booleans (during face-to-face sweeps)\r\n * @internal\r\n */\r\ntype BinaryBooleanAcceptFunction = (stateA: boolean, stateB: boolean) => boolean;\r\n/** Function signature ot announce classification of a face.\r\n * The `faceType` parameters are\r\n * * -1 for a fully exterior face. This is a negative area face.\r\n * * 0 for a positive area face classified as \"out\" for the boolean.\r\n * * 1 for a positive area face classified as \"in\" for the boolean.\r\n */\r\ntype AnnounceClassifiedFace = (graph: HalfEdgeGraph, faceSeed: HalfEdge, faceType: -1 | 0 | 1, area: number) => void;\r\n/**\r\n * Implementation of `RegionOpsFaceToFaceSearchCallbacks` for binary boolean sweep with polygonal regions.\r\n * * For this linear-boundary case the boundary geometry is carried entirely from the coordinates in the half edges.\r\n * * This assumes the each node in the graph has edgeTag set to:\r\n * * `edgeTag === undefined` if the edge crossing does not change classification.\r\n * * for example, an edge added by regularization\r\n * * `edgeTag === 1` if this is a boundary for the first of the boolean input regions\r\n * * `edgeTag === 2` if this is a boundary for the second of the boolean input regions\r\n * * constructor\r\n * * takes caller-supplied function to decide whether to accept a face given its state relative to the two boolean terms.\r\n * * sets the in/out status of both terms to false.\r\n * * `startComponent` marks the entire outer face as `EXTERIOR`\r\n * * `enterFace`\r\n * * if this is a bounding edge (according to `node.faceTag`) toggle the in/out status if this boolean term.\r\n * * ask the faceAcceptFunction if the current term states combine to in/out for the result\r\n * * if out, set the `EXTERIOR` mask around the face.\r\n * * `leaveFace`\r\n * * if this is a bounding edge (according to `node.faceTag`) toggle the in/out status if this boolean term.\r\n * * `finishComponent` is not reimplemented.\r\n * @internal\r\n */\r\nclass RegionOpsBinaryBooleanSweepCallbacks extends RegionOpsFaceToFaceSearchCallbacks {\r\n private _faceSelectFunction: BinaryBooleanAcceptFunction;\r\n private _inComponent: boolean[];\r\n private _exteriorMask: HalfEdgeMask;\r\n public constructor(acceptFaceFunction: BinaryBooleanAcceptFunction, exteriorMask: HalfEdgeMask) {\r\n super();\r\n this._inComponent = [false, false, false]; // entry 0 is never reused.\r\n this._exteriorMask = exteriorMask;\r\n this._faceSelectFunction = acceptFaceFunction;\r\n }\r\n /** Mark this face as exterior */\r\n public override startComponent(node: HalfEdge): boolean { node.setMaskAroundFace(this._exteriorMask); return true; }\r\n /**\r\n * * If necessary, toggle a term state.\r\n * * if indicated, mark this face exterior.\r\n */\r\n public override enterFace(_facePathStack: HalfEdge[], node: HalfEdge): boolean {\r\n const thisFaceIndex = node.edgeTag;\r\n if (node.edgeTag === 1 || node.edgeTag === 2)\r\n this._inComponent[thisFaceIndex] = !this._inComponent[thisFaceIndex];\r\n if (!this._faceSelectFunction(this._inComponent[1], this._inComponent[2]))\r\n node.setMaskAroundFace(this._exteriorMask);\r\n return true;\r\n }\r\n /**\r\n * * If necessary, toggle a term state.\r\n */\r\n public override leaveFace(_facePathStack: HalfEdge[], node: HalfEdge): boolean {\r\n const thisFaceIndex = node.edgeTag;\r\n if (node.edgeTag === 1 || node.edgeTag === 2)\r\n this._inComponent[thisFaceIndex] = !this._inComponent[thisFaceIndex];\r\n return true;\r\n }\r\n}\r\n/**\r\n * Low level graph search for face classification.\r\n * @internal\r\n */\r\nexport class RegionOpsFaceToFaceSearch {\r\n /**\r\n * run a DFS with face-to-face step announcements.\r\n * * false return from any function terminates search immediately.\r\n * * all reachable nodes assumed to have both visit masks clear.\r\n * @param graph containing graph.\r\n * @param seed first node to visit.\r\n * @param faceHasBeenVisited mask marking faces that have been seen.\r\n * @param nodeHasBeenVisited mask marking node-to-node step around face.\r\n *\r\n */\r\n public static faceToFaceSearchFromOuterLoop(_graph: HalfEdgeGraph, seed: HalfEdge, faceHasBeenVisited: HalfEdgeMask, nodeHasBeenVisited: HalfEdgeMask, callbacks: RegionOpsFaceToFaceSearchCallbacks) {\r\n if (seed.isMaskSet(faceHasBeenVisited))\r\n return;\r\n if (!callbacks.startComponent(seed))\r\n return;\r\n const facePathStack = [];\r\n seed.setMaskAroundFace(faceHasBeenVisited);\r\n let faceWalker = seed;\r\n do {\r\n let entryNode = faceWalker;\r\n let mate = faceWalker.edgeMate;\r\n if (!mate.isMaskSet(faceHasBeenVisited)) {\r\n // the faceWalker seed is always on the base of the stack.\r\n // the stack then contains even-odd pairs of (entryNode, currentNode)\r\n // * entryNode is the node where a face was entered.\r\n // * faceNode is another node around that face.\r\n facePathStack.push(faceWalker);\r\n facePathStack.push(mate);\r\n let faceNode = mate.faceSuccessor;\r\n mate.setMaskAroundFace(faceHasBeenVisited);\r\n entryNode = mate;\r\n if (callbacks.enterFace(facePathStack, mate)) {\r\n for (; ;) {\r\n mate = faceNode.edgeMate;\r\n if (!mate.isMaskSet(faceHasBeenVisited)) {\r\n mate.setMaskAroundFace(faceHasBeenVisited);\r\n if (!callbacks.enterFace(facePathStack, mate))\r\n return;\r\n facePathStack.push(faceNode);\r\n facePathStack.push(mate);\r\n faceNode = mate;\r\n entryNode = mate;\r\n }\r\n faceNode.setMask(nodeHasBeenVisited);\r\n faceNode = faceNode.faceSuccessor;\r\n if (faceNode === entryNode) {\r\n callbacks.leaveFace(facePathStack, faceNode);\r\n if (facePathStack.length <= 2) {\r\n break;\r\n }\r\n facePathStack.pop();\r\n faceNode = facePathStack[facePathStack.length - 1];\r\n facePathStack.pop();\r\n entryNode = facePathStack[facePathStack.length - 1];\r\n }\r\n if (faceNode.isMaskSet(nodeHasBeenVisited)) {\r\n // this is disaster !!!\r\n return;\r\n }\r\n }\r\n }\r\n }\r\n // continue at outermost level .....\r\n faceWalker = faceWalker.faceSuccessor;\r\n } while (faceWalker !== seed);\r\n callbacks.finishComponent(seed);\r\n }\r\n /** Complete multi-step process for polygon binary booleans starting with arrays of coordinates.\r\n * * Each of the binary input terms is a collection of loops\r\n * * Within the binary term, in/out is determined by edge-crossing parity rules.\r\n * * Processing steps are\r\n * * Build the loops for each set.\r\n * * Each edge labeled with 1 or 2 as binary term identifier.\r\n * * find crossings among the edges.\r\n * * Edges are split as needed, but split preserves the edgeTag\r\n * * sort edges around vertices\r\n * * add regularization edges so holes are connected to their parent.\r\n */\r\n public static doPolygonBoolean(loopsA: MultiLineStringDataVariant, loopsB: MultiLineStringDataVariant, faceSelectFunction: (inA: boolean, inB: boolean) => boolean, graphCheckPoint?: GraphCheckPointFunction): HalfEdgeGraph | undefined {\r\n const graph = new HalfEdgeGraph();\r\n const baseMask = HalfEdgeMask.BOUNDARY_EDGE | HalfEdgeMask.PRIMARY_EDGE;\r\n const seedA = RegionOps.addLoopsWithEdgeTagToGraph(graph, loopsA, baseMask, 1);\r\n const seedB = RegionOps.addLoopsWithEdgeTagToGraph(graph, loopsB, baseMask, 2);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"unmerged loops\", graph, \"U\");\r\n if (seedA || seedB) {\r\n // split edges where they cross . . .\r\n HalfEdgeGraphMerge.splitIntersectingEdges(graph);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"After splitIntersectingEdges\", graph, \"S\");\r\n // sort radially around vertices.\r\n HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"After clusterAndMergeXYTheta\", graph, \"M\");\r\n // add edges to connect various components (e.g. holes!!!)\r\n const context = new RegularizationContext(graph);\r\n context.regularizeGraph(true, true);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"After regularize\", graph, \"MR\");\r\n const exteriorHalfEdge = HalfEdgeGraphSearch.findMinimumAreaFace(graph);\r\n const exteriorMask = HalfEdgeMask.EXTERIOR;\r\n const faceVisitedMask = graph.grabMask();\r\n const nodeVisitedMask = graph.grabMask();\r\n const allMasksToClear = exteriorMask | faceVisitedMask | nodeVisitedMask;\r\n graph.clearMask(allMasksToClear);\r\n const callbacks = new RegionOpsBinaryBooleanSweepCallbacks(faceSelectFunction, exteriorMask);\r\n this.faceToFaceSearchFromOuterLoop(graph, exteriorHalfEdge, faceVisitedMask, nodeVisitedMask, callbacks);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"After faceToFaceSearchFromOuterLoop\", graph, \"MRX\");\r\n graph.dropMask(faceVisitedMask);\r\n graph.dropMask(nodeVisitedMask);\r\n return graph;\r\n }\r\n return undefined;\r\n }\r\n\r\n /** Complete multi-step process for polygon binary booleans starting with arrays of coordinates.\r\n * * the manyLoopsAndParitySets input is an array.\r\n * * Each entry is one or more loops.\r\n * * An entry that is \"just points\" is a simple loop.\r\n * * An entry that is itself an array of arrays of points is a set of loops with \"parity\" -- relation:\r\n * * typically the first is an outer loop an others are holes.\r\n * * but if there is self intersection or multiple outer loops, parity rules are applied to decide inner and outer.\r\n * * Processing steps are\r\n * * Build the loops for each set.\r\n * * Each edge labeled with index to the outer array.\r\n * * find crossings among the edges.\r\n * * Edges are split as needed, but split preserves the edgeTag\r\n * * sort edges around vertices\r\n * * add regularization edges so holes are connected to their parent.\r\n * * assign inside/outside by parity within each set and overall union.\r\n */\r\n public static doBinaryBooleanBetweenMultiLoopInputs(\r\n dataA: MultiLineStringDataVariant[],\r\n opA: RegionGroupOpType,\r\n binaryOp: RegionBinaryOpType,\r\n dataB: MultiLineStringDataVariant[],\r\n opB: RegionGroupOpType,\r\n purgeSliverExteriorFaces: boolean\r\n ): HalfEdgeGraph | undefined {\r\n const graph = new HalfEdgeGraph();\r\n const baseMask = HalfEdgeMask.BOUNDARY_EDGE | HalfEdgeMask.PRIMARY_EDGE;\r\n const callbacks = RegionBooleanContext.create(opA, opB);\r\n callbacks.graph = graph;\r\n callbacks.faceAreaFunction = HalfEdgeGraphSearch.signedFaceArea;\r\n\r\n // Add all the members in groupA ..\r\n for (const data of dataA) {\r\n if (data.length > 2){\r\n const member = new RegionGroupMember(data, callbacks.groupA);\r\n RegionOps.addLoopsWithEdgeTagToGraph(graph, data, baseMask, member);\r\n }\r\n }\r\n for (const data of dataB) {\r\n if (data.length > 2){\r\n const member = new RegionGroupMember(data, callbacks.groupB);\r\n RegionOps.addLoopsWithEdgeTagToGraph(graph, data, baseMask, member);\r\n }\r\n }\r\n // split edges where they cross . . .\r\n HalfEdgeGraphMerge.splitIntersectingEdges(graph);\r\n // sort radially around vertices.\r\n HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph);\r\n // add edges to connect various components (e.g. holes!!!)\r\n const context = new RegularizationContext(graph);\r\n context.regularizeGraph(true, true);\r\n callbacks.runClassificationSweep(binaryOp);\r\n if (purgeSliverExteriorFaces)\r\n callbacks.unmaskMaskedNullFaces(HalfEdgeMask.EXTERIOR);\r\n return graph;\r\n }\r\n}\r\n\r\n/**\r\n * Enumeration of operation types \"within a group operand\" for a `RegionBooleanContext`.\r\n * @internal\r\n */\r\nexport enum RegionGroupOpType {\r\n Union = 0,\r\n Parity = 1,\r\n Intersection = 2,\r\n NonBounding = -1,\r\n}\r\n/**\r\n * Each loop or parity region in a `RegionBooleanContext` is recorded as a `RegionGroupMember`, which carries\r\n * * the Loop or parityRegion object\r\n * * a numeric indication of the sweep state (parity) during the classification search.\r\n * * a reference to the parent group (which in turn leads back to the `RegionBooleanContext`)\r\n * @internal\r\n */\r\nclass RegionGroupMember {\r\n public region: Loop | ParityRegion | CurvePrimitive | MultiLineStringDataVariant;\r\n public sweepState: number;\r\n public parentGroup: RegionGroup;\r\n public constructor(region: Loop | ParityRegion | CurvePrimitive | MultiLineStringDataVariant, parentGroup: RegionGroup) {\r\n this.region = region;\r\n this.parentGroup = parentGroup;\r\n this.sweepState = 0;\r\n }\r\n public clearState() { this.sweepState = 0; }\r\n}\r\n/**\r\n * A `RegionGroup` is\r\n * * An array of `RegionGroupMembers`, carrying the regions of the Ai or Bi part of the boolean expression.\r\n * * The `RegionGroupOpType` to be applied among those members.\r\n * * Pointer to the containing context\r\n * * The count of number of regions known to be \"in\" as the search progresses.\r\n * @internal\r\n */\r\nexport class RegionGroup {\r\n public members: RegionGroupMember[];\r\n public groupOpType: RegionGroupOpType;\r\n public parent: RegionBooleanContext;\r\n private _numIn: number;\r\n public constructor(parent: RegionBooleanContext, groupOpType: RegionGroupOpType) {\r\n this.members = [];\r\n this.parent = parent;\r\n this.groupOpType = groupOpType;\r\n this._numIn = 0;\r\n }\r\n /** deep clear of state data -- group header plus all members */\r\n public clearState() {\r\n for (const member of this.members)\r\n member.clearState();\r\n this._numIn = 0;\r\n }\r\n public range(): Range3d {\r\n const range = Range3d.createNull();\r\n for (const m of this.members) {\r\n if (m.region instanceof GeometryQuery)\r\n m.region.extendRange(range);\r\n else {\r\n const range1 = Range3d.createFromVariantData(m.region);\r\n range.extendRange(range1);\r\n }\r\n }\r\n return range;\r\n }\r\n /** Ask if the current _numIn count qualifies as an \"in\" for this operation type.\r\n */\r\n public getInOut(): boolean {\r\n // UNION is true if one or more members are IN\r\n if (this.groupOpType === RegionGroupOpType.Union)\r\n return this._numIn > 0;\r\n // PARITY is true if an odd number of regions are IN\r\n if (this.groupOpType === RegionGroupOpType.Parity)\r\n return Geometry.isOdd(this._numIn);\r\n // INTERSECTION is true if ALL the regions are IN\r\n if (this.groupOpType === RegionGroupOpType.Intersection)\r\n return this._numIn === this.members.length;\r\n return false;\r\n }\r\n // push new members into the group.\r\n public addMember(data: AnyRegion | AnyRegion[] | LineSegment3d | undefined, allowLineSegment: boolean = false) {\r\n if (data instanceof Loop || data instanceof ParityRegion) {\r\n const cleanerData = data.clone() as (ParityRegion | Loop);\r\n RegionOps.consolidateAdjacentPrimitives(cleanerData);\r\n this.members.push(new RegionGroupMember(cleanerData, this));\r\n } else if (data instanceof UnionRegion) {\r\n for (const child of data.children) {\r\n this.addMember(child);\r\n }\r\n } else if (Array.isArray(data)) {\r\n for (const item of data) {\r\n this.addMember(item);\r\n }\r\n } else if (allowLineSegment && data instanceof LineSegment3d) {\r\n this.members.push(new RegionGroupMember(data, this));\r\n\r\n }\r\n }\r\n // update the \"in\" count _numIn according to old and new states (parity counts) for some member region.\r\n public recordMemberStateChange(oldState: number, newState: number) {\r\n const oldIn = Geometry.isOdd(oldState);\r\n const newIn = Geometry.isOdd(newState);\r\n if (!oldIn && newIn)\r\n this._numIn++;\r\n else if (oldIn && !newIn)\r\n this._numIn--;\r\n }\r\n}\r\n/**\r\n * A `RegionBooleanContext` carries structure and operations for binary operations between two sets of regions.\r\n * * In the binary operation OP (union, intersection, parity, difference), the left and right operands\r\n * are each a composite union, difference, or parity among multiple inputs, i.e.\r\n * * (operationA among Ai) OP (operationB among Bi)\r\n * * where the Ai are one set of regions, being combined by operationA\r\n * * and the Bi are the another set of regions, being combined by operationB\r\n * * Each group of Ai and Bi is a `RegionGroup`\r\n * * This is an extremely delicate structure.\r\n * * Members are public because of the unique variety of queries, but should only be used for queries.\r\n * * The graph and curves in the booleans are connected by an extended pointer chain:\r\n * * (HalfEdge in Graph).edgeTag points to a CurveLocationDetail\r\n * * (CurveLocationDetail).curve points to a curve\r\n * * (Curve).parent points to RegionGroupMember\r\n * * (RegionGroupMember) points to RegionGroup\r\n * * (RegionGroup) points to RegionBooleanBinaryContext\r\n * * So..when a graph sweep crosses an edge,\r\n * * the chain leads to a parity count in the RegionGroupMember\r\n * * that can change the number of members active in the RegionGroup\r\n * * which can change the state of the context.\r\n * @internal\r\n */\r\nexport class RegionBooleanContext implements RegionOpsFaceToFaceSearchCallbacks {\r\n public groupA!: RegionGroup;\r\n public groupB!: RegionGroup;\r\n public extraGeometry!: RegionGroup;\r\n public graph!: HalfEdgeGraph;\r\n public faceAreaFunction!: NodeToNumberFunction;\r\n public binaryOp: RegionBinaryOpType;\r\n\r\n private constructor(groupTypeA: RegionGroupOpType, groupTypeB: RegionGroupOpType) {\r\n this.groupA = new RegionGroup(this, groupTypeA);\r\n this.groupB = new RegionGroup(this, groupTypeB);\r\n this.extraGeometry = new RegionGroup(this, RegionGroupOpType.NonBounding);\r\n this.binaryOp = RegionBinaryOpType.Union; // it will be revised on can calls.\r\n }\r\n /**\r\n * Create a context with both A and B groups empty.\r\n * * Caller follows up by calls to `context.groupA.addMember (loopOrParityRegion)` or `context.groupB.addMember (loopOrParityRegion)`\r\n * @param groupTypeA\r\n * @param groupTypeB\r\n */\r\n public static create(groupTypeA: RegionGroupOpType, groupTypeB: RegionGroupOpType): RegionBooleanContext {\r\n return new RegionBooleanContext(groupTypeA, groupTypeB);\r\n }\r\n public addMembers(dataA: AnyRegion | AnyRegion[] | undefined, dataB: AnyRegion | AnyRegion[] | undefined) {\r\n this.groupA.addMember(dataA);\r\n this.groupB.addMember(dataB);\r\n // const doConnectives = 1;\r\n // if (doConnectives !== 0)\r\n this.addConnectives();\r\n }\r\n\r\n private _workSegment?: LineSegment3d;\r\n private static _bridgeDirection = Vector3d.createNormalized(1.0, -0.12328974132467)!; // magic unit direction to minimize vertex hits\r\n /**\r\n * The sweep operations require access to all geometry by edge crossings and face walk.\r\n * If input loops are non-overlapping, there may be disconnected islands not reachable.\r\n * This method:\r\n * * finds the total range\r\n * * creates parallel rays from the extreme point of each loop and extending beyond the overall range\r\n * * places those lines in the extraGeometry group\r\n */\r\n public addConnectives() {\r\n const rangeA = this.groupA.range();\r\n const rangeB = this.groupB.range();\r\n const rangeAB = rangeA.union(rangeB);\r\n const areaTol = RegionOps.computeXYAreaTolerance(rangeAB);\r\n let margin = 0.1;\r\n this._workSegment = PlaneAltitudeRangeContext.findExtremePointsInDirection(rangeAB.corners(), RegionBooleanContext._bridgeDirection, this._workSegment);\r\n if (this._workSegment)\r\n margin *= this._workSegment.point0Ref.distanceXY(this._workSegment.point1Ref); // how much further to extend each bridge ray\r\n\r\n const maxPoints: Point3d[] = [];\r\n const findExtremePointsInLoop = (region: Loop) => {\r\n const area = RegionOps.computeXYArea(region);\r\n if (area === undefined || Math.abs(area) < areaTol)\r\n return; // avoid bridging trivial faces\r\n this._workSegment = PlaneAltitudeRangeContext.findExtremePointsInDirection(region, RegionBooleanContext._bridgeDirection, this._workSegment);\r\n if (this._workSegment)\r\n maxPoints.push(this._workSegment.point1Ref);\r\n };\r\n\r\n for (const groupMembers of [this.groupA.members, this.groupB.members]) {\r\n for (const m of groupMembers) {\r\n if (m.region instanceof Loop) {\r\n findExtremePointsInLoop(m.region);\r\n } else if (m.region instanceof ParityRegion) {\r\n for (const loop of m.region.children)\r\n findExtremePointsInLoop(loop);\r\n }\r\n }\r\n }\r\n\r\n const ray = Ray3d.createZero();\r\n for (const p of maxPoints) {\r\n // Make a line from...\r\n // 1) exactly the max point of the loops to\r\n // 2) a point clearly outside the big range\r\n // If p came from some inner loop this will...\r\n // 1) create a bridge from the inner loop through any containing loops (always)\r\n // 2) avoid crossing any containing loop at a vertex. (with high probability, but not absolutely always)\r\n const bridgeLength = margin + Ray3d.create(p, RegionBooleanContext._bridgeDirection, ray).intersectionWithRange3d(rangeAB).high;\r\n const outside = Point3d.createAdd2Scaled(p, 1.0, RegionBooleanContext._bridgeDirection, bridgeLength);\r\n const bridgeLine = LineSegment3d.createXYXY(p.x, p.y, outside.x, outside.y);\r\n this.extraGeometry.addMember(bridgeLine, true);\r\n }\r\n }\r\n\r\n /**\r\n * Markup and assembly steps for geometry in the RegionGroups.\r\n * * Annotate connection from group to curves.\r\n * * groups with point data but no curves get no further annotation.\r\n * * compute intersections.\r\n * * assemble and merge the HalfEdgeGraph.\r\n */\r\n public annotateAndMergeCurvesInGraph() {\r\n const allPrimitives: CurvePrimitive[] = [];\r\n // ASSUME loops have fine-grained types -- no linestrings !!\r\n for (const group of [this.groupA, this.groupB, this.extraGeometry]) {\r\n for (const member of group.members) {\r\n let k = allPrimitives.length;\r\n if (member.region instanceof GeometryQuery) {\r\n RegionOps.collectCurvePrimitives(member.region, allPrimitives, true, true);\r\n for (; k < allPrimitives.length; k++)\r\n allPrimitives[k].parent = member;\r\n }\r\n }\r\n }\r\n // const range = RegionOps.curveArrayRange(allPrimitives);\r\n const intersections = CurveCurve.allIntersectionsAmongPrimitivesXY(allPrimitives);\r\n const graph = PlanarSubdivision.assembleHalfEdgeGraph(allPrimitives, intersections);\r\n this.graph = graph;\r\n this.faceAreaFunction = faceAreaFromCurvedEdgeData;\r\n }\r\n private _announceFaceFunction?: AnnounceClassifiedFace;\r\n /**\r\n * Sweep through the graph to assign in/out classifications to all faces.\r\n * * the classification is announced in two ways:\r\n * * the EXTERNAL mask is set on all half edges that are NOT interior faces.\r\n * * the announceFaceFunction is called once for each face.\r\n * @param binaryOp\r\n * @param announceFaceFunction\r\n */\r\n public runClassificationSweep(\r\n binaryOp: RegionBinaryOpType,\r\n announceFaceFunction?: AnnounceClassifiedFace) {\r\n this._announceFaceFunction = announceFaceFunction;\r\n this.binaryOp = binaryOp;\r\n this.graph.clearMask(HalfEdgeMask.EXTERIOR);\r\n for (const group of [this.groupA, this.groupB]) {\r\n group.clearState();\r\n }\r\n const faceHasBeenVisitedMask = this.graph.grabMask();\r\n const nodeHasBeenVisitedMask = this.graph.grabMask();\r\n const componentArray = GraphComponentArray.create(this.graph);\r\n for (const component of componentArray.components) {\r\n const exteriorHalfEdge = HalfEdgeGraphSearch.findMinimumAreaFace(component.faces, this.faceAreaFunction);\r\n if (exteriorHalfEdge) {\r\n const exteriorMask = HalfEdgeMask.EXTERIOR;\r\n const allMasksToClear = exteriorMask | faceHasBeenVisitedMask | nodeHasBeenVisitedMask;\r\n this.graph.clearMask(allMasksToClear);\r\n RegionOpsFaceToFaceSearch.faceToFaceSearchFromOuterLoop(this.graph, exteriorHalfEdge, faceHasBeenVisitedMask, nodeHasBeenVisitedMask, this);\r\n }\r\n }\r\n this.graph.dropMask(faceHasBeenVisitedMask);\r\n this.graph.dropMask(nodeHasBeenVisitedMask);\r\n }\r\n // search the graph for faces with\r\n // .. exactly 2 edges\r\n // .. both with given mask\r\n // .. at least one mate is not exterior.\r\n // .. clear that mark\r\n public unmaskMaskedNullFaces(mask: number) {\r\n for (const nodeA of this.graph.allHalfEdges) {\r\n const nodeB = nodeA.faceSuccessor;\r\n if (nodeB.faceSuccessor === nodeA) {\r\n if (nodeA.getMask(mask) && nodeB.getMask(mask)) {\r\n if (!nodeA.edgeMate.getMask(mask) || !nodeB.edgeMate.getMask(mask)) {\r\n nodeA.clearMask(mask);\r\n nodeB.clearMask(mask);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n private getInOut(): boolean {\r\n if (this.binaryOp === RegionBinaryOpType.Union)\r\n return this.groupA.getInOut() || this.groupB.getInOut();\r\n if (this.binaryOp === RegionBinaryOpType.Intersection)\r\n return this.groupA.getInOut() && this.groupB.getInOut();\r\n if (this.binaryOp === RegionBinaryOpType.AMinusB)\r\n return this.groupA.getInOut() && !this.groupB.getInOut();\r\n if (this.binaryOp === RegionBinaryOpType.BMinusA)\r\n return !this.groupA.getInOut() && this.groupB.getInOut();\r\n if (this.binaryOp === RegionBinaryOpType.Parity)\r\n return this.groupA.getInOut() !== this.groupB.getInOut();\r\n return false;\r\n }\r\n /**\r\n * Record transition across an edge as entry or exit from a RegionGroup.\r\n * * Work backward from the node to a RegionGroup. This path can be:\r\n * * If the node points to a CurveLocationDetail of a (possibly partial) curve, the path is (take a deep breath)\r\n * * node points to CurveLocation Detail\r\n * * CurveLocationDetail points to curve\r\n * * curve points to RegionGroupMember\r\n * * If the node points directly to a RegionGroup, it's ready to go!!!\r\n * @param node\r\n * @param delta\r\n */\r\n private recordTransitionAcrossEdge(node: HalfEdge, delta: number): RegionGroupMember | undefined {\r\n const updateRegionGroupMemberState = (member: RegionGroupMember): RegionGroupMember => {\r\n if (member.parentGroup.groupOpType === RegionGroupOpType.NonBounding)\r\n return member; // no transition across a bridge edge\r\n if (delta !== 0) {\r\n const oldSweepState = member.sweepState;\r\n member.sweepState += delta;\r\n member.parentGroup.recordMemberStateChange(oldSweepState, member.sweepState);\r\n }\r\n return member;\r\n };\r\n\r\n const data = node.edgeTag;\r\n if (data instanceof RegionGroupMember)\r\n return updateRegionGroupMemberState(data);\r\n\r\n if (data instanceof CurveLocationDetail) {\r\n // We trust that the caller has linked from the graph node to a curve which has a RegionGroupMember as its parent.\r\n const member = data.curve!.parent;\r\n if (member instanceof RegionGroupMember)\r\n return updateRegionGroupMemberState(member);\r\n }\r\n return undefined;\r\n }\r\n // obligations to act as sweep callback ...\r\n /** Announce a representative node on the outer face of a component */\r\n public startComponent(outerFaceNode: HalfEdge): boolean {\r\n outerFaceNode.setMaskAroundFace(HalfEdgeMask.EXTERIOR);\r\n if (this._announceFaceFunction)\r\n this._announceFaceFunction(this.graph, outerFaceNode, -1, faceAreaFromCurvedEdgeData(outerFaceNode));\r\n return true;\r\n }\r\n /** Announce return to outer face */\r\n public finishComponent(_node: HalfEdge): boolean {\r\n return true;\r\n }\r\n /** Announce entry to a graph face.\r\n * * Both both sides of a graph edge are from the same RegionGroupMember.\r\n * * Hence \"crossing that edge\" changes the parity count for the RegionGroupMember that owns that edge by 1.\r\n * * The parity count for other RegionGroupMembers are never affected by this crossing.\r\n * * Crossing a bridge edge does not change the parity count.\r\n */\r\n public enterFace(_facePathStack: HalfEdge[], newFaceNode: HalfEdge): boolean {\r\n this.recordTransitionAcrossEdge(newFaceNode, 1);\r\n const state = this.getInOut();\r\n if (!state)\r\n newFaceNode.setMaskAroundFace(HalfEdgeMask.EXTERIOR);\r\n if (this._announceFaceFunction)\r\n this._announceFaceFunction(this.graph, newFaceNode, state ? 1 : 0, faceAreaFromCurvedEdgeData(newFaceNode));\r\n return true;\r\n }\r\n /** Announce face exit */\r\n public leaveFace(_facePathStack: HalfEdge[], oldFaceNode: HalfEdge): boolean {\r\n this.recordTransitionAcrossEdge(oldFaceNode, -1);\r\n return true;\r\n }\r\n}\r\n/** return xy area between a (part of a) curve and the x axis through a reference point.\r\n * If detail is undefined or does not have both start and end fractions, just do trapezoid area\r\n */\r\nfunction areaUnderPartialCurveXY(detail: CurveLocationDetail | undefined, xyStart: XAndY, xyEnd: XAndY, referencePoint: XAndY): number {\r\n // area between trapezoid and axis\r\n let trapezoidArea;\r\n if (detail && detail.point1) {\r\n trapezoidArea = -(detail.point1.x - detail.point.x) * (0.5 * (detail.point.y + detail.point1.y) - referencePoint.y);\r\n } else {\r\n trapezoidArea = -(xyEnd.x - xyStart.x) * (0.5 * (xyStart.y + xyEnd.y) - referencePoint.y);\r\n }\r\n let areaToChord = 0.0;\r\n if (detail && detail.curve && detail.hasFraction1) {\r\n\r\n if (detail.curve instanceof LineSegment3d) {\r\n // ah .. nothing to do for a line segment\r\n } else if (detail.curve instanceof Arc3d) {\r\n areaToChord = detail.curve.areaToChordXY(detail.fraction, detail.fraction1!);\r\n }\r\n }\r\n return trapezoidArea + areaToChord;\r\n}\r\n/** Compute face area for a face whose edges are decorated with CurveLocationDetail for their (partial) curves */\r\nfunction faceAreaFromCurvedEdgeData(faceSeed: HalfEdge): number {\r\n let area = 0.0;\r\n let edge = faceSeed;\r\n do {\r\n area += (edge.sortData as number) * areaUnderPartialCurveXY((edge.edgeTag as CurveLocationDetail), edge, edge.faceSuccessor, faceSeed);\r\n } while ((edge = edge.faceSuccessor) !== faceSeed);\r\n return area;\r\n}\r\n\r\n/**\r\n * Function to accumulate area under edges\r\n * Array of nodes representing faces in a subset of a graph.\r\n * @internal\r\n */\r\nexport type NodeAndRangeFunction = (edge: HalfEdge, range: Range2d) => void;\r\n/**\r\n * Array of nodes representing faces in a subset of a graph.\r\n * @internal\r\n */\r\nexport class GraphComponent {\r\n public faces: HalfEdge[];\r\n public faceAreas: number[];\r\n public range: Range2d;\r\n public constructor(faces: HalfEdge[]) {\r\n this.faces = faces;\r\n this.range = Range2d.createNull();\r\n this.faceAreas = [];\r\n }\r\n /**\r\n * visit all vertices and edges in the component to build face area array and composite range.\r\n *\r\n * @param extendRangeForEdge optional function to compute edge range. If undefined, linear edge is assumed.\r\n * @param faceAreaFunction optional function to compute face area. If undefined, linear edges are assumed.\r\n */\r\n public buildFaceData(extendRangeForEdge: NodeAndRangeFunction | undefined, faceAreaFunction: NodeToNumberFunction | undefined) {\r\n const vertexFunction = (node: HalfEdge) => {\r\n if (extendRangeForEdge)\r\n extendRangeForEdge(node, this.range);\r\n else\r\n this.range.extendXY(node.x, node.y);\r\n return 0;\r\n };\r\n this.range.setNull();\r\n for (const f of this.faces) {\r\n f.sumAroundFace(vertexFunction);\r\n }\r\n this.faceAreas.length = 0;\r\n if (!faceAreaFunction)\r\n faceAreaFunction = HalfEdgeGraphSearch.signedFaceArea;\r\n for (const f of this.faces) {\r\n this.faceAreas.push(faceAreaFunction(f));\r\n }\r\n }\r\n}\r\n/** build and hold an array of component data for a HalfEdgeGraph.\r\n * @internal\r\n */\r\nexport class GraphComponentArray {\r\n public components: GraphComponent[];\r\n public graph: HalfEdgeGraph;\r\n private constructor(graph: HalfEdgeGraph) {\r\n this.graph = graph;\r\n this.components = [];\r\n }\r\n public static create(graph: HalfEdgeGraph, extendRangeForEdge?: (edge: HalfEdge, range: Range2d) => void): GraphComponentArray {\r\n const result = new GraphComponentArray(graph);\r\n const componentArrays = HalfEdgeGraphSearch.collectConnectedComponentsWithExteriorParityMasks(graph, undefined);\r\n for (const componentFaces of componentArrays) {\r\n const component = new GraphComponent(componentFaces);\r\n component.buildFaceData(extendRangeForEdge, faceAreaFromCurvedEdgeData);\r\n result.components.push(component);\r\n }\r\n return result;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RegionOpsClassificationSweeps.js","sourceRoot":"","sources":["../../../src/curve/RegionOpsClassificationSweeps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,6CAAgG;AAChG,yEAAsE;AACtE,iDAAyD;AACzD,+DAAmE;AAEnE,2CAAqF;AACrF,iDAA8C;AAC9C,iCAA8B;AAE9B,6CAA0C;AAC1C,iEAA8D;AAC9D,0CAAuC;AAEvC,+CAA4C;AAC5C,+DAA4D;AAE5D,mDAAgD;AAChD,mCAAgC;AAChC,+CAAuD;AACvD,mEAAkE;AAClE,4FAAyF;AACzF,mDAAgD;AAChD,+CAA4C;AAE5C;;;;;;;;;;;;;;GAcG;AACH,MAAe,kCAAkC;IAC/C,sEAAsE;IAC/D,cAAc,CAAC,KAAe,IAAa,OAAO,IAAI,CAAC,CAAC,CAAC;IAChE,oCAAoC;IAC7B,eAAe,CAAC,KAAe,IAAa,OAAO,IAAI,CAAC,CAAC,CAAC;IACjE,0BAA0B;IACnB,SAAS,CA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C;SAC1C;IACH,CAAC;CACF;AAlCD,wCAkCC;AACD;;GAEG;AACH,MAAa,mBAAmB;IAG9B,YAAoB,KAAoB;QACtC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;IACM,MAAM,CAAC,MAAM,CAAC,KAAoB,EAAE,kBAA6D;QACtG,MAAM,MAAM,GAAG,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC9C,MAAM,eAAe,GAAG,yCAAmB,CAAC,iDAAiD,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAChH,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE;YAC5C,MAAM,SAAS,GAAG,IAAI,cAAc,CAAC,cAAc,CAAC,CAAC;YACrD,SAAS,CAAC,aAAa,CAAC,kBAAkB,EAAE,0BAA0B,CAAC,CAAC;YACxE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACnC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAjBD,kDAiBC","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 Curve\r\n */\r\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask, NodeToNumberFunction } from \"../topology/Graph\";\r\nimport { HalfEdgeGraphSearch } from \"../topology/HalfEdgeGraphSearch\";\r\nimport { HalfEdgeGraphMerge } from \"../topology/Merging\";\r\nimport { RegularizationContext } from \"../topology/RegularizeFace\";\r\nimport { MultiLineStringDataVariant } from \"../topology/Triangulation\";\r\nimport { GraphCheckPointFunction, RegionBinaryOpType, RegionOps } from \"./RegionOps\";\r\nimport { ParityRegion } from \"./ParityRegion\";\r\nimport { Loop } from \"./Loop\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { CurveCurve } from \"./CurveCurve\";\r\nimport { PlanarSubdivision } from \"./Query/PlanarSubdivision\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { AnyRegion } from \"./CurveChain\";\r\nimport { UnionRegion } from \"./UnionRegion\";\r\nimport { CurveLocationDetail } from \"./CurveLocationDetail\";\r\nimport { XAndY } from \"../geometry3d/XYZProps\";\r\nimport { LineSegment3d } from \"./LineSegment3d\";\r\nimport { Arc3d } from \"./Arc3d\";\r\nimport { Range2d, Range3d } from \"../geometry3d/Range\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { PlaneAltitudeRangeContext } from \"./internalContexts/PlaneAltitudeRangeContext\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\n\r\n/**\r\n * base class for callbacks during region sweeps.\r\n * * At start of a component, `startComponent(node)` is called announcing a representative node on the outermost face.\r\n * * A Component in this usage is a component that is edge connected when ignoring \"exterior bridge edges\".\r\n * * As each face is entered, `enterFace(facePathStack, newFaceNode)` is called\r\n * * facePathStack[0] is the outermost node of the path from the outer face.\r\n * * facePathStack[1] is its inside mate.\r\n * * facePathStack[2k] is the outside node at crossing to face at depth k.\r\n * * facePathStack[2k+1] is the node where face at depth k was entered.\r\n * * newFaceNode is the entry node (redundant of stack tip)\r\n * * On retreat from a face, `leaveFace(facePathStack, faceNode)` is called.\r\n * * At end of component, `finishComponent (node)` is called.\r\n * * The base class is fully implemented to do nothing during the sweep.\r\n * @internal\r\n */\r\nabstract class RegionOpsFaceToFaceSearchCallbacks {\r\n /** Announce a representative node on the outer face of a component */\r\n public startComponent(_node: HalfEdge): boolean { return true; }\r\n /** Announce return to outer face */\r\n public finishComponent(_node: HalfEdge): boolean { return true; }\r\n /** Announce face entry */\r\n public enterFace(_facePathStack: HalfEdge[], _newFaceNode: HalfEdge): boolean { return true; }\r\n /** Announce face exit */\r\n public leaveFace(_facePathStack: HalfEdge[], _newFaceNode: HalfEdge): boolean { return true; }\r\n}\r\n/** Function signature to test if a pair of boolean states is to be accepted by area booleans (during face-to-face sweeps)\r\n * @internal\r\n */\r\ntype BinaryBooleanAcceptFunction = (stateA: boolean, stateB: boolean) => boolean;\r\n/** Function signature ot announce classification of a face.\r\n * The `faceType` parameters are\r\n * * -1 for a fully exterior face. This is a negative area face.\r\n * * 0 for a positive area face classified as \"out\" for the boolean.\r\n * * 1 for a positive area face classified as \"in\" for the boolean.\r\n */\r\ntype AnnounceClassifiedFace = (graph: HalfEdgeGraph, faceSeed: HalfEdge, faceType: -1 | 0 | 1, area: number) => void;\r\n/**\r\n * Implementation of `RegionOpsFaceToFaceSearchCallbacks` for binary boolean sweep with polygonal regions.\r\n * * For this linear-boundary case the boundary geometry is carried entirely from the coordinates in the half edges.\r\n * * This assumes the each node in the graph has edgeTag set to:\r\n * * `edgeTag === undefined` if the edge crossing does not change classification.\r\n * * for example, an edge added by regularization\r\n * * `edgeTag === 1` if this is a boundary for the first of the boolean input regions\r\n * * `edgeTag === 2` if this is a boundary for the second of the boolean input regions\r\n * * constructor\r\n * * takes caller-supplied function to decide whether to accept a face given its state relative to the two boolean terms.\r\n * * sets the in/out status of both terms to false.\r\n * * `startComponent` marks the entire outer face as `EXTERIOR`\r\n * * `enterFace`\r\n * * if this is a bounding edge (according to `node.faceTag`) toggle the in/out status if this boolean term.\r\n * * ask the faceAcceptFunction if the current term states combine to in/out for the result\r\n * * if out, set the `EXTERIOR` mask around the face.\r\n * * `leaveFace`\r\n * * if this is a bounding edge (according to `node.faceTag`) toggle the in/out status if this boolean term.\r\n * * `finishComponent` is not reimplemented.\r\n * @internal\r\n */\r\nclass RegionOpsBinaryBooleanSweepCallbacks extends RegionOpsFaceToFaceSearchCallbacks {\r\n private _faceSelectFunction: BinaryBooleanAcceptFunction;\r\n private _inComponent: boolean[];\r\n private _exteriorMask: HalfEdgeMask;\r\n public constructor(acceptFaceFunction: BinaryBooleanAcceptFunction, exteriorMask: HalfEdgeMask) {\r\n super();\r\n this._inComponent = [false, false, false]; // entry 0 is never reused.\r\n this._exteriorMask = exteriorMask;\r\n this._faceSelectFunction = acceptFaceFunction;\r\n }\r\n /** Mark this face as exterior */\r\n public override startComponent(node: HalfEdge): boolean { node.setMaskAroundFace(this._exteriorMask); return true; }\r\n /**\r\n * * If necessary, toggle a term state.\r\n * * if indicated, mark this face exterior.\r\n */\r\n public override enterFace(_facePathStack: HalfEdge[], node: HalfEdge): boolean {\r\n const thisFaceIndex = node.edgeTag;\r\n if (node.edgeTag === 1 || node.edgeTag === 2)\r\n this._inComponent[thisFaceIndex] = !this._inComponent[thisFaceIndex];\r\n if (!this._faceSelectFunction(this._inComponent[1], this._inComponent[2]))\r\n node.setMaskAroundFace(this._exteriorMask);\r\n return true;\r\n }\r\n /**\r\n * * If necessary, toggle a term state.\r\n */\r\n public override leaveFace(_facePathStack: HalfEdge[], node: HalfEdge): boolean {\r\n const thisFaceIndex = node.edgeTag;\r\n if (node.edgeTag === 1 || node.edgeTag === 2)\r\n this._inComponent[thisFaceIndex] = !this._inComponent[thisFaceIndex];\r\n return true;\r\n }\r\n}\r\n/**\r\n * Low level graph search for face classification.\r\n * @internal\r\n */\r\nexport class RegionOpsFaceToFaceSearch {\r\n /**\r\n * run a DFS with face-to-face step announcements.\r\n * * false return from any function terminates search immediately.\r\n * * all reachable nodes assumed to have both visit masks clear.\r\n * @param graph containing graph.\r\n * @param seed first node to visit.\r\n * @param faceHasBeenVisited mask marking faces that have been seen.\r\n * @param nodeHasBeenVisited mask marking node-to-node step around face.\r\n *\r\n */\r\n public static faceToFaceSearchFromOuterLoop(_graph: HalfEdgeGraph, seed: HalfEdge, faceHasBeenVisited: HalfEdgeMask, nodeHasBeenVisited: HalfEdgeMask, callbacks: RegionOpsFaceToFaceSearchCallbacks) {\r\n if (seed.isMaskSet(faceHasBeenVisited))\r\n return;\r\n if (!callbacks.startComponent(seed))\r\n return;\r\n const facePathStack = [];\r\n seed.setMaskAroundFace(faceHasBeenVisited);\r\n let faceWalker = seed;\r\n do {\r\n let entryNode = faceWalker;\r\n let mate = faceWalker.edgeMate;\r\n if (!mate.isMaskSet(faceHasBeenVisited)) {\r\n // the faceWalker seed is always on the base of the stack.\r\n // the stack then contains even-odd pairs of (entryNode, currentNode)\r\n // * entryNode is the node where a face was entered.\r\n // * faceNode is another node around that face.\r\n facePathStack.push(faceWalker);\r\n facePathStack.push(mate);\r\n let faceNode = mate.faceSuccessor;\r\n mate.setMaskAroundFace(faceHasBeenVisited);\r\n entryNode = mate;\r\n if (callbacks.enterFace(facePathStack, mate)) {\r\n for (; ;) {\r\n mate = faceNode.edgeMate;\r\n if (!mate.isMaskSet(faceHasBeenVisited)) {\r\n mate.setMaskAroundFace(faceHasBeenVisited);\r\n if (!callbacks.enterFace(facePathStack, mate))\r\n return;\r\n facePathStack.push(faceNode);\r\n facePathStack.push(mate);\r\n faceNode = mate;\r\n entryNode = mate;\r\n }\r\n faceNode.setMask(nodeHasBeenVisited);\r\n faceNode = faceNode.faceSuccessor;\r\n if (faceNode === entryNode) {\r\n callbacks.leaveFace(facePathStack, faceNode);\r\n if (facePathStack.length <= 2) {\r\n break;\r\n }\r\n facePathStack.pop();\r\n faceNode = facePathStack[facePathStack.length - 1];\r\n facePathStack.pop();\r\n entryNode = facePathStack[facePathStack.length - 1];\r\n }\r\n if (faceNode.isMaskSet(nodeHasBeenVisited)) {\r\n // this is disaster !!!\r\n return;\r\n }\r\n }\r\n }\r\n }\r\n // continue at outermost level .....\r\n faceWalker = faceWalker.faceSuccessor;\r\n } while (faceWalker !== seed);\r\n callbacks.finishComponent(seed);\r\n }\r\n /** Complete multi-step process for polygon binary booleans starting with arrays of coordinates.\r\n * * Each of the binary input terms is a collection of loops\r\n * * Within the binary term, in/out is determined by edge-crossing parity rules.\r\n * * Processing steps are\r\n * * Build the loops for each set.\r\n * * Each edge labeled with 1 or 2 as binary term identifier.\r\n * * find crossings among the edges.\r\n * * Edges are split as needed, but split preserves the edgeTag\r\n * * sort edges around vertices\r\n * * add regularization edges so holes are connected to their parent.\r\n */\r\n public static doPolygonBoolean(loopsA: MultiLineStringDataVariant, loopsB: MultiLineStringDataVariant, faceSelectFunction: (inA: boolean, inB: boolean) => boolean, graphCheckPoint?: GraphCheckPointFunction): HalfEdgeGraph | undefined {\r\n const graph = new HalfEdgeGraph();\r\n const baseMask = HalfEdgeMask.BOUNDARY_EDGE | HalfEdgeMask.PRIMARY_EDGE;\r\n const seedA = RegionOps.addLoopsWithEdgeTagToGraph(graph, loopsA, baseMask, 1);\r\n const seedB = RegionOps.addLoopsWithEdgeTagToGraph(graph, loopsB, baseMask, 2);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"unmerged loops\", graph, \"U\");\r\n if (seedA || seedB) {\r\n // split edges where they cross . . .\r\n HalfEdgeGraphMerge.splitIntersectingEdges(graph);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"After splitIntersectingEdges\", graph, \"S\");\r\n // sort radially around vertices.\r\n HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"After clusterAndMergeXYTheta\", graph, \"M\");\r\n // add edges to connect various components (e.g. holes!!!)\r\n const context = new RegularizationContext(graph);\r\n context.regularizeGraph(true, true);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"After regularize\", graph, \"MR\");\r\n const exteriorHalfEdge = HalfEdgeGraphSearch.findMinimumAreaFace(graph);\r\n const exteriorMask = HalfEdgeMask.EXTERIOR;\r\n const faceVisitedMask = graph.grabMask();\r\n const nodeVisitedMask = graph.grabMask();\r\n const allMasksToClear = exteriorMask | faceVisitedMask | nodeVisitedMask;\r\n graph.clearMask(allMasksToClear);\r\n const callbacks = new RegionOpsBinaryBooleanSweepCallbacks(faceSelectFunction, exteriorMask);\r\n this.faceToFaceSearchFromOuterLoop(graph, exteriorHalfEdge, faceVisitedMask, nodeVisitedMask, callbacks);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"After faceToFaceSearchFromOuterLoop\", graph, \"MRX\");\r\n graph.dropMask(faceVisitedMask);\r\n graph.dropMask(nodeVisitedMask);\r\n return graph;\r\n }\r\n return undefined;\r\n }\r\n\r\n /** Complete multi-step process for polygon binary booleans starting with arrays of coordinates.\r\n * * the manyLoopsAndParitySets input is an array.\r\n * * Each entry is one or more loops.\r\n * * An entry that is \"just points\" is a simple loop.\r\n * * An entry that is itself an array of arrays of points is a set of loops with \"parity\" -- relation:\r\n * * typically the first is an outer loop an others are holes.\r\n * * but if there is self intersection or multiple outer loops, parity rules are applied to decide inner and outer.\r\n * * Processing steps are\r\n * * Build the loops for each set.\r\n * * Each edge labeled with index to the outer array.\r\n * * find crossings among the edges.\r\n * * Edges are split as needed, but split preserves the edgeTag\r\n * * sort edges around vertices\r\n * * add regularization edges so holes are connected to their parent.\r\n * * assign inside/outside by parity within each set and overall union.\r\n */\r\n public static doBinaryBooleanBetweenMultiLoopInputs(\r\n dataA: MultiLineStringDataVariant[],\r\n opA: RegionGroupOpType,\r\n binaryOp: RegionBinaryOpType,\r\n dataB: MultiLineStringDataVariant[],\r\n opB: RegionGroupOpType,\r\n purgeSliverExteriorFaces: boolean\r\n ): HalfEdgeGraph | undefined {\r\n const graph = new HalfEdgeGraph();\r\n const baseMask = HalfEdgeMask.BOUNDARY_EDGE | HalfEdgeMask.PRIMARY_EDGE;\r\n const callbacks = RegionBooleanContext.create(opA, opB);\r\n callbacks.graph = graph;\r\n callbacks.faceAreaFunction = HalfEdgeGraphSearch.signedFaceArea;\r\n\r\n // Add all the members in groupA ..\r\n for (const data of dataA) {\r\n if (data.length > 2){\r\n const member = new RegionGroupMember(data, callbacks.groupA);\r\n RegionOps.addLoopsWithEdgeTagToGraph(graph, data, baseMask, member);\r\n }\r\n }\r\n for (const data of dataB) {\r\n if (data.length > 2){\r\n const member = new RegionGroupMember(data, callbacks.groupB);\r\n RegionOps.addLoopsWithEdgeTagToGraph(graph, data, baseMask, member);\r\n }\r\n }\r\n // split edges where they cross . . .\r\n HalfEdgeGraphMerge.splitIntersectingEdges(graph);\r\n // sort radially around vertices.\r\n HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph);\r\n // add edges to connect various components (e.g. holes!!!)\r\n const context = new RegularizationContext(graph);\r\n context.regularizeGraph(true, true);\r\n callbacks.runClassificationSweep(binaryOp);\r\n if (purgeSliverExteriorFaces)\r\n callbacks.unmaskMaskedNullFaces(HalfEdgeMask.EXTERIOR);\r\n return graph;\r\n }\r\n}\r\n\r\n/**\r\n * Enumeration of operation types \"within a group operand\" for a `RegionBooleanContext`.\r\n * @internal\r\n */\r\nexport enum RegionGroupOpType {\r\n Union = 0,\r\n Parity = 1,\r\n Intersection = 2,\r\n NonBounding = -1,\r\n}\r\n/**\r\n * Each loop or parity region in a `RegionBooleanContext` is recorded as a `RegionGroupMember`, which carries\r\n * * the Loop or parityRegion object\r\n * * a numeric indication of the sweep state (parity) during the classification search.\r\n * * a reference to the parent group (which in turn leads back to the `RegionBooleanContext`)\r\n * @internal\r\n */\r\nclass RegionGroupMember {\r\n public region: Loop | ParityRegion | CurvePrimitive | MultiLineStringDataVariant;\r\n public sweepState: number;\r\n public parentGroup: RegionGroup;\r\n public constructor(region: Loop | ParityRegion | CurvePrimitive | MultiLineStringDataVariant, parentGroup: RegionGroup) {\r\n this.region = region;\r\n this.parentGroup = parentGroup;\r\n this.sweepState = 0;\r\n }\r\n public clearState() { this.sweepState = 0; }\r\n}\r\n/**\r\n * A `RegionGroup` is\r\n * * An array of `RegionGroupMembers`, carrying the regions of the Ai or Bi part of the boolean expression.\r\n * * The `RegionGroupOpType` to be applied among those members.\r\n * * Pointer to the containing context\r\n * * The count of number of regions known to be \"in\" as the search progresses.\r\n * @internal\r\n */\r\nexport class RegionGroup {\r\n public members: RegionGroupMember[];\r\n public groupOpType: RegionGroupOpType;\r\n public parent: RegionBooleanContext;\r\n private _numIn: number;\r\n public constructor(parent: RegionBooleanContext, groupOpType: RegionGroupOpType) {\r\n this.members = [];\r\n this.parent = parent;\r\n this.groupOpType = groupOpType;\r\n this._numIn = 0;\r\n }\r\n /** deep clear of state data -- group header plus all members */\r\n public clearState() {\r\n for (const member of this.members)\r\n member.clearState();\r\n this._numIn = 0;\r\n }\r\n public range(): Range3d {\r\n const range = Range3d.createNull();\r\n for (const m of this.members) {\r\n if (m.region instanceof GeometryQuery)\r\n m.region.extendRange(range);\r\n else {\r\n const range1 = Range3d.createFromVariantData(m.region);\r\n range.extendRange(range1);\r\n }\r\n }\r\n return range;\r\n }\r\n /** Ask if the current _numIn count qualifies as an \"in\" for this operation type.\r\n */\r\n public getInOut(): boolean {\r\n // UNION is true if one or more members are IN\r\n if (this.groupOpType === RegionGroupOpType.Union)\r\n return this._numIn > 0;\r\n // PARITY is true if an odd number of regions are IN\r\n if (this.groupOpType === RegionGroupOpType.Parity)\r\n return Geometry.isOdd(this._numIn);\r\n // INTERSECTION is true if ALL the regions are IN\r\n if (this.groupOpType === RegionGroupOpType.Intersection)\r\n return this._numIn === this.members.length;\r\n return false;\r\n }\r\n // push new members into the group.\r\n public addMember(data: AnyRegion | AnyRegion[] | LineSegment3d | undefined, allowLineSegment: boolean = false) {\r\n if (data instanceof Loop || data instanceof ParityRegion) {\r\n const cleanerData = data.clone() as (ParityRegion | Loop);\r\n RegionOps.consolidateAdjacentPrimitives(cleanerData);\r\n this.members.push(new RegionGroupMember(cleanerData, this));\r\n } else if (data instanceof UnionRegion) {\r\n for (const child of data.children) {\r\n this.addMember(child);\r\n }\r\n } else if (Array.isArray(data)) {\r\n for (const item of data) {\r\n this.addMember(item);\r\n }\r\n } else if (allowLineSegment && data instanceof LineSegment3d) {\r\n this.members.push(new RegionGroupMember(data, this));\r\n\r\n }\r\n }\r\n // update the \"in\" count _numIn according to old and new states (parity counts) for some member region.\r\n public recordMemberStateChange(oldState: number, newState: number) {\r\n const oldIn = Geometry.isOdd(oldState);\r\n const newIn = Geometry.isOdd(newState);\r\n if (!oldIn && newIn)\r\n this._numIn++;\r\n else if (oldIn && !newIn)\r\n this._numIn--;\r\n }\r\n}\r\n/**\r\n * A `RegionBooleanContext` carries structure and operations for binary operations between two sets of regions.\r\n * * In the binary operation OP (union, intersection, parity, difference), the left and right operands\r\n * are each a composite union, difference, or parity among multiple inputs, i.e.\r\n * * (operationA among Ai) OP (operationB among Bi)\r\n * * where the Ai are one set of regions, being combined by operationA\r\n * * and the Bi are the another set of regions, being combined by operationB\r\n * * Each group of Ai and Bi is a `RegionGroup`\r\n * * This is an extremely delicate structure.\r\n * * Members are public because of the unique variety of queries, but should only be used for queries.\r\n * * The graph and curves in the booleans are connected by an extended pointer chain:\r\n * * (HalfEdge in Graph).edgeTag points to a CurveLocationDetail\r\n * * (CurveLocationDetail).curve points to a curve\r\n * * (Curve).parent points to RegionGroupMember\r\n * * (RegionGroupMember) points to RegionGroup\r\n * * (RegionGroup) points to RegionBooleanBinaryContext\r\n * * So..when a graph sweep crosses an edge,\r\n * * the chain leads to a parity count in the RegionGroupMember\r\n * * that can change the number of members active in the RegionGroup\r\n * * which can change the state of the context.\r\n * @internal\r\n */\r\nexport class RegionBooleanContext implements RegionOpsFaceToFaceSearchCallbacks {\r\n public groupA!: RegionGroup;\r\n public groupB!: RegionGroup;\r\n public extraGeometry!: RegionGroup;\r\n public graph!: HalfEdgeGraph;\r\n public faceAreaFunction!: NodeToNumberFunction;\r\n public binaryOp: RegionBinaryOpType;\r\n\r\n private constructor(groupTypeA: RegionGroupOpType, groupTypeB: RegionGroupOpType) {\r\n this.groupA = new RegionGroup(this, groupTypeA);\r\n this.groupB = new RegionGroup(this, groupTypeB);\r\n this.extraGeometry = new RegionGroup(this, RegionGroupOpType.NonBounding);\r\n this.binaryOp = RegionBinaryOpType.Union; // it will be revised on can calls.\r\n }\r\n /**\r\n * Create a context with both A and B groups empty.\r\n * * Caller follows up by calls to `context.groupA.addMember (loopOrParityRegion)` or `context.groupB.addMember (loopOrParityRegion)`\r\n * @param groupTypeA\r\n * @param groupTypeB\r\n */\r\n public static create(groupTypeA: RegionGroupOpType, groupTypeB: RegionGroupOpType): RegionBooleanContext {\r\n return new RegionBooleanContext(groupTypeA, groupTypeB);\r\n }\r\n public addMembers(dataA: AnyRegion | AnyRegion[] | undefined, dataB: AnyRegion | AnyRegion[] | undefined) {\r\n this.groupA.addMember(dataA);\r\n this.groupB.addMember(dataB);\r\n // const doConnectives = 1;\r\n // if (doConnectives !== 0)\r\n this.addConnectives();\r\n }\r\n\r\n private _workSegment?: LineSegment3d;\r\n private static _bridgeDirection = Vector3d.createNormalized(1.0, -0.12328974132467)!; // magic unit direction to minimize vertex hits\r\n /**\r\n * The sweep operations require access to all geometry by edge crossings and face walk.\r\n * If input loops are non-overlapping, there may be disconnected islands not reachable.\r\n * This method:\r\n * * finds the total range\r\n * * creates parallel rays from the extreme point of each loop and extending beyond the overall range\r\n * * places those lines in the extraGeometry group\r\n */\r\n public addConnectives() {\r\n const rangeA = this.groupA.range();\r\n const rangeB = this.groupB.range();\r\n const rangeAB = rangeA.union(rangeB);\r\n const areaTol = RegionOps.computeXYAreaTolerance(rangeAB);\r\n let margin = 0.1;\r\n this._workSegment = PlaneAltitudeRangeContext.findExtremePointsInDirection(rangeAB.corners(), RegionBooleanContext._bridgeDirection, this._workSegment);\r\n if (this._workSegment)\r\n margin *= this._workSegment.point0Ref.distanceXY(this._workSegment.point1Ref); // how much further to extend each bridge ray\r\n\r\n const maxPoints: Point3d[] = [];\r\n const findExtremePointsInLoop = (region: Loop) => {\r\n const area = RegionOps.computeXYArea(region);\r\n if (area === undefined || Math.abs(area) < areaTol)\r\n return; // avoid bridging trivial faces\r\n this._workSegment = PlaneAltitudeRangeContext.findExtremePointsInDirection(region, RegionBooleanContext._bridgeDirection, this._workSegment);\r\n if (this._workSegment)\r\n maxPoints.push(this._workSegment.point1Ref);\r\n };\r\n\r\n for (const groupMembers of [this.groupA.members, this.groupB.members]) {\r\n for (const m of groupMembers) {\r\n if (m.region instanceof Loop) {\r\n findExtremePointsInLoop(m.region);\r\n } else if (m.region instanceof ParityRegion) {\r\n for (const loop of m.region.children)\r\n findExtremePointsInLoop(loop);\r\n }\r\n }\r\n }\r\n\r\n const ray = Ray3d.createZero();\r\n for (const p of maxPoints) {\r\n // Make a line from...\r\n // 1) exactly the max point of the loops to\r\n // 2) a point clearly outside the big range\r\n // If p came from some inner loop this will...\r\n // 1) create a bridge from the inner loop through any containing loops (always)\r\n // 2) avoid crossing any containing loop at a vertex. (with high probability, but not absolutely always)\r\n const bridgeLength = margin + Ray3d.create(p, RegionBooleanContext._bridgeDirection, ray).intersectionWithRange3d(rangeAB).high;\r\n const outside = Point3d.createAdd2Scaled(p, 1.0, RegionBooleanContext._bridgeDirection, bridgeLength);\r\n const bridgeLine = LineSegment3d.createXYXY(p.x, p.y, outside.x, outside.y);\r\n this.extraGeometry.addMember(bridgeLine, true);\r\n }\r\n }\r\n\r\n /**\r\n * Markup and assembly steps for geometry in the RegionGroups.\r\n * * Annotate connection from group to curves.\r\n * * groups with point data but no curves get no further annotation.\r\n * * compute intersections.\r\n * * assemble and merge the HalfEdgeGraph.\r\n * @param mergeTolerance absolute distance tolerance for merging loops\r\n */\r\n public annotateAndMergeCurvesInGraph(mergeTolerance: number = Geometry.smallMetricDistance) {\r\n const allPrimitives: CurvePrimitive[] = [];\r\n // ASSUME loops have fine-grained types -- no linestrings !!\r\n for (const group of [this.groupA, this.groupB, this.extraGeometry]) {\r\n for (const member of group.members) {\r\n let k = allPrimitives.length;\r\n if (member.region instanceof GeometryQuery) {\r\n RegionOps.collectCurvePrimitives(member.region, allPrimitives, true, true);\r\n for (; k < allPrimitives.length; k++)\r\n allPrimitives[k].parent = member;\r\n }\r\n }\r\n }\r\n // const range = RegionOps.curveArrayRange(allPrimitives);\r\n const intersections = CurveCurve.allIntersectionsAmongPrimitivesXY(allPrimitives, mergeTolerance);\r\n const graph = PlanarSubdivision.assembleHalfEdgeGraph(allPrimitives, intersections);\r\n this.graph = graph;\r\n this.faceAreaFunction = faceAreaFromCurvedEdgeData;\r\n }\r\n private _announceFaceFunction?: AnnounceClassifiedFace;\r\n /**\r\n * Sweep through the graph to assign in/out classifications to all faces.\r\n * * the classification is announced in two ways:\r\n * * the EXTERNAL mask is set on all half edges that are NOT interior faces.\r\n * * the announceFaceFunction is called once for each face.\r\n * @param binaryOp\r\n * @param announceFaceFunction\r\n */\r\n public runClassificationSweep(\r\n binaryOp: RegionBinaryOpType,\r\n announceFaceFunction?: AnnounceClassifiedFace) {\r\n this._announceFaceFunction = announceFaceFunction;\r\n this.binaryOp = binaryOp;\r\n this.graph.clearMask(HalfEdgeMask.EXTERIOR);\r\n for (const group of [this.groupA, this.groupB]) {\r\n group.clearState();\r\n }\r\n const faceHasBeenVisitedMask = this.graph.grabMask();\r\n const nodeHasBeenVisitedMask = this.graph.grabMask();\r\n const componentArray = GraphComponentArray.create(this.graph);\r\n for (const component of componentArray.components) {\r\n const exteriorHalfEdge = HalfEdgeGraphSearch.findMinimumAreaFace(component.faces, this.faceAreaFunction);\r\n if (exteriorHalfEdge) {\r\n const exteriorMask = HalfEdgeMask.EXTERIOR;\r\n const allMasksToClear = exteriorMask | faceHasBeenVisitedMask | nodeHasBeenVisitedMask;\r\n this.graph.clearMask(allMasksToClear);\r\n RegionOpsFaceToFaceSearch.faceToFaceSearchFromOuterLoop(this.graph, exteriorHalfEdge, faceHasBeenVisitedMask, nodeHasBeenVisitedMask, this);\r\n }\r\n }\r\n this.graph.dropMask(faceHasBeenVisitedMask);\r\n this.graph.dropMask(nodeHasBeenVisitedMask);\r\n }\r\n // search the graph for faces with\r\n // .. exactly 2 edges\r\n // .. both with given mask\r\n // .. at least one mate is not exterior.\r\n // .. clear that mark\r\n public unmaskMaskedNullFaces(mask: number) {\r\n for (const nodeA of this.graph.allHalfEdges) {\r\n const nodeB = nodeA.faceSuccessor;\r\n if (nodeB.faceSuccessor === nodeA) {\r\n if (nodeA.getMask(mask) && nodeB.getMask(mask)) {\r\n if (!nodeA.edgeMate.getMask(mask) || !nodeB.edgeMate.getMask(mask)) {\r\n nodeA.clearMask(mask);\r\n nodeB.clearMask(mask);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n private getInOut(): boolean {\r\n if (this.binaryOp === RegionBinaryOpType.Union)\r\n return this.groupA.getInOut() || this.groupB.getInOut();\r\n if (this.binaryOp === RegionBinaryOpType.Intersection)\r\n return this.groupA.getInOut() && this.groupB.getInOut();\r\n if (this.binaryOp === RegionBinaryOpType.AMinusB)\r\n return this.groupA.getInOut() && !this.groupB.getInOut();\r\n if (this.binaryOp === RegionBinaryOpType.BMinusA)\r\n return !this.groupA.getInOut() && this.groupB.getInOut();\r\n if (this.binaryOp === RegionBinaryOpType.Parity)\r\n return this.groupA.getInOut() !== this.groupB.getInOut();\r\n return false;\r\n }\r\n /**\r\n * Record transition across an edge as entry or exit from a RegionGroup.\r\n * * Work backward from the node to a RegionGroup. This path can be:\r\n * * If the node points to a CurveLocationDetail of a (possibly partial) curve, the path is (take a deep breath)\r\n * * node points to CurveLocation Detail\r\n * * CurveLocationDetail points to curve\r\n * * curve points to RegionGroupMember\r\n * * If the node points directly to a RegionGroup, it's ready to go!!!\r\n * @param node\r\n * @param delta\r\n */\r\n private recordTransitionAcrossEdge(node: HalfEdge, delta: number): RegionGroupMember | undefined {\r\n const updateRegionGroupMemberState = (member: RegionGroupMember): RegionGroupMember => {\r\n if (member.parentGroup.groupOpType === RegionGroupOpType.NonBounding)\r\n return member; // no transition across a bridge edge\r\n if (delta !== 0) {\r\n const oldSweepState = member.sweepState;\r\n member.sweepState += delta;\r\n member.parentGroup.recordMemberStateChange(oldSweepState, member.sweepState);\r\n }\r\n return member;\r\n };\r\n\r\n const data = node.edgeTag;\r\n if (data instanceof RegionGroupMember)\r\n return updateRegionGroupMemberState(data);\r\n\r\n if (data instanceof CurveLocationDetail) {\r\n // We trust that the caller has linked from the graph node to a curve which has a RegionGroupMember as its parent.\r\n const member = data.curve!.parent;\r\n if (member instanceof RegionGroupMember)\r\n return updateRegionGroupMemberState(member);\r\n }\r\n return undefined;\r\n }\r\n // obligations to act as sweep callback ...\r\n /** Announce a representative node on the outer face of a component */\r\n public startComponent(outerFaceNode: HalfEdge): boolean {\r\n outerFaceNode.setMaskAroundFace(HalfEdgeMask.EXTERIOR);\r\n if (this._announceFaceFunction)\r\n this._announceFaceFunction(this.graph, outerFaceNode, -1, faceAreaFromCurvedEdgeData(outerFaceNode));\r\n return true;\r\n }\r\n /** Announce return to outer face */\r\n public finishComponent(_node: HalfEdge): boolean {\r\n return true;\r\n }\r\n /** Announce entry to a graph face.\r\n * * Both both sides of a graph edge are from the same RegionGroupMember.\r\n * * Hence \"crossing that edge\" changes the parity count for the RegionGroupMember that owns that edge by 1.\r\n * * The parity count for other RegionGroupMembers are never affected by this crossing.\r\n * * Crossing a bridge edge does not change the parity count.\r\n */\r\n public enterFace(_facePathStack: HalfEdge[], newFaceNode: HalfEdge): boolean {\r\n this.recordTransitionAcrossEdge(newFaceNode, 1);\r\n const state = this.getInOut();\r\n if (!state)\r\n newFaceNode.setMaskAroundFace(HalfEdgeMask.EXTERIOR);\r\n if (this._announceFaceFunction)\r\n this._announceFaceFunction(this.graph, newFaceNode, state ? 1 : 0, faceAreaFromCurvedEdgeData(newFaceNode));\r\n return true;\r\n }\r\n /** Announce face exit */\r\n public leaveFace(_facePathStack: HalfEdge[], oldFaceNode: HalfEdge): boolean {\r\n this.recordTransitionAcrossEdge(oldFaceNode, -1);\r\n return true;\r\n }\r\n}\r\n/** return xy area between a (part of a) curve and the x axis through a reference point.\r\n * If detail is undefined or does not have both start and end fractions, just do trapezoid area\r\n */\r\nfunction areaUnderPartialCurveXY(detail: CurveLocationDetail | undefined, xyStart: XAndY, xyEnd: XAndY, referencePoint: XAndY): number {\r\n // area between trapezoid and axis\r\n let trapezoidArea;\r\n if (detail && detail.point1) {\r\n trapezoidArea = -(detail.point1.x - detail.point.x) * (0.5 * (detail.point.y + detail.point1.y) - referencePoint.y);\r\n } else {\r\n trapezoidArea = -(xyEnd.x - xyStart.x) * (0.5 * (xyStart.y + xyEnd.y) - referencePoint.y);\r\n }\r\n let areaToChord = 0.0;\r\n if (detail && detail.curve && detail.hasFraction1) {\r\n\r\n if (detail.curve instanceof LineSegment3d) {\r\n // ah .. nothing to do for a line segment\r\n } else if (detail.curve instanceof Arc3d) {\r\n areaToChord = detail.curve.areaToChordXY(detail.fraction, detail.fraction1!);\r\n }\r\n }\r\n return trapezoidArea + areaToChord;\r\n}\r\n/** Compute face area for a face whose edges are decorated with CurveLocationDetail for their (partial) curves */\r\nfunction faceAreaFromCurvedEdgeData(faceSeed: HalfEdge): number {\r\n let area = 0.0;\r\n let edge = faceSeed;\r\n do {\r\n area += (edge.sortData as number) * areaUnderPartialCurveXY((edge.edgeTag as CurveLocationDetail), edge, edge.faceSuccessor, faceSeed);\r\n } while ((edge = edge.faceSuccessor) !== faceSeed);\r\n return area;\r\n}\r\n\r\n/**\r\n * Function to accumulate area under edges\r\n * Array of nodes representing faces in a subset of a graph.\r\n * @internal\r\n */\r\nexport type NodeAndRangeFunction = (edge: HalfEdge, range: Range2d) => void;\r\n/**\r\n * Array of nodes representing faces in a subset of a graph.\r\n * @internal\r\n */\r\nexport class GraphComponent {\r\n public faces: HalfEdge[];\r\n public faceAreas: number[];\r\n public range: Range2d;\r\n public constructor(faces: HalfEdge[]) {\r\n this.faces = faces;\r\n this.range = Range2d.createNull();\r\n this.faceAreas = [];\r\n }\r\n /**\r\n * visit all vertices and edges in the component to build face area array and composite range.\r\n *\r\n * @param extendRangeForEdge optional function to compute edge range. If undefined, linear edge is assumed.\r\n * @param faceAreaFunction optional function to compute face area. If undefined, linear edges are assumed.\r\n */\r\n public buildFaceData(extendRangeForEdge: NodeAndRangeFunction | undefined, faceAreaFunction: NodeToNumberFunction | undefined) {\r\n const vertexFunction = (node: HalfEdge) => {\r\n if (extendRangeForEdge)\r\n extendRangeForEdge(node, this.range);\r\n else\r\n this.range.extendXY(node.x, node.y);\r\n return 0;\r\n };\r\n this.range.setNull();\r\n for (const f of this.faces) {\r\n f.sumAroundFace(vertexFunction);\r\n }\r\n this.faceAreas.length = 0;\r\n if (!faceAreaFunction)\r\n faceAreaFunction = HalfEdgeGraphSearch.signedFaceArea;\r\n for (const f of this.faces) {\r\n this.faceAreas.push(faceAreaFunction(f));\r\n }\r\n }\r\n}\r\n/** build and hold an array of component data for a HalfEdgeGraph.\r\n * @internal\r\n */\r\nexport class GraphComponentArray {\r\n public components: GraphComponent[];\r\n public graph: HalfEdgeGraph;\r\n private constructor(graph: HalfEdgeGraph) {\r\n this.graph = graph;\r\n this.components = [];\r\n }\r\n public static create(graph: HalfEdgeGraph, extendRangeForEdge?: (edge: HalfEdge, range: Range2d) => void): GraphComponentArray {\r\n const result = new GraphComponentArray(graph);\r\n const componentArrays = HalfEdgeGraphSearch.collectConnectedComponentsWithExteriorParityMasks(graph, undefined);\r\n for (const componentFaces of componentArrays) {\r\n const component = new GraphComponent(componentFaces);\r\n component.buildFaceData(extendRangeForEdge, faceAreaFromCurvedEdgeData);\r\n result.components.push(component);\r\n }\r\n return result;\r\n }\r\n}\r\n"]}
|
|
@@ -56,10 +56,9 @@ class StrokeOptions {
|
|
|
56
56
|
get hasMaxEdgeLength() { return this.maxEdgeLength !== undefined && this.maxEdgeLength > 0.0; }
|
|
57
57
|
/** Return a deep clone */
|
|
58
58
|
clone() {
|
|
59
|
-
var _a;
|
|
60
59
|
const options = new StrokeOptions();
|
|
61
60
|
options.chordTol = this.chordTol;
|
|
62
|
-
options.angleTol =
|
|
61
|
+
options.angleTol = this.angleTol?.clone();
|
|
63
62
|
options.maxEdgeLength = this.maxEdgeLength;
|
|
64
63
|
options.needConvexFacets = this.needConvexFacets;
|
|
65
64
|
options.minStrokesPerPrimitive = this.minStrokesPerPrimitive;
|