@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"}
|
|
@@ -38,6 +38,10 @@ const Triangulation_1 = require("../topology/Triangulation");
|
|
|
38
38
|
const BoxTopology_1 = require("./BoxTopology");
|
|
39
39
|
const GreedyTriangulationBetweenLineStrings_1 = require("./GreedyTriangulationBetweenLineStrings");
|
|
40
40
|
const Polyface_1 = require("./Polyface");
|
|
41
|
+
const PolyfaceQuery_1 = require("./PolyfaceQuery");
|
|
42
|
+
const Angle_1 = require("../geometry3d/Angle");
|
|
43
|
+
const IndexedPolyfaceVisitor_1 = require("./IndexedPolyfaceVisitor");
|
|
44
|
+
const IndexedEdgeMatcher_1 = require("./IndexedEdgeMatcher");
|
|
41
45
|
/* eslint-disable @typescript-eslint/naming-convention, @typescript-eslint/prefer-for-of */
|
|
42
46
|
/**
|
|
43
47
|
* A FacetSector
|
|
@@ -163,14 +167,12 @@ FacetSector._edgeVector = Point3dVector3d_1.Vector3d.create();
|
|
|
163
167
|
* * Low-level detail construction -- direct use of indices
|
|
164
168
|
* * Create a builder with `builder = PolyfaceBuilder.create()`
|
|
165
169
|
* * Add GeometryQuery objects
|
|
166
|
-
* * `builder.
|
|
170
|
+
* * `builder.addPoint(point)`
|
|
167
171
|
* * `builder.findOrAddPointInLineString (linestring, index)`
|
|
168
|
-
* * `builder.
|
|
169
|
-
* * `builder.
|
|
170
|
-
* * `builder.
|
|
171
|
-
|
|
172
|
-
* * `builder.addOneBasedPointIndex (index)`
|
|
173
|
-
* @public
|
|
172
|
+
* * `builder.addPointXYZ(x,y,z)`
|
|
173
|
+
* * `builder.addTriangleFacet (points)`
|
|
174
|
+
* * `builder.addQuadFacet (points)`
|
|
175
|
+
* @public
|
|
174
176
|
*/
|
|
175
177
|
class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
176
178
|
constructor(options) {
|
|
@@ -230,7 +232,7 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
230
232
|
if (n > 2) {
|
|
231
233
|
if (toggle)
|
|
232
234
|
this.toggleReversedFacetFlag();
|
|
233
|
-
const index0 = this.
|
|
235
|
+
const index0 = this.addPoint(conePoint);
|
|
234
236
|
let index1 = this.findOrAddPointInLineString(ls, 0);
|
|
235
237
|
let index2 = 0;
|
|
236
238
|
for (let i = 1; i < n; i++) {
|
|
@@ -268,8 +270,8 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
268
270
|
let paramIndex1 = -1;
|
|
269
271
|
let paramIndex2 = -1;
|
|
270
272
|
if (packedUV) {
|
|
271
|
-
paramIndex0 = this.
|
|
272
|
-
paramIndex1 = this.
|
|
273
|
+
paramIndex0 = this.addParamInGrowableXYArray(packedUV, 0);
|
|
274
|
+
paramIndex1 = this.addParamInGrowableXYArray(packedUV, 1);
|
|
273
275
|
}
|
|
274
276
|
const pointIndex0 = this.findOrAddPointInLineString(ls, 0);
|
|
275
277
|
let pointIndex1 = this.findOrAddPointInLineString(ls, 1);
|
|
@@ -283,7 +285,7 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
283
285
|
if (normalIndex !== undefined)
|
|
284
286
|
this.addIndexedTriangleNormalIndexes(normalIndex, normalIndex, normalIndex);
|
|
285
287
|
if (packedUV) {
|
|
286
|
-
paramIndex2 = this.
|
|
288
|
+
paramIndex2 = this.addParamInGrowableXYArray(packedUV, i);
|
|
287
289
|
this.addIndexedTriangleParamIndexes(paramIndex0, paramIndex1, paramIndex2);
|
|
288
290
|
}
|
|
289
291
|
this._polyface.terminateFacet();
|
|
@@ -293,17 +295,31 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
293
295
|
}
|
|
294
296
|
}
|
|
295
297
|
/**
|
|
296
|
-
* Announce point coordinates.
|
|
298
|
+
* Announce point coordinates.
|
|
297
299
|
*/
|
|
298
|
-
|
|
300
|
+
addPoint(xyz) {
|
|
299
301
|
return this._polyface.addPoint(xyz);
|
|
300
302
|
}
|
|
301
303
|
/**
|
|
302
|
-
* Announce point coordinates.
|
|
304
|
+
* Announce point coordinates.
|
|
305
|
+
* @deprecated Use addPoint instead.
|
|
303
306
|
*/
|
|
304
|
-
|
|
307
|
+
findOrAddPoint(xyz) {
|
|
308
|
+
return this.addPoint(xyz);
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Announce uv parameter coordinates.
|
|
312
|
+
*/
|
|
313
|
+
addParamXY(x, y) {
|
|
305
314
|
return this._polyface.addParamUV(x, y);
|
|
306
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Announce uv parameter coordinates.
|
|
318
|
+
* @deprecated Use addParamXY instead.
|
|
319
|
+
*/
|
|
320
|
+
findOrAddParamXY(x, y) {
|
|
321
|
+
return this.addParamXY(x, y);
|
|
322
|
+
}
|
|
307
323
|
/**
|
|
308
324
|
* 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.
|
|
309
325
|
* @returns Returns the point index in the Polyface.
|
|
@@ -347,19 +363,26 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
347
363
|
return undefined;
|
|
348
364
|
}
|
|
349
365
|
/**
|
|
350
|
-
* Announce
|
|
351
|
-
* @returns Returns the
|
|
366
|
+
* Announce uv parameter coordinates.
|
|
367
|
+
* @returns Returns the uv parameter index in the Polyface.
|
|
352
368
|
* @param index Index of the param in the linestring.
|
|
353
369
|
*/
|
|
354
|
-
|
|
370
|
+
addParamInGrowableXYArray(data, index) {
|
|
355
371
|
if (!data)
|
|
356
372
|
return undefined;
|
|
357
|
-
const q = data.
|
|
373
|
+
const q = data.getPoint2dAtCheckedPointIndex(index, PolyfaceBuilder._workUVFindOrAdd);
|
|
358
374
|
if (q) {
|
|
359
375
|
return this._polyface.addParam(q);
|
|
360
376
|
}
|
|
361
377
|
return undefined;
|
|
362
378
|
}
|
|
379
|
+
/**
|
|
380
|
+
* Announce uv parameter coordinates.
|
|
381
|
+
* @deprecated Use addParamInGrowableXYArray instead.
|
|
382
|
+
*/
|
|
383
|
+
findOrAddParamInGrowableXYArray(data, index) {
|
|
384
|
+
return this.addParamInGrowableXYArray(data, index);
|
|
385
|
+
}
|
|
363
386
|
/**
|
|
364
387
|
* 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.
|
|
365
388
|
* @returns Returns the point index in the Polyface.
|
|
@@ -388,11 +411,18 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
388
411
|
return undefined;
|
|
389
412
|
}
|
|
390
413
|
/**
|
|
391
|
-
* Announce point coordinates.
|
|
414
|
+
* Announce point coordinates.
|
|
392
415
|
*/
|
|
393
|
-
|
|
416
|
+
addPointXYZ(x, y, z) {
|
|
394
417
|
return this._polyface.addPointXYZ(x, y, z);
|
|
395
418
|
}
|
|
419
|
+
/**
|
|
420
|
+
* Announce point coordinates.
|
|
421
|
+
* @deprecated Use addPointXYZ instead.
|
|
422
|
+
*/
|
|
423
|
+
findOrAddPointXYZ(x, y, z) {
|
|
424
|
+
return this.addPointXYZ(x, y, z);
|
|
425
|
+
}
|
|
396
426
|
/** Returns a transform who can be applied to points on a triangular facet in order to obtain UV parameters. */
|
|
397
427
|
getUVTransformForTriangleFacet(pointA, pointB, pointC) {
|
|
398
428
|
const vectorAB = pointA.vectorTo(pointB);
|
|
@@ -412,17 +442,21 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
412
442
|
// ###: Consider case where normals will be reversed and point through the other end of the facet
|
|
413
443
|
/**
|
|
414
444
|
* Add a quad to the polyface given its points in order around the edges.
|
|
415
|
-
*
|
|
416
|
-
*
|
|
445
|
+
* @param points array of at least three vertices
|
|
446
|
+
* @param params optional array of at least four uv parameters (if undefined, params are calculated without reference data)
|
|
447
|
+
* @param normals optional array of at least four vectors (if undefined, the quad is assumed to be planar and its normal is calculated)
|
|
448
|
+
* @param colors optional array of at least four colors
|
|
417
449
|
*/
|
|
418
|
-
addQuadFacet(points, params, normals) {
|
|
450
|
+
addQuadFacet(points, params, normals, colors) {
|
|
419
451
|
if (points instanceof GrowableXYZArray_1.GrowableXYZArray)
|
|
420
452
|
points = points.getPoint3dArray();
|
|
421
453
|
// If params and/or normals are needed, calculate them first
|
|
422
454
|
const needParams = this.options.needParams;
|
|
423
455
|
const needNormals = this.options.needNormals;
|
|
456
|
+
const needColors = this.options.needColors;
|
|
424
457
|
let param0, param1, param2, param3;
|
|
425
458
|
let normal0, normal1, normal2, normal3;
|
|
459
|
+
let color0, color1, color2, color3;
|
|
426
460
|
if (needParams) {
|
|
427
461
|
if (params !== undefined && params.length > 3) {
|
|
428
462
|
param0 = params[0];
|
|
@@ -457,18 +491,26 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
457
491
|
normal3 = this.getNormalForTriangularFacet(points[0], points[1], points[2]);
|
|
458
492
|
}
|
|
459
493
|
}
|
|
494
|
+
if (needColors) {
|
|
495
|
+
if (colors !== undefined && colors.length > 3) {
|
|
496
|
+
color0 = colors[0];
|
|
497
|
+
color1 = colors[1];
|
|
498
|
+
color2 = colors[2];
|
|
499
|
+
color3 = colors[3];
|
|
500
|
+
}
|
|
501
|
+
}
|
|
460
502
|
if (this._options.shouldTriangulate) {
|
|
461
503
|
// Add as two triangles, with a diagonal along the shortest distance
|
|
462
504
|
const vectorAC = points[0].vectorTo(points[2]);
|
|
463
505
|
const vectorBD = points[1].vectorTo(points[3]);
|
|
464
506
|
// Note: We pass along any values for normals or params that we calculated
|
|
465
507
|
if (vectorAC.magnitude() >= vectorBD.magnitude()) {
|
|
466
|
-
this.addTriangleFacet([points[0], points[1], points[2]], needParams ? [param0, param1, param2] : undefined, needNormals ? [normal0, normal1, normal2] : undefined);
|
|
467
|
-
this.addTriangleFacet([points[0], points[2], points[3]], needParams ? [param0, param2, param3] : undefined, needNormals ? [normal0, normal2, normal3] : undefined);
|
|
508
|
+
this.addTriangleFacet([points[0], points[1], points[2]], needParams ? [param0, param1, param2] : undefined, needNormals ? [normal0, normal1, normal2] : undefined, needColors ? [color0, color1, color2] : undefined);
|
|
509
|
+
this.addTriangleFacet([points[0], points[2], points[3]], needParams ? [param0, param2, param3] : undefined, needNormals ? [normal0, normal2, normal3] : undefined, needColors ? [color0, color2, color3] : undefined);
|
|
468
510
|
}
|
|
469
511
|
else {
|
|
470
|
-
this.addTriangleFacet([points[0], points[1], points[3]], needParams ? [param0, param1, param3] : undefined, needNormals ? [normal0, normal1, normal3] : undefined);
|
|
471
|
-
this.addTriangleFacet([points[1], points[2], points[3]], needParams ? [param1, param2, param3] : undefined, needNormals ? [normal1, normal2, normal3] : undefined);
|
|
512
|
+
this.addTriangleFacet([points[0], points[1], points[3]], needParams ? [param0, param1, param3] : undefined, needNormals ? [normal0, normal1, normal3] : undefined, needColors ? [color0, color1, color3] : undefined);
|
|
513
|
+
this.addTriangleFacet([points[1], points[2], points[3]], needParams ? [param1, param2, param3] : undefined, needNormals ? [normal1, normal2, normal3] : undefined, needColors ? [color1, color2, color3] : undefined);
|
|
472
514
|
}
|
|
473
515
|
return;
|
|
474
516
|
}
|
|
@@ -489,11 +531,19 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
489
531
|
idx3 = this._polyface.addNormal(normal3);
|
|
490
532
|
this.addIndexedQuadNormalIndexes(idx0, idx1, idx3, idx2);
|
|
491
533
|
}
|
|
534
|
+
// Add colors if needed
|
|
535
|
+
if (needColors) {
|
|
536
|
+
idx0 = this._polyface.addColor(color0);
|
|
537
|
+
idx1 = this._polyface.addColor(color1);
|
|
538
|
+
idx2 = this._polyface.addColor(color2);
|
|
539
|
+
idx3 = this._polyface.addColor(color3);
|
|
540
|
+
this.addIndexedQuadColorIndexes(idx0, idx1, idx3, idx2);
|
|
541
|
+
}
|
|
492
542
|
// Add point and point indexes last (terminates the facet)
|
|
493
|
-
idx0 = this.
|
|
494
|
-
idx1 = this.
|
|
495
|
-
idx2 = this.
|
|
496
|
-
idx3 = this.
|
|
543
|
+
idx0 = this.addPoint(points[0]);
|
|
544
|
+
idx1 = this.addPoint(points[1]);
|
|
545
|
+
idx2 = this.addPoint(points[2]);
|
|
546
|
+
idx3 = this.addPoint(points[3]);
|
|
497
547
|
this.addIndexedQuadPointIndexes(idx0, idx1, idx3, idx2);
|
|
498
548
|
}
|
|
499
549
|
/** Announce a single quad facet's point indexes.
|
|
@@ -548,12 +598,30 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
548
598
|
this._polyface.addNormalIndex(indexB0);
|
|
549
599
|
}
|
|
550
600
|
}
|
|
601
|
+
/** For a single quad facet, add the indexes of the corresponding colors. */
|
|
602
|
+
addIndexedQuadColorIndexes(indexA0, indexA1, indexB0, indexB1) {
|
|
603
|
+
if (this._reversed) {
|
|
604
|
+
this._polyface.addColorIndex(indexA0);
|
|
605
|
+
this._polyface.addColorIndex(indexB0);
|
|
606
|
+
this._polyface.addColorIndex(indexB1);
|
|
607
|
+
this._polyface.addColorIndex(indexA1);
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
this._polyface.addColorIndex(indexA0);
|
|
611
|
+
this._polyface.addColorIndex(indexA1);
|
|
612
|
+
this._polyface.addColorIndex(indexB1);
|
|
613
|
+
this._polyface.addColorIndex(indexB0);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
551
616
|
// ### TODO: Consider case where normals will be reversed and point through the other end of the facet
|
|
552
617
|
/**
|
|
553
618
|
* Add a triangle to the polyface given its points in order around the edges.
|
|
554
|
-
*
|
|
619
|
+
* @param points array of at least three vertices
|
|
620
|
+
* @param params optional array of at least three uv parameters (if undefined, params are calculated without reference data)
|
|
621
|
+
* @param normals optional array of at least three vectors (if undefined, the normal is calculated)
|
|
622
|
+
* @param colors optional array of at least three colors
|
|
555
623
|
*/
|
|
556
|
-
addTriangleFacet(points, params, normals) {
|
|
624
|
+
addTriangleFacet(points, params, normals, colors) {
|
|
557
625
|
if (points.length < 3)
|
|
558
626
|
return;
|
|
559
627
|
let idx0;
|
|
@@ -600,10 +668,19 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
600
668
|
}
|
|
601
669
|
this.addIndexedTriangleNormalIndexes(idx0, idx1, idx2);
|
|
602
670
|
}
|
|
671
|
+
// Add colors if needed and provided
|
|
672
|
+
if (this._options.needColors) {
|
|
673
|
+
if (colors !== undefined && colors.length > 2) {
|
|
674
|
+
idx0 = this._polyface.addColor(colors[0]);
|
|
675
|
+
idx1 = this._polyface.addColor(colors[1]);
|
|
676
|
+
idx2 = this._polyface.addColor(colors[2]);
|
|
677
|
+
this.addIndexedTriangleColorIndexes(idx0, idx1, idx2);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
603
680
|
// Add point and point indexes last (terminates the facet)
|
|
604
|
-
idx0 = this.
|
|
605
|
-
idx1 = this.
|
|
606
|
-
idx2 = this.
|
|
681
|
+
idx0 = this.addPoint(point0);
|
|
682
|
+
idx1 = this.addPoint(point1);
|
|
683
|
+
idx2 = this.addPoint(point2);
|
|
607
684
|
this.addIndexedTrianglePointIndexes(idx0, idx1, idx2);
|
|
608
685
|
}
|
|
609
686
|
/** Announce a single triangle facet's point indexes.
|
|
@@ -650,9 +727,22 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
650
727
|
this._polyface.addNormalIndex(indexB);
|
|
651
728
|
}
|
|
652
729
|
}
|
|
730
|
+
/** For a single triangle facet, add the indexes of the corresponding colors. */
|
|
731
|
+
addIndexedTriangleColorIndexes(indexA, indexB, indexC) {
|
|
732
|
+
if (!this._reversed) {
|
|
733
|
+
this._polyface.addColorIndex(indexA);
|
|
734
|
+
this._polyface.addColorIndex(indexB);
|
|
735
|
+
this._polyface.addColorIndex(indexC);
|
|
736
|
+
}
|
|
737
|
+
else {
|
|
738
|
+
this._polyface.addColorIndex(indexA);
|
|
739
|
+
this._polyface.addColorIndex(indexC);
|
|
740
|
+
this._polyface.addColorIndex(indexB);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
653
743
|
/** Find or add xyzIndex and normalIndex for coordinates in the sector. */
|
|
654
744
|
setSectorIndices(sector) {
|
|
655
|
-
sector.xyzIndex = this.
|
|
745
|
+
sector.xyzIndex = this.addPoint(sector.xyz);
|
|
656
746
|
if (sector.normal)
|
|
657
747
|
sector.normalIndex = this._polyface.addNormal(sector.normal);
|
|
658
748
|
if (sector.uv)
|
|
@@ -896,8 +986,8 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
896
986
|
for (let i = 0; i < n; i++) {
|
|
897
987
|
pointA = contour.pointAt(i, pointA);
|
|
898
988
|
pointB = pointA.plus(vector, pointB);
|
|
899
|
-
indexA1 = this.
|
|
900
|
-
indexB1 = this.
|
|
989
|
+
indexA1 = this.addPoint(pointA);
|
|
990
|
+
indexB1 = this.addPoint(pointB);
|
|
901
991
|
if (i > 0) {
|
|
902
992
|
this.addIndexedQuadPointIndexes(indexA0, indexA1, indexB0, indexB1);
|
|
903
993
|
}
|
|
@@ -1191,13 +1281,13 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
1191
1281
|
let index = 0;
|
|
1192
1282
|
if (!this._reversed) {
|
|
1193
1283
|
for (let i = 0; i < numPointsToUse; i++) {
|
|
1194
|
-
index = this.
|
|
1284
|
+
index = this.addPoint(points[i]);
|
|
1195
1285
|
this._polyface.addPointIndex(index);
|
|
1196
1286
|
}
|
|
1197
1287
|
}
|
|
1198
1288
|
else {
|
|
1199
1289
|
for (let i = numPointsToUse; --i >= 0;) {
|
|
1200
|
-
index = this.
|
|
1290
|
+
index = this.addPoint(points[i]);
|
|
1201
1291
|
this._polyface.addPointIndex(index);
|
|
1202
1292
|
}
|
|
1203
1293
|
}
|
|
@@ -1273,7 +1363,7 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
1273
1363
|
this._polyface.addNormalIndex(index);
|
|
1274
1364
|
}
|
|
1275
1365
|
if (params) {
|
|
1276
|
-
index = this.
|
|
1366
|
+
index = this.addParamInGrowableXYArray(params, i);
|
|
1277
1367
|
this._polyface.addParamIndex(index);
|
|
1278
1368
|
}
|
|
1279
1369
|
if (colors) {
|
|
@@ -1291,7 +1381,7 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
1291
1381
|
this._polyface.addNormalIndex(index);
|
|
1292
1382
|
}
|
|
1293
1383
|
if (params) {
|
|
1294
|
-
index = this.
|
|
1384
|
+
index = this.addParamInGrowableXYArray(params, i);
|
|
1295
1385
|
this._polyface.addParamIndex(index);
|
|
1296
1386
|
}
|
|
1297
1387
|
if (colors) {
|
|
@@ -1354,10 +1444,10 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
1354
1444
|
if (acceptFaceFunction(seed) && seed.countEdgesAroundFace() > 2) {
|
|
1355
1445
|
let node = seed;
|
|
1356
1446
|
do {
|
|
1357
|
-
index = this.
|
|
1447
|
+
index = this.addPointXYZ(node.x, node.y, node.z);
|
|
1358
1448
|
this._polyface.addPointIndex(index, isEdgeVisibleFunction === undefined ? true : isEdgeVisibleFunction(node));
|
|
1359
1449
|
if (needParams) {
|
|
1360
|
-
index = this.
|
|
1450
|
+
index = this.addParamXY(node.x, node.y);
|
|
1361
1451
|
this._polyface.addParamIndex(index);
|
|
1362
1452
|
}
|
|
1363
1453
|
if (needNormals) {
|
|
@@ -1384,7 +1474,7 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
1384
1474
|
for (const seed of faces) {
|
|
1385
1475
|
let node = seed;
|
|
1386
1476
|
do {
|
|
1387
|
-
index = this.
|
|
1477
|
+
index = this.addPointXYZ(node.x, node.y, node.z);
|
|
1388
1478
|
this._polyface.addPointIndex(index);
|
|
1389
1479
|
node = node.faceSuccessor;
|
|
1390
1480
|
} while (node !== seed);
|
|
@@ -1629,6 +1719,104 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
|
|
|
1629
1719
|
this.addMiteredPipesFromPoints(linestring.packedPoints, sectionData, numFacetAround);
|
|
1630
1720
|
}
|
|
1631
1721
|
}
|
|
1722
|
+
/** Return the polyface index array indices corresponding to the given edge, or undefined if error. */
|
|
1723
|
+
getEdgeIndices(edge) {
|
|
1724
|
+
let indexA = -1;
|
|
1725
|
+
let indexB = -1;
|
|
1726
|
+
for (let i = this._polyface.facetIndex0(edge.facetIndex); i < this._polyface.facetIndex1(edge.facetIndex); ++i) {
|
|
1727
|
+
if (edge.vertexIndexA === this._polyface.data.pointIndex[i])
|
|
1728
|
+
indexA = i;
|
|
1729
|
+
else if (edge.vertexIndexB === this._polyface.data.pointIndex[i])
|
|
1730
|
+
indexB = i;
|
|
1731
|
+
}
|
|
1732
|
+
return (indexA < 0 || indexB < 0) ? undefined : { edgeIndexA: indexA, edgeIndexB: indexB };
|
|
1733
|
+
}
|
|
1734
|
+
/** Create a side face between base and swept facets along a base boundary edge.
|
|
1735
|
+
* * 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).
|
|
1736
|
+
*/
|
|
1737
|
+
addSweptFace(baseBoundaryEdge, numBaseFacets) {
|
|
1738
|
+
const edge = this.getEdgeIndices(baseBoundaryEdge);
|
|
1739
|
+
if (undefined === edge)
|
|
1740
|
+
return false;
|
|
1741
|
+
const sweptFacetIndex = numBaseFacets + baseBoundaryEdge.facetIndex;
|
|
1742
|
+
if (!this._polyface.isValidFacetIndex(sweptFacetIndex))
|
|
1743
|
+
return false;
|
|
1744
|
+
const numBaseFacetEdges = this._polyface.numEdgeInFacet(baseBoundaryEdge.facetIndex);
|
|
1745
|
+
if (numBaseFacetEdges !== this._polyface.numEdgeInFacet(sweptFacetIndex))
|
|
1746
|
+
return false;
|
|
1747
|
+
// generate indices into the polyface index arrays
|
|
1748
|
+
const baseFacetIndexStart = this._polyface.facetIndex0(baseBoundaryEdge.facetIndex);
|
|
1749
|
+
const sweptFacetIndexStart = this._polyface.facetIndex0(sweptFacetIndex);
|
|
1750
|
+
const edgeIndexOffsetInFaceLoopA = edge.edgeIndexA - baseFacetIndexStart;
|
|
1751
|
+
const edgeIndexOffsetInFaceLoopB = edge.edgeIndexB - baseFacetIndexStart;
|
|
1752
|
+
const sweptEdgeIndexOffsetInFaceLoopA = (numBaseFacetEdges - 1) - edgeIndexOffsetInFaceLoopA;
|
|
1753
|
+
const sweptEdgeIndexOffsetInFaceLoopB = (numBaseFacetEdges - 1) - edgeIndexOffsetInFaceLoopB;
|
|
1754
|
+
const indices = [edge.edgeIndexB, edge.edgeIndexA, sweptFacetIndexStart + sweptEdgeIndexOffsetInFaceLoopA, sweptFacetIndexStart + sweptEdgeIndexOffsetInFaceLoopB];
|
|
1755
|
+
const vertices = [];
|
|
1756
|
+
let colors; // try to re-use colors; missing normals and params will be computed if needed
|
|
1757
|
+
if (undefined !== this.options.needColors && undefined !== this._polyface.data.color && undefined !== this._polyface.data.colorIndex)
|
|
1758
|
+
colors = [];
|
|
1759
|
+
for (let i = 0; i < 4; ++i) {
|
|
1760
|
+
const xyz = this._polyface.data.getPoint(this._polyface.data.pointIndex[indices[i]]);
|
|
1761
|
+
if (undefined === xyz)
|
|
1762
|
+
return false;
|
|
1763
|
+
vertices.push(xyz);
|
|
1764
|
+
if (undefined !== colors) {
|
|
1765
|
+
const color = this._polyface.data.getColor(this._polyface.data.colorIndex[indices[i]]);
|
|
1766
|
+
if (undefined === color)
|
|
1767
|
+
return false;
|
|
1768
|
+
colors.push(color);
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
this.addQuadFacet(vertices, undefined, undefined, colors);
|
|
1772
|
+
return true;
|
|
1773
|
+
}
|
|
1774
|
+
/**
|
|
1775
|
+
* 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.
|
|
1776
|
+
* @param source the surface mesh to sweep
|
|
1777
|
+
* @param sweepVector the direction and length to sweep the surface mesh
|
|
1778
|
+
* @param triangulateSides whether to triangulate side facets, or leave as quads
|
|
1779
|
+
* @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.
|
|
1780
|
+
*/
|
|
1781
|
+
addSweptIndexedPolyface(source, sweepVector, triangulateSides = false) {
|
|
1782
|
+
let isSimpleSweep = true;
|
|
1783
|
+
const totalProjectedArea = PolyfaceQuery_1.PolyfaceQuery.sumFacetAreas(source, sweepVector);
|
|
1784
|
+
if (Geometry_1.Geometry.isAlmostEqualNumber(0.0, totalProjectedArea))
|
|
1785
|
+
isSimpleSweep = false;
|
|
1786
|
+
const partitionedIndices = PolyfaceQuery_1.PolyfaceQuery.partitionFacetIndicesByVisibilityVector(source, sweepVector, Angle_1.Angle.createDegrees(1.0e-3));
|
|
1787
|
+
const numForwardFacets = partitionedIndices[0].length;
|
|
1788
|
+
const numBackwardFacets = partitionedIndices[1].length;
|
|
1789
|
+
const numSideFacets = partitionedIndices[2].length;
|
|
1790
|
+
if (numSideFacets > 0)
|
|
1791
|
+
isSimpleSweep = false;
|
|
1792
|
+
if (numForwardFacets > 0 && numBackwardFacets > 0)
|
|
1793
|
+
isSimpleSweep = false;
|
|
1794
|
+
// add base and swept facets with opposite orientations
|
|
1795
|
+
const reverseBase = numForwardFacets > 0;
|
|
1796
|
+
const firstBaseFacet = this._polyface.facetCount;
|
|
1797
|
+
this.addIndexedPolyface(source, reverseBase);
|
|
1798
|
+
const firstSweptFacet = this._polyface.facetCount;
|
|
1799
|
+
this.addIndexedPolyface(source, !reverseBase, Transform_1.Transform.createTranslation(sweepVector));
|
|
1800
|
+
// collect base edges added to the builder, and extract boundary
|
|
1801
|
+
const numBaseFacets = firstSweptFacet - firstBaseFacet;
|
|
1802
|
+
const baseFacetIndices = Array.from({ length: numBaseFacets }, (_, i) => firstBaseFacet + i);
|
|
1803
|
+
const baseFacetVisitor = IndexedPolyfaceVisitor_1.IndexedPolyfaceSubsetVisitor.createSubsetVisitor(this._polyface, baseFacetIndices, 1);
|
|
1804
|
+
const baseEdges = PolyfaceQuery_1.PolyfaceQuery.createIndexedEdges(baseFacetVisitor);
|
|
1805
|
+
const baseBoundaryEdges = [];
|
|
1806
|
+
baseEdges.sortAndCollectClusters(undefined, baseBoundaryEdges, undefined, undefined);
|
|
1807
|
+
// add a side face per boundary edge
|
|
1808
|
+
const oldShouldTriangulate = this._options.shouldTriangulate;
|
|
1809
|
+
this._options.shouldTriangulate = triangulateSides;
|
|
1810
|
+
for (const edgeOrCluster of baseBoundaryEdges) {
|
|
1811
|
+
if (edgeOrCluster instanceof IndexedEdgeMatcher_1.SortableEdge)
|
|
1812
|
+
this.addSweptFace(edgeOrCluster, numBaseFacets);
|
|
1813
|
+
else if (Array.isArray(edgeOrCluster))
|
|
1814
|
+
for (const edge of edgeOrCluster)
|
|
1815
|
+
this.addSweptFace(edge, numBaseFacets);
|
|
1816
|
+
}
|
|
1817
|
+
this._options.shouldTriangulate = oldShouldTriangulate;
|
|
1818
|
+
return isSimpleSweep;
|
|
1819
|
+
}
|
|
1632
1820
|
}
|
|
1633
1821
|
exports.PolyfaceBuilder = PolyfaceBuilder;
|
|
1634
1822
|
PolyfaceBuilder._workPointFindOrAddA = Point3dVector3d_1.Point3d.create();
|