@itwin/core-geometry 4.0.0-dev.23 → 4.0.0-dev.28

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.
Files changed (204) hide show
  1. package/CHANGELOG.md +7 -2
  2. package/lib/cjs/Geometry.d.ts +23 -0
  3. package/lib/cjs/Geometry.d.ts.map +1 -1
  4. package/lib/cjs/Geometry.js +25 -1
  5. package/lib/cjs/Geometry.js.map +1 -1
  6. package/lib/cjs/bspline/BSplineCurveOps.js +4 -5
  7. package/lib/cjs/bspline/BSplineCurveOps.js.map +1 -1
  8. package/lib/cjs/bspline/InterpolationCurve3d.js +7 -10
  9. package/lib/cjs/bspline/InterpolationCurve3d.js.map +1 -1
  10. package/lib/cjs/clipping/ClipPrimitive.js +2 -2
  11. package/lib/cjs/clipping/ClipPrimitive.js.map +1 -1
  12. package/lib/cjs/clipping/ClipUtils.js +4 -4
  13. package/lib/cjs/clipping/ClipUtils.js.map +1 -1
  14. package/lib/cjs/clipping/internalContexts/LineStringOffsetClipperContext.js +2 -2
  15. package/lib/cjs/clipping/internalContexts/LineStringOffsetClipperContext.js.map +1 -1
  16. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +1 -1
  17. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  18. package/lib/cjs/curve/CurveCollection.js +1 -1
  19. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  20. package/lib/cjs/curve/StrokeOptions.js +1 -2
  21. package/lib/cjs/curve/StrokeOptions.js.map +1 -1
  22. package/lib/cjs/curve/spiral/DirectSpiral3d.js +1 -2
  23. package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
  24. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js +1 -2
  25. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  26. package/lib/cjs/geometry3d/BarycentricTriangle.d.ts +195 -8
  27. package/lib/cjs/geometry3d/BarycentricTriangle.d.ts.map +1 -1
  28. package/lib/cjs/geometry3d/BarycentricTriangle.js +459 -11
  29. package/lib/cjs/geometry3d/BarycentricTriangle.js.map +1 -1
  30. package/lib/cjs/geometry3d/GrowableFloat64Array.js +2 -2
  31. package/lib/cjs/geometry3d/GrowableFloat64Array.js.map +1 -1
  32. package/lib/cjs/geometry3d/GrowableXYArray.d.ts +1 -1
  33. package/lib/cjs/geometry3d/GrowableXYArray.d.ts.map +1 -1
  34. package/lib/cjs/geometry3d/GrowableXYArray.js +2 -2
  35. package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
  36. package/lib/cjs/geometry3d/GrowableXYZArray.js +1 -1
  37. package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
  38. package/lib/cjs/geometry3d/IndexedXYCollection.d.ts +22 -7
  39. package/lib/cjs/geometry3d/IndexedXYCollection.d.ts.map +1 -1
  40. package/lib/cjs/geometry3d/IndexedXYCollection.js +41 -5
  41. package/lib/cjs/geometry3d/IndexedXYCollection.js.map +1 -1
  42. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +58 -4
  43. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  44. package/lib/cjs/geometry3d/IndexedXYZCollection.js +102 -4
  45. package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
  46. package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts +10 -0
  47. package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
  48. package/lib/cjs/geometry3d/Point2dArrayCarrier.js +14 -0
  49. package/lib/cjs/geometry3d/Point2dArrayCarrier.js.map +1 -1
  50. package/lib/cjs/geometry3d/Point2dVector2d.js +4 -6
  51. package/lib/cjs/geometry3d/Point2dVector2d.js.map +1 -1
  52. package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts +0 -6
  53. package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  54. package/lib/cjs/geometry3d/Point3dArrayCarrier.js +0 -6
  55. package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
  56. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +1 -1
  57. package/lib/cjs/geometry3d/Point3dVector3d.js +6 -8
  58. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  59. package/lib/cjs/geometry3d/PointHelpers.d.ts +14 -1
  60. package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
  61. package/lib/cjs/geometry3d/PointHelpers.js +33 -1
  62. package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
  63. package/lib/cjs/geometry3d/PolygonOps.d.ts +120 -10
  64. package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
  65. package/lib/cjs/geometry3d/PolygonOps.js +413 -13
  66. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  67. package/lib/cjs/geometry3d/Ray3d.js +1 -1
  68. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  69. package/lib/cjs/polyface/AuxData.js +1 -1
  70. package/lib/cjs/polyface/AuxData.js.map +1 -1
  71. package/lib/cjs/polyface/FacetLocationDetail.d.ts +264 -0
  72. package/lib/cjs/polyface/FacetLocationDetail.d.ts.map +1 -0
  73. package/lib/cjs/polyface/FacetLocationDetail.js +376 -0
  74. package/lib/cjs/polyface/FacetLocationDetail.js.map +1 -0
  75. package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts +2 -5
  76. package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
  77. package/lib/cjs/polyface/IndexedPolyfaceVisitor.js +5 -2
  78. package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
  79. package/lib/cjs/polyface/PolyfaceBuilder.d.ts +20 -14
  80. package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
  81. package/lib/cjs/polyface/PolyfaceBuilder.js +21 -17
  82. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  83. package/lib/cjs/polyface/PolyfaceClip.js +6 -7
  84. package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
  85. package/lib/cjs/polyface/PolyfaceData.d.ts +1 -1
  86. package/lib/cjs/polyface/PolyfaceData.d.ts.map +1 -1
  87. package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
  88. package/lib/cjs/polyface/PolyfaceQuery.d.ts +22 -1
  89. package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
  90. package/lib/cjs/polyface/PolyfaceQuery.js +52 -2
  91. package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
  92. package/lib/cjs/serialization/BGFBReader.js +4 -4
  93. package/lib/cjs/serialization/BGFBReader.js.map +1 -1
  94. package/lib/cjs/serialization/IModelJsonSchema.js +1 -2
  95. package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
  96. package/lib/cjs/solid/Sphere.d.ts +5 -5
  97. package/lib/cjs/solid/Sphere.js +5 -5
  98. package/lib/cjs/solid/Sphere.js.map +1 -1
  99. package/lib/cjs/solid/SweepContour.js +1 -1
  100. package/lib/cjs/solid/SweepContour.js.map +1 -1
  101. package/lib/cjs/topology/Triangulation.js +1 -1
  102. package/lib/cjs/topology/Triangulation.js.map +1 -1
  103. package/lib/esm/Geometry.d.ts +23 -0
  104. package/lib/esm/Geometry.d.ts.map +1 -1
  105. package/lib/esm/Geometry.js +24 -0
  106. package/lib/esm/Geometry.js.map +1 -1
  107. package/lib/esm/bspline/BSplineCurveOps.js +4 -5
  108. package/lib/esm/bspline/BSplineCurveOps.js.map +1 -1
  109. package/lib/esm/bspline/InterpolationCurve3d.js +7 -10
  110. package/lib/esm/bspline/InterpolationCurve3d.js.map +1 -1
  111. package/lib/esm/clipping/ClipPrimitive.js +2 -2
  112. package/lib/esm/clipping/ClipPrimitive.js.map +1 -1
  113. package/lib/esm/clipping/ClipUtils.js +4 -4
  114. package/lib/esm/clipping/ClipUtils.js.map +1 -1
  115. package/lib/esm/clipping/internalContexts/LineStringOffsetClipperContext.js +2 -2
  116. package/lib/esm/clipping/internalContexts/LineStringOffsetClipperContext.js.map +1 -1
  117. package/lib/esm/curve/CurveChainWithDistanceIndex.js +1 -1
  118. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  119. package/lib/esm/curve/CurveCollection.js +1 -1
  120. package/lib/esm/curve/CurveCollection.js.map +1 -1
  121. package/lib/esm/curve/StrokeOptions.js +1 -2
  122. package/lib/esm/curve/StrokeOptions.js.map +1 -1
  123. package/lib/esm/curve/spiral/DirectSpiral3d.js +1 -2
  124. package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
  125. package/lib/esm/curve/spiral/IntegratedSpiral3d.js +1 -2
  126. package/lib/esm/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  127. package/lib/esm/geometry3d/BarycentricTriangle.d.ts +195 -8
  128. package/lib/esm/geometry3d/BarycentricTriangle.d.ts.map +1 -1
  129. package/lib/esm/geometry3d/BarycentricTriangle.js +459 -12
  130. package/lib/esm/geometry3d/BarycentricTriangle.js.map +1 -1
  131. package/lib/esm/geometry3d/GrowableFloat64Array.js +2 -2
  132. package/lib/esm/geometry3d/GrowableFloat64Array.js.map +1 -1
  133. package/lib/esm/geometry3d/GrowableXYArray.d.ts +1 -1
  134. package/lib/esm/geometry3d/GrowableXYArray.d.ts.map +1 -1
  135. package/lib/esm/geometry3d/GrowableXYArray.js +2 -2
  136. package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
  137. package/lib/esm/geometry3d/GrowableXYZArray.js +1 -1
  138. package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
  139. package/lib/esm/geometry3d/IndexedXYCollection.d.ts +22 -7
  140. package/lib/esm/geometry3d/IndexedXYCollection.d.ts.map +1 -1
  141. package/lib/esm/geometry3d/IndexedXYCollection.js +41 -5
  142. package/lib/esm/geometry3d/IndexedXYCollection.js.map +1 -1
  143. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +58 -4
  144. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  145. package/lib/esm/geometry3d/IndexedXYZCollection.js +103 -5
  146. package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
  147. package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts +10 -0
  148. package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
  149. package/lib/esm/geometry3d/Point2dArrayCarrier.js +14 -0
  150. package/lib/esm/geometry3d/Point2dArrayCarrier.js.map +1 -1
  151. package/lib/esm/geometry3d/Point2dVector2d.js +4 -6
  152. package/lib/esm/geometry3d/Point2dVector2d.js.map +1 -1
  153. package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts +0 -6
  154. package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  155. package/lib/esm/geometry3d/Point3dArrayCarrier.js +0 -6
  156. package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
  157. package/lib/esm/geometry3d/Point3dVector3d.d.ts +1 -1
  158. package/lib/esm/geometry3d/Point3dVector3d.js +6 -8
  159. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  160. package/lib/esm/geometry3d/PointHelpers.d.ts +14 -1
  161. package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
  162. package/lib/esm/geometry3d/PointHelpers.js +33 -1
  163. package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
  164. package/lib/esm/geometry3d/PolygonOps.d.ts +120 -10
  165. package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
  166. package/lib/esm/geometry3d/PolygonOps.js +412 -13
  167. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  168. package/lib/esm/geometry3d/Ray3d.js +1 -1
  169. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  170. package/lib/esm/polyface/AuxData.js +1 -1
  171. package/lib/esm/polyface/AuxData.js.map +1 -1
  172. package/lib/esm/polyface/FacetLocationDetail.d.ts +264 -0
  173. package/lib/esm/polyface/FacetLocationDetail.d.ts.map +1 -0
  174. package/lib/esm/polyface/FacetLocationDetail.js +369 -0
  175. package/lib/esm/polyface/FacetLocationDetail.js.map +1 -0
  176. package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts +2 -5
  177. package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
  178. package/lib/esm/polyface/IndexedPolyfaceVisitor.js +5 -2
  179. package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
  180. package/lib/esm/polyface/PolyfaceBuilder.d.ts +20 -14
  181. package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
  182. package/lib/esm/polyface/PolyfaceBuilder.js +21 -17
  183. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  184. package/lib/esm/polyface/PolyfaceClip.js +6 -7
  185. package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
  186. package/lib/esm/polyface/PolyfaceData.d.ts +1 -1
  187. package/lib/esm/polyface/PolyfaceData.d.ts.map +1 -1
  188. package/lib/esm/polyface/PolyfaceData.js.map +1 -1
  189. package/lib/esm/polyface/PolyfaceQuery.d.ts +22 -1
  190. package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
  191. package/lib/esm/polyface/PolyfaceQuery.js +52 -2
  192. package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
  193. package/lib/esm/serialization/BGFBReader.js +4 -4
  194. package/lib/esm/serialization/BGFBReader.js.map +1 -1
  195. package/lib/esm/serialization/IModelJsonSchema.js +1 -2
  196. package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
  197. package/lib/esm/solid/Sphere.d.ts +5 -5
  198. package/lib/esm/solid/Sphere.js +5 -5
  199. package/lib/esm/solid/Sphere.js.map +1 -1
  200. package/lib/esm/solid/SweepContour.js +1 -1
  201. package/lib/esm/solid/SweepContour.js.map +1 -1
  202. package/lib/esm/topology/Triangulation.js +1 -1
  203. package/lib/esm/topology/Triangulation.js.map +1 -1
  204. package/package.json +4 -4
@@ -5,7 +5,6 @@
5
5
  /** @packageDocumentation
6
6
  * @module Polyface
7
7
  */
8
- // import { Point2d } from "./Geometry2d";
9
8
  /* eslint-disable @typescript-eslint/naming-convention, no-empty */
10
9
  import { Point3dArray } from "../geometry3d/PointHelpers";
11
10
  import { BagOfCurves } from "../curve/CurveCollection";
@@ -39,6 +38,8 @@ import { RangeLengthData } from "./RangeLengthData";
39
38
  import { SpacePolygonTriangulation } from "../topology/SpaceTriangulation";
40
39
  import { HalfEdgeGraphFromIndexedLoopsContext } from "../topology/HalfEdgeGraphFromIndexedLoopsContext";
41
40
  import { OffsetMeshContext } from "./multiclip/OffsetMeshContext";
41
+ import { ConvexFacetLocationDetail, NonConvexFacetLocationDetail, TriangularFacetLocationDetail } from "./FacetLocationDetail";
42
+ import { BarycentricTriangle } from "../geometry3d/BarycentricTriangle";
42
43
  /**
43
44
  * Options carrier for [[PolyfaceQuery.cloneOffset]].
44
45
  * * Default options are strongly recommended.
@@ -1311,7 +1312,7 @@ export class PolyfaceQuery {
1311
1312
  * * Compute simple average of those normals
1312
1313
  * * Index to the averages
1313
1314
  * * For typical meshes, this correctly clusters adjacent normals.
1314
- * * One cam imagine a vertex with multiple "smooth cone-like" sets of incident facets such that averaging occurs among two nonadjacent cones. But this does not seem to be a problem in practice.
1315
+ * * One can imagine a vertex with multiple "smooth cone-like" sets of incident facets such that averaging occurs among two nonadjacent cones. But this does not seem to be a problem in practice.
1315
1316
  * @param polyface polyface to update.
1316
1317
  * @param toleranceAngle averaging is done between normals up to this angle.
1317
1318
  */
@@ -1331,6 +1332,55 @@ export class PolyfaceQuery {
1331
1332
  OffsetMeshContext.buildOffsetMeshWithEdgeChamfers(source, offsetBuilder, signedOffsetDistance, offsetOptions);
1332
1333
  return offsetBuilder.claimPolyface();
1333
1334
  }
1335
+ /** Search facets for the first one that intersects the infinite line.
1336
+ * * To process _all_ intersections, callers can supply an `options.acceptIntersection` callback that always returns false.
1337
+ * In this case, `intersectRay3d` will return undefined, but the callback will be invoked for each intersection.
1338
+ * * Example callback logic:
1339
+ * * Accept the first found facet that intersects the half-line specified by the ray: `return detail.a >= 0.0;`
1340
+ * * Collect all intersections: `myIntersections.push(detail.clone()); return false;` Then after `intersectRay3d` returns, sort along `ray` with `myIntersections.sort((d0, d1) => d0.a - d1.a);`
1341
+ * @param visitor facet iterator
1342
+ * @param ray infinite line parameterized as a ray. The returned `detail.a` is the intersection parameter on the ray, e.g., zero at `ray.origin` and increasing in `ray.direction`.
1343
+ * @param options options for computing and populating an intersection detail, and an optional callback for accepting one
1344
+ * @return detail for the (accepted) intersection with `detail.IsInsideOrOn === true`, or `undefined` if no (accepted) intersection
1345
+ * @see PolygonOps.intersectRay3d
1346
+ */
1347
+ static intersectRay3d(visitor, ray, options) {
1348
+ if (visitor instanceof Polyface)
1349
+ return PolyfaceQuery.intersectRay3d(visitor.createVisitor(0), ray, options);
1350
+ let detail;
1351
+ visitor.setNumWrap(0);
1352
+ while (visitor.moveToNextFacet()) {
1353
+ const numEdges = visitor.pointCount; // #vertices = #edges since numWrap is zero
1354
+ const vertices = visitor.point;
1355
+ if (3 === numEdges) {
1356
+ const tri = this._workTriangle = BarycentricTriangle.create(vertices.getPoint3dAtUncheckedPointIndex(0), vertices.getPoint3dAtUncheckedPointIndex(1), vertices.getPoint3dAtUncheckedPointIndex(2), this._workTriangle);
1357
+ const detail3 = this._workTriDetail = tri.intersectRay3d(ray, this._workTriDetail);
1358
+ tri.snapLocationToEdge(detail3, options?.distanceTolerance, options?.parameterTolerance);
1359
+ detail = this._workFacetDetail3 = TriangularFacetLocationDetail.create(visitor.currentReadIndex(), detail3, this._workFacetDetail3);
1360
+ }
1361
+ else {
1362
+ const detailN = this._workPolyDetail = PolygonOps.intersectRay3d(vertices, ray, options?.distanceTolerance, this._workPolyDetail);
1363
+ if (PolygonOps.isConvex(vertices))
1364
+ detail = this._workFacetDetailC = ConvexFacetLocationDetail.create(visitor.currentReadIndex(), numEdges, detailN, this._workFacetDetailC);
1365
+ else
1366
+ detail = this._workFacetDetailNC = NonConvexFacetLocationDetail.create(visitor.currentReadIndex(), numEdges, detailN, this._workFacetDetailNC);
1367
+ }
1368
+ if (detail.isInsideOrOn) { // set optional caches, process the intersection
1369
+ if (options?.needNormal && visitor.normal)
1370
+ detail.getNormal(visitor.normal, vertices, options?.distanceTolerance);
1371
+ if (options?.needParam && visitor.param)
1372
+ detail.getParam(visitor.param, vertices, options?.distanceTolerance);
1373
+ if (options?.needColor && visitor.color)
1374
+ detail.getColor(visitor.color, vertices, options?.distanceTolerance);
1375
+ if (options?.needBarycentricCoordinates)
1376
+ detail.getBarycentricCoordinates(vertices, options?.distanceTolerance);
1377
+ if (options?.acceptIntersection && !options.acceptIntersection(detail, visitor))
1378
+ continue;
1379
+ return detail;
1380
+ }
1381
+ }
1382
+ return undefined; // no intersection
1383
+ }
1334
1384
  }
1335
1385
  // amount of computation to do per step of async methods.
1336
1386
  PolyfaceQuery._asyncWorkLimit = 1.e06;