@itwin/core-geometry 5.0.0-dev.114 → 5.0.0-dev.116

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.
Files changed (106) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/lib/cjs/bspline/BSplineSurface.d.ts +2 -1
  3. package/lib/cjs/bspline/BSplineSurface.d.ts.map +1 -1
  4. package/lib/cjs/bspline/BSplineSurface.js +2 -1
  5. package/lib/cjs/bspline/BSplineSurface.js.map +1 -1
  6. package/lib/cjs/clipping/ClipUtils.d.ts.map +1 -1
  7. package/lib/cjs/clipping/ClipUtils.js +5 -3
  8. package/lib/cjs/clipping/ClipUtils.js.map +1 -1
  9. package/lib/cjs/curve/RegionMomentsXY.d.ts +15 -21
  10. package/lib/cjs/curve/RegionMomentsXY.d.ts.map +1 -1
  11. package/lib/cjs/curve/RegionMomentsXY.js +38 -58
  12. package/lib/cjs/curve/RegionMomentsXY.js.map +1 -1
  13. package/lib/cjs/curve/RegionOps.d.ts +38 -16
  14. package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
  15. package/lib/cjs/curve/RegionOps.js +83 -23
  16. package/lib/cjs/curve/RegionOps.js.map +1 -1
  17. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +12 -13
  18. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
  19. package/lib/cjs/curve/RegionOpsClassificationSweeps.js +23 -23
  20. package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
  21. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  22. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +36 -12
  23. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  24. package/lib/cjs/curve/internalContexts/TransferWithSplitArcs.d.ts +14 -0
  25. package/lib/cjs/curve/internalContexts/TransferWithSplitArcs.d.ts.map +1 -0
  26. package/lib/cjs/curve/internalContexts/TransferWithSplitArcs.js +34 -0
  27. package/lib/cjs/curve/internalContexts/TransferWithSplitArcs.js.map +1 -0
  28. package/lib/cjs/geometry3d/AngleSweep.d.ts +10 -6
  29. package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
  30. package/lib/cjs/geometry3d/AngleSweep.js +17 -6
  31. package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
  32. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +1 -1
  33. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  34. package/lib/cjs/geometry3d/Point3dVector3d.js +3 -3
  35. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  36. package/lib/cjs/geometry3d/PolygonOps.d.ts +8 -7
  37. package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
  38. package/lib/cjs/geometry3d/PolygonOps.js +19 -15
  39. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  40. package/lib/cjs/geometry4d/Matrix4d.d.ts +7 -7
  41. package/lib/cjs/geometry4d/Matrix4d.d.ts.map +1 -1
  42. package/lib/cjs/geometry4d/Matrix4d.js +9 -9
  43. package/lib/cjs/geometry4d/Matrix4d.js.map +1 -1
  44. package/lib/cjs/geometry4d/MomentData.d.ts +32 -34
  45. package/lib/cjs/geometry4d/MomentData.d.ts.map +1 -1
  46. package/lib/cjs/geometry4d/MomentData.js +56 -57
  47. package/lib/cjs/geometry4d/MomentData.js.map +1 -1
  48. package/lib/cjs/geometry4d/Point4d.d.ts +3 -2
  49. package/lib/cjs/geometry4d/Point4d.d.ts.map +1 -1
  50. package/lib/cjs/geometry4d/Point4d.js +9 -2
  51. package/lib/cjs/geometry4d/Point4d.js.map +1 -1
  52. package/lib/cjs/polyface/IndexedPolyfaceVisitor.js +1 -1
  53. package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
  54. package/lib/esm/bspline/BSplineSurface.d.ts +2 -1
  55. package/lib/esm/bspline/BSplineSurface.d.ts.map +1 -1
  56. package/lib/esm/bspline/BSplineSurface.js +2 -1
  57. package/lib/esm/bspline/BSplineSurface.js.map +1 -1
  58. package/lib/esm/clipping/ClipUtils.d.ts.map +1 -1
  59. package/lib/esm/clipping/ClipUtils.js +5 -3
  60. package/lib/esm/clipping/ClipUtils.js.map +1 -1
  61. package/lib/esm/curve/RegionMomentsXY.d.ts +15 -21
  62. package/lib/esm/curve/RegionMomentsXY.d.ts.map +1 -1
  63. package/lib/esm/curve/RegionMomentsXY.js +38 -58
  64. package/lib/esm/curve/RegionMomentsXY.js.map +1 -1
  65. package/lib/esm/curve/RegionOps.d.ts +38 -16
  66. package/lib/esm/curve/RegionOps.d.ts.map +1 -1
  67. package/lib/esm/curve/RegionOps.js +84 -24
  68. package/lib/esm/curve/RegionOps.js.map +1 -1
  69. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +12 -13
  70. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
  71. package/lib/esm/curve/RegionOpsClassificationSweeps.js +23 -23
  72. package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
  73. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  74. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +36 -12
  75. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  76. package/lib/esm/curve/internalContexts/TransferWithSplitArcs.d.ts +14 -0
  77. package/lib/esm/curve/internalContexts/TransferWithSplitArcs.d.ts.map +1 -0
  78. package/lib/esm/curve/internalContexts/TransferWithSplitArcs.js +30 -0
  79. package/lib/esm/curve/internalContexts/TransferWithSplitArcs.js.map +1 -0
  80. package/lib/esm/geometry3d/AngleSweep.d.ts +10 -6
  81. package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
  82. package/lib/esm/geometry3d/AngleSweep.js +17 -6
  83. package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
  84. package/lib/esm/geometry3d/Point3dVector3d.d.ts +1 -1
  85. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  86. package/lib/esm/geometry3d/Point3dVector3d.js +3 -3
  87. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  88. package/lib/esm/geometry3d/PolygonOps.d.ts +8 -7
  89. package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
  90. package/lib/esm/geometry3d/PolygonOps.js +19 -15
  91. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  92. package/lib/esm/geometry4d/Matrix4d.d.ts +7 -7
  93. package/lib/esm/geometry4d/Matrix4d.d.ts.map +1 -1
  94. package/lib/esm/geometry4d/Matrix4d.js +9 -9
  95. package/lib/esm/geometry4d/Matrix4d.js.map +1 -1
  96. package/lib/esm/geometry4d/MomentData.d.ts +32 -34
  97. package/lib/esm/geometry4d/MomentData.d.ts.map +1 -1
  98. package/lib/esm/geometry4d/MomentData.js +56 -57
  99. package/lib/esm/geometry4d/MomentData.js.map +1 -1
  100. package/lib/esm/geometry4d/Point4d.d.ts +3 -2
  101. package/lib/esm/geometry4d/Point4d.d.ts.map +1 -1
  102. package/lib/esm/geometry4d/Point4d.js +9 -2
  103. package/lib/esm/geometry4d/Point4d.js.map +1 -1
  104. package/lib/esm/polyface/IndexedPolyfaceVisitor.js +1 -1
  105. package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
  106. 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,+CAA4C;AAC5C,mEAAoE;AACpE,mEAAwD;AACxD,yDAAsD;AAItD,iDAA8C;AAC9C,iCAA8B;AAE9B,mDAAgD;AAIhD;;;GAGG;AACH,MAAa,eAAgB,SAAQ,qCAAmB;IAC9C,iBAAiB,CAAc;IAC/B,OAAO,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;IAC3B,OAAO,GAAG,y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AM,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,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;AA/ID,0CA+IC","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,+CAA4C;AAC5C,mEAAoE;AACpE,mEAAwD;AACxD,yDAAsD;AAKtD,iDAA8C;AAC9C,iCAA8B;AAE9B,2CAA4D;AAE5D,mDAAgD;AAGhD;;;GAGG;AACH,MAAa,eAAgB,SAAQ,qCAAmB;IAC9C,iBAAiB,CAAc;IAC/B,OAAO,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;IAC3B,OAAO,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;IACnC;;;;OAIG;IACa,WAAW,CAAC,GAAU;QACpC,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAkB,CAAC;QAC3C,MAAM,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC;QAC5C,MAAM,YAAY,GAAG,YAAY,GAAG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eAAe,EAAE,CAAC;QAChD,gEAAgE;QAChE,OAAO,CAAC,QAAQ,GAAG,aAAK,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,2BAAY,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;AAvHD,0CAuHC","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
- * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
53
- * @param root any Loop, ParityRegion, or UnionRegion.
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(root: AnyRegion): MomentData | undefined;
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
- * * For a non-self-intersecting Loop, the returned area is negative if and only if the Loop is oriented clockwise
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(root: AnyRegion): number | undefined;
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
- * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
79
- * @param root any CurveCollection or CurvePrimitive.
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(root: AnyCurve): MomentData | undefined;
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":"AAUA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE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AAE,EAAE,SAAS,GAAE,MAAqC,GACxF,WAAW,EAAE;IAShB;;;;;;;;;;OAUG;WACW,sBAAsB,CAClC,UAAU,EAAE,QAAQ,GAAG,QAAQ,EAAE,EACjC,cAAc,CAAC,EAAE,cAAc,EAAE,EACjC,0BAA0B,GAAE,OAAe,EAC3C,kBAAkB,GAAE,OAAe,GAClC,cAAc,EAAE;IAanB;;;;;OAKG;WACW,iBAAiB,CAAC,UAAU,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE;IAe/E;;;;OAIG;WACW,eAAe,CAAC,IAAI,EAAE,GAAG,EAAE,YAAY,CAAC,EAAE,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"}
@@ -9,6 +9,7 @@ exports.ConsolidateAdjacentCurvePrimitivesOptions = exports.RegionOps = exports.
9
9
  * @module Curve
10
10
  */
11
11
  const Geometry_1 = require("../Geometry");
12
+ const FrameBuilder_1 = require("../geometry3d/FrameBuilder");
12
13
  const GrowableXYZArray_1 = require("../geometry3d/GrowableXYZArray");
13
14
  const IndexedXYZCollection_1 = require("../geometry3d/IndexedXYZCollection");
14
15
  const Point3dArrayCarrier_1 = require("../geometry3d/Point3dArrayCarrier");
@@ -16,6 +17,7 @@ const Point3dVector3d_1 = require("../geometry3d/Point3dVector3d");
16
17
  const PolygonOps_1 = require("../geometry3d/PolygonOps");
17
18
  const PolylineCompressionByEdgeOffset_1 = require("../geometry3d/PolylineCompressionByEdgeOffset");
18
19
  const Range_1 = require("../geometry3d/Range");
20
+ const Ray3d_1 = require("../geometry3d/Ray3d");
19
21
  const SortablePolygon_1 = require("../geometry3d/SortablePolygon");
20
22
  const Transform_1 = require("../geometry3d/Transform");
21
23
  const MomentData_1 = require("../geometry4d/MomentData");
@@ -32,6 +34,7 @@ const CurveWireMomentsXYZ_1 = require("./CurveWireMomentsXYZ");
32
34
  const GeometryQuery_1 = require("./GeometryQuery");
33
35
  const ChainCollectorContext_1 = require("./internalContexts/ChainCollectorContext");
34
36
  const PolygonOffsetContext_1 = require("./internalContexts/PolygonOffsetContext");
37
+ const TransferWithSplitArcs_1 = require("./internalContexts/TransferWithSplitArcs");
35
38
  const LineString3d_1 = require("./LineString3d");
36
39
  const Loop_1 = require("./Loop");
37
40
  const OffsetOptions_1 = require("./OffsetOptions");
@@ -71,13 +74,16 @@ var RegionBinaryOpType;
71
74
  class RegionOps {
72
75
  /**
73
76
  * Return moment sums for a loop, parity region, or union region.
77
+ * * The input region should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
74
78
  * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with
75
- * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
76
- * @param root any Loop, ParityRegion, or UnionRegion.
79
+ * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes(rawMomentData.origin, rawMomentData.sums);`
80
+ * * `rawMomentData.origin` is the centroid of `region`.
81
+ * * `rawMomentData.sums.weight()` is the signed area of `region`.
82
+ * @param region any [[Loop]], [[ParityRegion]], or [[UnionRegion]].
77
83
  */
78
- static computeXYAreaMoments(root) {
84
+ static computeXYAreaMoments(region) {
79
85
  const handler = new RegionMomentsXY_1.RegionMomentsXY();
80
- const result = root.dispatchToGeometryHandler(handler);
86
+ const result = region.dispatchToGeometryHandler(handler);
81
87
  if (result instanceof MomentData_1.MomentData) {
82
88
  result.shiftOriginAndSumsToCentroidOfSums();
83
89
  return result;
@@ -86,8 +92,8 @@ class RegionOps {
86
92
  }
87
93
  /**
88
94
  * Return an area tolerance for a given xy-range and optional distance tolerance.
89
- * @param range range of planar region to tolerance
90
- * @param distanceTolerance optional absolute distance tolerance
95
+ * @param range range of planar region to tolerance.
96
+ * @param distanceTolerance optional absolute distance tolerance.
91
97
  */
92
98
  static computeXYAreaTolerance(range, distanceTolerance = Geometry_1.Geometry.smallMetricDistance) {
93
99
  // 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).
@@ -96,19 +102,13 @@ class RegionOps {
96
102
  }
97
103
  /**
98
104
  * Return a (signed) xy area for a region.
99
- <<<<<<< HEAD
100
- * * The area is negative if and only if the region is oriented clockwise with respect to the positive z-axis.
101
- * @param root any Loop, ParityRegion, or UnionRegion.
102
- =======
103
105
  * * The input region should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
104
- * * For a non-self-intersecting Loop, the returned area is negative if and only if the Loop is oriented clockwise
105
- * with respect to the positive z-axis.
106
+ * * The area is negative if and only if the region is oriented clockwise with respect to the positive z-axis.
106
107
  * @param region any [[Loop]], [[ParityRegion]], or [[UnionRegion]].
107
- >>>>>>> 168574b454 (Utilize `PolyfaceData.edgeMateIndex` to speed up some `Polyface` methods (#8095))
108
108
  */
109
- static computeXYArea(root) {
109
+ static computeXYArea(region) {
110
110
  const handler = new RegionMomentsXY_1.RegionMomentsXY();
111
- const result = root.dispatchToGeometryHandler(handler);
111
+ const result = region.dispatchToGeometryHandler(handler);
112
112
  if (result instanceof MomentData_1.MomentData) {
113
113
  return result.quantitySum;
114
114
  }
@@ -116,17 +116,56 @@ class RegionOps {
116
116
  }
117
117
  /**
118
118
  * Return MomentData with the sums of wire moments.
119
+ * * The input curve should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
119
120
  * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with
120
- * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
121
- * @param root any CurveCollection or CurvePrimitive.
121
+ * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
122
+ * * `rawMomentData.origin` is the wire centroid of `curve`.
123
+ * * `rawMomentData.sums.weight()` is the signed length of `curve`.
124
+ * @param curve any [[CurveCollection]] or [[CurvePrimitive]].
122
125
  */
123
- static computeXYZWireMomentSums(root) {
126
+ static computeXYZWireMomentSums(curve) {
124
127
  const handler = new CurveWireMomentsXYZ_1.CurveWireMomentsXYZ();
125
- handler.visitLeaves(root);
128
+ handler.visitLeaves(curve);
126
129
  const result = handler.momentData;
127
130
  result.shiftOriginAndSumsToCentroidOfSums();
128
131
  return result;
129
132
  }
133
+ /**
134
+ * Return a [[Ray3d]] with:
135
+ * * `origin` is the centroid of the region,
136
+ * * `direction` is a unit vector perpendicular to the region plane,
137
+ * * `a` is the region area.
138
+ * @param region the region to process. Can lie in any plane.
139
+ * @param result optional pre-allocated result to populate and return.
140
+ */
141
+ static centroidAreaNormal(region, result) {
142
+ const localToWorld = FrameBuilder_1.FrameBuilder.createRightHandedFrame(undefined, region);
143
+ if (!localToWorld)
144
+ return undefined;
145
+ const normal = localToWorld.matrix.columnZ(result?.direction);
146
+ const regionIsXY = normal.isParallelTo(Point3dVector3d_1.Vector3d.unitZ(), true);
147
+ let regionXY = region;
148
+ if (!regionIsXY) { // rotate the region to be parallel to the xy-plane
149
+ regionXY = region.cloneTransformed(localToWorld.inverse());
150
+ if (!regionXY)
151
+ return undefined;
152
+ }
153
+ const momentData = RegionOps.computeXYAreaMoments(regionXY);
154
+ if (!momentData)
155
+ return undefined;
156
+ const centroid = momentData.origin.clone(result?.origin);
157
+ if (!regionIsXY) // rotate centroid back (area is unchanged)
158
+ localToWorld.multiplyPoint3d(centroid, centroid);
159
+ let area = momentData.sums.weight();
160
+ if (area < 0.0) {
161
+ area = -area;
162
+ normal.scale(-1.0, normal);
163
+ }
164
+ if (!result)
165
+ result = Ray3d_1.Ray3d.createCapture(centroid, normal);
166
+ result.a = area;
167
+ return result;
168
+ }
130
169
  /**
131
170
  * Create loops in the graph.
132
171
  * @internal
@@ -244,6 +283,28 @@ class RegionOps {
244
283
  const graph = RegionOpsClassificationSweeps_1.RegionOpsFaceToFaceSearch.doPolygonBoolean(loopsA, loopsB, (inA, inB) => (inA && !inB), this._graphCheckPointFunction);
245
284
  return this.finishGraphToPolyface(graph, triangulate);
246
285
  }
286
+ /**
287
+ * Simplify the type of the region by stripping redundant parent(s).
288
+ * * No Boolean operations are performed.
289
+ * * Invalid inputs (such as childless regions) are not corrected.
290
+ * @param region region to simplify
291
+ * @returns
292
+ * * For a [[UnionRegion]] with exactly one child, return it if it is a [[Loop]],
293
+ * or if it is a [[ParityRegion]] with multiple children, otherwise return the `ParityRegion`'s `Loop`.
294
+ * * For a `ParityRegion` with exactly one `Loop`, return it.
295
+ * * All other inputs returned unchanged.
296
+ */
297
+ static simplifyRegionType(region) {
298
+ if (region instanceof UnionRegion_1.UnionRegion) {
299
+ if (region.children.length === 1)
300
+ return this.simplifyRegionType(region.children[0]);
301
+ }
302
+ else if (region instanceof ParityRegion_1.ParityRegion) {
303
+ if (region.children.length === 1)
304
+ return region.children[0];
305
+ }
306
+ return region;
307
+ }
247
308
  /**
248
309
  * Return areas defined by a boolean operation.
249
310
  * @note For best results, input regions should have correctly oriented loops. See [[sortOuterAndHoleLoopsXY]].
@@ -257,8 +318,6 @@ class RegionOps {
257
318
  * to connect interior loops to exterior loops.
258
319
  */
259
320
  static regionBooleanXY(loopsA, loopsB, operation, mergeTolerance = Geometry_1.Geometry.smallMetricDistance) {
260
- // Always return UnionRegion for now. But keep return type as AnyRegion:
261
- // in the future, we might return the *simplest* region type.
262
321
  const result = UnionRegion_1.UnionRegion.create();
263
322
  const context = RegionOpsClassificationSweeps_1.RegionBooleanContext.create(RegionOpsClassificationSweeps_1.RegionGroupOpType.Union, RegionOpsClassificationSweeps_1.RegionGroupOpType.Union);
264
323
  context.addMembers(loopsA, loopsB);
@@ -277,7 +336,7 @@ class RegionOps {
277
336
  result.tryAddChild(loop);
278
337
  }
279
338
  });
280
- return result;
339
+ return result ? this.simplifyRegionType(result) : undefined;
281
340
  }
282
341
  /**
283
342
  * Return a polyface whose facets are a boolean operation between the input regions.
@@ -613,7 +672,8 @@ class RegionOps {
613
672
  * to the edge and a constituent curve in each.
614
673
  */
615
674
  static constructAllXYRegionLoops(curvesAndRegions, tolerance = Geometry_1.Geometry.smallMetricDistance) {
616
- const primitives = RegionOps.collectCurvePrimitives(curvesAndRegions, undefined, true, true);
675
+ let primitives = RegionOps.collectCurvePrimitives(curvesAndRegions, undefined, true, true);
676
+ primitives = TransferWithSplitArcs_1.TransferWithSplitArcs.clone(CurveCollection_1.BagOfCurves.create(...primitives)).children;
617
677
  const range = this.curveArrayRange(primitives);
618
678
  const areaTol = this.computeXYAreaTolerance(range, tolerance);
619
679
  const intersections = CurveCurve_1.CurveCurve.allIntersectionsAmongPrimitivesXY(primitives, tolerance);