@itwin/core-geometry 5.0.0-dev.22 → 5.0.0-dev.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/bspline/BezierCurveBase.d.ts.map +1 -1
- package/lib/cjs/bspline/BezierCurveBase.js.map +1 -1
- package/lib/cjs/curve/Arc3d.d.ts +10 -1
- package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
- package/lib/cjs/curve/Arc3d.js +13 -1
- package/lib/cjs/curve/Arc3d.js.map +1 -1
- package/lib/cjs/curve/CurveFactory.d.ts +10 -4
- package/lib/cjs/curve/CurveFactory.d.ts.map +1 -1
- package/lib/cjs/curve/CurveFactory.js +50 -59
- package/lib/cjs/curve/CurveFactory.js.map +1 -1
- package/lib/cjs/curve/StrokeOptions.d.ts +3 -3
- package/lib/cjs/curve/StrokeOptions.d.ts.map +1 -1
- package/lib/cjs/curve/StrokeOptions.js +1 -1
- package/lib/cjs/curve/StrokeOptions.js.map +1 -1
- package/lib/cjs/geometry3d/PolylineOps.d.ts +2 -1
- package/lib/cjs/geometry3d/PolylineOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PolylineOps.js +2 -1
- package/lib/cjs/geometry3d/PolylineOps.js.map +1 -1
- package/lib/cjs/polyface/IndexedEdgeMatcher.d.ts +27 -20
- package/lib/cjs/polyface/IndexedEdgeMatcher.d.ts.map +1 -1
- package/lib/cjs/polyface/IndexedEdgeMatcher.js +56 -30
- package/lib/cjs/polyface/IndexedEdgeMatcher.js.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts +2 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js +2 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts +4 -4
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.js +18 -50
- package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/cjs/solid/SweepContour.d.ts +24 -15
- package/lib/cjs/solid/SweepContour.d.ts.map +1 -1
- package/lib/cjs/solid/SweepContour.js +24 -15
- package/lib/cjs/solid/SweepContour.js.map +1 -1
- package/lib/esm/bspline/BezierCurveBase.d.ts.map +1 -1
- package/lib/esm/bspline/BezierCurveBase.js.map +1 -1
- package/lib/esm/curve/Arc3d.d.ts +10 -1
- package/lib/esm/curve/Arc3d.d.ts.map +1 -1
- package/lib/esm/curve/Arc3d.js +13 -1
- package/lib/esm/curve/Arc3d.js.map +1 -1
- package/lib/esm/curve/CurveFactory.d.ts +10 -4
- package/lib/esm/curve/CurveFactory.d.ts.map +1 -1
- package/lib/esm/curve/CurveFactory.js +50 -59
- package/lib/esm/curve/CurveFactory.js.map +1 -1
- package/lib/esm/curve/StrokeOptions.d.ts +3 -3
- package/lib/esm/curve/StrokeOptions.d.ts.map +1 -1
- package/lib/esm/curve/StrokeOptions.js +1 -1
- package/lib/esm/curve/StrokeOptions.js.map +1 -1
- package/lib/esm/geometry3d/PolylineOps.d.ts +2 -1
- package/lib/esm/geometry3d/PolylineOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/PolylineOps.js +2 -1
- package/lib/esm/geometry3d/PolylineOps.js.map +1 -1
- package/lib/esm/polyface/IndexedEdgeMatcher.d.ts +27 -20
- package/lib/esm/polyface/IndexedEdgeMatcher.d.ts.map +1 -1
- package/lib/esm/polyface/IndexedEdgeMatcher.js +56 -30
- package/lib/esm/polyface/IndexedEdgeMatcher.js.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts +2 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js +2 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.d.ts +4 -4
- package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.js +19 -51
- package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/esm/solid/SweepContour.d.ts +24 -15
- package/lib/esm/solid/SweepContour.d.ts.map +1 -1
- package/lib/esm/solid/SweepContour.js +24 -15
- package/lib/esm/solid/SweepContour.js.map +1 -1
- package/package.json +3 -3
|
@@ -20,27 +20,31 @@ export declare class SweepContour {
|
|
|
20
20
|
localToWorld: Transform;
|
|
21
21
|
/** Axis used only in rotational case. */
|
|
22
22
|
axis: Ray3d | undefined;
|
|
23
|
-
/**
|
|
23
|
+
/** Caches */
|
|
24
24
|
private _xyStrokes?;
|
|
25
25
|
private _facets?;
|
|
26
26
|
private constructor();
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Create for linear sweep.
|
|
28
29
|
* @param contour curve to sweep, CAPTURED. For best results, contour should be planar.
|
|
29
30
|
* @param defaultNormal optional default normal for guiding coordinate frame setup.
|
|
30
31
|
*/
|
|
31
32
|
static createForLinearSweep(contour: AnyCurve, defaultNormal?: Vector3d): SweepContour | undefined;
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
33
|
+
/**
|
|
34
|
+
* Create for linear sweep.
|
|
35
|
+
* @param points polygon to sweep, CAPTURED as a Loop. Closure point is optional. If multiple polygons are passed in,
|
|
36
|
+
* parity logic is employed.
|
|
34
37
|
* For best results, all points should be coplanar.
|
|
35
38
|
* @param defaultNormal optional default normal for guiding coordinate frame setup.
|
|
36
39
|
*/
|
|
37
40
|
static createForPolygon(points: MultiLineStringDataVariant, defaultNormal?: Vector3d): SweepContour | undefined;
|
|
38
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Create for rotational sweep.
|
|
39
43
|
* @param contour curve to sweep, CAPTURED. For best results, contour should be coplanar with axis.
|
|
40
44
|
* @param axis rotation axis
|
|
41
45
|
*/
|
|
42
46
|
static createForRotation(contour: AnyCurve, axis: Ray3d): SweepContour | undefined;
|
|
43
|
-
/** Return (Reference to) the curves */
|
|
47
|
+
/** Return (Reference to) the curves. */
|
|
44
48
|
getCurves(): CurveCollection;
|
|
45
49
|
/**
|
|
46
50
|
* Apply `transform` to the curves, axis.
|
|
@@ -53,14 +57,15 @@ export declare class SweepContour {
|
|
|
53
57
|
cloneTransformed(transform: Transform): SweepContour | undefined;
|
|
54
58
|
/** Test for near equality of curves, frame, and axis. */
|
|
55
59
|
isAlmostEqual(other: any): boolean;
|
|
56
|
-
/** Recompute the local strokes cache for this contour */
|
|
60
|
+
/** Recompute the local strokes cache for this contour. */
|
|
57
61
|
computeXYStrokes(options?: StrokeOptions): void;
|
|
58
|
-
/** Return cached contour strokes */
|
|
62
|
+
/** Return cached contour strokes. */
|
|
59
63
|
get xyStrokes(): CurveCollection | undefined;
|
|
60
64
|
/**
|
|
61
65
|
* Build the (cached) internal facets for the contour.
|
|
62
66
|
* @param options primarily how to stroke the contour, but also how to facet it.
|
|
63
|
-
* * By default, a triangulation is computed, but if `options.maximizeConvexFacets === true`, edges between coplanar
|
|
67
|
+
* * By default, a triangulation is computed, but if `options.maximizeConvexFacets === true`, edges between coplanar
|
|
68
|
+
* triangles are removed to return maximally convex facets.
|
|
64
69
|
*/
|
|
65
70
|
buildFacets(options?: StrokeOptions): void;
|
|
66
71
|
/**
|
|
@@ -68,21 +73,25 @@ export declare class SweepContour {
|
|
|
68
73
|
* * This protects against PolyfaceBuilder reusing facets constructed with different options settings.
|
|
69
74
|
*/
|
|
70
75
|
purgeFacets(): void;
|
|
71
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* Emit facets to a builder.
|
|
72
78
|
* This method may cache and reuse facets over multiple calls.
|
|
73
79
|
*/
|
|
74
80
|
emitFacets(builder: PolyfaceBuilder, reverse: boolean, transform?: Transform): void;
|
|
75
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Emit facets to a function.
|
|
76
83
|
* This method may cache and reuse facets over multiple calls.
|
|
77
|
-
* @param announce callback to receive the facet set
|
|
78
|
-
* @param options how to stroke the contour
|
|
84
|
+
* @param announce callback to receive the facet set.
|
|
85
|
+
* @param options how to stroke the contour.
|
|
79
86
|
*/
|
|
80
87
|
announceFacets(announce: (facets: IndexedPolyface) => void, options?: StrokeOptions): void;
|
|
81
88
|
/**
|
|
82
89
|
* Create a UnionOfConvexClipPlaneSets that clips to the swept faceted contour region.
|
|
83
90
|
* @param sweepVector the sweep direction and distance:
|
|
84
|
-
* * If undefined, the sweep direction is along the contour normal and no caps are constructed (the sweep is infinite
|
|
85
|
-
*
|
|
91
|
+
* * If undefined, the sweep direction is along the contour normal and no caps are constructed (the sweep is infinite
|
|
92
|
+
* in both directions).
|
|
93
|
+
* * If defined, the returned clipper is inverted if and only if sweepVector is in the opposite half-space as the
|
|
94
|
+
* computed contour normal.
|
|
86
95
|
* @param cap0 construct a clip plane equal to the contour plane. Note that `sweepVector` must be defined.
|
|
87
96
|
* @param cap1 construct a clip plane parallel to the contour plane at the end of `sweepVector`.
|
|
88
97
|
* @param options how to stroke the contour
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SweepContour.d.ts","sourceRoot":"","sources":["../../../src/solid/SweepContour.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAa,MAAM,qBAAqB,CAAC;AAM1D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAW,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,eA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ToWorld = map;
|
|
37
37
|
this.axis = axis;
|
|
38
38
|
}
|
|
39
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Create for linear sweep.
|
|
40
41
|
* @param contour curve to sweep, CAPTURED. For best results, contour should be planar.
|
|
41
42
|
* @param defaultNormal optional default normal for guiding coordinate frame setup.
|
|
42
43
|
*/
|
|
@@ -47,8 +48,10 @@ export class SweepContour {
|
|
|
47
48
|
}
|
|
48
49
|
return undefined;
|
|
49
50
|
}
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
51
|
+
/**
|
|
52
|
+
* Create for linear sweep.
|
|
53
|
+
* @param points polygon to sweep, CAPTURED as a Loop. Closure point is optional. If multiple polygons are passed in,
|
|
54
|
+
* parity logic is employed.
|
|
52
55
|
* For best results, all points should be coplanar.
|
|
53
56
|
* @param defaultNormal optional default normal for guiding coordinate frame setup.
|
|
54
57
|
*/
|
|
@@ -70,7 +73,8 @@ export class SweepContour {
|
|
|
70
73
|
}
|
|
71
74
|
return undefined;
|
|
72
75
|
}
|
|
73
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* Create for rotational sweep.
|
|
74
78
|
* @param contour curve to sweep, CAPTURED. For best results, contour should be coplanar with axis.
|
|
75
79
|
* @param axis rotation axis
|
|
76
80
|
*/
|
|
@@ -82,7 +86,7 @@ export class SweepContour {
|
|
|
82
86
|
}
|
|
83
87
|
return undefined;
|
|
84
88
|
}
|
|
85
|
-
/** Return (Reference to) the curves */
|
|
89
|
+
/** Return (Reference to) the curves. */
|
|
86
90
|
getCurves() { return this.curves; }
|
|
87
91
|
/**
|
|
88
92
|
* Apply `transform` to the curves, axis.
|
|
@@ -130,7 +134,7 @@ export class SweepContour {
|
|
|
130
134
|
return false;
|
|
131
135
|
return true;
|
|
132
136
|
}
|
|
133
|
-
/** Recompute the local strokes cache for this contour */
|
|
137
|
+
/** Recompute the local strokes cache for this contour. */
|
|
134
138
|
computeXYStrokes(options) {
|
|
135
139
|
this._xyStrokes = undefined;
|
|
136
140
|
const worldToLocal = this.localToWorld.inverse();
|
|
@@ -140,14 +144,15 @@ export class SweepContour {
|
|
|
140
144
|
this._xyStrokes = strokes;
|
|
141
145
|
}
|
|
142
146
|
}
|
|
143
|
-
/** Return cached contour strokes */
|
|
147
|
+
/** Return cached contour strokes. */
|
|
144
148
|
get xyStrokes() {
|
|
145
149
|
return this._xyStrokes;
|
|
146
150
|
}
|
|
147
151
|
/**
|
|
148
152
|
* Build the (cached) internal facets for the contour.
|
|
149
153
|
* @param options primarily how to stroke the contour, but also how to facet it.
|
|
150
|
-
* * By default, a triangulation is computed, but if `options.maximizeConvexFacets === true`, edges between coplanar
|
|
154
|
+
* * By default, a triangulation is computed, but if `options.maximizeConvexFacets === true`, edges between coplanar
|
|
155
|
+
* triangles are removed to return maximally convex facets.
|
|
151
156
|
*/
|
|
152
157
|
buildFacets(options) {
|
|
153
158
|
if (this._facets)
|
|
@@ -170,7 +175,8 @@ export class SweepContour {
|
|
|
170
175
|
purgeFacets() {
|
|
171
176
|
this._facets = undefined;
|
|
172
177
|
}
|
|
173
|
-
/**
|
|
178
|
+
/**
|
|
179
|
+
* Emit facets to a builder.
|
|
174
180
|
* This method may cache and reuse facets over multiple calls.
|
|
175
181
|
*/
|
|
176
182
|
emitFacets(builder, reverse, transform) {
|
|
@@ -178,10 +184,11 @@ export class SweepContour {
|
|
|
178
184
|
if (this._facets)
|
|
179
185
|
builder.addIndexedPolyface(this._facets, reverse, transform);
|
|
180
186
|
}
|
|
181
|
-
/**
|
|
187
|
+
/**
|
|
188
|
+
* Emit facets to a function.
|
|
182
189
|
* This method may cache and reuse facets over multiple calls.
|
|
183
|
-
* @param announce callback to receive the facet set
|
|
184
|
-
* @param options how to stroke the contour
|
|
190
|
+
* @param announce callback to receive the facet set.
|
|
191
|
+
* @param options how to stroke the contour.
|
|
185
192
|
*/
|
|
186
193
|
announceFacets(announce, options) {
|
|
187
194
|
this.buildFacets(options);
|
|
@@ -191,8 +198,10 @@ export class SweepContour {
|
|
|
191
198
|
/**
|
|
192
199
|
* Create a UnionOfConvexClipPlaneSets that clips to the swept faceted contour region.
|
|
193
200
|
* @param sweepVector the sweep direction and distance:
|
|
194
|
-
* * If undefined, the sweep direction is along the contour normal and no caps are constructed (the sweep is infinite
|
|
195
|
-
*
|
|
201
|
+
* * If undefined, the sweep direction is along the contour normal and no caps are constructed (the sweep is infinite
|
|
202
|
+
* in both directions).
|
|
203
|
+
* * If defined, the returned clipper is inverted if and only if sweepVector is in the opposite half-space as the
|
|
204
|
+
* computed contour normal.
|
|
196
205
|
* @param cap0 construct a clip plane equal to the contour plane. Note that `sweepVector` must be defined.
|
|
197
206
|
* @param cap1 construct a clip plane parallel to the contour plane at the end of `sweepVector`.
|
|
198
207
|
* @param options how to stroke the contour
|
|
@@ -206,7 +215,7 @@ export class SweepContour {
|
|
|
206
215
|
sweepVector = this.localToWorld.matrix.columnZ();
|
|
207
216
|
}
|
|
208
217
|
options.maximizeConvexFacets = true; // produce fewer ConvexClipPlaneSets
|
|
209
|
-
//
|
|
218
|
+
// it's a trip around the barn, but it's easy to make a polyface and scan it
|
|
210
219
|
this.buildFacets(options);
|
|
211
220
|
const facets = this._facets;
|
|
212
221
|
if (facets) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SweepContour.js","sourceRoot":"","sources":["../../../src/solid/SweepContour.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AAEpF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM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G,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACpD,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;gBACtC,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;gBACvC,MAAM,OAAO,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;gBACjD,IAAI,IAAI;oBACN,OAAO,CAAC,mBAAmB,CAAC,SAAS,CAAC,oBAAoB,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;gBAC3F,IAAI,IAAI;oBACN,OAAO,CAAC,mBAAmB,CAAC,SAAS,CAAC,oBAAoB,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;gBAC3F,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YAC/B,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Solid\r\n */\r\n\r\nimport { ClipPlane } from \"../clipping/ClipPlane\";\r\nimport { ConvexClipPlaneSet } from \"../clipping/ConvexClipPlaneSet\";\r\nimport { UnionOfConvexClipPlaneSets } from \"../clipping/UnionOfConvexClipPlaneSets\";\r\nimport { CurveCollection } from \"../curve/CurveCollection\";\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { AnyCurve, AnyRegion } from \"../curve/CurveTypes\";\r\nimport { LineString3d } from \"../curve/LineString3d\";\r\nimport { Loop } from \"../curve/Loop\";\r\nimport { ParityRegion } from \"../curve/ParityRegion\";\r\nimport { Path } from \"../curve/Path\";\r\nimport { RegionOps } from \"../curve/RegionOps\";\r\nimport { StrokeOptions } from \"../curve/StrokeOptions\";\r\nimport { FrameBuilder } from \"../geometry3d/FrameBuilder\";\r\nimport { MultiLineStringDataVariant } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { IndexedPolyface } from \"../polyface/Polyface\";\r\nimport { PolyfaceBuilder } from \"../polyface/PolyfaceBuilder\";\r\n\r\n/**\r\n * Sweepable planar contour with Transform for local to world interaction.\r\n * * The surface/solid classes `LinearSweep`, `RotationalSweep`, `RuledSweep` use this for their swept contours.\r\n * @public\r\n */\r\nexport class SweepContour {\r\n /** The underlying curve collection, in its world coordinates position. */\r\n public curves: CurveCollection;\r\n /** coordinate frame that in which the curves are all in the xy plane. */\r\n public localToWorld: Transform;\r\n /** Axis used only in rotational case. */\r\n public axis: Ray3d | undefined;\r\n\r\n /** caches */\r\n private _xyStrokes?: CurveCollection;\r\n private _facets?: IndexedPolyface;\r\n\r\n private constructor(contour: AnyCurve, map: Transform, axis: Ray3d | undefined) {\r\n if (contour instanceof CurvePrimitive) {\r\n // this.curves is a CurveCollection (not AnyCurve) so that contour type determines closure.\r\n // This is the only time we detect CurvePrimitive closure and wrap as a relevant CurveChain.\r\n // Note that we are ASSUMING closure means planar here. This is potentially problematic.\r\n const primitive = contour;\r\n contour = contour.startPoint().isAlmostEqual(contour.endPoint()) ? new Loop() : new Path();\r\n contour.tryAddChild(primitive);\r\n }\r\n this.curves = contour;\r\n this.localToWorld = map;\r\n this.axis = axis;\r\n }\r\n /** Create for linear sweep.\r\n * @param contour curve to sweep, CAPTURED. For best results, contour should be planar.\r\n * @param defaultNormal optional default normal for guiding coordinate frame setup.\r\n */\r\n public static createForLinearSweep(contour: AnyCurve, defaultNormal?: Vector3d): SweepContour | undefined {\r\n const localToWorld = FrameBuilder.createRightHandedFrame(defaultNormal, contour);\r\n if (localToWorld) {\r\n return new SweepContour(contour, localToWorld, undefined);\r\n }\r\n return undefined;\r\n }\r\n /** Create for linear sweep.\r\n * @param points polygon to sweep, CAPTURED as a Loop. Closure point is optional. If multiple polygons are passed in, parity logic is employed.\r\n * For best results, all points should be coplanar.\r\n * @param defaultNormal optional default normal for guiding coordinate frame setup.\r\n */\r\n public static createForPolygon(points: MultiLineStringDataVariant, defaultNormal?: Vector3d): SweepContour | undefined {\r\n const localToWorld = FrameBuilder.createRightHandedFrame(defaultNormal, points);\r\n if (localToWorld) {\r\n const linestrings = LineString3d.createArrayOfLineString3d(points);\r\n const loops = [];\r\n for (const ls of linestrings) {\r\n ls.addClosurePoint();\r\n loops.push(Loop.create(ls));\r\n }\r\n if (loops.length === 1) {\r\n return new SweepContour(loops[0], localToWorld, undefined);\r\n } else if (loops.length > 1) {\r\n return new SweepContour(ParityRegion.createLoops(loops), localToWorld, undefined);\r\n }\r\n }\r\n return undefined;\r\n }\r\n /** Create for rotational sweep.\r\n * @param contour curve to sweep, CAPTURED. For best results, contour should be coplanar with axis.\r\n * @param axis rotation axis\r\n */\r\n public static createForRotation(contour: AnyCurve, axis: Ray3d): SweepContour | undefined {\r\n // createRightHandedFrame -- the axis is a last-gasp resolver for in-plane vectors.\r\n const localToWorld = FrameBuilder.createRightHandedFrame(undefined, contour, axis);\r\n if (localToWorld) {\r\n return new SweepContour(contour, localToWorld, axis.clone());\r\n }\r\n return undefined;\r\n }\r\n /** Return (Reference to) the curves */\r\n public getCurves(): CurveCollection { return this.curves; }\r\n /**\r\n * Apply `transform` to the curves, axis.\r\n * * The local to world frame is reconstructed for the transformed curves.\r\n */\r\n public tryTransformInPlace(transform: Transform): boolean {\r\n if (this.curves.tryTransformInPlace(transform)) {\r\n if (this.axis)\r\n this.axis.transformInPlace(transform);\r\n\r\n const localToWorld = this.axis !== undefined\r\n ? FrameBuilder.createRightHandedFrame(undefined, this.curves, this.axis)\r\n : FrameBuilder.createRightHandedFrame(undefined, this.curves);\r\n if (localToWorld) {\r\n this.localToWorld.setFrom(localToWorld);\r\n this._xyStrokes = undefined;\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n /** Return a deep clone. */\r\n public clone(): SweepContour {\r\n return new SweepContour(this.curves.clone(), this.localToWorld.clone(), this.axis);\r\n }\r\n /** Return a transformed clone. */\r\n public cloneTransformed(transform: Transform): SweepContour | undefined {\r\n const newContour = this.clone();\r\n if (newContour.tryTransformInPlace(transform))\r\n return newContour;\r\n return undefined;\r\n }\r\n /** Test for near equality of curves, frame, and axis. */\r\n public isAlmostEqual(other: any): boolean {\r\n if (! (other instanceof SweepContour))\r\n return false;\r\n if (!this.curves.isAlmostEqual(other.curves))\r\n return false;\r\n if (!this.localToWorld.isAlmostEqual(other.localToWorld))\r\n return false;\r\n if (this.axis && other.axis) {\r\n if (!this.axis.isAlmostEqual(other.axis))\r\n return false;\r\n } else if (this.axis || other.axis)\r\n return false;\r\n return true;\r\n }\r\n\r\n /** Recompute the local strokes cache for this contour */\r\n public computeXYStrokes(options?: StrokeOptions): void {\r\n this._xyStrokes = undefined;\r\n const worldToLocal = this.localToWorld.inverse();\r\n if (worldToLocal) {\r\n const strokes = this.curves.cloneStroked(options);\r\n if (strokes.tryTransformInPlace(worldToLocal))\r\n this._xyStrokes = strokes;\r\n }\r\n }\r\n /** Return cached contour strokes */\r\n public get xyStrokes(): CurveCollection | undefined {\r\n return this._xyStrokes;\r\n }\r\n\r\n /**\r\n * Build the (cached) internal facets for the contour.\r\n * @param options primarily how to stroke the contour, but also how to facet it.\r\n * * By default, a triangulation is computed, but if `options.maximizeConvexFacets === true`, edges between coplanar triangles are removed to return maximally convex facets.\r\n */\r\n public buildFacets(options?: StrokeOptions): void {\r\n if (this._facets)\r\n return;\r\n if (!this.curves.isAnyRegion())\r\n return;\r\n const worldToLocal = this.localToWorld.inverse();\r\n if (!worldToLocal)\r\n return;\r\n const localRegion = this.curves.cloneTransformed(worldToLocal) as AnyRegion | undefined;\r\n if (!localRegion)\r\n return;\r\n if (this._facets = RegionOps.facetRegionXY(localRegion, options))\r\n this._facets.tryTransformInPlace(this.localToWorld);\r\n }\r\n /**\r\n * Delete facet cache.\r\n * * This protects against PolyfaceBuilder reusing facets constructed with different options settings.\r\n */\r\n public purgeFacets() {\r\n this._facets = undefined;\r\n }\r\n /** Emit facets to a builder.\r\n * This method may cache and reuse facets over multiple calls.\r\n */\r\n public emitFacets(builder: PolyfaceBuilder, reverse: boolean, transform?: Transform) {\r\n this.buildFacets(builder.options);\r\n if (this._facets)\r\n builder.addIndexedPolyface(this._facets, reverse, transform);\r\n }\r\n /** Emit facets to a function\r\n * This method may cache and reuse facets over multiple calls.\r\n * @param announce callback to receive the facet set\r\n * @param options how to stroke the contour\r\n */\r\n public announceFacets(announce: (facets: IndexedPolyface) => void, options?: StrokeOptions): void {\r\n this.buildFacets(options);\r\n if (this._facets)\r\n announce(this._facets);\r\n }\r\n /**\r\n * Create a UnionOfConvexClipPlaneSets that clips to the swept faceted contour region.\r\n * @param sweepVector the sweep direction and distance:\r\n * * If undefined, the sweep direction is along the contour normal and no caps are constructed (the sweep is infinite in both directions).\r\n * * If defined, the returned clipper is inverted if and only if sweepVector is in the opposite half-space as the computed contour normal.\r\n * @param cap0 construct a clip plane equal to the contour plane. Note that `sweepVector` must be defined.\r\n * @param cap1 construct a clip plane parallel to the contour plane at the end of `sweepVector`.\r\n * @param options how to stroke the contour\r\n * @returns clipper defined by faceting then sweeping the contour region\r\n */\r\n public sweepToUnionOfConvexClipPlaneSets(sweepVector?: Vector3d, cap0: boolean = false, cap1: boolean = false, options?: StrokeOptions): UnionOfConvexClipPlaneSets | undefined {\r\n if (!options)\r\n options = StrokeOptions.createForFacets();\r\n if (!sweepVector) {\r\n cap0 = cap1 = false;\r\n sweepVector = this.localToWorld.matrix.columnZ();\r\n }\r\n options.maximizeConvexFacets = true; // produce fewer ConvexClipPlaneSets\r\n // It's a trip around the barn, but it's easy to make a polyface and scan it . . .\r\n this.buildFacets(options);\r\n const facets = this._facets;\r\n if (facets) {\r\n const point0 = Point3d.create();\r\n const point1 = Point3d.create();\r\n const result = UnionOfConvexClipPlaneSets.createEmpty();\r\n const visitor = facets.createVisitor(1);\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n const numEdges = visitor.point.length - 1;\r\n const clipper = ConvexClipPlaneSet.createEmpty();\r\n for (let i = 0; i < numEdges; i++) {\r\n visitor.point.getPoint3dAtUncheckedPointIndex(i, point0);\r\n visitor.point.getPoint3dAtUncheckedPointIndex(i + 1, point1);\r\n const plane = ClipPlane.createEdgeAndUpVector(point1, point0, sweepVector);\r\n const visible = visitor.edgeVisible[i];\r\n plane?.setFlags(!visible, !visible);\r\n clipper.addPlaneToConvexSet(plane);\r\n }\r\n result.addConvexSet(clipper);\r\n }\r\n if (cap0 || cap1) {\r\n const zVector = this.localToWorld.matrix.columnZ();\r\n const plane0Origin = this.localToWorld.getOrigin();\r\n const plane1Origin = plane0Origin.plus(sweepVector);\r\n const inwardNormal0 = zVector.clone();\r\n const inwardNormal1 = zVector.negate();\r\n const clipper = ConvexClipPlaneSet.createEmpty();\r\n if (cap0)\r\n clipper.addPlaneToConvexSet(ClipPlane.createNormalAndPoint(inwardNormal0, plane0Origin));\r\n if (cap1)\r\n clipper.addPlaneToConvexSet(ClipPlane.createNormalAndPoint(inwardNormal1, plane1Origin));\r\n result.addConvexSet(clipper);\r\n }\r\n return result;\r\n }\r\n return undefined;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SweepContour.js","sourceRoot":"","sources":["../../../src/solid/SweepContour.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AAEpF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACr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AC;gBACnD,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC;gBACnD,MAAM,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACpD,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;gBACtC,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;gBACvC,MAAM,OAAO,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;gBACjD,IAAI,IAAI;oBACN,OAAO,CAAC,mBAAmB,CAAC,SAAS,CAAC,oBAAoB,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;gBAC3F,IAAI,IAAI;oBACN,OAAO,CAAC,mBAAmB,CAAC,SAAS,CAAC,oBAAoB,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;gBAC3F,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YAC/B,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Solid\r\n */\r\n\r\nimport { ClipPlane } from \"../clipping/ClipPlane\";\r\nimport { ConvexClipPlaneSet } from \"../clipping/ConvexClipPlaneSet\";\r\nimport { UnionOfConvexClipPlaneSets } from \"../clipping/UnionOfConvexClipPlaneSets\";\r\nimport { CurveCollection } from \"../curve/CurveCollection\";\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { AnyCurve, AnyRegion } from \"../curve/CurveTypes\";\r\nimport { LineString3d } from \"../curve/LineString3d\";\r\nimport { Loop } from \"../curve/Loop\";\r\nimport { ParityRegion } from \"../curve/ParityRegion\";\r\nimport { Path } from \"../curve/Path\";\r\nimport { RegionOps } from \"../curve/RegionOps\";\r\nimport { StrokeOptions } from \"../curve/StrokeOptions\";\r\nimport { FrameBuilder } from \"../geometry3d/FrameBuilder\";\r\nimport { MultiLineStringDataVariant } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { IndexedPolyface } from \"../polyface/Polyface\";\r\nimport { PolyfaceBuilder } from \"../polyface/PolyfaceBuilder\";\r\n\r\n/**\r\n * Sweepable planar contour with Transform for local to world interaction.\r\n * * The surface/solid classes `LinearSweep`, `RotationalSweep`, `RuledSweep` use this for their swept contours.\r\n * @public\r\n */\r\nexport class SweepContour {\r\n /** The underlying curve collection, in its world coordinates position. */\r\n public curves: CurveCollection;\r\n /** coordinate frame that in which the curves are all in the xy plane. */\r\n public localToWorld: Transform;\r\n /** Axis used only in rotational case. */\r\n public axis: Ray3d | undefined;\r\n /** Caches */\r\n private _xyStrokes?: CurveCollection;\r\n private _facets?: IndexedPolyface;\r\n\r\n private constructor(contour: AnyCurve, map: Transform, axis: Ray3d | undefined) {\r\n if (contour instanceof CurvePrimitive) {\r\n // this.curves is a CurveCollection (not AnyCurve) so that contour type determines closure.\r\n // This is the only time we detect CurvePrimitive closure and wrap as a relevant CurveChain.\r\n // Note that we are ASSUMING closure means planar here. This is potentially problematic.\r\n const primitive = contour;\r\n contour = contour.startPoint().isAlmostEqual(contour.endPoint()) ? new Loop() : new Path();\r\n contour.tryAddChild(primitive);\r\n }\r\n this.curves = contour;\r\n this.localToWorld = map;\r\n this.axis = axis;\r\n }\r\n /**\r\n * Create for linear sweep.\r\n * @param contour curve to sweep, CAPTURED. For best results, contour should be planar.\r\n * @param defaultNormal optional default normal for guiding coordinate frame setup.\r\n */\r\n public static createForLinearSweep(contour: AnyCurve, defaultNormal?: Vector3d): SweepContour | undefined {\r\n const localToWorld = FrameBuilder.createRightHandedFrame(defaultNormal, contour);\r\n if (localToWorld) {\r\n return new SweepContour(contour, localToWorld, undefined);\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Create for linear sweep.\r\n * @param points polygon to sweep, CAPTURED as a Loop. Closure point is optional. If multiple polygons are passed in,\r\n * parity logic is employed.\r\n * For best results, all points should be coplanar.\r\n * @param defaultNormal optional default normal for guiding coordinate frame setup.\r\n */\r\n public static createForPolygon(points: MultiLineStringDataVariant, defaultNormal?: Vector3d): SweepContour | undefined {\r\n const localToWorld = FrameBuilder.createRightHandedFrame(defaultNormal, points);\r\n if (localToWorld) {\r\n const linestrings = LineString3d.createArrayOfLineString3d(points);\r\n const loops = [];\r\n for (const ls of linestrings) {\r\n ls.addClosurePoint();\r\n loops.push(Loop.create(ls));\r\n }\r\n if (loops.length === 1) {\r\n return new SweepContour(loops[0], localToWorld, undefined);\r\n } else if (loops.length > 1) {\r\n return new SweepContour(ParityRegion.createLoops(loops), localToWorld, undefined);\r\n }\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Create for rotational sweep.\r\n * @param contour curve to sweep, CAPTURED. For best results, contour should be coplanar with axis.\r\n * @param axis rotation axis\r\n */\r\n public static createForRotation(contour: AnyCurve, axis: Ray3d): SweepContour | undefined {\r\n // createRightHandedFrame -- the axis is a last-gasp resolver for in-plane vectors.\r\n const localToWorld = FrameBuilder.createRightHandedFrame(undefined, contour, axis);\r\n if (localToWorld) {\r\n return new SweepContour(contour, localToWorld, axis.clone());\r\n }\r\n return undefined;\r\n }\r\n /** Return (Reference to) the curves. */\r\n public getCurves(): CurveCollection { return this.curves; }\r\n /**\r\n * Apply `transform` to the curves, axis.\r\n * * The local to world frame is reconstructed for the transformed curves.\r\n */\r\n public tryTransformInPlace(transform: Transform): boolean {\r\n if (this.curves.tryTransformInPlace(transform)) {\r\n if (this.axis)\r\n this.axis.transformInPlace(transform);\r\n const localToWorld = this.axis !== undefined\r\n ? FrameBuilder.createRightHandedFrame(undefined, this.curves, this.axis)\r\n : FrameBuilder.createRightHandedFrame(undefined, this.curves);\r\n if (localToWorld) {\r\n this.localToWorld.setFrom(localToWorld);\r\n this._xyStrokes = undefined;\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n /** Return a deep clone. */\r\n public clone(): SweepContour {\r\n return new SweepContour(this.curves.clone(), this.localToWorld.clone(), this.axis);\r\n }\r\n /** Return a transformed clone. */\r\n public cloneTransformed(transform: Transform): SweepContour | undefined {\r\n const newContour = this.clone();\r\n if (newContour.tryTransformInPlace(transform))\r\n return newContour;\r\n return undefined;\r\n }\r\n /** Test for near equality of curves, frame, and axis. */\r\n public isAlmostEqual(other: any): boolean {\r\n if (!(other instanceof SweepContour))\r\n return false;\r\n if (!this.curves.isAlmostEqual(other.curves))\r\n return false;\r\n if (!this.localToWorld.isAlmostEqual(other.localToWorld))\r\n return false;\r\n if (this.axis && other.axis) {\r\n if (!this.axis.isAlmostEqual(other.axis))\r\n return false;\r\n } else if (this.axis || other.axis)\r\n return false;\r\n return true;\r\n }\r\n /** Recompute the local strokes cache for this contour. */\r\n public computeXYStrokes(options?: StrokeOptions): void {\r\n this._xyStrokes = undefined;\r\n const worldToLocal = this.localToWorld.inverse();\r\n if (worldToLocal) {\r\n const strokes = this.curves.cloneStroked(options);\r\n if (strokes.tryTransformInPlace(worldToLocal))\r\n this._xyStrokes = strokes;\r\n }\r\n }\r\n /** Return cached contour strokes. */\r\n public get xyStrokes(): CurveCollection | undefined {\r\n return this._xyStrokes;\r\n }\r\n /**\r\n * Build the (cached) internal facets for the contour.\r\n * @param options primarily how to stroke the contour, but also how to facet it.\r\n * * By default, a triangulation is computed, but if `options.maximizeConvexFacets === true`, edges between coplanar\r\n * triangles are removed to return maximally convex facets.\r\n */\r\n public buildFacets(options?: StrokeOptions): void {\r\n if (this._facets)\r\n return;\r\n if (!this.curves.isAnyRegion())\r\n return;\r\n const worldToLocal = this.localToWorld.inverse();\r\n if (!worldToLocal)\r\n return;\r\n const localRegion = this.curves.cloneTransformed(worldToLocal) as AnyRegion | undefined;\r\n if (!localRegion)\r\n return;\r\n if (this._facets = RegionOps.facetRegionXY(localRegion, options))\r\n this._facets.tryTransformInPlace(this.localToWorld);\r\n }\r\n /**\r\n * Delete facet cache.\r\n * * This protects against PolyfaceBuilder reusing facets constructed with different options settings.\r\n */\r\n public purgeFacets() {\r\n this._facets = undefined;\r\n }\r\n /**\r\n * Emit facets to a builder.\r\n * This method may cache and reuse facets over multiple calls.\r\n */\r\n public emitFacets(builder: PolyfaceBuilder, reverse: boolean, transform?: Transform) {\r\n this.buildFacets(builder.options);\r\n if (this._facets)\r\n builder.addIndexedPolyface(this._facets, reverse, transform);\r\n }\r\n /**\r\n * Emit facets to a function.\r\n * This method may cache and reuse facets over multiple calls.\r\n * @param announce callback to receive the facet set.\r\n * @param options how to stroke the contour.\r\n */\r\n public announceFacets(announce: (facets: IndexedPolyface) => void, options?: StrokeOptions): void {\r\n this.buildFacets(options);\r\n if (this._facets)\r\n announce(this._facets);\r\n }\r\n /**\r\n * Create a UnionOfConvexClipPlaneSets that clips to the swept faceted contour region.\r\n * @param sweepVector the sweep direction and distance:\r\n * * If undefined, the sweep direction is along the contour normal and no caps are constructed (the sweep is infinite\r\n * in both directions).\r\n * * If defined, the returned clipper is inverted if and only if sweepVector is in the opposite half-space as the\r\n * computed contour normal.\r\n * @param cap0 construct a clip plane equal to the contour plane. Note that `sweepVector` must be defined.\r\n * @param cap1 construct a clip plane parallel to the contour plane at the end of `sweepVector`.\r\n * @param options how to stroke the contour\r\n * @returns clipper defined by faceting then sweeping the contour region\r\n */\r\n public sweepToUnionOfConvexClipPlaneSets(\r\n sweepVector?: Vector3d, cap0: boolean = false, cap1: boolean = false, options?: StrokeOptions,\r\n ): UnionOfConvexClipPlaneSets | undefined {\r\n if (!options)\r\n options = StrokeOptions.createForFacets();\r\n if (!sweepVector) {\r\n cap0 = cap1 = false;\r\n sweepVector = this.localToWorld.matrix.columnZ();\r\n }\r\n options.maximizeConvexFacets = true; // produce fewer ConvexClipPlaneSets\r\n // it's a trip around the barn, but it's easy to make a polyface and scan it\r\n this.buildFacets(options);\r\n const facets = this._facets;\r\n if (facets) {\r\n const point0 = Point3d.create();\r\n const point1 = Point3d.create();\r\n const result = UnionOfConvexClipPlaneSets.createEmpty();\r\n const visitor = facets.createVisitor(1);\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n const numEdges = visitor.point.length - 1;\r\n const clipper = ConvexClipPlaneSet.createEmpty();\r\n for (let i = 0; i < numEdges; i++) {\r\n visitor.point.getPoint3dAtUncheckedPointIndex(i, point0);\r\n visitor.point.getPoint3dAtUncheckedPointIndex(i + 1, point1);\r\n const plane = ClipPlane.createEdgeAndUpVector(point1, point0, sweepVector);\r\n const visible = visitor.edgeVisible[i];\r\n plane?.setFlags(!visible, !visible);\r\n clipper.addPlaneToConvexSet(plane);\r\n }\r\n result.addConvexSet(clipper);\r\n }\r\n if (cap0 || cap1) {\r\n const zVector = this.localToWorld.matrix.columnZ();\r\n const plane0Origin = this.localToWorld.getOrigin();\r\n const plane1Origin = plane0Origin.plus(sweepVector);\r\n const inwardNormal0 = zVector.clone();\r\n const inwardNormal1 = zVector.negate();\r\n const clipper = ConvexClipPlaneSet.createEmpty();\r\n if (cap0)\r\n clipper.addPlaneToConvexSet(ClipPlane.createNormalAndPoint(inwardNormal0, plane0Origin));\r\n if (cap1)\r\n clipper.addPlaneToConvexSet(ClipPlane.createNormalAndPoint(inwardNormal1, plane1Origin));\r\n result.addConvexSet(clipper);\r\n }\r\n return result;\r\n }\r\n return undefined;\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-geometry",
|
|
3
|
-
"version": "5.0.0-dev.
|
|
3
|
+
"version": "5.0.0-dev.23",
|
|
4
4
|
"description": "iTwin.js Core Geometry library",
|
|
5
5
|
"main": "lib/cjs/core-geometry.js",
|
|
6
6
|
"module": "lib/esm/core-geometry.js",
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"rimraf": "^3.0.2",
|
|
32
32
|
"typescript": "~5.6.2",
|
|
33
33
|
"vitest": "^2.1.0",
|
|
34
|
-
"@itwin/build-tools": "5.0.0-dev.
|
|
34
|
+
"@itwin/build-tools": "5.0.0-dev.23"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"flatbuffers": "~1.12.0",
|
|
38
|
-
"@itwin/core-bentley": "5.0.0-dev.
|
|
38
|
+
"@itwin/core-bentley": "5.0.0-dev.23"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "npm run -s build:cjs && npm run -s build:esm",
|