@itwin/core-geometry 5.1.0-dev.1 → 5.1.0-dev.12

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 (72) 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/curve/RegionMomentsXY.d.ts +15 -21
  7. package/lib/cjs/curve/RegionMomentsXY.d.ts.map +1 -1
  8. package/lib/cjs/curve/RegionMomentsXY.js +40 -60
  9. package/lib/cjs/curve/RegionMomentsXY.js.map +1 -1
  10. package/lib/cjs/curve/RegionOps.d.ts +28 -11
  11. package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
  12. package/lib/cjs/curve/RegionOps.js +64 -17
  13. package/lib/cjs/curve/RegionOps.js.map +1 -1
  14. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +12 -13
  15. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
  16. package/lib/cjs/curve/RegionOpsClassificationSweeps.js +23 -23
  17. package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
  18. package/lib/cjs/curve/internalContexts/TransferWithSplitArcs.d.ts +14 -0
  19. package/lib/cjs/curve/internalContexts/TransferWithSplitArcs.d.ts.map +1 -0
  20. package/lib/cjs/curve/internalContexts/TransferWithSplitArcs.js +34 -0
  21. package/lib/cjs/curve/internalContexts/TransferWithSplitArcs.js.map +1 -0
  22. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  23. package/lib/cjs/geometry3d/Point3dVector3d.js +3 -3
  24. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  25. package/lib/cjs/geometry3d/PolygonOps.d.ts +8 -7
  26. package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
  27. package/lib/cjs/geometry3d/PolygonOps.js +19 -15
  28. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  29. package/lib/cjs/geometry4d/Matrix4d.d.ts +7 -7
  30. package/lib/cjs/geometry4d/Matrix4d.d.ts.map +1 -1
  31. package/lib/cjs/geometry4d/Matrix4d.js +9 -9
  32. package/lib/cjs/geometry4d/Matrix4d.js.map +1 -1
  33. package/lib/cjs/geometry4d/MomentData.d.ts +32 -34
  34. package/lib/cjs/geometry4d/MomentData.d.ts.map +1 -1
  35. package/lib/cjs/geometry4d/MomentData.js +56 -57
  36. package/lib/cjs/geometry4d/MomentData.js.map +1 -1
  37. package/lib/esm/bspline/BSplineSurface.d.ts +2 -1
  38. package/lib/esm/bspline/BSplineSurface.d.ts.map +1 -1
  39. package/lib/esm/bspline/BSplineSurface.js +2 -1
  40. package/lib/esm/bspline/BSplineSurface.js.map +1 -1
  41. package/lib/esm/curve/RegionMomentsXY.d.ts +15 -21
  42. package/lib/esm/curve/RegionMomentsXY.d.ts.map +1 -1
  43. package/lib/esm/curve/RegionMomentsXY.js +40 -60
  44. package/lib/esm/curve/RegionMomentsXY.js.map +1 -1
  45. package/lib/esm/curve/RegionOps.d.ts +28 -11
  46. package/lib/esm/curve/RegionOps.d.ts.map +1 -1
  47. package/lib/esm/curve/RegionOps.js +65 -18
  48. package/lib/esm/curve/RegionOps.js.map +1 -1
  49. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +12 -13
  50. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
  51. package/lib/esm/curve/RegionOpsClassificationSweeps.js +23 -23
  52. package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
  53. package/lib/esm/curve/internalContexts/TransferWithSplitArcs.d.ts +14 -0
  54. package/lib/esm/curve/internalContexts/TransferWithSplitArcs.d.ts.map +1 -0
  55. package/lib/esm/curve/internalContexts/TransferWithSplitArcs.js +30 -0
  56. package/lib/esm/curve/internalContexts/TransferWithSplitArcs.js.map +1 -0
  57. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  58. package/lib/esm/geometry3d/Point3dVector3d.js +3 -3
  59. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  60. package/lib/esm/geometry3d/PolygonOps.d.ts +8 -7
  61. package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
  62. package/lib/esm/geometry3d/PolygonOps.js +19 -15
  63. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  64. package/lib/esm/geometry4d/Matrix4d.d.ts +7 -7
  65. package/lib/esm/geometry4d/Matrix4d.d.ts.map +1 -1
  66. package/lib/esm/geometry4d/Matrix4d.js +9 -9
  67. package/lib/esm/geometry4d/Matrix4d.js.map +1 -1
  68. package/lib/esm/geometry4d/MomentData.d.ts +32 -34
  69. package/lib/esm/geometry4d/MomentData.d.ts.map +1 -1
  70. package/lib/esm/geometry4d/MomentData.js +56 -57
  71. package/lib/esm/geometry4d/MomentData.js.map +1 -1
  72. package/package.json +3 -3
@@ -10,7 +10,7 @@ const GeometryHandler_1 = require("../geometry3d/GeometryHandler");
10
10
  const Point3dVector3d_1 = require("../geometry3d/Point3dVector3d");
11
11
  const MomentData_1 = require("../geometry4d/MomentData");
12
12
  const LineString3d_1 = require("./LineString3d");
13
- const Loop_1 = require("./Loop");
13
+ const RegionOps_1 = require("./RegionOps");
14
14
  const StrokeOptions_1 = require("./StrokeOptions");
15
15
  /**
16
16
  * Implementation class for computing XY area moments.
@@ -20,15 +20,15 @@ class RegionMomentsXY extends GeometryHandler_1.NullGeometryHandler {
20
20
  _activeMomentData;
21
21
  _point0 = Point3dVector3d_1.Point3d.create();
22
22
  _point1 = Point3dVector3d_1.Point3d.create();
23
- /** Accumulate (independent) integrations over
24
- * * origin to chord of the arc.
25
- * * origin to the "cap" between the chord and arc.
23
+ /**
24
+ * Accumulate (independent) integrations over:
25
+ * * The area between the arc and the chord connecting its endpoints.
26
+ * * The triangle with vertices: origin, arc start, arc end.
26
27
  */
27
28
  handleArc3d(arc) {
28
29
  const momentData = this._activeMomentData;
29
30
  const sweepRadians = arc.sweep.sweepRadians;
30
31
  const alphaRadians = sweepRadians * 0.5;
31
- // from https://apps.dtic.mil/dtic/tr/fulltext/u2/274936.pdf page 71 for radius = 1
32
32
  let s = Math.sin(alphaRadians);
33
33
  let c = Math.cos(alphaRadians);
34
34
  let s1 = Math.sin(sweepRadians);
@@ -55,12 +55,12 @@ class RegionMomentsXY extends GeometryHandler_1.NullGeometryHandler {
55
55
  const pointC = arc.fractionToPoint(1.0);
56
56
  momentData.accumulateTriangleMomentsXY(undefined, pointB, pointC);
57
57
  }
58
- /** Accumulate integrals over the (triangular) areas from the origin to each line segment */
58
+ /** Accumulate integrals over the (triangular) areas from the origin to each line segment. */
59
59
  handleLineString3d(ls) {
60
60
  const momentData = this._activeMomentData;
61
61
  momentData.accumulateTriangleToLineStringMomentsXY(undefined, ls.packedPoints);
62
62
  }
63
- /** Accumulate integrals over the (triangular) area from the origin to this line segment */
63
+ /** Accumulate integrals over the (triangular) area from the origin to this line segment. */
64
64
  handleLineSegment3d(segment) {
65
65
  const momentData = this._activeMomentData;
66
66
  segment.startPoint(this._point0);
@@ -76,57 +76,31 @@ class RegionMomentsXY extends GeometryHandler_1.NullGeometryHandler {
76
76
  this._activeMomentData = undefined;
77
77
  return momentData;
78
78
  }
79
- /**
80
- * ASSUMPTIONS FOR ORIENTATION AND CONTAINMENT ISSUES
81
- * * Largest area is outer
82
- * * All others are interior (and not overlapping)
83
- * Hence
84
- * * Outer area sign must be positive -- negate all integrations as needed
85
- * * Outer area signs must be positive -- negate all integrations as needed
86
- * @param region
87
- */
88
- handleParityRegion(region) {
89
- const allChildMoments = [];
90
- let maxAbsArea = 0.0;
91
- let largestChildMoments;
92
- for (const child of region.children) {
93
- if (child instanceof Loop_1.Loop) {
94
- const childMoments = this.handleLoop(child);
79
+ handleAnyRegion(region) {
80
+ const summedMoments = MomentData_1.MomentData.create();
81
+ // guarantee there is no overlapping children
82
+ const merged = RegionOps_1.RegionOps.regionBooleanXY(region, undefined, RegionOps_1.RegionBinaryOpType.Union);
83
+ if (merged) {
84
+ for (const child of merged.children) {
85
+ const childMoments = child.dispatchToGeometryHandler(this);
95
86
  if (childMoments) {
96
- allChildMoments.push(childMoments);
97
- const q = Math.abs(childMoments.quantitySum);
98
- if (q > maxAbsArea) {
99
- maxAbsArea = q;
100
- largestChildMoments = childMoments;
101
- }
87
+ const sign0 = childMoments.signFactor(1.0);
88
+ summedMoments.accumulateProducts(childMoments, sign0);
102
89
  }
103
90
  }
104
91
  }
105
- if (largestChildMoments) {
106
- const summedMoments = MomentData_1.MomentData.create();
107
- const sign0 = largestChildMoments.signFactor(1.0);
108
- summedMoments.accumulateProducts(largestChildMoments, sign0);
109
- for (const childMoments of allChildMoments) {
110
- if (childMoments !== largestChildMoments) {
111
- const sign1 = childMoments.signFactor(-1.0);
112
- summedMoments.accumulateProducts(childMoments, sign1);
113
- }
114
- }
115
- return summedMoments;
92
+ else {
93
+ return undefined;
116
94
  }
117
- return undefined;
95
+ return summedMoments;
96
+ }
97
+ /** Accumulate integrals from origin to the components of the parity region. */
98
+ handleParityRegion(region) {
99
+ return this.handleAnyRegion(region);
118
100
  }
119
- /** Accumulate (as simple addition) products over each component of the union region. */
101
+ /** Accumulate integrals from origin to the components of the union region. */
120
102
  handleUnionRegion(region) {
121
- const summedMoments = MomentData_1.MomentData.create();
122
- for (const child of region.children) {
123
- const childMoments = child.dispatchToGeometryHandler(this);
124
- if (childMoments) {
125
- const sign0 = childMoments.signFactor(1.0);
126
- summedMoments.accumulateProducts(childMoments, sign0);
127
- }
128
- }
129
- return summedMoments;
103
+ return this.handleAnyRegion(region);
130
104
  }
131
105
  _strokeOptions;
132
106
  getStrokeOptions() {
@@ -138,9 +112,9 @@ class RegionMomentsXY extends GeometryHandler_1.NullGeometryHandler {
138
112
  this._strokeOptions = options;
139
113
  return options;
140
114
  }
141
- /** Single curve primitive (not loop . . .).
142
- * * stroke the curve
143
- * * accumulate stroke array.
115
+ /**
116
+ * Handle a single curve primitive (not loop).
117
+ * * Stroke the curve and accumulate stroke array.
144
118
  */
145
119
  handleCurvePrimitive(cp) {
146
120
  const strokes = LineString3d_1.LineString3d.create();
@@ -148,12 +122,18 @@ class RegionMomentsXY extends GeometryHandler_1.NullGeometryHandler {
148
122
  cp.emitStrokes(strokes, options);
149
123
  this.handleLineString3d(strokes);
150
124
  }
151
- /** handle strongly typed BSplineCurve3d as generic curve primitive */
152
- handleBSplineCurve3d(g) { return this.handleCurvePrimitive(g); }
153
- /** handle strongly typed BSplineCurve3dH as generic curve primitive */
154
- handleBSplineCurve3dH(g) { return this.handleCurvePrimitive(g); }
155
- /** handle strongly typed TransitionSpiral as generic curve primitive */
156
- handleTransitionSpiral(g) { return this.handleCurvePrimitive(g); }
125
+ /** Handle strongly typed BSplineCurve3d as generic curve primitive. */
126
+ handleBSplineCurve3d(g) {
127
+ return this.handleCurvePrimitive(g);
128
+ }
129
+ /** Handle strongly typed BSplineCurve3dH as generic curve primitive. */
130
+ handleBSplineCurve3dH(g) {
131
+ return this.handleCurvePrimitive(g);
132
+ }
133
+ /** Handle strongly typed TransitionSpiral as generic curve primitive. */
134
+ handleTransitionSpiral(g) {
135
+ return this.handleCurvePrimitive(g);
136
+ }
157
137
  }
158
138
  exports.RegionMomentsXY = RegionMomentsXY;
159
139
  //# sourceMappingURL=RegionMomentsXY.js.map
@@ -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,MA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C,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,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;AAG9C,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,YA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ChD,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,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IACD,0EAA0E;IAC1D,qBAAqB,CAAC,CAAkB;QACtD,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IACD,0EAA0E;IAC1D,sBAAsB,CAAC,CAAqB;QAC1D,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IACtC,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 const summedMoments = MomentData.create();\n // guarantee there is no overlapping children\n const merged = RegionOps.regionBooleanXY(region, undefined, RegionBinaryOpType.Union);\n if (merged) {\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 } else {\n return undefined;\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) {\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) {\n return this.handleCurvePrimitive(g);\n }\n /** Handle strongly typed BSplineCurve3dH as generic curve primitive. */\n public override handleBSplineCurve3dH(g: BSplineCurve3dH) {\n return this.handleCurvePrimitive(g);\n }\n /** Handle strongly typed TransitionSpiral as generic curve primitive. */\n public override handleTransitionSpiral(g: TransitionSpiral3d) {\n return 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";
@@ -47,30 +48,46 @@ export declare enum RegionBinaryOpType {
47
48
  export declare class RegionOps {
48
49
  /**
49
50
  * Return moment sums for a loop, parity region, or union region.
51
+ * * The input region should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
50
52
  * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with
51
- * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
52
- * @param root any Loop, ParityRegion, or UnionRegion.
53
+ * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes(rawMomentData.origin, rawMomentData.sums);`
54
+ * * `rawMomentData.origin` is the centroid of `region`.
55
+ * * `rawMomentData.sums.weight()` is the signed area of `region`.
56
+ * @param region any [[Loop]], [[ParityRegion]], or [[UnionRegion]].
53
57
  */
54
- static computeXYAreaMoments(root: AnyRegion): MomentData | undefined;
58
+ static computeXYAreaMoments(region: AnyRegion): MomentData | undefined;
55
59
  /**
56
60
  * Return an area tolerance for a given xy-range and optional distance tolerance.
57
- * @param range range of planar region to tolerance
58
- * @param distanceTolerance optional absolute distance tolerance
61
+ * @param range range of planar region to tolerance.
62
+ * @param distanceTolerance optional absolute distance tolerance.
59
63
  */
60
64
  static computeXYAreaTolerance(range: Range3d, distanceTolerance?: number): number;
61
65
  /**
62
66
  * Return a (signed) xy area for a region.
67
+ * * The input region should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
63
68
  * * The area is negative if and only if the region is oriented clockwise with respect to the positive z-axis.
64
- * @param root any Loop, ParityRegion, or UnionRegion.
69
+ * @param region any [[Loop]], [[ParityRegion]], or [[UnionRegion]].
65
70
  */
66
- static computeXYArea(root: AnyRegion): number | undefined;
71
+ static computeXYArea(region: AnyRegion): number | undefined;
67
72
  /**
68
73
  * Return MomentData with the sums of wire moments.
74
+ * * The input curve should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
69
75
  * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with
70
- * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
71
- * @param root any CurveCollection or CurvePrimitive.
76
+ * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
77
+ * * `rawMomentData.origin` is the wire centroid of `curve`.
78
+ * * `rawMomentData.sums.weight()` is the signed length of `curve`.
79
+ * @param curve any [[CurveCollection]] or [[CurvePrimitive]].
72
80
  */
73
- static computeXYZWireMomentSums(root: AnyCurve): MomentData | undefined;
81
+ static computeXYZWireMomentSums(curve: AnyCurve): MomentData | undefined;
82
+ /**
83
+ * Return a [[Ray3d]] with:
84
+ * * `origin` is the centroid of the region,
85
+ * * `direction` is a unit vector perpendicular to the region plane,
86
+ * * `a` is the region area.
87
+ * @param region the region to process. Can lie in any plane.
88
+ * @param result optional pre-allocated result to populate and return.
89
+ */
90
+ static centroidAreaNormal(region: AnyRegion, result?: Ray3d): Ray3d | undefined;
74
91
  /**
75
92
  * Create loops in the graph.
76
93
  * @internal
@@ -305,7 +322,7 @@ export declare class RegionOps {
305
322
  * SignedLoops object.
306
323
  * @param curvesAndRegions Any collection of curves. Each Loop/ParityRegion/UnionRegion contributes its curve
307
324
  * primitives.
308
- * @param tolerance optional distance tolerance for coincidence
325
+ * @param tolerance optional distance tolerance for coincidence.
309
326
  * @returns array of [[SignedLoops]], each entry of which describes the faces in a single connected component:
310
327
  * * `positiveAreaLoops` contains "interior" loops, _including holes in ParityRegion input_. These loops have
311
328
  * positive area and counterclockwise orientation.
@@ -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,OAAO,EAC0B,oBAAoB,EAAyB,0BAA0B,EACvG,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAGxD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,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,EAAE,MAAM,mBAAmB,CAAC;AAG7E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;A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BpG;;;;;MAKE;WACY,wBAAwB,CAAC,OAAO,EAAE,0BAA0B,EAAE,QAAQ,GAAE,OAAc,GAAG,gBAAgB,EAAE,GAAG,SAAS;CActI;AAaD;;;GAGG;AACH,qBAAa,yCAAyC;IACpD,8EAA8E;IACvE,yBAAyB,EAAE,OAAO,CAAQ;IACjD,yEAAyE;IAClE,yBAAyB,EAAE,OAAO,CAAQ;IACjD,gDAAgD;IACzC,uBAAuB,SAAgC;IAC9D,uDAAuD;IAChD,sBAAsB,SAAgC;CAC9D"}
@@ -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");
@@ -70,13 +73,16 @@ var RegionBinaryOpType;
70
73
  class RegionOps {
71
74
  /**
72
75
  * Return moment sums for a loop, parity region, or union region.
76
+ * * The input region should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
73
77
  * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with
74
- * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
75
- * @param root any Loop, ParityRegion, or UnionRegion.
78
+ * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes(rawMomentData.origin, rawMomentData.sums);`
79
+ * * `rawMomentData.origin` is the centroid of `region`.
80
+ * * `rawMomentData.sums.weight()` is the signed area of `region`.
81
+ * @param region any [[Loop]], [[ParityRegion]], or [[UnionRegion]].
76
82
  */
77
- static computeXYAreaMoments(root) {
83
+ static computeXYAreaMoments(region) {
78
84
  const handler = new RegionMomentsXY_1.RegionMomentsXY();
79
- const result = root.dispatchToGeometryHandler(handler);
85
+ const result = region.dispatchToGeometryHandler(handler);
80
86
  if (result instanceof MomentData_1.MomentData) {
81
87
  result.shiftOriginAndSumsToCentroidOfSums();
82
88
  return result;
@@ -85,8 +91,8 @@ class RegionOps {
85
91
  }
86
92
  /**
87
93
  * Return an area tolerance for a given xy-range and optional distance tolerance.
88
- * @param range range of planar region to tolerance
89
- * @param distanceTolerance optional absolute distance tolerance
94
+ * @param range range of planar region to tolerance.
95
+ * @param distanceTolerance optional absolute distance tolerance.
90
96
  */
91
97
  static computeXYAreaTolerance(range, distanceTolerance = Geometry_1.Geometry.smallMetricDistance) {
92
98
  // 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).
@@ -95,12 +101,13 @@ class RegionOps {
95
101
  }
96
102
  /**
97
103
  * Return a (signed) xy area for a region.
104
+ * * The input region should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
98
105
  * * The area is negative if and only if the region is oriented clockwise with respect to the positive z-axis.
99
- * @param root any Loop, ParityRegion, or UnionRegion.
106
+ * @param region any [[Loop]], [[ParityRegion]], or [[UnionRegion]].
100
107
  */
101
- static computeXYArea(root) {
108
+ static computeXYArea(region) {
102
109
  const handler = new RegionMomentsXY_1.RegionMomentsXY();
103
- const result = root.dispatchToGeometryHandler(handler);
110
+ const result = region.dispatchToGeometryHandler(handler);
104
111
  if (result instanceof MomentData_1.MomentData) {
105
112
  return result.quantitySum;
106
113
  }
@@ -108,17 +115,56 @@ class RegionOps {
108
115
  }
109
116
  /**
110
117
  * Return MomentData with the sums of wire moments.
118
+ * * The input curve should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
111
119
  * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with
112
- * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
113
- * @param root any CurveCollection or CurvePrimitive.
120
+ * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
121
+ * * `rawMomentData.origin` is the wire centroid of `curve`.
122
+ * * `rawMomentData.sums.weight()` is the signed length of `curve`.
123
+ * @param curve any [[CurveCollection]] or [[CurvePrimitive]].
114
124
  */
115
- static computeXYZWireMomentSums(root) {
125
+ static computeXYZWireMomentSums(curve) {
116
126
  const handler = new CurveWireMomentsXYZ_1.CurveWireMomentsXYZ();
117
- handler.visitLeaves(root);
127
+ handler.visitLeaves(curve);
118
128
  const result = handler.momentData;
119
129
  result.shiftOriginAndSumsToCentroidOfSums();
120
130
  return result;
121
131
  }
132
+ /**
133
+ * Return a [[Ray3d]] with:
134
+ * * `origin` is the centroid of the region,
135
+ * * `direction` is a unit vector perpendicular to the region plane,
136
+ * * `a` is the region area.
137
+ * @param region the region to process. Can lie in any plane.
138
+ * @param result optional pre-allocated result to populate and return.
139
+ */
140
+ static centroidAreaNormal(region, result) {
141
+ const localToWorld = FrameBuilder_1.FrameBuilder.createRightHandedFrame(undefined, region);
142
+ if (!localToWorld)
143
+ return undefined;
144
+ const normal = localToWorld.matrix.columnZ(result?.direction);
145
+ const regionIsXY = normal.isParallelTo(Point3dVector3d_1.Vector3d.unitZ(), true);
146
+ let regionXY = region;
147
+ if (!regionIsXY) { // rotate the region to be parallel to the xy-plane
148
+ regionXY = region.cloneTransformed(localToWorld.inverse());
149
+ if (!regionXY)
150
+ return undefined;
151
+ }
152
+ const momentData = RegionOps.computeXYAreaMoments(regionXY);
153
+ if (!momentData)
154
+ return undefined;
155
+ const centroid = momentData.origin.clone(result?.origin);
156
+ if (!regionIsXY) // rotate centroid back (area is unchanged)
157
+ localToWorld.multiplyPoint3d(centroid, centroid);
158
+ let area = momentData.sums.weight();
159
+ if (area < 0.0) {
160
+ area = -area;
161
+ normal.scale(-1.0, normal);
162
+ }
163
+ if (!result)
164
+ result = Ray3d_1.Ray3d.createCapture(centroid, normal);
165
+ result.a = area;
166
+ return result;
167
+ }
122
168
  /**
123
169
  * Create loops in the graph.
124
170
  * @internal
@@ -248,8 +294,8 @@ class RegionOps {
248
294
  * to connect interior loops to exterior loops.
249
295
  */
250
296
  static regionBooleanXY(loopsA, loopsB, operation, mergeTolerance = Geometry_1.Geometry.smallMetricDistance) {
251
- // Always return UnionRegion for now. But keep return type as AnyRegion:
252
- // in the future, we might return the *simplest* region type.
297
+ // Always return UnionRegion for now, but keep return type as AnyRegion.
298
+ // In the future, we might return the *simplest* region type.
253
299
  const result = UnionRegion_1.UnionRegion.create();
254
300
  const context = RegionOpsClassificationSweeps_1.RegionBooleanContext.create(RegionOpsClassificationSweeps_1.RegionGroupOpType.Union, RegionOpsClassificationSweeps_1.RegionGroupOpType.Union);
255
301
  context.addMembers(loopsA, loopsB);
@@ -593,7 +639,7 @@ class RegionOps {
593
639
  * SignedLoops object.
594
640
  * @param curvesAndRegions Any collection of curves. Each Loop/ParityRegion/UnionRegion contributes its curve
595
641
  * primitives.
596
- * @param tolerance optional distance tolerance for coincidence
642
+ * @param tolerance optional distance tolerance for coincidence.
597
643
  * @returns array of [[SignedLoops]], each entry of which describes the faces in a single connected component:
598
644
  * * `positiveAreaLoops` contains "interior" loops, _including holes in ParityRegion input_. These loops have
599
645
  * positive area and counterclockwise orientation.
@@ -603,7 +649,8 @@ class RegionOps {
603
649
  * to the edge and a constituent curve in each.
604
650
  */
605
651
  static constructAllXYRegionLoops(curvesAndRegions, tolerance = Geometry_1.Geometry.smallMetricDistance) {
606
- const primitives = RegionOps.collectCurvePrimitives(curvesAndRegions, undefined, true, true);
652
+ let primitives = RegionOps.collectCurvePrimitives(curvesAndRegions, undefined, true, true);
653
+ primitives = TransferWithSplitArcs_1.TransferWithSplitArcs.clone(CurveCollection_1.BagOfCurves.create(...primitives)).children;
607
654
  const range = this.curveArrayRange(primitives);
608
655
  const areaTol = this.computeXYAreaTolerance(range, tolerance);
609
656
  const intersections = CurveCurve_1.CurveCurve.allIntersectionsAmongPrimitivesXY(primitives, tolerance);