@itwin/core-geometry 5.12.0-dev.12 → 5.12.0-dev.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +81 -57
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/cjs/geometry3d/Transform.d.ts +1 -4
- package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Transform.js +1 -4
- package/lib/cjs/geometry3d/Transform.js.map +1 -1
- package/lib/cjs/numerics/Polynomials.d.ts +3 -3
- package/lib/cjs/numerics/Polynomials.js +5 -5
- package/lib/cjs/numerics/Polynomials.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +81 -57
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/esm/geometry3d/Transform.d.ts +1 -4
- package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
- package/lib/esm/geometry3d/Transform.js +1 -4
- package/lib/esm/geometry3d/Transform.js.map +1 -1
- package/lib/esm/numerics/Polynomials.d.ts +3 -3
- package/lib/esm/numerics/Polynomials.js +5 -5
- package/lib/esm/numerics/Polynomials.js.map +1 -1
- package/package.json +3 -3
|
@@ -74,7 +74,7 @@ export declare class CurveCurveIntersectXY extends RecurseToCurvesGeometryHandle
|
|
|
74
74
|
*/
|
|
75
75
|
grabPairedResults(reinitialize?: boolean): CurveLocationDetailPair[];
|
|
76
76
|
/**
|
|
77
|
-
* Record the pre-computed intersection between two curves.
|
|
77
|
+
* Record the pre-computed intersection between two curves. Record with fraction mapping.
|
|
78
78
|
* @param localFractionA intersection fraction local to the subcurve of cpA between fractionA0 and fractionA1
|
|
79
79
|
* @param cpA the first curve
|
|
80
80
|
* @param fractionA0 start of the subcurve of cpA
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurveCurveIntersectXY.d.ts","sourceRoot":"","sources":["../../../../src/curve/internalContexts/CurveCurveIntersectXY.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,cAAc,EAAsB,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAOlF,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAMrD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAG7E,OAAO,EAA0C,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACzG,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAIlE;;;;;GAKG;AACH,qBAAa,qBAAsB,SAAQ,8BAA8B;IACvE,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,wBAAwB,CAAuB;IACvD,OAAO,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E,OAAO,GAChB,GAAG;IAqBN,iEAAiE;IACjE,OAAO,CAAC,2BAA2B;IAqCnC,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAQvC;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAyB/B;;;OAGG;IACH,OAAO,CAAC,mCAAmC;IAe3C;;;;;;;OAOG;IACH,OAAO,CAAC,2BAA2B;IA0CnC;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAKnB,mHAAmH;IACnH,OAAO,CAAC,2BAA2B;IAuBnC;;;OAGG;IACH,OAAO,CAAC,iCAAiC;IAmBzC;;;;OAIG;IACH,OAAO,CAAC,kCAAkC;IAW1C;;;;;;;;OAQG;IACH,OAAO,CAAC,mBAAmB;IAgB3B;;;MAGE;IACc,cAAc,CAAC,CAAC,EAAE,aAAa,GAAG,GAAG;IAwBrD,0DAA0D;IAC1C,mBAAmB,CAAC,QAAQ,EAAE,aAAa,GAAG,GAAG;IA+BjE,6DAA6D;IAC7C,kBAAkB,CAAC,GAAG,EAAE,YAAY,GAAG,GAAG;IAyB1D,sDAAsD;IACtC,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,GAAG;IAyB7C,gEAAgE;IAChD,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,GAAG;IAyBjE,+DAA+D;IAC/C,sBAAsB,CAAC,MAAM,EAAE,kBAAkB,GAAG,GAAG;IAUvE,8EAA8E;IAC9D,iCAAiC,CAAC,KAAK,EAAE,2BAA2B,GAAG,GAAG;IAK1F,4EAA4E;IAC5D,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,GAAG;CAKpE"}
|
|
@@ -125,12 +125,14 @@ class CurveCurveIntersectXY extends GeometryHandler_1.RecurseToCurvesGeometryHan
|
|
|
125
125
|
return true;
|
|
126
126
|
}
|
|
127
127
|
/** Test the fraction by strict parameter, but allow toleranced distance test at ends. */
|
|
128
|
-
acceptFractionOnLine(extend0, fraction, extend1, pointA, pointB
|
|
128
|
+
acceptFractionOnLine(extend0, fraction, extend1, pointA, pointB) {
|
|
129
129
|
if (!extend0 && fraction < 0) {
|
|
130
|
-
return Geometry_1.Geometry.isDistanceWithinTol(fraction * pointA.
|
|
130
|
+
return Geometry_1.Geometry.isDistanceWithinTol(fraction * fraction * pointA.distanceSquaredXY(pointB), this._coincidentGeometryContext.tolerance * this._coincidentGeometryContext.tolerance);
|
|
131
|
+
}
|
|
132
|
+
else if (!extend1 && fraction > 1.0) {
|
|
133
|
+
const f = fraction - 1;
|
|
134
|
+
return Geometry_1.Geometry.isDistanceWithinTol(f * f * pointA.distanceSquaredXY(pointB), this._coincidentGeometryContext.tolerance * this._coincidentGeometryContext.tolerance);
|
|
131
135
|
}
|
|
132
|
-
else if (!extend1 && fraction > 1.0)
|
|
133
|
-
return Geometry_1.Geometry.isDistanceWithinTol((fraction - 1.0) * pointA.distanceXY(pointB), tolerance);
|
|
134
136
|
return true;
|
|
135
137
|
}
|
|
136
138
|
/**
|
|
@@ -144,7 +146,7 @@ class CurveCurveIntersectXY extends GeometryHandler_1.RecurseToCurvesGeometryHan
|
|
|
144
146
|
return result;
|
|
145
147
|
}
|
|
146
148
|
/**
|
|
147
|
-
* Record the pre-computed intersection between two curves.
|
|
149
|
+
* Record the pre-computed intersection between two curves. Record with fraction mapping.
|
|
148
150
|
* @param localFractionA intersection fraction local to the subcurve of cpA between fractionA0 and fractionA1
|
|
149
151
|
* @param cpA the first curve
|
|
150
152
|
* @param fractionA0 start of the subcurve of cpA
|
|
@@ -224,8 +226,7 @@ class CurveCurveIntersectXY extends GeometryHandler_1.RecurseToCurvesGeometryHan
|
|
|
224
226
|
computeSegmentSegment3D(cpA, extendA0, pointA0, fractionA0, pointA1, fractionA1, extendA1, cpB, extendB0, pointB0, fractionB0, pointB1, fractionB1, extendB1, reversed) {
|
|
225
227
|
const aDir = { x: pointA1.x - pointA0.x, y: pointA1.y - pointA0.y };
|
|
226
228
|
const bDir = { x: pointB1.x - pointB0.x, y: pointB1.y - pointB0.y };
|
|
227
|
-
const
|
|
228
|
-
const fractions = SmallSystem_1.SmallSystem.lineSegmentXYUVIntersectionUnbounded(pointA0, aDir, pointB0, bDir, tol);
|
|
229
|
+
const fractions = SmallSystem_1.SmallSystem.lineSegmentXYUVIntersectionUnbounded(pointA0, aDir, pointB0, bDir, this._coincidentGeometryContext.tolerance);
|
|
229
230
|
if (!fractions)
|
|
230
231
|
return;
|
|
231
232
|
if (fractions.f1) { // the lines are coincident
|
|
@@ -238,8 +239,8 @@ class CurveCurveIntersectXY extends GeometryHandler_1.RecurseToCurvesGeometryHan
|
|
|
238
239
|
this.recordPointWithLocalFractions(overlap.detailA.fraction, cpA, fractionA0, fractionA1, overlap.detailB.fraction, cpB, fractionB0, fractionB1, reversed, overlap);
|
|
239
240
|
}
|
|
240
241
|
else { // the lines have a transverse intersection
|
|
241
|
-
if (this.acceptFractionOnLine(extendA0, fractions.f0.x, extendA1, pointA0, pointA1
|
|
242
|
-
if (this.acceptFractionOnLine(extendB0, fractions.f0.y, extendB1, pointB0, pointB1
|
|
242
|
+
if (this.acceptFractionOnLine(extendA0, fractions.f0.x, extendA1, pointA0, pointA1)) {
|
|
243
|
+
if (this.acceptFractionOnLine(extendB0, fractions.f0.y, extendB1, pointB0, pointB1))
|
|
243
244
|
this.recordPointWithLocalFractions(fractions.f0.x, cpA, fractionA0, fractionA1, fractions.f0.y, cpB, fractionB0, fractionB1, reversed);
|
|
244
245
|
}
|
|
245
246
|
}
|
|
@@ -304,10 +305,6 @@ class CurveCurveIntersectXY extends GeometryHandler_1.RecurseToCurvesGeometryHan
|
|
|
304
305
|
// solve for theta; evaluate points; project back to line
|
|
305
306
|
if (this._worldToLocalPerspective) {
|
|
306
307
|
const data = arc.toTransformedPoint4d(this._worldToLocalPerspective);
|
|
307
|
-
const radians0 = data.sweep.fractionToRadians(0);
|
|
308
|
-
const pointB0H = data.center.plus2Scaled(data.vector0, Math.cos(radians0), data.vector90, Math.sin(radians0));
|
|
309
|
-
const radians1 = data.sweep.fractionToRadians(1);
|
|
310
|
-
const pointB1H = data.center.plus2Scaled(data.vector0, Math.cos(radians1), data.vector90, Math.sin(radians1));
|
|
311
308
|
const pointA0H = this._worldToLocalPerspective.multiplyPoint3d(pointA0, 1);
|
|
312
309
|
const pointA1H = this._worldToLocalPerspective.multiplyPoint3d(pointA1, 1);
|
|
313
310
|
const alpha = Geometry_1.Geometry.tripleProductPoint4dXYW(pointA0H, pointA1H, data.center);
|
|
@@ -316,35 +313,49 @@ class CurveCurveIntersectXY extends GeometryHandler_1.RecurseToCurvesGeometryHan
|
|
|
316
313
|
let numRoots = Polynomials_1.AnalyticRoots.appendImplicitLineUnitCircleIntersections(alpha, beta, gamma, cosines, sines, radians, tol2);
|
|
317
314
|
const closeApproach = (0 === numRoots);
|
|
318
315
|
if (closeApproach)
|
|
319
|
-
numRoots = 1; //
|
|
320
|
-
|
|
321
|
-
const arcPoint = data.center.plus2Scaled(data.vector0, cosines.atUncheckedIndex(iRoot), data.vector90, sines.atUncheckedIndex(iRoot));
|
|
322
|
-
let fArc = data.sweep.radiansToSignedFraction(radians.atUncheckedIndex(iRoot), extendB0);
|
|
323
|
-
let fLine = SmallSystem_1.SmallSystem.lineSegment3dHXYClosestPointUnbounded(pointA0H, pointA1H, arcPoint);
|
|
324
|
-
if (fLine === undefined)
|
|
325
|
-
return undefined;
|
|
326
|
-
if (!checkOnlyEndPointDistance && this.acceptFraction(extendA0, fLine, extendA1) && this.acceptFraction(extendB0, fArc, extendB1))
|
|
327
|
-
return { fLine, fArc };
|
|
328
|
-
// check for an endpoint intersection that is beyond parametric tolerance but within point tolerance
|
|
329
|
-
fLine = fLine < 0.5 ? 0 : 1;
|
|
330
|
-
fArc = data.sweep.fractionToSignedPeriodicFraction(fArc) < 0.5 ? 0 : 1;
|
|
331
|
-
const pointAH = fLine ? pointA1H : pointA0H;
|
|
332
|
-
const pointBH = fArc ? pointB1H : pointB0H;
|
|
333
|
-
const dist2 = pointAH.realDistanceSquaredXY(pointBH);
|
|
334
|
-
return (dist2 !== undefined && Geometry_1.Geometry.isDistanceWithinTol(dist2, tol2)) ? { fLine, fArc } : undefined;
|
|
335
|
-
};
|
|
316
|
+
numRoots = 1; // arc closest approach is the first entry
|
|
317
|
+
let numAccepted = 0;
|
|
336
318
|
for (let i = 0; i < numRoots; i++) {
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
319
|
+
const arcPoint = data.center.plus2Scaled(data.vector0, cosines.atUncheckedIndex(i), data.vector90, sines.atUncheckedIndex(i));
|
|
320
|
+
const fArc = data.sweep.radiansToSignedFraction(radians.atUncheckedIndex(i), extendB0);
|
|
321
|
+
const fLine = SmallSystem_1.SmallSystem.lineSegment3dHXYClosestPointUnbounded(pointA0H, pointA1H, arcPoint);
|
|
322
|
+
if (fLine === undefined)
|
|
323
|
+
continue;
|
|
324
|
+
if (closeApproach) {
|
|
325
|
+
const linePoint = pointA0H.interpolate(fLine, pointA1H);
|
|
326
|
+
const dist2 = arcPoint.realDistanceSquaredXY(linePoint);
|
|
327
|
+
if (dist2 === undefined || !Geometry_1.Geometry.isDistanceWithinTol(dist2, tol2))
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
if (this.acceptFraction(extendA0, fLine, extendA1) && this.acceptFraction(extendB0, fArc, extendB1)) {
|
|
331
|
+
this.recordPointWithLocalFractions(fLine, cpA, fractionA0, fractionA1, fArc, arc, 0, 1, reversed);
|
|
332
|
+
numAccepted++;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (numAccepted === 0 && !arc.sweep.isFullCircle) {
|
|
336
|
+
// check for endpoint intersection beyond parametric tolerance but within point tolerance
|
|
337
|
+
const pointB0H = this._worldToLocalPerspective.multiplyPoint3d(arc.startPoint(), 1);
|
|
338
|
+
const pointB1H = this._worldToLocalPerspective.multiplyPoint3d(arc.endPoint(), 1);
|
|
339
|
+
const dist2 = [];
|
|
340
|
+
let d2 = pointA0H.realDistanceSquaredXY(pointB0H);
|
|
341
|
+
if (d2 !== undefined)
|
|
342
|
+
dist2.push({ d2, fA: 0, fB: 0 });
|
|
343
|
+
d2 = pointA0H.realDistanceSquaredXY(pointB1H);
|
|
344
|
+
if (d2 !== undefined)
|
|
345
|
+
dist2.push({ d2, fA: 0, fB: 1 });
|
|
346
|
+
d2 = pointA1H.realDistanceSquaredXY(pointB0H);
|
|
347
|
+
if (d2 !== undefined)
|
|
348
|
+
dist2.push({ d2, fA: 1, fB: 0 });
|
|
349
|
+
d2 = pointA1H.realDistanceSquaredXY(pointB1H);
|
|
350
|
+
if (d2 !== undefined)
|
|
351
|
+
dist2.push({ d2, fA: 1, fB: 1 });
|
|
352
|
+
dist2.sort((a, b) => a.d2 - b.d2);
|
|
353
|
+
if (Geometry_1.Geometry.isDistanceWithinTol(dist2[0].d2, tol2))
|
|
354
|
+
this.recordPointWithLocalFractions(dist2[0].fA, cpA, fractionA0, fractionA1, dist2[0].fB, arc, 0, 1, reversed);
|
|
340
355
|
}
|
|
341
356
|
}
|
|
342
357
|
else {
|
|
343
358
|
const data = arc.toTransformedVectors(this._worldToLocalAffine);
|
|
344
|
-
const radians0 = data.sweep.fractionToRadians(0);
|
|
345
|
-
const pointB0Local = data.center.plus2Scaled(data.vector0, Math.cos(radians0), data.vector90, Math.sin(radians0));
|
|
346
|
-
const radians1 = data.sweep.fractionToRadians(1);
|
|
347
|
-
const pointB1Local = data.center.plus2Scaled(data.vector0, Math.cos(radians1), data.vector90, Math.sin(radians1));
|
|
348
359
|
let pointA0Local = pointA0;
|
|
349
360
|
let pointA1Local = pointA1;
|
|
350
361
|
if (this._worldToLocalAffine) {
|
|
@@ -357,27 +368,40 @@ class CurveCurveIntersectXY extends GeometryHandler_1.RecurseToCurvesGeometryHan
|
|
|
357
368
|
let numRoots = Polynomials_1.AnalyticRoots.appendImplicitLineUnitCircleIntersections(alpha, beta, gamma, cosines, sines, radians, tol2);
|
|
358
369
|
const closeApproach = (0 === numRoots);
|
|
359
370
|
if (closeApproach)
|
|
360
|
-
numRoots = 1; //
|
|
361
|
-
|
|
362
|
-
const arcPoint = data.center.plus2Scaled(data.vector0, cosines.atUncheckedIndex(iRoot), data.vector90, sines.atUncheckedIndex(iRoot));
|
|
363
|
-
let fArc = data.sweep.radiansToSignedFraction(radians.atUncheckedIndex(iRoot), extendB0);
|
|
364
|
-
let fLine = SmallSystem_1.SmallSystem.lineSegment3dXYClosestPointUnbounded(pointA0Local, pointA1Local, arcPoint);
|
|
365
|
-
if (fLine === undefined)
|
|
366
|
-
return undefined;
|
|
367
|
-
if (!checkOnlyEndPointDistance && this.acceptFraction(extendA0, fLine, extendA1) && this.acceptFraction(extendB0, fArc, extendB1))
|
|
368
|
-
return { fLine, fArc };
|
|
369
|
-
// check for an endpoint intersection that is beyond parametric tolerance but within point tolerance
|
|
370
|
-
fLine = fLine < 0.5 ? 0 : 1;
|
|
371
|
-
fArc = data.sweep.fractionToSignedPeriodicFraction(fArc) < 0.5 ? 0 : 1;
|
|
372
|
-
const pointALocal = fLine ? pointA1Local : pointA0Local;
|
|
373
|
-
const pointBLocal = fArc ? pointB1Local : pointB0Local;
|
|
374
|
-
const dist2 = pointALocal.distanceSquaredXY(pointBLocal);
|
|
375
|
-
return Geometry_1.Geometry.isDistanceWithinTol(dist2, tol2) ? { fLine, fArc } : undefined;
|
|
376
|
-
};
|
|
371
|
+
numRoots = 1; // arc closest approach is the first entry
|
|
372
|
+
let numAccepted = 0;
|
|
377
373
|
for (let i = 0; i < numRoots; i++) {
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
|
|
374
|
+
const arcPoint = data.center.plus2Scaled(data.vector0, cosines.atUncheckedIndex(i), data.vector90, sines.atUncheckedIndex(i));
|
|
375
|
+
const fArc = data.sweep.radiansToSignedFraction(radians.atUncheckedIndex(i), extendB0);
|
|
376
|
+
const fLine = SmallSystem_1.SmallSystem.lineSegment3dXYClosestPointUnbounded(pointA0Local, pointA1Local, arcPoint);
|
|
377
|
+
if (fLine === undefined)
|
|
378
|
+
continue;
|
|
379
|
+
if (closeApproach) {
|
|
380
|
+
const linePoint = pointA0Local.interpolate(fLine, pointA1Local);
|
|
381
|
+
if (!Geometry_1.Geometry.isDistanceWithinTol(arcPoint.distanceSquaredXY(linePoint), tol2))
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
if (this.acceptFraction(extendA0, fLine, extendA1) && this.acceptFraction(extendB0, fArc, extendB1)) {
|
|
385
|
+
this.recordPointWithLocalFractions(fLine, cpA, fractionA0, fractionA1, fArc, arc, 0, 1, reversed);
|
|
386
|
+
numAccepted++;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
if (numAccepted === 0 && !arc.sweep.isFullCircle) {
|
|
390
|
+
// check for endpoint intersection beyond parametric tolerance but within point tolerance
|
|
391
|
+
const pointB0Local = arc.startPoint();
|
|
392
|
+
const pointB1Local = arc.endPoint();
|
|
393
|
+
if (this._worldToLocalAffine) {
|
|
394
|
+
this._worldToLocalAffine.multiplyXYAndZInPlace(pointB0Local);
|
|
395
|
+
this._worldToLocalAffine.multiplyXYAndZInPlace(pointB1Local);
|
|
396
|
+
}
|
|
397
|
+
const dist2 = [];
|
|
398
|
+
dist2.push({ d2: pointA0Local.distanceSquaredXY(pointB0Local), fA: 0, fB: 0 });
|
|
399
|
+
dist2.push({ d2: pointA0Local.distanceSquaredXY(pointB1Local), fA: 0, fB: 1 });
|
|
400
|
+
dist2.push({ d2: pointA1Local.distanceSquaredXY(pointB0Local), fA: 1, fB: 0 });
|
|
401
|
+
dist2.push({ d2: pointA1Local.distanceSquaredXY(pointB1Local), fA: 1, fB: 1 });
|
|
402
|
+
dist2.sort((a, b) => a.d2 - b.d2);
|
|
403
|
+
if (Geometry_1.Geometry.isDistanceWithinTol(dist2[0].d2, tol2))
|
|
404
|
+
this.recordPointWithLocalFractions(dist2[0].fA, cpA, fractionA0, fractionA1, dist2[0].fB, arc, 0, 1, reversed);
|
|
381
405
|
}
|
|
382
406
|
}
|
|
383
407
|
}
|