@itwin/core-geometry 4.1.0-dev.70 → 4.1.0-dev.72
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/CHANGELOG.md +6 -1
- package/lib/cjs/clipping/AlternatingConvexClipTree.d.ts +15 -17
- package/lib/cjs/clipping/AlternatingConvexClipTree.d.ts.map +1 -1
- package/lib/cjs/clipping/AlternatingConvexClipTree.js +24 -20
- package/lib/cjs/clipping/AlternatingConvexClipTree.js.map +1 -1
- package/lib/cjs/clipping/BooleanClipFactory.d.ts +28 -28
- package/lib/cjs/clipping/BooleanClipFactory.d.ts.map +1 -1
- package/lib/cjs/clipping/BooleanClipFactory.js +28 -28
- package/lib/cjs/clipping/BooleanClipFactory.js.map +1 -1
- package/lib/cjs/clipping/BooleanClipNode.d.ts +11 -11
- package/lib/cjs/clipping/BooleanClipNode.d.ts.map +1 -1
- package/lib/cjs/clipping/BooleanClipNode.js +11 -11
- package/lib/cjs/clipping/BooleanClipNode.js.map +1 -1
- package/lib/cjs/clipping/ClipPlane.d.ts +73 -76
- package/lib/cjs/clipping/ClipPlane.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipPlane.js +105 -86
- package/lib/cjs/clipping/ClipPlane.js.map +1 -1
- package/lib/cjs/clipping/ClipPrimitive.d.ts +78 -47
- package/lib/cjs/clipping/ClipPrimitive.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipPrimitive.js +110 -54
- package/lib/cjs/clipping/ClipPrimitive.js.map +1 -1
- package/lib/cjs/clipping/ClipUtils.d.ts +54 -44
- package/lib/cjs/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipUtils.js +33 -29
- package/lib/cjs/clipping/ClipUtils.js.map +1 -1
- package/lib/cjs/clipping/ClipVector.d.ts +39 -25
- package/lib/cjs/clipping/ClipVector.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipVector.js +35 -23
- package/lib/cjs/clipping/ClipVector.js.map +1 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts +61 -38
- package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.js +64 -41
- package/lib/cjs/clipping/ConvexClipPlaneSet.js.map +1 -1
- package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.d.ts +49 -30
- package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.d.ts.map +1 -1
- package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.js +50 -30
- package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
- package/lib/cjs/clipping/internalContexts/LineStringOffsetClipperContext.d.ts +2 -2
- package/lib/cjs/clipping/internalContexts/LineStringOffsetClipperContext.d.ts.map +1 -1
- package/lib/cjs/clipping/internalContexts/LineStringOffsetClipperContext.js +2 -2
- package/lib/cjs/clipping/internalContexts/LineStringOffsetClipperContext.js.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.d.ts +4 -2
- package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
- package/lib/cjs/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineSegment3d.js.map +1 -1
- package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineString3d.js.map +1 -1
- package/lib/esm/clipping/AlternatingConvexClipTree.d.ts +15 -17
- package/lib/esm/clipping/AlternatingConvexClipTree.d.ts.map +1 -1
- package/lib/esm/clipping/AlternatingConvexClipTree.js +24 -20
- package/lib/esm/clipping/AlternatingConvexClipTree.js.map +1 -1
- package/lib/esm/clipping/BooleanClipFactory.d.ts +28 -28
- package/lib/esm/clipping/BooleanClipFactory.d.ts.map +1 -1
- package/lib/esm/clipping/BooleanClipFactory.js +28 -28
- package/lib/esm/clipping/BooleanClipFactory.js.map +1 -1
- package/lib/esm/clipping/BooleanClipNode.d.ts +11 -11
- package/lib/esm/clipping/BooleanClipNode.d.ts.map +1 -1
- package/lib/esm/clipping/BooleanClipNode.js +11 -11
- package/lib/esm/clipping/BooleanClipNode.js.map +1 -1
- package/lib/esm/clipping/ClipPlane.d.ts +73 -76
- package/lib/esm/clipping/ClipPlane.d.ts.map +1 -1
- package/lib/esm/clipping/ClipPlane.js +105 -86
- package/lib/esm/clipping/ClipPlane.js.map +1 -1
- package/lib/esm/clipping/ClipPrimitive.d.ts +78 -47
- package/lib/esm/clipping/ClipPrimitive.d.ts.map +1 -1
- package/lib/esm/clipping/ClipPrimitive.js +110 -54
- package/lib/esm/clipping/ClipPrimitive.js.map +1 -1
- package/lib/esm/clipping/ClipUtils.d.ts +54 -44
- package/lib/esm/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/esm/clipping/ClipUtils.js +33 -29
- package/lib/esm/clipping/ClipUtils.js.map +1 -1
- package/lib/esm/clipping/ClipVector.d.ts +39 -25
- package/lib/esm/clipping/ClipVector.d.ts.map +1 -1
- package/lib/esm/clipping/ClipVector.js +35 -23
- package/lib/esm/clipping/ClipVector.js.map +1 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.d.ts +61 -38
- package/lib/esm/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.js +64 -41
- package/lib/esm/clipping/ConvexClipPlaneSet.js.map +1 -1
- package/lib/esm/clipping/UnionOfConvexClipPlaneSets.d.ts +49 -30
- package/lib/esm/clipping/UnionOfConvexClipPlaneSets.d.ts.map +1 -1
- package/lib/esm/clipping/UnionOfConvexClipPlaneSets.js +50 -30
- package/lib/esm/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
- package/lib/esm/clipping/internalContexts/LineStringOffsetClipperContext.d.ts +2 -2
- package/lib/esm/clipping/internalContexts/LineStringOffsetClipperContext.d.ts.map +1 -1
- package/lib/esm/clipping/internalContexts/LineStringOffsetClipperContext.js +2 -2
- package/lib/esm/clipping/internalContexts/LineStringOffsetClipperContext.js.map +1 -1
- package/lib/esm/curve/CurvePrimitive.d.ts +4 -2
- package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/esm/curve/CurvePrimitive.js.map +1 -1
- package/lib/esm/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/esm/curve/LineSegment3d.js.map +1 -1
- package/lib/esm/curve/LineString3d.d.ts.map +1 -1
- package/lib/esm/curve/LineString3d.js.map +1 -1
- package/package.json +3 -3
|
@@ -26,22 +26,26 @@ export type ConvexClipPlaneSetProps = ClipPlaneProps[];
|
|
|
26
26
|
export declare class ConvexClipPlaneSet implements Clipper, PolygonClipper {
|
|
27
27
|
/** Value acting as "at infinity" for coordinates along a ray. */
|
|
28
28
|
static readonly hugeVal = 1e+37;
|
|
29
|
+
/** Planes that define the convex set. */
|
|
29
30
|
private _planes;
|
|
30
31
|
private constructor();
|
|
31
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Return an array containing all the planes of the convex set.
|
|
32
34
|
* * Note that this has no leading keyword identifying it as a ConvexClipPlaneSet.
|
|
33
35
|
*/
|
|
34
36
|
toJSON(): ConvexClipPlaneSetProps;
|
|
35
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Extract clip planes from a json array `[ clipPlane, clipPlane ]`.
|
|
36
39
|
* * Non-clipPlane members are ignored.
|
|
37
40
|
*/
|
|
38
41
|
static fromJSON(json: ConvexClipPlaneSetProps | undefined, result?: ConvexClipPlaneSet): ConvexClipPlaneSet;
|
|
39
42
|
/**
|
|
40
|
-
* Return true if all members are almostEqual to corresponding members of other.
|
|
43
|
+
* Return true if all members are almostEqual to corresponding members of other. This includes identical order in array.
|
|
41
44
|
* @param other clip plane to compare
|
|
42
45
|
*/
|
|
43
46
|
isAlmostEqual(other: ConvexClipPlaneSet): boolean;
|
|
44
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Create ConvexClipPlaneSet from an array of planes.
|
|
45
49
|
* * Each plane reference in the `planes` array is taken into the result.
|
|
46
50
|
* * The input array itself is NOT taken into the result.
|
|
47
51
|
*/
|
|
@@ -57,20 +61,23 @@ export declare class ConvexClipPlaneSet implements Clipper, PolygonClipper {
|
|
|
57
61
|
* @param highZ true to clip at the high z plane
|
|
58
62
|
*/
|
|
59
63
|
static createRange3dPlanes(range: Range3d, lowX?: boolean, highX?: boolean, lowY?: boolean, highY?: boolean, lowZ?: boolean, highZ?: boolean): ConvexClipPlaneSet;
|
|
60
|
-
/**
|
|
64
|
+
/** Create an empty `ConvexClipPlaneSet` */
|
|
61
65
|
static createEmpty(result?: ConvexClipPlaneSet): ConvexClipPlaneSet;
|
|
62
|
-
/**
|
|
66
|
+
/** Negate all planes of the set. */
|
|
63
67
|
negateAllPlanes(): void;
|
|
64
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Create a convex clip plane set that clips to `x0 <= x <= x1` and `y0 <= y <= y1`.
|
|
65
70
|
* * Note that there is no test for the usual ordering `x0 <= x1` or `y0 <= y1`.
|
|
66
|
-
*
|
|
71
|
+
* * if the usual ordering is violated, the convex set is an empty set.
|
|
67
72
|
*/
|
|
68
73
|
static createXYBox(x0: number, y0: number, x1: number, y1: number, result?: ConvexClipPlaneSet): ConvexClipPlaneSet;
|
|
69
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Create a convex set containing a half space for each edge between points of a polyline.
|
|
70
76
|
* * Caller is responsible for assuring the polyline is convex.
|
|
71
|
-
* @param points array of points.
|
|
72
|
-
* @param interior array whose boolean value is used as both the `interior` and `invisible` bits of the plane for the
|
|
73
|
-
*
|
|
77
|
+
* @param points array of points. Only xy parts are considered.
|
|
78
|
+
* @param interior array whose boolean value is used as both the `interior` and `invisible` bits of the plane for the
|
|
79
|
+
* succeeding segment. If this array is not provided, both are false.
|
|
80
|
+
* @param leftIsInside if true, the interior is "to the left" of the segments. If false, interior is "to the right".
|
|
74
81
|
*/
|
|
75
82
|
static createXYPolyLine(points: Point3d[], interior: boolean[] | undefined, leftIsInside: boolean, result?: ConvexClipPlaneSet): ConvexClipPlaneSet;
|
|
76
83
|
/**
|
|
@@ -79,7 +86,7 @@ export declare class ConvexClipPlaneSet implements Clipper, PolygonClipper {
|
|
|
79
86
|
*/
|
|
80
87
|
static createXYPolyLineInsideLeft(points: Point3d[], result?: ConvexClipPlaneSet): ConvexClipPlaneSet;
|
|
81
88
|
/**
|
|
82
|
-
* (
|
|
89
|
+
* Set (or reset) a plane and ConvexClipPlaneSet for a convex array, such as a convex facet used for xy clip.
|
|
83
90
|
* * The planeOfPolygon is (re)initialized with the normal from 3 points, but not otherwise referenced.
|
|
84
91
|
* * The ConvexClipPlaneSet is filled with outward normals of the facet edges as viewed to xy plane.
|
|
85
92
|
* @param points
|
|
@@ -94,7 +101,7 @@ export declare class ConvexClipPlaneSet implements Clipper, PolygonClipper {
|
|
|
94
101
|
* Test if there is any intersection with a ray defined by origin and direction.
|
|
95
102
|
* * Optionally record the range (null or otherwise) in caller-allocated result.
|
|
96
103
|
* * If the ray is unbounded inside the clip, result can contain positive or negative
|
|
97
|
-
*
|
|
104
|
+
* "Geometry.largeCoordinateResult" values.
|
|
98
105
|
* * If no result is provide, there are no object allocations.
|
|
99
106
|
* @param result optional Range1d to receive parameters along the ray.
|
|
100
107
|
*/
|
|
@@ -104,7 +111,8 @@ export declare class ConvexClipPlaneSet implements Clipper, PolygonClipper {
|
|
|
104
111
|
* @param matrix matrix to apply.
|
|
105
112
|
* @param invert if true, use in verse of the matrix.
|
|
106
113
|
* @param transpose if true, use the transpose of the matrix (or inverse, per invert parameter)
|
|
107
|
-
* * Note that if matrixA is applied to all of space, the matrix to send to this method to get a corresponding effect
|
|
114
|
+
* * Note that if matrixA is applied to all of space, the matrix to send to this method to get a corresponding effect
|
|
115
|
+
* on the plane is the inverse transpose of matrixA.
|
|
108
116
|
* * Callers that will apply the same matrix to many planes should pre-invert the matrix for efficiency.
|
|
109
117
|
* * Both params default to true to get the full effect of transforming space.
|
|
110
118
|
* @param matrix matrix to apply
|
|
@@ -120,13 +128,15 @@ export declare class ConvexClipPlaneSet implements Clipper, PolygonClipper {
|
|
|
120
128
|
* @param radius radius of sphere.
|
|
121
129
|
*/
|
|
122
130
|
isSphereInside(centerPoint: Point3d, radius: number): boolean;
|
|
123
|
-
/**
|
|
124
|
-
*
|
|
125
|
-
* *
|
|
131
|
+
/**
|
|
132
|
+
* Find the parts of the line segment (if any) that is within the convex clip volume.
|
|
133
|
+
* * The line segment is defined by `pointA` and `pointB`.
|
|
134
|
+
* * The input fractional interval from `fraction0` to `fraction1` (increasing) is the active part to consider.
|
|
135
|
+
* * To clip to the usual bounded line segment, start with fractions (0,1).
|
|
126
136
|
* If the clip volume is unbounded, the line interval may also be unbounded.
|
|
127
|
-
* * An unbounded line portion will have fraction coordinates positive or negative Number.MAX_VALUE
|
|
128
|
-
* @param
|
|
129
|
-
* @param
|
|
137
|
+
* * An unbounded line portion will have fraction coordinates positive or negative `Number.MAX_VALUE`.
|
|
138
|
+
* @param f0 fraction that is the initial lower fraction of the active interval (e.g., 0.0 for bounded segment).
|
|
139
|
+
* @param f1 fraction that is the initial upper fraction of the active interval (e.g., 1.0 for bounded segment).
|
|
130
140
|
* @param pointA segment start (fraction 0)
|
|
131
141
|
* @param pointB segment end (fraction 1)
|
|
132
142
|
* @param announce function to be called to announce a fraction interval that is within the convex clip volume.
|
|
@@ -134,11 +144,13 @@ export declare class ConvexClipPlaneSet implements Clipper, PolygonClipper {
|
|
|
134
144
|
*/
|
|
135
145
|
announceClippedSegmentIntervals(f0: number, f1: number, pointA: Point3d, pointB: Point3d, announce?: AnnounceNumberNumber): boolean;
|
|
136
146
|
private static _clipArcFractionArray;
|
|
137
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* Find fractional parts of the arc that are within this ClipPlaneSet, and announce each as
|
|
138
149
|
* * `announce(fraction, fraction, curve)`
|
|
139
150
|
*/
|
|
140
151
|
announceClippedArcIntervals(arc: Arc3d, announce?: AnnounceNumberNumberCurvePrimitive): boolean;
|
|
141
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* Find the parts of the (unbounded) line segment (if any) that is within the convex clip volume.
|
|
142
154
|
* @param pointA segment start (fraction 0)
|
|
143
155
|
* @param pointB segment end (fraction 1)
|
|
144
156
|
* @param announce function to be called to announce a fraction interval that is within the convex clip volume.
|
|
@@ -156,27 +168,30 @@ export declare class ConvexClipPlaneSet implements Clipper, PolygonClipper {
|
|
|
156
168
|
* @param tolerance tolerance for "on plane" decision.
|
|
157
169
|
*/
|
|
158
170
|
clipConvexPolygonInPlace(xyz: GrowableXYZArray, work: GrowableXYZArray, tolerance?: number): void;
|
|
159
|
-
/**
|
|
171
|
+
/**
|
|
172
|
+
* Clip a convex polygon to (a single) inside part and (possibly many) outside parts.
|
|
160
173
|
* @param xyz input polygon.
|
|
161
174
|
* @param outsideFragments an array to receive (via push, with no preliminary clear) outside fragments
|
|
162
175
|
* @param arrayCache cache for work arrays.
|
|
163
176
|
* @return the surviving inside part (if any)
|
|
164
177
|
*/
|
|
165
178
|
clipInsidePushOutside(xyz: GrowableXYZArray, outsideFragments: GrowableXYZArray[] | undefined, arrayCache: GrowableXYZArrayCache): GrowableXYZArray | undefined;
|
|
166
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* Returns 1, 2, or 3 based on whether point array is strongly inside, ambiguous, or strongly outside respectively.
|
|
167
181
|
* * This has a peculiar expected use case as a very fast pre-filter for more precise clipping.
|
|
168
182
|
* * The expected point set is for a polygon.
|
|
169
183
|
* * Hence any clipping will eventually have to consider the lines between the points.
|
|
170
184
|
* * This method looks for the special case of a single clip plane that has all the points outside.
|
|
171
185
|
* * In this case the whole polygon must be outside.
|
|
172
186
|
* * Note that this does not detect a polygon that is outside but "crosses a corner" -- it is mixed with respect to
|
|
173
|
-
*
|
|
187
|
+
* multiple planes.
|
|
174
188
|
*/
|
|
175
189
|
classifyPointContainment(points: Point3d[], onIsOutside: boolean): ClipPlaneContainment;
|
|
176
190
|
/**
|
|
177
191
|
* * Create a convex clip set for a polygon swept with possible tilt angle.
|
|
178
192
|
* * planes are constructed by ClipPlane.createEdgeAndUpVector, using successive points from the array.
|
|
179
|
-
* * If the first and last points match, the polygon area is checked. If the area is negative, points are used in
|
|
193
|
+
* * If the first and last points match, the polygon area is checked. If the area is negative, points are used in
|
|
194
|
+
* reverse order.
|
|
180
195
|
* * If first and last points do not match, points are used in order given
|
|
181
196
|
* @param points polygon points. (Closure point optional)
|
|
182
197
|
* @param upVector primary sweep direction, as applied by ClipPlane.createEdgeAndUpVector
|
|
@@ -189,7 +204,7 @@ export declare class ConvexClipPlaneSet implements Clipper, PolygonClipper {
|
|
|
189
204
|
*/
|
|
190
205
|
addPlaneToConvexSet(plane: ClipPlane | Plane3dByOriginAndUnitNormal | undefined): void;
|
|
191
206
|
/**
|
|
192
|
-
*
|
|
207
|
+
* Test many points. Distribute them to arrays depending on in/out result.
|
|
193
208
|
* @param points points to test
|
|
194
209
|
* @param inOrOn points that are in or on the set
|
|
195
210
|
* @param out points that are out.
|
|
@@ -198,8 +213,10 @@ export declare class ConvexClipPlaneSet implements Clipper, PolygonClipper {
|
|
|
198
213
|
/**
|
|
199
214
|
* Clip a polygon to the planes of the clip plane set.
|
|
200
215
|
* * For a convex input polygon, the output is another convex polygon.
|
|
201
|
-
* * For a non-convex input, the output may have double-back edges along plane intersections.
|
|
202
|
-
*
|
|
216
|
+
* * For a non-convex input, the output may have double-back edges along plane intersections. This is still a
|
|
217
|
+
* valid clip in a parity sense.
|
|
218
|
+
* * The containingPlane parameter allows callers within ConvexClipPlane set to bypass planes known to contain
|
|
219
|
+
* the polygon.
|
|
203
220
|
* @param input input polygon, usually convex.
|
|
204
221
|
* @param output output polygon
|
|
205
222
|
* @param work work array.
|
|
@@ -220,13 +237,16 @@ export declare class ConvexClipPlaneSet implements Clipper, PolygonClipper {
|
|
|
220
237
|
* * optionally throw out points that are not in the set.
|
|
221
238
|
* * optionally push the points in the caller-supplied point array.
|
|
222
239
|
* * optionally extend a caller supplied range.
|
|
223
|
-
* * In the common case where the convex set is (a) a slab or (b) a view frustum, there will be 8 points and the
|
|
224
|
-
*
|
|
240
|
+
* * In the common case where the convex set is (a) a slab or (b) a view frustum, there will be 8 points and the
|
|
241
|
+
* range is the range of the convex set.
|
|
242
|
+
* * If the convex set is unbounded, the range only contains the range of the accepted (corner) points, and the
|
|
243
|
+
* range is not a representative of the "range of all points in the set".
|
|
225
244
|
* @param transform (optional) transform to apply to the points.
|
|
226
245
|
* @param points (optional) array to which computed points are to be added.
|
|
227
246
|
* @param range (optional) range to be extended by the computed points
|
|
228
247
|
* @param transform (optional) transform to apply to the accepted points.
|
|
229
|
-
* @param testContainment if true, test each point to see if it is within the convex set.
|
|
248
|
+
* @param testContainment if true, test each point to see if it is within the convex set. (send false if confident
|
|
249
|
+
* that the convex set is rectilinear set such as a slab. Send true if chiseled corners are possible).
|
|
230
250
|
* @returns number of points.
|
|
231
251
|
*/
|
|
232
252
|
computePlanePlanePlaneIntersections(points: Point3d[] | undefined, rangeToExtend: Range3d | undefined, transform?: Transform, testContainment?: boolean): number;
|
|
@@ -242,15 +262,18 @@ export declare class ConvexClipPlaneSet implements Clipper, PolygonClipper {
|
|
|
242
262
|
* @param zHigh high z value. The plane clips out points with z above this.
|
|
243
263
|
*/
|
|
244
264
|
addZClipPlanes(invisible: boolean, zLow?: number, zHigh?: number): void;
|
|
245
|
-
/**
|
|
246
|
-
*
|
|
265
|
+
/**
|
|
266
|
+
* Implement appendPolygonClip, as defined in interface PolygonClipper.
|
|
247
267
|
* @param xyz input polygon. This is not changed.
|
|
248
|
-
* @param insideFragments Array to receive "inside" fragments.
|
|
249
|
-
*
|
|
268
|
+
* @param insideFragments Array to receive "inside" fragments. Each fragment is a GrowableXYZArray grabbed from
|
|
269
|
+
* the cache. This is NOT cleared.
|
|
270
|
+
* @param outsideFragments Array to receive "outside" fragments. Each fragment is a GrowableXYZArray grabbed from
|
|
271
|
+
* the cache. This is NOT cleared.
|
|
250
272
|
* @param arrayCache cache for reusable GrowableXYZArray.
|
|
251
273
|
*/
|
|
252
274
|
appendPolygonClip(xyz: GrowableXYZArray, insideFragments: GrowableXYZArray[], outsideFragments: GrowableXYZArray[], arrayCache: GrowableXYZArrayCache): void;
|
|
253
|
-
/**
|
|
275
|
+
/**
|
|
276
|
+
* Create a convex clip set from a convex mesh.
|
|
254
277
|
* * Create a plane for each facet.
|
|
255
278
|
* * Assemble the planes as a single clip plane set.
|
|
256
279
|
* * If the facets are closed by edge pairing, use the sign of the computed volume to point the plane normals inward.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConvexClipPlaneSet.d.ts","sourceRoot":"","sources":["../../../src/clipping/ConvexClipPlaneSet.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,kCAAkC,EAAE,MAAM,yBAAyB,CAAC;AAEnG,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAiB,cAAc,EAAE,MA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GAAG,SAAS,EAClC,SAAS,CAAC,EAAE,SAAS,EACrB,eAAe,GAAE,OAAc,GAC9B,MAAM;IA6BT;;;OAGG;IACI,YAAY,CAAC,SAAS,EAAE,OAAO;IAKtC;;;;;OAKG;IACI,cAAc,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAMvE;;;;;;;;OAQG;IACI,iBAAiB,CACtB,GAAG,EAAE,gBAAgB,EACrB,eAAe,EAAE,gBAAgB,EAAE,EACnC,gBAAgB,EAAE,gBAAgB,EAAE,EACpC,UAAU,EAAE,qBAAqB,GAChC,IAAI;IAKP;;;;;;;;;;MAUE;WACY,oBAAoB,CAChC,UAAU,EAAE,QAAQ,GAAG,eAAe,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAClE;QAAE,OAAO,EAAE,kBAAkB,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;CAsCnD"}
|
|
@@ -29,7 +29,8 @@ class ConvexClipPlaneSet {
|
|
|
29
29
|
// this._parity = 1;
|
|
30
30
|
this._planes = planes ? planes : [];
|
|
31
31
|
}
|
|
32
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Return an array containing all the planes of the convex set.
|
|
33
34
|
* * Note that this has no leading keyword identifying it as a ConvexClipPlaneSet.
|
|
34
35
|
*/
|
|
35
36
|
toJSON() {
|
|
@@ -38,7 +39,8 @@ class ConvexClipPlaneSet {
|
|
|
38
39
|
val.push(plane.toJSON());
|
|
39
40
|
return val;
|
|
40
41
|
}
|
|
41
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Extract clip planes from a json array `[ clipPlane, clipPlane ]`.
|
|
42
44
|
* * Non-clipPlane members are ignored.
|
|
43
45
|
*/
|
|
44
46
|
static fromJSON(json, result) {
|
|
@@ -54,7 +56,7 @@ class ConvexClipPlaneSet {
|
|
|
54
56
|
return result;
|
|
55
57
|
}
|
|
56
58
|
/**
|
|
57
|
-
* Return true if all members are almostEqual to corresponding members of other.
|
|
59
|
+
* Return true if all members are almostEqual to corresponding members of other. This includes identical order in array.
|
|
58
60
|
* @param other clip plane to compare
|
|
59
61
|
*/
|
|
60
62
|
isAlmostEqual(other) {
|
|
@@ -65,7 +67,8 @@ class ConvexClipPlaneSet {
|
|
|
65
67
|
return false;
|
|
66
68
|
return true;
|
|
67
69
|
}
|
|
68
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Create ConvexClipPlaneSet from an array of planes.
|
|
69
72
|
* * Each plane reference in the `planes` array is taken into the result.
|
|
70
73
|
* * The input array itself is NOT taken into the result.
|
|
71
74
|
*/
|
|
@@ -108,7 +111,7 @@ class ConvexClipPlaneSet {
|
|
|
108
111
|
result.planes.push(ClipPlane_1.ClipPlane.createNormalAndPointXYZXYZ(0, 0, -1, 0, 0, range.high.z));
|
|
109
112
|
return result;
|
|
110
113
|
}
|
|
111
|
-
/**
|
|
114
|
+
/** Create an empty `ConvexClipPlaneSet` */
|
|
112
115
|
static createEmpty(result) {
|
|
113
116
|
if (result) {
|
|
114
117
|
result._planes.length = 0;
|
|
@@ -116,14 +119,15 @@ class ConvexClipPlaneSet {
|
|
|
116
119
|
}
|
|
117
120
|
return new ConvexClipPlaneSet();
|
|
118
121
|
}
|
|
119
|
-
/**
|
|
122
|
+
/** Negate all planes of the set. */
|
|
120
123
|
negateAllPlanes() {
|
|
121
124
|
for (const plane of this._planes)
|
|
122
125
|
plane.negateInPlace();
|
|
123
126
|
}
|
|
124
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* Create a convex clip plane set that clips to `x0 <= x <= x1` and `y0 <= y <= y1`.
|
|
125
129
|
* * Note that there is no test for the usual ordering `x0 <= x1` or `y0 <= y1`.
|
|
126
|
-
*
|
|
130
|
+
* * if the usual ordering is violated, the convex set is an empty set.
|
|
127
131
|
*/
|
|
128
132
|
static createXYBox(x0, y0, x1, y1, result) {
|
|
129
133
|
result = result ? result : new ConvexClipPlaneSet();
|
|
@@ -137,11 +141,13 @@ class ConvexClipPlaneSet {
|
|
|
137
141
|
}
|
|
138
142
|
return result;
|
|
139
143
|
}
|
|
140
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* Create a convex set containing a half space for each edge between points of a polyline.
|
|
141
146
|
* * Caller is responsible for assuring the polyline is convex.
|
|
142
|
-
* @param points array of points.
|
|
143
|
-
* @param interior array whose boolean value is used as both the `interior` and `invisible` bits of the plane for the
|
|
144
|
-
*
|
|
147
|
+
* @param points array of points. Only xy parts are considered.
|
|
148
|
+
* @param interior array whose boolean value is used as both the `interior` and `invisible` bits of the plane for the
|
|
149
|
+
* succeeding segment. If this array is not provided, both are false.
|
|
150
|
+
* @param leftIsInside if true, the interior is "to the left" of the segments. If false, interior is "to the right".
|
|
145
151
|
*/
|
|
146
152
|
static createXYPolyLine(points, interior, leftIsInside, result) {
|
|
147
153
|
result = result ? result : new ConvexClipPlaneSet();
|
|
@@ -185,7 +191,7 @@ class ConvexClipPlaneSet {
|
|
|
185
191
|
return result;
|
|
186
192
|
}
|
|
187
193
|
/**
|
|
188
|
-
* (
|
|
194
|
+
* Set (or reset) a plane and ConvexClipPlaneSet for a convex array, such as a convex facet used for xy clip.
|
|
189
195
|
* * The planeOfPolygon is (re)initialized with the normal from 3 points, but not otherwise referenced.
|
|
190
196
|
* * The ConvexClipPlaneSet is filled with outward normals of the facet edges as viewed to xy plane.
|
|
191
197
|
* @param points
|
|
@@ -229,7 +235,7 @@ class ConvexClipPlaneSet {
|
|
|
229
235
|
* Test if there is any intersection with a ray defined by origin and direction.
|
|
230
236
|
* * Optionally record the range (null or otherwise) in caller-allocated result.
|
|
231
237
|
* * If the ray is unbounded inside the clip, result can contain positive or negative
|
|
232
|
-
*
|
|
238
|
+
* "Geometry.largeCoordinateResult" values.
|
|
233
239
|
* * If no result is provide, there are no object allocations.
|
|
234
240
|
* @param result optional Range1d to receive parameters along the ray.
|
|
235
241
|
*/
|
|
@@ -274,7 +280,8 @@ class ConvexClipPlaneSet {
|
|
|
274
280
|
* @param matrix matrix to apply.
|
|
275
281
|
* @param invert if true, use in verse of the matrix.
|
|
276
282
|
* @param transpose if true, use the transpose of the matrix (or inverse, per invert parameter)
|
|
277
|
-
* * Note that if matrixA is applied to all of space, the matrix to send to this method to get a corresponding effect
|
|
283
|
+
* * Note that if matrixA is applied to all of space, the matrix to send to this method to get a corresponding effect
|
|
284
|
+
* on the plane is the inverse transpose of matrixA.
|
|
278
285
|
* * Callers that will apply the same matrix to many planes should pre-invert the matrix for efficiency.
|
|
279
286
|
* * Both params default to true to get the full effect of transforming space.
|
|
280
287
|
* @param matrix matrix to apply
|
|
@@ -294,7 +301,8 @@ class ConvexClipPlaneSet {
|
|
|
294
301
|
/** Return true if `point` satisfies `point.isPointInside` for all planes */
|
|
295
302
|
isPointInside(point) {
|
|
296
303
|
for (const plane of this._planes) {
|
|
297
|
-
|
|
304
|
+
// Defaults to strict inside check. Other clipping classes may use "on or inside" check for the "on" case
|
|
305
|
+
if (!plane.isPointInside(point))
|
|
298
306
|
return false;
|
|
299
307
|
}
|
|
300
308
|
return true;
|
|
@@ -322,13 +330,15 @@ class ConvexClipPlaneSet {
|
|
|
322
330
|
}
|
|
323
331
|
return true;
|
|
324
332
|
}
|
|
325
|
-
/**
|
|
326
|
-
*
|
|
327
|
-
* *
|
|
333
|
+
/**
|
|
334
|
+
* Find the parts of the line segment (if any) that is within the convex clip volume.
|
|
335
|
+
* * The line segment is defined by `pointA` and `pointB`.
|
|
336
|
+
* * The input fractional interval from `fraction0` to `fraction1` (increasing) is the active part to consider.
|
|
337
|
+
* * To clip to the usual bounded line segment, start with fractions (0,1).
|
|
328
338
|
* If the clip volume is unbounded, the line interval may also be unbounded.
|
|
329
|
-
* * An unbounded line portion will have fraction coordinates positive or negative Number.MAX_VALUE
|
|
330
|
-
* @param
|
|
331
|
-
* @param
|
|
339
|
+
* * An unbounded line portion will have fraction coordinates positive or negative `Number.MAX_VALUE`.
|
|
340
|
+
* @param f0 fraction that is the initial lower fraction of the active interval (e.g., 0.0 for bounded segment).
|
|
341
|
+
* @param f1 fraction that is the initial upper fraction of the active interval (e.g., 1.0 for bounded segment).
|
|
332
342
|
* @param pointA segment start (fraction 0)
|
|
333
343
|
* @param pointB segment end (fraction 1)
|
|
334
344
|
* @param announce function to be called to announce a fraction interval that is within the convex clip volume.
|
|
@@ -343,7 +353,7 @@ class ConvexClipPlaneSet {
|
|
|
343
353
|
const hB = -plane.altitude(pointB);
|
|
344
354
|
fraction = Geometry_1.Geometry.conditionalDivideFraction(-hA, (hB - hA));
|
|
345
355
|
if (fraction === undefined) {
|
|
346
|
-
//
|
|
356
|
+
// Line parallel to the plane. If positive, it is all OUT
|
|
347
357
|
if (hA > 0.0)
|
|
348
358
|
return false;
|
|
349
359
|
}
|
|
@@ -372,7 +382,8 @@ class ConvexClipPlaneSet {
|
|
|
372
382
|
}
|
|
373
383
|
return false;
|
|
374
384
|
}
|
|
375
|
-
/**
|
|
385
|
+
/**
|
|
386
|
+
* Find fractional parts of the arc that are within this ClipPlaneSet, and announce each as
|
|
376
387
|
* * `announce(fraction, fraction, curve)`
|
|
377
388
|
*/
|
|
378
389
|
announceClippedArcIntervals(arc, announce) {
|
|
@@ -384,7 +395,8 @@ class ConvexClipPlaneSet {
|
|
|
384
395
|
arc.sweep.radiansArrayToPositivePeriodicFractions(breaks);
|
|
385
396
|
return ClipUtils_1.ClipUtilities.selectIntervals01(arc, breaks, this, announce);
|
|
386
397
|
}
|
|
387
|
-
/**
|
|
398
|
+
/**
|
|
399
|
+
* Find the parts of the (unbounded) line segment (if any) that is within the convex clip volume.
|
|
388
400
|
* @param pointA segment start (fraction 0)
|
|
389
401
|
* @param pointB segment end (fraction 1)
|
|
390
402
|
* @param announce function to be called to announce a fraction interval that is within the convex clip volume.
|
|
@@ -414,7 +426,8 @@ class ConvexClipPlaneSet {
|
|
|
414
426
|
return;
|
|
415
427
|
}
|
|
416
428
|
}
|
|
417
|
-
/**
|
|
429
|
+
/**
|
|
430
|
+
* Clip a convex polygon to (a single) inside part and (possibly many) outside parts.
|
|
418
431
|
* @param xyz input polygon.
|
|
419
432
|
* @param outsideFragments an array to receive (via push, with no preliminary clear) outside fragments
|
|
420
433
|
* @param arrayCache cache for work arrays.
|
|
@@ -457,14 +470,15 @@ class ConvexClipPlaneSet {
|
|
|
457
470
|
arrayCache.dropToCache(insidePart);
|
|
458
471
|
return undefined;
|
|
459
472
|
}
|
|
460
|
-
/**
|
|
473
|
+
/**
|
|
474
|
+
* Returns 1, 2, or 3 based on whether point array is strongly inside, ambiguous, or strongly outside respectively.
|
|
461
475
|
* * This has a peculiar expected use case as a very fast pre-filter for more precise clipping.
|
|
462
476
|
* * The expected point set is for a polygon.
|
|
463
477
|
* * Hence any clipping will eventually have to consider the lines between the points.
|
|
464
478
|
* * This method looks for the special case of a single clip plane that has all the points outside.
|
|
465
479
|
* * In this case the whole polygon must be outside.
|
|
466
480
|
* * Note that this does not detect a polygon that is outside but "crosses a corner" -- it is mixed with respect to
|
|
467
|
-
*
|
|
481
|
+
* multiple planes.
|
|
468
482
|
*/
|
|
469
483
|
classifyPointContainment(points, onIsOutside) {
|
|
470
484
|
let allInside = true;
|
|
@@ -486,7 +500,8 @@ class ConvexClipPlaneSet {
|
|
|
486
500
|
/**
|
|
487
501
|
* * Create a convex clip set for a polygon swept with possible tilt angle.
|
|
488
502
|
* * planes are constructed by ClipPlane.createEdgeAndUpVector, using successive points from the array.
|
|
489
|
-
* * If the first and last points match, the polygon area is checked. If the area is negative, points are used in
|
|
503
|
+
* * If the first and last points match, the polygon area is checked. If the area is negative, points are used in
|
|
504
|
+
* reverse order.
|
|
490
505
|
* * If first and last points do not match, points are used in order given
|
|
491
506
|
* @param points polygon points. (Closure point optional)
|
|
492
507
|
* @param upVector primary sweep direction, as applied by ClipPlane.createEdgeAndUpVector
|
|
@@ -534,7 +549,7 @@ class ConvexClipPlaneSet {
|
|
|
534
549
|
this._planes.push(ClipPlane_1.ClipPlane.createPlane(plane));
|
|
535
550
|
}
|
|
536
551
|
/**
|
|
537
|
-
*
|
|
552
|
+
* Test many points. Distribute them to arrays depending on in/out result.
|
|
538
553
|
* @param points points to test
|
|
539
554
|
* @param inOrOn points that are in or on the set
|
|
540
555
|
* @param out points that are out.
|
|
@@ -554,8 +569,10 @@ class ConvexClipPlaneSet {
|
|
|
554
569
|
/**
|
|
555
570
|
* Clip a polygon to the planes of the clip plane set.
|
|
556
571
|
* * For a convex input polygon, the output is another convex polygon.
|
|
557
|
-
* * For a non-convex input, the output may have double-back edges along plane intersections.
|
|
558
|
-
*
|
|
572
|
+
* * For a non-convex input, the output may have double-back edges along plane intersections. This is still a
|
|
573
|
+
* valid clip in a parity sense.
|
|
574
|
+
* * The containingPlane parameter allows callers within ConvexClipPlane set to bypass planes known to contain
|
|
575
|
+
* the polygon.
|
|
559
576
|
* @param input input polygon, usually convex.
|
|
560
577
|
* @param output output polygon
|
|
561
578
|
* @param work work array.
|
|
@@ -600,7 +617,7 @@ class ConvexClipPlaneSet {
|
|
|
600
617
|
const inwardNormal = Point3dVector3d_1.Vector3d.createCrossProduct(sweepDirection.x, sweepDirection.y, sweepDirection.z, edgeVector.x, edgeVector.y, edgeVector.z);
|
|
601
618
|
const inwardNormalNormalized = inwardNormal.normalize();
|
|
602
619
|
let distance;
|
|
603
|
-
if (inwardNormalNormalized) { //
|
|
620
|
+
if (inwardNormalNormalized) { // should never fail... simply a check due to the format of the normalize function return
|
|
604
621
|
distance = inwardNormalNormalized.dotProduct(xyz0);
|
|
605
622
|
const clipToAdd = ClipPlane_1.ClipPlane.createNormalAndDistance(inwardNormalNormalized, distance, false, false);
|
|
606
623
|
if (clipToAdd) {
|
|
@@ -629,13 +646,16 @@ class ConvexClipPlaneSet {
|
|
|
629
646
|
* * optionally throw out points that are not in the set.
|
|
630
647
|
* * optionally push the points in the caller-supplied point array.
|
|
631
648
|
* * optionally extend a caller supplied range.
|
|
632
|
-
* * In the common case where the convex set is (a) a slab or (b) a view frustum, there will be 8 points and the
|
|
633
|
-
*
|
|
649
|
+
* * In the common case where the convex set is (a) a slab or (b) a view frustum, there will be 8 points and the
|
|
650
|
+
* range is the range of the convex set.
|
|
651
|
+
* * If the convex set is unbounded, the range only contains the range of the accepted (corner) points, and the
|
|
652
|
+
* range is not a representative of the "range of all points in the set".
|
|
634
653
|
* @param transform (optional) transform to apply to the points.
|
|
635
654
|
* @param points (optional) array to which computed points are to be added.
|
|
636
655
|
* @param range (optional) range to be extended by the computed points
|
|
637
656
|
* @param transform (optional) transform to apply to the accepted points.
|
|
638
|
-
* @param testContainment if true, test each point to see if it is within the convex set.
|
|
657
|
+
* @param testContainment if true, test each point to see if it is within the convex set. (send false if confident
|
|
658
|
+
* that the convex set is rectilinear set such as a slab. Send true if chiseled corners are possible).
|
|
639
659
|
* @returns number of points.
|
|
640
660
|
*/
|
|
641
661
|
computePlanePlanePlaneIntersections(points, rangeToExtend, transform, testContainment = true) {
|
|
@@ -684,11 +704,13 @@ class ConvexClipPlaneSet {
|
|
|
684
704
|
if (zHigh !== undefined)
|
|
685
705
|
this._planes.push(ClipPlane_1.ClipPlane.createNormalAndDistance(Point3dVector3d_1.Vector3d.create(0, 0, -1), -zHigh, invisible));
|
|
686
706
|
}
|
|
687
|
-
/**
|
|
688
|
-
*
|
|
707
|
+
/**
|
|
708
|
+
* Implement appendPolygonClip, as defined in interface PolygonClipper.
|
|
689
709
|
* @param xyz input polygon. This is not changed.
|
|
690
|
-
* @param insideFragments Array to receive "inside" fragments.
|
|
691
|
-
*
|
|
710
|
+
* @param insideFragments Array to receive "inside" fragments. Each fragment is a GrowableXYZArray grabbed from
|
|
711
|
+
* the cache. This is NOT cleared.
|
|
712
|
+
* @param outsideFragments Array to receive "outside" fragments. Each fragment is a GrowableXYZArray grabbed from
|
|
713
|
+
* the cache. This is NOT cleared.
|
|
692
714
|
* @param arrayCache cache for reusable GrowableXYZArray.
|
|
693
715
|
*/
|
|
694
716
|
appendPolygonClip(xyz, insideFragments, outsideFragments, arrayCache) {
|
|
@@ -696,7 +718,8 @@ class ConvexClipPlaneSet {
|
|
|
696
718
|
if (newInside)
|
|
697
719
|
insideFragments.push(newInside);
|
|
698
720
|
}
|
|
699
|
-
/**
|
|
721
|
+
/**
|
|
722
|
+
* Create a convex clip set from a convex mesh.
|
|
700
723
|
* * Create a plane for each facet.
|
|
701
724
|
* * Assemble the planes as a single clip plane set.
|
|
702
725
|
* * If the facets are closed by edge pairing, use the sign of the computed volume to point the plane normals inward.
|