@itwin/ecschema-rpcinterface-tests 5.7.0-dev.9 → 5.8.0-dev.1

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.
@@ -22736,30 +22736,58 @@ class Logger {
22736
22736
  const minLevel = Logger.getLevel(category);
22737
22737
  return (minLevel !== undefined) && (level >= minLevel);
22738
22738
  }
22739
- /** Log the specified message to the **error** stream.
22740
- * @param category The category of the message.
22741
- * @param message The message.
22742
- * @param metaData Optional data for the message
22743
- */
22744
- static logError(category, message, metaData) {
22745
- if (Logger._logError && Logger.isEnabled(category, LogLevel.Error))
22746
- Logger._logError(category, message, metaData);
22739
+ // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
22740
+ static logError(category, messageOrError, metaData) {
22741
+ if (Logger._logError && Logger.isEnabled(category, LogLevel.Error)) {
22742
+ if (typeof messageOrError === "string") {
22743
+ Logger._logError(category, messageOrError, metaData);
22744
+ }
22745
+ else if (_BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.isError(messageOrError)) {
22746
+ // For backwards compatibility, log BentleyError old way
22747
+ Logger._logError(category, Logger.getExceptionMessage(messageOrError), () => ({ ..._BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getErrorMetadata(messageOrError), exceptionType: messageOrError?.constructor?.name ?? "<Unknown>", ..._BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getMetaData(metaData) }));
22748
+ }
22749
+ else {
22750
+ // Else, return a copy of the error, with non-enumerable members `message` and `stack` removed, as "metadata" for log.
22751
+ Logger._logError(category, Logger.getExceptionMessage(messageOrError), Logger.getExceptionMetaData(messageOrError, metaData));
22752
+ }
22753
+ }
22747
22754
  }
22748
- static getExceptionMessage(err) {
22749
- if (err === undefined) {
22750
- return "Error: err is undefined.";
22755
+ /**
22756
+ * Get a sting message for a given error.
22757
+ * For legacy [[BentleyError]] exceptions, this will include the error message and, optionally, the call stack.
22758
+ * For other exceptions, this will include the stringified version of the error.
22759
+ * @param error The error to get the message for
22760
+ * @returns A string message for the error
22761
+ */
22762
+ static getExceptionMessage(error) {
22763
+ if (error === undefined) {
22764
+ return "Error: error is undefined.";
22765
+ }
22766
+ if (error === null) {
22767
+ return "Error: error is null.";
22751
22768
  }
22752
- if (err === null) {
22753
- return "Error: err is null.";
22769
+ const stack = Logger.logExceptionCallstacks ? `\n${_BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getErrorStack(error)}` : "";
22770
+ return _BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getErrorMessage(error) + stack;
22771
+ }
22772
+ /**
22773
+ * Merged passed metaData with error properties into one LoggingMetaData, with the passed metaData taking precedence in case of conflict.
22774
+ * @param error The error to be logged as metadata
22775
+ * @param metaData Optional metadata to be merged with the error
22776
+ * @returns A function returning the merged metadata
22777
+ */
22778
+ static getExceptionMetaData(error, metaData) {
22779
+ const exceptionType = error?.constructor?.name ?? "<Unknown>";
22780
+ if (metaData === undefined) {
22781
+ return () => ({ exceptionType, ...error });
22754
22782
  }
22755
- const stack = Logger.logExceptionCallstacks ? `\n${_BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getErrorStack(err)}` : "";
22756
- return _BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getErrorMessage(err) + stack;
22783
+ return () => ({ exceptionType, ...error, ..._BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getMetaData(metaData) });
22757
22784
  }
22758
22785
  /** Log the specified exception.
22759
22786
  * For legacy [[BentleyError]] exceptions, the special "exceptionType" property will be added as metadata. Otherwise, all enumerable members of the exception are logged as metadata.
22760
22787
  * @param category The category of the message.
22761
22788
  * @param err The exception object.
22762
22789
  * @param log The logger output function to use - defaults to Logger.logError
22790
+ * @deprecated in 5.6. Use logError(category, error, metaData) instead, which will log exceptions in the same way but is more flexible and easier to use.
22763
22791
  */
22764
22792
  static logException(category, err, log = (_category, message, metaData) => Logger.logError(_category, message, metaData)) {
22765
22793
  log(category, Logger.getExceptionMessage(err), () => {
@@ -22875,6 +22903,10 @@ class ObservableSet extends Set {
22875
22903
  onDeleted = new _BeEvent__WEBPACK_IMPORTED_MODULE_0__.BeEvent();
22876
22904
  /** Emitted after this set's contents are cleared. */
22877
22905
  onCleared = new _BeEvent__WEBPACK_IMPORTED_MODULE_0__.BeEvent();
22906
+ /** Emitted after multiple items are added to this set via [[addAll]]. */
22907
+ onBatchAdded = new _BeEvent__WEBPACK_IMPORTED_MODULE_0__.BeEvent();
22908
+ /** Emitted after multiple items are deleted from this set via [[deleteAll]]. */
22909
+ onBatchDeleted = new _BeEvent__WEBPACK_IMPORTED_MODULE_0__.BeEvent();
22878
22910
  /** Construct a new ObservableSet.
22879
22911
  * @param elements Optional elements with which to populate the new set.
22880
22912
  */
@@ -22907,6 +22939,32 @@ class ObservableSet extends Set {
22907
22939
  this.onCleared.raiseEvent();
22908
22940
  }
22909
22941
  }
22942
+ /** Add multiple items to the set, raising [[onBatchAdded]] only once after all items are added.
22943
+ * This is more efficient than calling [[add]] in a loop when listeners need not be notified of each individual addition.
22944
+ * @param items The items to add.
22945
+ * @returns The number of items that were actually added (i.e., were not already present).
22946
+ */
22947
+ addAll(items) {
22948
+ const prevSize = this.size;
22949
+ for (const item of items)
22950
+ super.add(item);
22951
+ if (this.size !== prevSize)
22952
+ this.onBatchAdded.raiseEvent();
22953
+ return this.size - prevSize;
22954
+ }
22955
+ /** Delete multiple items from the set, raising [[onBatchDeleted]] only once after all items are deleted.
22956
+ * This is more efficient than calling [[delete]] in a loop when listeners need not be notified of each individual deletion.
22957
+ * @param items The items to delete.
22958
+ * @returns The number of items that were actually deleted (i.e., were present in the set).
22959
+ */
22960
+ deleteAll(items) {
22961
+ const prevSize = this.size;
22962
+ for (const item of items)
22963
+ super.delete(item);
22964
+ if (this.size !== prevSize)
22965
+ this.onBatchDeleted.raiseEvent();
22966
+ return prevSize - this.size;
22967
+ }
22910
22968
  }
22911
22969
 
22912
22970
 
@@ -23015,11 +23073,15 @@ class OneAtATimeAction {
23015
23073
  return await promise;
23016
23074
  }
23017
23075
  finally {
23018
- // do all of this whether promise was fulfilled or rejected
23019
- this._active = this._pending; // see if there's a pending request waiting
23020
- this._pending = undefined; // clear pending
23021
- if (this._active)
23022
- this._active.start(); // eslint-disable-line @typescript-eslint/no-floating-promises
23076
+ // A replaced pending request can be abandoned before it ever becomes active.
23077
+ // Only the currently active entry is allowed to promote/start the next pending request.
23078
+ if (this._active === entry) {
23079
+ // do all of this whether promise was fulfilled or rejected
23080
+ this._active = this._pending; // see if there's a pending request waiting
23081
+ this._pending = undefined; // clear pending
23082
+ if (this._active)
23083
+ this._active.start(); // eslint-disable-line @typescript-eslint/no-floating-promises
23084
+ }
23023
23085
  }
23024
23086
  }
23025
23087
  }
@@ -25102,7 +25164,7 @@ class UnexpectedErrors {
25102
25164
  /** handler for logging exception to console */
25103
25165
  static consoleLog = (e) => console.error(e); // eslint-disable-line no-console
25104
25166
  /** handler for logging exception with [[Logger]] */
25105
- static errorLog = (e) => _Logger__WEBPACK_IMPORTED_MODULE_0__.Logger.logException("unhandled", e);
25167
+ static errorLog = (e) => _Logger__WEBPACK_IMPORTED_MODULE_0__.Logger.logError("unhandled", e);
25106
25168
  static _telemetry = [];
25107
25169
  static _handler = this.errorLog; // default to error logging
25108
25170
  constructor() { } // this is a singleton
@@ -47405,7 +47467,7 @@ var ElementGeometry;
47405
47467
  if (entry.text) {
47406
47468
  result = this.appendTextString(new _TextString__WEBPACK_IMPORTED_MODULE_5__.TextString(entry.text));
47407
47469
  }
47408
- else if (entry.color) {
47470
+ else if (undefined !== entry.color) {
47409
47471
  const params = geomParams?.clone() ?? new _GeometryParams__WEBPACK_IMPORTED_MODULE_7__.GeometryParams(_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.Id64.invalid);
47410
47472
  if (entry.color !== "subcategory") {
47411
47473
  params.lineColor = _ColorDef__WEBPACK_IMPORTED_MODULE_6__.ColorDef.fromJSON(entry.color);
@@ -66205,7 +66267,8 @@ class SchemaFormatsProvider {
66205
66267
  * @param contextOrLocater The SchemaContext or a different ISchemaLocater implementation used to retrieve the schema. The SchemaContext
66206
66268
  * class implements the ISchemaLocater interface. If the provided locater is not a SchemaContext instance a new SchemaContext will be
66207
66269
  * created and the locater will be added.
66208
- * @param unitSystem Used to lookup a default format through a schema specific algorithm, when the format retrieved is associated with a KindOfQuantity.
66270
+ * @param unitSystem Optional unit system used to lookup a default format through a schema specific algorithm, when the format retrieved is associated with a KindOfQuantity.
66271
+ * If not provided, the default presentation format will be used directly without matching unit systems.
66209
66272
  */
66210
66273
  constructor(contextOrLocater, unitSystem) {
66211
66274
  if (contextOrLocater instanceof _Context__WEBPACK_IMPORTED_MODULE_0__.SchemaContext) {
@@ -66254,39 +66317,44 @@ class SchemaFormatsProvider {
66254
66317
  if (!kindOfQuantity) {
66255
66318
  return undefined;
66256
66319
  }
66257
- // Find the first presentation format that matches the provided unit system.
66258
- const unitSystemMatchers = getUnitSystemGroupMatchers(this._unitSystem);
66259
- const presentationFormats = kindOfQuantity.presentationFormats;
66260
- for (const matcher of unitSystemMatchers) {
66261
- for (const lazyFormat of presentationFormats) {
66262
- const format = await lazyFormat;
66263
- const unit = await (format.units && format.units[0][0]);
66264
- if (!unit) {
66265
- continue;
66266
- }
66267
- const currentUnitSystem = await unit.unitSystem;
66268
- if (currentUnitSystem && matcher(currentUnitSystem)) {
66269
- this._formatsRetrieved.add(itemKey.fullName);
66270
- const props = (0,_Metadata_OverrideFormat__WEBPACK_IMPORTED_MODULE_6__.getFormatProps)(format);
66271
- return this.convertToFormatDefinition(props, kindOfQuantity);
66320
+ // If a unit system is provided, find the first presentation format that matches it.
66321
+ if (this._unitSystem) {
66322
+ const unitSystemMatchers = getUnitSystemGroupMatchers(this._unitSystem);
66323
+ const presentationFormats = kindOfQuantity.presentationFormats;
66324
+ for (const matcher of unitSystemMatchers) {
66325
+ for (const lazyFormat of presentationFormats) {
66326
+ const format = await lazyFormat;
66327
+ const unit = await (format.units && format.units[0][0]);
66328
+ if (!unit) {
66329
+ continue;
66330
+ }
66331
+ const currentUnitSystem = await unit.unitSystem;
66332
+ if (currentUnitSystem && matcher(currentUnitSystem)) {
66333
+ this._formatsRetrieved.add(itemKey.fullName);
66334
+ const props = (0,_Metadata_OverrideFormat__WEBPACK_IMPORTED_MODULE_6__.getFormatProps)(format);
66335
+ return this.convertToFormatDefinition(props, kindOfQuantity);
66336
+ }
66272
66337
  }
66273
66338
  }
66339
+ // If no matching presentation format was found, fall back to persistence unit format
66340
+ // only if it matches the requested unit system.
66341
+ const persistenceUnit = await kindOfQuantity.persistenceUnit;
66342
+ const persistenceUnitSystem = await persistenceUnit?.unitSystem;
66343
+ if (persistenceUnit && persistenceUnitSystem && unitSystemMatchers.some((matcher) => matcher(persistenceUnitSystem))) {
66344
+ this._formatsRetrieved.add(itemKey.fullName);
66345
+ const props = getPersistenceUnitFormatProps(persistenceUnit);
66346
+ return this.convertToFormatDefinition(props, kindOfQuantity);
66347
+ }
66274
66348
  }
66275
- // If no matching presentation format was found, use persistence unit format if it matches unit system.
66276
- const persistenceUnit = await kindOfQuantity.persistenceUnit;
66277
- const persistenceUnitSystem = await persistenceUnit?.unitSystem;
66278
- if (persistenceUnit && persistenceUnitSystem && unitSystemMatchers.some((matcher) => matcher(persistenceUnitSystem))) {
66279
- this._formatsRetrieved.add(itemKey.fullName);
66280
- const props = getPersistenceUnitFormatProps(persistenceUnit);
66281
- return this.convertToFormatDefinition(props, kindOfQuantity);
66282
- }
66349
+ // If no unit system was provided, or no matching format was found, use the default presentation format.
66350
+ // Unit conversion from persistence unit to presentation unit will be handled by FormatterSpec.
66283
66351
  const defaultFormat = kindOfQuantity.defaultPresentationFormat;
66284
- if (!defaultFormat) {
66285
- return undefined;
66352
+ if (defaultFormat) {
66353
+ this._formatsRetrieved.add(itemKey.fullName);
66354
+ const defaultProps = (0,_Metadata_OverrideFormat__WEBPACK_IMPORTED_MODULE_6__.getFormatProps)(await defaultFormat);
66355
+ return this.convertToFormatDefinition(defaultProps, kindOfQuantity);
66286
66356
  }
66287
- this._formatsRetrieved.add(itemKey.fullName);
66288
- const defaultProps = (0,_Metadata_OverrideFormat__WEBPACK_IMPORTED_MODULE_6__.getFormatProps)(await defaultFormat);
66289
- return this.convertToFormatDefinition(defaultProps, kindOfQuantity);
66357
+ return undefined;
66290
66358
  }
66291
66359
  /**
66292
66360
  * Retrieves a Format from a SchemaContext. If the format is part of a KindOfQuantity, the first presentation format in the KindOfQuantity that matches the current unit system will be retrieved.
@@ -83115,6 +83183,18 @@ class CategorySelectorState extends _EntityState__WEBPACK_IMPORTED_MODULE_1__.El
83115
83183
  for (const id of _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Id64.iterable(arg))
83116
83184
  this.categories.delete(id);
83117
83185
  }
83186
+ /** Add one or more categories to this CategorySelector, raising a single batch event instead of one event per category.
83187
+ * This is more efficient than [[addCategories]] when adding many categories at once.
83188
+ */
83189
+ addCategoriesBatched(arg) {
83190
+ this._categories.addAll(_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Id64.iterable(arg));
83191
+ }
83192
+ /** Remove one or more categories from this CategorySelector, raising a single batch event instead of one event per category.
83193
+ * This is more efficient than [[dropCategories]] when dropping many categories at once.
83194
+ */
83195
+ dropCategoriesBatched(arg) {
83196
+ this._categories.deleteAll(_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Id64.iterable(arg));
83197
+ }
83118
83198
  /** Add or remove categories from this CategorySelector.
83119
83199
  * @param arg The categories to add or remove
83120
83200
  * @param add If true, categories will be added; otherwise they will be removed.
@@ -87053,7 +87133,7 @@ class CoordinateConverter {
87053
87133
  this._cache.set(requests[j], results[j]);
87054
87134
  }
87055
87135
  }).catch((err) => {
87056
- _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logException(`${_common_FrontendLoggerCategory__WEBPACK_IMPORTED_MODULE_2__.FrontendLoggerCategory.Package}.geoservices`, err);
87136
+ _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logError(`${_common_FrontendLoggerCategory__WEBPACK_IMPORTED_MODULE_2__.FrontendLoggerCategory.Package}.geoservices`, err);
87057
87137
  });
87058
87138
  promises.push(promise);
87059
87139
  }
@@ -89585,72 +89665,7 @@ class SnapshotConnection extends IModelConnection {
89585
89665
  /** The collection of loaded ModelState objects for an [[IModelConnection]]. */
89586
89666
  class Models {
89587
89667
  _iModel;
89588
- _modelExtentsQuery = `
89589
- SELECT
89590
- Model.Id AS ECInstanceId,
89591
- iModel_bbox_union(
89592
- iModel_placement_aabb(
89593
- iModel_placement(
89594
- iModel_point(Origin.X, Origin.Y, 0),
89595
- iModel_angles(Rotation, 0, 0),
89596
- iModel_bbox(
89597
- BBoxLow.X, BBoxLow.Y, -1,
89598
- BBoxHigh.X, BBoxHigh.Y, 1
89599
- )
89600
- )
89601
- )
89602
- ) AS bbox
89603
- FROM bis.GeometricElement2d
89604
- WHERE InVirtualSet(:ids64, Model.Id) AND Origin.X IS NOT NULL
89605
- GROUP BY Model.Id
89606
- UNION
89607
- SELECT
89608
- ge.Model.Id AS ECInstanceId,
89609
- iModel_bbox(
89610
- min(i.MinX), min(i.MinY), min(i.MinZ),
89611
- max(i.MaxX), max(i.MaxY), max(i.MaxZ)
89612
- ) AS bbox
89613
- FROM bis.SpatialIndex AS i, bis.GeometricElement3d AS ge, bis.GeometricModel3d AS gm
89614
- WHERE InVirtualSet(:ids64, ge.Model.Id) AND ge.ECInstanceId=i.ECInstanceId AND InVirtualSet(:ids64, gm.ECInstanceId) AND (gm.$->isNotSpatiallyLocated?=false OR gm.$->isNotSpatiallyLocated? IS NULL)
89615
- GROUP BY ge.Model.Id
89616
- UNION
89617
- SELECT
89618
- ge.Model.Id AS ECInstanceId,
89619
- iModel_bbox_union(
89620
- iModel_placement_aabb(
89621
- iModel_placement(
89622
- iModel_point(ge.Origin.X, ge.Origin.Y, ge.Origin.Z),
89623
- iModel_angles(ge.Yaw, ge.Pitch, ge.Roll),
89624
- iModel_bbox(
89625
- ge.BBoxLow.X, ge.BBoxLow.Y, ge.BBoxLow.Z,
89626
- ge.BBoxHigh.X, ge.BBoxHigh.Y, ge.BBoxHigh.Z
89627
- )
89628
- )
89629
- )
89630
- ) AS bbox
89631
- FROM bis.GeometricElement3d AS ge, bis.GeometricModel3d as gm
89632
- WHERE InVirtualSet(:ids64, ge.Model.Id) AND ge.Origin.X IS NOT NULL AND InVirtualSet(:ids64, gm.ECInstanceId) AND gm.$->isNotSpatiallyLocated?=true
89633
- GROUP BY ge.Model.Id`;
89634
- _modelExistenceQuery = `
89635
- WITH
89636
- GeometricModels AS(
89637
- SELECT
89638
- ECInstanceId
89639
- FROM bis.GeometricModel
89640
- WHERE InVirtualSet(: ids64, ECInstanceId)
89641
- )
89642
- SELECT
89643
- ECInstanceId,
89644
- true AS isGeometricModel
89645
- FROM GeometricModels
89646
- UNION ALL
89647
- SELECT
89648
- ECInstanceId,
89649
- false AS isGeometricModel
89650
- FROM bis.Model
89651
- WHERE InVirtualSet(: ids64, ECInstanceId)
89652
- AND ECInstanceId NOT IN(SELECT ECInstanceId FROM GeometricModels)`;
89653
- _loadedExtents = [];
89668
+ _loadedExtents = new Map();
89654
89669
  _geometryChangedListener;
89655
89670
  _loaded = new Map();
89656
89671
  /** @internal */
@@ -89665,7 +89680,9 @@ class SnapshotConnection extends IModelConnection {
89665
89680
  IModelConnection.onOpen.addListener(() => {
89666
89681
  if (this._iModel.isBriefcaseConnection()) {
89667
89682
  this._geometryChangedListener = (changes) => {
89668
- this._loadedExtents = this._loadedExtents.filter((extent) => !changes.some((change) => change.id === extent.id));
89683
+ changes.forEach((change) => {
89684
+ this._loadedExtents.delete(change.id);
89685
+ });
89669
89686
  };
89670
89687
  this._iModel.txns.onModelGeometryChanged.addListener(this._geometryChangedListener);
89671
89688
  }
@@ -89769,64 +89786,132 @@ class SnapshotConnection extends IModelConnection {
89769
89786
  return [];
89770
89787
  if (typeof modelIds === "string")
89771
89788
  modelIds = [modelIds];
89772
- const modelExtents = [];
89789
+ const resolvedExtents = new Map();
89790
+ const uncachedModelIds = [];
89791
+ // Add the cached model ids and the invalid ids
89773
89792
  for (const modelId of modelIds) {
89774
- if (!_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Id64.isValidId64(modelId)) {
89775
- modelExtents.push({ id: modelId, extents: _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_2__.Range3d.createNull(), status: _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.IModelStatus.InvalidId });
89793
+ if (this._loadedExtents.has(modelId)) {
89794
+ resolvedExtents.set(modelId, this._loadedExtents.get(modelId));
89776
89795
  }
89777
- }
89778
- const getUnloadedModelIds = () => modelIds.filter((modelId) => !modelExtents.some((loadedExtent) => loadedExtent.id === modelId));
89779
- let remainingModelIds = getUnloadedModelIds();
89780
- for (const modelId of remainingModelIds) {
89781
- const modelExtent = this._loadedExtents.find((extent) => modelId === extent.id);
89782
- if (modelExtent) {
89783
- modelExtents.push(modelExtent);
89796
+ else if (!_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Id64.isValidId64(modelId)) {
89797
+ resolvedExtents.set(modelId, { id: modelId, extents: _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_2__.Range3d.createNull(), status: _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.IModelStatus.InvalidId });
89784
89798
  }
89785
- }
89786
- remainingModelIds = getUnloadedModelIds();
89787
- if (remainingModelIds.length > 0) {
89788
- const params = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_1__.QueryBinder();
89789
- params.bindIdSet("ids64", remainingModelIds);
89790
- const extentsQueryReader = this._iModel.createQueryReader(this._modelExtentsQuery, params, {
89799
+ else {
89800
+ uncachedModelIds.push(modelId);
89801
+ }
89802
+ }
89803
+ // Run the ECSql to get uncached model extents
89804
+ if (uncachedModelIds.length > 0) {
89805
+ const modelList = uncachedModelIds.join(",");
89806
+ const useSingleModelQuery = uncachedModelIds.length === 1;
89807
+ const modelExtentsQuery = `
89808
+ SELECT
89809
+ Model.Id AS ECInstanceId,
89810
+ iModel_bbox_union(
89811
+ iModel_placement_aabb(
89812
+ iModel_placement(
89813
+ iModel_point(Origin.X, Origin.Y, 0),
89814
+ iModel_angles(Rotation, 0, 0),
89815
+ iModel_bbox(
89816
+ BBoxLow.X, BBoxLow.Y, -1,
89817
+ BBoxHigh.X, BBoxHigh.Y, 1
89818
+ )
89819
+ )
89820
+ )
89821
+ ) AS bbox
89822
+ FROM bis.GeometricElement2d
89823
+ WHERE Model.Id ${useSingleModelQuery ? `= ${uncachedModelIds[0]}` : `IN (${modelList})`}
89824
+ AND Origin.X IS NOT NULL
89825
+ GROUP BY Model.Id
89826
+
89827
+ UNION
89828
+
89829
+ SELECT
89830
+ ge.Model.Id AS ECInstanceId,
89831
+ iModel_bbox(
89832
+ min(i.MinX), min(i.MinY), min(i.MinZ),
89833
+ max(i.MaxX), max(i.MaxY), max(i.MaxZ)
89834
+ ) AS bbox
89835
+ FROM bis.SpatialIndex AS i
89836
+ INNER JOIN bis.GeometricElement3d AS ge
89837
+ ON ge.ECInstanceId = i.ECInstanceId
89838
+ INNER JOIN bis.GeometricModel3d AS gm
89839
+ ON ge.Model.Id = gm.ECInstanceId
89840
+ WHERE ge.Model.Id ${useSingleModelQuery ? `= ${uncachedModelIds[0]}` : `IN (${modelList})`}
89841
+ AND (gm.$->IsNotSpatiallyLocated? IS NULL OR gm.$->IsNotSpatiallyLocated? IS FALSE)
89842
+ GROUP BY ge.Model.Id
89843
+
89844
+ UNION
89845
+
89846
+ SELECT
89847
+ ge.Model.Id AS ECInstanceId,
89848
+ iModel_bbox_union(
89849
+ iModel_placement_aabb(
89850
+ iModel_placement(
89851
+ iModel_point(ge.Origin.X, ge.Origin.Y, ge.Origin.Z),
89852
+ iModel_angles(ge.Yaw, ge.Pitch, ge.Roll),
89853
+ iModel_bbox(
89854
+ ge.BBoxLow.X, ge.BBoxLow.Y, ge.BBoxLow.Z,
89855
+ ge.BBoxHigh.X, ge.BBoxHigh.Y, ge.BBoxHigh.Z
89856
+ )
89857
+ )
89858
+ )
89859
+ ) AS bbox
89860
+ FROM bis.GeometricElement3d ge
89861
+ INNER JOIN bis.GeometricModel3d gm
89862
+ ON ge.Model.Id = gm.ECInstanceId
89863
+ WHERE ge.Model.Id ${useSingleModelQuery ? `= ${uncachedModelIds[0]}` : `IN (${modelList})`}
89864
+ AND gm.$->IsNotSpatiallyLocated? IS TRUE
89865
+ AND ge.Origin.X IS NOT NULL
89866
+ GROUP BY ge.Model.Id
89867
+ `;
89868
+ const extentsQueryReader = this._iModel.createQueryReader(modelExtentsQuery, undefined, {
89791
89869
  rowFormat: _itwin_core_common__WEBPACK_IMPORTED_MODULE_1__.QueryRowFormat.UseECSqlPropertyNames,
89792
89870
  });
89793
89871
  for await (const row of extentsQueryReader) {
89794
89872
  const byteArray = new Uint8Array(Object.values(row.bbox));
89795
89873
  const extents = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_2__.Range3d.fromArrayBuffer(byteArray.buffer);
89796
89874
  const extent = { id: row.ECInstanceId, extents, status: _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.IModelStatus.Success };
89797
- modelExtents.push(extent);
89798
- this._loadedExtents.push(extent);
89799
- }
89800
- }
89801
- remainingModelIds = getUnloadedModelIds();
89802
- if (remainingModelIds.length > 0) {
89803
- const params = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_1__.QueryBinder();
89804
- params.bindIdSet("ids64", remainingModelIds);
89805
- const modelExistenceQueryReader = this._iModel.createQueryReader(this._modelExistenceQuery, params, {
89875
+ resolvedExtents.set(extent.id, extent);
89876
+ this._loadedExtents.set(extent.id, extent);
89877
+ }
89878
+ }
89879
+ // Check if there still are any unresolved model IDs
89880
+ const unresolvedModelIds = uncachedModelIds.filter((id) => !resolvedExtents.has(id));
89881
+ if (unresolvedModelIds.length > 0) {
89882
+ const modelList = unresolvedModelIds.join(",");
89883
+ const modelExistenceQuery = `
89884
+ SELECT
89885
+ m.ECInstanceId,
89886
+ CASE WHEN g.ECInstanceId IS NOT NULL THEN 1 ELSE 0 END AS isGeometricModel
89887
+ FROM bis.Model m
89888
+ LEFT JOIN bis.GeometricModel g
89889
+ ON m.ECInstanceId = g.ECInstanceId
89890
+ WHERE m.ECInstanceId ${unresolvedModelIds.length === 1 ? `= ${unresolvedModelIds[0]}` : `IN (${modelList})`}
89891
+ `;
89892
+ const modelExistenceQueryReader = this._iModel.createQueryReader(modelExistenceQuery, undefined, {
89806
89893
  rowFormat: _itwin_core_common__WEBPACK_IMPORTED_MODULE_1__.QueryRowFormat.UseECSqlPropertyNames,
89807
89894
  });
89808
89895
  for await (const row of modelExistenceQueryReader) {
89809
- let extent;
89810
- if (row.isGeometricModel) {
89811
- extent = { id: row.ECInstanceId, extents: _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_2__.Range3d.createNull(), status: _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.IModelStatus.Success };
89812
- }
89813
- else {
89814
- extent = { id: row.ECInstanceId, extents: _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_2__.Range3d.createNull(), status: _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.IModelStatus.WrongModel };
89815
- }
89816
- modelExtents.push(extent);
89817
- this._loadedExtents.push(extent);
89896
+ const extent = {
89897
+ id: row.ECInstanceId,
89898
+ extents: _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_2__.Range3d.createNull(),
89899
+ status: row.isGeometricModel ? _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.IModelStatus.Success : _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.IModelStatus.WrongModel,
89900
+ };
89901
+ resolvedExtents.set(extent.id, extent);
89902
+ this._loadedExtents.set(extent.id, extent);
89818
89903
  }
89819
89904
  }
89905
+ // Return the results while maintaining the same order
89820
89906
  return modelIds.map((modelId) => {
89821
- let extent = modelExtents.find((loadedExtent) => loadedExtent.id === modelId);
89907
+ const extent = resolvedExtents.get(modelId);
89822
89908
  if (extent === undefined) {
89823
- extent = { id: modelId, extents: _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_2__.Range3d.createNull(), status: _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.IModelStatus.NotFound };
89824
- this._loadedExtents.push(extent);
89825
- return extent;
89909
+ const notFound = { id: modelId, extents: _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_2__.Range3d.createNull(), status: _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.IModelStatus.NotFound };
89910
+ this._loadedExtents.set(notFound.id, notFound);
89911
+ return notFound;
89826
89912
  }
89827
- else if (extent.status === _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.IModelStatus.InvalidId) {
89828
- extent.id = "0";
89829
- return extent;
89913
+ if (extent.status === _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.IModelStatus.InvalidId) {
89914
+ return { ...extent, id: "0" };
89830
89915
  }
89831
89916
  return extent;
89832
89917
  });
@@ -98780,6 +98865,8 @@ class ViewState extends _EntityState__WEBPACK_IMPORTED_MODULE_5__.ElementState {
98780
98865
  this._unregisterCategorySelectorListeners.push(cats.onAdded.addListener(event));
98781
98866
  this._unregisterCategorySelectorListeners.push(cats.onDeleted.addListener(event));
98782
98867
  this._unregisterCategorySelectorListeners.push(cats.onCleared.addListener(event));
98868
+ this._unregisterCategorySelectorListeners.push(cats.onBatchAdded.addListener(event));
98869
+ this._unregisterCategorySelectorListeners.push(cats.onBatchDeleted.addListener(event));
98783
98870
  }
98784
98871
  /** Invoked when this view, previously attached to the specified [[Viewport]] via [[attachToViewport]], is no longer the view displayed by that Viewport.
98785
98872
  * This method is invoked automatically by the viewport - there is generally no reason for applications to invoke it directly.
@@ -100806,13 +100893,20 @@ class Viewport {
100806
100893
  * @param categories The Id(s) of the categories to which the change should be applied. No other categories will be affected.
100807
100894
  * @param display Whether or not elements on the specified categories should be displayed in the viewport.
100808
100895
  * @param enableAllSubCategories Specifies that when enabling display for a category, all of its subcategories should also be displayed even if they are overridden to be invisible.
100896
+ * @param batchNotify If true, a single batch event is raised instead of one event per category. This is more efficient when changing many categories at once.
100809
100897
  */
100810
- changeCategoryDisplay(categories, display, enableAllSubCategories = false) {
100898
+ changeCategoryDisplay(categories, display, enableAllSubCategories = false, batchNotify = false) {
100811
100899
  if (!display) {
100812
- this.view.categorySelector.dropCategories(categories);
100900
+ if (batchNotify)
100901
+ this.view.categorySelector.dropCategoriesBatched(categories);
100902
+ else
100903
+ this.view.categorySelector.dropCategories(categories);
100813
100904
  return;
100814
100905
  }
100815
- this.view.categorySelector.addCategories(categories);
100906
+ if (batchNotify)
100907
+ this.view.categorySelector.addCategoriesBatched(categories);
100908
+ else
100909
+ this.view.categorySelector.addCategories(categories);
100816
100910
  const categoryIds = _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Id64.toIdSet(categories);
100817
100911
  this.updateSubCategories(categoryIds, enableAllSubCategories);
100818
100912
  }
@@ -149481,7 +149575,7 @@ async function getDecoder() {
149481
149575
  instance.exports.__wasm_call_ctors();
149482
149576
  }
149483
149577
  catch (err) {
149484
- _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logException(_common_FrontendLoggerCategory__WEBPACK_IMPORTED_MODULE_1__.FrontendLoggerCategory.Render, err);
149578
+ _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logError(_common_FrontendLoggerCategory__WEBPACK_IMPORTED_MODULE_1__.FrontendLoggerCategory.Render, err);
149485
149579
  return undefined;
149486
149580
  }
149487
149581
  function unpack(data) {
@@ -150290,7 +150384,7 @@ async function decodeDracoPointCloud(buf) {
150290
150384
  }
150291
150385
  catch (err) {
150292
150386
  _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logWarning(_common_FrontendLoggerCategory__WEBPACK_IMPORTED_MODULE_3__.FrontendLoggerCategory.Render, "Failed to decode draco-encoded point cloud");
150293
- _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logException(_common_FrontendLoggerCategory__WEBPACK_IMPORTED_MODULE_3__.FrontendLoggerCategory.Render, err);
150387
+ _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logError(_common_FrontendLoggerCategory__WEBPACK_IMPORTED_MODULE_3__.FrontendLoggerCategory.Render, err);
150294
150388
  return undefined;
150295
150389
  }
150296
150390
  }
@@ -162578,7 +162672,7 @@ class GltfReader {
162578
162672
  }
162579
162673
  catch (err) {
162580
162674
  _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logWarning(_common_FrontendLoggerCategory__WEBPACK_IMPORTED_MODULE_9__.FrontendLoggerCategory.Render, "Failed to decode draco-encoded glTF mesh");
162581
- _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logException(_common_FrontendLoggerCategory__WEBPACK_IMPORTED_MODULE_9__.FrontendLoggerCategory.Render, err);
162675
+ _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logError(_common_FrontendLoggerCategory__WEBPACK_IMPORTED_MODULE_9__.FrontendLoggerCategory.Render, err);
162582
162676
  }
162583
162677
  }
162584
162678
  async _resolveResources() {
@@ -190153,7 +190247,7 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
190153
190247
  * @param result optional pre-allocated detail to populate and return.
190154
190248
  * @returns details of the closest point.
190155
190249
  */
190156
- closestPoint(spacePoint, _extend, result) {
190250
+ closestPoint(spacePoint, _extend = false, result) {
190157
190251
  // seed at start point; final point comes with final bezier perpendicular step
190158
190252
  const point = this.fractionToPoint(0);
190159
190253
  result = _curve_CurveLocationDetail__WEBPACK_IMPORTED_MODULE_3__.CurveLocationDetail.createCurveFractionPointDistance(this, 0.0, point, point.distance(spacePoint), result);
@@ -197387,7 +197481,8 @@ class ClipShape extends ClipPrimitive {
197387
197481
  }
197388
197482
  /**
197389
197483
  * Return true if this ClipShape has a local to world transform
197390
- * @deprecated in 5.1.9 - will not be removed until after 2027-01-05. Use duplicate property [[transformValid]] or type guard [[hasTransformFromClip]] instead.
197484
+ * @deprecated in 5.1.9 - will not be removed until after 2027-01-05. Use duplicate property [[transformValid]] or
197485
+ * type guard [[hasTransformFromClip]] instead.
197391
197486
  */
197392
197487
  get transformIsValid() {
197393
197488
  return this._transformFromClip !== undefined;
@@ -202155,48 +202250,61 @@ class Arc3d extends _CurvePrimitive__WEBPACK_IMPORTED_MODULE_1__.CurvePrimitive
202155
202250
  /**
202156
202251
  * Return details of the closest point on the arc, optionally extending to full ellipse.
202157
202252
  * @param spacePoint search for point closest to this point.
202158
- * @param extend if true, consider projections to the complete ellipse. If false, consider only endpoints and
202159
- * projections within the arc sweep.
202253
+ * @param extend if true, consider projections to the complete ellipse. If false (default), consider only endpoints
202254
+ * and projections within the arc sweep. Note that for an open arc, extending one end is the same as extending both ends.
202160
202255
  * @param result optional preallocated result.
202161
202256
  */
202162
- closestPoint(spacePoint, extend, result) {
202257
+ closestPoint(spacePoint, extend = false, result) {
202163
202258
  result = _CurveLocationDetail__WEBPACK_IMPORTED_MODULE_12__.CurveLocationDetail.create(this, result);
202164
- const allRadians = this.allPerpendicularAngles(spacePoint, true, true);
202165
- let extend0 = _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 0);
202166
- let extend1 = _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 1);
202167
- // distinct extends for cyclic space are awkward ....
202168
- if (this._sweep.isFullCircle) {
202169
- extend0 = _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendMode.None;
202170
- extend1 = _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendMode.None;
202171
- }
202172
- if (extend0 !== _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendMode.None && extend1 !== _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendMode.None) {
202173
- allRadians.push(this._sweep.startRadians);
202174
- allRadians.push(this._sweep.endRadians);
202175
- }
202176
- // hm... logically there must at least two angles there ... but if it happens return the start point ...
202259
+ const allRadians = this.allPerpendicularAngles(spacePoint, true, false);
202260
+ // test endpoints if and only if arc is open and unextended
202261
+ if (!this._sweep.isFullCircle) {
202262
+ const extend0 = _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 0);
202263
+ const extend1 = _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 1);
202264
+ if (extend0 === _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendMode.None && extend1 === _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendMode.None) {
202265
+ allRadians.push(this._sweep.startRadians);
202266
+ allRadians.push(this._sweep.endRadians);
202267
+ }
202268
+ }
202177
202269
  const workRay = _geometry3d_Ray3d__WEBPACK_IMPORTED_MODULE_3__.Ray3d.createZero();
202178
- if (allRadians.length === 0) {
202179
- result.setFR(0.0, this.radiansToPointAndDerivative(this._sweep.startRadians, workRay));
202180
- result.a = spacePoint.distance(result.point);
202270
+ if (allRadians.length === 0) { // shouldn't happen; there should always be at least 2 angles
202271
+ result.setFR(0.0, this.radiansToPointAndDerivative(this._sweep.startRadians, workRay), spacePoint.distance(result.point));
202181
202272
  }
202182
202273
  else {
202183
202274
  let dMin = Number.MAX_VALUE;
202184
202275
  let d = 0;
202185
202276
  for (const radians of allRadians) {
202186
- const fraction = _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendOptions.resolveRadiansToSweepFraction(extend, radians, this.sweep);
202187
- if (fraction !== undefined) {
202188
- this.fractionToPointAndDerivative(fraction, workRay);
202277
+ const validatedFraction = _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendOptions.resolveRadiansToValidSweepFraction(extend, radians, this.sweep);
202278
+ if (validatedFraction.isValid) {
202279
+ this.fractionToPointAndDerivative(validatedFraction.fraction, workRay);
202189
202280
  d = spacePoint.distance(workRay.origin);
202190
202281
  if (d < dMin) {
202191
202282
  dMin = d;
202192
- result.setFR(fraction, workRay);
202193
- result.a = d;
202283
+ result.setFR(validatedFraction.fraction, workRay, d);
202194
202284
  }
202195
202285
  }
202196
202286
  }
202197
202287
  }
202198
202288
  return result;
202199
202289
  }
202290
+ /**
202291
+ * Search for a point on the Arc3d that is closest to the spacePoint as viewed in the xy-plane (ignoring z).
202292
+ * * If the space point is exactly on the curve, this is the reverse of fractionToPoint.
202293
+ * * Since CurvePrimitive should always have start and end available as candidate points, this method should always
202294
+ * succeed.
202295
+ * @param spacePoint point in space.
202296
+ * @param extend if true, consider projections to the complete ellipse. If false (default), consider only endpoints
202297
+ * and projections within the arc sweep. Note that for an open arc, extending one end is the same as extending both ends.
202298
+ * @param result (optional) pre-allocated detail to populate and return.
202299
+ * @returns details of the closest point.
202300
+ */
202301
+ closestPointXY(spacePoint, extend = false, result) {
202302
+ // prevent `ClosestPointStroker.claimResult` from clamping an exterior fraction when arc is half-extended
202303
+ const extend0 = _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 0);
202304
+ const extend1 = _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 1);
202305
+ extend = extend0 !== _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendMode.None || extend1 !== _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendMode.None;
202306
+ return super.closestPointXY(spacePoint, extend, result); // TODO: implement exact solution instead of deferring to superclass
202307
+ }
202200
202308
  /** Override of [[CurvePrimitive.emitTangents]] for Arc3d. */
202201
202309
  emitTangents(spacePoint, announceTangent, options) {
202202
202310
  const centerToPoint = _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_2__.Vector3d.createStartEnd(this.centerRef, spacePoint);
@@ -203743,23 +203851,14 @@ class CurveChainWithDistanceIndex extends _curve_CurvePrimitive__WEBPACK_IMPORTE
203743
203851
  }
203744
203852
  return a;
203745
203853
  }
203746
- /**
203747
- * Search for the curve point that is closest to the spacePoint.
203748
- * * The CurveChainWithDistanceIndex invokes the base class CurvePrimitive method, which (via a handler)
203749
- * determines a CurveLocation detail among the children.
203750
- * * The returned detail directly identifies fractional position along the CurveChainWithDistanceIndex and
203751
- * has pointer to an additional detail for the child curve.
203752
- * @param spacePoint point in space
203753
- * @param extend true to extend the curve
203754
- * @param result optional pre-allocated detail to populate and return.
203755
- * @returns details of the closest point
203756
- */
203757
- closestPoint(spacePoint, extend, result) {
203854
+ computeClosestPoint(spacePoint, extend = false, result, xyOnly = false) {
203758
203855
  let childDetail;
203759
203856
  let aMin = Number.MAX_VALUE;
203760
203857
  const numChildren = this.path.children.length;
203761
203858
  if (numChildren === 1) {
203762
- childDetail = this.path.children[0].closestPoint(spacePoint, extend);
203859
+ childDetail = xyOnly ?
203860
+ this.path.children[0].closestPointXY(spacePoint, extend) :
203861
+ this.path.children[0].closestPoint(spacePoint, extend);
203763
203862
  }
203764
203863
  else {
203765
203864
  const sortedFragments = PathFragment.collectSortedQuickMinDistances(this._fragments, spacePoint);
@@ -203783,7 +203882,8 @@ class CurveChainWithDistanceIndex extends _curve_CurvePrimitive__WEBPACK_IMPORTE
203783
203882
  break;
203784
203883
  CurveChainWithDistanceIndex._numTested++;
203785
203884
  const child = sortedFragment.childCurve;
203786
- detailA = child.closestPoint(spacePoint, sortedFragment === fragment0 ? extend0 : sortedFragment === fragment1 ? extend1 : false, detailA);
203885
+ extend = child === fragment0.childCurve ? extend0 : (child === fragment1.childCurve ? extend1 : false);
203886
+ detailA = xyOnly ? child.closestPointXY(spacePoint, extend, detailA) : child.closestPoint(spacePoint, extend, detailA);
203787
203887
  if (detailA && detailA.a < aMin) {
203788
203888
  aMin = detailA.a;
203789
203889
  childDetail = detailA.clone(childDetail);
@@ -203795,6 +203895,34 @@ class CurveChainWithDistanceIndex extends _curve_CurvePrimitive__WEBPACK_IMPORTE
203795
203895
  return undefined;
203796
203896
  return this.computeChainDetail(childDetail, result);
203797
203897
  }
203898
+ /**
203899
+ * Search for the curve point that is closest to the spacePoint.
203900
+ * * The CurveChainWithDistanceIndex invokes the base class CurvePrimitive method, which (via a handler)
203901
+ * determines a CurveLocation detail among the children.
203902
+ * * The returned detail directly identifies fractional position along the CurveChainWithDistanceIndex and
203903
+ * has pointer to an additional detail for the child curve.
203904
+ * @param spacePoint point in space.
203905
+ * @param extend (optional) compute the closest point to the curve extended according to variant type (default false).
203906
+ * @param result (optional) pre-allocated detail to populate and return.
203907
+ * @returns details of the closest point.
203908
+ */
203909
+ closestPoint(spacePoint, extend = false, result) {
203910
+ return this.computeClosestPoint(spacePoint, extend, result);
203911
+ }
203912
+ /**
203913
+ * Search for the curve point that is closest to the spacePoint as viewed in the xy-plane (ignoring z).
203914
+ * * The CurveChainWithDistanceIndex invokes the base class CurvePrimitive method, which (via a handler)
203915
+ * determines a CurveLocation detail among the children.
203916
+ * * The returned detail directly identifies fractional position along the CurveChainWithDistanceIndex and
203917
+ * has pointer to an additional detail for the child curve.
203918
+ * @param spacePoint point in space.
203919
+ * @param extend (optional) compute the closest point to the curve extended according to variant type (default false).
203920
+ * @param result (optional) pre-allocated detail to populate and return.
203921
+ * @returns details of the closest point.
203922
+ */
203923
+ closestPointXY(spacePoint, extend = false, result) {
203924
+ return this.computeClosestPoint(spacePoint, extend, result, true);
203925
+ }
203798
203926
  /**
203799
203927
  * Construct an offset of each child as viewed in the xy-plane (ignoring z).
203800
203928
  * * No attempt is made to join the offset children. Use RegionOps.constructCurveXYOffset to return a fully
@@ -203896,21 +204024,22 @@ __webpack_require__.r(__webpack_exports__);
203896
204024
  /* harmony export */ CurveCollection: () => (/* binding */ CurveCollection)
203897
204025
  /* harmony export */ });
203898
204026
  /* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
203899
- /* harmony import */ var _Geometry__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Geometry */ "../../core/geometry/lib/esm/Geometry.js");
203900
- /* harmony import */ var _geometry3d_Matrix3d__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../geometry3d/Matrix3d */ "../../core/geometry/lib/esm/geometry3d/Matrix3d.js");
204027
+ /* harmony import */ var _Geometry__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Geometry */ "../../core/geometry/lib/esm/Geometry.js");
204028
+ /* harmony import */ var _geometry3d_Matrix3d__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../geometry3d/Matrix3d */ "../../core/geometry/lib/esm/geometry3d/Matrix3d.js");
204029
+ /* harmony import */ var _CurveExtendMode__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./CurveExtendMode */ "../../core/geometry/lib/esm/curve/CurveExtendMode.js");
203901
204030
  /* harmony import */ var _CurveLocationDetail__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./CurveLocationDetail */ "../../core/geometry/lib/esm/curve/CurveLocationDetail.js");
203902
- /* harmony import */ var _CurvePrimitive__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./CurvePrimitive */ "../../core/geometry/lib/esm/curve/CurvePrimitive.js");
204031
+ /* harmony import */ var _CurvePrimitive__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./CurvePrimitive */ "../../core/geometry/lib/esm/curve/CurvePrimitive.js");
203903
204032
  /* harmony import */ var _GeometryQuery__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./GeometryQuery */ "../../core/geometry/lib/esm/curve/GeometryQuery.js");
203904
- /* harmony import */ var _internalContexts_AnnounceTangentStrokeHandler__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./internalContexts/AnnounceTangentStrokeHandler */ "../../core/geometry/lib/esm/curve/internalContexts/AnnounceTangentStrokeHandler.js");
203905
- /* harmony import */ var _internalContexts_CloneCurvesContext__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./internalContexts/CloneCurvesContext */ "../../core/geometry/lib/esm/curve/internalContexts/CloneCurvesContext.js");
203906
- /* harmony import */ var _internalContexts_CloneWithExpandedLineStrings__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./internalContexts/CloneWithExpandedLineStrings */ "../../core/geometry/lib/esm/curve/internalContexts/CloneWithExpandedLineStrings.js");
203907
- /* harmony import */ var _internalContexts_CountLinearPartsSearchContext__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./internalContexts/CountLinearPartsSearchContext */ "../../core/geometry/lib/esm/curve/internalContexts/CountLinearPartsSearchContext.js");
203908
- /* harmony import */ var _internalContexts_GapSearchContext__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./internalContexts/GapSearchContext */ "../../core/geometry/lib/esm/curve/internalContexts/GapSearchContext.js");
203909
- /* harmony import */ var _internalContexts_PlaneAltitudeRangeContext__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./internalContexts/PlaneAltitudeRangeContext */ "../../core/geometry/lib/esm/curve/internalContexts/PlaneAltitudeRangeContext.js");
204033
+ /* harmony import */ var _internalContexts_AnnounceTangentStrokeHandler__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./internalContexts/AnnounceTangentStrokeHandler */ "../../core/geometry/lib/esm/curve/internalContexts/AnnounceTangentStrokeHandler.js");
204034
+ /* harmony import */ var _internalContexts_CloneCurvesContext__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./internalContexts/CloneCurvesContext */ "../../core/geometry/lib/esm/curve/internalContexts/CloneCurvesContext.js");
204035
+ /* harmony import */ var _internalContexts_CloneWithExpandedLineStrings__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./internalContexts/CloneWithExpandedLineStrings */ "../../core/geometry/lib/esm/curve/internalContexts/CloneWithExpandedLineStrings.js");
204036
+ /* harmony import */ var _internalContexts_CountLinearPartsSearchContext__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./internalContexts/CountLinearPartsSearchContext */ "../../core/geometry/lib/esm/curve/internalContexts/CountLinearPartsSearchContext.js");
204037
+ /* harmony import */ var _internalContexts_GapSearchContext__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./internalContexts/GapSearchContext */ "../../core/geometry/lib/esm/curve/internalContexts/GapSearchContext.js");
204038
+ /* harmony import */ var _internalContexts_PlaneAltitudeRangeContext__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./internalContexts/PlaneAltitudeRangeContext */ "../../core/geometry/lib/esm/curve/internalContexts/PlaneAltitudeRangeContext.js");
203910
204039
  /* harmony import */ var _internalContexts_SumLengthsContext__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./internalContexts/SumLengthsContext */ "../../core/geometry/lib/esm/curve/internalContexts/SumLengthsContext.js");
203911
- /* harmony import */ var _internalContexts_TransformInPlaceContext__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./internalContexts/TransformInPlaceContext */ "../../core/geometry/lib/esm/curve/internalContexts/TransformInPlaceContext.js");
203912
- /* harmony import */ var _LineString3d__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./LineString3d */ "../../core/geometry/lib/esm/curve/LineString3d.js");
203913
- /* harmony import */ var _ProxyCurve__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ProxyCurve */ "../../core/geometry/lib/esm/curve/ProxyCurve.js");
204040
+ /* harmony import */ var _internalContexts_TransformInPlaceContext__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./internalContexts/TransformInPlaceContext */ "../../core/geometry/lib/esm/curve/internalContexts/TransformInPlaceContext.js");
204041
+ /* harmony import */ var _LineString3d__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./LineString3d */ "../../core/geometry/lib/esm/curve/LineString3d.js");
204042
+ /* harmony import */ var _ProxyCurve__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ProxyCurve */ "../../core/geometry/lib/esm/curve/ProxyCurve.js");
203914
204043
  /*---------------------------------------------------------------------------------------------
203915
204044
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
203916
204045
  * See LICENSE.md in the project root for license terms and full copyright notice.
@@ -203934,6 +204063,7 @@ __webpack_require__.r(__webpack_exports__);
203934
204063
 
203935
204064
 
203936
204065
 
204066
+
203937
204067
  /**
203938
204068
  * A `CurveCollection` is an abstract (non-instantiable) class for various sets of curves with particular structures:
203939
204069
  * - [[CurveChain]] - a non-instantiable intermediate class for a sequence of [[CurvePrimitive]] joining head-to-tail.
@@ -203956,27 +204086,47 @@ class CurveCollection extends _GeometryQuery__WEBPACK_IMPORTED_MODULE_1__.Geomet
203956
204086
  sumLengths() {
203957
204087
  return _internalContexts_SumLengthsContext__WEBPACK_IMPORTED_MODULE_2__.SumLengthsContext.sumLengths(this);
203958
204088
  }
203959
- /**
203960
- * Return the closest point on the contained curves.
203961
- * @param spacePoint point in space.
203962
- * @param _extend unused here (pass false), but applicable to overrides in [[Path]] and [[BagOfCurves]].
203963
- * @param result optional pre-allocated detail to populate and return.
203964
- * @returns details of the closest point.
203965
- */
203966
- closestPoint(spacePoint, _extend = false, result) {
204089
+ computeClosestPoint(spacePoint, extend = false, result, xyOnly = false) {
203967
204090
  let detailA;
203968
204091
  const detailB = new _CurveLocationDetail__WEBPACK_IMPORTED_MODULE_3__.CurveLocationDetail();
203969
- if (this.children !== undefined) {
203970
- for (const child of this.children) {
203971
- if (child.closestPoint(spacePoint, false, detailB)) {
203972
- const smaller = _CurveLocationDetail__WEBPACK_IMPORTED_MODULE_3__.CurveLocationDetail.chooseSmallerA(detailA, detailB);
203973
- (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(undefined !== smaller, "expect defined because detailB is always defined");
203974
- detailA = result = smaller.clone(result);
203975
- }
204092
+ let ext = this.isAnyRegion() ? false : extend;
204093
+ for (let i = 0; i < this.children.length; i++) {
204094
+ const child = this.children[i];
204095
+ if (this.isPath()) {
204096
+ // head only extends at start; tail only at end. NOTE: child may be both head and tail!
204097
+ const mode0 = (i === 0) ? _CurveExtendMode__WEBPACK_IMPORTED_MODULE_4__.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 0) : _CurveExtendMode__WEBPACK_IMPORTED_MODULE_4__.CurveExtendMode.None;
204098
+ const mode1 = (i === this.children.length - 1) ? _CurveExtendMode__WEBPACK_IMPORTED_MODULE_4__.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 1) : _CurveExtendMode__WEBPACK_IMPORTED_MODULE_4__.CurveExtendMode.None;
204099
+ ext = [mode0, mode1];
204100
+ }
204101
+ const cp = xyOnly ? child.closestPointXY(spacePoint, ext, detailB) : child.closestPoint(spacePoint, ext, detailB);
204102
+ if (cp) {
204103
+ const smaller = _CurveLocationDetail__WEBPACK_IMPORTED_MODULE_3__.CurveLocationDetail.chooseSmallerA(detailA, detailB);
204104
+ (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(undefined !== smaller, "expect defined because detailB is always defined");
204105
+ detailA = result = smaller.clone(result);
203976
204106
  }
203977
204107
  }
203978
204108
  return detailA;
203979
204109
  }
204110
+ /**
204111
+ * Return the closest point on the contained curves.
204112
+ * @param spacePoint point in space.
204113
+ * @param extend extend applicable only to [[Path]] and [[BagOfCurves]]. Default value `false`.
204114
+ * @param result (optional) pre-allocated detail to populate and return.
204115
+ * @returns details of the closest point.
204116
+ */
204117
+ closestPoint(spacePoint, extend = false, result) {
204118
+ return this.computeClosestPoint(spacePoint, extend, result);
204119
+ }
204120
+ /**
204121
+ * Return the closest point on the contained curves as viewed in the xy-plane (ignoring z).
204122
+ * @param spacePoint point in space.
204123
+ * @param extend (optional) extend applicable only to [[Path]] and [[BagOfCurves]]. Default value `false`.
204124
+ * @param result (optional) pre-allocated detail to populate and return.
204125
+ * @returns details of the closest point.
204126
+ */
204127
+ closestPointXY(spacePoint, extend = false, result) {
204128
+ return this.computeClosestPoint(spacePoint, extend, result, true);
204129
+ }
203980
204130
  /**
203981
204131
  * Announce all points `P` on the contained curves such that the line containing `spacePoint` and `P` is tangent to
203982
204132
  * the contained curves in the view defined by `options.vectorToEye`.
@@ -203989,10 +204139,10 @@ class CurveCollection extends _GeometryQuery__WEBPACK_IMPORTED_MODULE_1__.Geomet
203989
204139
  * @param options (optional) options for computing tangents. See [[TangentOptions]] for defaults.
203990
204140
  */
203991
204141
  emitTangents(spacePoint, announceTangent, options) {
203992
- const strokeHandler = new _internalContexts_AnnounceTangentStrokeHandler__WEBPACK_IMPORTED_MODULE_4__.AnnounceTangentStrokeHandler(spacePoint, announceTangent, options);
204142
+ const strokeHandler = new _internalContexts_AnnounceTangentStrokeHandler__WEBPACK_IMPORTED_MODULE_5__.AnnounceTangentStrokeHandler(spacePoint, announceTangent, options);
203993
204143
  if (this.children !== undefined) {
203994
204144
  for (const child of this.children) {
203995
- if (child instanceof _CurvePrimitive__WEBPACK_IMPORTED_MODULE_5__.CurvePrimitive)
204145
+ if (child instanceof _CurvePrimitive__WEBPACK_IMPORTED_MODULE_6__.CurvePrimitive)
203996
204146
  child.emitStrokableParts(strokeHandler, options?.strokeOptions);
203997
204147
  else if (child instanceof CurveCollection)
203998
204148
  child.emitTangents(spacePoint, announceTangent, options);
@@ -204024,12 +204174,12 @@ class CurveCollection extends _GeometryQuery__WEBPACK_IMPORTED_MODULE_1__.Geomet
204024
204174
  const hint = options?.hintPoint ?? spacePoint;
204025
204175
  let toLocal;
204026
204176
  if (options?.vectorToEye && !options.vectorToEye.isExactEqual({ x: 0, y: 0, z: 1 }))
204027
- toLocal = _geometry3d_Matrix3d__WEBPACK_IMPORTED_MODULE_6__.Matrix3d.createRigidViewAxesZTowardsEye(options.vectorToEye.x, options.vectorToEye.y, options.vectorToEye.z);
204177
+ toLocal = _geometry3d_Matrix3d__WEBPACK_IMPORTED_MODULE_7__.Matrix3d.createRigidViewAxesZTowardsEye(options.vectorToEye.x, options.vectorToEye.y, options.vectorToEye.z);
204028
204178
  const measureHintDist2 = (pt) => {
204029
204179
  return toLocal?.multiplyTransposeXYZ(hint.x - pt.x, hint.y - pt.y, hint.z - pt.z).magnitudeSquaredXY() ?? pt.distanceSquaredXY(hint);
204030
204180
  };
204031
204181
  let closestTangent;
204032
- let closestDist2 = _Geometry__WEBPACK_IMPORTED_MODULE_7__.Geometry.largeCoordinateResult;
204182
+ let closestDist2 = _Geometry__WEBPACK_IMPORTED_MODULE_8__.Geometry.largeCoordinateResult;
204033
204183
  const collectClosestTangent = (tangent) => {
204034
204184
  const dist2 = measureHintDist2(tangent.point);
204035
204185
  if (!closestTangent || dist2 < closestDist2) {
@@ -204053,27 +204203,27 @@ class CurveCollection extends _GeometryQuery__WEBPACK_IMPORTED_MODULE_1__.Geomet
204053
204203
  * "unstructured" so gaps should not be semantically meaningful.
204054
204204
  */
204055
204205
  maxGap() {
204056
- return _internalContexts_GapSearchContext__WEBPACK_IMPORTED_MODULE_8__.GapSearchContext.maxGap(this);
204206
+ return _internalContexts_GapSearchContext__WEBPACK_IMPORTED_MODULE_9__.GapSearchContext.maxGap(this);
204057
204207
  }
204058
204208
  /** Return true if the curve collection has any primitives other than LineSegment3d and LineString3d */
204059
204209
  checkForNonLinearPrimitives() {
204060
- return _internalContexts_CountLinearPartsSearchContext__WEBPACK_IMPORTED_MODULE_9__.CountLinearPartsSearchContext.hasNonLinearPrimitives(this);
204210
+ return _internalContexts_CountLinearPartsSearchContext__WEBPACK_IMPORTED_MODULE_10__.CountLinearPartsSearchContext.hasNonLinearPrimitives(this);
204061
204211
  }
204062
204212
  /** Apply transform recursively to children */
204063
204213
  tryTransformInPlace(transform) {
204064
- return _internalContexts_TransformInPlaceContext__WEBPACK_IMPORTED_MODULE_10__.TransformInPlaceContext.tryTransformInPlace(this, transform);
204214
+ return _internalContexts_TransformInPlaceContext__WEBPACK_IMPORTED_MODULE_11__.TransformInPlaceContext.tryTransformInPlace(this, transform);
204065
204215
  }
204066
204216
  /** Return a deep copy. */
204067
204217
  clone() {
204068
- return _internalContexts_CloneCurvesContext__WEBPACK_IMPORTED_MODULE_11__.CloneCurvesContext.clone(this);
204218
+ return _internalContexts_CloneCurvesContext__WEBPACK_IMPORTED_MODULE_12__.CloneCurvesContext.clone(this);
204069
204219
  }
204070
204220
  /** Create a deep copy of transformed curves. */
204071
204221
  cloneTransformed(transform) {
204072
- return _internalContexts_CloneCurvesContext__WEBPACK_IMPORTED_MODULE_11__.CloneCurvesContext.clone(this, transform);
204222
+ return _internalContexts_CloneCurvesContext__WEBPACK_IMPORTED_MODULE_12__.CloneCurvesContext.clone(this, transform);
204073
204223
  }
204074
204224
  /** Create a deep copy with all linestrings broken down into multiple LineSegment3d. */
204075
204225
  cloneWithExpandedLineStrings() {
204076
- return _internalContexts_CloneWithExpandedLineStrings__WEBPACK_IMPORTED_MODULE_12__.CloneWithExpandedLineStrings.clone(this);
204226
+ return _internalContexts_CloneWithExpandedLineStrings__WEBPACK_IMPORTED_MODULE_13__.CloneWithExpandedLineStrings.clone(this);
204077
204227
  }
204078
204228
  /**
204079
204229
  * Push all CurvePrimitives contained in the instance onto the `results` array.
@@ -204083,7 +204233,7 @@ class CurveCollection extends _GeometryQuery__WEBPACK_IMPORTED_MODULE_1__.Geomet
204083
204233
  collectCurvePrimitivesGo(results, smallestPossiblePrimitives, explodeLinestrings = false) {
204084
204234
  if (this.children) {
204085
204235
  for (const child of this.children) {
204086
- if (child instanceof _CurvePrimitive__WEBPACK_IMPORTED_MODULE_5__.CurvePrimitive)
204236
+ if (child instanceof _CurvePrimitive__WEBPACK_IMPORTED_MODULE_6__.CurvePrimitive)
204087
204237
  child.collectCurvePrimitivesGo(results, smallestPossiblePrimitives, explodeLinestrings);
204088
204238
  else if (child instanceof CurveCollection)
204089
204239
  child.collectCurvePrimitivesGo(results, smallestPossiblePrimitives, explodeLinestrings);
@@ -204163,7 +204313,7 @@ class CurveCollection extends _GeometryQuery__WEBPACK_IMPORTED_MODULE_1__.Geomet
204163
204313
  static createCurveLocationDetailOnAnyCurvePrimitive(source, fraction = 0.5) {
204164
204314
  if (!source)
204165
204315
  return undefined;
204166
- if (source instanceof _CurvePrimitive__WEBPACK_IMPORTED_MODULE_5__.CurvePrimitive) {
204316
+ if (source instanceof _CurvePrimitive__WEBPACK_IMPORTED_MODULE_6__.CurvePrimitive) {
204167
204317
  return _CurveLocationDetail__WEBPACK_IMPORTED_MODULE_3__.CurveLocationDetail.createCurveEvaluatedFraction(source, fraction);
204168
204318
  }
204169
204319
  else if (source instanceof CurveCollection && source.children !== undefined)
@@ -204183,7 +204333,7 @@ class CurveCollection extends _GeometryQuery__WEBPACK_IMPORTED_MODULE_1__.Geomet
204183
204333
  * end of the ray.
204184
204334
  */
204185
204335
  projectedParameterRange(ray, lowHigh) {
204186
- return _internalContexts_PlaneAltitudeRangeContext__WEBPACK_IMPORTED_MODULE_13__.PlaneAltitudeRangeContext.findExtremeFractionsAlongDirection(this, ray, lowHigh);
204336
+ return _internalContexts_PlaneAltitudeRangeContext__WEBPACK_IMPORTED_MODULE_14__.PlaneAltitudeRangeContext.findExtremeFractionsAlongDirection(this, ray, lowHigh);
204187
204337
  }
204188
204338
  /** Return the immediate parent of the input curve in the instance, or undefined if it is not a descendant. */
204189
204339
  findParentOfDescendant(descendant) {
@@ -204244,7 +204394,7 @@ class CurveChain extends CurveCollection {
204244
204394
  * @param tolerance optional distance tolerance (default is [[Geometry.smallMetricDistance]])
204245
204395
  * @param xyOnly if true, ignore z coordinate (default is `false`)
204246
204396
  */
204247
- isPhysicallyClosedCurve(tolerance = _Geometry__WEBPACK_IMPORTED_MODULE_7__.Geometry.smallMetricDistance, xyOnly = false) {
204397
+ isPhysicallyClosedCurve(tolerance = _Geometry__WEBPACK_IMPORTED_MODULE_8__.Geometry.smallMetricDistance, xyOnly = false) {
204248
204398
  const p0 = this.startPoint();
204249
204399
  const p1 = this.endPoint();
204250
204400
  return p0 !== undefined && p1 !== undefined && (xyOnly ? p0.isAlmostEqualXY(p1, tolerance) : p0.isAlmostEqual(p1, tolerance));
@@ -204284,7 +204434,7 @@ class CurveChain extends CurveCollection {
204284
204434
  if (index >= 0 && index < n) // try simplest non-cyclic access first
204285
204435
  return this.children[index];
204286
204436
  if (cyclic) {
204287
- const index2 = _Geometry__WEBPACK_IMPORTED_MODULE_7__.Geometry.modulo(index, n);
204437
+ const index2 = _Geometry__WEBPACK_IMPORTED_MODULE_8__.Geometry.modulo(index, n);
204288
204438
  return this.children[index2];
204289
204439
  }
204290
204440
  return undefined;
@@ -204304,7 +204454,7 @@ class CurveChain extends CurveCollection {
204304
204454
  const children = tree.children;
204305
204455
  if (children.length === 1) {
204306
204456
  const ls = children[0];
204307
- if (ls instanceof _LineString3d__WEBPACK_IMPORTED_MODULE_14__.LineString3d)
204457
+ if (ls instanceof _LineString3d__WEBPACK_IMPORTED_MODULE_15__.LineString3d)
204308
204458
  return ls.packedPoints;
204309
204459
  }
204310
204460
  }
@@ -204316,7 +204466,7 @@ class CurveChain extends CurveCollection {
204316
204466
  * @return whether the child was added
204317
204467
  */
204318
204468
  tryAddChild(child) {
204319
- if (child && child instanceof _CurvePrimitive__WEBPACK_IMPORTED_MODULE_5__.CurvePrimitive) {
204469
+ if (child && child instanceof _CurvePrimitive__WEBPACK_IMPORTED_MODULE_6__.CurvePrimitive) {
204320
204470
  this._curves.push(child);
204321
204471
  return true;
204322
204472
  }
@@ -204358,7 +204508,7 @@ class CurveChain extends CurveCollection {
204358
204508
  if (alsoSearchProxies ?? false) {
204359
204509
  for (let i = 0; i < this._curves.length; i++) {
204360
204510
  const childCurve = this._curves[i];
204361
- if (childCurve instanceof _ProxyCurve__WEBPACK_IMPORTED_MODULE_15__.ProxyCurve) {
204511
+ if (childCurve instanceof _ProxyCurve__WEBPACK_IMPORTED_MODULE_16__.ProxyCurve) {
204362
204512
  if (childCurve.proxyCurve === target)
204363
204513
  return i;
204364
204514
  }
@@ -204422,8 +204572,8 @@ class BagOfCurves extends CurveCollection {
204422
204572
  const clone = new BagOfCurves();
204423
204573
  let child;
204424
204574
  for (child of this.children) {
204425
- if (child instanceof _CurvePrimitive__WEBPACK_IMPORTED_MODULE_5__.CurvePrimitive) {
204426
- const ls = _LineString3d__WEBPACK_IMPORTED_MODULE_14__.LineString3d.create();
204575
+ if (child instanceof _CurvePrimitive__WEBPACK_IMPORTED_MODULE_6__.CurvePrimitive) {
204576
+ const ls = _LineString3d__WEBPACK_IMPORTED_MODULE_15__.LineString3d.create();
204427
204577
  child.emitStrokes(ls, options);
204428
204578
  if (ls)
204429
204579
  clone.children.push(ls);
@@ -204436,27 +204586,6 @@ class BagOfCurves extends CurveCollection {
204436
204586
  }
204437
204587
  return clone;
204438
204588
  }
204439
- /**
204440
- * Return the closest point on the contained curves.
204441
- * @param spacePoint point in space.
204442
- * @param extend applicable only to children of type [[CurvePrimitive]], [[Path]], or [[BagOfCurves]]
204443
- * @param result optional pre-allocated detail to populate and return.
204444
- * @returns details of the closest point.
204445
- */
204446
- closestPoint(spacePoint, extend = false, result) {
204447
- let detailA;
204448
- const detailB = new _CurveLocationDetail__WEBPACK_IMPORTED_MODULE_3__.CurveLocationDetail();
204449
- if (this.children !== undefined) {
204450
- for (const child of this.children) {
204451
- if (child.closestPoint(spacePoint, extend, detailB)) {
204452
- const smaller = _CurveLocationDetail__WEBPACK_IMPORTED_MODULE_3__.CurveLocationDetail.chooseSmallerA(detailA, detailB);
204453
- (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(undefined !== smaller, "expect defined because detailB is always defined");
204454
- detailA = result = smaller.clone(result);
204455
- }
204456
- }
204457
- }
204458
- return detailA;
204459
- }
204460
204589
  /** Return an empty `BagOfCurves` */
204461
204590
  cloneEmptyPeer() {
204462
204591
  return new BagOfCurves();
@@ -204654,7 +204783,7 @@ var CurveExtendMode;
204654
204783
  (function (CurveExtendMode) {
204655
204784
  /** No extension allowed. */
204656
204785
  CurveExtendMode[CurveExtendMode["None"] = 0] = "None";
204657
- /** Extend along continuation of the end tangent. */
204786
+ /** Extend along continuation of the end tangent. Not implemented. */
204658
204787
  CurveExtendMode[CurveExtendMode["OnTangent"] = 1] = "OnTangent";
204659
204788
  /** Extend along continuation of the curve. */
204660
204789
  CurveExtendMode[CurveExtendMode["OnCurve"] = 2] = "OnCurve";
@@ -204672,6 +204801,7 @@ class CurveExtendOptions {
204672
204801
  * * Return dereferenced array at entry `endIndex` if the param is an array of CurveExtendMode.
204673
204802
  */
204674
204803
  static resolveVariantCurveExtendParameterToCurveExtendMode(param, endIndex) {
204804
+ param ??= false;
204675
204805
  if (param === false)
204676
204806
  return CurveExtendMode.None;
204677
204807
  if (param === true)
@@ -204687,6 +204817,7 @@ class CurveExtendOptions {
204687
204817
  * * If fraction is greater than 1 use `extendParam` to decide whether to return it unchanged, or to return 1.
204688
204818
  */
204689
204819
  static correctFraction(extendParam, fraction) {
204820
+ extendParam ??= false;
204690
204821
  if (fraction < 0) {
204691
204822
  const mode = CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extendParam, 0);
204692
204823
  if (mode === CurveExtendMode.None)
@@ -204710,6 +204841,7 @@ class CurveExtendOptions {
204710
204841
  * the sweep extended per `extendParam`.
204711
204842
  */
204712
204843
  static resolveRadiansToValidSweepFraction(extendParam, radians, sweep) {
204844
+ extendParam ??= false;
204713
204845
  let fraction = sweep.radiansToSignedPeriodicFraction(radians);
204714
204846
  let isValid = true;
204715
204847
  if (!sweep.isRadiansInSweep(radians)) {
@@ -206701,15 +206833,31 @@ class CurvePrimitive extends _GeometryQuery__WEBPACK_IMPORTED_MODULE_1__.Geometr
206701
206833
  * * Since CurvePrimitive should always have start and end available as candidate points, this method should always
206702
206834
  * succeed.
206703
206835
  * @param spacePoint point in space.
206704
- * @param extend (optional) compute the closest point to the curve extended according to variant type (default false)
206836
+ * @param extend (optional) compute the closest point to the curve extended according to variant type (default false).
206705
206837
  * @param result (optional) pre-allocated detail to populate and return.
206706
206838
  * @returns details of the closest point.
206707
206839
  */
206708
- closestPoint(spacePoint, extend, result) {
206840
+ closestPoint(spacePoint, extend = false, result) {
206709
206841
  const strokeHandler = new _internalContexts_ClosestPointStrokeHandler__WEBPACK_IMPORTED_MODULE_10__.ClosestPointStrokeHandler(spacePoint, extend, result);
206710
206842
  this.emitStrokableParts(strokeHandler);
206711
206843
  return strokeHandler.claimResult();
206712
206844
  }
206845
+ /**
206846
+ * Search for a point on the curve that is closest to `spacePoint`, ignoring z-coordinates.
206847
+ * * This is equivalent to finding the closest point as seen in the top view.
206848
+ * * If the space point is exactly on the curve, this is the reverse of fractionToPoint.
206849
+ * * Since CurvePrimitive should always have start and end available as candidate points, this method should always
206850
+ * succeed.
206851
+ * @param spacePoint point in space.
206852
+ * @param extend (optional) compute the closest point to the curve extended according to variant type (default false).
206853
+ * @param result (optional) pre-allocated detail to populate and return.
206854
+ * @returns details of the closest point.
206855
+ */
206856
+ closestPointXY(spacePoint, extend = false, result) {
206857
+ const strokeHandler = new _internalContexts_ClosestPointStrokeHandler__WEBPACK_IMPORTED_MODULE_10__.ClosestPointStrokeHandler(spacePoint, extend, result, true);
206858
+ this.emitStrokableParts(strokeHandler);
206859
+ return strokeHandler.claimResult();
206860
+ }
206713
206861
  /**
206714
206862
  * Announce all points `P` on the curve such that the line containing `spacePoint` and `P` is tangent to the curve in
206715
206863
  * the view defined by `options.vectorToEye`.
@@ -207536,12 +207684,12 @@ class LineSegment3d extends _CurvePrimitive__WEBPACK_IMPORTED_MODULE_1__.CurvePr
207536
207684
  /**
207537
207685
  * Returns a curve location detail with both xyz and fractional coordinates of the closest point.
207538
207686
  * @param spacePoint point in space
207539
- * @param extend if false, only return points within the bounded line segment. If true, allow the point to be on
207687
+ * @param extend if false (default), only return points within the bounded line segment. If true, allow the point to be on
207540
207688
  * the unbounded line that contains the bounded segment.
207541
207689
  * @param result optional pre-allocated object to populate and return
207542
207690
  * @returns detail, with `a` field set to the distance from `spacePoint` to the closest point
207543
207691
  */
207544
- closestPoint(spacePoint, extend, result) {
207692
+ closestPoint(spacePoint, extend = false, result) {
207545
207693
  let fraction = spacePoint.fractionOfProjectionToLine(this._point0, this._point1, 0.0);
207546
207694
  fraction = _CurveExtendMode__WEBPACK_IMPORTED_MODULE_5__.CurveExtendOptions.correctFraction(extend, fraction);
207547
207695
  result = _CurveLocationDetail__WEBPACK_IMPORTED_MODULE_6__.CurveLocationDetail.create(this, result);
@@ -208756,7 +208904,7 @@ class LineString3d extends _CurvePrimitive__WEBPACK_IMPORTED_MODULE_2__.CurvePri
208756
208904
  return undefined;
208757
208905
  }
208758
208906
  /** Find the point on the linestring (including its segment interiors) that is closest to spacePoint. */
208759
- closestPoint(spacePoint, extend, result) {
208907
+ closestPoint(spacePoint, extend = false, result) {
208760
208908
  result = _CurveLocationDetail__WEBPACK_IMPORTED_MODULE_13__.CurveLocationDetail.create(this, result);
208761
208909
  const extend0 = _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 0);
208762
208910
  const extend1 = _CurveExtendMode__WEBPACK_IMPORTED_MODULE_14__.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 1);
@@ -209918,24 +210066,15 @@ __webpack_require__.r(__webpack_exports__);
209918
210066
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
209919
210067
  /* harmony export */ Path: () => (/* binding */ Path)
209920
210068
  /* harmony export */ });
209921
- /* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
209922
- /* harmony import */ var _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../geometry3d/Point3dVector3d */ "../../core/geometry/lib/esm/geometry3d/Point3dVector3d.js");
209923
- /* harmony import */ var _CurveChainWithDistanceIndex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CurveChainWithDistanceIndex */ "../../core/geometry/lib/esm/curve/CurveChainWithDistanceIndex.js");
209924
- /* harmony import */ var _CurveCollection__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./CurveCollection */ "../../core/geometry/lib/esm/curve/CurveCollection.js");
209925
- /* harmony import */ var _CurveExtendMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./CurveExtendMode */ "../../core/geometry/lib/esm/curve/CurveExtendMode.js");
209926
- /* harmony import */ var _CurveLocationDetail__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./CurveLocationDetail */ "../../core/geometry/lib/esm/curve/CurveLocationDetail.js");
209927
- /* harmony import */ var _CurvePrimitive__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./CurvePrimitive */ "../../core/geometry/lib/esm/curve/CurvePrimitive.js");
209928
- /* harmony import */ var _LineString3d__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./LineString3d */ "../../core/geometry/lib/esm/curve/LineString3d.js");
210069
+ /* harmony import */ var _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../geometry3d/Point3dVector3d */ "../../core/geometry/lib/esm/geometry3d/Point3dVector3d.js");
210070
+ /* harmony import */ var _CurveChainWithDistanceIndex__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./CurveChainWithDistanceIndex */ "../../core/geometry/lib/esm/curve/CurveChainWithDistanceIndex.js");
210071
+ /* harmony import */ var _CurveCollection__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./CurveCollection */ "../../core/geometry/lib/esm/curve/CurveCollection.js");
210072
+ /* harmony import */ var _CurvePrimitive__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CurvePrimitive */ "../../core/geometry/lib/esm/curve/CurvePrimitive.js");
210073
+ /* harmony import */ var _LineString3d__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./LineString3d */ "../../core/geometry/lib/esm/curve/LineString3d.js");
209929
210074
  /*---------------------------------------------------------------------------------------------
209930
210075
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
209931
210076
  * See LICENSE.md in the project root for license terms and full copyright notice.
209932
210077
  *--------------------------------------------------------------------------------------------*/
209933
- /** @packageDocumentation
209934
- * @module Curve
209935
- */
209936
-
209937
-
209938
-
209939
210078
 
209940
210079
 
209941
210080
 
@@ -209947,7 +210086,7 @@ __webpack_require__.r(__webpack_exports__);
209947
210086
  * @see [Curve Collections]($docs/learning/geometry/CurveCollection.md) learning article.
209948
210087
  * @public
209949
210088
  */
209950
- class Path extends _CurveCollection__WEBPACK_IMPORTED_MODULE_1__.CurveChain {
210089
+ class Path extends _CurveCollection__WEBPACK_IMPORTED_MODULE_0__.CurveChain {
209951
210090
  /** String name for schema properties */
209952
210091
  curveCollectionType = "path";
209953
210092
  /** Test if `other` is an instance of `Path` */
@@ -209970,18 +210109,18 @@ class Path extends _CurveCollection__WEBPACK_IMPORTED_MODULE_1__.CurveChain {
209970
210109
  static create(...curves) {
209971
210110
  const result = new Path();
209972
210111
  for (const curve of curves) {
209973
- if (curve instanceof _CurveChainWithDistanceIndex__WEBPACK_IMPORTED_MODULE_2__.CurveChainWithDistanceIndex)
210112
+ if (curve instanceof _CurveChainWithDistanceIndex__WEBPACK_IMPORTED_MODULE_1__.CurveChainWithDistanceIndex)
209974
210113
  result.children.push(...curve.path.children);
209975
- else if (curve instanceof _CurvePrimitive__WEBPACK_IMPORTED_MODULE_3__.CurvePrimitive)
210114
+ else if (curve instanceof _CurvePrimitive__WEBPACK_IMPORTED_MODULE_2__.CurvePrimitive)
209976
210115
  result.children.push(curve);
209977
- else if (Array.isArray(curve) && curve.length > 0 && curve[0] instanceof _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_4__.Point3d) {
209978
- result.children.push(_LineString3d__WEBPACK_IMPORTED_MODULE_5__.LineString3d.create(curve));
210116
+ else if (Array.isArray(curve) && curve.length > 0 && curve[0] instanceof _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_3__.Point3d) {
210117
+ result.children.push(_LineString3d__WEBPACK_IMPORTED_MODULE_4__.LineString3d.create(curve));
209979
210118
  }
209980
210119
  }
209981
210120
  return result;
209982
210121
  }
209983
210122
  /**
209984
- * Create a path from a an array of curve primitives.
210123
+ * Create a path from an array of curve primitives.
209985
210124
  * @param curves array of individual curve primitives.
209986
210125
  */
209987
210126
  static createArray(curves) {
@@ -209989,39 +210128,11 @@ class Path extends _CurveCollection__WEBPACK_IMPORTED_MODULE_1__.CurveChain {
209989
210128
  }
209990
210129
  /** Return a deep copy, with leaf-level curve primitives stroked. */
209991
210130
  cloneStroked(options) {
209992
- const strokes = _LineString3d__WEBPACK_IMPORTED_MODULE_5__.LineString3d.create();
210131
+ const strokes = _LineString3d__WEBPACK_IMPORTED_MODULE_4__.LineString3d.create();
209993
210132
  for (const curve of this.children)
209994
210133
  curve.emitStrokes(strokes, options);
209995
210134
  return Path.create(strokes);
209996
210135
  }
209997
- /**
209998
- * Return the closest point on the contained curves.
209999
- * @param spacePoint point in space.
210000
- * @param extend compute the closest point to the path extended according to variant type:
210001
- * * false: do not extend the path
210002
- * * true: extend the path at both start and end
210003
- * * CurveExtendOptions: extend the path in the specified manner at both start and end
210004
- * * CurveExtendOptions[]: first entry applies to path start; second, to path end; any other entries ignored
210005
- * @param result optional pre-allocated detail to populate and return.
210006
- * @returns details of the closest point.
210007
- */
210008
- closestPoint(spacePoint, extend = false, result) {
210009
- let detailA;
210010
- const detailB = new _CurveLocationDetail__WEBPACK_IMPORTED_MODULE_6__.CurveLocationDetail();
210011
- if (this.children !== undefined) {
210012
- for (let i = 0; i < this.children.length; i++) {
210013
- const child = this.children[i]; // head only extends at start; tail, only at end. NOTE: child may be both head and tail!
210014
- const mode0 = (i === 0) ? _CurveExtendMode__WEBPACK_IMPORTED_MODULE_7__.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 0) : _CurveExtendMode__WEBPACK_IMPORTED_MODULE_7__.CurveExtendMode.None;
210015
- const mode1 = (i === this.children.length - 1) ? _CurveExtendMode__WEBPACK_IMPORTED_MODULE_7__.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 1) : _CurveExtendMode__WEBPACK_IMPORTED_MODULE_7__.CurveExtendMode.None;
210016
- if (child.closestPoint(spacePoint, [mode0, mode1], detailB)) {
210017
- const smaller = _CurveLocationDetail__WEBPACK_IMPORTED_MODULE_6__.CurveLocationDetail.chooseSmallerA(detailA, detailB);
210018
- (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(undefined !== smaller, "expect defined because detailB is always defined");
210019
- detailA = result = smaller.clone(result);
210020
- }
210021
- }
210022
- }
210023
- return detailA;
210024
- }
210025
210136
  /** Return the boundary type (1) of a corresponding MicroStation CurveVector */
210026
210137
  dgnBoundaryType() {
210027
210138
  return 1;
@@ -215152,6 +215263,7 @@ __webpack_require__.r(__webpack_exports__);
215152
215263
  /* harmony import */ var _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../geometry3d/Point3dVector3d */ "../../core/geometry/lib/esm/geometry3d/Point3dVector3d.js");
215153
215264
  /* harmony import */ var _geometry3d_Ray3d__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../geometry3d/Ray3d */ "../../core/geometry/lib/esm/geometry3d/Ray3d.js");
215154
215265
  /* harmony import */ var _numerics_Newton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../numerics/Newton */ "../../core/geometry/lib/esm/numerics/Newton.js");
215266
+ /* harmony import */ var _numerics_SmallSystem__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../numerics/SmallSystem */ "../../core/geometry/lib/esm/numerics/SmallSystem.js");
215155
215267
  /* harmony import */ var _CurveExtendMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../CurveExtendMode */ "../../core/geometry/lib/esm/curve/CurveExtendMode.js");
215156
215268
  /* harmony import */ var _CurveLocationDetail__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../CurveLocationDetail */ "../../core/geometry/lib/esm/curve/CurveLocationDetail.js");
215157
215269
  /* harmony import */ var _NewtonRtoRStrokeHandler__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./NewtonRtoRStrokeHandler */ "../../core/geometry/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.js");
@@ -215170,6 +215282,7 @@ __webpack_require__.r(__webpack_exports__);
215170
215282
 
215171
215283
 
215172
215284
 
215285
+
215173
215286
  /**
215174
215287
  * Context for searching for the closest point to a CurvePrimitive.
215175
215288
  * @internal
@@ -215179,6 +215292,7 @@ class ClosestPointStrokeHandler extends _NewtonRtoRStrokeHandler__WEBPACK_IMPORT
215179
215292
  _closestPoint;
215180
215293
  _spacePoint;
215181
215294
  _extend;
215295
+ _xyOnly;
215182
215296
  // fraction and function value on one side of an interval that may bracket a root
215183
215297
  _fractionA = 0;
215184
215298
  _functionA = 0;
@@ -215191,7 +215305,7 @@ class ClosestPointStrokeHandler extends _NewtonRtoRStrokeHandler__WEBPACK_IMPORT
215191
215305
  _workRay;
215192
215306
  _newtonSolver;
215193
215307
  /** Constructor */
215194
- constructor(spacePoint, extend, result) {
215308
+ constructor(spacePoint, extend, result, xyOnly) {
215195
215309
  super();
215196
215310
  this._spacePoint = spacePoint;
215197
215311
  this._workPoint = _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_2__.Point3d.create();
@@ -215200,6 +215314,7 @@ class ClosestPointStrokeHandler extends _NewtonRtoRStrokeHandler__WEBPACK_IMPORT
215200
215314
  if (this._closestPoint)
215201
215315
  this._closestPoint.a = _Geometry__WEBPACK_IMPORTED_MODULE_4__.Geometry.largeCoordinateResult;
215202
215316
  this._extend = extend ?? false;
215317
+ this._xyOnly = xyOnly ?? false;
215203
215318
  this.startCurvePrimitive(undefined);
215204
215319
  this._newtonSolver = new _numerics_Newton__WEBPACK_IMPORTED_MODULE_5__.Newton1dUnboundedApproximateDerivative(this);
215205
215320
  }
@@ -215240,7 +215355,7 @@ class ClosestPointStrokeHandler extends _NewtonRtoRStrokeHandler__WEBPACK_IMPORT
215240
215355
  }
215241
215356
  }
215242
215357
  announceCandidate(cp, fraction, point) {
215243
- const distance = this._spacePoint.distance(point);
215358
+ const distance = this._xyOnly ? this._spacePoint.distanceXY(point) : this._spacePoint.distance(point);
215244
215359
  if (this._closestPoint && distance > this._closestPoint.a)
215245
215360
  return;
215246
215361
  this._closestPoint = _CurveLocationDetail__WEBPACK_IMPORTED_MODULE_7__.CurveLocationDetail.createCurveFractionPoint(cp, fraction, point, this._closestPoint);
@@ -215249,16 +215364,15 @@ class ClosestPointStrokeHandler extends _NewtonRtoRStrokeHandler__WEBPACK_IMPORT
215249
215364
  this._closestPoint.curve = this._parentCurvePrimitive;
215250
215365
  }
215251
215366
  announceSegmentInterval(cp, point0, point1, _numStrokes, fraction0, fraction1) {
215252
- let localFraction = this._spacePoint.fractionOfProjectionToLine(point0, point1, 0.0);
215253
- // only consider extending the segment if the immediate caller says we are at endpoints
215254
- if (!this._extend)
215255
- localFraction = _Geometry__WEBPACK_IMPORTED_MODULE_4__.Geometry.clampToStartEnd(localFraction, 0.0, 1.0);
215256
- else {
215257
- if (fraction0 !== 0.0)
215258
- localFraction = Math.max(localFraction, 0.0);
215259
- if (fraction1 !== 1.0)
215260
- localFraction = Math.min(localFraction, 1.0);
215261
- }
215367
+ let localFraction = 0;
215368
+ if (this._xyOnly)
215369
+ localFraction = _numerics_SmallSystem__WEBPACK_IMPORTED_MODULE_8__.SmallSystem.lineSegment3dXYClosestPointUnbounded(point0, point1, this._spacePoint) ?? 0;
215370
+ else
215371
+ localFraction = this._spacePoint.fractionOfProjectionToLine(point0, point1, 0.0);
215372
+ // only consider segment extension at a parent curve endpoint, i.e. when fraction0 is 0 or fraction1 is 1
215373
+ const extend0 = (fraction0 === 0) ? _CurveExtendMode__WEBPACK_IMPORTED_MODULE_6__.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(this._extend, 0) : _CurveExtendMode__WEBPACK_IMPORTED_MODULE_6__.CurveExtendMode.None;
215374
+ const extend1 = (fraction1 === 1) ? _CurveExtendMode__WEBPACK_IMPORTED_MODULE_6__.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(this._extend, 1) : _CurveExtendMode__WEBPACK_IMPORTED_MODULE_6__.CurveExtendMode.None;
215375
+ localFraction = _CurveExtendMode__WEBPACK_IMPORTED_MODULE_6__.CurveExtendOptions.correctFraction([extend0, extend1], localFraction);
215262
215376
  this._workPoint = point0.interpolate(localFraction, point1);
215263
215377
  const globalFraction = _Geometry__WEBPACK_IMPORTED_MODULE_4__.Geometry.interpolate(fraction0, localFraction, fraction1);
215264
215378
  this.announceCandidate(cp, globalFraction, this._workPoint);
@@ -215307,7 +215421,10 @@ class ClosestPointStrokeHandler extends _NewtonRtoRStrokeHandler__WEBPACK_IMPORT
215307
215421
  this._workRay = curve.fractionToPointAndDerivative(fraction, this._workRay);
215308
215422
  else
215309
215423
  return undefined;
215310
- return this._workRay.dotProductToPoint(this._spacePoint);
215424
+ if (this._xyOnly)
215425
+ return this._workRay.dotProductToPointXY(this._spacePoint);
215426
+ else
215427
+ return this._workRay.dotProductToPoint(this._spacePoint);
215311
215428
  }
215312
215429
  evaluate(fraction) {
215313
215430
  let curve = this._curve;
@@ -226645,7 +226762,8 @@ class Ellipsoid {
226645
226762
  * @param angleB end point of arc (given as angles on this ellipsoid)
226646
226763
  * @returns arc in the plane defined by the normal at the intermediate point. If calculation fails, return an
226647
226764
  * arc with zero matrix.
226648
- * @deprecated in 5.1.9 - will not be removed until after 2027-01-05. Prefer [[sectionArcInPlaneOfInterpolatedNormal]], which has expanded return type.
226765
+ * @deprecated in 5.1.9 - will not be removed until after 2027-01-05. Prefer [[sectionArcInPlaneOfInterpolatedNormal]],
226766
+ * which has expanded return type.
226649
226767
  */
226650
226768
  sectionArcWithIntermediateNormal(angleA, intermediateNormalFraction, angleB) {
226651
226769
  const arc = this.sectionArcInPlaneOfInterpolatedNormal(angleA, intermediateNormalFraction, angleB);
@@ -243841,6 +243959,13 @@ class Ray3d {
243841
243959
  dotProductToPoint(spacePoint) {
243842
243960
  return this.direction.dotProductStartEnd(this.origin, spacePoint);
243843
243961
  }
243962
+ /**
243963
+ * Return the XY dot product of the ray's direction vector with a vector from the ray origin to the `spacePoint`.
243964
+ * * Ignores the z component of both ray's direction and spacePoint.
243965
+ */
243966
+ dotProductToPointXY(spacePoint) {
243967
+ return this.direction.dotProductStartEndXY(this.origin, spacePoint);
243968
+ }
243844
243969
  /** Return the fractional coordinate (along the direction vector) of the `spacePoint` projected to the ray. */
243845
243970
  pointToFraction(spacePoint) {
243846
243971
  return _Geometry__WEBPACK_IMPORTED_MODULE_2__.Geometry.safeDivideFraction(this.dotProductToPoint(spacePoint), this.direction.magnitudeSquared(), 0);
@@ -251135,7 +251260,8 @@ class CurvePointCloseApproachXYRtoRD extends NewtonEvaluatorRtoRD {
251135
251260
  /**
251136
251261
  * To find a close approach between xy-curve P(u) and xy-point q we should solve
251137
251262
  * F(u) := P'(u).(P(u) - q) = 0
251138
- * For a solution u, the segment S(u) := P(u) - q is perpendicular to the curve tangent P'(u), which means S(u) is a close approach.
251263
+ * For a solution u, the segment S(u) := P(u) - q is perpendicular to the curve tangent P'(u), which means S(u) is
251264
+ * a close approach.
251139
251265
  * Using the Newton method we can find the fractions u at the close approach location via
251140
251266
  * u_{n+1} = u_n + F(u_n)/F'(u_n) = u_n + [ P'(u_n).S(u_n) ]/[ P''(u_n).S(u_n) + P'(u_n).P'(u_n) ]
251141
251267
  * Note that this is xy close approach so we can ignore z.
@@ -321385,7 +321511,7 @@ var loadLanguages = instance.loadLanguages;
321385
321511
  /***/ ((module) => {
321386
321512
 
321387
321513
  "use strict";
321388
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.7.0-dev.9","description":"iTwin.js frontend components","main":"lib/cjs/core-frontend.js","module":"lib/esm/core-frontend.js","typings":"lib/cjs/core-frontend","license":"MIT","scripts":{"build":"npm run -s copy:public && npm run -s build:cjs && npm run -s build:esm && npm run -s webpackWorkers && npm run -s copy:workers && npm run -s copy:draco","build:cjs":"npm run -s copy:js:cjs && tsc 1>&2 --outDir lib/cjs","build:esm":"npm run -s copy:js:esm && tsc 1>&2 --module ES2022 --outDir lib/esm","clean":"rimraf -g lib .rush/temp/package-deps*.json","copy:public":"cpx \\"./src/public/**/*\\" ./lib/public","copy:js:cjs":"cpx \\"./src/**/*.js\\" ./lib/cjs","copy:js:esm":"cpx \\"./src/**/*.js\\" ./lib/esm","copy:workers":"cpx \\"./lib/workers/webpack/parse-imdl-worker.js\\" ./lib/public/scripts","copy:draco":"cpx \\"./node_modules/@loaders.gl/draco/dist/libs/*\\" ./lib/public/scripts","docs":"betools docs --json=../../generated-docs/core/core-frontend/file.json --tsIndexFile=./core-frontend.ts --onlyJson --excludes=webgl/**/*,**/map/*.d.ts,**/tile/*.d.ts,**/*-css.ts","extract-api":"betools extract-api --entry=core-frontend && npm run extract-extension-api","extract-extension-api":"eslint --no-inline-config -c extraction.eslint.config.js \\"./src/**/*.ts\\" 1>&2","lint":"eslint \\"./src/**/*.ts\\" 1>&2","lint-fix":"eslint --fix -f visualstudio \\"./src/**/*.ts\\" 1>&2","lint-deprecation":"eslint --fix -f visualstudio --no-inline-config -c ../../common/config/eslint/eslint.config.deprecation-policy.js \\"./src/**/*.ts\\"","pseudolocalize":"betools pseudolocalize --englishDir ./src/public/locales/en --out ./public/locales/en-PSEUDO","test":"npm run webpackTestWorker && vitest --run","cover":"npm run webpackTestWorker && vitest --run","webpackTests":"webpack --config ./src/test/utils/webpack.config.js 1>&2 && npm run -s webpackTestWorker","webpackTestWorker":"webpack --config ./src/test/worker/webpack.config.js 1>&2 && cpx \\"./lib/test/test-worker.js\\" ./lib/test","webpackWorkers":"webpack --config ./src/workers/ImdlParser/webpack.config.js 1>&2"},"repository":{"type":"git","url":"https://github.com/iTwin/itwinjs-core.git","directory":"core/frontend"},"keywords":["Bentley","BIM","iModel","digital-twin","iTwin"],"author":{"name":"Bentley Systems, Inc.","url":"http://www.bentley.com"},"peerDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/ecschema-metadata":"workspace:*","@itwin/ecschema-rpcinterface-common":"workspace:*"},"//devDependencies":["NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install","NOTE: All tools used by scripts in this package must be listed as devDependencies"],"devDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/build-tools":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/ecschema-metadata":"workspace:*","@itwin/ecschema-rpcinterface-common":"workspace:*","@itwin/object-storage-core":"^3.0.4","@itwin/eslint-plugin":"^6.0.0","@types/chai-as-promised":"^7","@types/draco3d":"^1.4.10","@types/sinon":"^17.0.2","@vitest/browser":"^3.0.6","@vitest/coverage-v8":"^3.0.6","cpx2":"^8.0.0","eslint":"^9.31.0","glob":"^10.5.0","playwright":"~1.56.1","rimraf":"^6.0.1","sinon":"^17.0.2","source-map-loader":"^5.0.0","typescript":"~5.6.2","vitest":"^3.0.6","vite-multiple-assets":"^1.3.1","vite-plugin-static-copy":"2.2.0","webpack":"^5.97.1"},"//dependencies":["NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API","NOTE: core-frontend should remain UI technology agnostic, so no react/angular dependencies are allowed"],"dependencies":{"@itwin/core-i18n":"workspace:*","@itwin/webgl-compatibility":"workspace:*","@loaders.gl/core":"^4.3.4","@loaders.gl/draco":"^4.3.4","fuse.js":"^3.3.0","wms-capabilities":"0.4.0"}}');
321514
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.8.0-dev.1","description":"iTwin.js frontend components","main":"lib/cjs/core-frontend.js","module":"lib/esm/core-frontend.js","typings":"lib/cjs/core-frontend","license":"MIT","scripts":{"build":"npm run -s copy:public && npm run -s build:cjs && npm run -s build:esm && npm run -s webpackWorkers && npm run -s copy:workers && npm run -s copy:draco","build:cjs":"npm run -s copy:js:cjs && tsc 1>&2 --outDir lib/cjs","build:esm":"npm run -s copy:js:esm && tsc 1>&2 --module ES2022 --outDir lib/esm","clean":"rimraf -g lib .rush/temp/package-deps*.json","copy:public":"cpx \\"./src/public/**/*\\" ./lib/public","copy:js:cjs":"cpx \\"./src/**/*.js\\" ./lib/cjs","copy:js:esm":"cpx \\"./src/**/*.js\\" ./lib/esm","copy:workers":"cpx \\"./lib/workers/webpack/parse-imdl-worker.js\\" ./lib/public/scripts","copy:draco":"cpx \\"./node_modules/@loaders.gl/draco/dist/libs/*\\" ./lib/public/scripts","docs":"betools docs --json=../../generated-docs/core/core-frontend/file.json --tsIndexFile=./core-frontend.ts --onlyJson --excludes=webgl/**/*,**/map/*.d.ts,**/tile/*.d.ts,**/*-css.ts","extract-api":"betools extract-api --entry=core-frontend && npm run extract-extension-api","extract-extension-api":"eslint --no-inline-config -c extraction.eslint.config.js \\"./src/**/*.ts\\" 1>&2","lint":"eslint \\"./src/**/*.ts\\" 1>&2","lint-fix":"eslint --fix -f visualstudio \\"./src/**/*.ts\\" 1>&2","lint-deprecation":"eslint --fix -f visualstudio --no-inline-config -c ../../common/config/eslint/eslint.config.deprecation-policy.js \\"./src/**/*.ts\\"","pseudolocalize":"betools pseudolocalize --englishDir ./src/public/locales/en --out ./public/locales/en-PSEUDO","test":"npm run webpackTestWorker && vitest --run","cover":"npm run webpackTestWorker && vitest --run","webpackTests":"webpack --config ./src/test/utils/webpack.config.js 1>&2 && npm run -s webpackTestWorker","webpackTestWorker":"webpack --config ./src/test/worker/webpack.config.js 1>&2 && cpx \\"./lib/test/test-worker.js\\" ./lib/test","webpackWorkers":"webpack --config ./src/workers/ImdlParser/webpack.config.js 1>&2"},"repository":{"type":"git","url":"https://github.com/iTwin/itwinjs-core.git","directory":"core/frontend"},"keywords":["Bentley","BIM","iModel","digital-twin","iTwin"],"author":{"name":"Bentley Systems, Inc.","url":"http://www.bentley.com"},"peerDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/ecschema-metadata":"workspace:*","@itwin/ecschema-rpcinterface-common":"workspace:*"},"//devDependencies":["NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install","NOTE: All tools used by scripts in this package must be listed as devDependencies"],"devDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/build-tools":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/ecschema-metadata":"workspace:*","@itwin/ecschema-rpcinterface-common":"workspace:*","@itwin/object-storage-core":"^3.0.4","@itwin/eslint-plugin":"^6.0.0","@types/chai-as-promised":"^7","@types/draco3d":"^1.4.10","@types/sinon":"^17.0.2","@vitest/browser":"^3.0.6","@vitest/coverage-v8":"^3.0.6","cpx2":"^8.0.0","eslint":"^9.31.0","glob":"^10.5.0","playwright":"~1.56.1","rimraf":"^6.0.1","sinon":"^17.0.2","source-map-loader":"^5.0.0","typescript":"~5.6.2","vitest":"^3.0.6","vite-multiple-assets":"^1.3.1","vite-plugin-static-copy":"2.2.0","webpack":"^5.97.1"},"//dependencies":["NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API","NOTE: core-frontend should remain UI technology agnostic, so no react/angular dependencies are allowed"],"dependencies":{"@itwin/core-i18n":"workspace:*","@itwin/webgl-compatibility":"workspace:*","@loaders.gl/core":"^4.3.4","@loaders.gl/draco":"^4.3.4","fuse.js":"^3.3.0","wms-capabilities":"0.4.0"}}');
321389
321515
 
321390
321516
  /***/ })
321391
321517