@mlightcad/geometry-engine 1.0.0
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/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/geometry-engine.js +10186 -0
- package/dist/geometry-engine.umd.cjs +4 -0
- package/lib/geometry/AcGeArea2d.d.ts +61 -0
- package/lib/geometry/AcGeArea2d.d.ts.map +1 -0
- package/lib/geometry/AcGeArea2d.js +174 -0
- package/lib/geometry/AcGeArea2d.js.map +1 -0
- package/lib/geometry/AcGeCircArc2d.d.ts +108 -0
- package/lib/geometry/AcGeCircArc2d.d.ts.map +1 -0
- package/lib/geometry/AcGeCircArc2d.js +412 -0
- package/lib/geometry/AcGeCircArc2d.js.map +1 -0
- package/lib/geometry/AcGeCircArc3d.d.ts +138 -0
- package/lib/geometry/AcGeCircArc3d.d.ts.map +1 -0
- package/lib/geometry/AcGeCircArc3d.js +447 -0
- package/lib/geometry/AcGeCircArc3d.js.map +1 -0
- package/lib/geometry/AcGeCurve2d.d.ts +85 -0
- package/lib/geometry/AcGeCurve2d.d.ts.map +1 -0
- package/lib/geometry/AcGeCurve2d.js +213 -0
- package/lib/geometry/AcGeCurve2d.js.map +1 -0
- package/lib/geometry/AcGeCurve3d.d.ts +27 -0
- package/lib/geometry/AcGeCurve3d.d.ts.map +1 -0
- package/lib/geometry/AcGeCurve3d.js +29 -0
- package/lib/geometry/AcGeCurve3d.js.map +1 -0
- package/lib/geometry/AcGeEllipseArc2d.d.ts +105 -0
- package/lib/geometry/AcGeEllipseArc2d.d.ts.map +1 -0
- package/lib/geometry/AcGeEllipseArc2d.js +292 -0
- package/lib/geometry/AcGeEllipseArc2d.js.map +1 -0
- package/lib/geometry/AcGeEllipseArc3d.d.ts +141 -0
- package/lib/geometry/AcGeEllipseArc3d.d.ts.map +1 -0
- package/lib/geometry/AcGeEllipseArc3d.js +442 -0
- package/lib/geometry/AcGeEllipseArc3d.js.map +1 -0
- package/lib/geometry/AcGeLine2d.d.ts +56 -0
- package/lib/geometry/AcGeLine2d.d.ts.map +1 -0
- package/lib/geometry/AcGeLine2d.js +125 -0
- package/lib/geometry/AcGeLine2d.js.map +1 -0
- package/lib/geometry/AcGeLine3d.d.ts +134 -0
- package/lib/geometry/AcGeLine3d.d.ts.map +1 -0
- package/lib/geometry/AcGeLine3d.js +291 -0
- package/lib/geometry/AcGeLine3d.js.map +1 -0
- package/lib/geometry/AcGeLoop2d.d.ts +59 -0
- package/lib/geometry/AcGeLoop2d.d.ts.map +1 -0
- package/lib/geometry/AcGeLoop2d.js +141 -0
- package/lib/geometry/AcGeLoop2d.js.map +1 -0
- package/lib/geometry/AcGePolyline2d.d.ts +90 -0
- package/lib/geometry/AcGePolyline2d.d.ts.map +1 -0
- package/lib/geometry/AcGePolyline2d.js +224 -0
- package/lib/geometry/AcGePolyline2d.js.map +1 -0
- package/lib/geometry/AcGeShape.d.ts +12 -0
- package/lib/geometry/AcGeShape.d.ts.map +1 -0
- package/lib/geometry/AcGeShape.js +22 -0
- package/lib/geometry/AcGeShape.js.map +1 -0
- package/lib/geometry/AcGeShape2d.d.ts +31 -0
- package/lib/geometry/AcGeShape2d.d.ts.map +1 -0
- package/lib/geometry/AcGeShape2d.js +51 -0
- package/lib/geometry/AcGeShape2d.js.map +1 -0
- package/lib/geometry/AcGeShape3d.d.ts +33 -0
- package/lib/geometry/AcGeShape3d.d.ts.map +1 -0
- package/lib/geometry/AcGeShape3d.js +52 -0
- package/lib/geometry/AcGeShape3d.js.map +1 -0
- package/lib/geometry/AcGeSpline3d.d.ts +77 -0
- package/lib/geometry/AcGeSpline3d.d.ts.map +1 -0
- package/lib/geometry/AcGeSpline3d.js +221 -0
- package/lib/geometry/AcGeSpline3d.js.map +1 -0
- package/lib/geometry/index.d.ts +13 -0
- package/lib/geometry/index.d.ts.map +1 -0
- package/lib/geometry/index.js +13 -0
- package/lib/geometry/index.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -0
- package/lib/math/AcGeBox2d.d.ts +173 -0
- package/lib/math/AcGeBox2d.d.ts.map +1 -0
- package/lib/math/AcGeBox2d.js +289 -0
- package/lib/math/AcGeBox2d.js.map +1 -0
- package/lib/math/AcGeBox3d.d.ts +195 -0
- package/lib/math/AcGeBox3d.d.ts.map +1 -0
- package/lib/math/AcGeBox3d.js +378 -0
- package/lib/math/AcGeBox3d.js.map +1 -0
- package/lib/math/AcGeEuler.d.ts +133 -0
- package/lib/math/AcGeEuler.d.ts.map +1 -0
- package/lib/math/AcGeEuler.js +358 -0
- package/lib/math/AcGeEuler.js.map +1 -0
- package/lib/math/AcGeMatrix2d.d.ts +203 -0
- package/lib/math/AcGeMatrix2d.d.ts.map +1 -0
- package/lib/math/AcGeMatrix2d.js +393 -0
- package/lib/math/AcGeMatrix2d.js.map +1 -0
- package/lib/math/AcGeMatrix3d.d.ts +279 -0
- package/lib/math/AcGeMatrix3d.d.ts.map +1 -0
- package/lib/math/AcGeMatrix3d.js +1037 -0
- package/lib/math/AcGeMatrix3d.js.map +1 -0
- package/lib/math/AcGePlane.d.ts +131 -0
- package/lib/math/AcGePlane.d.ts.map +1 -0
- package/lib/math/AcGePlane.js +218 -0
- package/lib/math/AcGePlane.js.map +1 -0
- package/lib/math/AcGePoint.d.ts +4 -0
- package/lib/math/AcGePoint.d.ts.map +1 -0
- package/lib/math/AcGePoint.js +2 -0
- package/lib/math/AcGePoint.js.map +1 -0
- package/lib/math/AcGePoint2d.d.ts +17 -0
- package/lib/math/AcGePoint2d.d.ts.map +1 -0
- package/lib/math/AcGePoint2d.js +40 -0
- package/lib/math/AcGePoint2d.js.map +1 -0
- package/lib/math/AcGePoint3d.d.ts +18 -0
- package/lib/math/AcGePoint3d.d.ts.map +1 -0
- package/lib/math/AcGePoint3d.js +43 -0
- package/lib/math/AcGePoint3d.js.map +1 -0
- package/lib/math/AcGeQuaternion.d.ts +230 -0
- package/lib/math/AcGeQuaternion.d.ts.map +1 -0
- package/lib/math/AcGeQuaternion.js +666 -0
- package/lib/math/AcGeQuaternion.js.map +1 -0
- package/lib/math/AcGeVector.d.ts +9 -0
- package/lib/math/AcGeVector.d.ts.map +1 -0
- package/lib/math/AcGeVector.js +2 -0
- package/lib/math/AcGeVector.js.map +1 -0
- package/lib/math/AcGeVector2d.d.ts +361 -0
- package/lib/math/AcGeVector2d.d.ts.map +1 -0
- package/lib/math/AcGeVector2d.js +622 -0
- package/lib/math/AcGeVector2d.js.map +1 -0
- package/lib/math/AcGeVector3d.d.ts +493 -0
- package/lib/math/AcGeVector3d.d.ts.map +1 -0
- package/lib/math/AcGeVector3d.js +868 -0
- package/lib/math/AcGeVector3d.js.map +1 -0
- package/lib/math/index.d.ts +14 -0
- package/lib/math/index.d.ts.map +1 -0
- package/lib/math/index.js +14 -0
- package/lib/math/index.js.map +1 -0
- package/lib/util/AcGeConstants.d.ts +19 -0
- package/lib/util/AcGeConstants.d.ts.map +1 -0
- package/lib/util/AcGeConstants.js +25 -0
- package/lib/util/AcGeConstants.js.map +1 -0
- package/lib/util/AcGeGeometryUtil.d.ts +16 -0
- package/lib/util/AcGeGeometryUtil.d.ts.map +1 -0
- package/lib/util/AcGeGeometryUtil.js +56 -0
- package/lib/util/AcGeGeometryUtil.js.map +1 -0
- package/lib/util/AcGeMathUtil.d.ts +203 -0
- package/lib/util/AcGeMathUtil.d.ts.map +1 -0
- package/lib/util/AcGeMathUtil.js +585 -0
- package/lib/util/AcGeMathUtil.js.map +1 -0
- package/lib/util/AcGeTol.d.ts +91 -0
- package/lib/util/AcGeTol.d.ts.map +1 -0
- package/lib/util/AcGeTol.js +83 -0
- package/lib/util/AcGeTol.js.map +1 -0
- package/lib/util/index.d.ts +5 -0
- package/lib/util/index.d.ts.map +1 -0
- package/lib/util/index.js +5 -0
- package/lib/util/index.js.map +1 -0
- package/package.json +42 -0
@@ -0,0 +1,134 @@
|
|
1
|
+
import { AcGeBox3d, AcGeMatrix3d, AcGePoint3d, AcGePoint3dLike, AcGeVector3d } from '../math';
|
2
|
+
import { AcGeCurve3d } from './AcGeCurve3d';
|
3
|
+
/**
|
4
|
+
* The class represents one 3d line geometry specified by its start point and end point.
|
5
|
+
*/
|
6
|
+
export declare class AcGeLine3d extends AcGeCurve3d {
|
7
|
+
private _start;
|
8
|
+
private _end;
|
9
|
+
/**
|
10
|
+
* This constructor initializes the line object to use start as the start point, and end
|
11
|
+
* as the endpoint. Both points must be in WCS coordinates.
|
12
|
+
*/
|
13
|
+
constructor(start: AcGePoint3dLike, end: AcGePoint3dLike);
|
14
|
+
/**
|
15
|
+
* The line's startpoint in WCS coordinates
|
16
|
+
*/
|
17
|
+
get startPoint(): AcGePoint3d;
|
18
|
+
set startPoint(value: AcGePoint3dLike);
|
19
|
+
/**
|
20
|
+
* The line's endpoint in WCS coordinates
|
21
|
+
*/
|
22
|
+
get endPoint(): AcGePoint3d;
|
23
|
+
set endPoint(value: AcGePoint3dLike);
|
24
|
+
/**
|
25
|
+
* Normalized direction vector of this line
|
26
|
+
*/
|
27
|
+
get direction(): AcGeVector3d;
|
28
|
+
/**
|
29
|
+
* The middle point of this line.
|
30
|
+
*/
|
31
|
+
get midPoint(): AcGePoint3d;
|
32
|
+
/**
|
33
|
+
* @inheritdoc
|
34
|
+
*/
|
35
|
+
get length(): number;
|
36
|
+
/**
|
37
|
+
* Check whether the specified point is on this line.
|
38
|
+
* @param point Input point to check
|
39
|
+
* @returns Return true if the specified point is on this line. Otherwise, return false.
|
40
|
+
*/
|
41
|
+
isPointOnLine(point: AcGePoint3dLike): boolean;
|
42
|
+
/**
|
43
|
+
* Return a point at a certain position along the line. When t = 0, it returns the start point,
|
44
|
+
* and when t = 1 it returns the end point.
|
45
|
+
* @param t Use values 0-1 to return a position along the line.
|
46
|
+
* @param target The result will be copied into this point.
|
47
|
+
* @returns Return a point at a certain position along the line.
|
48
|
+
*/
|
49
|
+
at(t: number, target: AcGePoint3d): AcGeVector3d;
|
50
|
+
/**
|
51
|
+
* Return a point at a certain position along the line.
|
52
|
+
* - If `flag` is false, use the length from start point to determinate the point
|
53
|
+
* - If `flag` is true, use the length from end point to determinate the point
|
54
|
+
* @param length Use this length value to return a position along the line.
|
55
|
+
* @returns Return a point at a certain position along the line.
|
56
|
+
*/
|
57
|
+
atLength(length: number, flag?: boolean): AcGePoint3d;
|
58
|
+
/**
|
59
|
+
* Extend this line with the specified length
|
60
|
+
* @param length Input the length of extension
|
61
|
+
* @param inversed Input the flag to determinate which point is used to calculate the length
|
62
|
+
* - ture: start point is used as the start point of the line extension
|
63
|
+
* - false: end point is used as the start point of the line extension
|
64
|
+
*/
|
65
|
+
extend(length: number, inversed?: boolean): this;
|
66
|
+
/**
|
67
|
+
* Return a point parameter based on the closest point as projected on the line segment. If clampToLine
|
68
|
+
* is true, then the returned value will be between 0 and 1.
|
69
|
+
* @param point Input the point for which to return a point parameter.
|
70
|
+
* @param clampToLine Whether to clamp the result to the range [0, 1].
|
71
|
+
* @returns Return a point parameter based on the closest point as projected on the line segment.
|
72
|
+
*/
|
73
|
+
closestPointToPointParameter(point: AcGePoint3d, clampToLine: boolean): number;
|
74
|
+
/**
|
75
|
+
* Return the closets point on the line. If clampToLine is true, then the returned value will be
|
76
|
+
* clamped to the line segment.
|
77
|
+
* @param point Return the closest point on the line to this point.
|
78
|
+
* @param clampToLine Whether to clamp the returned value to the line segment.
|
79
|
+
* @param target The result will be copied into this point.
|
80
|
+
* @returns Return the closets point on the line.
|
81
|
+
*/
|
82
|
+
closestPointToPoint(point: AcGePoint3d, clampToLine: boolean, target: AcGePoint3d): AcGeVector3d;
|
83
|
+
/**
|
84
|
+
* Returns the delta vector of the line segment (end vector minus the start vector).
|
85
|
+
* @param target The result will be copied into this vector.
|
86
|
+
* @returns Return the delta vector of the line segment (end vector minus the start vector).
|
87
|
+
*/
|
88
|
+
delta(target: AcGeVector3d): AcGeVector3d;
|
89
|
+
/**
|
90
|
+
* Return the square of the Euclidean distance (straight-line distance) between the line's start and
|
91
|
+
* end point.
|
92
|
+
* @returns Return the square of the Euclidean distance (straight-line distance) between the line's
|
93
|
+
* start and end point.
|
94
|
+
*/
|
95
|
+
distanceSq(): number;
|
96
|
+
/**
|
97
|
+
* Return the Euclidean distance (straight-line distance) between the line's start and end points.
|
98
|
+
* @returns Return the Euclidean distance (straight-line distance) between the line's start and end points.
|
99
|
+
*/
|
100
|
+
distance(): number;
|
101
|
+
/**
|
102
|
+
* Project a 3d point onto this line
|
103
|
+
*/
|
104
|
+
project(pt: AcGePoint3dLike): AcGePoint3d;
|
105
|
+
/**
|
106
|
+
* Finds the point on the line that is perpendicular to the given point. When you need the shortest distance
|
107
|
+
* between the given point and the line, perpPoint gives the point on the line that is the closest to the
|
108
|
+
* given point.
|
109
|
+
* @param point Input one point to calculate the point on the line that is the closest to this point
|
110
|
+
* @returns Return the point on the line that is the closest to the given point.
|
111
|
+
*/
|
112
|
+
perpPoint(point: AcGePoint3d): AcGePoint3d;
|
113
|
+
/**
|
114
|
+
* @inheritdoc
|
115
|
+
*/
|
116
|
+
calculateBoundingBox(): AcGeBox3d;
|
117
|
+
/**
|
118
|
+
* @inheritdoc
|
119
|
+
*/
|
120
|
+
transform(matrix: AcGeMatrix3d): this;
|
121
|
+
/**
|
122
|
+
* @inheritdoc
|
123
|
+
*/
|
124
|
+
get closed(): boolean;
|
125
|
+
/**
|
126
|
+
* @inheritdoc
|
127
|
+
*/
|
128
|
+
copy(value: AcGeLine3d): this;
|
129
|
+
/**
|
130
|
+
* @inheritdoc
|
131
|
+
*/
|
132
|
+
clone(): AcGeLine3d;
|
133
|
+
}
|
134
|
+
//# sourceMappingURL=AcGeLine3d.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AcGeLine3d.d.ts","sourceRoot":"","sources":["../../src/geometry/AcGeLine3d.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,WAAW,EACX,eAAe,EACf,YAAY,EACb,MA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K,EAAE,WAAW;IAmB5B;;OAEG;IACH,oBAAoB,IAAI,SAAS;IAcjC;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,YAAY;IAO9B;;OAEG;IACH,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED;;OAEG;IACH,IAAI,CAAC,KAAK,EAAE,UAAU;IAOtB;;OAEG;IACH,KAAK;CAGN"}
|
@@ -0,0 +1,291 @@
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
2
|
+
var extendStatics = function (d, b) {
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
+
return extendStatics(d, b);
|
7
|
+
};
|
8
|
+
return function (d, b) {
|
9
|
+
if (typeof b !== "function" && b !== null)
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
+
extendStatics(d, b);
|
12
|
+
function __() { this.constructor = d; }
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
+
};
|
15
|
+
})();
|
16
|
+
import { AcGeBox3d, AcGePoint3d, AcGeVector3d } from '../math';
|
17
|
+
import { AcGeMathUtil } from '../util';
|
18
|
+
import { AcGeCurve3d } from './AcGeCurve3d';
|
19
|
+
/**
|
20
|
+
* The class represents one 3d line geometry specified by its start point and end point.
|
21
|
+
*/
|
22
|
+
var AcGeLine3d = /** @class */ (function (_super) {
|
23
|
+
__extends(AcGeLine3d, _super);
|
24
|
+
/**
|
25
|
+
* This constructor initializes the line object to use start as the start point, and end
|
26
|
+
* as the endpoint. Both points must be in WCS coordinates.
|
27
|
+
*/
|
28
|
+
function AcGeLine3d(start, end) {
|
29
|
+
var _this = _super.call(this) || this;
|
30
|
+
_this._start = new AcGePoint3d(start);
|
31
|
+
_this._end = new AcGePoint3d(end);
|
32
|
+
return _this;
|
33
|
+
}
|
34
|
+
Object.defineProperty(AcGeLine3d.prototype, "startPoint", {
|
35
|
+
/**
|
36
|
+
* The line's startpoint in WCS coordinates
|
37
|
+
*/
|
38
|
+
get: function () {
|
39
|
+
return this._start;
|
40
|
+
},
|
41
|
+
set: function (value) {
|
42
|
+
this._start.copy(value);
|
43
|
+
this._boundingBoxNeedsUpdate = true;
|
44
|
+
},
|
45
|
+
enumerable: false,
|
46
|
+
configurable: true
|
47
|
+
});
|
48
|
+
Object.defineProperty(AcGeLine3d.prototype, "endPoint", {
|
49
|
+
/**
|
50
|
+
* The line's endpoint in WCS coordinates
|
51
|
+
*/
|
52
|
+
get: function () {
|
53
|
+
return this._end;
|
54
|
+
},
|
55
|
+
set: function (value) {
|
56
|
+
this._end.copy(value);
|
57
|
+
this._boundingBoxNeedsUpdate = true;
|
58
|
+
},
|
59
|
+
enumerable: false,
|
60
|
+
configurable: true
|
61
|
+
});
|
62
|
+
Object.defineProperty(AcGeLine3d.prototype, "direction", {
|
63
|
+
/**
|
64
|
+
* Normalized direction vector of this line
|
65
|
+
*/
|
66
|
+
get: function () {
|
67
|
+
return new AcGeVector3d()
|
68
|
+
.subVectors(this.endPoint, this.startPoint)
|
69
|
+
.normalize();
|
70
|
+
},
|
71
|
+
enumerable: false,
|
72
|
+
configurable: true
|
73
|
+
});
|
74
|
+
Object.defineProperty(AcGeLine3d.prototype, "midPoint", {
|
75
|
+
/**
|
76
|
+
* The middle point of this line.
|
77
|
+
*/
|
78
|
+
get: function () {
|
79
|
+
return new AcGePoint3d((this._start.x + this._end.x) / 2, (this._start.y + this._end.y) / 2, (this._start.z + this._end.z) / 2);
|
80
|
+
},
|
81
|
+
enumerable: false,
|
82
|
+
configurable: true
|
83
|
+
});
|
84
|
+
Object.defineProperty(AcGeLine3d.prototype, "length", {
|
85
|
+
/**
|
86
|
+
* @inheritdoc
|
87
|
+
*/
|
88
|
+
get: function () {
|
89
|
+
return this.startPoint.distanceTo(this.endPoint);
|
90
|
+
},
|
91
|
+
enumerable: false,
|
92
|
+
configurable: true
|
93
|
+
});
|
94
|
+
/**
|
95
|
+
* Check whether the specified point is on this line.
|
96
|
+
* @param point Input point to check
|
97
|
+
* @returns Return true if the specified point is on this line. Otherwise, return false.
|
98
|
+
*/
|
99
|
+
AcGeLine3d.prototype.isPointOnLine = function (point) {
|
100
|
+
// Compute the projected point on the line
|
101
|
+
var projectedPoint = this.project(point);
|
102
|
+
var tolerance = 1e-6;
|
103
|
+
return projectedPoint.distanceTo(point) < tolerance;
|
104
|
+
};
|
105
|
+
/**
|
106
|
+
* Return a point at a certain position along the line. When t = 0, it returns the start point,
|
107
|
+
* and when t = 1 it returns the end point.
|
108
|
+
* @param t Use values 0-1 to return a position along the line.
|
109
|
+
* @param target The result will be copied into this point.
|
110
|
+
* @returns Return a point at a certain position along the line.
|
111
|
+
*/
|
112
|
+
AcGeLine3d.prototype.at = function (t, target) {
|
113
|
+
return this.delta(target).multiplyScalar(t).add(this._start);
|
114
|
+
};
|
115
|
+
/**
|
116
|
+
* Return a point at a certain position along the line.
|
117
|
+
* - If `flag` is false, use the length from start point to determinate the point
|
118
|
+
* - If `flag` is true, use the length from end point to determinate the point
|
119
|
+
* @param length Use this length value to return a position along the line.
|
120
|
+
* @returns Return a point at a certain position along the line.
|
121
|
+
*/
|
122
|
+
AcGeLine3d.prototype.atLength = function (length, flag) {
|
123
|
+
if (flag === void 0) { flag = false; }
|
124
|
+
if (flag) {
|
125
|
+
var direction = this.delta(_vector).normalize();
|
126
|
+
return new AcGePoint3d(this._start).addScaledVector(direction, length);
|
127
|
+
}
|
128
|
+
else {
|
129
|
+
var direction = this.delta(_vector).normalize();
|
130
|
+
return new AcGePoint3d(this._end).addScaledVector(direction, length);
|
131
|
+
}
|
132
|
+
};
|
133
|
+
/**
|
134
|
+
* Extend this line with the specified length
|
135
|
+
* @param length Input the length of extension
|
136
|
+
* @param inversed Input the flag to determinate which point is used to calculate the length
|
137
|
+
* - ture: start point is used as the start point of the line extension
|
138
|
+
* - false: end point is used as the start point of the line extension
|
139
|
+
*/
|
140
|
+
AcGeLine3d.prototype.extend = function (length, inversed) {
|
141
|
+
if (inversed === void 0) { inversed = false; }
|
142
|
+
if (inversed) {
|
143
|
+
var direction = _vector.subVectors(this._start, this._end).normalize();
|
144
|
+
this._start = new AcGePoint3d(this._start).addScaledVector(direction, length);
|
145
|
+
}
|
146
|
+
else {
|
147
|
+
var direction = this.delta(_vector).normalize();
|
148
|
+
this._end = new AcGePoint3d(this._end).addScaledVector(direction, length);
|
149
|
+
}
|
150
|
+
this._boundingBoxNeedsUpdate = true;
|
151
|
+
return this;
|
152
|
+
};
|
153
|
+
/**
|
154
|
+
* Return a point parameter based on the closest point as projected on the line segment. If clampToLine
|
155
|
+
* is true, then the returned value will be between 0 and 1.
|
156
|
+
* @param point Input the point for which to return a point parameter.
|
157
|
+
* @param clampToLine Whether to clamp the result to the range [0, 1].
|
158
|
+
* @returns Return a point parameter based on the closest point as projected on the line segment.
|
159
|
+
*/
|
160
|
+
AcGeLine3d.prototype.closestPointToPointParameter = function (point, clampToLine) {
|
161
|
+
_startP.subVectors(point, this._start);
|
162
|
+
_startEnd.subVectors(this.endPoint, this.startPoint);
|
163
|
+
var startEnd2 = _startEnd.dot(_startEnd);
|
164
|
+
var startEnd_startP = _startEnd.dot(_startP);
|
165
|
+
var t = startEnd_startP / startEnd2;
|
166
|
+
if (clampToLine) {
|
167
|
+
t = AcGeMathUtil.clamp(t, 0, 1);
|
168
|
+
}
|
169
|
+
return t;
|
170
|
+
};
|
171
|
+
/**
|
172
|
+
* Return the closets point on the line. If clampToLine is true, then the returned value will be
|
173
|
+
* clamped to the line segment.
|
174
|
+
* @param point Return the closest point on the line to this point.
|
175
|
+
* @param clampToLine Whether to clamp the returned value to the line segment.
|
176
|
+
* @param target The result will be copied into this point.
|
177
|
+
* @returns Return the closets point on the line.
|
178
|
+
*/
|
179
|
+
AcGeLine3d.prototype.closestPointToPoint = function (point, clampToLine, target) {
|
180
|
+
var t = this.closestPointToPointParameter(point, clampToLine);
|
181
|
+
return this.delta(target).multiplyScalar(t).add(this._start);
|
182
|
+
};
|
183
|
+
/**
|
184
|
+
* Returns the delta vector of the line segment (end vector minus the start vector).
|
185
|
+
* @param target The result will be copied into this vector.
|
186
|
+
* @returns Return the delta vector of the line segment (end vector minus the start vector).
|
187
|
+
*/
|
188
|
+
AcGeLine3d.prototype.delta = function (target) {
|
189
|
+
return target.subVectors(this._end, this._start);
|
190
|
+
};
|
191
|
+
/**
|
192
|
+
* Return the square of the Euclidean distance (straight-line distance) between the line's start and
|
193
|
+
* end point.
|
194
|
+
* @returns Return the square of the Euclidean distance (straight-line distance) between the line's
|
195
|
+
* start and end point.
|
196
|
+
*/
|
197
|
+
AcGeLine3d.prototype.distanceSq = function () {
|
198
|
+
return this._start.distanceToSquared(this._end);
|
199
|
+
};
|
200
|
+
/**
|
201
|
+
* Return the Euclidean distance (straight-line distance) between the line's start and end points.
|
202
|
+
* @returns Return the Euclidean distance (straight-line distance) between the line's start and end points.
|
203
|
+
*/
|
204
|
+
AcGeLine3d.prototype.distance = function () {
|
205
|
+
return this._start.distanceTo(this._end);
|
206
|
+
};
|
207
|
+
/**
|
208
|
+
* Project a 3d point onto this line
|
209
|
+
*/
|
210
|
+
AcGeLine3d.prototype.project = function (pt) {
|
211
|
+
var lineDirection = this.direction;
|
212
|
+
// Create the vector from the start point to the point to project
|
213
|
+
var pointDirection = _vector.subVectors(pt, this.startPoint);
|
214
|
+
// Project the point onto the line using the dot product
|
215
|
+
var projectionLength = pointDirection.dot(lineDirection);
|
216
|
+
// Calculate the projected point
|
217
|
+
return new AcGePoint3d()
|
218
|
+
.copy(lineDirection)
|
219
|
+
.multiplyScalar(projectionLength)
|
220
|
+
.add(this.startPoint);
|
221
|
+
};
|
222
|
+
/**
|
223
|
+
* Finds the point on the line that is perpendicular to the given point. When you need the shortest distance
|
224
|
+
* between the given point and the line, perpPoint gives the point on the line that is the closest to the
|
225
|
+
* given point.
|
226
|
+
* @param point Input one point to calculate the point on the line that is the closest to this point
|
227
|
+
* @returns Return the point on the line that is the closest to the given point.
|
228
|
+
*/
|
229
|
+
AcGeLine3d.prototype.perpPoint = function (point) {
|
230
|
+
var lineDirection = this.direction;
|
231
|
+
var lineStart = this.startPoint;
|
232
|
+
// Create a vector from the line start to the given point
|
233
|
+
var pointToLineStart = _vector.subVectors(point, lineStart);
|
234
|
+
// Project the point-to-line-start vector onto the line direction
|
235
|
+
var projectionLength = pointToLineStart.dot(lineDirection);
|
236
|
+
// Calculate the projected point on the line
|
237
|
+
var projectedVector = _vector
|
238
|
+
.copy(lineDirection)
|
239
|
+
.multiplyScalar(projectionLength);
|
240
|
+
// The perpendicular point on the line
|
241
|
+
return new AcGePoint3d().addVectors(lineStart, projectedVector);
|
242
|
+
};
|
243
|
+
/**
|
244
|
+
* @inheritdoc
|
245
|
+
*/
|
246
|
+
AcGeLine3d.prototype.calculateBoundingBox = function () {
|
247
|
+
var min = new AcGePoint3d(Math.min(this._start.x, this._end.x), Math.min(this._start.y, this._end.y), Math.min(this._start.z, this._end.z));
|
248
|
+
var max = new AcGePoint3d(Math.max(this._start.x, this._end.x), Math.max(this._start.y, this._end.y), Math.max(this._start.z, this._end.z));
|
249
|
+
return new AcGeBox3d(min, max);
|
250
|
+
};
|
251
|
+
/**
|
252
|
+
* @inheritdoc
|
253
|
+
*/
|
254
|
+
AcGeLine3d.prototype.transform = function (matrix) {
|
255
|
+
this._start.applyMatrix3d(matrix);
|
256
|
+
this._end.applyMatrix3d(matrix);
|
257
|
+
this._boundingBoxNeedsUpdate = true;
|
258
|
+
return this;
|
259
|
+
};
|
260
|
+
Object.defineProperty(AcGeLine3d.prototype, "closed", {
|
261
|
+
/**
|
262
|
+
* @inheritdoc
|
263
|
+
*/
|
264
|
+
get: function () {
|
265
|
+
return false;
|
266
|
+
},
|
267
|
+
enumerable: false,
|
268
|
+
configurable: true
|
269
|
+
});
|
270
|
+
/**
|
271
|
+
* @inheritdoc
|
272
|
+
*/
|
273
|
+
AcGeLine3d.prototype.copy = function (value) {
|
274
|
+
this.startPoint = value.startPoint;
|
275
|
+
this.endPoint = value.endPoint;
|
276
|
+
this._boundingBoxNeedsUpdate = true;
|
277
|
+
return this;
|
278
|
+
};
|
279
|
+
/**
|
280
|
+
* @inheritdoc
|
281
|
+
*/
|
282
|
+
AcGeLine3d.prototype.clone = function () {
|
283
|
+
return new AcGeLine3d(this._start.clone(), this._end.clone());
|
284
|
+
};
|
285
|
+
return AcGeLine3d;
|
286
|
+
}(AcGeCurve3d));
|
287
|
+
export { AcGeLine3d };
|
288
|
+
var _vector = /*@__PURE__*/ new AcGeVector3d();
|
289
|
+
var _startP = /*@__PURE__*/ new AcGeVector3d();
|
290
|
+
var _startEnd = /*@__PURE__*/ new AcGeVector3d();
|
291
|
+
//# sourceMappingURL=AcGeLine3d.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AcGeLine3d.js","sourceRoot":"","sources":["../../src/geometry/AcGeLine3d.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EACL,SAAS,EAET,WAAW,EAEX,YAAY,EACb,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;GAEG;AACH;IAAgC,8BAAW;IAGzC;;;OAGG;IACH,oBAAY,KAAsB,EAAE,GAAoB;QACtD,YAAA,MAAK,WAAE,SAAA;QACP,KAAI,CAAC,MAAM,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,CAAA;QACpC,KAAI,CAAC,IAAI,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC,CAAA;;IAClC,CAAC;IAKD,sBAAI,kCAAU;QAHd;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,MAAM,CAAA;QACpB,CAAC;aACD,UAAe,KAAsB;YACnC,IAAI,CAAC,MAAM,CAAC,IAAI,CAA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,UAAU,CAAA;QAClC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAA;QAC9B,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAA;QACnC,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;OAEG;IACH,0BAAK,GAAL;QACE,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAA;IAC/D,CAAC;IACH,iBAAC;AAAD,CAAC,AA5RD,CAAgC,WAAW,GA4R1C;;AAED,IAAM,OAAO,GAAG,aAAa,CAAC,IAAI,YAAY,EAAE,CAAA;AAChD,IAAM,OAAO,GAAG,aAAa,CAAC,IAAI,YAAY,EAAE,CAAA;AAChD,IAAM,SAAS,GAAG,aAAa,CAAC,IAAI,YAAY,EAAE,CAAA"}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import { AcGeEllipseArc2d, AcGeSpline3d } from '../geometry';
|
2
|
+
import { AcGeBox2d, AcGeMatrix2d, AcGePoint2d } from '../math';
|
3
|
+
import { AcGeCircArc2d } from './AcGeCircArc2d';
|
4
|
+
import { AcGeCurve2d } from './AcGeCurve2d';
|
5
|
+
import { AcGeLine2d } from './AcGeLine2d';
|
6
|
+
export type AcGeBoundaryEdgeType = AcGeLine2d | AcGeCircArc2d | AcGeSpline3d | AcGeEllipseArc2d;
|
7
|
+
/**
|
8
|
+
* The class representing one closed loop created by connected edges, which can be line, circular arc,
|
9
|
+
* ellipse arc, or spline.
|
10
|
+
*/
|
11
|
+
export declare class AcGeLoop2d extends AcGeCurve2d {
|
12
|
+
private _curves;
|
13
|
+
/**
|
14
|
+
* Create one loop by connected curves
|
15
|
+
* @param curves Input one array of connected curves
|
16
|
+
*/
|
17
|
+
constructor(curves?: Array<AcGeBoundaryEdgeType>);
|
18
|
+
get curves(): ReadonlyArray<AcGeBoundaryEdgeType>;
|
19
|
+
/**
|
20
|
+
* Append an edge to this loop
|
21
|
+
* @param curve
|
22
|
+
*/
|
23
|
+
add(curve: AcGeBoundaryEdgeType): void;
|
24
|
+
/**
|
25
|
+
* The number of edges in this loop
|
26
|
+
*/
|
27
|
+
get numberOfEdges(): number;
|
28
|
+
/**
|
29
|
+
* Start point of this polyline
|
30
|
+
*/
|
31
|
+
get startPoint(): AcGePoint2d;
|
32
|
+
/**
|
33
|
+
* End point of this polyline
|
34
|
+
*/
|
35
|
+
get endPoint(): AcGePoint2d;
|
36
|
+
/**
|
37
|
+
* @inheritdoc
|
38
|
+
*/
|
39
|
+
get length(): number;
|
40
|
+
/**
|
41
|
+
* @inheritdoc
|
42
|
+
*/
|
43
|
+
calculateBoundingBox(): AcGeBox2d;
|
44
|
+
/**
|
45
|
+
* @inheritdoc
|
46
|
+
*/
|
47
|
+
transform(_matrix: AcGeMatrix2d): this;
|
48
|
+
/**
|
49
|
+
* @inheritdoc
|
50
|
+
*/
|
51
|
+
get closed(): boolean;
|
52
|
+
/**
|
53
|
+
* Return boundary points of this area
|
54
|
+
* @param numPoints Input the nubmer of points returned for arc segmentation
|
55
|
+
* @returns Return points
|
56
|
+
*/
|
57
|
+
getPoints(numPoints: number): AcGePoint2d[];
|
58
|
+
}
|
59
|
+
//# sourceMappingURL=AcGeLoop2d.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AcGeLoop2d.d.ts","sourceRoot":"","sources":["../../src/geometry/AcGeLoop2d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAe,MAAM,SAAS,CAAA;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,MAAM,MAAM,oBAAoB,GAC5B,UAAU,GACV,aAAa,GACb,YAAY,GACZ,gBAAgB,CAAA;AAEpB;;;GAGG;AACH,qBAAa,UAAW,SAAQ,WAAW;IACzC,OAAO,CAAC,OAAO,CAA6B;IAE5C;;;OAGG;gBACS,MAAM,GAAE,KAAK,CAAC,oBAAoB,CAAM;IAKpD,IAAI,MAAM,IACe,aAAa,CAAC,oBAAoB,CAAC,CAC3D;IAED;;;OAGG;IACH,GAAG,CAAC,KAAK,EAAE,oBAAoB;IAK/B;;OAEG;IACH,IAAI,aAAa,WAEhB;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,WAAW,CAM5B;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,WAAW,CAE1B;IAED;;OAEG;IACH,IAAI,MAAM,WAMT;IAED;;OAEG;IACH,oBAAoB,IAAI,SAAS;IAOjC;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,YAAY;IAM/B;;OAEG;IACH,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED;;;;OAIG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,EAAE;CAS5C"}
|
@@ -0,0 +1,141 @@
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
2
|
+
var extendStatics = function (d, b) {
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
+
return extendStatics(d, b);
|
7
|
+
};
|
8
|
+
return function (d, b) {
|
9
|
+
if (typeof b !== "function" && b !== null)
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
+
extendStatics(d, b);
|
12
|
+
function __() { this.constructor = d; }
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
+
};
|
15
|
+
})();
|
16
|
+
import { AcGeBox2d, AcGePoint2d } from '../math';
|
17
|
+
import { AcGeCurve2d } from './AcGeCurve2d';
|
18
|
+
/**
|
19
|
+
* The class representing one closed loop created by connected edges, which can be line, circular arc,
|
20
|
+
* ellipse arc, or spline.
|
21
|
+
*/
|
22
|
+
var AcGeLoop2d = /** @class */ (function (_super) {
|
23
|
+
__extends(AcGeLoop2d, _super);
|
24
|
+
/**
|
25
|
+
* Create one loop by connected curves
|
26
|
+
* @param curves Input one array of connected curves
|
27
|
+
*/
|
28
|
+
function AcGeLoop2d(curves) {
|
29
|
+
if (curves === void 0) { curves = []; }
|
30
|
+
var _this = _super.call(this) || this;
|
31
|
+
_this._curves = curves;
|
32
|
+
return _this;
|
33
|
+
}
|
34
|
+
Object.defineProperty(AcGeLoop2d.prototype, "curves", {
|
35
|
+
get: function () {
|
36
|
+
return this._curves;
|
37
|
+
},
|
38
|
+
enumerable: false,
|
39
|
+
configurable: true
|
40
|
+
});
|
41
|
+
/**
|
42
|
+
* Append an edge to this loop
|
43
|
+
* @param curve
|
44
|
+
*/
|
45
|
+
AcGeLoop2d.prototype.add = function (curve) {
|
46
|
+
this._curves.push(curve);
|
47
|
+
this._boundingBoxNeedsUpdate = true;
|
48
|
+
};
|
49
|
+
Object.defineProperty(AcGeLoop2d.prototype, "numberOfEdges", {
|
50
|
+
/**
|
51
|
+
* The number of edges in this loop
|
52
|
+
*/
|
53
|
+
get: function () {
|
54
|
+
return this._curves.length;
|
55
|
+
},
|
56
|
+
enumerable: false,
|
57
|
+
configurable: true
|
58
|
+
});
|
59
|
+
Object.defineProperty(AcGeLoop2d.prototype, "startPoint", {
|
60
|
+
/**
|
61
|
+
* Start point of this polyline
|
62
|
+
*/
|
63
|
+
get: function () {
|
64
|
+
if (this._curves.length > 0) {
|
65
|
+
var temp = this._curves[0].startPoint;
|
66
|
+
return new AcGePoint2d(temp.x, temp.y);
|
67
|
+
}
|
68
|
+
throw new Error('Start point does not exist in an empty loop.');
|
69
|
+
},
|
70
|
+
enumerable: false,
|
71
|
+
configurable: true
|
72
|
+
});
|
73
|
+
Object.defineProperty(AcGeLoop2d.prototype, "endPoint", {
|
74
|
+
/**
|
75
|
+
* End point of this polyline
|
76
|
+
*/
|
77
|
+
get: function () {
|
78
|
+
return this.startPoint;
|
79
|
+
},
|
80
|
+
enumerable: false,
|
81
|
+
configurable: true
|
82
|
+
});
|
83
|
+
Object.defineProperty(AcGeLoop2d.prototype, "length", {
|
84
|
+
/**
|
85
|
+
* @inheritdoc
|
86
|
+
*/
|
87
|
+
get: function () {
|
88
|
+
var length = 0;
|
89
|
+
this._curves.forEach(function (curve) {
|
90
|
+
length += curve.length;
|
91
|
+
});
|
92
|
+
return length;
|
93
|
+
},
|
94
|
+
enumerable: false,
|
95
|
+
configurable: true
|
96
|
+
});
|
97
|
+
/**
|
98
|
+
* @inheritdoc
|
99
|
+
*/
|
100
|
+
AcGeLoop2d.prototype.calculateBoundingBox = function () {
|
101
|
+
var points = this.getPoints(100);
|
102
|
+
var box2d = new AcGeBox2d();
|
103
|
+
box2d.setFromPoints(points);
|
104
|
+
return box2d;
|
105
|
+
};
|
106
|
+
/**
|
107
|
+
* @inheritdoc
|
108
|
+
*/
|
109
|
+
AcGeLoop2d.prototype.transform = function (_matrix) {
|
110
|
+
// TODO: implement it
|
111
|
+
this._boundingBoxNeedsUpdate = true;
|
112
|
+
return this;
|
113
|
+
};
|
114
|
+
Object.defineProperty(AcGeLoop2d.prototype, "closed", {
|
115
|
+
/**
|
116
|
+
* @inheritdoc
|
117
|
+
*/
|
118
|
+
get: function () {
|
119
|
+
return true;
|
120
|
+
},
|
121
|
+
enumerable: false,
|
122
|
+
configurable: true
|
123
|
+
});
|
124
|
+
/**
|
125
|
+
* Return boundary points of this area
|
126
|
+
* @param numPoints Input the nubmer of points returned for arc segmentation
|
127
|
+
* @returns Return points
|
128
|
+
*/
|
129
|
+
AcGeLoop2d.prototype.getPoints = function (numPoints) {
|
130
|
+
var points = [];
|
131
|
+
this.curves.forEach(function (curve) {
|
132
|
+
curve.getPoints(numPoints).forEach(function (point) {
|
133
|
+
points.push(new AcGePoint2d(point.x, point.y));
|
134
|
+
});
|
135
|
+
});
|
136
|
+
return points;
|
137
|
+
};
|
138
|
+
return AcGeLoop2d;
|
139
|
+
}(AcGeCurve2d));
|
140
|
+
export { AcGeLoop2d };
|
141
|
+
//# sourceMappingURL=AcGeLoop2d.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AcGeLoop2d.js","sourceRoot":"","sources":["../../src/geometry/AcGeLoop2d.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,OAAO,EAAE,SAAS,EAAgB,WAAW,EAAe,MAAM,SAAS,CAAA;AAE3E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAS3C;;;GAGG;AACH;IAAgC,8BAAW;IAGzC;;;OAGG;IACH,oBAAY,MAAwC;QAAxC,uBAAA,EAAA,WAAwC;QAClD,YAAA,MAAK,WAAE,SAAA;QACP,KAAI,CAAC,OAAO,GAAG,MAAM,CAAA;;IACvB,CAAC;IAED,sBAAI,8BAAM;aAAV;YACE,OAAO,IAAI,CAAC,OAA8C,CAAA;QAC5D,CAAC;;;OAAA;IAED;;;OAGG;IACH,wBAAG,GAAH,UAAI,KAA2B;QAC7B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACxB,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAA;IACrC,CAAC;IAKD,sBAAI,qCAAa;QAHjB;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAA;QAC5B,CAAC;;;OAAA;IAKD,sBAAI,kCAAU;QAHd;;WAEG;aACH;YACE,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC5B,IAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;gBACvC,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,E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