@itwin/core-geometry 4.0.0-dev.99 → 4.1.0-dev.11
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/Geometry.d.ts.map +1 -1
- package/lib/cjs/Geometry.js +8 -5
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/curve/Arc3d.d.ts +70 -86
- package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
- package/lib/cjs/curve/Arc3d.js +109 -96
- package/lib/cjs/curve/Arc3d.js.map +1 -1
- package/lib/cjs/curve/CurveCollection.d.ts +47 -30
- package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCollection.js +63 -34
- package/lib/cjs/curve/CurveCollection.js.map +1 -1
- package/lib/cjs/curve/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCurveIntersectXY.js +3 -3
- package/lib/cjs/curve/CurveCurveIntersectXY.js.map +1 -1
- package/lib/cjs/curve/CurveLocationDetail.d.ts +41 -42
- package/lib/cjs/curve/CurveLocationDetail.d.ts.map +1 -1
- package/lib/cjs/curve/CurveLocationDetail.js +32 -36
- package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.d.ts +137 -92
- package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.js +114 -75
- package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
- package/lib/cjs/curve/GeometryQuery.d.ts +26 -20
- package/lib/cjs/curve/GeometryQuery.d.ts.map +1 -1
- package/lib/cjs/curve/GeometryQuery.js +11 -9
- package/lib/cjs/curve/GeometryQuery.js.map +1 -1
- package/lib/cjs/curve/LineSegment3d.d.ts +34 -25
- package/lib/cjs/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineSegment3d.js +76 -38
- package/lib/cjs/curve/LineSegment3d.js.map +1 -1
- package/lib/cjs/curve/LineString3d.d.ts +70 -51
- package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineString3d.js +120 -71
- package/lib/cjs/curve/LineString3d.js.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.d.ts +3 -2
- package/lib/cjs/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.js +57 -43
- package/lib/cjs/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/cjs/curve/Query/StrokeCountMap.d.ts +14 -13
- package/lib/cjs/curve/Query/StrokeCountMap.d.ts.map +1 -1
- package/lib/cjs/curve/Query/StrokeCountMap.js +9 -8
- package/lib/cjs/curve/Query/StrokeCountMap.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +7 -5
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +17 -16
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/cjs/curve/StrokeOptions.d.ts +29 -21
- package/lib/cjs/curve/StrokeOptions.d.ts.map +1 -1
- package/lib/cjs/curve/StrokeOptions.js +44 -22
- package/lib/cjs/curve/StrokeOptions.js.map +1 -1
- package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts +9 -9
- package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/CoincidentGeometryOps.js +82 -56
- package/lib/cjs/geometry3d/CoincidentGeometryOps.js.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.d.ts +2 -2
- package/lib/cjs/geometry3d/Matrix3d.js +3 -3
- package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
- package/lib/cjs/topology/Merging.d.ts +1 -0
- package/lib/cjs/topology/Merging.d.ts.map +1 -1
- package/lib/cjs/topology/Merging.js +1 -0
- package/lib/cjs/topology/Merging.js.map +1 -1
- package/lib/esm/Geometry.d.ts.map +1 -1
- package/lib/esm/Geometry.js +8 -5
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/curve/Arc3d.d.ts +70 -86
- package/lib/esm/curve/Arc3d.d.ts.map +1 -1
- package/lib/esm/curve/Arc3d.js +109 -96
- package/lib/esm/curve/Arc3d.js.map +1 -1
- package/lib/esm/curve/CurveCollection.d.ts +47 -30
- package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
- package/lib/esm/curve/CurveCollection.js +63 -34
- package/lib/esm/curve/CurveCollection.js.map +1 -1
- package/lib/esm/curve/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/esm/curve/CurveCurveIntersectXY.js +3 -3
- package/lib/esm/curve/CurveCurveIntersectXY.js.map +1 -1
- package/lib/esm/curve/CurveLocationDetail.d.ts +41 -42
- package/lib/esm/curve/CurveLocationDetail.d.ts.map +1 -1
- package/lib/esm/curve/CurveLocationDetail.js +32 -36
- package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
- package/lib/esm/curve/CurvePrimitive.d.ts +137 -92
- package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/esm/curve/CurvePrimitive.js +114 -75
- package/lib/esm/curve/CurvePrimitive.js.map +1 -1
- package/lib/esm/curve/GeometryQuery.d.ts +26 -20
- package/lib/esm/curve/GeometryQuery.d.ts.map +1 -1
- package/lib/esm/curve/GeometryQuery.js +11 -9
- package/lib/esm/curve/GeometryQuery.js.map +1 -1
- package/lib/esm/curve/LineSegment3d.d.ts +34 -25
- package/lib/esm/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/esm/curve/LineSegment3d.js +76 -38
- package/lib/esm/curve/LineSegment3d.js.map +1 -1
- package/lib/esm/curve/LineString3d.d.ts +70 -51
- package/lib/esm/curve/LineString3d.d.ts.map +1 -1
- package/lib/esm/curve/LineString3d.js +120 -71
- package/lib/esm/curve/LineString3d.js.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.d.ts +3 -2
- package/lib/esm/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.js +58 -44
- package/lib/esm/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/esm/curve/Query/StrokeCountMap.d.ts +14 -13
- package/lib/esm/curve/Query/StrokeCountMap.d.ts.map +1 -1
- package/lib/esm/curve/Query/StrokeCountMap.js +9 -8
- package/lib/esm/curve/Query/StrokeCountMap.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +7 -5
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +17 -16
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.js +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/esm/curve/StrokeOptions.d.ts +29 -21
- package/lib/esm/curve/StrokeOptions.d.ts.map +1 -1
- package/lib/esm/curve/StrokeOptions.js +44 -22
- package/lib/esm/curve/StrokeOptions.js.map +1 -1
- package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts +9 -9
- package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/CoincidentGeometryOps.js +82 -56
- package/lib/esm/geometry3d/CoincidentGeometryOps.js.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.d.ts +2 -2
- package/lib/esm/geometry3d/Matrix3d.js +3 -3
- package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
- package/lib/esm/topology/Merging.d.ts +1 -0
- package/lib/esm/topology/Merging.d.ts.map +1 -1
- package/lib/esm/topology/Merging.js +1 -0
- package/lib/esm/topology/Merging.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Angle } from "../geometry3d/Angle";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Tolerance blob for various stroking methods.
|
|
3
4
|
*
|
|
4
5
|
* * Across many applications, the critical concepts are: chordTol, angleTol, maxEdgeLength
|
|
5
6
|
* * Chord error is an distance measured from a curve or facet to its approximating stroke or facet.
|
|
@@ -21,17 +22,17 @@ import { Angle } from "../geometry3d/Angle";
|
|
|
21
22
|
* @public
|
|
22
23
|
*/
|
|
23
24
|
export declare class StrokeOptions {
|
|
24
|
-
/**
|
|
25
|
+
/** Distance from stroke to actual geometry */
|
|
25
26
|
chordTol?: number;
|
|
26
|
-
/**
|
|
27
|
+
/** Turning angle between strokes. */
|
|
27
28
|
angleTol?: Angle;
|
|
28
|
-
/**
|
|
29
|
+
/** Maximum length of a single stroke. */
|
|
29
30
|
maxEdgeLength?: number;
|
|
30
|
-
/**
|
|
31
|
+
/** Caller expects convex facets. */
|
|
31
32
|
needConvexFacets?: boolean;
|
|
32
|
-
/**
|
|
33
|
+
/** Minimum strokes on a primitive */
|
|
33
34
|
minStrokesPerPrimitive?: number;
|
|
34
|
-
/**
|
|
35
|
+
/** Whether or not to triangulate each added facet */
|
|
35
36
|
shouldTriangulate: boolean;
|
|
36
37
|
private _needNormals?;
|
|
37
38
|
private _needTwoSided?;
|
|
@@ -45,27 +46,29 @@ export declare class StrokeOptions {
|
|
|
45
46
|
/** Whether twoSided is requested. */
|
|
46
47
|
get needTwoSided(): boolean;
|
|
47
48
|
set needTwoSided(value: boolean);
|
|
48
|
-
/**
|
|
49
|
+
/** Optional color request flag */
|
|
49
50
|
needColors?: boolean;
|
|
50
|
-
/**
|
|
51
|
+
/** Default number of strokes for a circle. */
|
|
51
52
|
defaultCircleStrokes: number;
|
|
52
|
-
/**
|
|
53
|
+
/** Ask if angleTol is specified */
|
|
53
54
|
get hasAngleTol(): boolean;
|
|
54
|
-
/**
|
|
55
|
+
/** Ask if chordTol is specified */
|
|
55
56
|
get hasChordTol(): boolean;
|
|
56
|
-
/**
|
|
57
|
+
/** Ask if maxEdgeLength is specified */
|
|
57
58
|
get hasMaxEdgeLength(): boolean;
|
|
58
59
|
/** Return a deep clone */
|
|
59
60
|
clone(): StrokeOptions;
|
|
60
|
-
/**
|
|
61
|
+
/** Return stroke count which is the larger of the minCount or count needed for edge length condition. */
|
|
61
62
|
applyMaxEdgeLength(minCount: number, totalLength: number): number;
|
|
62
63
|
/**
|
|
63
|
-
*
|
|
64
|
+
* Return stroke count which is the larger of the existing count or count needed for angle condition for given
|
|
65
|
+
* sweepRadians.
|
|
64
66
|
* * defaultStepRadians is assumed to be larger than zero.
|
|
65
67
|
*/
|
|
66
68
|
applyAngleTol(minCount: number, sweepRadians: number, defaultStepRadians: number): number;
|
|
67
69
|
/**
|
|
68
|
-
*
|
|
70
|
+
* Return stroke count which is the larger of minCount and the count required to turn sweepRadians, using tolerance
|
|
71
|
+
* from the options.
|
|
69
72
|
*/
|
|
70
73
|
static applyAngleTol(options: StrokeOptions | undefined, minCount: number, sweepRadians: number, defaultStepRadians?: number): number;
|
|
71
74
|
/**
|
|
@@ -76,22 +79,27 @@ export declare class StrokeOptions {
|
|
|
76
79
|
*/
|
|
77
80
|
static applyMaxEdgeLength(options: StrokeOptions | undefined, minCount: number, edgeLength: number): number;
|
|
78
81
|
/**
|
|
79
|
-
* Determine a stroke count for a (partial) circular arc of given radius. This considers angle, maxEdgeLength,
|
|
82
|
+
* Determine a stroke count for a (partial) circular arc of given radius. This considers angle, maxEdgeLength,
|
|
83
|
+
* chord, and minimum stroke.
|
|
80
84
|
*/
|
|
81
85
|
applyTolerancesToArc(radius: number, sweepRadians?: number): number;
|
|
82
|
-
/**
|
|
86
|
+
/** Return stroke count which is the larger of existing count or count needed for circular arc chord tolerance condition. */
|
|
83
87
|
applyChordTol(minCount: number, radius: number, sweepRadians: number): number;
|
|
84
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* Return stroke count which is the larger of existing count or count needed for circular arc chord tol with given
|
|
90
|
+
* arc length and radians
|
|
85
91
|
*/
|
|
86
92
|
applyChordTolToLengthAndRadians(minCount: number, length: number, sweepRadians: number): number;
|
|
87
|
-
/**
|
|
93
|
+
/** Return stroke count which is the larger of existing count or `this.minStrokesPerPrimitive` */
|
|
88
94
|
applyMinStrokesPerPrimitive(minCount: number): number;
|
|
89
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* Create `StrokeOptions` with defaults appropriate for curves.
|
|
90
97
|
* * angle tolerance of 15 degrees.
|
|
91
98
|
* * all others inactive.
|
|
92
99
|
*/
|
|
93
100
|
static createForCurves(): StrokeOptions;
|
|
94
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Create `StrokeOptions` with defaults appropriate for surfaces facets
|
|
95
103
|
* * angle tolerance of 22.5 degrees.
|
|
96
104
|
* * all others inactive.
|
|
97
105
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StrokeOptions.d.ts","sourceRoot":"","sources":["../../../src/curve/StrokeOptions.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAI5C
|
|
1
|
+
{"version":3,"file":"StrokeOptions.d.ts","sourceRoot":"","sources":["../../../src/curve/StrokeOptions.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAI5C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,aAAa;IACxB,8CAA8C;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IACzB,qCAAqC;IAC9B,QAAQ,CAAC,EAAE,KAAK,CAAC;IACxB,yCAAyC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IAC9B,qCAAqC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAClC,qCAAqC;IAC9B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IACvC,qDAAqD;IAC9C,iBAAiB,EAAE,OAAO,CAAS;IAC1C,OAAO,CAAC,YAAY,CAAC,CAAU;IAC/B,OAAO,CAAC,aAAa,CAAC,CAAU;IAChC,OAAO,CAAC,WAAW,CAAC,CAAU;IAC9B,oC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YAAY,EAAE,MAAM,GAAG,MAAM;IAQpF;;;OAGG;IACI,+BAA+B,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM;IAQtG,iGAAiG;IAC1F,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAM5D;;;;OAIG;WACW,eAAe,IAAI,aAAa;IAK9C;;;;OAIG;WACW,eAAe,IAAI,aAAa;CAK/C"}
|
|
@@ -11,7 +11,8 @@ exports.StrokeOptions = void 0;
|
|
|
11
11
|
const Geometry_1 = require("../Geometry");
|
|
12
12
|
const Angle_1 = require("../geometry3d/Angle");
|
|
13
13
|
/* eslint-disable @typescript-eslint/naming-convention, no-empty */
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Tolerance blob for various stroking methods.
|
|
15
16
|
*
|
|
16
17
|
* * Across many applications, the critical concepts are: chordTol, angleTol, maxEdgeLength
|
|
17
18
|
* * Chord error is an distance measured from a curve or facet to its approximating stroke or facet.
|
|
@@ -34,26 +35,40 @@ const Angle_1 = require("../geometry3d/Angle");
|
|
|
34
35
|
*/
|
|
35
36
|
class StrokeOptions {
|
|
36
37
|
constructor() {
|
|
37
|
-
/**
|
|
38
|
+
/** Whether or not to triangulate each added facet */
|
|
38
39
|
this.shouldTriangulate = false;
|
|
39
|
-
/**
|
|
40
|
+
/** Default number of strokes for a circle. */
|
|
40
41
|
this.defaultCircleStrokes = 16;
|
|
41
42
|
}
|
|
42
43
|
/** Whether params are requested. */
|
|
43
|
-
get needParams() {
|
|
44
|
-
|
|
44
|
+
get needParams() {
|
|
45
|
+
return this._needParams !== undefined ? this._needParams : false;
|
|
46
|
+
}
|
|
47
|
+
set needParams(value) {
|
|
48
|
+
this._needParams = value;
|
|
49
|
+
}
|
|
45
50
|
/** Whether normals are requested */
|
|
46
|
-
get needNormals() {
|
|
51
|
+
get needNormals() {
|
|
52
|
+
return this._needNormals !== undefined ? this._needNormals : false;
|
|
53
|
+
}
|
|
47
54
|
set needNormals(value) { this._needNormals = value; }
|
|
48
55
|
/** Whether twoSided is requested. */
|
|
49
|
-
get needTwoSided() {
|
|
56
|
+
get needTwoSided() {
|
|
57
|
+
return this._needTwoSided !== undefined ? this._needTwoSided : false;
|
|
58
|
+
}
|
|
50
59
|
set needTwoSided(value) { this._needTwoSided = value; }
|
|
51
|
-
/**
|
|
52
|
-
get hasAngleTol() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
get
|
|
60
|
+
/** Ask if angleTol is specified */
|
|
61
|
+
get hasAngleTol() {
|
|
62
|
+
return this.angleTol !== undefined && Math.abs(this.angleTol.radians) > 0.0;
|
|
63
|
+
}
|
|
64
|
+
/** Ask if chordTol is specified */
|
|
65
|
+
get hasChordTol() {
|
|
66
|
+
return this.chordTol !== undefined && this.chordTol > 0.0;
|
|
67
|
+
}
|
|
68
|
+
/** Ask if maxEdgeLength is specified */
|
|
69
|
+
get hasMaxEdgeLength() {
|
|
70
|
+
return this.maxEdgeLength !== undefined && this.maxEdgeLength > 0.0;
|
|
71
|
+
}
|
|
57
72
|
/** Return a deep clone */
|
|
58
73
|
clone() {
|
|
59
74
|
const options = new StrokeOptions();
|
|
@@ -70,7 +85,7 @@ class StrokeOptions {
|
|
|
70
85
|
options.defaultCircleStrokes = this.defaultCircleStrokes;
|
|
71
86
|
return options;
|
|
72
87
|
}
|
|
73
|
-
/**
|
|
88
|
+
/** Return stroke count which is the larger of the minCount or count needed for edge length condition. */
|
|
74
89
|
applyMaxEdgeLength(minCount, totalLength) {
|
|
75
90
|
totalLength = Math.abs(totalLength);
|
|
76
91
|
if (this.maxEdgeLength && this.maxEdgeLength > 0.0 && minCount * this.maxEdgeLength < totalLength) {
|
|
@@ -79,14 +94,16 @@ class StrokeOptions {
|
|
|
79
94
|
return minCount;
|
|
80
95
|
}
|
|
81
96
|
/**
|
|
82
|
-
*
|
|
97
|
+
* Return stroke count which is the larger of the existing count or count needed for angle condition for given
|
|
98
|
+
* sweepRadians.
|
|
83
99
|
* * defaultStepRadians is assumed to be larger than zero.
|
|
84
100
|
*/
|
|
85
101
|
applyAngleTol(minCount, sweepRadians, defaultStepRadians) {
|
|
86
102
|
return StrokeOptions.applyAngleTol(this, minCount, sweepRadians, defaultStepRadians);
|
|
87
103
|
}
|
|
88
104
|
/**
|
|
89
|
-
*
|
|
105
|
+
* Return stroke count which is the larger of minCount and the count required to turn sweepRadians, using tolerance
|
|
106
|
+
* from the options.
|
|
90
107
|
*/
|
|
91
108
|
static applyAngleTol(options, minCount, sweepRadians, defaultStepRadians) {
|
|
92
109
|
sweepRadians = Math.abs(sweepRadians);
|
|
@@ -114,7 +131,8 @@ class StrokeOptions {
|
|
|
114
131
|
return minCount;
|
|
115
132
|
}
|
|
116
133
|
/**
|
|
117
|
-
* Determine a stroke count for a (partial) circular arc of given radius. This considers angle, maxEdgeLength,
|
|
134
|
+
* Determine a stroke count for a (partial) circular arc of given radius. This considers angle, maxEdgeLength,
|
|
135
|
+
* chord, and minimum stroke.
|
|
118
136
|
*/
|
|
119
137
|
applyTolerancesToArc(radius, sweepRadians = Math.PI * 2) {
|
|
120
138
|
let numStrokes = 1;
|
|
@@ -124,7 +142,7 @@ class StrokeOptions {
|
|
|
124
142
|
numStrokes = this.applyMinStrokesPerPrimitive(numStrokes);
|
|
125
143
|
return numStrokes;
|
|
126
144
|
}
|
|
127
|
-
/**
|
|
145
|
+
/** Return stroke count which is the larger of existing count or count needed for circular arc chord tolerance condition. */
|
|
128
146
|
applyChordTol(minCount, radius, sweepRadians) {
|
|
129
147
|
if (this.chordTol && this.chordTol > 0.0 && this.chordTol < radius) {
|
|
130
148
|
const a = this.chordTol;
|
|
@@ -133,7 +151,9 @@ class StrokeOptions {
|
|
|
133
151
|
}
|
|
134
152
|
return minCount;
|
|
135
153
|
}
|
|
136
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* Return stroke count which is the larger of existing count or count needed for circular arc chord tol with given
|
|
156
|
+
* arc length and radians
|
|
137
157
|
*/
|
|
138
158
|
applyChordTolToLengthAndRadians(minCount, length, sweepRadians) {
|
|
139
159
|
if (this.chordTol && this.chordTol > 0.0) {
|
|
@@ -143,14 +163,15 @@ class StrokeOptions {
|
|
|
143
163
|
}
|
|
144
164
|
return minCount;
|
|
145
165
|
}
|
|
146
|
-
/**
|
|
166
|
+
/** Return stroke count which is the larger of existing count or `this.minStrokesPerPrimitive` */
|
|
147
167
|
applyMinStrokesPerPrimitive(minCount) {
|
|
148
168
|
if (this.minStrokesPerPrimitive !== undefined && Number.isFinite(this.minStrokesPerPrimitive)
|
|
149
169
|
&& this.minStrokesPerPrimitive > minCount)
|
|
150
170
|
minCount = this.minStrokesPerPrimitive;
|
|
151
171
|
return minCount;
|
|
152
172
|
}
|
|
153
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* Create `StrokeOptions` with defaults appropriate for curves.
|
|
154
175
|
* * angle tolerance of 15 degrees.
|
|
155
176
|
* * all others inactive.
|
|
156
177
|
*/
|
|
@@ -159,7 +180,8 @@ class StrokeOptions {
|
|
|
159
180
|
options.angleTol = Angle_1.Angle.createDegrees(15.0);
|
|
160
181
|
return options;
|
|
161
182
|
}
|
|
162
|
-
/**
|
|
183
|
+
/**
|
|
184
|
+
* Create `StrokeOptions` with defaults appropriate for surfaces facets
|
|
163
185
|
* * angle tolerance of 22.5 degrees.
|
|
164
186
|
* * all others inactive.
|
|
165
187
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StrokeOptions.js","sourceRoot":"","sources":["../../../src/curve/StrokeOptions.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AACvC,+CAA4C;AAE5C,mEAAmE;AAEnE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,aAAa;IAA1B;QAYE,qDAAqD;QAC9C,sBAAiB,GAAY,KAAK,CAAC;QAe1C,8CAA8C;QACvC,yB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,CAAC,sBAAsB,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,sBAAsB,CAAC;eACxF,IAAI,CAAC,sBAAsB,GAAG,QAAQ;YACzC,QAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC;QACzC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,eAAe;QAC3B,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,OAAO,CAAC,QAAQ,GAAG,aAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,eAAe;QAC3B,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,OAAO,CAAC,QAAQ,GAAG,aAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA5JD,sCA4JC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Angle } from \"../geometry3d/Angle\";\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\r\n\r\n/** tolerance blob for various stroking methods.\r\n *\r\n * * Across many applications, the critical concepts are: chordTol, angleTol, maxEdgeLength\r\n * * Chord error is an distance measured from a curve or facet to its approximating stroke or facet.\r\n * * angle is the angle between two contiguous strokes or across a facet edge.\r\n * * maxEdgeLength is the length of a stroke or a edge of a facet.\r\n *\r\n * It is rare for all three to be active at once:\r\n * * Nearly all stroke and facet use cases will apply an angle tolerance.\r\n * * * For curves, 15 degrees is typical\r\n * * * For facets, 22.5 degrees is typical.\r\n * * * Halving the angle tolerance will (roughly) make curves get twice as many strokes, and surfaces get 4 times as many facets.\r\n * * * The angle tolerance has the useful property that its effect is independent of scale of that data. If data is suddenly scaled into millimeters rather than meters, the facet counts remain the same.\r\n * * When creating output for devices such as 3D printing will want a chord tolerance.\r\n * * For graphics display, use an angle tolerance of around 15 degrees and an chord tolerance which is the size of several pixels.\r\n * * Analysis meshes (e.g. Finite Elements) commonly need to apply maxEdgeLength.\r\n * * * Using maxEdgeLength for graphics probably produces too many facets. For example, it causes long cylinders to get many nearly-square facets instead of the small number of long quads usually used for graphics.\r\n * * Facet tolerances are, as the Pirates' Code, guidelines, not absolute rules. Facet and stroke code may ignore tolerances in awkward situations.\r\n * * If multiple tolerances are in effect, the actual count will usually be based on the one that demands the most strokes or facets, unless it is so high that it violates some upper limit on the number of facets on an arc or a section of a curve.\r\n * @public\r\n */\r\nexport class StrokeOptions {\r\n\r\n /** distance from stroke to actual geometry */\r\n public chordTol?: number;\r\n /** turning angle between strokes. */\r\n public angleTol?: Angle;\r\n /** maximum length of a single stroke. */\r\n public maxEdgeLength?: number;\r\n /** caller expects convex facets. */\r\n public needConvexFacets?: boolean;\r\n /** minimum strokes on a primitive */\r\n public minStrokesPerPrimitive?: number;\r\n /** whether or not to triangulate each added facet */\r\n public shouldTriangulate: boolean = false;\r\n private _needNormals?: boolean;\r\n private _needTwoSided?: boolean;\r\n private _needParams?: boolean;\r\n /** Whether params are requested. */\r\n public get needParams(): boolean { return this._needParams !== undefined ? this._needParams : false; }\r\n public set needParams(value: boolean) { this._needParams = value; }\r\n /** Whether normals are requested */\r\n public get needNormals(): boolean { return this._needNormals !== undefined ? this._needNormals : false; }\r\n public set needNormals(value: boolean) { this._needNormals = value; }\r\n /** Whether twoSided is requested. */\r\n public get needTwoSided(): boolean { return this._needTwoSided !== undefined ? this._needTwoSided : false; }\r\n public set needTwoSided(value: boolean) { this._needTwoSided = value; }\r\n /** optional color request flag */\r\n public needColors?: boolean;\r\n /** default number of strokes for a circle. */\r\n public defaultCircleStrokes = 16;\r\n /** ask if angleTol is specified */\r\n public get hasAngleTol(): boolean { return this.angleTol !== undefined && Math.abs(this.angleTol.radians) > 0.0; }\r\n /** ask if chordTol is specified */\r\n public get hasChordTol(): boolean { return this.chordTol !== undefined && this.chordTol > 0.0; }\r\n /** ask if maxEdgeLength is specified */\r\n public get hasMaxEdgeLength(): boolean { return this.maxEdgeLength !== undefined && this.maxEdgeLength > 0.0; }\r\n\r\n /** Return a deep clone */\r\n public clone(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.chordTol = this.chordTol;\r\n options.angleTol = this.angleTol?.clone();\r\n options.maxEdgeLength = this.maxEdgeLength;\r\n options.needConvexFacets = this.needConvexFacets;\r\n options.minStrokesPerPrimitive = this.minStrokesPerPrimitive;\r\n options.shouldTriangulate = this.shouldTriangulate;\r\n options._needNormals = this._needNormals;\r\n options._needTwoSided = this._needTwoSided;\r\n options._needParams = this._needParams;\r\n options.needColors = this.needColors;\r\n options.defaultCircleStrokes = this.defaultCircleStrokes;\r\n return options;\r\n }\r\n\r\n /** return stroke count which is the larger of the minCount or count needed for edge length condition. */\r\n public applyMaxEdgeLength(minCount: number, totalLength: number): number {\r\n totalLength = Math.abs(totalLength);\r\n if (this.maxEdgeLength && this.maxEdgeLength > 0.0 && minCount * this.maxEdgeLength < totalLength) {\r\n minCount = Geometry.stepCount(this.maxEdgeLength, totalLength, minCount);\r\n }\r\n return minCount;\r\n }\r\n\r\n /**\r\n * return stroke count which is the larger of the existing count or count needed for angle condition for given sweepRadians\r\n * * defaultStepRadians is assumed to be larger than zero.\r\n */\r\n public applyAngleTol(minCount: number, sweepRadians: number, defaultStepRadians: number): number {\r\n return StrokeOptions.applyAngleTol(this, minCount, sweepRadians, defaultStepRadians);\r\n }\r\n /**\r\n * return stroke count which is the larger of minCount and the count required to turn sweepRadians, using tolerance from the options.\r\n */\r\n public static applyAngleTol(options: StrokeOptions | undefined, minCount: number, sweepRadians: number, defaultStepRadians?: number): number {\r\n sweepRadians = Math.abs(sweepRadians);\r\n let stepRadians = defaultStepRadians ? defaultStepRadians : Math.PI / 8.0;\r\n if (options && options.angleTol && options.angleTol.radians > 0.0)\r\n stepRadians = options.angleTol.radians;\r\n if (minCount * stepRadians < sweepRadians)\r\n minCount = Geometry.stepCount(stepRadians, sweepRadians, minCount);\r\n return minCount;\r\n }\r\n /**\r\n * Return the number of strokes needed for given edgeLength curve.\r\n * @param options\r\n * @param minCount smallest allowed count\r\n * @param edgeLength\r\n */\r\n public static applyMaxEdgeLength(options: StrokeOptions | undefined, minCount: number, edgeLength: number): number {\r\n if (edgeLength < 0)\r\n edgeLength = - edgeLength;\r\n if (minCount < 1)\r\n minCount = 1;\r\n if (options && options.maxEdgeLength && options.maxEdgeLength * minCount < edgeLength) {\r\n minCount = Geometry.stepCount(options.maxEdgeLength, edgeLength, minCount);\r\n }\r\n return minCount;\r\n }\r\n /**\r\n * Determine a stroke count for a (partial) circular arc of given radius. This considers angle, maxEdgeLength, chord, and minimum stroke.\r\n */\r\n public applyTolerancesToArc(radius: number, sweepRadians: number = Math.PI * 2): number {\r\n let numStrokes = 1;\r\n numStrokes = this.applyAngleTol(numStrokes, sweepRadians, Math.PI * 0.25);\r\n numStrokes = this.applyMaxEdgeLength(numStrokes, sweepRadians * radius);\r\n numStrokes = this.applyChordTol(numStrokes, radius, sweepRadians);\r\n numStrokes = this.applyMinStrokesPerPrimitive(numStrokes);\r\n return numStrokes;\r\n }\r\n\r\n /** return stroke count which is the larger of existing count or count needed for circular arc chord tolerance condition. */\r\n public applyChordTol(minCount: number, radius: number, sweepRadians: number): number {\r\n if (this.chordTol && this.chordTol > 0.0 && this.chordTol < radius) {\r\n const a = this.chordTol;\r\n const stepRadians = 2.0 * Math.acos((1.0 - a / radius));\r\n minCount = Geometry.stepCount(stepRadians, sweepRadians, minCount);\r\n }\r\n return minCount;\r\n }\r\n /** return stroke count which is the larger of existing count or count needed for circular arc chord tol with given arc length and radians\r\n */\r\n public applyChordTolToLengthAndRadians(minCount: number, length: number, sweepRadians: number): number {\r\n if (this.chordTol && this.chordTol > 0.0) {\r\n const radius = Geometry.conditionalDivideFraction(length, sweepRadians);\r\n if (radius !== undefined)\r\n return this.applyChordTol(minCount, radius, sweepRadians);\r\n }\r\n return minCount;\r\n }\r\n\r\n /** return stroke count which is the larger of existing count or `this.minStrokesPerPrimitive` */\r\n public applyMinStrokesPerPrimitive(minCount: number): number {\r\n if (this.minStrokesPerPrimitive !== undefined && Number.isFinite(this.minStrokesPerPrimitive)\r\n && this.minStrokesPerPrimitive > minCount)\r\n minCount = this.minStrokesPerPrimitive;\r\n return minCount;\r\n }\r\n\r\n /** create `StrokeOptions` with defaults appropriate for curves.\r\n * * angle tolerance of 15 degrees.\r\n * * all others inactive.\r\n */\r\n public static createForCurves(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.angleTol = Angle.createDegrees(15.0);\r\n return options;\r\n }\r\n /** create `StrokeOptions` with defaults appropriate for surfaces facets\r\n * * angle tolerance of 22.5 degrees.\r\n * * all others inactive.\r\n */\r\n public static createForFacets(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.angleTol = Angle.createDegrees(22.5);\r\n return options;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"StrokeOptions.js","sourceRoot":"","sources":["../../../src/curve/StrokeOptions.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AACvC,+CAA4C;AAE5C,mEAAmE;AAEnE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,aAAa;IAA1B;QAWE,qDAAqD;QAC9C,sBAAiB,GAAY,KAAK,CAAC;QAuB1C,8CAA8C;QACvC,yBAAoB,GAAG,EAAE,CAAC;IA0InC,CAAC;IA9JC,oCAAoC;IACpC,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC;IACnE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QAAQ,CAAC;IAClB,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,eAAe;QAC3B,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,OAAO,CAAC,QAAQ,GAAG,aAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,eAAe;QAC3B,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,OAAO,CAAC,QAAQ,GAAG,aAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA9KD,sCA8KC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Angle } from \"../geometry3d/Angle\";\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\r\n\r\n/**\r\n * Tolerance blob for various stroking methods.\r\n *\r\n * * Across many applications, the critical concepts are: chordTol, angleTol, maxEdgeLength\r\n * * Chord error is an distance measured from a curve or facet to its approximating stroke or facet.\r\n * * angle is the angle between two contiguous strokes or across a facet edge.\r\n * * maxEdgeLength is the length of a stroke or a edge of a facet.\r\n *\r\n * It is rare for all three to be active at once:\r\n * * Nearly all stroke and facet use cases will apply an angle tolerance.\r\n * * * For curves, 15 degrees is typical\r\n * * * For facets, 22.5 degrees is typical.\r\n * * * Halving the angle tolerance will (roughly) make curves get twice as many strokes, and surfaces get 4 times as many facets.\r\n * * * The angle tolerance has the useful property that its effect is independent of scale of that data. If data is suddenly scaled into millimeters rather than meters, the facet counts remain the same.\r\n * * When creating output for devices such as 3D printing will want a chord tolerance.\r\n * * For graphics display, use an angle tolerance of around 15 degrees and an chord tolerance which is the size of several pixels.\r\n * * Analysis meshes (e.g. Finite Elements) commonly need to apply maxEdgeLength.\r\n * * * Using maxEdgeLength for graphics probably produces too many facets. For example, it causes long cylinders to get many nearly-square facets instead of the small number of long quads usually used for graphics.\r\n * * Facet tolerances are, as the Pirates' Code, guidelines, not absolute rules. Facet and stroke code may ignore tolerances in awkward situations.\r\n * * If multiple tolerances are in effect, the actual count will usually be based on the one that demands the most strokes or facets, unless it is so high that it violates some upper limit on the number of facets on an arc or a section of a curve.\r\n * @public\r\n */\r\nexport class StrokeOptions {\r\n /** Distance from stroke to actual geometry */\r\n public chordTol?: number;\r\n /** Turning angle between strokes. */\r\n public angleTol?: Angle;\r\n /** Maximum length of a single stroke. */\r\n public maxEdgeLength?: number;\r\n /** Caller expects convex facets. */\r\n public needConvexFacets?: boolean;\r\n /** Minimum strokes on a primitive */\r\n public minStrokesPerPrimitive?: number;\r\n /** Whether or not to triangulate each added facet */\r\n public shouldTriangulate: boolean = false;\r\n private _needNormals?: boolean;\r\n private _needTwoSided?: boolean;\r\n private _needParams?: boolean;\r\n /** Whether params are requested. */\r\n public get needParams(): boolean {\r\n return this._needParams !== undefined ? this._needParams : false;\r\n }\r\n public set needParams(value: boolean) {\r\n this._needParams = value;\r\n }\r\n /** Whether normals are requested */\r\n public get needNormals(): boolean {\r\n return this._needNormals !== undefined ? this._needNormals : false;\r\n }\r\n public set needNormals(value: boolean) { this._needNormals = value; }\r\n /** Whether twoSided is requested. */\r\n public get needTwoSided(): boolean {\r\n return this._needTwoSided !== undefined ? this._needTwoSided : false;\r\n }\r\n public set needTwoSided(value: boolean) { this._needTwoSided = value; }\r\n /** Optional color request flag */\r\n public needColors?: boolean;\r\n /** Default number of strokes for a circle. */\r\n public defaultCircleStrokes = 16;\r\n /** Ask if angleTol is specified */\r\n public get hasAngleTol(): boolean {\r\n return this.angleTol !== undefined && Math.abs(this.angleTol.radians) > 0.0;\r\n }\r\n /** Ask if chordTol is specified */\r\n public get hasChordTol(): boolean {\r\n return this.chordTol !== undefined && this.chordTol > 0.0;\r\n }\r\n /** Ask if maxEdgeLength is specified */\r\n public get hasMaxEdgeLength(): boolean {\r\n return this.maxEdgeLength !== undefined && this.maxEdgeLength > 0.0;\r\n }\r\n /** Return a deep clone */\r\n public clone(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.chordTol = this.chordTol;\r\n options.angleTol = this.angleTol?.clone();\r\n options.maxEdgeLength = this.maxEdgeLength;\r\n options.needConvexFacets = this.needConvexFacets;\r\n options.minStrokesPerPrimitive = this.minStrokesPerPrimitive;\r\n options.shouldTriangulate = this.shouldTriangulate;\r\n options._needNormals = this._needNormals;\r\n options._needTwoSided = this._needTwoSided;\r\n options._needParams = this._needParams;\r\n options.needColors = this.needColors;\r\n options.defaultCircleStrokes = this.defaultCircleStrokes;\r\n return options;\r\n }\r\n /** Return stroke count which is the larger of the minCount or count needed for edge length condition. */\r\n public applyMaxEdgeLength(minCount: number, totalLength: number): number {\r\n totalLength = Math.abs(totalLength);\r\n if (this.maxEdgeLength && this.maxEdgeLength > 0.0 && minCount * this.maxEdgeLength < totalLength) {\r\n minCount = Geometry.stepCount(this.maxEdgeLength, totalLength, minCount);\r\n }\r\n return minCount;\r\n }\r\n /**\r\n * Return stroke count which is the larger of the existing count or count needed for angle condition for given\r\n * sweepRadians.\r\n * * defaultStepRadians is assumed to be larger than zero.\r\n */\r\n public applyAngleTol(minCount: number, sweepRadians: number, defaultStepRadians: number): number {\r\n return StrokeOptions.applyAngleTol(this, minCount, sweepRadians, defaultStepRadians);\r\n }\r\n /**\r\n * Return stroke count which is the larger of minCount and the count required to turn sweepRadians, using tolerance\r\n * from the options.\r\n */\r\n public static applyAngleTol(\r\n options: StrokeOptions | undefined, minCount: number, sweepRadians: number, defaultStepRadians?: number\r\n ): number {\r\n sweepRadians = Math.abs(sweepRadians);\r\n let stepRadians = defaultStepRadians ? defaultStepRadians : Math.PI / 8.0;\r\n if (options && options.angleTol && options.angleTol.radians > 0.0)\r\n stepRadians = options.angleTol.radians;\r\n if (minCount * stepRadians < sweepRadians)\r\n minCount = Geometry.stepCount(stepRadians, sweepRadians, minCount);\r\n return minCount;\r\n }\r\n /**\r\n * Return the number of strokes needed for given edgeLength curve.\r\n * @param options\r\n * @param minCount smallest allowed count\r\n * @param edgeLength\r\n */\r\n public static applyMaxEdgeLength(\r\n options: StrokeOptions | undefined, minCount: number, edgeLength: number\r\n ): number {\r\n if (edgeLength < 0)\r\n edgeLength = - edgeLength;\r\n if (minCount < 1)\r\n minCount = 1;\r\n if (options && options.maxEdgeLength && options.maxEdgeLength * minCount < edgeLength) {\r\n minCount = Geometry.stepCount(options.maxEdgeLength, edgeLength, minCount);\r\n }\r\n return minCount;\r\n }\r\n /**\r\n * Determine a stroke count for a (partial) circular arc of given radius. This considers angle, maxEdgeLength,\r\n * chord, and minimum stroke.\r\n */\r\n public applyTolerancesToArc(radius: number, sweepRadians: number = Math.PI * 2): number {\r\n let numStrokes = 1;\r\n numStrokes = this.applyAngleTol(numStrokes, sweepRadians, Math.PI * 0.25);\r\n numStrokes = this.applyMaxEdgeLength(numStrokes, sweepRadians * radius);\r\n numStrokes = this.applyChordTol(numStrokes, radius, sweepRadians);\r\n numStrokes = this.applyMinStrokesPerPrimitive(numStrokes);\r\n return numStrokes;\r\n }\r\n /** Return stroke count which is the larger of existing count or count needed for circular arc chord tolerance condition. */\r\n public applyChordTol(minCount: number, radius: number, sweepRadians: number): number {\r\n if (this.chordTol && this.chordTol > 0.0 && this.chordTol < radius) {\r\n const a = this.chordTol;\r\n const stepRadians = 2.0 * Math.acos((1.0 - a / radius));\r\n minCount = Geometry.stepCount(stepRadians, sweepRadians, minCount);\r\n }\r\n return minCount;\r\n }\r\n /**\r\n * Return stroke count which is the larger of existing count or count needed for circular arc chord tol with given\r\n * arc length and radians\r\n */\r\n public applyChordTolToLengthAndRadians(minCount: number, length: number, sweepRadians: number): number {\r\n if (this.chordTol && this.chordTol > 0.0) {\r\n const radius = Geometry.conditionalDivideFraction(length, sweepRadians);\r\n if (radius !== undefined)\r\n return this.applyChordTol(minCount, radius, sweepRadians);\r\n }\r\n return minCount;\r\n }\r\n /** Return stroke count which is the larger of existing count or `this.minStrokesPerPrimitive` */\r\n public applyMinStrokesPerPrimitive(minCount: number): number {\r\n if (this.minStrokesPerPrimitive !== undefined && Number.isFinite(this.minStrokesPerPrimitive)\r\n && this.minStrokesPerPrimitive > minCount)\r\n minCount = this.minStrokesPerPrimitive;\r\n return minCount;\r\n }\r\n /**\r\n * Create `StrokeOptions` with defaults appropriate for curves.\r\n * * angle tolerance of 15 degrees.\r\n * * all others inactive.\r\n */\r\n public static createForCurves(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.angleTol = Angle.createDegrees(15.0);\r\n return options;\r\n }\r\n /**\r\n * Create `StrokeOptions` with defaults appropriate for surfaces facets\r\n * * angle tolerance of 22.5 degrees.\r\n * * all others inactive.\r\n */\r\n public static createForFacets(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.angleTol = Angle.createDegrees(22.5);\r\n return options;\r\n }\r\n}\r\n"]}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module CartesianGeometry
|
|
3
|
-
*/
|
|
4
1
|
import { Arc3d } from "../curve/Arc3d";
|
|
5
2
|
import { CurveLocationDetail, CurveLocationDetailPair } from "../curve/CurveLocationDetail";
|
|
6
3
|
import { Point3d } from "./Point3dVector3d";
|
|
@@ -13,6 +10,8 @@ import { Point3d } from "./Point3dVector3d";
|
|
|
13
10
|
export declare class CoincidentGeometryQuery {
|
|
14
11
|
private _vectorU?;
|
|
15
12
|
private _vectorV?;
|
|
13
|
+
private _point0?;
|
|
14
|
+
private _point1?;
|
|
16
15
|
private _tolerance;
|
|
17
16
|
get tolerance(): number;
|
|
18
17
|
private constructor();
|
|
@@ -36,12 +35,13 @@ export declare class CoincidentGeometryQuery {
|
|
|
36
35
|
*/
|
|
37
36
|
coincidentSegmentRangeXY(pointA0: Point3d, pointA1: Point3d, pointB0: Point3d, pointB1: Point3d, restrictToBounds?: boolean): CurveLocationDetailPair | undefined;
|
|
38
37
|
/**
|
|
39
|
-
* Create a CurveLocationDetailPair
|
|
38
|
+
* Create a CurveLocationDetailPair for a coincident interval of two overlapping curves
|
|
40
39
|
* @param cpA curveA
|
|
41
|
-
* @param cpB
|
|
42
|
-
* @param fractionsOnA
|
|
43
|
-
* @param fractionB0
|
|
44
|
-
* @param fractionB1 end fraction of
|
|
40
|
+
* @param cpB curveB
|
|
41
|
+
* @param fractionsOnA coincident interval of curveB in fraction space of curveA
|
|
42
|
+
* @param fractionB0 curveB start in fraction space of curveA
|
|
43
|
+
* @param fractionB1 curveB end in fraction space of curveA
|
|
44
|
+
* @param reverse whether curveB and curveA have opposite direction
|
|
45
45
|
*/
|
|
46
46
|
private createDetailPair;
|
|
47
47
|
private appendDetailPair;
|
|
@@ -50,7 +50,7 @@ export declare class CoincidentGeometryQuery {
|
|
|
50
50
|
* @param arcA
|
|
51
51
|
* @param arcB
|
|
52
52
|
* @param _restrictToBounds
|
|
53
|
-
* @return 0, 1, or 2 overlap intervals
|
|
53
|
+
* @return 0, 1, or 2 overlap points/intervals
|
|
54
54
|
*/
|
|
55
55
|
coincidentArcIntersectionXY(arcA: Arc3d, arcB: Arc3d, _restrictToBounds?: boolean): CurveLocationDetailPair[] | undefined;
|
|
56
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoincidentGeometryOps.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/CoincidentGeometryOps.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CoincidentGeometryOps.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/CoincidentGeometryOps.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAI5F,OAAO,EAAE,OAAO,EAAY,MAAM,mBAAmB,CAAC;AAGtD;;;;;GAKG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,QAAQ,CAAC,CAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,CAAW;IAC5B,OAAO,CAAC,OAAO,CAAC,CAAU;IAC1B,OAAO,CAAC,OAAO,CAAC,CAAU;IAC1B,OAAO,CAAC,UAAU,CAAS;IAC3B,IAAW,SAAS,IAAI,MAAM,CAE7B;IACD,OAAO;WAGO,MAAM,CAAC,SAAS,GAAE,MAAqC,GAAG,uBAAuB;IAG/F;;;OAGG;WACW,0CAA0C,CAAC,MAAM,EAAE,mBAAmB,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAC1G,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,GAAE,OAAe;IAazD;;OAEG;IACI,uBAAuB,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,mBAAmB;IAS1G;;;;;;;OAOG;IACI,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAE,OAAc,GAAG,uBAAuB,GAAG,SAAS;IA2D9K;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,gBAAgB;IAQxB;;;;;;OAMG;IACI,2BAA2B,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,iBAAiB,GAAE,OAAc,GAAG,uBAAuB,EAAE,GAAG,SAAS;CAgEvI"}
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.CoincidentGeometryQuery = void 0;
|
|
8
|
+
/** @packageDocumentation
|
|
9
|
+
* @module CartesianGeometry
|
|
10
|
+
*/
|
|
11
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
8
12
|
const CurveLocationDetail_1 = require("../curve/CurveLocationDetail");
|
|
9
13
|
const Geometry_1 = require("../Geometry");
|
|
10
14
|
const AngleSweep_1 = require("./AngleSweep");
|
|
@@ -62,71 +66,71 @@ class CoincidentGeometryQuery {
|
|
|
62
66
|
* @param pointB1 end point of segment B
|
|
63
67
|
*/
|
|
64
68
|
coincidentSegmentRangeXY(pointA0, pointA1, pointB0, pointB1, restrictToBounds = true) {
|
|
65
|
-
const
|
|
66
|
-
if (pointA0.distanceXY(
|
|
69
|
+
const detailA0OnB = this.projectPointToSegmentXY(pointA0, pointB0, pointB1);
|
|
70
|
+
if (pointA0.distanceXY(detailA0OnB.point) > this._tolerance)
|
|
67
71
|
return undefined;
|
|
68
72
|
const detailA1OnB = this.projectPointToSegmentXY(pointA1, pointB0, pointB1);
|
|
69
73
|
if (pointA1.distanceXY(detailA1OnB.point) > this._tolerance)
|
|
70
74
|
return undefined;
|
|
71
|
-
const
|
|
72
|
-
if (pointB0.distanceXY(
|
|
75
|
+
const detailB0OnA = this.projectPointToSegmentXY(pointB0, pointA0, pointA1);
|
|
76
|
+
if (pointB0.distanceXY(detailB0OnA.point) > this._tolerance)
|
|
73
77
|
return undefined;
|
|
74
78
|
const detailB1OnA = this.projectPointToSegmentXY(pointB1, pointA0, pointA1);
|
|
75
79
|
if (pointB1.distanceXY(detailB1OnA.point) > this._tolerance)
|
|
76
80
|
return undefined;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
detailA0OnB.fraction1 = detailA1OnB.fraction;
|
|
82
|
+
detailA0OnB.point1 = detailA1OnB.point; // capture -- detailA1OnB is not reused.
|
|
83
|
+
detailB0OnA.fraction1 = detailB1OnA.fraction;
|
|
84
|
+
detailB0OnA.point1 = detailB1OnA.point;
|
|
81
85
|
if (!restrictToBounds)
|
|
82
|
-
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(
|
|
83
|
-
const segment = Segment1d_1.Segment1d.create(
|
|
86
|
+
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
87
|
+
const segment = Segment1d_1.Segment1d.create(detailB0OnA.fraction, detailB0OnA.fraction1);
|
|
84
88
|
if (segment.clampDirectedTo01()) {
|
|
85
|
-
segment.reverseIfNeededForDeltaSign(1.0);
|
|
86
89
|
const f0 = segment.x0;
|
|
87
90
|
const f1 = segment.x1;
|
|
88
|
-
const h0 =
|
|
89
|
-
const h1 =
|
|
91
|
+
const h0 = detailB0OnA.inverseInterpolateFraction(f0);
|
|
92
|
+
const h1 = detailB0OnA.inverseInterpolateFraction(f1);
|
|
90
93
|
// recompute fractions and points..
|
|
91
|
-
CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(
|
|
92
|
-
CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(
|
|
93
|
-
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(
|
|
94
|
+
CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(detailB0OnA, f0, f1, pointA0, pointA1, f0 > f1);
|
|
95
|
+
CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(detailA0OnB, h0, h1, pointB0, pointB1, h0 > h1);
|
|
96
|
+
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
94
97
|
}
|
|
95
98
|
else {
|
|
96
99
|
if (segment.signedDelta() < 0.0) {
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(
|
|
100
|
+
if (detailB0OnA.point.isAlmostEqual(pointA0, this.tolerance)) {
|
|
101
|
+
detailB0OnA.collapseToStart();
|
|
102
|
+
detailA0OnB.collapseToStart();
|
|
103
|
+
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
101
104
|
}
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(
|
|
105
|
+
if (detailB0OnA.point1.isAlmostEqual(pointA1, this.tolerance)) {
|
|
106
|
+
detailB0OnA.collapseToEnd();
|
|
107
|
+
detailA0OnB.collapseToEnd();
|
|
108
|
+
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
else {
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(
|
|
112
|
+
if (detailB0OnA.point.isAlmostEqual(pointA1, this.tolerance)) {
|
|
113
|
+
detailB0OnA.collapseToStart();
|
|
114
|
+
detailA0OnB.collapseToEnd();
|
|
115
|
+
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
113
116
|
}
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(
|
|
117
|
+
if (detailB0OnA.point1.isAlmostEqual(pointA0, this.tolerance)) {
|
|
118
|
+
detailB0OnA.collapseToEnd();
|
|
119
|
+
detailA0OnB.collapseToStart();
|
|
120
|
+
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
return undefined;
|
|
122
125
|
}
|
|
123
126
|
/**
|
|
124
|
-
* Create a CurveLocationDetailPair
|
|
127
|
+
* Create a CurveLocationDetailPair for a coincident interval of two overlapping curves
|
|
125
128
|
* @param cpA curveA
|
|
126
|
-
* @param cpB
|
|
127
|
-
* @param fractionsOnA
|
|
128
|
-
* @param fractionB0
|
|
129
|
-
* @param fractionB1 end fraction of
|
|
129
|
+
* @param cpB curveB
|
|
130
|
+
* @param fractionsOnA coincident interval of curveB in fraction space of curveA
|
|
131
|
+
* @param fractionB0 curveB start in fraction space of curveA
|
|
132
|
+
* @param fractionB1 curveB end in fraction space of curveA
|
|
133
|
+
* @param reverse whether curveB and curveA have opposite direction
|
|
130
134
|
*/
|
|
131
135
|
createDetailPair(cpA, cpB, fractionsOnA, fractionB0, fractionB1, reverse) {
|
|
132
136
|
const deltaB = fractionB1 - fractionB0;
|
|
@@ -135,10 +139,8 @@ class CoincidentGeometryQuery {
|
|
|
135
139
|
if (g0 !== undefined && g1 !== undefined) {
|
|
136
140
|
const detailA = CurveLocationDetail_1.CurveLocationDetail.createCurveEvaluatedFractionFraction(cpA, fractionsOnA.x0, fractionsOnA.x1);
|
|
137
141
|
const detailB = CurveLocationDetail_1.CurveLocationDetail.createCurveEvaluatedFractionFraction(cpB, g0, g1);
|
|
138
|
-
if (reverse)
|
|
142
|
+
if (reverse)
|
|
139
143
|
detailA.swapFractionsAndPoints();
|
|
140
|
-
detailB.swapFractionsAndPoints();
|
|
141
|
-
}
|
|
142
144
|
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailA, detailB);
|
|
143
145
|
}
|
|
144
146
|
return undefined;
|
|
@@ -156,11 +158,11 @@ class CoincidentGeometryQuery {
|
|
|
156
158
|
* @param arcA
|
|
157
159
|
* @param arcB
|
|
158
160
|
* @param _restrictToBounds
|
|
159
|
-
* @return 0, 1, or 2 overlap intervals
|
|
161
|
+
* @return 0, 1, or 2 overlap points/intervals
|
|
160
162
|
*/
|
|
161
163
|
coincidentArcIntersectionXY(arcA, arcB, _restrictToBounds = true) {
|
|
162
164
|
let result;
|
|
163
|
-
if (arcA.center.isAlmostEqual(arcB.center)) {
|
|
165
|
+
if (arcA.center.isAlmostEqual(arcB.center, this.tolerance)) {
|
|
164
166
|
const matrixBToA = arcA.matrixRef.multiplyMatrixInverseMatrix(arcB.matrixRef);
|
|
165
167
|
if (matrixBToA) {
|
|
166
168
|
const ux = matrixBToA.at(0, 0);
|
|
@@ -174,25 +176,49 @@ class CoincidentGeometryQuery {
|
|
|
174
176
|
if (Geometry_1.Geometry.isAlmostEqualNumber(ru, 1.0)
|
|
175
177
|
&& Geometry_1.Geometry.isAlmostEqualNumber(rv, 1.0)
|
|
176
178
|
&& Geometry_1.Geometry.isAlmostEqualNumber(0, dot)) {
|
|
177
|
-
const alphaB0Radians = Math.atan2(uy, ux); // angular position of arcB 0 point in
|
|
178
|
-
const sweepDirection = cross > 0 ? 1.0 : -1.0; // 1 if arcB
|
|
179
|
-
const betaStartRadians = alphaB0Radians + sweepDirection * arcB.sweep.startRadians;
|
|
180
|
-
const betaEndRadians = alphaB0Radians + sweepDirection * arcB.sweep.endRadians;
|
|
179
|
+
const alphaB0Radians = Math.atan2(uy, ux); // angular position of arcB 0 point in arcA sweep
|
|
180
|
+
const sweepDirection = cross > 0 ? 1.0 : -1.0; // 1 if arcB parameter space sweeps in same direction as arcA, -1 if opposite
|
|
181
|
+
const betaStartRadians = alphaB0Radians + sweepDirection * arcB.sweep.startRadians; // arcB start in arcA parameter space
|
|
182
|
+
const betaEndRadians = alphaB0Radians + sweepDirection * arcB.sweep.endRadians; // arcB end in arcA parameter space
|
|
181
183
|
const fractionSpacesReversed = (sweepDirection * arcA.sweep.sweepRadians * arcB.sweep.sweepRadians) < 0;
|
|
182
184
|
const sweepB = AngleSweep_1.AngleSweep.createStartEndRadians(betaStartRadians, betaEndRadians);
|
|
183
185
|
const sweepA = arcA.sweep;
|
|
184
186
|
const fractionPeriodA = sweepA.fractionPeriod();
|
|
185
|
-
const fractionB0 = sweepA.radiansToPositivePeriodicFraction(sweepB.startRadians);
|
|
186
|
-
|
|
187
|
-
const
|
|
187
|
+
const fractionB0 = sweepA.radiansToPositivePeriodicFraction(sweepB.startRadians); // arcB start in arcA fraction space
|
|
188
|
+
(0, core_bentley_1.assert)(fractionB0 >= 0.0);
|
|
189
|
+
const fractionSweep = sweepB.sweepRadians / sweepA.sweepRadians; // arcB sweep in arcA fraction space
|
|
190
|
+
const fractionB1 = fractionB0 + fractionSweep; // arcB end in arcA fraction space
|
|
188
191
|
const fractionSweepB = Segment1d_1.Segment1d.create(fractionB0, fractionB1);
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
/** lambda to add a coincident interval or isolated intersection, given inputs in arcA fraction space
|
|
193
|
+
* @param arcBInArcAFractionSpace span of arcB in arcA fraction space. On return, clamped to [0,1] if nontrivial.
|
|
194
|
+
* @param testStartOfArcA if no nontrivial coincident interval was found, look for an isolated intersection at the start (true) or end (false) of arcA
|
|
195
|
+
* @returns whether a detail pair was appended to result
|
|
196
|
+
*/
|
|
197
|
+
const appendCoincidentIntersection = (arcBInArcAFractionSpace, testStartOfArcA) => {
|
|
198
|
+
const size = result ? result.length : 0;
|
|
199
|
+
const arcBStart = arcBInArcAFractionSpace.x0;
|
|
200
|
+
const arcBEnd = arcBInArcAFractionSpace.x1;
|
|
201
|
+
if (arcBInArcAFractionSpace.clampDirectedTo01() && !Geometry_1.Geometry.isSmallRelative(arcBInArcAFractionSpace.absoluteDelta())) {
|
|
202
|
+
result = this.appendDetailPair(result, this.createDetailPair(arcA, arcB, arcBInArcAFractionSpace, arcBStart, arcBEnd, fractionSpacesReversed));
|
|
203
|
+
}
|
|
204
|
+
else { // test isolated intersection
|
|
205
|
+
const testStartOfArcB = fractionSpacesReversed ? testStartOfArcA : !testStartOfArcA;
|
|
206
|
+
const arcAPt = this._point0 = testStartOfArcA ? arcA.startPoint(this._point0) : arcA.endPoint(this._point0);
|
|
207
|
+
const arcBPt = this._point1 = testStartOfArcB ? arcB.startPoint(this._point1) : arcB.endPoint(this._point1);
|
|
208
|
+
if (arcAPt.isAlmostEqual(arcBPt, this.tolerance)) {
|
|
209
|
+
const detailA = CurveLocationDetail_1.CurveLocationDetail.createCurveFractionPoint(arcA, testStartOfArcA ? 0 : 1, arcAPt);
|
|
210
|
+
const detailB = CurveLocationDetail_1.CurveLocationDetail.createCurveFractionPoint(arcB, testStartOfArcB ? 0 : 1, arcBPt);
|
|
211
|
+
result = this.appendDetailPair(result, CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailA, detailB));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return result !== undefined && result.length > size;
|
|
215
|
+
};
|
|
216
|
+
appendCoincidentIntersection(fractionSweepB, false); // compute overlap in strict interior, or at end of arcA
|
|
217
|
+
// check overlap at start of arcA with a periodic shift of fractionSweepB
|
|
218
|
+
if (fractionB1 >= fractionPeriodA)
|
|
219
|
+
appendCoincidentIntersection(Segment1d_1.Segment1d.create(fractionB0 - fractionPeriodA, fractionB1 - fractionPeriodA), true);
|
|
220
|
+
else if (fractionB0 === 0.0)
|
|
221
|
+
appendCoincidentIntersection(Segment1d_1.Segment1d.create(fractionB0 + fractionPeriodA, fractionB1 + fractionPeriodA), true);
|
|
196
222
|
}
|
|
197
223
|
}
|
|
198
224
|
}
|