@itwin/core-geometry 4.1.0-dev.70 → 4.1.0-dev.71
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"}
|
|
@@ -26,7 +26,8 @@ class ConvexClipPlaneSet {
|
|
|
26
26
|
// this._parity = 1;
|
|
27
27
|
this._planes = planes ? planes : [];
|
|
28
28
|
}
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Return an array containing all the planes of the convex set.
|
|
30
31
|
* * Note that this has no leading keyword identifying it as a ConvexClipPlaneSet.
|
|
31
32
|
*/
|
|
32
33
|
toJSON() {
|
|
@@ -35,7 +36,8 @@ class ConvexClipPlaneSet {
|
|
|
35
36
|
val.push(plane.toJSON());
|
|
36
37
|
return val;
|
|
37
38
|
}
|
|
38
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Extract clip planes from a json array `[ clipPlane, clipPlane ]`.
|
|
39
41
|
* * Non-clipPlane members are ignored.
|
|
40
42
|
*/
|
|
41
43
|
static fromJSON(json, result) {
|
|
@@ -51,7 +53,7 @@ class ConvexClipPlaneSet {
|
|
|
51
53
|
return result;
|
|
52
54
|
}
|
|
53
55
|
/**
|
|
54
|
-
* Return true if all members are almostEqual to corresponding members of other.
|
|
56
|
+
* Return true if all members are almostEqual to corresponding members of other. This includes identical order in array.
|
|
55
57
|
* @param other clip plane to compare
|
|
56
58
|
*/
|
|
57
59
|
isAlmostEqual(other) {
|
|
@@ -62,7 +64,8 @@ class ConvexClipPlaneSet {
|
|
|
62
64
|
return false;
|
|
63
65
|
return true;
|
|
64
66
|
}
|
|
65
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Create ConvexClipPlaneSet from an array of planes.
|
|
66
69
|
* * Each plane reference in the `planes` array is taken into the result.
|
|
67
70
|
* * The input array itself is NOT taken into the result.
|
|
68
71
|
*/
|
|
@@ -105,7 +108,7 @@ class ConvexClipPlaneSet {
|
|
|
105
108
|
result.planes.push(ClipPlane.createNormalAndPointXYZXYZ(0, 0, -1, 0, 0, range.high.z));
|
|
106
109
|
return result;
|
|
107
110
|
}
|
|
108
|
-
/**
|
|
111
|
+
/** Create an empty `ConvexClipPlaneSet` */
|
|
109
112
|
static createEmpty(result) {
|
|
110
113
|
if (result) {
|
|
111
114
|
result._planes.length = 0;
|
|
@@ -113,14 +116,15 @@ class ConvexClipPlaneSet {
|
|
|
113
116
|
}
|
|
114
117
|
return new ConvexClipPlaneSet();
|
|
115
118
|
}
|
|
116
|
-
/**
|
|
119
|
+
/** Negate all planes of the set. */
|
|
117
120
|
negateAllPlanes() {
|
|
118
121
|
for (const plane of this._planes)
|
|
119
122
|
plane.negateInPlace();
|
|
120
123
|
}
|
|
121
|
-
/**
|
|
124
|
+
/**
|
|
125
|
+
* Create a convex clip plane set that clips to `x0 <= x <= x1` and `y0 <= y <= y1`.
|
|
122
126
|
* * Note that there is no test for the usual ordering `x0 <= x1` or `y0 <= y1`.
|
|
123
|
-
*
|
|
127
|
+
* * if the usual ordering is violated, the convex set is an empty set.
|
|
124
128
|
*/
|
|
125
129
|
static createXYBox(x0, y0, x1, y1, result) {
|
|
126
130
|
result = result ? result : new ConvexClipPlaneSet();
|
|
@@ -134,11 +138,13 @@ class ConvexClipPlaneSet {
|
|
|
134
138
|
}
|
|
135
139
|
return result;
|
|
136
140
|
}
|
|
137
|
-
/**
|
|
141
|
+
/**
|
|
142
|
+
* Create a convex set containing a half space for each edge between points of a polyline.
|
|
138
143
|
* * Caller is responsible for assuring the polyline is convex.
|
|
139
|
-
* @param points array of points.
|
|
140
|
-
* @param interior array whose boolean value is used as both the `interior` and `invisible` bits of the plane for the
|
|
141
|
-
*
|
|
144
|
+
* @param points array of points. Only xy parts are considered.
|
|
145
|
+
* @param interior array whose boolean value is used as both the `interior` and `invisible` bits of the plane for the
|
|
146
|
+
* succeeding segment. If this array is not provided, both are false.
|
|
147
|
+
* @param leftIsInside if true, the interior is "to the left" of the segments. If false, interior is "to the right".
|
|
142
148
|
*/
|
|
143
149
|
static createXYPolyLine(points, interior, leftIsInside, result) {
|
|
144
150
|
result = result ? result : new ConvexClipPlaneSet();
|
|
@@ -182,7 +188,7 @@ class ConvexClipPlaneSet {
|
|
|
182
188
|
return result;
|
|
183
189
|
}
|
|
184
190
|
/**
|
|
185
|
-
* (
|
|
191
|
+
* Set (or reset) a plane and ConvexClipPlaneSet for a convex array, such as a convex facet used for xy clip.
|
|
186
192
|
* * The planeOfPolygon is (re)initialized with the normal from 3 points, but not otherwise referenced.
|
|
187
193
|
* * The ConvexClipPlaneSet is filled with outward normals of the facet edges as viewed to xy plane.
|
|
188
194
|
* @param points
|
|
@@ -226,7 +232,7 @@ class ConvexClipPlaneSet {
|
|
|
226
232
|
* Test if there is any intersection with a ray defined by origin and direction.
|
|
227
233
|
* * Optionally record the range (null or otherwise) in caller-allocated result.
|
|
228
234
|
* * If the ray is unbounded inside the clip, result can contain positive or negative
|
|
229
|
-
*
|
|
235
|
+
* "Geometry.largeCoordinateResult" values.
|
|
230
236
|
* * If no result is provide, there are no object allocations.
|
|
231
237
|
* @param result optional Range1d to receive parameters along the ray.
|
|
232
238
|
*/
|
|
@@ -271,7 +277,8 @@ class ConvexClipPlaneSet {
|
|
|
271
277
|
* @param matrix matrix to apply.
|
|
272
278
|
* @param invert if true, use in verse of the matrix.
|
|
273
279
|
* @param transpose if true, use the transpose of the matrix (or inverse, per invert parameter)
|
|
274
|
-
* * Note that if matrixA is applied to all of space, the matrix to send to this method to get a corresponding effect
|
|
280
|
+
* * Note that if matrixA is applied to all of space, the matrix to send to this method to get a corresponding effect
|
|
281
|
+
* on the plane is the inverse transpose of matrixA.
|
|
275
282
|
* * Callers that will apply the same matrix to many planes should pre-invert the matrix for efficiency.
|
|
276
283
|
* * Both params default to true to get the full effect of transforming space.
|
|
277
284
|
* @param matrix matrix to apply
|
|
@@ -291,7 +298,8 @@ class ConvexClipPlaneSet {
|
|
|
291
298
|
/** Return true if `point` satisfies `point.isPointInside` for all planes */
|
|
292
299
|
isPointInside(point) {
|
|
293
300
|
for (const plane of this._planes) {
|
|
294
|
-
|
|
301
|
+
// Defaults to strict inside check. Other clipping classes may use "on or inside" check for the "on" case
|
|
302
|
+
if (!plane.isPointInside(point))
|
|
295
303
|
return false;
|
|
296
304
|
}
|
|
297
305
|
return true;
|
|
@@ -319,13 +327,15 @@ class ConvexClipPlaneSet {
|
|
|
319
327
|
}
|
|
320
328
|
return true;
|
|
321
329
|
}
|
|
322
|
-
/**
|
|
323
|
-
*
|
|
324
|
-
* *
|
|
330
|
+
/**
|
|
331
|
+
* Find the parts of the line segment (if any) that is within the convex clip volume.
|
|
332
|
+
* * The line segment is defined by `pointA` and `pointB`.
|
|
333
|
+
* * The input fractional interval from `fraction0` to `fraction1` (increasing) is the active part to consider.
|
|
334
|
+
* * To clip to the usual bounded line segment, start with fractions (0,1).
|
|
325
335
|
* If the clip volume is unbounded, the line interval may also be unbounded.
|
|
326
|
-
* * An unbounded line portion will have fraction coordinates positive or negative Number.MAX_VALUE
|
|
327
|
-
* @param
|
|
328
|
-
* @param
|
|
336
|
+
* * An unbounded line portion will have fraction coordinates positive or negative `Number.MAX_VALUE`.
|
|
337
|
+
* @param f0 fraction that is the initial lower fraction of the active interval (e.g., 0.0 for bounded segment).
|
|
338
|
+
* @param f1 fraction that is the initial upper fraction of the active interval (e.g., 1.0 for bounded segment).
|
|
329
339
|
* @param pointA segment start (fraction 0)
|
|
330
340
|
* @param pointB segment end (fraction 1)
|
|
331
341
|
* @param announce function to be called to announce a fraction interval that is within the convex clip volume.
|
|
@@ -340,7 +350,7 @@ class ConvexClipPlaneSet {
|
|
|
340
350
|
const hB = -plane.altitude(pointB);
|
|
341
351
|
fraction = Geometry.conditionalDivideFraction(-hA, (hB - hA));
|
|
342
352
|
if (fraction === undefined) {
|
|
343
|
-
//
|
|
353
|
+
// Line parallel to the plane. If positive, it is all OUT
|
|
344
354
|
if (hA > 0.0)
|
|
345
355
|
return false;
|
|
346
356
|
}
|
|
@@ -369,7 +379,8 @@ class ConvexClipPlaneSet {
|
|
|
369
379
|
}
|
|
370
380
|
return false;
|
|
371
381
|
}
|
|
372
|
-
/**
|
|
382
|
+
/**
|
|
383
|
+
* Find fractional parts of the arc that are within this ClipPlaneSet, and announce each as
|
|
373
384
|
* * `announce(fraction, fraction, curve)`
|
|
374
385
|
*/
|
|
375
386
|
announceClippedArcIntervals(arc, announce) {
|
|
@@ -381,7 +392,8 @@ class ConvexClipPlaneSet {
|
|
|
381
392
|
arc.sweep.radiansArrayToPositivePeriodicFractions(breaks);
|
|
382
393
|
return ClipUtilities.selectIntervals01(arc, breaks, this, announce);
|
|
383
394
|
}
|
|
384
|
-
/**
|
|
395
|
+
/**
|
|
396
|
+
* Find the parts of the (unbounded) line segment (if any) that is within the convex clip volume.
|
|
385
397
|
* @param pointA segment start (fraction 0)
|
|
386
398
|
* @param pointB segment end (fraction 1)
|
|
387
399
|
* @param announce function to be called to announce a fraction interval that is within the convex clip volume.
|
|
@@ -411,7 +423,8 @@ class ConvexClipPlaneSet {
|
|
|
411
423
|
return;
|
|
412
424
|
}
|
|
413
425
|
}
|
|
414
|
-
/**
|
|
426
|
+
/**
|
|
427
|
+
* Clip a convex polygon to (a single) inside part and (possibly many) outside parts.
|
|
415
428
|
* @param xyz input polygon.
|
|
416
429
|
* @param outsideFragments an array to receive (via push, with no preliminary clear) outside fragments
|
|
417
430
|
* @param arrayCache cache for work arrays.
|
|
@@ -454,14 +467,15 @@ class ConvexClipPlaneSet {
|
|
|
454
467
|
arrayCache.dropToCache(insidePart);
|
|
455
468
|
return undefined;
|
|
456
469
|
}
|
|
457
|
-
/**
|
|
470
|
+
/**
|
|
471
|
+
* Returns 1, 2, or 3 based on whether point array is strongly inside, ambiguous, or strongly outside respectively.
|
|
458
472
|
* * This has a peculiar expected use case as a very fast pre-filter for more precise clipping.
|
|
459
473
|
* * The expected point set is for a polygon.
|
|
460
474
|
* * Hence any clipping will eventually have to consider the lines between the points.
|
|
461
475
|
* * This method looks for the special case of a single clip plane that has all the points outside.
|
|
462
476
|
* * In this case the whole polygon must be outside.
|
|
463
477
|
* * Note that this does not detect a polygon that is outside but "crosses a corner" -- it is mixed with respect to
|
|
464
|
-
*
|
|
478
|
+
* multiple planes.
|
|
465
479
|
*/
|
|
466
480
|
classifyPointContainment(points, onIsOutside) {
|
|
467
481
|
let allInside = true;
|
|
@@ -483,7 +497,8 @@ class ConvexClipPlaneSet {
|
|
|
483
497
|
/**
|
|
484
498
|
* * Create a convex clip set for a polygon swept with possible tilt angle.
|
|
485
499
|
* * planes are constructed by ClipPlane.createEdgeAndUpVector, using successive points from the array.
|
|
486
|
-
* * If the first and last points match, the polygon area is checked. If the area is negative, points are used in
|
|
500
|
+
* * If the first and last points match, the polygon area is checked. If the area is negative, points are used in
|
|
501
|
+
* reverse order.
|
|
487
502
|
* * If first and last points do not match, points are used in order given
|
|
488
503
|
* @param points polygon points. (Closure point optional)
|
|
489
504
|
* @param upVector primary sweep direction, as applied by ClipPlane.createEdgeAndUpVector
|
|
@@ -531,7 +546,7 @@ class ConvexClipPlaneSet {
|
|
|
531
546
|
this._planes.push(ClipPlane.createPlane(plane));
|
|
532
547
|
}
|
|
533
548
|
/**
|
|
534
|
-
*
|
|
549
|
+
* Test many points. Distribute them to arrays depending on in/out result.
|
|
535
550
|
* @param points points to test
|
|
536
551
|
* @param inOrOn points that are in or on the set
|
|
537
552
|
* @param out points that are out.
|
|
@@ -551,8 +566,10 @@ class ConvexClipPlaneSet {
|
|
|
551
566
|
/**
|
|
552
567
|
* Clip a polygon to the planes of the clip plane set.
|
|
553
568
|
* * For a convex input polygon, the output is another convex polygon.
|
|
554
|
-
* * For a non-convex input, the output may have double-back edges along plane intersections.
|
|
555
|
-
*
|
|
569
|
+
* * For a non-convex input, the output may have double-back edges along plane intersections. This is still a
|
|
570
|
+
* valid clip in a parity sense.
|
|
571
|
+
* * The containingPlane parameter allows callers within ConvexClipPlane set to bypass planes known to contain
|
|
572
|
+
* the polygon.
|
|
556
573
|
* @param input input polygon, usually convex.
|
|
557
574
|
* @param output output polygon
|
|
558
575
|
* @param work work array.
|
|
@@ -597,7 +614,7 @@ class ConvexClipPlaneSet {
|
|
|
597
614
|
const inwardNormal = Vector3d.createCrossProduct(sweepDirection.x, sweepDirection.y, sweepDirection.z, edgeVector.x, edgeVector.y, edgeVector.z);
|
|
598
615
|
const inwardNormalNormalized = inwardNormal.normalize();
|
|
599
616
|
let distance;
|
|
600
|
-
if (inwardNormalNormalized) { //
|
|
617
|
+
if (inwardNormalNormalized) { // should never fail... simply a check due to the format of the normalize function return
|
|
601
618
|
distance = inwardNormalNormalized.dotProduct(xyz0);
|
|
602
619
|
const clipToAdd = ClipPlane.createNormalAndDistance(inwardNormalNormalized, distance, false, false);
|
|
603
620
|
if (clipToAdd) {
|
|
@@ -626,13 +643,16 @@ class ConvexClipPlaneSet {
|
|
|
626
643
|
* * optionally throw out points that are not in the set.
|
|
627
644
|
* * optionally push the points in the caller-supplied point array.
|
|
628
645
|
* * optionally extend a caller supplied range.
|
|
629
|
-
* * In the common case where the convex set is (a) a slab or (b) a view frustum, there will be 8 points and the
|
|
630
|
-
*
|
|
646
|
+
* * In the common case where the convex set is (a) a slab or (b) a view frustum, there will be 8 points and the
|
|
647
|
+
* range is the range of the convex set.
|
|
648
|
+
* * If the convex set is unbounded, the range only contains the range of the accepted (corner) points, and the
|
|
649
|
+
* range is not a representative of the "range of all points in the set".
|
|
631
650
|
* @param transform (optional) transform to apply to the points.
|
|
632
651
|
* @param points (optional) array to which computed points are to be added.
|
|
633
652
|
* @param range (optional) range to be extended by the computed points
|
|
634
653
|
* @param transform (optional) transform to apply to the accepted points.
|
|
635
|
-
* @param testContainment if true, test each point to see if it is within the convex set.
|
|
654
|
+
* @param testContainment if true, test each point to see if it is within the convex set. (send false if confident
|
|
655
|
+
* that the convex set is rectilinear set such as a slab. Send true if chiseled corners are possible).
|
|
636
656
|
* @returns number of points.
|
|
637
657
|
*/
|
|
638
658
|
computePlanePlanePlaneIntersections(points, rangeToExtend, transform, testContainment = true) {
|
|
@@ -681,11 +701,13 @@ class ConvexClipPlaneSet {
|
|
|
681
701
|
if (zHigh !== undefined)
|
|
682
702
|
this._planes.push(ClipPlane.createNormalAndDistance(Vector3d.create(0, 0, -1), -zHigh, invisible));
|
|
683
703
|
}
|
|
684
|
-
/**
|
|
685
|
-
*
|
|
704
|
+
/**
|
|
705
|
+
* Implement appendPolygonClip, as defined in interface PolygonClipper.
|
|
686
706
|
* @param xyz input polygon. This is not changed.
|
|
687
|
-
* @param insideFragments Array to receive "inside" fragments.
|
|
688
|
-
*
|
|
707
|
+
* @param insideFragments Array to receive "inside" fragments. Each fragment is a GrowableXYZArray grabbed from
|
|
708
|
+
* the cache. This is NOT cleared.
|
|
709
|
+
* @param outsideFragments Array to receive "outside" fragments. Each fragment is a GrowableXYZArray grabbed from
|
|
710
|
+
* the cache. This is NOT cleared.
|
|
689
711
|
* @param arrayCache cache for reusable GrowableXYZArray.
|
|
690
712
|
*/
|
|
691
713
|
appendPolygonClip(xyz, insideFragments, outsideFragments, arrayCache) {
|
|
@@ -693,7 +715,8 @@ class ConvexClipPlaneSet {
|
|
|
693
715
|
if (newInside)
|
|
694
716
|
insideFragments.push(newInside);
|
|
695
717
|
}
|
|
696
|
-
/**
|
|
718
|
+
/**
|
|
719
|
+
* Create a convex clip set from a convex mesh.
|
|
697
720
|
* * Create a plane for each facet.
|
|
698
721
|
* * Assemble the planes as a single clip plane set.
|
|
699
722
|
* * If the facets are closed by edge pairing, use the sign of the computed volume to point the plane normals inward.
|