@itwin/core-geometry 5.14.0-dev.5 → 5.14.0-dev.7

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 (60) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/lib/cjs/curve/CurveCollection.d.ts +6 -0
  3. package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
  4. package/lib/cjs/curve/CurveCollection.js +15 -0
  5. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  6. package/lib/cjs/curve/CurveOps.d.ts.map +1 -1
  7. package/lib/cjs/curve/CurveOps.js.map +1 -1
  8. package/lib/cjs/curve/GeometryQuery.d.ts +41 -0
  9. package/lib/cjs/curve/GeometryQuery.d.ts.map +1 -1
  10. package/lib/cjs/curve/GeometryQuery.js +52 -0
  11. package/lib/cjs/curve/GeometryQuery.js.map +1 -1
  12. package/lib/cjs/curve/Query/PlanarSubdivision.d.ts +36 -35
  13. package/lib/cjs/curve/Query/PlanarSubdivision.d.ts.map +1 -1
  14. package/lib/cjs/curve/Query/PlanarSubdivision.js +4 -4
  15. package/lib/cjs/curve/Query/PlanarSubdivision.js.map +1 -1
  16. package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
  17. package/lib/cjs/curve/RegionOps.js +3 -1
  18. package/lib/cjs/curve/RegionOps.js.map +1 -1
  19. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +2 -0
  20. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  21. package/lib/cjs/geometry3d/Point3dVector3d.js +4 -0
  22. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  23. package/lib/cjs/geometry3d/Range.d.ts +2 -0
  24. package/lib/cjs/geometry3d/Range.d.ts.map +1 -1
  25. package/lib/cjs/geometry3d/Range.js +6 -0
  26. package/lib/cjs/geometry3d/Range.js.map +1 -1
  27. package/lib/cjs/topology/Merging.d.ts +4 -2
  28. package/lib/cjs/topology/Merging.d.ts.map +1 -1
  29. package/lib/cjs/topology/Merging.js +23 -20
  30. package/lib/cjs/topology/Merging.js.map +1 -1
  31. package/lib/esm/curve/CurveCollection.d.ts +6 -0
  32. package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
  33. package/lib/esm/curve/CurveCollection.js +15 -0
  34. package/lib/esm/curve/CurveCollection.js.map +1 -1
  35. package/lib/esm/curve/CurveOps.d.ts.map +1 -1
  36. package/lib/esm/curve/CurveOps.js.map +1 -1
  37. package/lib/esm/curve/GeometryQuery.d.ts +41 -0
  38. package/lib/esm/curve/GeometryQuery.d.ts.map +1 -1
  39. package/lib/esm/curve/GeometryQuery.js +52 -0
  40. package/lib/esm/curve/GeometryQuery.js.map +1 -1
  41. package/lib/esm/curve/Query/PlanarSubdivision.d.ts +36 -35
  42. package/lib/esm/curve/Query/PlanarSubdivision.d.ts.map +1 -1
  43. package/lib/esm/curve/Query/PlanarSubdivision.js +4 -4
  44. package/lib/esm/curve/Query/PlanarSubdivision.js.map +1 -1
  45. package/lib/esm/curve/RegionOps.d.ts.map +1 -1
  46. package/lib/esm/curve/RegionOps.js +3 -1
  47. package/lib/esm/curve/RegionOps.js.map +1 -1
  48. package/lib/esm/geometry3d/Point3dVector3d.d.ts +2 -0
  49. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  50. package/lib/esm/geometry3d/Point3dVector3d.js +4 -0
  51. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  52. package/lib/esm/geometry3d/Range.d.ts +2 -0
  53. package/lib/esm/geometry3d/Range.d.ts.map +1 -1
  54. package/lib/esm/geometry3d/Range.js +6 -0
  55. package/lib/esm/geometry3d/Range.js.map +1 -1
  56. package/lib/esm/topology/Merging.d.ts +4 -2
  57. package/lib/esm/topology/Merging.d.ts.map +1 -1
  58. package/lib/esm/topology/Merging.js +23 -20
  59. package/lib/esm/topology/Merging.js.map +1 -1
  60. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"GeometryQuery.js","sourceRoot":"","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AC;gBACjB,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;iBAAM,IAAI,SAAS,IAAI,SAAS,EAAE,CAAC,CAAC,uGAAuG;gBAC1I,OAAO,KAAK,CAAC,CAAC,oBAAoB;YACpC,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAI,CAAC,CAAC,oCAAoC;YACnD,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,cAAc,CAAC,CAA4B,EAAE,CAA4B;QACrF,IAAI,CAAC,YAAY,aAAa,IAAI,CAAC,YAAY,aAAa;YAC1D,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,CAAC,CAAC,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,SAAS,CAAC;YACxC,OAAO,IAAI,CAAC;QACd,OAAO,KAAK,CAAC;IACf,CAAC;CAWF;AArFD,sCAqFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\nimport { BSpline2dNd } from \"../bspline/BSplineSurface\";\r\nimport { GeometryHandler } from \"../geometry3d/GeometryHandler\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { Polyface } from \"../polyface/Polyface\";\r\nimport { SolidPrimitive } from \"../solid/SolidPrimitive\";\r\nimport { CoordinateXYZ } from \"./CoordinateXYZ\";\r\nimport { CurveCollection } from \"./CurveCollection\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { PointString3d } from \"./PointString3d\";\r\n\r\n/**\r\n * Describes the category of a [[GeometryQuery]], enabling type-switching like:\r\n * ```ts\r\n * function processGeometryQuery(q: GeometryQuery): void {\r\n * if (\"solid\" === q.geometryCategory)\r\n * alert(\"Solid type = \" + q.solidPrimitiveType); // compiler knows q is an instance of SolidPrimitive\r\n * // ...etc...\r\n * ```\r\n *\r\n * Each string maps to a particular subclass of [[GeometryQuery]]:\r\n * - \"polyface\" => [[Polyface]]\r\n * - \"curvePrimitive\" => [[CurvePrimitive]]\r\n * - \"curveCollection\" => [[CurveCollection]]\r\n * - \"solid\" => [[SolidPrimitive]]\r\n * - \"point\" => [[CoordinateXYZ]]\r\n * - \"pointCollection\" => [[PointString3d]]\r\n * - \"bsurf\" => [[BSpline2dNd]] (which is an intermediate class shared by [[BSplineSurface3d]] and [[BSplineSurface3dH]])\r\n *\r\n * @see [[AnyGeometryQuery]]\r\n * @public\r\n */\r\nexport type GeometryQueryCategory = \"polyface\" | \"curvePrimitive\" | \"curveCollection\" | \"solid\" | \"point\" | \"pointCollection\" | \"bsurf\";\r\n\r\n/**\r\n * Union type for subclasses of [[GeometryQuery]]. Specific subclasses can be discriminated at compile- or run-time\r\n * using [[GeometryQuery.geometryCategory]].\r\n * @public\r\n */\r\nexport type AnyGeometryQuery = Polyface | CurvePrimitive | CurveCollection | SolidPrimitive | CoordinateXYZ | PointString3d | BSpline2dNd;\r\n\r\n/**\r\n * Queries to be supported by Curve, Surface, and Solid objects.\r\n * * `GeometryQuery` is an abstract base class with (abstract) methods for querying curve, solid primitive, mesh,\r\n * and bspline surfaces.\r\n * @public\r\n */\r\nexport abstract class GeometryQuery {\r\n /** Type discriminator. */\r\n public abstract readonly geometryCategory: GeometryQueryCategory;\r\n /** Return the range of the entire GeometryQuery tree. */\r\n public range(transform?: Transform, result?: Range3d): Range3d {\r\n if (result)\r\n result.setNull();\r\n const range = result ? result : Range3d.createNull();\r\n this.extendRange(range, transform);\r\n return range;\r\n }\r\n /** Extend `rangeToExtend` by the range of this geometry multiplied by the `transform`. */\r\n public abstract extendRange(rangeToExtend: Range3d, transform?: Transform): void;\r\n /**\r\n * Attempt to transform in place.\r\n * * LineSegment3d, Arc3d, LineString3d, BsplineCurve3d always succeed.\r\n * * Some geometry types may fail if scaling is non-uniform.\r\n */\r\n public abstract tryTransformInPlace(transform: Transform): boolean;\r\n /** Try to move the geometry by dx,dy,dz. */\r\n public tryTranslateInPlace(dx: number, dy: number = 0.0, dz: number = 0.0): boolean {\r\n return this.tryTransformInPlace(Transform.createTranslationXYZ(dx, dy, dz));\r\n }\r\n /** Return a transformed clone. */\r\n public abstract cloneTransformed(transform: Transform): GeometryQuery | undefined;\r\n /** Return a clone */\r\n public abstract clone(): GeometryQuery | undefined;\r\n /**\r\n * Return GeometryQuery children for recursive queries.\r\n * * leaf classes do not need to implement.\r\n */\r\n public get children(): GeometryQuery[] | undefined {\r\n return undefined;\r\n }\r\n /** Test `if (other instanceof this.Type)`. REQUIRED IN ALL CONCRETE CLASSES. */\r\n public abstract isSameGeometryClass(other: GeometryQuery): boolean;\r\n /**\r\n * Test for exact structure and nearly identical geometry.\r\n * * Leaf classes must implement.\r\n * * Base class implementation recurses through children.\r\n * * Base implementation is complete for classes with children and no properties.\r\n * * Classes with both children and properties must implement for properties, call super for children.\r\n */\r\n public isAlmostEqual(other: GeometryQuery): boolean {\r\n if (this.isSameGeometryClass(other)) {\r\n const childrenA = this.children;\r\n const childrenB = other.children;\r\n if (childrenA && childrenB) {\r\n if (childrenA.length !== childrenB.length)\r\n return false;\r\n for (let i = 0; i < childrenA.length; i++) {\r\n if (!childrenA[i].isAlmostEqual(childrenB[i]))\r\n return false;\r\n }\r\n return true;\r\n } else if (childrenA || childrenB) { // CurveCollections start with empty arrays for children so these null pointer cases are never reached.\r\n return false; // plainly different\r\n } else {\r\n return true; // both children null; call it equal\r\n }\r\n }\r\n return false;\r\n }\r\n /**\r\n * Apply instance method [[isAlmostEqual]] if both are defined.\r\n * * Both undefined returns true.\r\n * * Single defined returns false.\r\n */\r\n public static areAlmostEqual(a: GeometryQuery | undefined, b: GeometryQuery | undefined): boolean {\r\n if (a instanceof GeometryQuery && b instanceof GeometryQuery)\r\n return a.isAlmostEqual(b);\r\n if ((a === undefined) && (b === undefined))\r\n return true;\r\n return false;\r\n }\r\n /**\r\n * Double Dispatch call pattern.\r\n * * User code implements a `GeometryHandler` with specialized methods to handle `LineSegment3d`, `Arc3d`, etc as\r\n * relevant to its use case.\r\n * * Each such `GeometryQuery` class implements this method as a one-line method containing the appropriate call\r\n * such as `handler.handleLineSegment3d())`\r\n * * This allows each type-specific method to be called without a switch or `instanceof` test.\r\n * @param handler handler to be called by the particular geometry class\r\n */\r\n public abstract dispatchToGeometryHandler(handler: GeometryHandler): any;\r\n}\r\n"]}
1
+ {"version":3,"file":"GeometryQuery.js","sourceRoot":"","sources":["../../../src/curve/GeometryQuery.ts"],"names":[],"mappings":";;;AAQA,0CAAuC;AAEvC,+CAA8C;AAC9C,uDAAoD;AAqDpD;;;;;GAKG;AACH,MAAsB,aAAa;IAGjC,yDAAyD;IAClD,KAAK,CAAC,SAAqB,EAAE,MAAgB;QAClD,IAAI,MAAM;YACR,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,eAAO,CAAC,UAAU,EAAE,CAAC;QACrD,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IASD,4CAA4C;IACrC,mBAAmB,CAAC,EAAU,EAAE,KAAa,GAAG,EAAE,KAAa,GAAG;QACvE,OAAO,IAAI,CAAC,mBAAmB,CAAC,qBAAS,CAAC,oBAAoB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC;IAKD;;;OAGG;IACH,IAAW,QAAQ;QACjB,OAAO,SAAS,CAAC;IACnB,CAAC;IAGD;;;;;;OAMG;IACI,aAAa,CAAC,KAAoB;QACvC,IAAI,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC;YACpC,MAAM,SAAS,GAAG,IA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AAQ,GAAG,CAAC,EAAE,CAAC;oBACjB,qGAAqG;oBACrG,gGAAgG;oBAChG,MAAM,SAAS,GAAG,EAAE,CAAC,CAAC,qEAAqE;oBAC3F,MAAM,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,iBAAiB,CAAC,CAAC,CAAC;oBAClF,IAAI,oBAAoB,GAAG,SAAS;wBAClC,iBAAiB,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,oBAAoB,GAAG,SAAS,CAAC,CAAC;gBACxE,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF;AA1ID,sCA0IC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\nimport { BSpline2dNd } from \"../bspline/BSplineSurface\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GeometryHandler } from \"../geometry3d/GeometryHandler\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { Polyface } from \"../polyface/Polyface\";\r\nimport { SolidPrimitive } from \"../solid/SolidPrimitive\";\r\nimport { CoordinateXYZ } from \"./CoordinateXYZ\";\r\nimport { CurveCollection } from \"./CurveCollection\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { PointString3d } from \"./PointString3d\";\r\n\r\n/**\r\n * Describes the category of a [[GeometryQuery]], enabling type-switching like:\r\n * ```ts\r\n * function processGeometryQuery(q: GeometryQuery): void {\r\n * if (\"solid\" === q.geometryCategory)\r\n * alert(\"Solid type = \" + q.solidPrimitiveType); // compiler knows q is an instance of SolidPrimitive\r\n * // ...etc...\r\n * ```\r\n *\r\n * Each string maps to a particular subclass of [[GeometryQuery]]:\r\n * - \"polyface\" => [[Polyface]]\r\n * - \"curvePrimitive\" => [[CurvePrimitive]]\r\n * - \"curveCollection\" => [[CurveCollection]]\r\n * - \"solid\" => [[SolidPrimitive]]\r\n * - \"point\" => [[CoordinateXYZ]]\r\n * - \"pointCollection\" => [[PointString3d]]\r\n * - \"bsurf\" => [[BSpline2dNd]] (which is an intermediate class shared by [[BSplineSurface3d]] and [[BSplineSurface3dH]])\r\n *\r\n * @see [[AnyGeometryQuery]]\r\n * @public\r\n */\r\nexport type GeometryQueryCategory = \"polyface\" | \"curvePrimitive\" | \"curveCollection\" | \"solid\" | \"point\" | \"pointCollection\" | \"bsurf\";\r\n\r\n/**\r\n * Union type for subclasses of [[GeometryQuery]]. Specific subclasses can be discriminated at compile- or run-time\r\n * using [[GeometryQuery.geometryCategory]].\r\n * @public\r\n */\r\nexport type AnyGeometryQuery = Polyface | CurvePrimitive | CurveCollection | SolidPrimitive | CoordinateXYZ | PointString3d | BSpline2dNd;\r\n\r\n/**\r\n * Options bundle for [[GeometryQuery.computeScaledTolerance]] and [[GeometryQuery.scaleToleranceForGeometry]].\r\n * @public\r\n */\r\nexport interface ScaledToleranceOptions {\r\n /** Optional transform to apply to geometry before computing its size. */\r\n transform?: Transform;\r\n /** Relative tolerance by which to scale the computed geometry size. Default is [[Geometry.smallMetricDistance]]. */\r\n relativeTolerance?: number;\r\n /** Smallest tolerance to return. Default is [[Geometry.smallMetricDistanceSquared]]. */\r\n minimumTolerance?: number;\r\n /** Whether to ignore z-coordinates when computing the geometry size. */\r\n xyOnly?: boolean;\r\n}\r\n\r\n/**\r\n * Queries to be supported by Curve, Surface, and Solid objects.\r\n * * `GeometryQuery` is an abstract base class with (abstract) methods for querying curve, solid primitive, mesh,\r\n * and bspline surfaces.\r\n * @public\r\n */\r\nexport abstract class GeometryQuery {\r\n /** Type discriminator. */\r\n public abstract readonly geometryCategory: GeometryQueryCategory;\r\n /** Return the range of the entire GeometryQuery tree. */\r\n public range(transform?: Transform, result?: Range3d): Range3d {\r\n if (result)\r\n result.setNull();\r\n const range = result ? result : Range3d.createNull();\r\n this.extendRange(range, transform);\r\n return range;\r\n }\r\n /** Extend `rangeToExtend` by the range of this geometry multiplied by the `transform`. */\r\n public abstract extendRange(rangeToExtend: Range3d, transform?: Transform): void;\r\n /**\r\n * Attempt to transform in place.\r\n * * LineSegment3d, Arc3d, LineString3d, BsplineCurve3d always succeed.\r\n * * Some geometry types may fail if scaling is non-uniform.\r\n */\r\n public abstract tryTransformInPlace(transform: Transform): boolean;\r\n /** Try to move the geometry by dx,dy,dz. */\r\n public tryTranslateInPlace(dx: number, dy: number = 0.0, dz: number = 0.0): boolean {\r\n return this.tryTransformInPlace(Transform.createTranslationXYZ(dx, dy, dz));\r\n }\r\n /** Return a transformed clone. */\r\n public abstract cloneTransformed(transform: Transform): GeometryQuery | undefined;\r\n /** Return a clone */\r\n public abstract clone(): GeometryQuery | undefined;\r\n /**\r\n * Return GeometryQuery children for recursive queries.\r\n * * leaf classes do not need to implement.\r\n */\r\n public get children(): GeometryQuery[] | undefined {\r\n return undefined;\r\n }\r\n /** Test `if (other instanceof this.Type)`. REQUIRED IN ALL CONCRETE CLASSES. */\r\n public abstract isSameGeometryClass(other: GeometryQuery): boolean;\r\n /**\r\n * Test for exact structure and nearly identical geometry.\r\n * * Leaf classes must implement.\r\n * * Base class implementation recurses through children.\r\n * * Base implementation is complete for classes with children and no properties.\r\n * * Classes with both children and properties must implement for properties, call super for children.\r\n */\r\n public isAlmostEqual(other: GeometryQuery): boolean {\r\n if (this.isSameGeometryClass(other)) {\r\n const childrenA = this.children;\r\n const childrenB = other.children;\r\n if (childrenA && childrenB) {\r\n if (childrenA.length !== childrenB.length)\r\n return false;\r\n for (let i = 0; i < childrenA.length; i++) {\r\n if (!childrenA[i].isAlmostEqual(childrenB[i]))\r\n return false;\r\n }\r\n return true;\r\n } else if (childrenA || childrenB) { // CurveCollections start with empty arrays for children so these null pointer cases are never reached.\r\n return false; // plainly different\r\n } else {\r\n return true; // both children null; call it equal\r\n }\r\n }\r\n return false;\r\n }\r\n /**\r\n * Apply instance method [[isAlmostEqual]] if both are defined.\r\n * * Both undefined returns true.\r\n * * Single defined returns false.\r\n */\r\n public static areAlmostEqual(a: GeometryQuery | undefined, b: GeometryQuery | undefined): boolean {\r\n if (a instanceof GeometryQuery && b instanceof GeometryQuery)\r\n return a.isAlmostEqual(b);\r\n if ((a === undefined) && (b === undefined))\r\n return true;\r\n return false;\r\n }\r\n /**\r\n * Double Dispatch call pattern.\r\n * * User code implements a `GeometryHandler` with specialized methods to handle `LineSegment3d`, `Arc3d`, etc as\r\n * relevant to its use case.\r\n * * Each such `GeometryQuery` class implements this method as a one-line method containing the appropriate call\r\n * such as `handler.handleLineSegment3d())`\r\n * * This allows each type-specific method to be called without a switch or `instanceof` test.\r\n * @param handler handler to be called by the particular geometry class\r\n */\r\n public abstract dispatchToGeometryHandler(handler: GeometryHandler): any;\r\n\r\n /**\r\n * Compute a distance tolerance appropriate for comparing the coordinates of `geom`.\r\n * * The formula is `absTol = minTol + relTol * geomSize`, where `geomSize` is the largest absolute coordinate of\r\n * the geometry range.\r\n * * Scaling tolerances by geometry size helps account for the decreased floating point resolution between large\r\n * coordinates. While using such scaled tolerances can enable more tolerance-sensitive constructions to succeed on\r\n * far-flung geometries, on extremely small geometries at extremely large coordinate magnitudes, geometric\r\n * constructions are generally more accurate when applied to the geometry temporarily translated to the origin.\r\n * @param geom geometry to measure\r\n * @param options bundle of options\r\n * @returns the computed absolute tolerance\r\n * @see [[scaleToleranceForGeometry]]\r\n */\r\n public static computeScaledTolerance(geom: GeometryQuery | GeometryQuery[], options?: ScaledToleranceOptions): number {\r\n const relTol = Math.abs(options?.relativeTolerance ?? Geometry.smallMetricDistance);\r\n const minTol = Math.abs(options?.minimumTolerance ?? Geometry.smallMetricDistanceSquared);\r\n const geomRange = Range3d.createNull();\r\n (Array.isArray(geom) ? geom : [geom]).forEach((g: GeometryQuery) => g.extendRange(geomRange, options?.transform));\r\n const geomSize = geomRange.isNull ? 0 : options?.xyOnly ? geomRange.maxAbsXY() : geomRange.maxAbs();\r\n return minTol + relTol * geomSize;\r\n }\r\n\r\n /**\r\n * Scale the given distance tolerance as appropriate for comparing the coordinates of `geom`.\r\n * * Scaling tolerances by geometry size helps account for the decreased floating point resolution between large\r\n * coordinates. While using such scaled tolerances can enable more tolerance-sensitive constructions to succeed on\r\n * far-flung geometries, on extremely small geometries at extremely large coordinate magnitudes, geometric\r\n * constructions are generally more accurate when applied to the geometry temporarily translated to the origin.\r\n * @param geom geometry to measure\r\n * @param distanceTolerance positive input distance tolerance to examine\r\n * @param options bundle of options (`minimumTolerance` and `relativeTolerance` are ignored)\r\n * @return a distance tolerance >= `distanceTolerance`\r\n * @see [[computeScaledTolerance]]\r\n */\r\n public static scaleToleranceForGeometry(geom: GeometryQuery | GeometryQuery[], distanceTolerance: number, options?: ScaledToleranceOptions): number {\r\n if (distanceTolerance > 0) {\r\n const geomRange = Range3d.createNull();\r\n (Array.isArray(geom) ? geom : [geom]).forEach((g: GeometryQuery) => g.extendRange(geomRange, options?.transform));\r\n if (!geomRange.isNull) {\r\n const geomSize = options?.xyOnly ? geomRange.maxAbsXY() : geomRange.maxAbs();\r\n if (geomSize > 0) {\r\n // HEURISTIC: truncate the fractional part of a coordinate's base-10 significand to maxDigits digits.\r\n // Adding the tolerance to this number should change the significand; otherwise, it's too small.\r\n const maxDigits = 10; // comfortably far from IEEE double's 15 guaranteed fractional digits\r\n const requiredDigitsForTol = Math.floor(Math.log10(geomSize / distanceTolerance));\r\n if (requiredDigitsForTol > maxDigits)\r\n distanceTolerance *= Math.pow(10, requiredDigitsForTol - maxDigits);\r\n }\r\n }\r\n }\r\n return distanceTolerance;\r\n }\r\n}\r\n"]}
@@ -3,6 +3,39 @@ import { CurveLocationDetailPair } from "../CurveLocationDetail";
3
3
  import { CurvePrimitive } from "../CurvePrimitive";
4
4
  import { Loop, SignedLoops } from "../Loop";
5
5
  import { ParityRegion } from "../ParityRegion";
6
+ /** @packageDocumentation
7
+ * @module Curve
8
+ */
9
+ /**
10
+ * Options bundle for [[PlanarSubdivision.createLoopInFace]] and [[PlanarSubdivision.createLoopOrParityRegionInFace]].
11
+ * @internal
12
+ */
13
+ export interface CreateRegionInFaceOptions {
14
+ /**
15
+ * Optional callback invoked on each `edge` before its `curve` is added to `loop`.
16
+ * * Note that if a [[ParityRegion]] is being constructed, `curve` and `loop` may subsequently be reversed.
17
+ */
18
+ announceEdge?: (edge: HalfEdge, curve: CurvePrimitive, loop: Loop) => void;
19
+ /**
20
+ * Whether to consolidate adjacent curves in an output [[Loop]]. Default value is `false`.
21
+ * * If `announce` is defined, no compression is performed, as edges and curves would no longer be in 1-1 correspondence.
22
+ */
23
+ compress?: boolean;
24
+ /** Absolute xy-distance for confirming a returned Loop is closed. Default value is [[Geometry.smallMetricDistance]]. */
25
+ closureTol?: number;
26
+ /**
27
+ * Mask preset on bridge edges. Default value is `HalfEdgeMask.BRIDGE_EDGE`.
28
+ * * This mask is used to distinguish a split-washer type face, which can result in a [[ParityRegion]].
29
+ */
30
+ bridgeMask?: HalfEdgeMask;
31
+ /** Mask to use for visiting edges when creating a [[ParityRegion]] from a split-washer type face. Default value is `HalfEdgeMask.VISITED`. */
32
+ visitMask?: HalfEdgeMask;
33
+ /**
34
+ * Optional z-coordinate for the result region.
35
+ * * If undefined, graph z-coordinates are used, but this may result in a non-planar region if the graph is not planar!
36
+ */
37
+ z?: number;
38
+ }
6
39
  /**
7
40
  * @internal
8
41
  */
@@ -14,7 +47,7 @@ export declare class PlanarSubdivision {
14
47
  * @param allPairs array of curve-curve xy-intersections
15
48
  * @param mergeTolerance optional distance tolerance for clustering vertices. Default value is [[Geometry.smallMetricDistance]].
16
49
  */
17
- static assembleHalfEdgeGraph(primitives: CurvePrimitive[], allPairs: CurveLocationDetailPair[], mergeTolerance?: number): HalfEdgeGraph;
50
+ static assembleHalfEdgeGraph(primitives: CurvePrimitive[], allPairs: CurveLocationDetailPair[], mergeTolerance?: number, radianTolerance?: number): HalfEdgeGraph;
18
51
  /**
19
52
  * Filter for trivial curve fragment: fast computation if line segment; otherwise clip, flatten, and measure.
20
53
  * * Different metrics are employed for expedience.
@@ -50,7 +83,7 @@ export declare class PlanarSubdivision {
50
83
  * @param options bundle of options.
51
84
  * @returns the Loop, or `undefined` if it is not closed within xy-tolerance.
52
85
  */
53
- static createLoopInFace(face: HalfEdge | HalfEdge[], options?: PlanarSubdivision.CreateRegionInFaceOptions): Loop | undefined;
86
+ static createLoopInFace(face: HalfEdge | HalfEdge[], options?: CreateRegionInFaceOptions): Loop | undefined;
54
87
  /**
55
88
  * Create a [[Loop]] or [[ParityRegion]] for the given face.
56
89
  * * A ParityRegion is created for a split-washer type face by removing bridge edges.
@@ -58,43 +91,11 @@ export declare class PlanarSubdivision {
58
91
  * @param options bundle of options.
59
92
  * @returns the Loop or ParityRegion, or `undefined` if one could not be computed.
60
93
  */
61
- static createLoopOrParityRegionInFace(face: HalfEdge, options?: PlanarSubdivision.CreateRegionInFaceOptions): Loop | ParityRegion | undefined;
94
+ static createLoopOrParityRegionInFace(face: HalfEdge, options?: CreateRegionInFaceOptions): Loop | ParityRegion | undefined;
62
95
  /** Return true if there are only two edges in the face loop, and their start curvatures are the same. */
63
96
  private static isNullFace;
64
97
  /** Look across edge mates (possibly several) for a non-null mate face. */
65
98
  private static getNonNullEdgeMate;
66
99
  static collectSignedLoopSetsInHalfEdgeGraph(graph: HalfEdgeGraph, closureTol?: number, areaTol?: number): SignedLoops[];
67
100
  }
68
- /**
69
- * @internal
70
- */
71
- export declare namespace PlanarSubdivision {
72
- /** Options bundle for [[PlanarSubdivision.createLoopInFace]] and [[PlanarSubdivision.createLoopOrParityRegionInFace]]. */
73
- interface CreateRegionInFaceOptions {
74
- /**
75
- * Optional callback invoked on each `edge` before its `curve` is added to `loop`.
76
- * * Note that if a [[ParityRegion]] is being constructed, `curve` and `loop` may subsequently be reversed.
77
- */
78
- announceEdge?: (edge: HalfEdge, curve: CurvePrimitive, loop: Loop) => void;
79
- /**
80
- * Whether to consolidate adjacent curves in an output [[Loop]]. Default value is `false`.
81
- * * If `announce` is defined, no compression is performed, as edges and curves would no longer be in 1-1 correspondence.
82
- */
83
- compress?: boolean;
84
- /** Absolute xy-distance for confirming a returned Loop is closed. Default value is [[Geometry.smallMetricDistance]]. */
85
- closureTol?: number;
86
- /**
87
- * Mask preset on bridge edges. Default value is `HalfEdgeMask.BRIDGE_EDGE`.
88
- * * This mask is used to distinguish a split-washer type face, which can result in a [[ParityRegion]].
89
- */
90
- bridgeMask?: HalfEdgeMask;
91
- /** Mask to use for visiting edges when creating a [[ParityRegion]] from a split-washer type face. Default value is `HalfEdgeMask.VISITED`. */
92
- visitMask?: HalfEdgeMask;
93
- /**
94
- * Optional z-coordinate for the result region.
95
- * * If undefined, graph z-coordinates are used, but this may result in a non-planar region if the graph is not planar!
96
- */
97
- z?: number;
98
- }
99
- }
100
101
  //# sourceMappingURL=PlanarSubdivision.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlanarSubdivision.d.ts","sourceRoot":"","sources":["../../../../src/curve/Query/PlanarSubdivision.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI7E,OAAO,EAAuB,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD,OAAO,EAAE,IAAI,EAAsB,WAAW,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAyE/C;;GAEG;AACH,qBAAa,iBAAiB;IAC5B;;;;;;OAMG;WACW,qBAAqB,CACjC,UAAU,EAAE,cAAc,EAAE,EAC5B,QAAQ,EAAE,uBAAuB,EAAE,EACnC,cAAc,GAAE,MAAqC,GACpD,aAAa;IAoDhB;;;MAGE;IACF,OAAO,CAAC,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IA6B1B;;;;;;OAMG;WACW,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,GAAE,MAAgB,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,MAAM;IAe7H,sDAAsD;IACtD,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAUtC,kDAAkD;IAClD,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAYhC;;;;;OAKG;WACW,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,EAAE,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,IAAI,GAAG,SAAS;IAsBlH;;;;;;OAMG;WACW,8BAA8B,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,IAAI,GAAG,YAAY,GAAG,SAAS;IAqClI,yGAAyG;IACzG,OAAO,CAAC,MAAM,CAAC,UAAU;IAWzB,0EAA0E;IAC1E,OAAO,CAAC,MAAM,CAAC,kBAAkB;WAWnB,oCAAoC,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,GAAE,MAAqC,EAAE,OAAO,GAAE,MAAgB,GAAG,WAAW,EAAE;CAkCtK"}
@@ -19,8 +19,8 @@ const Loop_1 = require("../Loop");
19
19
  const ParityRegion_1 = require("../ParityRegion");
20
20
  const RegionOps_1 = require("../RegionOps");
21
21
  const RegionOpsClassificationSweeps_1 = require("../RegionOpsClassificationSweeps");
22
- /** @packageDocumentation
23
- * @module Curve
22
+ /**
23
+ * @internal
24
24
  */
25
25
  class MapCurvePrimitiveToCurveLocationDetailPairArray {
26
26
  primitiveToPair = new Map();
@@ -90,7 +90,7 @@ class PlanarSubdivision {
90
90
  * @param allPairs array of curve-curve xy-intersections
91
91
  * @param mergeTolerance optional distance tolerance for clustering vertices. Default value is [[Geometry.smallMetricDistance]].
92
92
  */
93
- static assembleHalfEdgeGraph(primitives, allPairs, mergeTolerance = Geometry_1.Geometry.smallMetricDistance) {
93
+ static assembleHalfEdgeGraph(primitives, allPairs, mergeTolerance = Geometry_1.Geometry.smallMetricDistance, radianTolerance = Geometry_1.Geometry.smallAngleRadians) {
94
94
  // map from key CurvePrimitive to CurveLocationDetailPair
95
95
  const detailByPrimitive = new MapCurvePrimitiveToCurveLocationDetailPairArray();
96
96
  for (const pair of allPairs)
@@ -138,7 +138,7 @@ class PlanarSubdivision {
138
138
  this.addHalfEdge(graph, p, last.point, last.fraction, p.endPoint(), 1.0, mergeTolerance);
139
139
  }
140
140
  // every edge got its sortAngle defined by addHalfEdge
141
- Merging_1.HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph, (he) => he.sortAngle ?? 0, mergeTolerance);
141
+ Merging_1.HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph, (he) => he.sortAngle ?? 0, mergeTolerance, radianTolerance);
142
142
  return graph;
143
143
  }
144
144
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"PlanarSubdivision.js","sourceRoot":"","sources":["../../../../src/curve/Query/PlanarSubdivision.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,sDAA6C;AAC7C,6CAA0C;AAE1C,0DAAuD;AACvD,gDAA6E;AAC7E,4EAAyE;AACzE,oDAA4D;AAC5D,oCAAiC;AACjC,gEAAsF;AAGtF,oDAAiD;AACjD,kDAA+C;AAC/C,kCAAgE;AAChE,kDAA+C;AAC/C,4CAAyC;AACzC,oFAAwF;AAExF;;GAEG;AAEH,MAAM,+CAA+C;IAC5C,eAAe,GAAG,IAAI,GAAG,EAA6C,CAAC;IAC9E,mDAAmD;IAC5C,gBAAgB,GAAG,IAAI,GAAG,EAA0B,CAAC;IACpD,qBAAqB,GAAW,CAAC,CAAC;IACnC,oBAAoB,CAAC,SAAqC;QAC/D,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACnD,IAAI,KAAK,KAAK,SAAS,E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,EAAE,EAAE,EAAE,CAAC,CAAC;wBACtB,CAAC;6BAAM,IAAI,CAAC,YAAY,yBAAkB,EAAE,CAAC;4BAC3C,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;4BACtB,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;4BACd,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;wBACvB,CAAC;oBACH,CAAC;gBACH,CAAC,CAAC;gBACF,MAAM,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC,CAAC;gBAC3E,IAAI,IAAI;oBACN,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;YACtE,CAAC;YACD,cAAc,CAAC,KAAK,GAAG,KAAK,CAAC;YAC7B,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC5B,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAvSD,8CAuSC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Geometry } from \"../../Geometry\";\r\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\r\nimport { Transform } from \"../../geometry3d/Transform\";\r\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask } from \"../../topology/Graph\";\r\nimport { HalfEdgeGraphSearch } from \"../../topology/HalfEdgeGraphSearch\";\r\nimport { HalfEdgeGraphMerge } from \"../../topology/Merging\";\r\nimport { Arc3d } from \"../Arc3d\";\r\nimport { CurveLocationDetail, CurveLocationDetailPair } from \"../CurveLocationDetail\";\r\nimport { CurvePrimitive } from \"../CurvePrimitive\";\r\nimport { AnyRegion } from \"../CurveTypes\";\r\nimport { LineSegment3d } from \"../LineSegment3d\";\r\nimport { LineString3d } from \"../LineString3d\";\r\nimport { Loop, LoopCurveLoopCurve, SignedLoops } from \"../Loop\";\r\nimport { ParityRegion } from \"../ParityRegion\";\r\nimport { RegionOps } from \"../RegionOps\";\r\nimport { RegionGroupMember, RegionGroupOpType } from \"../RegionOpsClassificationSweeps\";\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nclass MapCurvePrimitiveToCurveLocationDetailPairArray {\r\n public primitiveToPair = new Map<CurvePrimitive, CurveLocationDetailPair[]>();\r\n // index assigned to this primitive (for debugging)\r\n public primitiveToIndex = new Map<CurvePrimitive, number>();\r\n private _numIndexedPrimitives: number = 0;\r\n public assignPrimitiveIndex(primitive: CurvePrimitive | undefined) {\r\n if (primitive !== undefined) {\r\n const index = this.primitiveToIndex.get(primitive);\r\n if (index === undefined) {\r\n this.primitiveToIndex.set(primitive, this._numIndexedPrimitives++);\r\n }\r\n }\r\n }\r\n public insertPrimitiveToPair(primitive: CurvePrimitive | undefined, pair: CurveLocationDetailPair) {\r\n if (primitive) {\r\n const priorPairs = this.primitiveToPair.get(primitive);\r\n this.assignPrimitiveIndex(primitive);\r\n if (!priorPairs) {\r\n this.primitiveToPair.set(primitive, [pair]);\r\n } else {\r\n priorPairs.push(pair);\r\n }\r\n }\r\n }\r\n public insertPair(pair: CurveLocationDetailPair) {\r\n const primitiveA = pair.detailA.curve;\r\n if (primitiveA)\r\n this.insertPrimitiveToPair(primitiveA, pair);\r\n const primitiveB = pair.detailB.curve;\r\n if (primitiveB)\r\n this.insertPrimitiveToPair(primitiveB, pair);\r\n }\r\n /**\r\n * Split closed missing primitives in half and add new intersection pairs.\r\n * * When bridge edges aren't included in the primitives array, a closed primitive with no intersections will not be\r\n * added to the graph because it isn't in the `primitiveToPair` map. By splitting such a missing primitive in two, we\r\n * introduce two intersections for each half, which allows the primitive to be represented in the map.\r\n */\r\n public splitAndAppendMissingClosedPrimitives(\r\n primitives: CurvePrimitive[], tolerance: number = Geometry.smallMetricDistance,\r\n ): void {\r\n for (const p of primitives) {\r\n let closedCurveSplitCandidate = false;\r\n if (p instanceof Arc3d)\r\n closedCurveSplitCandidate = p.sweep.isFullCircle;\r\n else if (!(p instanceof LineSegment3d) && !(p instanceof LineString3d)) // TODO: probably should do this for all types. Lots of spline-type primitives can be closed.\r\n closedCurveSplitCandidate = p.startPoint().isAlmostEqualXY(p.endPoint(), tolerance);\r\n if (closedCurveSplitCandidate && !this.primitiveToPair.has(p)) {\r\n const p0 = p.clonePartialCurve(0.0, 0.5);\r\n const p1 = p.clonePartialCurve(0.5, 1.0);\r\n if (p0 && p1) {\r\n this.insertPair(CurveLocationDetailPair.createCapture(\r\n CurveLocationDetail.createCurveEvaluatedFraction(p0, 0.0),\r\n CurveLocationDetail.createCurveEvaluatedFraction(p1, 1.0),\r\n ));\r\n this.insertPair(CurveLocationDetailPair.createCapture(\r\n CurveLocationDetail.createCurveEvaluatedFraction(p0, 1.0),\r\n CurveLocationDetail.createCurveEvaluatedFraction(p1, 0.0),\r\n ));\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class PlanarSubdivision {\r\n /**\r\n * Create a graph from curves and precomputed intersections.\r\n * * Z-coordinates are ignored.\r\n * @param primitives input curves\r\n * @param allPairs array of curve-curve xy-intersections\r\n * @param mergeTolerance optional distance tolerance for clustering vertices. Default value is [[Geometry.smallMetricDistance]].\r\n */\r\n public static assembleHalfEdgeGraph(\r\n primitives: CurvePrimitive[],\r\n allPairs: CurveLocationDetailPair[],\r\n mergeTolerance: number = Geometry.smallMetricDistance,\r\n ): HalfEdgeGraph {\r\n // map from key CurvePrimitive to CurveLocationDetailPair\r\n const detailByPrimitive = new MapCurvePrimitiveToCurveLocationDetailPairArray();\r\n for (const pair of allPairs)\r\n detailByPrimitive.insertPair(pair);\r\n if (primitives.length > detailByPrimitive.primitiveToPair.size) {\r\n // otherwise, these single-primitive loops are missing from the graph\r\n detailByPrimitive.splitAndAppendMissingClosedPrimitives(primitives, mergeTolerance);\r\n }\r\n // these helper lambdas assume exactly one of the paired details is on the input curve\r\n const getFractionOnCurve = (pair: CurveLocationDetailPair, curve: CurvePrimitive): number => {\r\n return (pair.detailA.curve === curve) ? pair.detailA.fraction : pair.detailB.fraction;\r\n };\r\n const getDetailOnCurve = (pair: CurveLocationDetailPair, curve: CurvePrimitive): CurveLocationDetail => {\r\n return (pair.detailA.curve === curve) ? pair.detailA : pair.detailB;\r\n };\r\n const graph = new HalfEdgeGraph();\r\n for (const entry of detailByPrimitive.primitiveToPair.entries()) {\r\n const p = entry[0];\r\n // convert each interval intersection into two isolated intersections\r\n const details = entry[1].reduce((accumulator: CurveLocationDetailPair[], detailPair) => {\r\n const detail = getDetailOnCurve(detailPair, p);\r\n if (detail.isInterval()) {\r\n const detail0 = CurveLocationDetail.createCurveFractionPoint(p, detail.fraction, detail.point);\r\n const detail1 = CurveLocationDetail.createCurveFractionPoint(p, detail.fraction1, detail.point1);\r\n return [\r\n ...accumulator,\r\n CurveLocationDetailPair.createCapture(detail0, detail0),\r\n CurveLocationDetailPair.createCapture(detail1, detail1),\r\n ];\r\n }\r\n return [...accumulator, detailPair];\r\n }, []);\r\n // lexical sort on p intersection fraction\r\n details.sort((pairA: CurveLocationDetailPair, pairB: CurveLocationDetailPair) => {\r\n const fractionA = getFractionOnCurve(pairA, p);\r\n const fractionB = getFractionOnCurve(pairB, p);\r\n return fractionA - fractionB;\r\n });\r\n let last = { point: p.startPoint(), fraction: 0.0 };\r\n for (const detailPair of details) {\r\n const detail = getDetailOnCurve(detailPair, p);\r\n const detailFraction = Geometry.restrictToInterval(detail.fraction, 0, 1); // truncate fraction, but don't snap point; clustering happens later\r\n last = this.addHalfEdge(graph, p, last.point, last.fraction, detail.point, detailFraction, mergeTolerance);\r\n }\r\n this.addHalfEdge(graph, p, last.point, last.fraction, p.endPoint(), 1.0, mergeTolerance);\r\n }\r\n // every edge got its sortAngle defined by addHalfEdge\r\n HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph, (he: HalfEdge) => he.sortAngle ?? 0, mergeTolerance);\r\n return graph;\r\n }\r\n\r\n /**\r\n * Filter for trivial curve fragment: fast computation if line segment; otherwise clip, flatten, and measure.\r\n * * Different metrics are employed for expedience.\r\n */\r\n private static isCurveTrivialXY(p: CurvePrimitive, point0: Point3d, fraction0: number, point1: Point3d, fraction1: number, mergeTolerance: number): boolean {\r\n if (Geometry.isSmallRelative(fraction0 - fraction1))\r\n return true;\r\n if (!(p instanceof LineSegment3d)) {\r\n const p0 = p.clonePartialCurve(fraction0, fraction1);\r\n if (p0?.tryTransformInPlace(Transform.createRowValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0))) // flatten\r\n return p0.curveLength() <= mergeTolerance; // Euclidean\r\n }\r\n return point0.isAlmostEqualXY(point1, mergeTolerance); // Manhattan\r\n }\r\n\r\n /**\r\n * Create a pair of mated half edges referencing a non-trivial interval of a primitive.\r\n * @param graph containing graph\r\n * @param p the curve\r\n * @param point0 start point\r\n * @param fraction0 starting fraction\r\n * @param point1 end point\r\n * @param fraction1 end fraction\r\n * @param mergeTolerance optional maximum xy-length of a trivial edge\r\n * @returns end point and fraction\r\n */\r\n private static addHalfEdge(\r\n graph: HalfEdgeGraph,\r\n p: CurvePrimitive,\r\n point0: Point3d,\r\n fraction0: number,\r\n point1: Point3d,\r\n fraction1: number,\r\n mergeTolerance: number = Geometry.smallMetricDistance,\r\n ): { point: Point3d, fraction: number } {\r\n if (!this.isCurveTrivialXY(p, point0, fraction0, point1, fraction1, mergeTolerance)) {\r\n const halfEdge = graph.createEdgeXYAndZ(point0, 0, point1, 0);\r\n if (p.parent && p.parent instanceof RegionGroupMember && p.parent.parentGroup.groupOpType === RegionGroupOpType.NonBounding)\r\n halfEdge.setMaskAroundEdge(HalfEdgeMask.BRIDGE_EDGE);\r\n const detail01 = CurveLocationDetail.createCurveEvaluatedFractionFraction(p, fraction0, fraction1);\r\n const mate = halfEdge.edgeMate;\r\n halfEdge.edgeTag = detail01;\r\n halfEdge.sortData = 1.0;\r\n mate.edgeTag = detail01;\r\n mate.sortData = -1.0;\r\n const computeSortAngle = (f: number, reverse: boolean): number => {\r\n const ray = p.fractionToPointAndDerivative(f);\r\n const s = reverse ? -1.0 : 1.0;\r\n return Math.atan2(s * ray.direction.y, s * ray.direction.x);\r\n };\r\n halfEdge.sortAngle = computeSortAngle(fraction0, false);\r\n mate.sortAngle = computeSortAngle(fraction1, true);\r\n }\r\n return { point: point1, fraction: fraction1 }; // where the next curve fragment starts\r\n }\r\n /**\r\n * Based on computed (and toleranced) area, push the loop (pointer) onto the appropriate array of positive, negative,\r\n * or sliver loops.\r\n * @param areaTol absolute area tolerance for sliver face detection\r\n * @param isSliverFace whether the loop is known a priori (e.g., via topology) to have zero area\r\n * @returns the area (forced to zero if within tolerance)\r\n */\r\n public static collectSignedLoop(loop: Loop, outLoops: SignedLoops, areaTol: number = 1.0e-10, isSliverFace?: boolean): number {\r\n let area = isSliverFace ? 0.0 : RegionOps.computeXYArea(loop);\r\n if (area === undefined)\r\n area = 0;\r\n if (Math.abs(area) < areaTol)\r\n area = 0.0;\r\n (loop as any).computedAreaInPlanarSubdivision = area;\r\n if (area > 0)\r\n outLoops.positiveAreaLoops.push(loop);\r\n else if (area < 0)\r\n outLoops.negativeAreaLoops.push(loop);\r\n else\r\n outLoops.slivers.push(loop);\r\n return area;\r\n }\r\n /** Extract geometric info from a topological edge. */\r\n private static extractGeometryFromEdge(edge: HalfEdge): { detail: CurveLocationDetail, reversed: boolean } | undefined {\r\n if (edge.sortData !== undefined && edge.edgeTag && edge.edgeTag instanceof CurveLocationDetail) {\r\n const detail = edge.edgeTag;\r\n if (detail.curve && detail.fraction1 !== undefined) {\r\n const reversed = edge.sortData < 0;\r\n return { detail, reversed };\r\n }\r\n }\r\n return undefined;\r\n }\r\n /** Create the geometry for a topological edge. */\r\n private static createCurveInEdge(edge: HalfEdge, z?: number): CurvePrimitive | undefined {\r\n let result: CurvePrimitive | undefined;\r\n const info = this.extractGeometryFromEdge(edge);\r\n if (info && info.detail.curve && info.detail.isInterval()) {\r\n const f0 = info.reversed ? info.detail.fraction1 : info.detail.fraction;\r\n const f1 = info.reversed ? info.detail.fraction : info.detail.fraction1;\r\n result = info.detail.curve.clonePartialCurve(f0, f1);\r\n if (result && z !== undefined)\r\n result.tryTransformInPlace(Transform.createRowValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, z));\r\n }\r\n return result;\r\n }\r\n /**\r\n * Create a [[Loop]] for the given face or super face.\r\n * @param face a node in the face loop, or an array of HalfEdges that comprise a loop (e.g., a super face).\r\n * @param options bundle of options.\r\n * @returns the Loop, or `undefined` if it is not closed within xy-tolerance.\r\n */\r\n public static createLoopInFace(face: HalfEdge | HalfEdge[], options?: PlanarSubdivision.CreateRegionInFaceOptions): Loop | undefined {\r\n const consolidate = options?.announceEdge ? false : options?.compress ?? false; // can't compress if announcing\r\n const loop = Loop.create();\r\n const addEdgeCurve = (edge: HalfEdge): void => {\r\n const curve = this.createCurveInEdge(edge, options?.z);\r\n if (curve) {\r\n options?.announceEdge?.(edge, curve, loop);\r\n loop.tryAddChild(curve);\r\n }\r\n };\r\n if (Array.isArray(face))\r\n face.forEach(addEdgeCurve);\r\n else\r\n face.announceEdgesInFace(addEdgeCurve);\r\n if (consolidate) {\r\n RegionOps.consolidateAdjacentPrimitives(loop, { consolidateLoopSeam: true });\r\n }\r\n if (loop.isPhysicallyClosedCurve(options?.closureTol, true))\r\n return loop;\r\n assert(() => false, \"face is not physically closed\");\r\n return undefined;\r\n }\r\n /**\r\n * Create a [[Loop]] or [[ParityRegion]] for the given face.\r\n * * A ParityRegion is created for a split-washer type face by removing bridge edges.\r\n * @param face a node in the face loop.\r\n * @param options bundle of options.\r\n * @returns the Loop or ParityRegion, or `undefined` if one could not be computed.\r\n */\r\n public static createLoopOrParityRegionInFace(face: HalfEdge, options?: PlanarSubdivision.CreateRegionInFaceOptions): Loop | ParityRegion | undefined {\r\n let region: AnyRegion | undefined;\r\n const visitMask = options?.visitMask ?? HalfEdgeMask.VISITED;\r\n const bridgeMask = options?.bridgeMask ?? HalfEdgeMask.BRIDGE_EDGE;\r\n let startBridgeEdge: HalfEdge | undefined;\r\n // is it a split-washer face?\r\n if (face.isSplitWasherFace(bridgeMask) && (startBridgeEdge = face.findMaskAroundFace(bridgeMask, true))) {\r\n const loops: Loop[] = [];\r\n const loopEdges: HalfEdge[] = [];\r\n const bridgeStack: HalfEdge[] = [startBridgeEdge];\r\n const announceEdge = (he: HalfEdge) => { he.setMask(visitMask); loopEdges.push(he); };\r\n const announceBridge = (he: HalfEdge) => { if (!he.isMaskSet(visitMask)) bridgeStack.push(he); };\r\n face.clearMaskAroundFace(visitMask);\r\n let bridge: HalfEdge | undefined;\r\n while (undefined !== (bridge = bridgeStack.pop())) {\r\n bridge.setMask(visitMask);\r\n const loopSeed = bridge.findMaskAroundFace(bridgeMask, false); // advance to next loop\r\n if (loopSeed) {\r\n if (loopSeed.isMaskSet(visitMask))\r\n continue;\r\n loopEdges.length = 0;\r\n if (loopSeed.announceEdgesInSuperFace(bridgeMask, announceEdge, announceBridge)) {\r\n const loop = this.createLoopInFace(loopEdges, options);\r\n if (loop) {\r\n loops.push(loop);\r\n continue;\r\n }\r\n }\r\n }\r\n }\r\n region = RegionOps.sortOuterAndHoleLoopsXY(loops);\r\n region = RegionOps.simplifyRegion(region);\r\n } else {\r\n region = this.createLoopInFace(face, options);\r\n }\r\n return (region && (region instanceof Loop || region instanceof ParityRegion)) ? region : undefined;\r\n }\r\n /** Return true if there are only two edges in the face loop, and their start curvatures are the same. */\r\n private static isNullFace(he: HalfEdge): boolean {\r\n const faceHasTwoEdges = (he.faceSuccessor.faceSuccessor === he);\r\n let faceIsBanana = false;\r\n if (faceHasTwoEdges) {\r\n const c0 = HalfEdgeGraphMerge.curvatureSortKey(he);\r\n const c1 = HalfEdgeGraphMerge.curvatureSortKey(he.faceSuccessor.edgeMate);\r\n if (!Geometry.isSameCoordinate(c0, c1)) // default tol!\r\n faceIsBanana = true; // heuristic: we could also check end curvatures, and/or higher derivatives...\r\n }\r\n return faceHasTwoEdges && !faceIsBanana;\r\n }\r\n /** Look across edge mates (possibly several) for a non-null mate face. */\r\n private static getNonNullEdgeMate(_graph: HalfEdgeGraph, e: HalfEdge): HalfEdge | undefined {\r\n if (this.isNullFace(e))\r\n return undefined;\r\n let e1 = e.edgeMate;\r\n while (this.isNullFace(e1)) {\r\n e1 = e1.faceSuccessor.edgeMate;\r\n if (e1 === e)\r\n return undefined;\r\n }\r\n return e1;\r\n }\r\n public static collectSignedLoopSetsInHalfEdgeGraph(graph: HalfEdgeGraph, closureTol: number = Geometry.smallMetricDistance, areaTol: number = 1.0e-10): SignedLoops[] {\r\n const q = HalfEdgeGraphSearch.collectConnectedComponentsWithExteriorParityMasks(graph, undefined);\r\n const result: SignedLoops[] = [];\r\n const edgeMap = new Map<HalfEdge, LoopCurveLoopCurve>();\r\n for (const faceSeeds of q) {\r\n const componentAreas: SignedLoops = { positiveAreaLoops: [], negativeAreaLoops: [], slivers: [] };\r\n const edges: LoopCurveLoopCurve[] = [];\r\n for (const faceSeed of faceSeeds) {\r\n const isNullFace = this.isNullFace(faceSeed);\r\n const announceEdge = isNullFace ? undefined : (he: HalfEdge, curveC: CurvePrimitive, loopC: Loop) => {\r\n const mate = this.getNonNullEdgeMate(graph, he);\r\n if (mate !== undefined) {\r\n const e = edgeMap.get(mate);\r\n if (e === undefined) {\r\n // Record this as loopA,edgeA of a shared edge to be completed later from the other side of the edge\r\n const e1 = new LoopCurveLoopCurve(loopC, curveC, undefined, undefined);\r\n edgeMap.set(he, e1);\r\n } else if (e instanceof LoopCurveLoopCurve) {\r\n e.setB(loopC, curveC);\r\n edges.push(e);\r\n edgeMap.delete(mate);\r\n }\r\n }\r\n };\r\n const loop = this.createLoopInFace(faceSeed, { announceEdge, closureTol });\r\n if (loop)\r\n this.collectSignedLoop(loop, componentAreas, areaTol, isNullFace);\r\n }\r\n componentAreas.edges = edges;\r\n result.push(componentAreas);\r\n edgeMap.clear();\r\n }\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n*/\r\nexport namespace PlanarSubdivision {\r\n /** Options bundle for [[PlanarSubdivision.createLoopInFace]] and [[PlanarSubdivision.createLoopOrParityRegionInFace]]. */\r\n export interface CreateRegionInFaceOptions {\r\n /**\r\n * Optional callback invoked on each `edge` before its `curve` is added to `loop`.\r\n * * Note that if a [[ParityRegion]] is being constructed, `curve` and `loop` may subsequently be reversed.\r\n */\r\n announceEdge?: (edge: HalfEdge, curve: CurvePrimitive, loop: Loop) => void;\r\n /**\r\n * Whether to consolidate adjacent curves in an output [[Loop]]. Default value is `false`.\r\n * * If `announce` is defined, no compression is performed, as edges and curves would no longer be in 1-1 correspondence.\r\n */\r\n compress?: boolean;\r\n /** Absolute xy-distance for confirming a returned Loop is closed. Default value is [[Geometry.smallMetricDistance]]. */\r\n closureTol?: number;\r\n /**\r\n * Mask preset on bridge edges. Default value is `HalfEdgeMask.BRIDGE_EDGE`.\r\n * * This mask is used to distinguish a split-washer type face, which can result in a [[ParityRegion]].\r\n */\r\n bridgeMask?: HalfEdgeMask;\r\n /** Mask to use for visiting edges when creating a [[ParityRegion]] from a split-washer type face. Default value is `HalfEdgeMask.VISITED`. */\r\n visitMask?: HalfEdgeMask;\r\n /**\r\n * Optional z-coordinate for the result region.\r\n * * If undefined, graph z-coordinates are used, but this may result in a non-planar region if the graph is not planar!\r\n */\r\n z?: number;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"PlanarSubdivision.js","sourceRoot":"","sources":["../../../../src/curve/Query/PlanarSubdivision.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,sDAA6C;AAC7C,6CAA0C;AAE1C,0DAAuD;AACvD,gDAA6E;AAC7E,4EAAyE;AACzE,oDAA4D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xSD,8CAwSC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Geometry } from \"../../Geometry\";\r\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\r\nimport { Transform } from \"../../geometry3d/Transform\";\r\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask } from \"../../topology/Graph\";\r\nimport { HalfEdgeGraphSearch } from \"../../topology/HalfEdgeGraphSearch\";\r\nimport { HalfEdgeGraphMerge } from \"../../topology/Merging\";\r\nimport { Arc3d } from \"../Arc3d\";\r\nimport { CurveLocationDetail, CurveLocationDetailPair } from \"../CurveLocationDetail\";\r\nimport { CurvePrimitive } from \"../CurvePrimitive\";\r\nimport { AnyRegion } from \"../CurveTypes\";\r\nimport { LineSegment3d } from \"../LineSegment3d\";\r\nimport { LineString3d } from \"../LineString3d\";\r\nimport { Loop, LoopCurveLoopCurve, SignedLoops } from \"../Loop\";\r\nimport { ParityRegion } from \"../ParityRegion\";\r\nimport { RegionOps } from \"../RegionOps\";\r\nimport { RegionGroupMember, RegionGroupOpType } from \"../RegionOpsClassificationSweeps\";\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\n/**\r\n * Options bundle for [[PlanarSubdivision.createLoopInFace]] and [[PlanarSubdivision.createLoopOrParityRegionInFace]].\r\n * @internal\r\n */\r\nexport interface CreateRegionInFaceOptions {\r\n /**\r\n * Optional callback invoked on each `edge` before its `curve` is added to `loop`.\r\n * * Note that if a [[ParityRegion]] is being constructed, `curve` and `loop` may subsequently be reversed.\r\n */\r\n announceEdge?: (edge: HalfEdge, curve: CurvePrimitive, loop: Loop) => void;\r\n /**\r\n * Whether to consolidate adjacent curves in an output [[Loop]]. Default value is `false`.\r\n * * If `announce` is defined, no compression is performed, as edges and curves would no longer be in 1-1 correspondence.\r\n */\r\n compress?: boolean;\r\n /** Absolute xy-distance for confirming a returned Loop is closed. Default value is [[Geometry.smallMetricDistance]]. */\r\n closureTol?: number;\r\n /**\r\n * Mask preset on bridge edges. Default value is `HalfEdgeMask.BRIDGE_EDGE`.\r\n * * This mask is used to distinguish a split-washer type face, which can result in a [[ParityRegion]].\r\n */\r\n bridgeMask?: HalfEdgeMask;\r\n /** Mask to use for visiting edges when creating a [[ParityRegion]] from a split-washer type face. Default value is `HalfEdgeMask.VISITED`. */\r\n visitMask?: HalfEdgeMask;\r\n /**\r\n * Optional z-coordinate for the result region.\r\n * * If undefined, graph z-coordinates are used, but this may result in a non-planar region if the graph is not planar!\r\n */\r\n z?: number;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nclass MapCurvePrimitiveToCurveLocationDetailPairArray {\r\n public primitiveToPair = new Map<CurvePrimitive, CurveLocationDetailPair[]>();\r\n // index assigned to this primitive (for debugging)\r\n public primitiveToIndex = new Map<CurvePrimitive, number>();\r\n private _numIndexedPrimitives: number = 0;\r\n public assignPrimitiveIndex(primitive: CurvePrimitive | undefined) {\r\n if (primitive !== undefined) {\r\n const index = this.primitiveToIndex.get(primitive);\r\n if (index === undefined) {\r\n this.primitiveToIndex.set(primitive, this._numIndexedPrimitives++);\r\n }\r\n }\r\n }\r\n public insertPrimitiveToPair(primitive: CurvePrimitive | undefined, pair: CurveLocationDetailPair) {\r\n if (primitive) {\r\n const priorPairs = this.primitiveToPair.get(primitive);\r\n this.assignPrimitiveIndex(primitive);\r\n if (!priorPairs) {\r\n this.primitiveToPair.set(primitive, [pair]);\r\n } else {\r\n priorPairs.push(pair);\r\n }\r\n }\r\n }\r\n public insertPair(pair: CurveLocationDetailPair) {\r\n const primitiveA = pair.detailA.curve;\r\n if (primitiveA)\r\n this.insertPrimitiveToPair(primitiveA, pair);\r\n const primitiveB = pair.detailB.curve;\r\n if (primitiveB)\r\n this.insertPrimitiveToPair(primitiveB, pair);\r\n }\r\n /**\r\n * Split closed missing primitives in half and add new intersection pairs.\r\n * * When bridge edges aren't included in the primitives array, a closed primitive with no intersections will not be\r\n * added to the graph because it isn't in the `primitiveToPair` map. By splitting such a missing primitive in two, we\r\n * introduce two intersections for each half, which allows the primitive to be represented in the map.\r\n */\r\n public splitAndAppendMissingClosedPrimitives(\r\n primitives: CurvePrimitive[], tolerance: number = Geometry.smallMetricDistance,\r\n ): void {\r\n for (const p of primitives) {\r\n let closedCurveSplitCandidate = false;\r\n if (p instanceof Arc3d)\r\n closedCurveSplitCandidate = p.sweep.isFullCircle;\r\n else if (!(p instanceof LineSegment3d) && !(p instanceof LineString3d)) // TODO: probably should do this for all types. Lots of spline-type primitives can be closed.\r\n closedCurveSplitCandidate = p.startPoint().isAlmostEqualXY(p.endPoint(), tolerance);\r\n if (closedCurveSplitCandidate && !this.primitiveToPair.has(p)) {\r\n const p0 = p.clonePartialCurve(0.0, 0.5);\r\n const p1 = p.clonePartialCurve(0.5, 1.0);\r\n if (p0 && p1) {\r\n this.insertPair(CurveLocationDetailPair.createCapture(\r\n CurveLocationDetail.createCurveEvaluatedFraction(p0, 0.0),\r\n CurveLocationDetail.createCurveEvaluatedFraction(p1, 1.0),\r\n ));\r\n this.insertPair(CurveLocationDetailPair.createCapture(\r\n CurveLocationDetail.createCurveEvaluatedFraction(p0, 1.0),\r\n CurveLocationDetail.createCurveEvaluatedFraction(p1, 0.0),\r\n ));\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class PlanarSubdivision {\r\n /**\r\n * Create a graph from curves and precomputed intersections.\r\n * * Z-coordinates are ignored.\r\n * @param primitives input curves\r\n * @param allPairs array of curve-curve xy-intersections\r\n * @param mergeTolerance optional distance tolerance for clustering vertices. Default value is [[Geometry.smallMetricDistance]].\r\n */\r\n public static assembleHalfEdgeGraph(\r\n primitives: CurvePrimitive[],\r\n allPairs: CurveLocationDetailPair[],\r\n mergeTolerance: number = Geometry.smallMetricDistance,\r\n radianTolerance: number = Geometry.smallAngleRadians,\r\n ): HalfEdgeGraph {\r\n // map from key CurvePrimitive to CurveLocationDetailPair\r\n const detailByPrimitive = new MapCurvePrimitiveToCurveLocationDetailPairArray();\r\n for (const pair of allPairs)\r\n detailByPrimitive.insertPair(pair);\r\n if (primitives.length > detailByPrimitive.primitiveToPair.size) {\r\n // otherwise, these single-primitive loops are missing from the graph\r\n detailByPrimitive.splitAndAppendMissingClosedPrimitives(primitives, mergeTolerance);\r\n }\r\n // these helper lambdas assume exactly one of the paired details is on the input curve\r\n const getFractionOnCurve = (pair: CurveLocationDetailPair, curve: CurvePrimitive): number => {\r\n return (pair.detailA.curve === curve) ? pair.detailA.fraction : pair.detailB.fraction;\r\n };\r\n const getDetailOnCurve = (pair: CurveLocationDetailPair, curve: CurvePrimitive): CurveLocationDetail => {\r\n return (pair.detailA.curve === curve) ? pair.detailA : pair.detailB;\r\n };\r\n const graph = new HalfEdgeGraph();\r\n for (const entry of detailByPrimitive.primitiveToPair.entries()) {\r\n const p = entry[0];\r\n // convert each interval intersection into two isolated intersections\r\n const details = entry[1].reduce((accumulator: CurveLocationDetailPair[], detailPair) => {\r\n const detail = getDetailOnCurve(detailPair, p);\r\n if (detail.isInterval()) {\r\n const detail0 = CurveLocationDetail.createCurveFractionPoint(p, detail.fraction, detail.point);\r\n const detail1 = CurveLocationDetail.createCurveFractionPoint(p, detail.fraction1, detail.point1);\r\n return [\r\n ...accumulator,\r\n CurveLocationDetailPair.createCapture(detail0, detail0),\r\n CurveLocationDetailPair.createCapture(detail1, detail1),\r\n ];\r\n }\r\n return [...accumulator, detailPair];\r\n }, []);\r\n // lexical sort on p intersection fraction\r\n details.sort((pairA: CurveLocationDetailPair, pairB: CurveLocationDetailPair) => {\r\n const fractionA = getFractionOnCurve(pairA, p);\r\n const fractionB = getFractionOnCurve(pairB, p);\r\n return fractionA - fractionB;\r\n });\r\n let last = { point: p.startPoint(), fraction: 0.0 };\r\n for (const detailPair of details) {\r\n const detail = getDetailOnCurve(detailPair, p);\r\n const detailFraction = Geometry.restrictToInterval(detail.fraction, 0, 1); // truncate fraction, but don't snap point; clustering happens later\r\n last = this.addHalfEdge(graph, p, last.point, last.fraction, detail.point, detailFraction, mergeTolerance);\r\n }\r\n this.addHalfEdge(graph, p, last.point, last.fraction, p.endPoint(), 1.0, mergeTolerance);\r\n }\r\n // every edge got its sortAngle defined by addHalfEdge\r\n HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph, (he: HalfEdge) => he.sortAngle ?? 0, mergeTolerance, radianTolerance);\r\n return graph;\r\n }\r\n\r\n /**\r\n * Filter for trivial curve fragment: fast computation if line segment; otherwise clip, flatten, and measure.\r\n * * Different metrics are employed for expedience.\r\n */\r\n private static isCurveTrivialXY(p: CurvePrimitive, point0: Point3d, fraction0: number, point1: Point3d, fraction1: number, mergeTolerance: number): boolean {\r\n if (Geometry.isSmallRelative(fraction0 - fraction1))\r\n return true;\r\n if (!(p instanceof LineSegment3d)) {\r\n const p0 = p.clonePartialCurve(fraction0, fraction1);\r\n if (p0?.tryTransformInPlace(Transform.createRowValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0))) // flatten\r\n return p0.curveLength() <= mergeTolerance; // Euclidean\r\n }\r\n return point0.isAlmostEqualXY(point1, mergeTolerance); // Manhattan\r\n }\r\n\r\n /**\r\n * Create a pair of mated half edges referencing a non-trivial interval of a primitive.\r\n * @param graph containing graph\r\n * @param p the curve\r\n * @param point0 start point\r\n * @param fraction0 starting fraction\r\n * @param point1 end point\r\n * @param fraction1 end fraction\r\n * @param mergeTolerance optional maximum xy-length of a trivial edge\r\n * @returns end point and fraction\r\n */\r\n private static addHalfEdge(\r\n graph: HalfEdgeGraph,\r\n p: CurvePrimitive,\r\n point0: Point3d,\r\n fraction0: number,\r\n point1: Point3d,\r\n fraction1: number,\r\n mergeTolerance: number = Geometry.smallMetricDistance,\r\n ): { point: Point3d, fraction: number } {\r\n if (!this.isCurveTrivialXY(p, point0, fraction0, point1, fraction1, mergeTolerance)) {\r\n const halfEdge = graph.createEdgeXYAndZ(point0, 0, point1, 0);\r\n if (p.parent && p.parent instanceof RegionGroupMember && p.parent.parentGroup.groupOpType === RegionGroupOpType.NonBounding)\r\n halfEdge.setMaskAroundEdge(HalfEdgeMask.BRIDGE_EDGE);\r\n const detail01 = CurveLocationDetail.createCurveEvaluatedFractionFraction(p, fraction0, fraction1);\r\n const mate = halfEdge.edgeMate;\r\n halfEdge.edgeTag = detail01;\r\n halfEdge.sortData = 1.0;\r\n mate.edgeTag = detail01;\r\n mate.sortData = -1.0;\r\n const computeSortAngle = (f: number, reverse: boolean): number => {\r\n const ray = p.fractionToPointAndDerivative(f);\r\n const s = reverse ? -1.0 : 1.0;\r\n return Math.atan2(s * ray.direction.y, s * ray.direction.x);\r\n };\r\n halfEdge.sortAngle = computeSortAngle(fraction0, false);\r\n mate.sortAngle = computeSortAngle(fraction1, true);\r\n }\r\n return { point: point1, fraction: fraction1 }; // where the next curve fragment starts\r\n }\r\n /**\r\n * Based on computed (and toleranced) area, push the loop (pointer) onto the appropriate array of positive, negative,\r\n * or sliver loops.\r\n * @param areaTol absolute area tolerance for sliver face detection\r\n * @param isSliverFace whether the loop is known a priori (e.g., via topology) to have zero area\r\n * @returns the area (forced to zero if within tolerance)\r\n */\r\n public static collectSignedLoop(loop: Loop, outLoops: SignedLoops, areaTol: number = 1.0e-10, isSliverFace?: boolean): number {\r\n let area = isSliverFace ? 0.0 : RegionOps.computeXYArea(loop);\r\n if (area === undefined)\r\n area = 0;\r\n if (Math.abs(area) < areaTol)\r\n area = 0.0;\r\n (loop as any).computedAreaInPlanarSubdivision = area;\r\n if (area > 0)\r\n outLoops.positiveAreaLoops.push(loop);\r\n else if (area < 0)\r\n outLoops.negativeAreaLoops.push(loop);\r\n else\r\n outLoops.slivers.push(loop);\r\n return area;\r\n }\r\n /** Extract geometric info from a topological edge. */\r\n private static extractGeometryFromEdge(edge: HalfEdge): { detail: CurveLocationDetail, reversed: boolean } | undefined {\r\n if (edge.sortData !== undefined && edge.edgeTag && edge.edgeTag instanceof CurveLocationDetail) {\r\n const detail = edge.edgeTag;\r\n if (detail.curve && detail.fraction1 !== undefined) {\r\n const reversed = edge.sortData < 0;\r\n return { detail, reversed };\r\n }\r\n }\r\n return undefined;\r\n }\r\n /** Create the geometry for a topological edge. */\r\n private static createCurveInEdge(edge: HalfEdge, z?: number): CurvePrimitive | undefined {\r\n let result: CurvePrimitive | undefined;\r\n const info = this.extractGeometryFromEdge(edge);\r\n if (info && info.detail.curve && info.detail.isInterval()) {\r\n const f0 = info.reversed ? info.detail.fraction1 : info.detail.fraction;\r\n const f1 = info.reversed ? info.detail.fraction : info.detail.fraction1;\r\n result = info.detail.curve.clonePartialCurve(f0, f1);\r\n if (result && z !== undefined)\r\n result.tryTransformInPlace(Transform.createRowValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, z));\r\n }\r\n return result;\r\n }\r\n /**\r\n * Create a [[Loop]] for the given face or super face.\r\n * @param face a node in the face loop, or an array of HalfEdges that comprise a loop (e.g., a super face).\r\n * @param options bundle of options.\r\n * @returns the Loop, or `undefined` if it is not closed within xy-tolerance.\r\n */\r\n public static createLoopInFace(face: HalfEdge | HalfEdge[], options?: CreateRegionInFaceOptions): Loop | undefined {\r\n const consolidate = options?.announceEdge ? false : options?.compress ?? false; // can't compress if announcing\r\n const loop = Loop.create();\r\n const addEdgeCurve = (edge: HalfEdge): void => {\r\n const curve = this.createCurveInEdge(edge, options?.z);\r\n if (curve) {\r\n options?.announceEdge?.(edge, curve, loop);\r\n loop.tryAddChild(curve);\r\n }\r\n };\r\n if (Array.isArray(face))\r\n face.forEach(addEdgeCurve);\r\n else\r\n face.announceEdgesInFace(addEdgeCurve);\r\n if (consolidate) {\r\n RegionOps.consolidateAdjacentPrimitives(loop, { consolidateLoopSeam: true });\r\n }\r\n if (loop.isPhysicallyClosedCurve(options?.closureTol, true))\r\n return loop;\r\n assert(() => false, \"face is not physically closed\");\r\n return undefined;\r\n }\r\n /**\r\n * Create a [[Loop]] or [[ParityRegion]] for the given face.\r\n * * A ParityRegion is created for a split-washer type face by removing bridge edges.\r\n * @param face a node in the face loop.\r\n * @param options bundle of options.\r\n * @returns the Loop or ParityRegion, or `undefined` if one could not be computed.\r\n */\r\n public static createLoopOrParityRegionInFace(face: HalfEdge, options?: CreateRegionInFaceOptions): Loop | ParityRegion | undefined {\r\n let region: AnyRegion | undefined;\r\n const visitMask = options?.visitMask ?? HalfEdgeMask.VISITED;\r\n const bridgeMask = options?.bridgeMask ?? HalfEdgeMask.BRIDGE_EDGE;\r\n let startBridgeEdge: HalfEdge | undefined;\r\n // is it a split-washer face?\r\n if (face.isSplitWasherFace(bridgeMask) && (startBridgeEdge = face.findMaskAroundFace(bridgeMask, true))) {\r\n const loops: Loop[] = [];\r\n const loopEdges: HalfEdge[] = [];\r\n const bridgeStack: HalfEdge[] = [startBridgeEdge];\r\n const announceEdge = (he: HalfEdge) => { he.setMask(visitMask); loopEdges.push(he); };\r\n const announceBridge = (he: HalfEdge) => { if (!he.isMaskSet(visitMask)) bridgeStack.push(he); };\r\n face.clearMaskAroundFace(visitMask);\r\n let bridge: HalfEdge | undefined;\r\n while (undefined !== (bridge = bridgeStack.pop())) {\r\n bridge.setMask(visitMask);\r\n const loopSeed = bridge.findMaskAroundFace(bridgeMask, false); // advance to next loop\r\n if (loopSeed) {\r\n if (loopSeed.isMaskSet(visitMask))\r\n continue;\r\n loopEdges.length = 0;\r\n if (loopSeed.announceEdgesInSuperFace(bridgeMask, announceEdge, announceBridge)) {\r\n const loop = this.createLoopInFace(loopEdges, options);\r\n if (loop) {\r\n loops.push(loop);\r\n continue;\r\n }\r\n }\r\n }\r\n }\r\n region = RegionOps.sortOuterAndHoleLoopsXY(loops);\r\n region = RegionOps.simplifyRegion(region);\r\n } else {\r\n region = this.createLoopInFace(face, options);\r\n }\r\n return (region && (region instanceof Loop || region instanceof ParityRegion)) ? region : undefined;\r\n }\r\n /** Return true if there are only two edges in the face loop, and their start curvatures are the same. */\r\n private static isNullFace(he: HalfEdge): boolean {\r\n const faceHasTwoEdges = (he.faceSuccessor.faceSuccessor === he);\r\n let faceIsBanana = false;\r\n if (faceHasTwoEdges) {\r\n const c0 = HalfEdgeGraphMerge.curvatureSortKey(he);\r\n const c1 = HalfEdgeGraphMerge.curvatureSortKey(he.faceSuccessor.edgeMate);\r\n if (!Geometry.isSameCoordinate(c0, c1)) // default tol!\r\n faceIsBanana = true; // heuristic: we could also check end curvatures, and/or higher derivatives...\r\n }\r\n return faceHasTwoEdges && !faceIsBanana;\r\n }\r\n /** Look across edge mates (possibly several) for a non-null mate face. */\r\n private static getNonNullEdgeMate(_graph: HalfEdgeGraph, e: HalfEdge): HalfEdge | undefined {\r\n if (this.isNullFace(e))\r\n return undefined;\r\n let e1 = e.edgeMate;\r\n while (this.isNullFace(e1)) {\r\n e1 = e1.faceSuccessor.edgeMate;\r\n if (e1 === e)\r\n return undefined;\r\n }\r\n return e1;\r\n }\r\n public static collectSignedLoopSetsInHalfEdgeGraph(graph: HalfEdgeGraph, closureTol: number = Geometry.smallMetricDistance, areaTol: number = 1.0e-10): SignedLoops[] {\r\n const q = HalfEdgeGraphSearch.collectConnectedComponentsWithExteriorParityMasks(graph, undefined);\r\n const result: SignedLoops[] = [];\r\n const edgeMap = new Map<HalfEdge, LoopCurveLoopCurve>();\r\n for (const faceSeeds of q) {\r\n const componentAreas: SignedLoops = { positiveAreaLoops: [], negativeAreaLoops: [], slivers: [] };\r\n const edges: LoopCurveLoopCurve[] = [];\r\n for (const faceSeed of faceSeeds) {\r\n const isNullFace = this.isNullFace(faceSeed);\r\n const announceEdge = isNullFace ? undefined : (he: HalfEdge, curveC: CurvePrimitive, loopC: Loop) => {\r\n const mate = this.getNonNullEdgeMate(graph, he);\r\n if (mate !== undefined) {\r\n const e = edgeMap.get(mate);\r\n if (e === undefined) {\r\n // Record this as loopA,edgeA of a shared edge to be completed later from the other side of the edge\r\n const e1 = new LoopCurveLoopCurve(loopC, curveC, undefined, undefined);\r\n edgeMap.set(he, e1);\r\n } else if (e instanceof LoopCurveLoopCurve) {\r\n e.setB(loopC, curveC);\r\n edges.push(e);\r\n edgeMap.delete(mate);\r\n }\r\n }\r\n };\r\n const loop = this.createLoopInFace(faceSeed, { announceEdge, closureTol });\r\n if (loop)\r\n this.collectSignedLoop(loop, componentAreas, areaTol, isNullFace);\r\n }\r\n componentAreas.edges = edges;\r\n result.push(componentAreas);\r\n edgeMap.clear();\r\n }\r\n return result;\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RegionOps.d.ts","sourceRoot":"","sources":["../../../src/curve/RegionOps.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAC0B,oBAAoB,EAAyB,0BAA0B,EACvG,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAY,MAAM,+BAA+B,CAAC;AAGlE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAI/H,OAAO,EAAe,UAAU,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAI7E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAQ7D,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,QAAQ,C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"}
@@ -1055,6 +1055,7 @@ class RegionOps {
1055
1055
  * to the edge and a constituent curve in each.
1056
1056
  */
1057
1057
  static constructAllXYRegionLoops(curvesAndRegions, tolerance = Geometry_1.Geometry.smallMetricDistance, addBridges = true) {
1058
+ tolerance = GeometryQuery_1.GeometryQuery.scaleToleranceForGeometry(curvesAndRegions, tolerance, { xyOnly: true });
1058
1059
  let primitives = RegionOps.collectCurvePrimitives(curvesAndRegions, undefined, true, true);
1059
1060
  primitives = TransferWithSplitArcs_1.TransferWithSplitArcs.clone(CurveCollection_1.BagOfCurves.create(...primitives)).children;
1060
1061
  let hasOpenCurve = false;
@@ -1077,8 +1078,9 @@ class RegionOps {
1077
1078
  });
1078
1079
  }
1079
1080
  }
1081
+ const radianTolerance = 10000 * Geometry_1.Geometry.smallAngleRadians; // be generous, and rely on curvature to break ties
1080
1082
  const intersections = CurveCurve_1.CurveCurve.allIntersectionsAmongPrimitivesXY(primitives, tolerance);
1081
- const graph = PlanarSubdivision_1.PlanarSubdivision.assembleHalfEdgeGraph(primitives, intersections, tolerance);
1083
+ const graph = PlanarSubdivision_1.PlanarSubdivision.assembleHalfEdgeGraph(primitives, intersections, tolerance, radianTolerance);
1082
1084
  if (addBridges && hasOpenCurve)
1083
1085
  RegionOps.removeExtraneousBridgeEdges(graph);
1084
1086
  const areaTol = this.computeMinimumArea(tolerance);