@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
@@ -7,7 +7,7 @@ import { NullGeometryHandler } from "../geometry3d/GeometryHandler";
7
7
  import { Point3d } from "../geometry3d/Point3dVector3d";
8
8
  import { MomentData } from "../geometry4d/MomentData";
9
9
  import { LineString3d } from "./LineString3d";
10
- import { Loop } from "./Loop";
10
+ import { RegionBinaryOpType, RegionOps } from "./RegionOps";
11
11
  import { StrokeOptions } from "./StrokeOptions";
12
12
  /**
13
13
  * Implementation class for computing XY area moments.
@@ -17,15 +17,15 @@ export class RegionMomentsXY extends NullGeometryHandler {
17
17
  _activeMomentData;
18
18
  _point0 = Point3d.create();
19
19
  _point1 = Point3d.create();
20
- /** Accumulate (independent) integrations over
21
- * * origin to chord of the arc.
22
- * * origin to the "cap" between the chord and arc.
20
+ /**
21
+ * Accumulate (independent) integrations over:
22
+ * * The area between the arc and the chord connecting its endpoints.
23
+ * * The triangle with vertices: origin, arc start, arc end.
23
24
  */
24
25
  handleArc3d(arc) {
25
26
  const momentData = this._activeMomentData;
26
27
  const sweepRadians = arc.sweep.sweepRadians;
27
28
  const alphaRadians = sweepRadians * 0.5;
28
- // from https://apps.dtic.mil/dtic/tr/fulltext/u2/274936.pdf page 71 for radius = 1
29
29
  let s = Math.sin(alphaRadians);
30
30
  let c = Math.cos(alphaRadians);
31
31
  let s1 = Math.sin(sweepRadians);
@@ -52,12 +52,12 @@ export class RegionMomentsXY extends NullGeometryHandler {
52
52
  const pointC = arc.fractionToPoint(1.0);
53
53
  momentData.accumulateTriangleMomentsXY(undefined, pointB, pointC);
54
54
  }
55
- /** Accumulate integrals over the (triangular) areas from the origin to each line segment */
55
+ /** Accumulate integrals over the (triangular) areas from the origin to each line segment. */
56
56
  handleLineString3d(ls) {
57
57
  const momentData = this._activeMomentData;
58
58
  momentData.accumulateTriangleToLineStringMomentsXY(undefined, ls.packedPoints);
59
59
  }
60
- /** Accumulate integrals over the (triangular) area from the origin to this line segment */
60
+ /** Accumulate integrals over the (triangular) area from the origin to this line segment. */
61
61
  handleLineSegment3d(segment) {
62
62
  const momentData = this._activeMomentData;
63
63
  segment.startPoint(this._point0);
@@ -73,57 +73,31 @@ export class RegionMomentsXY extends NullGeometryHandler {
73
73
  this._activeMomentData = undefined;
74
74
  return momentData;
75
75
  }
76
- /**
77
- * ASSUMPTIONS FOR ORIENTATION AND CONTAINMENT ISSUES
78
- * * Largest area is outer
79
- * * All others are interior (and not overlapping)
80
- * Hence
81
- * * Outer area sign must be positive -- negate all integrations as needed
82
- * * Outer area signs must be positive -- negate all integrations as needed
83
- * @param region
84
- */
85
- handleParityRegion(region) {
86
- const allChildMoments = [];
87
- let maxAbsArea = 0.0;
88
- let largestChildMoments;
89
- for (const child of region.children) {
90
- if (child instanceof Loop) {
91
- const childMoments = this.handleLoop(child);
76
+ handleAnyRegion(region) {
77
+ const summedMoments = MomentData.create();
78
+ // guarantee there is no overlapping children
79
+ const merged = RegionOps.regionBooleanXY(region, undefined, RegionBinaryOpType.Union);
80
+ if (merged) {
81
+ for (const child of merged.children) {
82
+ const childMoments = child.dispatchToGeometryHandler(this);
92
83
  if (childMoments) {
93
- allChildMoments.push(childMoments);
94
- const q = Math.abs(childMoments.quantitySum);
95
- if (q > maxAbsArea) {
96
- maxAbsArea = q;
97
- largestChildMoments = childMoments;
98
- }
84
+ const sign0 = childMoments.signFactor(1.0);
85
+ summedMoments.accumulateProducts(childMoments, sign0);
99
86
  }
100
87
  }
101
88
  }
102
- if (largestChildMoments) {
103
- const summedMoments = MomentData.create();
104
- const sign0 = largestChildMoments.signFactor(1.0);
105
- summedMoments.accumulateProducts(largestChildMoments, sign0);
106
- for (const childMoments of allChildMoments) {
107
- if (childMoments !== largestChildMoments) {
108
- const sign1 = childMoments.signFactor(-1.0);
109
- summedMoments.accumulateProducts(childMoments, sign1);
110
- }
111
- }
112
- return summedMoments;
89
+ else {
90
+ return undefined;
113
91
  }
114
- return undefined;
92
+ return summedMoments;
93
+ }
94
+ /** Accumulate integrals from origin to the components of the parity region. */
95
+ handleParityRegion(region) {
96
+ return this.handleAnyRegion(region);
115
97
  }
116
- /** Accumulate (as simple addition) products over each component of the union region. */
98
+ /** Accumulate integrals from origin to the components of the union region. */
117
99
  handleUnionRegion(region) {
118
- const summedMoments = MomentData.create();
119
- for (const child of region.children) {
120
- const childMoments = child.dispatchToGeometryHandler(this);
121
- if (childMoments) {
122
- const sign0 = childMoments.signFactor(1.0);
123
- summedMoments.accumulateProducts(childMoments, sign0);
124
- }
125
- }
126
- return summedMoments;
100
+ return this.handleAnyRegion(region);
127
101
  }
128
102
  _strokeOptions;
129
103
  getStrokeOptions() {
@@ -135,9 +109,9 @@ export class RegionMomentsXY extends NullGeometryHandler {
135
109
  this._strokeOptions = options;
136
110
  return options;
137
111
  }
138
- /** Single curve primitive (not loop . . .).
139
- * * stroke the curve
140
- * * accumulate stroke array.
112
+ /**
113
+ * Handle a single curve primitive (not loop).
114
+ * * Stroke the curve and accumulate stroke array.
141
115
  */
142
116
  handleCurvePrimitive(cp) {
143
117
  const strokes = LineString3d.create();
@@ -145,11 +119,17 @@ export class RegionMomentsXY extends NullGeometryHandler {
145
119
  cp.emitStrokes(strokes, options);
146
120
  this.handleLineString3d(strokes);
147
121
  }
148
- /** handle strongly typed BSplineCurve3d as generic curve primitive */
149
- handleBSplineCurve3d(g) { return this.handleCurvePrimitive(g); }
150
- /** handle strongly typed BSplineCurve3dH as generic curve primitive */
151
- handleBSplineCurve3dH(g) { return this.handleCurvePrimitive(g); }
152
- /** handle strongly typed TransitionSpiral as generic curve primitive */
153
- handleTransitionSpiral(g) { return this.handleCurvePrimitive(g); }
122
+ /** Handle strongly typed BSplineCurve3d as generic curve primitive. */
123
+ handleBSplineCurve3d(g) {
124
+ return this.handleCurvePrimitive(g);
125
+ }
126
+ /** Handle strongly typed BSplineCurve3dH as generic curve primitive. */
127
+ handleBSplineCurve3dH(g) {
128
+ return this.handleCurvePrimitive(g);
129
+ }
130
+ /** Handle strongly typed TransitionSpiral as generic curve primitive. */
131
+ handleTransitionSpiral(g) {
132
+ return this.handleCurvePrimitive(g);
133
+ }
154
134
  }
155
135
  //# 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,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,eAAg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AAO,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,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;AAG9C,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD;;;GAGG;AACH,MA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CAAC,eAAe,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,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","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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AS,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;;;;;;;;;;;OAWG;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,8EAA8E;IACvE,yBAAyB,EAAE,OAAO,CAAQ;IACjD,yEAAyE;IAClE,yBAAyB,EAAE,OAAO,CAAQ;IACjD,gDAAgD;IACzC,uBAAuB,SAAgC;IAC9D,uDAAuD;IAChD,sBAAsB,SAAgC;CAC9D"}
@@ -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";
@@ -67,13 +70,16 @@ export var RegionBinaryOpType;
67
70
  export class RegionOps {
68
71
  /**
69
72
  * Return moment sums for a loop, parity region, or union region.
73
+ * * The input region should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
70
74
  * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with
71
- * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
72
- * @param root any Loop, ParityRegion, or UnionRegion.
75
+ * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes(rawMomentData.origin, rawMomentData.sums);`
76
+ * * `rawMomentData.origin` is the centroid of `region`.
77
+ * * `rawMomentData.sums.weight()` is the signed area of `region`.
78
+ * @param region any [[Loop]], [[ParityRegion]], or [[UnionRegion]].
73
79
  */
74
- static computeXYAreaMoments(root) {
80
+ static computeXYAreaMoments(region) {
75
81
  const handler = new RegionMomentsXY();
76
- const result = root.dispatchToGeometryHandler(handler);
82
+ const result = region.dispatchToGeometryHandler(handler);
77
83
  if (result instanceof MomentData) {
78
84
  result.shiftOriginAndSumsToCentroidOfSums();
79
85
  return result;
@@ -82,8 +88,8 @@ export class RegionOps {
82
88
  }
83
89
  /**
84
90
  * Return an area tolerance for a given xy-range and optional distance tolerance.
85
- * @param range range of planar region to tolerance
86
- * @param distanceTolerance optional absolute distance tolerance
91
+ * @param range range of planar region to tolerance.
92
+ * @param distanceTolerance optional absolute distance tolerance.
87
93
  */
88
94
  static computeXYAreaTolerance(range, distanceTolerance = Geometry.smallMetricDistance) {
89
95
  // 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).
@@ -92,12 +98,13 @@ export class RegionOps {
92
98
  }
93
99
  /**
94
100
  * Return a (signed) xy area for a region.
101
+ * * The input region should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
95
102
  * * The area is negative if and only if the region is oriented clockwise with respect to the positive z-axis.
96
- * @param root any Loop, ParityRegion, or UnionRegion.
103
+ * @param region any [[Loop]], [[ParityRegion]], or [[UnionRegion]].
97
104
  */
98
- static computeXYArea(root) {
105
+ static computeXYArea(region) {
99
106
  const handler = new RegionMomentsXY();
100
- const result = root.dispatchToGeometryHandler(handler);
107
+ const result = region.dispatchToGeometryHandler(handler);
101
108
  if (result instanceof MomentData) {
102
109
  return result.quantitySum;
103
110
  }
@@ -105,17 +112,56 @@ export class RegionOps {
105
112
  }
106
113
  /**
107
114
  * Return MomentData with the sums of wire moments.
115
+ * * The input curve should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
108
116
  * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with
109
- * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
110
- * @param root any CurveCollection or CurvePrimitive.
117
+ * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
118
+ * * `rawMomentData.origin` is the wire centroid of `curve`.
119
+ * * `rawMomentData.sums.weight()` is the signed length of `curve`.
120
+ * @param curve any [[CurveCollection]] or [[CurvePrimitive]].
111
121
  */
112
- static computeXYZWireMomentSums(root) {
122
+ static computeXYZWireMomentSums(curve) {
113
123
  const handler = new CurveWireMomentsXYZ();
114
- handler.visitLeaves(root);
124
+ handler.visitLeaves(curve);
115
125
  const result = handler.momentData;
116
126
  result.shiftOriginAndSumsToCentroidOfSums();
117
127
  return result;
118
128
  }
129
+ /**
130
+ * Return a [[Ray3d]] with:
131
+ * * `origin` is the centroid of the region,
132
+ * * `direction` is a unit vector perpendicular to the region plane,
133
+ * * `a` is the region area.
134
+ * @param region the region to process. Can lie in any plane.
135
+ * @param result optional pre-allocated result to populate and return.
136
+ */
137
+ static centroidAreaNormal(region, result) {
138
+ const localToWorld = FrameBuilder.createRightHandedFrame(undefined, region);
139
+ if (!localToWorld)
140
+ return undefined;
141
+ const normal = localToWorld.matrix.columnZ(result?.direction);
142
+ const regionIsXY = normal.isParallelTo(Vector3d.unitZ(), true);
143
+ let regionXY = region;
144
+ if (!regionIsXY) { // rotate the region to be parallel to the xy-plane
145
+ regionXY = region.cloneTransformed(localToWorld.inverse());
146
+ if (!regionXY)
147
+ return undefined;
148
+ }
149
+ const momentData = RegionOps.computeXYAreaMoments(regionXY);
150
+ if (!momentData)
151
+ return undefined;
152
+ const centroid = momentData.origin.clone(result?.origin);
153
+ if (!regionIsXY) // rotate centroid back (area is unchanged)
154
+ localToWorld.multiplyPoint3d(centroid, centroid);
155
+ let area = momentData.sums.weight();
156
+ if (area < 0.0) {
157
+ area = -area;
158
+ normal.scale(-1.0, normal);
159
+ }
160
+ if (!result)
161
+ result = Ray3d.createCapture(centroid, normal);
162
+ result.a = area;
163
+ return result;
164
+ }
119
165
  /**
120
166
  * Create loops in the graph.
121
167
  * @internal
@@ -245,8 +291,8 @@ export class RegionOps {
245
291
  * to connect interior loops to exterior loops.
246
292
  */
247
293
  static regionBooleanXY(loopsA, loopsB, operation, mergeTolerance = Geometry.smallMetricDistance) {
248
- // Always return UnionRegion for now. But keep return type as AnyRegion:
249
- // in the future, we might return the *simplest* region type.
294
+ // Always return UnionRegion for now, but keep return type as AnyRegion.
295
+ // In the future, we might return the *simplest* region type.
250
296
  const result = UnionRegion.create();
251
297
  const context = RegionBooleanContext.create(RegionGroupOpType.Union, RegionGroupOpType.Union);
252
298
  context.addMembers(loopsA, loopsB);
@@ -590,7 +636,7 @@ export class RegionOps {
590
636
  * SignedLoops object.
591
637
  * @param curvesAndRegions Any collection of curves. Each Loop/ParityRegion/UnionRegion contributes its curve
592
638
  * primitives.
593
- * @param tolerance optional distance tolerance for coincidence
639
+ * @param tolerance optional distance tolerance for coincidence.
594
640
  * @returns array of [[SignedLoops]], each entry of which describes the faces in a single connected component:
595
641
  * * `positiveAreaLoops` contains "interior" loops, _including holes in ParityRegion input_. These loops have
596
642
  * positive area and counterclockwise orientation.
@@ -600,7 +646,8 @@ export class RegionOps {
600
646
  * to the edge and a constituent curve in each.
601
647
  */
602
648
  static constructAllXYRegionLoops(curvesAndRegions, tolerance = Geometry.smallMetricDistance) {
603
- const primitives = RegionOps.collectCurvePrimitives(curvesAndRegions, undefined, true, true);
649
+ let primitives = RegionOps.collectCurvePrimitives(curvesAndRegions, undefined, true, true);
650
+ primitives = TransferWithSplitArcs.clone(BagOfCurves.create(...primitives)).children;
604
651
  const range = this.curveArrayRange(primitives);
605
652
  const areaTol = this.computeXYAreaTolerance(range, tolerance);
606
653
  const intersections = CurveCurve.allIntersectionsAmongPrimitivesXY(primitives, tolerance);