@itwin/core-geometry 3.2.0-dev.7 → 3.2.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 +38 -1
- package/lib/cjs/geometry3d/Angle.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Angle.js.map +1 -1
- package/lib/cjs/numerics/ClusterableArray.d.ts +29 -2
- package/lib/cjs/numerics/ClusterableArray.d.ts.map +1 -1
- package/lib/cjs/numerics/ClusterableArray.js +54 -2
- package/lib/cjs/numerics/ClusterableArray.js.map +1 -1
- package/lib/cjs/polyface/IndexedEdgeMatcher.d.ts.map +1 -1
- package/lib/cjs/polyface/IndexedEdgeMatcher.js +0 -3
- package/lib/cjs/polyface/IndexedEdgeMatcher.js.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/cjs/polyface/Polyface.d.ts +4 -4
- package/lib/cjs/polyface/Polyface.d.ts.map +1 -1
- package/lib/cjs/polyface/Polyface.js +30 -44
- package/lib/cjs/polyface/Polyface.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts +58 -17
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.js +235 -47
- package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceData.d.ts +3 -3
- package/lib/cjs/polyface/PolyfaceData.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceData.js +8 -3
- package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.d.ts +6 -4
- package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js +20 -7
- package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/cjs/serialization/BGFBAccessors.d.ts +2 -2
- package/lib/cjs/serialization/BGFBAccessors.d.ts.map +1 -1
- package/lib/cjs/serialization/BGFBAccessors.js +2 -2
- package/lib/cjs/serialization/BGFBAccessors.js.map +1 -1
- package/lib/cjs/serialization/BGFBReader.d.ts.map +1 -1
- package/lib/cjs/serialization/BGFBReader.js +0 -1
- package/lib/cjs/serialization/BGFBReader.js.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.js +4 -3
- package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
- package/lib/esm/geometry3d/Angle.d.ts.map +1 -1
- package/lib/esm/geometry3d/Angle.js.map +1 -1
- package/lib/esm/numerics/ClusterableArray.d.ts +29 -2
- package/lib/esm/numerics/ClusterableArray.d.ts.map +1 -1
- package/lib/esm/numerics/ClusterableArray.js +54 -2
- package/lib/esm/numerics/ClusterableArray.js.map +1 -1
- package/lib/esm/polyface/IndexedEdgeMatcher.d.ts.map +1 -1
- package/lib/esm/polyface/IndexedEdgeMatcher.js +0 -3
- package/lib/esm/polyface/IndexedEdgeMatcher.js.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/esm/polyface/Polyface.d.ts +4 -4
- package/lib/esm/polyface/Polyface.d.ts.map +1 -1
- package/lib/esm/polyface/Polyface.js +30 -44
- package/lib/esm/polyface/Polyface.js.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.d.ts +58 -17
- package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.js +235 -47
- package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/esm/polyface/PolyfaceData.d.ts +3 -3
- package/lib/esm/polyface/PolyfaceData.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceData.js +8 -3
- package/lib/esm/polyface/PolyfaceData.js.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.d.ts +6 -4
- package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js +20 -7
- package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/esm/serialization/BGFBAccessors.d.ts +2 -2
- package/lib/esm/serialization/BGFBAccessors.d.ts.map +1 -1
- package/lib/esm/serialization/BGFBAccessors.js +2 -2
- package/lib/esm/serialization/BGFBAccessors.js.map +1 -1
- package/lib/esm/serialization/BGFBReader.d.ts.map +1 -1
- package/lib/esm/serialization/BGFBReader.js +0 -1
- package/lib/esm/serialization/BGFBReader.js.map +1 -1
- package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/esm/serialization/GeometrySamples.js +4 -3
- package/lib/esm/serialization/GeometrySamples.js.map +1 -1
- package/package.json +4 -5
|
@@ -64,14 +64,12 @@ import { XAndY } from "../geometry3d/XYZProps";
|
|
|
64
64
|
* * Low-level detail construction -- direct use of indices
|
|
65
65
|
* * Create a builder with `builder = PolyfaceBuilder.create()`
|
|
66
66
|
* * Add GeometryQuery objects
|
|
67
|
-
* * `builder.
|
|
67
|
+
* * `builder.addPoint(point)`
|
|
68
68
|
* * `builder.findOrAddPointInLineString (linestring, index)`
|
|
69
|
-
* * `builder.
|
|
70
|
-
* * `builder.
|
|
71
|
-
* * `builder.
|
|
72
|
-
|
|
73
|
-
* * `builder.addOneBasedPointIndex (index)`
|
|
74
|
-
* @public
|
|
69
|
+
* * `builder.addPointXYZ(x,y,z)`
|
|
70
|
+
* * `builder.addTriangleFacet (points)`
|
|
71
|
+
* * `builder.addQuadFacet (points)`
|
|
72
|
+
* @public
|
|
75
73
|
*/
|
|
76
74
|
export declare class PolyfaceBuilder extends NullGeometryHandler {
|
|
77
75
|
private _polyface;
|
|
@@ -111,11 +109,21 @@ export declare class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
111
109
|
*/
|
|
112
110
|
addTrianglesInUncheckedConvexPolygon(ls: LineString3d, toggle: boolean): void;
|
|
113
111
|
/**
|
|
114
|
-
* Announce point coordinates.
|
|
112
|
+
* Announce point coordinates.
|
|
113
|
+
*/
|
|
114
|
+
addPoint(xyz: Point3d): number;
|
|
115
|
+
/**
|
|
116
|
+
* Announce point coordinates.
|
|
117
|
+
* @deprecated Use addPoint instead.
|
|
115
118
|
*/
|
|
116
119
|
findOrAddPoint(xyz: Point3d): number;
|
|
117
120
|
/**
|
|
118
|
-
* Announce
|
|
121
|
+
* Announce uv parameter coordinates.
|
|
122
|
+
*/
|
|
123
|
+
addParamXY(x: number, y: number): number;
|
|
124
|
+
/**
|
|
125
|
+
* Announce uv parameter coordinates.
|
|
126
|
+
* @deprecated Use addParamXY instead.
|
|
119
127
|
*/
|
|
120
128
|
findOrAddParamXY(x: number, y: number): number;
|
|
121
129
|
private static _workPointFindOrAddA;
|
|
@@ -140,10 +148,15 @@ export declare class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
140
148
|
*/
|
|
141
149
|
findOrAddNormalInGrowableXYZArray(xyz: GrowableXYZArray, index: number, transform?: Transform, priorIndex?: number): number | undefined;
|
|
142
150
|
/**
|
|
143
|
-
* Announce
|
|
144
|
-
* @returns Returns the
|
|
151
|
+
* Announce uv parameter coordinates.
|
|
152
|
+
* @returns Returns the uv parameter index in the Polyface.
|
|
145
153
|
* @param index Index of the param in the linestring.
|
|
146
154
|
*/
|
|
155
|
+
addParamInGrowableXYArray(data: GrowableXYArray, index: number): number | undefined;
|
|
156
|
+
/**
|
|
157
|
+
* Announce uv parameter coordinates.
|
|
158
|
+
* @deprecated Use addParamInGrowableXYArray instead.
|
|
159
|
+
*/
|
|
147
160
|
findOrAddParamInGrowableXYArray(data: GrowableXYArray, index: number): number | undefined;
|
|
148
161
|
/**
|
|
149
162
|
* Announce param coordinates, taking u from ls.fractions and v from parameter. The implementation is free to either create a new param or (if known) return index of a prior point with the same coordinates.
|
|
@@ -159,7 +172,12 @@ export declare class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
159
172
|
*/
|
|
160
173
|
findOrAddNormalInLineString(ls: LineString3d, index: number, transform?: Transform, priorIndexA?: number, priorIndexB?: number): number | undefined;
|
|
161
174
|
/**
|
|
162
|
-
* Announce point coordinates.
|
|
175
|
+
* Announce point coordinates.
|
|
176
|
+
*/
|
|
177
|
+
addPointXYZ(x: number, y: number, z: number): number;
|
|
178
|
+
/**
|
|
179
|
+
* Announce point coordinates.
|
|
180
|
+
* @deprecated Use addPointXYZ instead.
|
|
163
181
|
*/
|
|
164
182
|
findOrAddPointXYZ(x: number, y: number, z: number): number;
|
|
165
183
|
/** Returns a transform who can be applied to points on a triangular facet in order to obtain UV parameters. */
|
|
@@ -168,10 +186,12 @@ export declare class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
168
186
|
private getNormalForTriangularFacet;
|
|
169
187
|
/**
|
|
170
188
|
* Add a quad to the polyface given its points in order around the edges.
|
|
171
|
-
*
|
|
172
|
-
*
|
|
189
|
+
* @param points array of at least three vertices
|
|
190
|
+
* @param params optional array of at least four uv parameters (if undefined, params are calculated without reference data)
|
|
191
|
+
* @param normals optional array of at least four vectors (if undefined, the quad is assumed to be planar and its normal is calculated)
|
|
192
|
+
* @param colors optional array of at least four colors
|
|
173
193
|
*/
|
|
174
|
-
addQuadFacet(points: Point3d[] | GrowableXYZArray, params?: Point2d[], normals?: Vector3d[]): void;
|
|
194
|
+
addQuadFacet(points: Point3d[] | GrowableXYZArray, params?: Point2d[], normals?: Vector3d[], colors?: number[]): void;
|
|
175
195
|
/** Announce a single quad facet's point indexes.
|
|
176
196
|
*
|
|
177
197
|
* * The actual quad may be reversed or triangulated based on builder setup.
|
|
@@ -183,11 +203,16 @@ export declare class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
183
203
|
private addIndexedQuadParamIndexes;
|
|
184
204
|
/** For a single quad facet, add the indexes of the corresponding normal vectors. */
|
|
185
205
|
private addIndexedQuadNormalIndexes;
|
|
206
|
+
/** For a single quad facet, add the indexes of the corresponding colors. */
|
|
207
|
+
private addIndexedQuadColorIndexes;
|
|
186
208
|
/**
|
|
187
209
|
* Add a triangle to the polyface given its points in order around the edges.
|
|
188
|
-
*
|
|
210
|
+
* @param points array of at least three vertices
|
|
211
|
+
* @param params optional array of at least three uv parameters (if undefined, params are calculated without reference data)
|
|
212
|
+
* @param normals optional array of at least three vectors (if undefined, the normal is calculated)
|
|
213
|
+
* @param colors optional array of at least three colors
|
|
189
214
|
*/
|
|
190
|
-
addTriangleFacet(points: Point3d[] | GrowableXYZArray, params?: Point2d[], normals?: Vector3d[]): void;
|
|
215
|
+
addTriangleFacet(points: Point3d[] | GrowableXYZArray, params?: Point2d[], normals?: Vector3d[], colors?: number[]): void;
|
|
191
216
|
/** Announce a single triangle facet's point indexes.
|
|
192
217
|
*
|
|
193
218
|
* * The actual quad may be reversed or triangulated based on builder setup.
|
|
@@ -197,6 +222,8 @@ export declare class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
197
222
|
private addIndexedTriangleParamIndexes;
|
|
198
223
|
/** For a single triangle facet, add the indexes of the corresponding params. */
|
|
199
224
|
private addIndexedTriangleNormalIndexes;
|
|
225
|
+
/** For a single triangle facet, add the indexes of the corresponding colors. */
|
|
226
|
+
private addIndexedTriangleColorIndexes;
|
|
200
227
|
/** Find or add xyzIndex and normalIndex for coordinates in the sector. */
|
|
201
228
|
private setSectorIndices;
|
|
202
229
|
private addSectorQuadA01B01;
|
|
@@ -405,5 +432,19 @@ export declare class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
405
432
|
* @param numFacetAround how many equal parameter-space chords around each section
|
|
406
433
|
*/
|
|
407
434
|
addMiteredPipes(centerline: IndexedXYZCollection | Point3d[] | CurvePrimitive, sectionData: number | XAndY | Arc3d, numFacetAround?: number): void;
|
|
435
|
+
/** Return the polyface index array indices corresponding to the given edge, or undefined if error. */
|
|
436
|
+
private getEdgeIndices;
|
|
437
|
+
/** Create a side face between base and swept facets along a base boundary edge.
|
|
438
|
+
* * Assumes numBaseFacets base facets were added to this builder, immediately followed by the same number of swept facets with opposite orientation (first index not preserved).
|
|
439
|
+
*/
|
|
440
|
+
private addSweptFace;
|
|
441
|
+
/**
|
|
442
|
+
* Add facets from the source polyface, from its translation along the vector, and from its swept boundary edges, to form a polyface that encloses a volume.
|
|
443
|
+
* @param source the surface mesh to sweep
|
|
444
|
+
* @param sweepVector the direction and length to sweep the surface mesh
|
|
445
|
+
* @param triangulateSides whether to triangulate side facets, or leave as quads
|
|
446
|
+
* @returns whether the added facets comprise a simple sweep. If false, the resulting mesh may have self-intersections, be non-manifold, have inconsistently oriented facets, etc.
|
|
447
|
+
*/
|
|
448
|
+
addSweptIndexedPolyface(source: IndexedPolyface, sweepVector: Vector3d, triangulateSides?: boolean): boolean;
|
|
408
449
|
}
|
|
409
450
|
//# sourceMappingURL=PolyfaceBuilder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PolyfaceBuilder.d.ts","sourceRoot":"","sources":["../../../src/polyface/PolyfaceBuilder.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAG1D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAIrD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAKvD,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAG1E,OAAO,EAA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AE,OAAO,GAAE,OAAe;IAclI;;;;;;;;;;OAUG;IACI,aAAa,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,SAAS;IAiHvG;;;OAGG;WACW,4BAA4B,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,eAAe,GAAG,SAAS;IAM1F;;;;;;;;;OASG;IACI,wCAAwC,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,YAAY,GAAG,oBAAoB,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,YAAY,GAAG,oBAAoB;IAUlK,OAAO,CAAC,yBAAyB;IAuBjC;;;;;;;;OAQG;IACI,eAAe,CAAC,UAAU,EAAE,oBAAoB,GAAG,OAAO,EAAE,GAAG,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,EAAE,cAAc,GAAE,MAAW;IAgBtJ,sGAAsG;IACtG,OAAO,CAAC,cAAc;IAWtB;;MAEE;IACF,OAAO,CAAC,YAAY;IAyCpB;;;;;;OAMG;IACI,uBAAuB,CAAC,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,GAAE,OAAe,GAAG,OAAO;CA0C3H"}
|
|
@@ -35,6 +35,10 @@ import { Triangulator } from "../topology/Triangulation";
|
|
|
35
35
|
import { BoxTopology } from "./BoxTopology";
|
|
36
36
|
import { GreedyTriangulationBetweenLineStrings } from "./GreedyTriangulationBetweenLineStrings";
|
|
37
37
|
import { IndexedPolyface } from "./Polyface";
|
|
38
|
+
import { PolyfaceQuery } from "./PolyfaceQuery";
|
|
39
|
+
import { Angle } from "../geometry3d/Angle";
|
|
40
|
+
import { IndexedPolyfaceSubsetVisitor } from "./IndexedPolyfaceVisitor";
|
|
41
|
+
import { SortableEdge } from "./IndexedEdgeMatcher";
|
|
38
42
|
/* eslint-disable @typescript-eslint/naming-convention, @typescript-eslint/prefer-for-of */
|
|
39
43
|
/**
|
|
40
44
|
* A FacetSector
|
|
@@ -160,14 +164,12 @@ FacetSector._edgeVector = Vector3d.create();
|
|
|
160
164
|
* * Low-level detail construction -- direct use of indices
|
|
161
165
|
* * Create a builder with `builder = PolyfaceBuilder.create()`
|
|
162
166
|
* * Add GeometryQuery objects
|
|
163
|
-
* * `builder.
|
|
167
|
+
* * `builder.addPoint(point)`
|
|
164
168
|
* * `builder.findOrAddPointInLineString (linestring, index)`
|
|
165
|
-
* * `builder.
|
|
166
|
-
* * `builder.
|
|
167
|
-
* * `builder.
|
|
168
|
-
|
|
169
|
-
* * `builder.addOneBasedPointIndex (index)`
|
|
170
|
-
* @public
|
|
169
|
+
* * `builder.addPointXYZ(x,y,z)`
|
|
170
|
+
* * `builder.addTriangleFacet (points)`
|
|
171
|
+
* * `builder.addQuadFacet (points)`
|
|
172
|
+
* @public
|
|
171
173
|
*/
|
|
172
174
|
export class PolyfaceBuilder extends NullGeometryHandler {
|
|
173
175
|
constructor(options) {
|
|
@@ -227,7 +229,7 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
227
229
|
if (n > 2) {
|
|
228
230
|
if (toggle)
|
|
229
231
|
this.toggleReversedFacetFlag();
|
|
230
|
-
const index0 = this.
|
|
232
|
+
const index0 = this.addPoint(conePoint);
|
|
231
233
|
let index1 = this.findOrAddPointInLineString(ls, 0);
|
|
232
234
|
let index2 = 0;
|
|
233
235
|
for (let i = 1; i < n; i++) {
|
|
@@ -265,8 +267,8 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
265
267
|
let paramIndex1 = -1;
|
|
266
268
|
let paramIndex2 = -1;
|
|
267
269
|
if (packedUV) {
|
|
268
|
-
paramIndex0 = this.
|
|
269
|
-
paramIndex1 = this.
|
|
270
|
+
paramIndex0 = this.addParamInGrowableXYArray(packedUV, 0);
|
|
271
|
+
paramIndex1 = this.addParamInGrowableXYArray(packedUV, 1);
|
|
270
272
|
}
|
|
271
273
|
const pointIndex0 = this.findOrAddPointInLineString(ls, 0);
|
|
272
274
|
let pointIndex1 = this.findOrAddPointInLineString(ls, 1);
|
|
@@ -280,7 +282,7 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
280
282
|
if (normalIndex !== undefined)
|
|
281
283
|
this.addIndexedTriangleNormalIndexes(normalIndex, normalIndex, normalIndex);
|
|
282
284
|
if (packedUV) {
|
|
283
|
-
paramIndex2 = this.
|
|
285
|
+
paramIndex2 = this.addParamInGrowableXYArray(packedUV, i);
|
|
284
286
|
this.addIndexedTriangleParamIndexes(paramIndex0, paramIndex1, paramIndex2);
|
|
285
287
|
}
|
|
286
288
|
this._polyface.terminateFacet();
|
|
@@ -290,17 +292,31 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
290
292
|
}
|
|
291
293
|
}
|
|
292
294
|
/**
|
|
293
|
-
* Announce point coordinates.
|
|
295
|
+
* Announce point coordinates.
|
|
294
296
|
*/
|
|
295
|
-
|
|
297
|
+
addPoint(xyz) {
|
|
296
298
|
return this._polyface.addPoint(xyz);
|
|
297
299
|
}
|
|
298
300
|
/**
|
|
299
|
-
* Announce point coordinates.
|
|
301
|
+
* Announce point coordinates.
|
|
302
|
+
* @deprecated Use addPoint instead.
|
|
300
303
|
*/
|
|
301
|
-
|
|
304
|
+
findOrAddPoint(xyz) {
|
|
305
|
+
return this.addPoint(xyz);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Announce uv parameter coordinates.
|
|
309
|
+
*/
|
|
310
|
+
addParamXY(x, y) {
|
|
302
311
|
return this._polyface.addParamUV(x, y);
|
|
303
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* Announce uv parameter coordinates.
|
|
315
|
+
* @deprecated Use addParamXY instead.
|
|
316
|
+
*/
|
|
317
|
+
findOrAddParamXY(x, y) {
|
|
318
|
+
return this.addParamXY(x, y);
|
|
319
|
+
}
|
|
304
320
|
/**
|
|
305
321
|
* Announce point coordinates. The implementation is free to either create a new point or (if known) return index of a prior point with the same coordinates.
|
|
306
322
|
* @returns Returns the point index in the Polyface.
|
|
@@ -344,19 +360,26 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
344
360
|
return undefined;
|
|
345
361
|
}
|
|
346
362
|
/**
|
|
347
|
-
* Announce
|
|
348
|
-
* @returns Returns the
|
|
363
|
+
* Announce uv parameter coordinates.
|
|
364
|
+
* @returns Returns the uv parameter index in the Polyface.
|
|
349
365
|
* @param index Index of the param in the linestring.
|
|
350
366
|
*/
|
|
351
|
-
|
|
367
|
+
addParamInGrowableXYArray(data, index) {
|
|
352
368
|
if (!data)
|
|
353
369
|
return undefined;
|
|
354
|
-
const q = data.
|
|
370
|
+
const q = data.getPoint2dAtCheckedPointIndex(index, PolyfaceBuilder._workUVFindOrAdd);
|
|
355
371
|
if (q) {
|
|
356
372
|
return this._polyface.addParam(q);
|
|
357
373
|
}
|
|
358
374
|
return undefined;
|
|
359
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* Announce uv parameter coordinates.
|
|
378
|
+
* @deprecated Use addParamInGrowableXYArray instead.
|
|
379
|
+
*/
|
|
380
|
+
findOrAddParamInGrowableXYArray(data, index) {
|
|
381
|
+
return this.addParamInGrowableXYArray(data, index);
|
|
382
|
+
}
|
|
360
383
|
/**
|
|
361
384
|
* Announce param coordinates, taking u from ls.fractions and v from parameter. The implementation is free to either create a new param or (if known) return index of a prior point with the same coordinates.
|
|
362
385
|
* @returns Returns the point index in the Polyface.
|
|
@@ -385,11 +408,18 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
385
408
|
return undefined;
|
|
386
409
|
}
|
|
387
410
|
/**
|
|
388
|
-
* Announce point coordinates.
|
|
411
|
+
* Announce point coordinates.
|
|
389
412
|
*/
|
|
390
|
-
|
|
413
|
+
addPointXYZ(x, y, z) {
|
|
391
414
|
return this._polyface.addPointXYZ(x, y, z);
|
|
392
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
* Announce point coordinates.
|
|
418
|
+
* @deprecated Use addPointXYZ instead.
|
|
419
|
+
*/
|
|
420
|
+
findOrAddPointXYZ(x, y, z) {
|
|
421
|
+
return this.addPointXYZ(x, y, z);
|
|
422
|
+
}
|
|
393
423
|
/** Returns a transform who can be applied to points on a triangular facet in order to obtain UV parameters. */
|
|
394
424
|
getUVTransformForTriangleFacet(pointA, pointB, pointC) {
|
|
395
425
|
const vectorAB = pointA.vectorTo(pointB);
|
|
@@ -409,17 +439,21 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
409
439
|
// ###: Consider case where normals will be reversed and point through the other end of the facet
|
|
410
440
|
/**
|
|
411
441
|
* Add a quad to the polyface given its points in order around the edges.
|
|
412
|
-
*
|
|
413
|
-
*
|
|
442
|
+
* @param points array of at least three vertices
|
|
443
|
+
* @param params optional array of at least four uv parameters (if undefined, params are calculated without reference data)
|
|
444
|
+
* @param normals optional array of at least four vectors (if undefined, the quad is assumed to be planar and its normal is calculated)
|
|
445
|
+
* @param colors optional array of at least four colors
|
|
414
446
|
*/
|
|
415
|
-
addQuadFacet(points, params, normals) {
|
|
447
|
+
addQuadFacet(points, params, normals, colors) {
|
|
416
448
|
if (points instanceof GrowableXYZArray)
|
|
417
449
|
points = points.getPoint3dArray();
|
|
418
450
|
// If params and/or normals are needed, calculate them first
|
|
419
451
|
const needParams = this.options.needParams;
|
|
420
452
|
const needNormals = this.options.needNormals;
|
|
453
|
+
const needColors = this.options.needColors;
|
|
421
454
|
let param0, param1, param2, param3;
|
|
422
455
|
let normal0, normal1, normal2, normal3;
|
|
456
|
+
let color0, color1, color2, color3;
|
|
423
457
|
if (needParams) {
|
|
424
458
|
if (params !== undefined && params.length > 3) {
|
|
425
459
|
param0 = params[0];
|
|
@@ -454,18 +488,26 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
454
488
|
normal3 = this.getNormalForTriangularFacet(points[0], points[1], points[2]);
|
|
455
489
|
}
|
|
456
490
|
}
|
|
491
|
+
if (needColors) {
|
|
492
|
+
if (colors !== undefined && colors.length > 3) {
|
|
493
|
+
color0 = colors[0];
|
|
494
|
+
color1 = colors[1];
|
|
495
|
+
color2 = colors[2];
|
|
496
|
+
color3 = colors[3];
|
|
497
|
+
}
|
|
498
|
+
}
|
|
457
499
|
if (this._options.shouldTriangulate) {
|
|
458
500
|
// Add as two triangles, with a diagonal along the shortest distance
|
|
459
501
|
const vectorAC = points[0].vectorTo(points[2]);
|
|
460
502
|
const vectorBD = points[1].vectorTo(points[3]);
|
|
461
503
|
// Note: We pass along any values for normals or params that we calculated
|
|
462
504
|
if (vectorAC.magnitude() >= vectorBD.magnitude()) {
|
|
463
|
-
this.addTriangleFacet([points[0], points[1], points[2]], needParams ? [param0, param1, param2] : undefined, needNormals ? [normal0, normal1, normal2] : undefined);
|
|
464
|
-
this.addTriangleFacet([points[0], points[2], points[3]], needParams ? [param0, param2, param3] : undefined, needNormals ? [normal0, normal2, normal3] : undefined);
|
|
505
|
+
this.addTriangleFacet([points[0], points[1], points[2]], needParams ? [param0, param1, param2] : undefined, needNormals ? [normal0, normal1, normal2] : undefined, needColors ? [color0, color1, color2] : undefined);
|
|
506
|
+
this.addTriangleFacet([points[0], points[2], points[3]], needParams ? [param0, param2, param3] : undefined, needNormals ? [normal0, normal2, normal3] : undefined, needColors ? [color0, color2, color3] : undefined);
|
|
465
507
|
}
|
|
466
508
|
else {
|
|
467
|
-
this.addTriangleFacet([points[0], points[1], points[3]], needParams ? [param0, param1, param3] : undefined, needNormals ? [normal0, normal1, normal3] : undefined);
|
|
468
|
-
this.addTriangleFacet([points[1], points[2], points[3]], needParams ? [param1, param2, param3] : undefined, needNormals ? [normal1, normal2, normal3] : undefined);
|
|
509
|
+
this.addTriangleFacet([points[0], points[1], points[3]], needParams ? [param0, param1, param3] : undefined, needNormals ? [normal0, normal1, normal3] : undefined, needColors ? [color0, color1, color3] : undefined);
|
|
510
|
+
this.addTriangleFacet([points[1], points[2], points[3]], needParams ? [param1, param2, param3] : undefined, needNormals ? [normal1, normal2, normal3] : undefined, needColors ? [color1, color2, color3] : undefined);
|
|
469
511
|
}
|
|
470
512
|
return;
|
|
471
513
|
}
|
|
@@ -486,11 +528,19 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
486
528
|
idx3 = this._polyface.addNormal(normal3);
|
|
487
529
|
this.addIndexedQuadNormalIndexes(idx0, idx1, idx3, idx2);
|
|
488
530
|
}
|
|
531
|
+
// Add colors if needed
|
|
532
|
+
if (needColors) {
|
|
533
|
+
idx0 = this._polyface.addColor(color0);
|
|
534
|
+
idx1 = this._polyface.addColor(color1);
|
|
535
|
+
idx2 = this._polyface.addColor(color2);
|
|
536
|
+
idx3 = this._polyface.addColor(color3);
|
|
537
|
+
this.addIndexedQuadColorIndexes(idx0, idx1, idx3, idx2);
|
|
538
|
+
}
|
|
489
539
|
// Add point and point indexes last (terminates the facet)
|
|
490
|
-
idx0 = this.
|
|
491
|
-
idx1 = this.
|
|
492
|
-
idx2 = this.
|
|
493
|
-
idx3 = this.
|
|
540
|
+
idx0 = this.addPoint(points[0]);
|
|
541
|
+
idx1 = this.addPoint(points[1]);
|
|
542
|
+
idx2 = this.addPoint(points[2]);
|
|
543
|
+
idx3 = this.addPoint(points[3]);
|
|
494
544
|
this.addIndexedQuadPointIndexes(idx0, idx1, idx3, idx2);
|
|
495
545
|
}
|
|
496
546
|
/** Announce a single quad facet's point indexes.
|
|
@@ -545,12 +595,30 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
545
595
|
this._polyface.addNormalIndex(indexB0);
|
|
546
596
|
}
|
|
547
597
|
}
|
|
598
|
+
/** For a single quad facet, add the indexes of the corresponding colors. */
|
|
599
|
+
addIndexedQuadColorIndexes(indexA0, indexA1, indexB0, indexB1) {
|
|
600
|
+
if (this._reversed) {
|
|
601
|
+
this._polyface.addColorIndex(indexA0);
|
|
602
|
+
this._polyface.addColorIndex(indexB0);
|
|
603
|
+
this._polyface.addColorIndex(indexB1);
|
|
604
|
+
this._polyface.addColorIndex(indexA1);
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
this._polyface.addColorIndex(indexA0);
|
|
608
|
+
this._polyface.addColorIndex(indexA1);
|
|
609
|
+
this._polyface.addColorIndex(indexB1);
|
|
610
|
+
this._polyface.addColorIndex(indexB0);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
548
613
|
// ### TODO: Consider case where normals will be reversed and point through the other end of the facet
|
|
549
614
|
/**
|
|
550
615
|
* Add a triangle to the polyface given its points in order around the edges.
|
|
551
|
-
*
|
|
616
|
+
* @param points array of at least three vertices
|
|
617
|
+
* @param params optional array of at least three uv parameters (if undefined, params are calculated without reference data)
|
|
618
|
+
* @param normals optional array of at least three vectors (if undefined, the normal is calculated)
|
|
619
|
+
* @param colors optional array of at least three colors
|
|
552
620
|
*/
|
|
553
|
-
addTriangleFacet(points, params, normals) {
|
|
621
|
+
addTriangleFacet(points, params, normals, colors) {
|
|
554
622
|
if (points.length < 3)
|
|
555
623
|
return;
|
|
556
624
|
let idx0;
|
|
@@ -597,10 +665,19 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
597
665
|
}
|
|
598
666
|
this.addIndexedTriangleNormalIndexes(idx0, idx1, idx2);
|
|
599
667
|
}
|
|
668
|
+
// Add colors if needed and provided
|
|
669
|
+
if (this._options.needColors) {
|
|
670
|
+
if (colors !== undefined && colors.length > 2) {
|
|
671
|
+
idx0 = this._polyface.addColor(colors[0]);
|
|
672
|
+
idx1 = this._polyface.addColor(colors[1]);
|
|
673
|
+
idx2 = this._polyface.addColor(colors[2]);
|
|
674
|
+
this.addIndexedTriangleColorIndexes(idx0, idx1, idx2);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
600
677
|
// Add point and point indexes last (terminates the facet)
|
|
601
|
-
idx0 = this.
|
|
602
|
-
idx1 = this.
|
|
603
|
-
idx2 = this.
|
|
678
|
+
idx0 = this.addPoint(point0);
|
|
679
|
+
idx1 = this.addPoint(point1);
|
|
680
|
+
idx2 = this.addPoint(point2);
|
|
604
681
|
this.addIndexedTrianglePointIndexes(idx0, idx1, idx2);
|
|
605
682
|
}
|
|
606
683
|
/** Announce a single triangle facet's point indexes.
|
|
@@ -647,9 +724,22 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
647
724
|
this._polyface.addNormalIndex(indexB);
|
|
648
725
|
}
|
|
649
726
|
}
|
|
727
|
+
/** For a single triangle facet, add the indexes of the corresponding colors. */
|
|
728
|
+
addIndexedTriangleColorIndexes(indexA, indexB, indexC) {
|
|
729
|
+
if (!this._reversed) {
|
|
730
|
+
this._polyface.addColorIndex(indexA);
|
|
731
|
+
this._polyface.addColorIndex(indexB);
|
|
732
|
+
this._polyface.addColorIndex(indexC);
|
|
733
|
+
}
|
|
734
|
+
else {
|
|
735
|
+
this._polyface.addColorIndex(indexA);
|
|
736
|
+
this._polyface.addColorIndex(indexC);
|
|
737
|
+
this._polyface.addColorIndex(indexB);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
650
740
|
/** Find or add xyzIndex and normalIndex for coordinates in the sector. */
|
|
651
741
|
setSectorIndices(sector) {
|
|
652
|
-
sector.xyzIndex = this.
|
|
742
|
+
sector.xyzIndex = this.addPoint(sector.xyz);
|
|
653
743
|
if (sector.normal)
|
|
654
744
|
sector.normalIndex = this._polyface.addNormal(sector.normal);
|
|
655
745
|
if (sector.uv)
|
|
@@ -893,8 +983,8 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
893
983
|
for (let i = 0; i < n; i++) {
|
|
894
984
|
pointA = contour.pointAt(i, pointA);
|
|
895
985
|
pointB = pointA.plus(vector, pointB);
|
|
896
|
-
indexA1 = this.
|
|
897
|
-
indexB1 = this.
|
|
986
|
+
indexA1 = this.addPoint(pointA);
|
|
987
|
+
indexB1 = this.addPoint(pointB);
|
|
898
988
|
if (i > 0) {
|
|
899
989
|
this.addIndexedQuadPointIndexes(indexA0, indexA1, indexB0, indexB1);
|
|
900
990
|
}
|
|
@@ -1188,13 +1278,13 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
1188
1278
|
let index = 0;
|
|
1189
1279
|
if (!this._reversed) {
|
|
1190
1280
|
for (let i = 0; i < numPointsToUse; i++) {
|
|
1191
|
-
index = this.
|
|
1281
|
+
index = this.addPoint(points[i]);
|
|
1192
1282
|
this._polyface.addPointIndex(index);
|
|
1193
1283
|
}
|
|
1194
1284
|
}
|
|
1195
1285
|
else {
|
|
1196
1286
|
for (let i = numPointsToUse; --i >= 0;) {
|
|
1197
|
-
index = this.
|
|
1287
|
+
index = this.addPoint(points[i]);
|
|
1198
1288
|
this._polyface.addPointIndex(index);
|
|
1199
1289
|
}
|
|
1200
1290
|
}
|
|
@@ -1270,7 +1360,7 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
1270
1360
|
this._polyface.addNormalIndex(index);
|
|
1271
1361
|
}
|
|
1272
1362
|
if (params) {
|
|
1273
|
-
index = this.
|
|
1363
|
+
index = this.addParamInGrowableXYArray(params, i);
|
|
1274
1364
|
this._polyface.addParamIndex(index);
|
|
1275
1365
|
}
|
|
1276
1366
|
if (colors) {
|
|
@@ -1288,7 +1378,7 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
1288
1378
|
this._polyface.addNormalIndex(index);
|
|
1289
1379
|
}
|
|
1290
1380
|
if (params) {
|
|
1291
|
-
index = this.
|
|
1381
|
+
index = this.addParamInGrowableXYArray(params, i);
|
|
1292
1382
|
this._polyface.addParamIndex(index);
|
|
1293
1383
|
}
|
|
1294
1384
|
if (colors) {
|
|
@@ -1351,10 +1441,10 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
1351
1441
|
if (acceptFaceFunction(seed) && seed.countEdgesAroundFace() > 2) {
|
|
1352
1442
|
let node = seed;
|
|
1353
1443
|
do {
|
|
1354
|
-
index = this.
|
|
1444
|
+
index = this.addPointXYZ(node.x, node.y, node.z);
|
|
1355
1445
|
this._polyface.addPointIndex(index, isEdgeVisibleFunction === undefined ? true : isEdgeVisibleFunction(node));
|
|
1356
1446
|
if (needParams) {
|
|
1357
|
-
index = this.
|
|
1447
|
+
index = this.addParamXY(node.x, node.y);
|
|
1358
1448
|
this._polyface.addParamIndex(index);
|
|
1359
1449
|
}
|
|
1360
1450
|
if (needNormals) {
|
|
@@ -1381,7 +1471,7 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
1381
1471
|
for (const seed of faces) {
|
|
1382
1472
|
let node = seed;
|
|
1383
1473
|
do {
|
|
1384
|
-
index = this.
|
|
1474
|
+
index = this.addPointXYZ(node.x, node.y, node.z);
|
|
1385
1475
|
this._polyface.addPointIndex(index);
|
|
1386
1476
|
node = node.faceSuccessor;
|
|
1387
1477
|
} while (node !== seed);
|
|
@@ -1626,6 +1716,104 @@ export class PolyfaceBuilder extends NullGeometryHandler {
|
|
|
1626
1716
|
this.addMiteredPipesFromPoints(linestring.packedPoints, sectionData, numFacetAround);
|
|
1627
1717
|
}
|
|
1628
1718
|
}
|
|
1719
|
+
/** Return the polyface index array indices corresponding to the given edge, or undefined if error. */
|
|
1720
|
+
getEdgeIndices(edge) {
|
|
1721
|
+
let indexA = -1;
|
|
1722
|
+
let indexB = -1;
|
|
1723
|
+
for (let i = this._polyface.facetIndex0(edge.facetIndex); i < this._polyface.facetIndex1(edge.facetIndex); ++i) {
|
|
1724
|
+
if (edge.vertexIndexA === this._polyface.data.pointIndex[i])
|
|
1725
|
+
indexA = i;
|
|
1726
|
+
else if (edge.vertexIndexB === this._polyface.data.pointIndex[i])
|
|
1727
|
+
indexB = i;
|
|
1728
|
+
}
|
|
1729
|
+
return (indexA < 0 || indexB < 0) ? undefined : { edgeIndexA: indexA, edgeIndexB: indexB };
|
|
1730
|
+
}
|
|
1731
|
+
/** Create a side face between base and swept facets along a base boundary edge.
|
|
1732
|
+
* * Assumes numBaseFacets base facets were added to this builder, immediately followed by the same number of swept facets with opposite orientation (first index not preserved).
|
|
1733
|
+
*/
|
|
1734
|
+
addSweptFace(baseBoundaryEdge, numBaseFacets) {
|
|
1735
|
+
const edge = this.getEdgeIndices(baseBoundaryEdge);
|
|
1736
|
+
if (undefined === edge)
|
|
1737
|
+
return false;
|
|
1738
|
+
const sweptFacetIndex = numBaseFacets + baseBoundaryEdge.facetIndex;
|
|
1739
|
+
if (!this._polyface.isValidFacetIndex(sweptFacetIndex))
|
|
1740
|
+
return false;
|
|
1741
|
+
const numBaseFacetEdges = this._polyface.numEdgeInFacet(baseBoundaryEdge.facetIndex);
|
|
1742
|
+
if (numBaseFacetEdges !== this._polyface.numEdgeInFacet(sweptFacetIndex))
|
|
1743
|
+
return false;
|
|
1744
|
+
// generate indices into the polyface index arrays
|
|
1745
|
+
const baseFacetIndexStart = this._polyface.facetIndex0(baseBoundaryEdge.facetIndex);
|
|
1746
|
+
const sweptFacetIndexStart = this._polyface.facetIndex0(sweptFacetIndex);
|
|
1747
|
+
const edgeIndexOffsetInFaceLoopA = edge.edgeIndexA - baseFacetIndexStart;
|
|
1748
|
+
const edgeIndexOffsetInFaceLoopB = edge.edgeIndexB - baseFacetIndexStart;
|
|
1749
|
+
const sweptEdgeIndexOffsetInFaceLoopA = (numBaseFacetEdges - 1) - edgeIndexOffsetInFaceLoopA;
|
|
1750
|
+
const sweptEdgeIndexOffsetInFaceLoopB = (numBaseFacetEdges - 1) - edgeIndexOffsetInFaceLoopB;
|
|
1751
|
+
const indices = [edge.edgeIndexB, edge.edgeIndexA, sweptFacetIndexStart + sweptEdgeIndexOffsetInFaceLoopA, sweptFacetIndexStart + sweptEdgeIndexOffsetInFaceLoopB];
|
|
1752
|
+
const vertices = [];
|
|
1753
|
+
let colors; // try to re-use colors; missing normals and params will be computed if needed
|
|
1754
|
+
if (undefined !== this.options.needColors && undefined !== this._polyface.data.color && undefined !== this._polyface.data.colorIndex)
|
|
1755
|
+
colors = [];
|
|
1756
|
+
for (let i = 0; i < 4; ++i) {
|
|
1757
|
+
const xyz = this._polyface.data.getPoint(this._polyface.data.pointIndex[indices[i]]);
|
|
1758
|
+
if (undefined === xyz)
|
|
1759
|
+
return false;
|
|
1760
|
+
vertices.push(xyz);
|
|
1761
|
+
if (undefined !== colors) {
|
|
1762
|
+
const color = this._polyface.data.getColor(this._polyface.data.colorIndex[indices[i]]);
|
|
1763
|
+
if (undefined === color)
|
|
1764
|
+
return false;
|
|
1765
|
+
colors.push(color);
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
this.addQuadFacet(vertices, undefined, undefined, colors);
|
|
1769
|
+
return true;
|
|
1770
|
+
}
|
|
1771
|
+
/**
|
|
1772
|
+
* Add facets from the source polyface, from its translation along the vector, and from its swept boundary edges, to form a polyface that encloses a volume.
|
|
1773
|
+
* @param source the surface mesh to sweep
|
|
1774
|
+
* @param sweepVector the direction and length to sweep the surface mesh
|
|
1775
|
+
* @param triangulateSides whether to triangulate side facets, or leave as quads
|
|
1776
|
+
* @returns whether the added facets comprise a simple sweep. If false, the resulting mesh may have self-intersections, be non-manifold, have inconsistently oriented facets, etc.
|
|
1777
|
+
*/
|
|
1778
|
+
addSweptIndexedPolyface(source, sweepVector, triangulateSides = false) {
|
|
1779
|
+
let isSimpleSweep = true;
|
|
1780
|
+
const totalProjectedArea = PolyfaceQuery.sumFacetAreas(source, sweepVector);
|
|
1781
|
+
if (Geometry.isAlmostEqualNumber(0.0, totalProjectedArea))
|
|
1782
|
+
isSimpleSweep = false;
|
|
1783
|
+
const partitionedIndices = PolyfaceQuery.partitionFacetIndicesByVisibilityVector(source, sweepVector, Angle.createDegrees(1.0e-3));
|
|
1784
|
+
const numForwardFacets = partitionedIndices[0].length;
|
|
1785
|
+
const numBackwardFacets = partitionedIndices[1].length;
|
|
1786
|
+
const numSideFacets = partitionedIndices[2].length;
|
|
1787
|
+
if (numSideFacets > 0)
|
|
1788
|
+
isSimpleSweep = false;
|
|
1789
|
+
if (numForwardFacets > 0 && numBackwardFacets > 0)
|
|
1790
|
+
isSimpleSweep = false;
|
|
1791
|
+
// add base and swept facets with opposite orientations
|
|
1792
|
+
const reverseBase = numForwardFacets > 0;
|
|
1793
|
+
const firstBaseFacet = this._polyface.facetCount;
|
|
1794
|
+
this.addIndexedPolyface(source, reverseBase);
|
|
1795
|
+
const firstSweptFacet = this._polyface.facetCount;
|
|
1796
|
+
this.addIndexedPolyface(source, !reverseBase, Transform.createTranslation(sweepVector));
|
|
1797
|
+
// collect base edges added to the builder, and extract boundary
|
|
1798
|
+
const numBaseFacets = firstSweptFacet - firstBaseFacet;
|
|
1799
|
+
const baseFacetIndices = Array.from({ length: numBaseFacets }, (_, i) => firstBaseFacet + i);
|
|
1800
|
+
const baseFacetVisitor = IndexedPolyfaceSubsetVisitor.createSubsetVisitor(this._polyface, baseFacetIndices, 1);
|
|
1801
|
+
const baseEdges = PolyfaceQuery.createIndexedEdges(baseFacetVisitor);
|
|
1802
|
+
const baseBoundaryEdges = [];
|
|
1803
|
+
baseEdges.sortAndCollectClusters(undefined, baseBoundaryEdges, undefined, undefined);
|
|
1804
|
+
// add a side face per boundary edge
|
|
1805
|
+
const oldShouldTriangulate = this._options.shouldTriangulate;
|
|
1806
|
+
this._options.shouldTriangulate = triangulateSides;
|
|
1807
|
+
for (const edgeOrCluster of baseBoundaryEdges) {
|
|
1808
|
+
if (edgeOrCluster instanceof SortableEdge)
|
|
1809
|
+
this.addSweptFace(edgeOrCluster, numBaseFacets);
|
|
1810
|
+
else if (Array.isArray(edgeOrCluster))
|
|
1811
|
+
for (const edge of edgeOrCluster)
|
|
1812
|
+
this.addSweptFace(edge, numBaseFacets);
|
|
1813
|
+
}
|
|
1814
|
+
this._options.shouldTriangulate = oldShouldTriangulate;
|
|
1815
|
+
return isSimpleSweep;
|
|
1816
|
+
}
|
|
1629
1817
|
}
|
|
1630
1818
|
PolyfaceBuilder._workPointFindOrAddA = Point3d.create();
|
|
1631
1819
|
PolyfaceBuilder._workVectorFindOrAdd = Vector3d.create();
|