@itwin/core-geometry 5.0.0-dev.114 → 5.0.0-dev.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -1
- package/lib/cjs/bspline/BSplineSurface.d.ts +2 -1
- package/lib/cjs/bspline/BSplineSurface.d.ts.map +1 -1
- package/lib/cjs/bspline/BSplineSurface.js +2 -1
- package/lib/cjs/bspline/BSplineSurface.js.map +1 -1
- package/lib/cjs/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipUtils.js +5 -3
- package/lib/cjs/clipping/ClipUtils.js.map +1 -1
- package/lib/cjs/curve/RegionMomentsXY.d.ts +15 -21
- package/lib/cjs/curve/RegionMomentsXY.d.ts.map +1 -1
- package/lib/cjs/curve/RegionMomentsXY.js +38 -58
- package/lib/cjs/curve/RegionMomentsXY.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +38 -16
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +83 -23
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +12 -13
- package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js +23 -23
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +36 -12
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/cjs/curve/internalContexts/TransferWithSplitArcs.d.ts +14 -0
- package/lib/cjs/curve/internalContexts/TransferWithSplitArcs.d.ts.map +1 -0
- package/lib/cjs/curve/internalContexts/TransferWithSplitArcs.js +34 -0
- package/lib/cjs/curve/internalContexts/TransferWithSplitArcs.js.map +1 -0
- package/lib/cjs/geometry3d/AngleSweep.d.ts +10 -6
- package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js +17 -6
- package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +3 -3
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.d.ts +8 -7
- package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.js +19 -15
- package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
- package/lib/cjs/geometry4d/Matrix4d.d.ts +7 -7
- package/lib/cjs/geometry4d/Matrix4d.d.ts.map +1 -1
- package/lib/cjs/geometry4d/Matrix4d.js +9 -9
- package/lib/cjs/geometry4d/Matrix4d.js.map +1 -1
- package/lib/cjs/geometry4d/MomentData.d.ts +32 -34
- package/lib/cjs/geometry4d/MomentData.d.ts.map +1 -1
- package/lib/cjs/geometry4d/MomentData.js +56 -57
- package/lib/cjs/geometry4d/MomentData.js.map +1 -1
- package/lib/cjs/geometry4d/Point4d.d.ts +3 -2
- package/lib/cjs/geometry4d/Point4d.d.ts.map +1 -1
- package/lib/cjs/geometry4d/Point4d.js +9 -2
- package/lib/cjs/geometry4d/Point4d.js.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/esm/bspline/BSplineSurface.d.ts +2 -1
- package/lib/esm/bspline/BSplineSurface.d.ts.map +1 -1
- package/lib/esm/bspline/BSplineSurface.js +2 -1
- package/lib/esm/bspline/BSplineSurface.js.map +1 -1
- package/lib/esm/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/esm/clipping/ClipUtils.js +5 -3
- package/lib/esm/clipping/ClipUtils.js.map +1 -1
- package/lib/esm/curve/RegionMomentsXY.d.ts +15 -21
- package/lib/esm/curve/RegionMomentsXY.d.ts.map +1 -1
- package/lib/esm/curve/RegionMomentsXY.js +38 -58
- package/lib/esm/curve/RegionMomentsXY.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +38 -16
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +84 -24
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +12 -13
- package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.js +23 -23
- package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +36 -12
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/esm/curve/internalContexts/TransferWithSplitArcs.d.ts +14 -0
- package/lib/esm/curve/internalContexts/TransferWithSplitArcs.d.ts.map +1 -0
- package/lib/esm/curve/internalContexts/TransferWithSplitArcs.js +30 -0
- package/lib/esm/curve/internalContexts/TransferWithSplitArcs.js.map +1 -0
- package/lib/esm/geometry3d/AngleSweep.d.ts +10 -6
- package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.js +17 -6
- package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +3 -3
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.d.ts +8 -7
- package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.js +19 -15
- package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
- package/lib/esm/geometry4d/Matrix4d.d.ts +7 -7
- package/lib/esm/geometry4d/Matrix4d.d.ts.map +1 -1
- package/lib/esm/geometry4d/Matrix4d.js +9 -9
- package/lib/esm/geometry4d/Matrix4d.js.map +1 -1
- package/lib/esm/geometry4d/MomentData.d.ts +32 -34
- package/lib/esm/geometry4d/MomentData.d.ts.map +1 -1
- package/lib/esm/geometry4d/MomentData.js +56 -57
- package/lib/esm/geometry4d/MomentData.js.map +1 -1
- package/lib/esm/geometry4d/Point4d.d.ts +3 -2
- package/lib/esm/geometry4d/Point4d.d.ts.map +1 -1
- package/lib/esm/geometry4d/Point4d.js +9 -2
- package/lib/esm/geometry4d/Point4d.js.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegionMomentsXY.js","sourceRoot":"","sources":["../../../src/curve/RegionMomentsXY.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAU/F,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAItD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,mBAAmB;IAC9C,iBAAiB,CAAc;IAC/B,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAC3B,OAAO,GAAG,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AE,CAAC;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxC,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IACD,wEAAwE;IACxD,oBAAoB,CAAC,CAAiB,IAAI,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChG,yEAAyE;IACzD,qBAAqB,CAAC,CAAkB,IAAI,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClG,0EAA0E;IAC1D,sBAAsB,CAAC,CAAqB,IAAI,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAEvG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Curve\n */\n\n// import { Geometry, Angle, AngleSweep } from \"../Geometry\";\n\nimport { BSplineCurve3d } from \"../bspline/BSplineCurve\";\nimport { BSplineCurve3dH } from \"../bspline/BSplineCurve3dH\";\nimport { Angle } from \"../geometry3d/Angle\";\nimport { NullGeometryHandler } from \"../geometry3d/GeometryHandler\";\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\nimport { MomentData } from \"../geometry4d/MomentData\";\nimport { Arc3d } from \"./Arc3d\";\nimport { CurvePrimitive } from \"./CurvePrimitive\";\nimport { LineSegment3d } from \"./LineSegment3d\";\nimport { LineString3d } from \"./LineString3d\";\nimport { Loop } from \"./Loop\";\nimport { ParityRegion } from \"./ParityRegion\";\nimport { StrokeOptions } from \"./StrokeOptions\";\nimport { TransitionSpiral3d } from \"./spiral/TransitionSpiral3d\";\nimport { UnionRegion } from \"./UnionRegion\";\n\n/**\n * Implementation class for computing XY area moments.\n * @internal\n */\nexport class RegionMomentsXY extends NullGeometryHandler {\n private _activeMomentData?: MomentData;\n private _point0 = Point3d.create();\n private _point1 = Point3d.create();\n\n /** Accumulate (independent) integrations over\n * * origin to chord of the arc.\n * * origin to the \"cap\" between the chord and arc.\n */\n public override handleArc3d(arc: Arc3d): void {\n const momentData = this._activeMomentData!;\n const sweepRadians = arc.sweep.sweepRadians;\n const alphaRadians = sweepRadians * 0.5;\n // from https://apps.dtic.mil/dtic/tr/fulltext/u2/274936.pdf page 71 for radius = 1\n let s = Math.sin(alphaRadians);\n let c = Math.cos(alphaRadians);\n let s1 = Math.sin(sweepRadians);\n if (Angle.isFullCircleRadians(sweepRadians)) {\n s = 0.0;\n c = -1.0;\n s1 = 0.0;\n }\n const q = 2 * s * s * s * c / (alphaRadians - s * c);\n const s3 = s * s * s;\n const s6 = s3 * s3;\n const area = 0.5 * (sweepRadians - s1);\n const inertiaXX = 0.25 * area * (1.0 - q / 3.0);\n const inertiaYY1 = 0.25 * area * (1.0 + q);\n const inertiaYY = inertiaYY1 - 4.0 * s6 / (9.0 * area);\n const productXX = inertiaYY;\n const productYY = inertiaXX;\n const centerToCentroid = 4.0 * s * s * s / (3.0 * (sweepRadians - s1));\n const midRadians = arc.sweep.fractionToRadians(0.5);\n const centralPlane = arc.radiansToRotatedBasis(midRadians);\n const centroid = centralPlane.origin.plusScaled(centralPlane.vectorU, centerToCentroid);\n momentData.accumulateXYProductsInCentroidalFrame(productXX, 0.0, productYY, area, centroid, centralPlane.vectorU, centralPlane.vectorV);\n const pointB = arc.fractionToPoint(0.0);\n const pointC = arc.fractionToPoint(1.0);\n momentData.accumulateTriangleMomentsXY(undefined, pointB, pointC);\n }\n\n /** Accumulate integrals over the (triangular) areas from the origin to each line segment */\n public override handleLineString3d(ls: LineString3d): void {\n const momentData = this._activeMomentData!;\n momentData.accumulateTriangleToLineStringMomentsXY(undefined, ls.packedPoints);\n }\n /** Accumulate integrals over the (triangular) area from the origin to this line segment */\n public override handleLineSegment3d(segment: LineSegment3d): void {\n const momentData = this._activeMomentData!;\n segment.startPoint(this._point0);\n segment.endPoint(this._point1);\n momentData.accumulateTriangleMomentsXY(undefined, this._point0, this._point1);\n }\n /** Accumulate integrals from origin to all primitives in the chain. */\n public override handleLoop(loop: Loop): MomentData | undefined {\n const momentData = this._activeMomentData = MomentData.create();\n momentData.needOrigin = false;\n for (const child of loop.children)\n child.dispatchToGeometryHandler(this);\n this._activeMomentData = undefined;\n return momentData;\n }\n /**\n * ASSUMPTIONS FOR ORIENTATION AND CONTAINMENT ISSUES\n * * Largest area is outer\n * * All others are interior (and not overlapping)\n * Hence\n * * Outer area sign must be positive -- negate all integrations as needed\n * * Outer area signs must be positive -- negate all integrations as needed\n * @param region\n */\n public override handleParityRegion(region: ParityRegion): MomentData | undefined {\n const allChildMoments: MomentData[] = [];\n let maxAbsArea = 0.0;\n let largestChildMoments: MomentData | undefined;\n for (const child of region.children) {\n if (child instanceof Loop) {\n const childMoments = this.handleLoop(child);\n if (childMoments) {\n allChildMoments.push(childMoments);\n const q = Math.abs(childMoments.quantitySum);\n if (q > maxAbsArea) {\n maxAbsArea = q;\n largestChildMoments = childMoments;\n }\n\n }\n }\n }\n if (largestChildMoments) {\n const summedMoments = MomentData.create();\n const sign0 = largestChildMoments.signFactor(1.0);\n summedMoments.accumulateProducts(largestChildMoments, sign0);\n for (const childMoments of allChildMoments) {\n if (childMoments !== largestChildMoments) {\n const sign1 = childMoments.signFactor(-1.0);\n summedMoments.accumulateProducts(childMoments, sign1);\n }\n }\n return summedMoments;\n }\n return undefined;\n }\n /** Accumulate (as simple addition) products over each component of the union region. */\n public override handleUnionRegion(region: UnionRegion): MomentData | undefined {\n const summedMoments = MomentData.create();\n for (const child of region.children) {\n const childMoments = child.dispatchToGeometryHandler(this);\n if (childMoments) {\n const sign0 = childMoments.signFactor(1.0);\n summedMoments.accumulateProducts(childMoments, sign0);\n }\n }\n return summedMoments;\n }\n\n private _strokeOptions?: StrokeOptions;\n private getStrokeOptions(): StrokeOptions {\n if (this._strokeOptions)\n return this._strokeOptions;\n const options = StrokeOptions.createForCurves();\n // this is unusually fine for stroking, but appropriate for sum.\n options.angleTol = Angle.createDegrees(5.0);\n this._strokeOptions = options;\n return options;\n }\n /** Single curve primitive (not loop . . .).\n * * stroke the curve\n * * accumulate stroke array.\n */\n public handleCurvePrimitive(cp: CurvePrimitive) {\n const strokes = LineString3d.create();\n const options = this.getStrokeOptions();\n cp.emitStrokes(strokes, options);\n this.handleLineString3d(strokes);\n }\n /** handle strongly typed BSplineCurve3d as generic curve primitive */\n public override handleBSplineCurve3d(g: BSplineCurve3d) { return this.handleCurvePrimitive(g); }\n /** handle strongly typed BSplineCurve3dH as generic curve primitive */\n public override handleBSplineCurve3dH(g: BSplineCurve3dH) { return this.handleCurvePrimitive(g); }\n /** handle strongly typed TransitionSpiral as generic curve primitive */\n public override handleTransitionSpiral(g: TransitionSpiral3d) { return this.handleCurvePrimitive(g); }\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RegionMomentsXY.js","sourceRoot":"","sources":["../../../src/curve/RegionMomentsXY.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAU/F,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAKtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,mBAAmB;IAC9C,iBAAiB,CA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e,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IACD,8EAA8E;IAC9D,iBAAiB,CAAC,MAAmB;QACnD,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IACO,cAAc,CAAiB;IAC/B,gBAAgB;QACtB,IAAI,IAAI,CAAC,cAAc;YACrB,OAAO,IAAI,CAAC,cAAc,CAAC;QAC7B,MAAM,OAAO,GAAG,aAAa,CAAC,eAAe,EAAE,CAAC;QAChD,gEAAgE;QAChE,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAC5C,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD;;;OAGG;IACI,oBAAoB,CAAC,EAAkB;QAC5C,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxC,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IACD,yEAAyE;IACzD,oBAAoB,CAAC,CAAiB;QACpD,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;IACD,0EAA0E;IAC1D,qBAAqB,CAAC,CAAkB;QACtD,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;IACD,0EAA0E;IAC1D,sBAAsB,CAAC,CAAqB;QAC1D,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Curve\n */\n\n// import { Geometry, Angle, AngleSweep } from \"../Geometry\";\n\nimport { BSplineCurve3d } from \"../bspline/BSplineCurve\";\nimport { BSplineCurve3dH } from \"../bspline/BSplineCurve3dH\";\nimport { Angle } from \"../geometry3d/Angle\";\nimport { NullGeometryHandler } from \"../geometry3d/GeometryHandler\";\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\nimport { MomentData } from \"../geometry4d/MomentData\";\nimport { Arc3d } from \"./Arc3d\";\nimport { CurvePrimitive } from \"./CurvePrimitive\";\nimport { AnyRegion } from \"./CurveTypes\";\nimport { LineSegment3d } from \"./LineSegment3d\";\nimport { LineString3d } from \"./LineString3d\";\nimport { Loop } from \"./Loop\";\nimport { ParityRegion } from \"./ParityRegion\";\nimport { RegionBinaryOpType, RegionOps } from \"./RegionOps\";\nimport { TransitionSpiral3d } from \"./spiral/TransitionSpiral3d\";\nimport { StrokeOptions } from \"./StrokeOptions\";\nimport { UnionRegion } from \"./UnionRegion\";\n\n/**\n * Implementation class for computing XY area moments.\n * @internal\n */\nexport class RegionMomentsXY extends NullGeometryHandler {\n private _activeMomentData?: MomentData;\n private _point0 = Point3d.create();\n private _point1 = Point3d.create();\n /**\n * Accumulate (independent) integrations over:\n * * The area between the arc and the chord connecting its endpoints.\n * * The triangle with vertices: origin, arc start, arc end.\n */\n public override handleArc3d(arc: Arc3d): void {\n const momentData = this._activeMomentData!;\n const sweepRadians = arc.sweep.sweepRadians;\n const alphaRadians = sweepRadians * 0.5;\n let s = Math.sin(alphaRadians);\n let c = Math.cos(alphaRadians);\n let s1 = Math.sin(sweepRadians);\n if (Angle.isFullCircleRadians(sweepRadians)) {\n s = 0.0;\n c = -1.0;\n s1 = 0.0;\n }\n const q = 2 * s * s * s * c / (alphaRadians - s * c);\n const s3 = s * s * s;\n const s6 = s3 * s3;\n const area = 0.5 * (sweepRadians - s1);\n const inertiaXX = 0.25 * area * (1.0 - q / 3.0);\n const inertiaYY1 = 0.25 * area * (1.0 + q);\n const inertiaYY = inertiaYY1 - 4.0 * s6 / (9.0 * area);\n const productXX = inertiaYY;\n const productYY = inertiaXX;\n const centerToCentroid = 4.0 * s * s * s / (3.0 * (sweepRadians - s1));\n const midRadians = arc.sweep.fractionToRadians(0.5);\n const centralPlane = arc.radiansToRotatedBasis(midRadians);\n const centroid = centralPlane.origin.plusScaled(centralPlane.vectorU, centerToCentroid);\n momentData.accumulateXYProductsInCentroidalFrame(\n productXX, 0.0, productYY, area, centroid, centralPlane.vectorU, centralPlane.vectorV,\n );\n const pointB = arc.fractionToPoint(0.0);\n const pointC = arc.fractionToPoint(1.0);\n momentData.accumulateTriangleMomentsXY(undefined, pointB, pointC);\n }\n /** Accumulate integrals over the (triangular) areas from the origin to each line segment. */\n public override handleLineString3d(ls: LineString3d): void {\n const momentData = this._activeMomentData!;\n momentData.accumulateTriangleToLineStringMomentsXY(undefined, ls.packedPoints);\n }\n /** Accumulate integrals over the (triangular) area from the origin to this line segment. */\n public override handleLineSegment3d(segment: LineSegment3d): void {\n const momentData = this._activeMomentData!;\n segment.startPoint(this._point0);\n segment.endPoint(this._point1);\n momentData.accumulateTriangleMomentsXY(undefined, this._point0, this._point1);\n }\n /** Accumulate integrals from origin to all primitives in the chain. */\n public override handleLoop(loop: Loop): MomentData | undefined {\n const momentData = this._activeMomentData = MomentData.create();\n momentData.needOrigin = false;\n for (const child of loop.children)\n child.dispatchToGeometryHandler(this);\n this._activeMomentData = undefined;\n return momentData;\n }\n private handleAnyRegion(region: AnyRegion): MomentData | undefined {\n // guarantee there is no overlapping children\n const merged = RegionOps.regionBooleanXY(region, undefined, RegionBinaryOpType.Union);\n if (!merged)\n return undefined;\n if (merged instanceof Loop)\n return this.handleLoop(merged);\n const summedMoments = MomentData.create();\n for (const child of merged.children) {\n const childMoments = child.dispatchToGeometryHandler(this);\n if (childMoments) {\n const sign0 = childMoments.signFactor(1.0);\n summedMoments.accumulateProducts(childMoments, sign0);\n }\n }\n return summedMoments;\n }\n /** Accumulate integrals from origin to the components of the parity region. */\n public override handleParityRegion(region: ParityRegion): MomentData | undefined {\n return this.handleAnyRegion(region);\n }\n /** Accumulate integrals from origin to the components of the union region. */\n public override handleUnionRegion(region: UnionRegion): MomentData | undefined {\n return this.handleAnyRegion(region);\n }\n private _strokeOptions?: StrokeOptions;\n private getStrokeOptions(): StrokeOptions {\n if (this._strokeOptions)\n return this._strokeOptions;\n const options = StrokeOptions.createForCurves();\n // this is unusually fine for stroking, but appropriate for sum.\n options.angleTol = Angle.createDegrees(5.0);\n this._strokeOptions = options;\n return options;\n }\n /**\n * Handle a single curve primitive (not loop).\n * * Stroke the curve and accumulate stroke array.\n */\n public handleCurvePrimitive(cp: CurvePrimitive): void {\n const strokes = LineString3d.create();\n const options = this.getStrokeOptions();\n cp.emitStrokes(strokes, options);\n this.handleLineString3d(strokes);\n }\n /** Handle strongly typed BSplineCurve3d as generic curve primitive. */\n public override handleBSplineCurve3d(g: BSplineCurve3d): void {\n this.handleCurvePrimitive(g);\n }\n /** Handle strongly typed BSplineCurve3dH as generic curve primitive. */\n public override handleBSplineCurve3dH(g: BSplineCurve3dH): void {\n this.handleCurvePrimitive(g);\n }\n /** Handle strongly typed TransitionSpiral as generic curve primitive. */\n public override handleTransitionSpiral(g: TransitionSpiral3d): void {\n this.handleCurvePrimitive(g);\n }\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import { GrowableXYZArray } from "../geometry3d/GrowableXYZArray";
|
|
|
2
2
|
import { IndexedXYZCollection, MultiLineStringDataVariant } from "../geometry3d/IndexedXYZCollection";
|
|
3
3
|
import { Point3d } from "../geometry3d/Point3dVector3d";
|
|
4
4
|
import { Range3d } from "../geometry3d/Range";
|
|
5
|
+
import { Ray3d } from "../geometry3d/Ray3d";
|
|
5
6
|
import { Transform } from "../geometry3d/Transform";
|
|
6
7
|
import { MomentData } from "../geometry4d/MomentData";
|
|
7
8
|
import { IndexedPolyface, Polyface } from "../polyface/Polyface";
|
|
@@ -48,37 +49,46 @@ export declare enum RegionBinaryOpType {
|
|
|
48
49
|
export declare class RegionOps {
|
|
49
50
|
/**
|
|
50
51
|
* Return moment sums for a loop, parity region, or union region.
|
|
52
|
+
* * The input region should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
|
|
51
53
|
* * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
+
* call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes(rawMomentData.origin, rawMomentData.sums);`
|
|
55
|
+
* * `rawMomentData.origin` is the centroid of `region`.
|
|
56
|
+
* * `rawMomentData.sums.weight()` is the signed area of `region`.
|
|
57
|
+
* @param region any [[Loop]], [[ParityRegion]], or [[UnionRegion]].
|
|
54
58
|
*/
|
|
55
|
-
static computeXYAreaMoments(
|
|
59
|
+
static computeXYAreaMoments(region: AnyRegion): MomentData | undefined;
|
|
56
60
|
/**
|
|
57
61
|
* Return an area tolerance for a given xy-range and optional distance tolerance.
|
|
58
|
-
* @param range range of planar region to tolerance
|
|
59
|
-
* @param distanceTolerance optional absolute distance tolerance
|
|
62
|
+
* @param range range of planar region to tolerance.
|
|
63
|
+
* @param distanceTolerance optional absolute distance tolerance.
|
|
60
64
|
*/
|
|
61
65
|
static computeXYAreaTolerance(range: Range3d, distanceTolerance?: number): number;
|
|
62
66
|
/**
|
|
63
67
|
* Return a (signed) xy area for a region.
|
|
64
|
-
<<<<<<< HEAD
|
|
65
|
-
* * The area is negative if and only if the region is oriented clockwise with respect to the positive z-axis.
|
|
66
|
-
* @param root any Loop, ParityRegion, or UnionRegion.
|
|
67
|
-
=======
|
|
68
68
|
* * The input region should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
|
|
69
|
-
* *
|
|
70
|
-
* with respect to the positive z-axis.
|
|
69
|
+
* * The area is negative if and only if the region is oriented clockwise with respect to the positive z-axis.
|
|
71
70
|
* @param region any [[Loop]], [[ParityRegion]], or [[UnionRegion]].
|
|
72
|
-
>>>>>>> 168574b454 (Utilize `PolyfaceData.edgeMateIndex` to speed up some `Polyface` methods (#8095))
|
|
73
71
|
*/
|
|
74
|
-
static computeXYArea(
|
|
72
|
+
static computeXYArea(region: AnyRegion): number | undefined;
|
|
75
73
|
/**
|
|
76
74
|
* Return MomentData with the sums of wire moments.
|
|
75
|
+
* * The input curve should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
|
|
77
76
|
* * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with
|
|
78
|
-
*
|
|
79
|
-
*
|
|
77
|
+
* call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
|
|
78
|
+
* * `rawMomentData.origin` is the wire centroid of `curve`.
|
|
79
|
+
* * `rawMomentData.sums.weight()` is the signed length of `curve`.
|
|
80
|
+
* @param curve any [[CurveCollection]] or [[CurvePrimitive]].
|
|
80
81
|
*/
|
|
81
|
-
static computeXYZWireMomentSums(
|
|
82
|
+
static computeXYZWireMomentSums(curve: AnyCurve): MomentData | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Return a [[Ray3d]] with:
|
|
85
|
+
* * `origin` is the centroid of the region,
|
|
86
|
+
* * `direction` is a unit vector perpendicular to the region plane,
|
|
87
|
+
* * `a` is the region area.
|
|
88
|
+
* @param region the region to process. Can lie in any plane.
|
|
89
|
+
* @param result optional pre-allocated result to populate and return.
|
|
90
|
+
*/
|
|
91
|
+
static centroidAreaNormal(region: AnyRegion, result?: Ray3d): Ray3d | undefined;
|
|
82
92
|
/**
|
|
83
93
|
* Create loops in the graph.
|
|
84
94
|
* @internal
|
|
@@ -127,6 +137,18 @@ export declare class RegionOps {
|
|
|
127
137
|
* @param triangulate whether to triangulate the result
|
|
128
138
|
*/
|
|
129
139
|
static polygonXYAreaDifferenceLoopsToPolyface(loopsA: MultiLineStringDataVariant, loopsB: MultiLineStringDataVariant, triangulate?: boolean): Polyface | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* Simplify the type of the region by stripping redundant parent(s).
|
|
142
|
+
* * No Boolean operations are performed.
|
|
143
|
+
* * Invalid inputs (such as childless regions) are not corrected.
|
|
144
|
+
* @param region region to simplify
|
|
145
|
+
* @returns
|
|
146
|
+
* * For a [[UnionRegion]] with exactly one child, return it if it is a [[Loop]],
|
|
147
|
+
* or if it is a [[ParityRegion]] with multiple children, otherwise return the `ParityRegion`'s `Loop`.
|
|
148
|
+
* * For a `ParityRegion` with exactly one `Loop`, return it.
|
|
149
|
+
* * All other inputs returned unchanged.
|
|
150
|
+
*/
|
|
151
|
+
static simplifyRegionType(region: AnyRegion): AnyRegion;
|
|
130
152
|
/**
|
|
131
153
|
* Return areas defined by a boolean operation.
|
|
132
154
|
* @note For best results, input regions should have correctly oriented loops. See [[sortOuterAndHoleLoopsXY]].
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegionOps.d.ts","sourceRoot":"","sources":["../../../src/curve/RegionOps.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RegionOps.d.ts","sourceRoot":"","sources":["../../../src/curve/RegionOps.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAC0B,oBAAoB,EAAyB,0BAA0B,EACvG,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAY,MAAM,+BAA+B,CAAC;AAGlE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAI1E,OAAO,EAAe,UAAU,EAAE,eAAe,EAA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AE,SAAS,GAAG,OAAO;IAkB3E;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,iCAAiC;IAqChD,oCAAoC;IACpC,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAepC;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAIzC;;;;;;;;;OASG;WACW,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,eAAe,GAAG,SAAS;IAyBpG;;;;;MAKE;WACY,wBAAwB,CAAC,OAAO,EAAE,0BAA0B,EAAE,QAAQ,GAAE,OAAc,GAAG,gBAAgB,EAAE,GAAG,SAAS;CActI;AAaD;;;GAGG;AACH,qBAAa,yCAAyC;IACpD,+EAA+E;IACxE,yBAAyB,EAAE,OAAO,CAAQ;IACjD,0EAA0E;IACnE,yBAAyB,EAAE,OAAO,CAAQ;IACjD,gEAAgE;IACzD,wBAAwB,CAAC,EAAE,OAAO,CAAS;IAClD,kFAAkF;IAC3E,uBAAuB,EAAE,MAAM,CAAgC;IACtE,wFAAwF;IACjF,sBAAsB,EAAE,MAAM,CAAgC;CACtE"}
|
|
@@ -6,13 +6,15 @@
|
|
|
6
6
|
* @module Curve
|
|
7
7
|
*/
|
|
8
8
|
import { Geometry } from "../Geometry";
|
|
9
|
+
import { FrameBuilder } from "../geometry3d/FrameBuilder";
|
|
9
10
|
import { GrowableXYZArray } from "../geometry3d/GrowableXYZArray";
|
|
10
11
|
import { IndexedReadWriteXYZCollection, IndexedXYZCollection, } from "../geometry3d/IndexedXYZCollection";
|
|
11
12
|
import { Point3dArrayCarrier } from "../geometry3d/Point3dArrayCarrier";
|
|
12
|
-
import { Point3d } from "../geometry3d/Point3dVector3d";
|
|
13
|
+
import { Point3d, Vector3d } from "../geometry3d/Point3dVector3d";
|
|
13
14
|
import { PolygonOps } from "../geometry3d/PolygonOps";
|
|
14
15
|
import { PolylineCompressionContext } from "../geometry3d/PolylineCompressionByEdgeOffset";
|
|
15
16
|
import { Range3d } from "../geometry3d/Range";
|
|
17
|
+
import { Ray3d } from "../geometry3d/Ray3d";
|
|
16
18
|
import { SortablePolygon } from "../geometry3d/SortablePolygon";
|
|
17
19
|
import { Transform } from "../geometry3d/Transform";
|
|
18
20
|
import { MomentData } from "../geometry4d/MomentData";
|
|
@@ -29,6 +31,7 @@ import { CurveWireMomentsXYZ } from "./CurveWireMomentsXYZ";
|
|
|
29
31
|
import { GeometryQuery } from "./GeometryQuery";
|
|
30
32
|
import { ChainCollectorContext } from "./internalContexts/ChainCollectorContext";
|
|
31
33
|
import { PolygonWireOffsetContext } from "./internalContexts/PolygonOffsetContext";
|
|
34
|
+
import { TransferWithSplitArcs } from "./internalContexts/TransferWithSplitArcs";
|
|
32
35
|
import { LineString3d } from "./LineString3d";
|
|
33
36
|
import { Loop } from "./Loop";
|
|
34
37
|
import { OffsetOptions } from "./OffsetOptions";
|
|
@@ -68,13 +71,16 @@ export var RegionBinaryOpType;
|
|
|
68
71
|
export class RegionOps {
|
|
69
72
|
/**
|
|
70
73
|
* Return moment sums for a loop, parity region, or union region.
|
|
74
|
+
* * The input region should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
|
|
71
75
|
* * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with
|
|
72
|
-
*
|
|
73
|
-
*
|
|
76
|
+
* call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes(rawMomentData.origin, rawMomentData.sums);`
|
|
77
|
+
* * `rawMomentData.origin` is the centroid of `region`.
|
|
78
|
+
* * `rawMomentData.sums.weight()` is the signed area of `region`.
|
|
79
|
+
* @param region any [[Loop]], [[ParityRegion]], or [[UnionRegion]].
|
|
74
80
|
*/
|
|
75
|
-
static computeXYAreaMoments(
|
|
81
|
+
static computeXYAreaMoments(region) {
|
|
76
82
|
const handler = new RegionMomentsXY();
|
|
77
|
-
const result =
|
|
83
|
+
const result = region.dispatchToGeometryHandler(handler);
|
|
78
84
|
if (result instanceof MomentData) {
|
|
79
85
|
result.shiftOriginAndSumsToCentroidOfSums();
|
|
80
86
|
return result;
|
|
@@ -83,8 +89,8 @@ export class RegionOps {
|
|
|
83
89
|
}
|
|
84
90
|
/**
|
|
85
91
|
* Return an area tolerance for a given xy-range and optional distance tolerance.
|
|
86
|
-
* @param range range of planar region to tolerance
|
|
87
|
-
* @param distanceTolerance optional absolute distance tolerance
|
|
92
|
+
* @param range range of planar region to tolerance.
|
|
93
|
+
* @param distanceTolerance optional absolute distance tolerance.
|
|
88
94
|
*/
|
|
89
95
|
static computeXYAreaTolerance(range, distanceTolerance = Geometry.smallMetricDistance) {
|
|
90
96
|
// 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).
|
|
@@ -93,19 +99,13 @@ export class RegionOps {
|
|
|
93
99
|
}
|
|
94
100
|
/**
|
|
95
101
|
* Return a (signed) xy area for a region.
|
|
96
|
-
<<<<<<< HEAD
|
|
97
|
-
* * The area is negative if and only if the region is oriented clockwise with respect to the positive z-axis.
|
|
98
|
-
* @param root any Loop, ParityRegion, or UnionRegion.
|
|
99
|
-
=======
|
|
100
102
|
* * The input region should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
|
|
101
|
-
* *
|
|
102
|
-
* with respect to the positive z-axis.
|
|
103
|
+
* * The area is negative if and only if the region is oriented clockwise with respect to the positive z-axis.
|
|
103
104
|
* @param region any [[Loop]], [[ParityRegion]], or [[UnionRegion]].
|
|
104
|
-
>>>>>>> 168574b454 (Utilize `PolyfaceData.edgeMateIndex` to speed up some `Polyface` methods (#8095))
|
|
105
105
|
*/
|
|
106
|
-
static computeXYArea(
|
|
106
|
+
static computeXYArea(region) {
|
|
107
107
|
const handler = new RegionMomentsXY();
|
|
108
|
-
const result =
|
|
108
|
+
const result = region.dispatchToGeometryHandler(handler);
|
|
109
109
|
if (result instanceof MomentData) {
|
|
110
110
|
return result.quantitySum;
|
|
111
111
|
}
|
|
@@ -113,17 +113,56 @@ export class RegionOps {
|
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
115
|
* Return MomentData with the sums of wire moments.
|
|
116
|
+
* * The input curve should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
|
|
116
117
|
* * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with
|
|
117
|
-
*
|
|
118
|
-
*
|
|
118
|
+
* call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
|
|
119
|
+
* * `rawMomentData.origin` is the wire centroid of `curve`.
|
|
120
|
+
* * `rawMomentData.sums.weight()` is the signed length of `curve`.
|
|
121
|
+
* @param curve any [[CurveCollection]] or [[CurvePrimitive]].
|
|
119
122
|
*/
|
|
120
|
-
static computeXYZWireMomentSums(
|
|
123
|
+
static computeXYZWireMomentSums(curve) {
|
|
121
124
|
const handler = new CurveWireMomentsXYZ();
|
|
122
|
-
handler.visitLeaves(
|
|
125
|
+
handler.visitLeaves(curve);
|
|
123
126
|
const result = handler.momentData;
|
|
124
127
|
result.shiftOriginAndSumsToCentroidOfSums();
|
|
125
128
|
return result;
|
|
126
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Return a [[Ray3d]] with:
|
|
132
|
+
* * `origin` is the centroid of the region,
|
|
133
|
+
* * `direction` is a unit vector perpendicular to the region plane,
|
|
134
|
+
* * `a` is the region area.
|
|
135
|
+
* @param region the region to process. Can lie in any plane.
|
|
136
|
+
* @param result optional pre-allocated result to populate and return.
|
|
137
|
+
*/
|
|
138
|
+
static centroidAreaNormal(region, result) {
|
|
139
|
+
const localToWorld = FrameBuilder.createRightHandedFrame(undefined, region);
|
|
140
|
+
if (!localToWorld)
|
|
141
|
+
return undefined;
|
|
142
|
+
const normal = localToWorld.matrix.columnZ(result?.direction);
|
|
143
|
+
const regionIsXY = normal.isParallelTo(Vector3d.unitZ(), true);
|
|
144
|
+
let regionXY = region;
|
|
145
|
+
if (!regionIsXY) { // rotate the region to be parallel to the xy-plane
|
|
146
|
+
regionXY = region.cloneTransformed(localToWorld.inverse());
|
|
147
|
+
if (!regionXY)
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
const momentData = RegionOps.computeXYAreaMoments(regionXY);
|
|
151
|
+
if (!momentData)
|
|
152
|
+
return undefined;
|
|
153
|
+
const centroid = momentData.origin.clone(result?.origin);
|
|
154
|
+
if (!regionIsXY) // rotate centroid back (area is unchanged)
|
|
155
|
+
localToWorld.multiplyPoint3d(centroid, centroid);
|
|
156
|
+
let area = momentData.sums.weight();
|
|
157
|
+
if (area < 0.0) {
|
|
158
|
+
area = -area;
|
|
159
|
+
normal.scale(-1.0, normal);
|
|
160
|
+
}
|
|
161
|
+
if (!result)
|
|
162
|
+
result = Ray3d.createCapture(centroid, normal);
|
|
163
|
+
result.a = area;
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
127
166
|
/**
|
|
128
167
|
* Create loops in the graph.
|
|
129
168
|
* @internal
|
|
@@ -241,6 +280,28 @@ export class RegionOps {
|
|
|
241
280
|
const graph = RegionOpsFaceToFaceSearch.doPolygonBoolean(loopsA, loopsB, (inA, inB) => (inA && !inB), this._graphCheckPointFunction);
|
|
242
281
|
return this.finishGraphToPolyface(graph, triangulate);
|
|
243
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Simplify the type of the region by stripping redundant parent(s).
|
|
285
|
+
* * No Boolean operations are performed.
|
|
286
|
+
* * Invalid inputs (such as childless regions) are not corrected.
|
|
287
|
+
* @param region region to simplify
|
|
288
|
+
* @returns
|
|
289
|
+
* * For a [[UnionRegion]] with exactly one child, return it if it is a [[Loop]],
|
|
290
|
+
* or if it is a [[ParityRegion]] with multiple children, otherwise return the `ParityRegion`'s `Loop`.
|
|
291
|
+
* * For a `ParityRegion` with exactly one `Loop`, return it.
|
|
292
|
+
* * All other inputs returned unchanged.
|
|
293
|
+
*/
|
|
294
|
+
static simplifyRegionType(region) {
|
|
295
|
+
if (region instanceof UnionRegion) {
|
|
296
|
+
if (region.children.length === 1)
|
|
297
|
+
return this.simplifyRegionType(region.children[0]);
|
|
298
|
+
}
|
|
299
|
+
else if (region instanceof ParityRegion) {
|
|
300
|
+
if (region.children.length === 1)
|
|
301
|
+
return region.children[0];
|
|
302
|
+
}
|
|
303
|
+
return region;
|
|
304
|
+
}
|
|
244
305
|
/**
|
|
245
306
|
* Return areas defined by a boolean operation.
|
|
246
307
|
* @note For best results, input regions should have correctly oriented loops. See [[sortOuterAndHoleLoopsXY]].
|
|
@@ -254,8 +315,6 @@ export class RegionOps {
|
|
|
254
315
|
* to connect interior loops to exterior loops.
|
|
255
316
|
*/
|
|
256
317
|
static regionBooleanXY(loopsA, loopsB, operation, mergeTolerance = Geometry.smallMetricDistance) {
|
|
257
|
-
// Always return UnionRegion for now. But keep return type as AnyRegion:
|
|
258
|
-
// in the future, we might return the *simplest* region type.
|
|
259
318
|
const result = UnionRegion.create();
|
|
260
319
|
const context = RegionBooleanContext.create(RegionGroupOpType.Union, RegionGroupOpType.Union);
|
|
261
320
|
context.addMembers(loopsA, loopsB);
|
|
@@ -274,7 +333,7 @@ export class RegionOps {
|
|
|
274
333
|
result.tryAddChild(loop);
|
|
275
334
|
}
|
|
276
335
|
});
|
|
277
|
-
return result;
|
|
336
|
+
return result ? this.simplifyRegionType(result) : undefined;
|
|
278
337
|
}
|
|
279
338
|
/**
|
|
280
339
|
* Return a polyface whose facets are a boolean operation between the input regions.
|
|
@@ -610,7 +669,8 @@ export class RegionOps {
|
|
|
610
669
|
* to the edge and a constituent curve in each.
|
|
611
670
|
*/
|
|
612
671
|
static constructAllXYRegionLoops(curvesAndRegions, tolerance = Geometry.smallMetricDistance) {
|
|
613
|
-
|
|
672
|
+
let primitives = RegionOps.collectCurvePrimitives(curvesAndRegions, undefined, true, true);
|
|
673
|
+
primitives = TransferWithSplitArcs.clone(BagOfCurves.create(...primitives)).children;
|
|
614
674
|
const range = this.curveArrayRange(primitives);
|
|
615
675
|
const areaTol = this.computeXYAreaTolerance(range, tolerance);
|
|
616
676
|
const intersections = CurveCurve.allIntersectionsAmongPrimitivesXY(primitives, tolerance);
|