@itwin/core-geometry 5.0.0-dev.3 → 5.0.0-dev.5

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 (185) hide show
  1. package/lib/cjs/curve/Arc3d.d.ts +25 -5
  2. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  3. package/lib/cjs/curve/Arc3d.js +44 -5
  4. package/lib/cjs/curve/Arc3d.js.map +1 -1
  5. package/lib/cjs/curve/CurveCollection.d.ts +6 -2
  6. package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
  7. package/lib/cjs/curve/CurveCollection.js +11 -2
  8. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  9. package/lib/cjs/curve/LineString3d.d.ts +12 -8
  10. package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
  11. package/lib/cjs/curve/LineString3d.js +29 -8
  12. package/lib/cjs/curve/LineString3d.js.map +1 -1
  13. package/lib/cjs/curve/Loop.d.ts +12 -6
  14. package/lib/cjs/curve/Loop.d.ts.map +1 -1
  15. package/lib/cjs/curve/Loop.js +12 -6
  16. package/lib/cjs/curve/Loop.js.map +1 -1
  17. package/lib/cjs/curve/Query/CylindricalRange.d.ts +8 -6
  18. package/lib/cjs/curve/Query/CylindricalRange.d.ts.map +1 -1
  19. package/lib/cjs/curve/Query/CylindricalRange.js +13 -9
  20. package/lib/cjs/curve/Query/CylindricalRange.js.map +1 -1
  21. package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.d.ts.map +1 -1
  22. package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.js +24 -18
  23. package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.js.map +1 -1
  24. package/lib/cjs/geometry3d/BarycentricTriangle.d.ts +14 -8
  25. package/lib/cjs/geometry3d/BarycentricTriangle.d.ts.map +1 -1
  26. package/lib/cjs/geometry3d/BarycentricTriangle.js +17 -8
  27. package/lib/cjs/geometry3d/BarycentricTriangle.js.map +1 -1
  28. package/lib/cjs/geometry3d/GrowableFloat64Array.d.ts +2 -0
  29. package/lib/cjs/geometry3d/GrowableFloat64Array.d.ts.map +1 -1
  30. package/lib/cjs/geometry3d/GrowableFloat64Array.js +4 -0
  31. package/lib/cjs/geometry3d/GrowableFloat64Array.js.map +1 -1
  32. package/lib/cjs/geometry3d/Matrix3d.d.ts +8 -4
  33. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  34. package/lib/cjs/geometry3d/Matrix3d.js +25 -22
  35. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  36. package/lib/cjs/geometry3d/PolygonOps.d.ts +10 -4
  37. package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
  38. package/lib/cjs/geometry3d/PolygonOps.js +92 -45
  39. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  40. package/lib/cjs/numerics/Polynomials.d.ts +5 -5
  41. package/lib/cjs/numerics/Polynomials.js +6 -6
  42. package/lib/cjs/numerics/Polynomials.js.map +1 -1
  43. package/lib/cjs/polyface/AuxData.d.ts +2 -2
  44. package/lib/cjs/polyface/AuxData.d.ts.map +1 -1
  45. package/lib/cjs/polyface/AuxData.js +11 -3
  46. package/lib/cjs/polyface/AuxData.js.map +1 -1
  47. package/lib/cjs/polyface/Polyface.d.ts +3 -5
  48. package/lib/cjs/polyface/Polyface.d.ts.map +1 -1
  49. package/lib/cjs/polyface/Polyface.js +6 -13
  50. package/lib/cjs/polyface/Polyface.js.map +1 -1
  51. package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
  52. package/lib/cjs/polyface/PolyfaceBuilder.js +23 -13
  53. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  54. package/lib/cjs/polyface/PolyfaceData.d.ts +13 -3
  55. package/lib/cjs/polyface/PolyfaceData.d.ts.map +1 -1
  56. package/lib/cjs/polyface/PolyfaceData.js +21 -4
  57. package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
  58. package/lib/cjs/polyface/PolyfaceQuery.d.ts +2 -2
  59. package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
  60. package/lib/cjs/polyface/PolyfaceQuery.js +4 -3
  61. package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
  62. package/lib/cjs/solid/Box.d.ts +9 -3
  63. package/lib/cjs/solid/Box.d.ts.map +1 -1
  64. package/lib/cjs/solid/Box.js +10 -5
  65. package/lib/cjs/solid/Box.js.map +1 -1
  66. package/lib/cjs/solid/Cone.d.ts +3 -2
  67. package/lib/cjs/solid/Cone.d.ts.map +1 -1
  68. package/lib/cjs/solid/Cone.js +3 -3
  69. package/lib/cjs/solid/Cone.js.map +1 -1
  70. package/lib/cjs/solid/LinearSweep.d.ts +9 -3
  71. package/lib/cjs/solid/LinearSweep.d.ts.map +1 -1
  72. package/lib/cjs/solid/LinearSweep.js +9 -4
  73. package/lib/cjs/solid/LinearSweep.js.map +1 -1
  74. package/lib/cjs/solid/RotationalSweep.d.ts +15 -4
  75. package/lib/cjs/solid/RotationalSweep.d.ts.map +1 -1
  76. package/lib/cjs/solid/RotationalSweep.js +20 -7
  77. package/lib/cjs/solid/RotationalSweep.js.map +1 -1
  78. package/lib/cjs/solid/RuledSweep.d.ts +9 -3
  79. package/lib/cjs/solid/RuledSweep.d.ts.map +1 -1
  80. package/lib/cjs/solid/RuledSweep.js +11 -5
  81. package/lib/cjs/solid/RuledSweep.js.map +1 -1
  82. package/lib/cjs/solid/Sphere.d.ts +17 -7
  83. package/lib/cjs/solid/Sphere.d.ts.map +1 -1
  84. package/lib/cjs/solid/Sphere.js +22 -16
  85. package/lib/cjs/solid/Sphere.js.map +1 -1
  86. package/lib/cjs/solid/SweepContour.d.ts +1 -1
  87. package/lib/cjs/solid/SweepContour.js +1 -1
  88. package/lib/cjs/solid/SweepContour.js.map +1 -1
  89. package/lib/cjs/solid/TorusPipe.d.ts +8 -2
  90. package/lib/cjs/solid/TorusPipe.d.ts.map +1 -1
  91. package/lib/cjs/solid/TorusPipe.js +9 -5
  92. package/lib/cjs/solid/TorusPipe.js.map +1 -1
  93. package/lib/esm/curve/Arc3d.d.ts +25 -5
  94. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  95. package/lib/esm/curve/Arc3d.js +44 -5
  96. package/lib/esm/curve/Arc3d.js.map +1 -1
  97. package/lib/esm/curve/CurveCollection.d.ts +6 -2
  98. package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
  99. package/lib/esm/curve/CurveCollection.js +11 -2
  100. package/lib/esm/curve/CurveCollection.js.map +1 -1
  101. package/lib/esm/curve/LineString3d.d.ts +12 -8
  102. package/lib/esm/curve/LineString3d.d.ts.map +1 -1
  103. package/lib/esm/curve/LineString3d.js +29 -8
  104. package/lib/esm/curve/LineString3d.js.map +1 -1
  105. package/lib/esm/curve/Loop.d.ts +12 -6
  106. package/lib/esm/curve/Loop.d.ts.map +1 -1
  107. package/lib/esm/curve/Loop.js +12 -6
  108. package/lib/esm/curve/Loop.js.map +1 -1
  109. package/lib/esm/curve/Query/CylindricalRange.d.ts +8 -6
  110. package/lib/esm/curve/Query/CylindricalRange.d.ts.map +1 -1
  111. package/lib/esm/curve/Query/CylindricalRange.js +13 -9
  112. package/lib/esm/curve/Query/CylindricalRange.js.map +1 -1
  113. package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.d.ts.map +1 -1
  114. package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.js +24 -18
  115. package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.js.map +1 -1
  116. package/lib/esm/geometry3d/BarycentricTriangle.d.ts +14 -8
  117. package/lib/esm/geometry3d/BarycentricTriangle.d.ts.map +1 -1
  118. package/lib/esm/geometry3d/BarycentricTriangle.js +17 -8
  119. package/lib/esm/geometry3d/BarycentricTriangle.js.map +1 -1
  120. package/lib/esm/geometry3d/GrowableFloat64Array.d.ts +2 -0
  121. package/lib/esm/geometry3d/GrowableFloat64Array.d.ts.map +1 -1
  122. package/lib/esm/geometry3d/GrowableFloat64Array.js +4 -0
  123. package/lib/esm/geometry3d/GrowableFloat64Array.js.map +1 -1
  124. package/lib/esm/geometry3d/Matrix3d.d.ts +8 -4
  125. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  126. package/lib/esm/geometry3d/Matrix3d.js +25 -22
  127. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  128. package/lib/esm/geometry3d/PolygonOps.d.ts +10 -4
  129. package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
  130. package/lib/esm/geometry3d/PolygonOps.js +92 -45
  131. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  132. package/lib/esm/numerics/Polynomials.d.ts +5 -5
  133. package/lib/esm/numerics/Polynomials.js +6 -6
  134. package/lib/esm/numerics/Polynomials.js.map +1 -1
  135. package/lib/esm/polyface/AuxData.d.ts +2 -2
  136. package/lib/esm/polyface/AuxData.d.ts.map +1 -1
  137. package/lib/esm/polyface/AuxData.js +11 -3
  138. package/lib/esm/polyface/AuxData.js.map +1 -1
  139. package/lib/esm/polyface/Polyface.d.ts +3 -5
  140. package/lib/esm/polyface/Polyface.d.ts.map +1 -1
  141. package/lib/esm/polyface/Polyface.js +6 -13
  142. package/lib/esm/polyface/Polyface.js.map +1 -1
  143. package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
  144. package/lib/esm/polyface/PolyfaceBuilder.js +23 -13
  145. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  146. package/lib/esm/polyface/PolyfaceData.d.ts +13 -3
  147. package/lib/esm/polyface/PolyfaceData.d.ts.map +1 -1
  148. package/lib/esm/polyface/PolyfaceData.js +21 -4
  149. package/lib/esm/polyface/PolyfaceData.js.map +1 -1
  150. package/lib/esm/polyface/PolyfaceQuery.d.ts +2 -2
  151. package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
  152. package/lib/esm/polyface/PolyfaceQuery.js +4 -3
  153. package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
  154. package/lib/esm/solid/Box.d.ts +9 -3
  155. package/lib/esm/solid/Box.d.ts.map +1 -1
  156. package/lib/esm/solid/Box.js +10 -5
  157. package/lib/esm/solid/Box.js.map +1 -1
  158. package/lib/esm/solid/Cone.d.ts +3 -2
  159. package/lib/esm/solid/Cone.d.ts.map +1 -1
  160. package/lib/esm/solid/Cone.js +3 -3
  161. package/lib/esm/solid/Cone.js.map +1 -1
  162. package/lib/esm/solid/LinearSweep.d.ts +9 -3
  163. package/lib/esm/solid/LinearSweep.d.ts.map +1 -1
  164. package/lib/esm/solid/LinearSweep.js +9 -4
  165. package/lib/esm/solid/LinearSweep.js.map +1 -1
  166. package/lib/esm/solid/RotationalSweep.d.ts +15 -4
  167. package/lib/esm/solid/RotationalSweep.d.ts.map +1 -1
  168. package/lib/esm/solid/RotationalSweep.js +20 -7
  169. package/lib/esm/solid/RotationalSweep.js.map +1 -1
  170. package/lib/esm/solid/RuledSweep.d.ts +9 -3
  171. package/lib/esm/solid/RuledSweep.d.ts.map +1 -1
  172. package/lib/esm/solid/RuledSweep.js +11 -5
  173. package/lib/esm/solid/RuledSweep.js.map +1 -1
  174. package/lib/esm/solid/Sphere.d.ts +17 -7
  175. package/lib/esm/solid/Sphere.d.ts.map +1 -1
  176. package/lib/esm/solid/Sphere.js +22 -16
  177. package/lib/esm/solid/Sphere.js.map +1 -1
  178. package/lib/esm/solid/SweepContour.d.ts +1 -1
  179. package/lib/esm/solid/SweepContour.js +1 -1
  180. package/lib/esm/solid/SweepContour.js.map +1 -1
  181. package/lib/esm/solid/TorusPipe.d.ts +8 -2
  182. package/lib/esm/solid/TorusPipe.d.ts.map +1 -1
  183. package/lib/esm/solid/TorusPipe.js +9 -5
  184. package/lib/esm/solid/TorusPipe.js.map +1 -1
  185. package/package.json +3 -3
@@ -27,8 +27,8 @@ var AuxChannelDataType;
27
27
  * When the host Polyface is transformed the displacements are rotated and scaled accordingly.
28
28
  */
29
29
  AuxChannelDataType[AuxChannelDataType["Vector"] = 2] = "Vector";
30
- /** (X, Y, Z) normal vectors that replace the host [[Polyface]]'s own normals.
31
- * When the Polyface is transformed the normals are rotated accordingly.
30
+ /** (X, Y, Z) unit normal vectors that replace the host [[Polyface]]'s own normals.
31
+ * When the Polyface is transformed the normals are rotated and renormalized accordingly.
32
32
  */
33
33
  AuxChannelDataType[AuxChannelDataType["Normal"] = 3] = "Normal";
34
34
  })(AuxChannelDataType || (exports.AuxChannelDataType = AuxChannelDataType = {}));
@@ -219,7 +219,15 @@ class PolyfaceAuxData {
219
219
  inverseRot = inverseRot ?? rot.inverse();
220
220
  if (!inverseRot)
221
221
  return false;
222
- transformPoints(data.values, (point) => inverseRot.multiplyTransposeVectorInPlace(point));
222
+ transformPoints(data.values, (point) => {
223
+ inverseRot.multiplyTransposeVectorInPlace(point);
224
+ const dot = point.magnitudeSquared();
225
+ const tol = 1.0e-15; // cf. GrowableXYZArray.multiplyAndRenormalizeMatrix3dInverseTransposeInPlace
226
+ if (dot > tol && Math.abs(dot - 1.0) > tol) { // only renormalize if magnitude is not near 0 or 1
227
+ const mag = 1.0 / Math.sqrt(dot);
228
+ point.scaleInPlace(mag);
229
+ }
230
+ });
223
231
  break;
224
232
  }
225
233
  case AuxChannelDataType.Vector: {
@@ -1 +1 @@
1
- {"version":3,"file":"AuxData.js","sourceRoot":"","sources":["../../../src/polyface/AuxData.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAS/F,mEAAwD;AACxD,6DAAyD;AACzD,yCAAyC;AACzC,+CAAuD;AAEvD;;;GAGG;AACH,IAAY,kBAiBX;AAjBD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,+DAAU,CAAA;IACV;;OAEG;IACH,mEAAY,CAAA;IACZ;;OAEG;IACH,+DAAU,CAAA;IACV;;OAEG;IACH,+DAAU,CAAA;AACZ,CAAC,EAjBW,kBAAkB,kCAAlB,kBAAkB,QAiB7B;AAED;;EAEE;AACF,MAAa,cAAc;IAMzB,mEAAmE;IACnE,YAAY,KAAa,EAAE,MA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5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACnD,SAAS,CAAC,KAAK,CAAC,CAAC;QACjB,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;QACpB,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;QACxB,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Polyface\r\n */\r\n\r\n// import { Point2d } from \"./Geometry2d\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { Matrix3d } from \"../geometry3d/Matrix3d\";\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { NumberArray } from \"../geometry3d/PointHelpers\";\r\n// import { Geometry } from \"./Geometry\";\r\nimport { Range1d, Range3d } from \"../geometry3d/Range\";\r\n\r\n/** The types of data that can be represented by an [[AuxChannelData]]. Each type of data contributes differently to the\r\n * animation applied by an [AnalysisStyle]($common) and responds differently when the host [[PolyfaceAuxData]] is transformed.\r\n * @public\r\n */\r\nexport enum AuxChannelDataType {\r\n /** General-purpose scalar values like stress, temperature, etc., used to recolor the [[Polyface]]'s vertices.\r\n * When the host Polyface is transformed, scalar values remain unmodified.\r\n */\r\n Scalar = 0,\r\n /** Distances in meters used to recolor the [[Polyface]]'s vertices.\r\n * When the host [[Polyface]] is transformed the [[Transform]]'s scale is applied to the distances.\r\n */\r\n Distance = 1,\r\n /** (X, Y, Z) displacement vectors added to the [[Polyface]]'s vertex positions resulting in deformation of the mesh.\r\n * When the host Polyface is transformed the displacements are rotated and scaled accordingly.\r\n */\r\n Vector = 2,\r\n /** (X, Y, Z) normal vectors that replace the host [[Polyface]]'s own normals.\r\n * When the Polyface is transformed the normals are rotated accordingly.\r\n */\r\n Normal = 3,\r\n}\r\n\r\n/** Represents the [[AuxChannel]] data at a single input value.\r\n * @public\r\n*/\r\nexport class AuxChannelData {\r\n /** The input value for this data. */\r\n public input: number;\r\n /** The vertex values for this data. A single value per vertex for scalar and distance types and 3 values (x,y,z) for normal or vector channels. */\r\n public values: number[];\r\n\r\n /** Constructor. If `values` is a number array, it is captured. */\r\n constructor(input: number, values: number[] | Float64Array) {\r\n this.input = input;\r\n if (values instanceof Float64Array) {\r\n this.values = [];\r\n for (const v of values) this.values.push(v);\r\n } else\r\n this.values = values;\r\n }\r\n\r\n /** Copy blocks of size `blockSize` from (blocked index) `thisIndex` in this AuxChannelData to (blockIndex) `otherIndex` of `other` */\r\n public copyValues(other: AuxChannelData, thisIndex: number, otherIndex: number, blockSize: number): void {\r\n for (let i = 0; i < blockSize; i++)\r\n this.values[thisIndex * blockSize + i] = other.values[otherIndex * blockSize + i];\r\n }\r\n\r\n /** return a deep copy */\r\n public clone(): AuxChannelData {\r\n return new AuxChannelData(this.input, this.values.slice());\r\n }\r\n\r\n /** toleranced comparison of the `input` and `value` fields.\r\n * * Default tolerance is 1.0e-8\r\n */\r\n public isAlmostEqual(other: AuxChannelData, tol?: number): boolean {\r\n const tolerance = tol ? tol : 1.0E-8;\r\n return Math.abs(this.input - other.input) < tolerance && NumberArray.isAlmostEqual(this.values, other.values, tolerance);\r\n }\r\n}\r\n\r\n/** Represents a single [[PolyfaceAuxData]] channel.\r\n * @public\r\n*/\r\nexport class AuxChannel {\r\n /** An array of [[AuxChannelData]] that represents the vertex data at one or more input values. */\r\n public data: AuxChannelData[];\r\n /** The type of data stored in this channel. */\r\n public dataType: AuxChannelDataType;\r\n /** The channel name. This is used to present the [[AuxChannel]] to the user and also to select the [[AuxChannel]] for display from AnalysisStyle */\r\n public name?: string;\r\n /** The input name. */\r\n public inputName?: string;\r\n\r\n /** Constructor with CAPTURED inputs. */\r\n public constructor(data: AuxChannelData[], dataType: AuxChannelDataType, name?: string, inputName?: string) {\r\n this.data = data;\r\n this.dataType = dataType;\r\n this.name = name;\r\n this.inputName = inputName;\r\n }\r\n\r\n /** Return a deep copy. */\r\n public clone(): AuxChannel {\r\n const clonedData = [];\r\n for (const data of this.data) clonedData.push(data.clone());\r\n return new AuxChannel(clonedData, this.dataType, this.name, this.inputName);\r\n }\r\n\r\n /** Toleranced comparison of contents. */\r\n public isAlmostEqual(other: AuxChannel, tol?: number): boolean {\r\n if (this.dataType !== other.dataType ||\r\n this.name !== other.name ||\r\n this.inputName !== other.inputName ||\r\n this.data.length !== other.data.length)\r\n return false;\r\n\r\n for (let i = 0; i < this.data.length; i++)\r\n if (!this.data[i].isAlmostEqual(other.data[i], tol))\r\n return false;\r\n\r\n return true;\r\n }\r\n\r\n /** True if the data type is 1-dimensional. */\r\n public static isScalar(dataType: AuxChannelDataType): boolean {\r\n return dataType === AuxChannelDataType.Distance || dataType === AuxChannelDataType.Scalar;\r\n }\r\n\r\n /** True if the data stored in this AuxChannel is 1-dimensional. */\r\n public get isScalar(): boolean {\r\n return AuxChannel.isScalar(this.dataType);\r\n }\r\n\r\n /** The dimension (1D or 3D) of each datum of an AuxChannel of the given type. */\r\n public static entriesPerValue(dataType: AuxChannelDataType): number {\r\n return this.isScalar(dataType) ? 1 : 3;\r\n }\r\n\r\n /** The dimension (1D or 3D) of each datum in the data arrays of this AuxChannel. */\r\n public get entriesPerValue(): number {\r\n return AuxChannel.entriesPerValue(this.dataType);\r\n }\r\n\r\n /** The number of data stored in each data array of this AuxChannel, equal to the length of the array divided by `entriesPerValue`. */\r\n public get valueCount(): number {\r\n return 0 === this.data.length ? 0 : this.data[0].values.length / this.entriesPerValue;\r\n }\r\n\r\n /** The minimum and maximum values in `data.values`, or `undefined` if [[isScalar]] is false. */\r\n public get scalarRange(): Range1d | undefined {\r\n if (!this.isScalar)\r\n return undefined;\r\n\r\n const range = Range1d.createNull();\r\n for (const data of this.data)\r\n range.extendArray(data.values);\r\n\r\n return range;\r\n }\r\n\r\n /** Compute the range of this channel's displacement values, if [[dataType]] is [[AuxChannelDataType.Vector]].\r\n * @param scale Scale by which to multiply each displacement.\r\n * @param result Preallocated object in which to store result.\r\n * @returns The range encompassing all this channel's displacements scaled by `scale`; or a null range if this channel does not contain displacements.\r\n */\r\n public computeDisplacementRange(scale = 1, result?: Range3d): Range3d {\r\n result = Range3d.createNull(result);\r\n\r\n if (AuxChannelDataType.Vector === this.dataType) {\r\n for (const data of this.data) {\r\n const v = data.values;\r\n for (let i = 0; i < v.length; i += 3)\r\n result.extendXYZ(v[i] * scale, v[i + 1] * scale, v[i + 2] * scale);\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n * The `PolyfaceAuxData` structure contains one or more analytical data channels for each vertex of a [[Polyface]], allowing the polyface to be styled\r\n * using an [AnalysisStyle]($common).\r\n * Typically a polyface will contain only vertex data required for its basic display: vertex position, normal, texture parameter, color.\r\n * `PolyfaceAuxData` provides supplemental per-vertex data that is generally computed in an analysis program or other external data source.\r\n * This supplemental data can be either 1D (e.g., height, override color) or 3D (e.g., displacement vector, override normal); see [[AuxChannel.entriesPerValue]], [[AuxChannel.dataType]].\r\n * All data channels are indexed by the same indices, which must have the same length and structure as the other Polyface indices.\r\n * This means that if a facet's face loop is found at index range [i0,i1] in the Polyface vertex index array, then the same index range [i0,i1]\r\n * locates the data for this facet in all the other Polyface index arrays, including the `PolyfaceAuxData` indices.\r\n * @see [[PolyfaceData.auxData]] to associate auxiliary data with a polyface.\r\n * @public\r\n */\r\nexport class PolyfaceAuxData {\r\n /** Array with one or more channels of auxiliary data for the associated polyface. */\r\n public channels: AuxChannel[];\r\n /** The indices (shared by all data in all channels) mapping the data to the mesh facets. */\r\n public indices: number[];\r\n\r\n /** Constructor with CAPTURED inputs. */\r\n public constructor(channels: AuxChannel[], indices: number[]) {\r\n this.channels = channels;\r\n this.indices = indices;\r\n }\r\n\r\n /** Return a deep copy. */\r\n public clone(): PolyfaceAuxData {\r\n const clonedChannels = this.channels.map((x) => x.clone());\r\n return new PolyfaceAuxData(clonedChannels, this.indices.slice());\r\n }\r\n\r\n /** Returns true if `this` is equivalent to `other` within `tolerance`.\r\n * The indices are compared for exact equality. The data in the channels are compared using `tolerance`, which defaults to 1.0e-8.\r\n */\r\n public isAlmostEqual(other: PolyfaceAuxData, tolerance?: number): boolean {\r\n if (!NumberArray.isExactEqual(this.indices, other.indices) || this.channels.length !== other.channels.length)\r\n return false;\r\n\r\n for (let i = 0; i < this.channels.length; i++)\r\n if (!this.channels[i].isAlmostEqual(other.channels[i], tolerance))\r\n return false;\r\n\r\n return true;\r\n }\r\n\r\n /** Returns true if both `left` and `right` are undefined, or both are defined and equivalent within `tolerance` (default: 1.0e-8). */\r\n public static isAlmostEqual(left: PolyfaceAuxData | undefined, right: PolyfaceAuxData | undefined, tol?: number): boolean {\r\n if (left === right) // This catches double undefined !!!\r\n return true;\r\n if (left && right)\r\n return left.isAlmostEqual(right, tol);\r\n return false;\r\n }\r\n\r\n /** Create a PolyfaceAuxData for use by a [[PolyfaceVisitor]]. */\r\n public createForVisitor(): PolyfaceAuxData {\r\n const visitorChannels: AuxChannel[] = [];\r\n\r\n for (const parentChannel of this.channels) {\r\n const visitorChannelData: AuxChannelData[] = [];\r\n for (const parentChannelData of parentChannel.data)\r\n visitorChannelData.push(new AuxChannelData(parentChannelData.input, []));\r\n\r\n visitorChannels.push(new AuxChannel(visitorChannelData, parentChannel.dataType, parentChannel.name, parentChannel.inputName));\r\n }\r\n\r\n return new PolyfaceAuxData(visitorChannels, []);\r\n }\r\n\r\n /** Apply `transform` to the data in each channel.\r\n * @see [[AuxChannelDataType]] for details regarding how each data type is affected by the transform.\r\n * @note This method may fail if a channel of [[AuxChannelDataType.Normal]] exists and `transform.matrix` is non-invertible.\r\n * @returns true if the channels were all successfully transformed.\r\n */\r\n public tryTransformInPlace(transform: Transform): boolean {\r\n let inverseRot: Matrix3d | undefined;\r\n const rot = transform.matrix;\r\n const det = rot.determinant();\r\n const scale = Math.pow(Math.abs(det), 1 / 3) * (det >= 0 ? 1 : -1);\r\n\r\n for (const channel of this.channels) {\r\n for (const data of channel.data) {\r\n switch (channel.dataType) {\r\n case AuxChannelDataType.Scalar:\r\n continue;\r\n case AuxChannelDataType.Distance: {\r\n for (let i = 0; i < data.values.length; i++)\r\n data.values[i] *= scale;\r\n\r\n break;\r\n }\r\n case AuxChannelDataType.Normal: {\r\n inverseRot = inverseRot ?? rot.inverse();\r\n if (!inverseRot)\r\n return false;\r\n\r\n transformPoints(data.values, (point) => inverseRot!.multiplyTransposeVectorInPlace(point));\r\n break;\r\n }\r\n case AuxChannelDataType.Vector: {\r\n transformPoints(data.values, (point) => rot.multiplyVectorInPlace(point));\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n\r\nfunction transformPoints(coords: number[], transform: (point: Point3d) => void): void {\r\n const point = new Point3d();\r\n for (let i = 0; i < coords.length; i += 3) {\r\n point.set(coords[i], coords[i + 1], coords[i + 2]);\r\n transform(point);\r\n coords[i] = point.x;\r\n coords[i + 1] = point.y;\r\n coords[i + 2] = point.z;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"AuxData.js","sourceRoot":"","sources":["../../../src/polyface/AuxData.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAS/F,mEAAwD;AACxD,6DAAyD;AACzD,yCAAyC;AACzC,+CAAuD;AAEvD;;;GAGG;AACH,IAAY,kBAiBX;AAjBD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,+DAAU,CAAA;I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G,EAAG,CAAC,CAAC,mDAAmD;gCAChG,MAAM,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gCACjC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;4BAC1B,CAAC;wBACH,CAAC,CAAC,CAAC;wBACH,MAAM;oBACR,CAAC;oBACD,KAAK,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;wBAC/B,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;wBAC1E,MAAM;oBACR,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAxGD,0CAwGC;AAED,SAAS,eAAe,CAAC,MAAgB,EAAE,SAAmC;IAC5E,MAAM,KAAK,GAAG,IAAI,yBAAO,EAAE,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACnD,SAAS,CAAC,KAAK,CAAC,CAAC;QACjB,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;QACpB,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;QACxB,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Polyface\r\n */\r\n\r\n// import { Point2d } from \"./Geometry2d\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { Matrix3d } from \"../geometry3d/Matrix3d\";\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { NumberArray } from \"../geometry3d/PointHelpers\";\r\n// import { Geometry } from \"./Geometry\";\r\nimport { Range1d, Range3d } from \"../geometry3d/Range\";\r\n\r\n/** The types of data that can be represented by an [[AuxChannelData]]. Each type of data contributes differently to the\r\n * animation applied by an [AnalysisStyle]($common) and responds differently when the host [[PolyfaceAuxData]] is transformed.\r\n * @public\r\n */\r\nexport enum AuxChannelDataType {\r\n /** General-purpose scalar values like stress, temperature, etc., used to recolor the [[Polyface]]'s vertices.\r\n * When the host Polyface is transformed, scalar values remain unmodified.\r\n */\r\n Scalar = 0,\r\n /** Distances in meters used to recolor the [[Polyface]]'s vertices.\r\n * When the host [[Polyface]] is transformed the [[Transform]]'s scale is applied to the distances.\r\n */\r\n Distance = 1,\r\n /** (X, Y, Z) displacement vectors added to the [[Polyface]]'s vertex positions resulting in deformation of the mesh.\r\n * When the host Polyface is transformed the displacements are rotated and scaled accordingly.\r\n */\r\n Vector = 2,\r\n /** (X, Y, Z) unit normal vectors that replace the host [[Polyface]]'s own normals.\r\n * When the Polyface is transformed the normals are rotated and renormalized accordingly.\r\n */\r\n Normal = 3,\r\n}\r\n\r\n/** Represents the [[AuxChannel]] data at a single input value.\r\n * @public\r\n*/\r\nexport class AuxChannelData {\r\n /** The input value for this data. */\r\n public input: number;\r\n /** The vertex values for this data. A single value per vertex for scalar and distance types and 3 values (x,y,z) for normal or vector channels. */\r\n public values: number[];\r\n\r\n /** Constructor. If `values` is a number array, it is captured. */\r\n constructor(input: number, values: number[] | Float64Array) {\r\n this.input = input;\r\n if (values instanceof Float64Array) {\r\n this.values = [];\r\n for (const v of values) this.values.push(v);\r\n } else\r\n this.values = values;\r\n }\r\n\r\n /** Copy blocks of size `blockSize` from (blocked index) `thisIndex` in this AuxChannelData to (blockIndex) `otherIndex` of `other` */\r\n public copyValues(other: AuxChannelData, thisIndex: number, otherIndex: number, blockSize: number): void {\r\n for (let i = 0; i < blockSize; i++)\r\n this.values[thisIndex * blockSize + i] = other.values[otherIndex * blockSize + i];\r\n }\r\n\r\n /** return a deep copy */\r\n public clone(): AuxChannelData {\r\n return new AuxChannelData(this.input, this.values.slice());\r\n }\r\n\r\n /** toleranced comparison of the `input` and `value` fields.\r\n * * Default tolerance is 1.0e-8\r\n */\r\n public isAlmostEqual(other: AuxChannelData, tol?: number): boolean {\r\n const tolerance = tol ? tol : 1.0E-8;\r\n return Math.abs(this.input - other.input) < tolerance && NumberArray.isAlmostEqual(this.values, other.values, tolerance);\r\n }\r\n}\r\n\r\n/** Represents a single [[PolyfaceAuxData]] channel.\r\n * @public\r\n*/\r\nexport class AuxChannel {\r\n /** An array of [[AuxChannelData]] that represents the vertex data at one or more input values. */\r\n public data: AuxChannelData[];\r\n /** The type of data stored in this channel. */\r\n public dataType: AuxChannelDataType;\r\n /** The channel name. This is used to present the [[AuxChannel]] to the user and also to select the [[AuxChannel]] for display from AnalysisStyle */\r\n public name?: string;\r\n /** The input name. */\r\n public inputName?: string;\r\n\r\n /** Constructor with CAPTURED inputs. */\r\n public constructor(data: AuxChannelData[], dataType: AuxChannelDataType, name?: string, inputName?: string) {\r\n this.data = data;\r\n this.dataType = dataType;\r\n this.name = name;\r\n this.inputName = inputName;\r\n }\r\n\r\n /** Return a deep copy. */\r\n public clone(): AuxChannel {\r\n const clonedData = [];\r\n for (const data of this.data) clonedData.push(data.clone());\r\n return new AuxChannel(clonedData, this.dataType, this.name, this.inputName);\r\n }\r\n\r\n /** Toleranced comparison of contents. */\r\n public isAlmostEqual(other: AuxChannel, tol?: number): boolean {\r\n if (this.dataType !== other.dataType ||\r\n this.name !== other.name ||\r\n this.inputName !== other.inputName ||\r\n this.data.length !== other.data.length)\r\n return false;\r\n\r\n for (let i = 0; i < this.data.length; i++)\r\n if (!this.data[i].isAlmostEqual(other.data[i], tol))\r\n return false;\r\n\r\n return true;\r\n }\r\n\r\n /** True if the data type is 1-dimensional. */\r\n public static isScalar(dataType: AuxChannelDataType): boolean {\r\n return dataType === AuxChannelDataType.Distance || dataType === AuxChannelDataType.Scalar;\r\n }\r\n\r\n /** True if the data stored in this AuxChannel is 1-dimensional. */\r\n public get isScalar(): boolean {\r\n return AuxChannel.isScalar(this.dataType);\r\n }\r\n\r\n /** The dimension (1D or 3D) of each datum of an AuxChannel of the given type. */\r\n public static entriesPerValue(dataType: AuxChannelDataType): number {\r\n return this.isScalar(dataType) ? 1 : 3;\r\n }\r\n\r\n /** The dimension (1D or 3D) of each datum in the data arrays of this AuxChannel. */\r\n public get entriesPerValue(): number {\r\n return AuxChannel.entriesPerValue(this.dataType);\r\n }\r\n\r\n /** The number of data stored in each data array of this AuxChannel, equal to the length of the array divided by `entriesPerValue`. */\r\n public get valueCount(): number {\r\n return 0 === this.data.length ? 0 : this.data[0].values.length / this.entriesPerValue;\r\n }\r\n\r\n /** The minimum and maximum values in `data.values`, or `undefined` if [[isScalar]] is false. */\r\n public get scalarRange(): Range1d | undefined {\r\n if (!this.isScalar)\r\n return undefined;\r\n\r\n const range = Range1d.createNull();\r\n for (const data of this.data)\r\n range.extendArray(data.values);\r\n\r\n return range;\r\n }\r\n\r\n /** Compute the range of this channel's displacement values, if [[dataType]] is [[AuxChannelDataType.Vector]].\r\n * @param scale Scale by which to multiply each displacement.\r\n * @param result Preallocated object in which to store result.\r\n * @returns The range encompassing all this channel's displacements scaled by `scale`; or a null range if this channel does not contain displacements.\r\n */\r\n public computeDisplacementRange(scale = 1, result?: Range3d): Range3d {\r\n result = Range3d.createNull(result);\r\n\r\n if (AuxChannelDataType.Vector === this.dataType) {\r\n for (const data of this.data) {\r\n const v = data.values;\r\n for (let i = 0; i < v.length; i += 3)\r\n result.extendXYZ(v[i] * scale, v[i + 1] * scale, v[i + 2] * scale);\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n * The `PolyfaceAuxData` structure contains one or more analytical data channels for each vertex of a [[Polyface]], allowing the polyface to be styled\r\n * using an [AnalysisStyle]($common).\r\n * Typically a polyface will contain only vertex data required for its basic display: vertex position, normal, texture parameter, color.\r\n * `PolyfaceAuxData` provides supplemental per-vertex data that is generally computed in an analysis program or other external data source.\r\n * This supplemental data can be either 1D (e.g., height, override color) or 3D (e.g., displacement vector, override normal); see [[AuxChannel.entriesPerValue]], [[AuxChannel.dataType]].\r\n * All data channels are indexed by the same indices, which must have the same length and structure as the other Polyface indices.\r\n * This means that if a facet's face loop is found at index range [i0,i1] in the Polyface vertex index array, then the same index range [i0,i1]\r\n * locates the data for this facet in all the other Polyface index arrays, including the `PolyfaceAuxData` indices.\r\n * @see [[PolyfaceData.auxData]] to associate auxiliary data with a polyface.\r\n * @public\r\n */\r\nexport class PolyfaceAuxData {\r\n /** Array with one or more channels of auxiliary data for the associated polyface. */\r\n public channels: AuxChannel[];\r\n /** The indices (shared by all data in all channels) mapping the data to the mesh facets. */\r\n public indices: number[];\r\n\r\n /** Constructor with CAPTURED inputs. */\r\n public constructor(channels: AuxChannel[], indices: number[]) {\r\n this.channels = channels;\r\n this.indices = indices;\r\n }\r\n\r\n /** Return a deep copy. */\r\n public clone(): PolyfaceAuxData {\r\n const clonedChannels = this.channels.map((x) => x.clone());\r\n return new PolyfaceAuxData(clonedChannels, this.indices.slice());\r\n }\r\n\r\n /** Returns true if `this` is equivalent to `other` within `tolerance`.\r\n * The indices are compared for exact equality. The data in the channels are compared using `tolerance`, which defaults to 1.0e-8.\r\n */\r\n public isAlmostEqual(other: PolyfaceAuxData, tolerance?: number): boolean {\r\n if (!NumberArray.isExactEqual(this.indices, other.indices) || this.channels.length !== other.channels.length)\r\n return false;\r\n\r\n for (let i = 0; i < this.channels.length; i++)\r\n if (!this.channels[i].isAlmostEqual(other.channels[i], tolerance))\r\n return false;\r\n\r\n return true;\r\n }\r\n\r\n /** Returns true if both `left` and `right` are undefined, or both are defined and equivalent within `tolerance` (default: 1.0e-8). */\r\n public static isAlmostEqual(left: PolyfaceAuxData | undefined, right: PolyfaceAuxData | undefined, tol?: number): boolean {\r\n if (left === right) // This catches double undefined !!!\r\n return true;\r\n if (left && right)\r\n return left.isAlmostEqual(right, tol);\r\n return false;\r\n }\r\n\r\n /** Create a PolyfaceAuxData for use by a [[PolyfaceVisitor]]. */\r\n public createForVisitor(): PolyfaceAuxData {\r\n const visitorChannels: AuxChannel[] = [];\r\n\r\n for (const parentChannel of this.channels) {\r\n const visitorChannelData: AuxChannelData[] = [];\r\n for (const parentChannelData of parentChannel.data)\r\n visitorChannelData.push(new AuxChannelData(parentChannelData.input, []));\r\n\r\n visitorChannels.push(new AuxChannel(visitorChannelData, parentChannel.dataType, parentChannel.name, parentChannel.inputName));\r\n }\r\n\r\n return new PolyfaceAuxData(visitorChannels, []);\r\n }\r\n\r\n /** Apply `transform` to the data in each channel.\r\n * @see [[AuxChannelDataType]] for details regarding how each data type is affected by the transform.\r\n * @note This method may fail if a channel of [[AuxChannelDataType.Normal]] exists and `transform.matrix` is non-invertible.\r\n * @returns true if the channels were all successfully transformed.\r\n */\r\n public tryTransformInPlace(transform: Transform): boolean {\r\n let inverseRot: Matrix3d | undefined;\r\n const rot = transform.matrix;\r\n const det = rot.determinant();\r\n const scale = Math.pow(Math.abs(det), 1 / 3) * (det >= 0 ? 1 : -1);\r\n\r\n for (const channel of this.channels) {\r\n for (const data of channel.data) {\r\n switch (channel.dataType) {\r\n case AuxChannelDataType.Scalar:\r\n continue;\r\n case AuxChannelDataType.Distance: {\r\n for (let i = 0; i < data.values.length; i++)\r\n data.values[i] *= scale;\r\n\r\n break;\r\n }\r\n case AuxChannelDataType.Normal: {\r\n inverseRot = inverseRot ?? rot.inverse();\r\n if (!inverseRot)\r\n return false;\r\n\r\n transformPoints(data.values, (point) => {\r\n inverseRot!.multiplyTransposeVectorInPlace(point);\r\n const dot = point.magnitudeSquared();\r\n const tol = 1.0e-15; // cf. GrowableXYZArray.multiplyAndRenormalizeMatrix3dInverseTransposeInPlace\r\n if (dot > tol && Math.abs(dot - 1.0) > tol ) { // only renormalize if magnitude is not near 0 or 1\r\n const mag = 1.0 / Math.sqrt(dot);\r\n point.scaleInPlace(mag);\r\n }\r\n });\r\n break;\r\n }\r\n case AuxChannelDataType.Vector: {\r\n transformPoints(data.values, (point) => rot.multiplyVectorInPlace(point));\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n\r\nfunction transformPoints(coords: number[], transform: (point: Point3d) => void): void {\r\n const point = new Point3d();\r\n for (let i = 0; i < coords.length; i += 3) {\r\n point.set(coords[i], coords[i + 1], coords[i + 2]);\r\n transform(point);\r\n coords[i] = point.x;\r\n coords[i + 1] = point.y;\r\n coords[i + 2] = point.z;\r\n }\r\n}\r\n"]}
@@ -89,11 +89,9 @@ export declare class IndexedPolyface extends Polyface {
89
89
  get isEmpty(): boolean;
90
90
  /**
91
91
  * Transform the mesh.
92
- * * Apply the transform to points.
93
- * * Apply the (inverse transpose of the) matrix part to normals.
94
- * * If determinant of the transform matrix is negative, also
95
- * * negate normals
96
- * * reverse index order around each facet.
92
+ * * If `transform` is a mirror, also reverse the index order around each facet.
93
+ * * Note that this method always returns true. If transforming the normals fails (due to singular matrix or zero
94
+ * normal), the original normal(s) are left unchanged.
97
95
  */
98
96
  tryTransformInPlace(transform: Transform): boolean;
99
97
  /** Reverse indices for a single facet. */
@@ -1 +1 @@
1
- {"version":3,"file":"Polyface.d.ts","sourceRoot":"","sources":["../../../src/polyface/Polyface.ts"],"names":[],"mappings":"AAKA;;GAEG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC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;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,mGAAmG;IACnG,WAAW,IAAI,IAAI,CAAC;IACpB,6FAA6F;IAC7F,YAAY,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1D;;;OAGG;IACH,wBAAwB,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACzG;;;OAGG;IACH,sBAAsB,CAAC,IAAI,MAAM,CAAC;CACnC"}
@@ -124,20 +124,14 @@ class IndexedPolyface extends Polyface {
124
124
  }
125
125
  /**
126
126
  * Transform the mesh.
127
- * * Apply the transform to points.
128
- * * Apply the (inverse transpose of the) matrix part to normals.
129
- * * If determinant of the transform matrix is negative, also
130
- * * negate normals
131
- * * reverse index order around each facet.
127
+ * * If `transform` is a mirror, also reverse the index order around each facet.
128
+ * * Note that this method always returns true. If transforming the normals fails (due to singular matrix or zero
129
+ * normal), the original normal(s) are left unchanged.
132
130
  */
133
131
  tryTransformInPlace(transform) {
134
- if (!this.data.tryTransformInPlace(transform))
135
- return false;
136
- const determinant = transform.matrix.determinant();
137
- if (determinant < 0) {
132
+ this.data.tryTransformInPlace(transform);
133
+ if (transform.matrix.determinant() < 0)
138
134
  this.reverseIndices();
139
- this.reverseNormals();
140
- }
141
135
  return true;
142
136
  }
143
137
  /** Reverse indices for a single facet. */
@@ -146,8 +140,7 @@ class IndexedPolyface extends Polyface {
146
140
  }
147
141
  /** Return a deep clone. */
148
142
  clone() {
149
- const result = new IndexedPolyface(this.data.clone(), this._facetStart.slice(), this._facetToFaceData.slice());
150
- return result;
143
+ return new IndexedPolyface(this.data.clone(), this._facetStart.slice(), this._facetToFaceData.slice());
151
144
  }
152
145
  /**
153
146
  * Return a deep clone with transformed points and normals.
@@ -1 +1 @@
1
- {"version":3,"file":"Polyface.js","source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AAC,CAAC,CAAC,aAAa,CAAC,CAAC;QAC5E,OAAO,IAAI,CAAC;IACd,CAAC;IACD,kFAAkF;IAC3E,yBAAyB,CAAC,OAAwB;QACvD,OAAO,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;CACF;AAnhBD,0CAmhBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Polyface\r\n */\r\n\r\n// cspell:word internaldocs\r\n\r\nimport { GeometryQuery } from \"../curve/GeometryQuery\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GeometryHandler } from \"../geometry3d/GeometryHandler\";\r\nimport { GrowableXYArray } from \"../geometry3d/GrowableXYArray\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { Point2d } from \"../geometry3d/Point2dVector2d\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { NumberArray } from \"../geometry3d/PointHelpers\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { FacetFaceData } from \"./FacetFaceData\";\r\nimport { IndexedPolyfaceVisitor } from \"./IndexedPolyfaceVisitor\";\r\nimport { PolyfaceData } from \"./PolyfaceData\";\r\n\r\n/**\r\n * A Polyface is an abstract mesh structure (of unspecified implementation) that provides a PolyfaceVisitor\r\n * to iterate over its facets.\r\n * @public\r\n */\r\nexport abstract class Polyface extends GeometryQuery {\r\n /** String name for schema properties */\r\n public readonly geometryCategory = \"polyface\";\r\n /** Underlying polyface data. */\r\n public data: PolyfaceData;\r\n /** Constructor */\r\n protected constructor(data: PolyfaceData) {\r\n super();\r\n this.data = data;\r\n }\r\n /**\r\n * Create and return a visitor for this concrete polyface.\r\n * @param numWrap the number of vertices to replicate in visitor arrays.\r\n */\r\n public abstract createVisitor(numWrap: number): PolyfaceVisitor;\r\n /** Flag indicating if the mesh display must assume both sides are visible. */\r\n public get twoSided() {\r\n return this.data.twoSided;\r\n }\r\n public set twoSided(value: boolean) {\r\n this.data.twoSided = value;\r\n }\r\n /**\r\n * Flag indicating if the mesh closure is unknown (0), open sheet (1), closed solid (2).\r\n * * A boundary edge of a mesh is defined as an edge with only one connected facet.\r\n * * Closed solid is a mesh with no boundary edge. Open sheet is a mesh that has boundary edge(s).\r\n */\r\n public get expectedClosure(): number {\r\n return this.data.expectedClosure;\r\n }\r\n public set expectedClosure(value: number) {\r\n this.data.expectedClosure = value;\r\n }\r\n /**\r\n * Check validity of indices into a data array.\r\n * * It is valid to have both indices and data undefined.\r\n * * It is NOT valid for just one to be defined.\r\n * * Index values at indices[indexPositionA <= i < indexPositionB] must be valid indices to the data array.\r\n * @param indices array of indices.\r\n * @param indexPositionA first index to test.\r\n * @param indexPositionB one past final index to test.\r\n * @param data data array.\r\n * @param dataLength length of data array.\r\n */\r\n public static areIndicesValid(\r\n indices: number[] | undefined,\r\n indexPositionA: number,\r\n indexPositionB: number,\r\n data: any,\r\n dataLength: number,\r\n ): boolean {\r\n if (indices === undefined && data === undefined)\r\n return true;\r\n if (indices === undefined || data === undefined)\r\n return false;\r\n if (indexPositionA < 0 || indexPositionA >= indices.length)\r\n return false;\r\n if (indexPositionB <= indexPositionA || indexPositionB > indices.length)\r\n return false;\r\n for (let i = indexPositionA; i < indexPositionB; i++)\r\n if (indices[i] < 0 || indices[i] >= dataLength)\r\n return false;\r\n return true;\r\n }\r\n /** Returns true if this polyface has no facets. */\r\n public abstract get isEmpty(): boolean;\r\n /** Returns the number of facets of this polyface. Subclasses should override. */\r\n public get facetCount(): number | undefined {\r\n return undefined;\r\n }\r\n}\r\n\r\n/**\r\n * An `IndexedPolyface` is a set of facets which can have normal, param, and color arrays with independent point,\r\n * normal, param, and color indices.\r\n * @public\r\n */\r\nexport class IndexedPolyface extends Polyface { // more info can be found at geometry/internaldocs/Polyface.md\r\n /**\r\n * Start indices of all facets of the polyface.\r\n * * Each element is an index to the `this.data.pointIndex` array entry for a specific facet.\r\n * * The facet count is `_facetStart.length - 1`.\r\n * * The face loop for the i_th facet consists of the entries in `this.data.pointIndex` at indices `_facetStart[i]`\r\n * up to (but not including) `_facetStart[i + 1]`.\r\n * * Note the array is initialized with one entry (value 0).\r\n */\r\n protected _facetStart: number[];\r\n /**\r\n * Index to the `this.data.face` array entry for a specific facet.\r\n * * `_facetToFaceData` has one entry per facet.\r\n */\r\n protected _facetToFaceData: number[];\r\n /**\r\n * Constructor for a new polyface.\r\n * @param data PolyfaceData arrays to capture.\r\n * @param facetStart optional array of facet start indices (e.g. known during clone)\r\n * @param facetToFacetData optional array of face identifiers (e.g. known during clone)\r\n */\r\n protected constructor(data: PolyfaceData, facetStart?: number[], facetToFaceData?: number[]) {\r\n super(data);\r\n if (facetStart)\r\n this._facetStart = facetStart.slice(); // deep copy\r\n else {\r\n this._facetStart = [];\r\n this._facetStart.push(0);\r\n }\r\n if (facetToFaceData)\r\n this._facetToFaceData = facetToFaceData.slice(); // deep copy\r\n else\r\n this._facetToFaceData = [];\r\n }\r\n /** Test if other is an instance of `IndexedPolyface` */\r\n public isSameGeometryClass(other: any): boolean {\r\n return other instanceof IndexedPolyface;\r\n }\r\n /** Tests for equivalence between two IndexedPolyfaces. */\r\n public override isAlmostEqual(other: any): boolean {\r\n if (other instanceof IndexedPolyface) {\r\n return this.data.isAlmostEqual(other.data) &&\r\n NumberArray.isExactEqual(this._facetStart, other._facetStart) &&\r\n NumberArray.isExactEqual(this._facetToFaceData, other._facetToFaceData);\r\n }\r\n return false;\r\n }\r\n /** Returns true if either the point array or the point index array is empty. */\r\n public get isEmpty(): boolean {\r\n return this.data.pointCount === 0 || this.data.pointIndex.length === 0;\r\n }\r\n /**\r\n * Transform the mesh.\r\n * * Apply the transform to points.\r\n * * Apply the (inverse transpose of the) matrix part to normals.\r\n * * If determinant of the transform matrix is negative, also\r\n * * negate normals\r\n * * reverse index order around each facet.\r\n */\r\n public tryTransformInPlace(transform: Transform) {\r\n if (!this.data.tryTransformInPlace(transform))\r\n return false;\r\n const determinant = transform.matrix.determinant();\r\n if (determinant < 0) {\r\n this.reverseIndices();\r\n this.reverseNormals();\r\n }\r\n return true;\r\n }\r\n /** Reverse indices for a single facet. */\r\n public reverseSingleFacet(facetId: number) {\r\n this.data.reverseIndicesSingleFacet(facetId, this._facetStart);\r\n }\r\n /** Return a deep clone. */\r\n public clone(): IndexedPolyface {\r\n const result = new IndexedPolyface(this.data.clone(), this._facetStart.slice(), this._facetToFaceData.slice());\r\n return result;\r\n }\r\n /**\r\n * Return a deep clone with transformed points and normals.\r\n * @see [[IndexedPolyface.tryTransformInPlace]] for details of how transform is done.\r\n */\r\n public cloneTransformed(transform: Transform): IndexedPolyface {\r\n const result = this.clone();\r\n result.tryTransformInPlace(transform);\r\n return result;\r\n }\r\n /** Reverse the order of indices around all facets. */\r\n public reverseIndices() {\r\n this.data.reverseIndices(this._facetStart);\r\n }\r\n /** Reverse the direction of all normal vectors. */\r\n public reverseNormals() {\r\n this.data.reverseNormals();\r\n }\r\n /**\r\n * Return face data using a facet index.\r\n * * Returns `undefined` if none found.\r\n * * This is the REFERENCE to the FacetFaceData not a copy.\r\n */\r\n public tryGetFaceData(i: number): FacetFaceData | undefined {\r\n if (i < 0 || i >= this._facetToFaceData.length)\r\n return undefined;\r\n const faceIndex = this._facetToFaceData[i];\r\n if (faceIndex < 0 || faceIndex >= this.data.face.length)\r\n return undefined;\r\n return this.data.face[faceIndex];\r\n }\r\n /**\r\n * Add facets from `source` to `this` polyface.\r\n * * Optionally reverse facet indices as per `PolyfaceData.reverseIndicesSingleFacet()` with `preserveStart = false` and\r\n * invert source normals.\r\n * * Optionally apply a `transform` to points and normals.\r\n * * Will only copy param, normal, color, and face data if we are already tracking them AND/OR the source contains them.\r\n */\r\n public addIndexedPolyface(source: IndexedPolyface, reversed: boolean, transform: Transform | undefined) {\r\n const numSourceFacets = source.facetCount;\r\n // add point, point index, and edge visibility data\r\n // note that there is no need to build an intermediate index map since all points are added\r\n const startOfNewPoints = this.data.point.length;\r\n const xyz = Point3d.create();\r\n for (let i = 0; i < source.data.point.length; i++) {\r\n source.data.point.getPoint3dAtUncheckedPointIndex(i, xyz);\r\n if (transform) {\r\n transform.multiplyPoint3d(xyz, xyz);\r\n this.addPoint(xyz);\r\n } else\r\n this.addPoint(xyz);\r\n }\r\n for (let i = 0; i < numSourceFacets; i++) {\r\n const i0 = source._facetStart[i];\r\n const i1 = source._facetStart[i + 1];\r\n if (reversed) {\r\n for (let j = i1; j-- > i0;) { // visibility is transferred from far vertex, e.g., -abc-d => dc-b-a\r\n this.addPointIndex(\r\n startOfNewPoints + source.data.pointIndex[j],\r\n source.data.edgeVisible[j > i0 ? j - 1 : i1 - 1],\r\n );\r\n }\r\n } else {\r\n for (let j = i0; j < i1; j++) {\r\n this.addPointIndex(\r\n startOfNewPoints + source.data.pointIndex[j],\r\n source.data.edgeVisible[j],\r\n );\r\n }\r\n }\r\n this.terminateFacet(false);\r\n }\r\n // add param and param index data\r\n if (undefined !== this.data.param && undefined !== source.data.param && undefined !== source.data.paramIndex) {\r\n const startOfNewParams = this.data.param.length;\r\n this.data.param.pushFromGrowableXYArray(source.data.param);\r\n for (let i = 0; i < numSourceFacets; i++) { // expect facet start and ends for points to match normals\r\n const i0 = source._facetStart[i];\r\n const i1 = source._facetStart[i + 1];\r\n if (reversed) {\r\n for (let j = i1; j-- > i0;)\r\n this.addParamIndex(startOfNewParams + source.data.paramIndex[j]);\r\n } else {\r\n for (let j = i0; j < i1; j++)\r\n this.addParamIndex(startOfNewParams + source.data.paramIndex[j]);\r\n }\r\n }\r\n }\r\n // add normal and normal index data\r\n if (undefined !== this.data.normal && undefined !== source.data.normal && undefined !== source.data.normalIndex) {\r\n const startOfNewNormals = this.data.normal.length;\r\n for (let i = 0; i < source.data.normal.length; i++) {\r\n const sourceNormal = source.data.normal.getVector3dAtCheckedVectorIndex(i)!;\r\n if (transform)\r\n transform.multiplyVector(sourceNormal, sourceNormal);\r\n if (reversed)\r\n sourceNormal.scaleInPlace(-1.0);\r\n this.addNormal(sourceNormal);\r\n }\r\n for (let i = 0; i < numSourceFacets; i++) { // expect facet start and ends for points to match normals\r\n const i0 = source._facetStart[i];\r\n const i1 = source._facetStart[i + 1];\r\n if (reversed) {\r\n for (let j = i1; j-- > i0;)\r\n this.addNormalIndex(startOfNewNormals + source.data.normalIndex[j]);\r\n } else {\r\n for (let j = i0; j < i1; j++)\r\n this.addNormalIndex(startOfNewNormals + source.data.normalIndex[j]);\r\n }\r\n }\r\n }\r\n // add color and color index data\r\n if (undefined !== this.data.color && undefined !== source.data.color && undefined !== source.data.colorIndex) {\r\n const startOfNewColors = this.data.color.length;\r\n for (const sourceColor of source.data.color)\r\n this.addColor(sourceColor);\r\n for (let i = 0; i < numSourceFacets; i++) { // expect facet start and ends for points to match colors\r\n const i0 = source._facetStart[i];\r\n const i1 = source._facetStart[i + 1];\r\n if (reversed) {\r\n for (let j = i1; j-- > i0;)\r\n this.addColorIndex(startOfNewColors + source.data.colorIndex[j]);\r\n } else {\r\n for (let j = i0; j < i1; j++)\r\n this.addColorIndex(startOfNewColors + source.data.colorIndex[j]);\r\n }\r\n }\r\n }\r\n // add face and facetToFace index data\r\n if (source.data.face.length !== 0) {\r\n const startOfNewFaceData = this.data.face.length;\r\n for (const face of source.data.face) {\r\n const sourceFaceData = face.clone();\r\n this.data.face.push(sourceFaceData);\r\n }\r\n for (const facetToFaceIdx of source._facetToFaceData) {\r\n this._facetToFaceData.push(startOfNewFaceData + facetToFaceIdx);\r\n }\r\n }\r\n }\r\n /**\r\n * Return the total number of indices in zero-terminated style, which includes\r\n * * all the indices in the packed zero-based table.\r\n * * one additional index for the zero-terminator of each facet.\r\n * @note Note that all index arrays (pointIndex, normalIndex, paramIndex, colorIndex) have the same counts, so there\r\n * is not a separate query for each of them.\r\n */\r\n public get zeroTerminatedIndexCount(): number {\r\n return this.data.pointIndex.length + this._facetStart.length - 1;\r\n }\r\n /**\r\n * Create an empty facet set with coordinate and index data to be supplied later.\r\n * @param needNormals `true` to allocate empty normal data and index arrays; `false` (default) to leave undefined.\r\n * @param needParams `true` to allocate empty uv parameter data and index arrays; `false` (default) to leave undefined.\r\n * @param needColors `true` to allocate empty color data and index arrays; `false` (default) to leave undefined.\r\n * @param twoSided `true` if the facets are to be considered viewable from the back; `false` (default) if not.\r\n */\r\n public static create(\r\n needNormals: boolean = false,\r\n needParams: boolean = false,\r\n needColors: boolean = false,\r\n twoSided: boolean = false,\r\n ): IndexedPolyface {\r\n return new IndexedPolyface(new PolyfaceData(needNormals, needParams, needColors, twoSided));\r\n }\r\n /**\r\n * Add (a clone of) a point to point array.\r\n * @param point the point.\r\n * @param priorIndex (optional) index of prior point to check for possible duplicate value.\r\n * @returns the zero-based index of the added or duplicate point.\r\n */\r\n public addPoint(point: Point3d, priorIndex?: number): number {\r\n if (priorIndex !== undefined) {\r\n const distance = this.data.point.distanceIndexToPoint(priorIndex, point);\r\n if (distance !== undefined && Geometry.isSmallMetricDistance(distance))\r\n return priorIndex;\r\n }\r\n this.data.point.pushXYZ(point.x, point.y, point.z);\r\n return this.data.point.length - 1;\r\n }\r\n /**\r\n * Add a point to point array.\r\n * @param x the x coordinate of point.\r\n * @param y the y coordinate of point.\r\n * @param z the z coordinate of point.\r\n * @returns the zero-based index of the added point.\r\n */\r\n public addPointXYZ(x: number, y: number, z: number): number {\r\n this.data.point.pushXYZ(x, y, z);\r\n return this.data.point.length - 1;\r\n }\r\n /**\r\n * Add (a clone of) a uv parameter to the parameter array.\r\n * @param param the parameter.\r\n * @returns zero-based index of the added param.\r\n */\r\n public addParam(param: Point2d): number {\r\n if (!this.data.param)\r\n this.data.param = new GrowableXYArray();\r\n this.data.param.push(param);\r\n return this.data.param.length - 1;\r\n }\r\n /**\r\n * Add a uv parameter to the parameter array.\r\n * @param u the u part of parameter.\r\n * @param v the v part of parameter.\r\n * @param priorIndexA first index to check for possible duplicate value.\r\n * @param priorIndexB second index to check for possible duplicate value.\r\n * @returns zero-based index of the added or duplicate parameter.\r\n */\r\n public addParamUV(u: number, v: number, priorIndexA?: number, priorIndexB?: number): number {\r\n if (!this.data.param)\r\n this.data.param = new GrowableXYArray();\r\n if (priorIndexA !== undefined && this.data.isAlmostEqualParamIndexUV(priorIndexA, u, v))\r\n return priorIndexA;\r\n if (priorIndexB !== undefined && this.data.isAlmostEqualParamIndexUV(priorIndexB, u, v))\r\n return priorIndexB;\r\n this.data.param.pushXY(u, v);\r\n return this.data.param.length - 1;\r\n }\r\n /**\r\n * Add (a clone of) a normal vector to the normal array.\r\n * @param normal the normal vector.\r\n * @param priorIndexA first index to check for possible duplicate value.\r\n * @param priorIndexB second index to check for possible duplicate value.\r\n * @returns zero-based index of the added or duplicate normal.\r\n */\r\n public addNormal(normal: Vector3d, priorIndexA?: number, priorIndexB?: number): number {\r\n // check if `normal` is duplicate of `dataNormal` at index `i`\r\n const normalIsDuplicate = (i: number) => {\r\n const distance = this.data.normal!.distanceIndexToPoint(i, normal);\r\n return distance !== undefined && Geometry.isSmallMetricDistance(distance);\r\n };\r\n if (this.data.normal !== undefined) {\r\n if (priorIndexA !== undefined && normalIsDuplicate(priorIndexA))\r\n return priorIndexA;\r\n if (priorIndexB !== undefined && normalIsDuplicate(priorIndexB))\r\n return priorIndexB;\r\n // check the tail index for possible duplicate\r\n if (priorIndexA !== undefined || priorIndexB !== undefined) {\r\n const tailIndex = this.data.normal.length - 1;\r\n if (normalIsDuplicate(tailIndex))\r\n return tailIndex;\r\n }\r\n }\r\n return this.addNormalXYZ(normal.x, normal.y, normal.z);\r\n }\r\n /**\r\n * Add a normal vector to the normal array.\r\n * @param x the x coordinate of normal.\r\n * @param y the y coordinate of normal.\r\n * @param z the z coordinate of normal.\r\n * @returns zero-based index of the added normal vector.\r\n */\r\n public addNormalXYZ(x: number, y: number, z: number): number {\r\n if (!this.data.normal)\r\n this.data.normal = new GrowableXYZArray();\r\n this.data.normal.pushXYZ(x, y, z);\r\n return this.data.normal.length - 1;\r\n }\r\n /**\r\n * Add a color to the color array\r\n * @param color the color.\r\n * @returns zero-based index of the added color.\r\n */\r\n public addColor(color: number): number {\r\n if (!this.data.color)\r\n this.data.color = [];\r\n this.data.color.push(color);\r\n return this.data.color.length - 1;\r\n }\r\n /** Add a point index with edge visibility flag. */\r\n public addPointIndex(index: number, visible: boolean = true): void {\r\n this.data.pointIndex.push(index);\r\n this.data.edgeVisible.push(visible);\r\n }\r\n /** Add a normal index. */\r\n public addNormalIndex(index: number): void {\r\n if (!this.data.normalIndex)\r\n this.data.normalIndex = [];\r\n this.data.normalIndex.push(index);\r\n }\r\n /** Add a param index. */\r\n public addParamIndex(index: number): void {\r\n if (!this.data.paramIndex)\r\n this.data.paramIndex = [];\r\n this.data.paramIndex.push(index);\r\n }\r\n /** Add a color index. */\r\n public addColorIndex(index: number): void {\r\n if (!this.data.colorIndex)\r\n this.data.colorIndex = [];\r\n this.data.colorIndex.push(index);\r\n }\r\n /**\r\n * Clean up the open facet.\r\n * @deprecated in 4.x to remove nebulous \"open facet\" concept from the API. Call [[PolyfaceData.trimAllIndexArrays]]\r\n * instead.\r\n */\r\n public cleanupOpenFacet(): void {\r\n this.data.trimAllIndexArrays(this.data.pointIndex.length);\r\n }\r\n\r\n /**\r\n * Validate (the tail of) the active index arrays: point, normal, param, color.\r\n * @param index0 optional offset into the index arrays at which to start validating indices. Default 0.\r\n * @param errors optional array appended with error message(s) if invalid indices are encountered\r\n * @return whether the indices are valid\r\n */\r\n public validateAllIndices(index0: number = 0, errors?: string[]): boolean {\r\n const numPointIndices = this.data.pointIndex.length;\r\n const messages = errors ?? [];\r\n if (this.data.normalIndex && this.data.normalIndex.length !== numPointIndices)\r\n messages.push(\"normalIndex count must match pointIndex count\");\r\n if (this.data.paramIndex && this.data.paramIndex.length !== numPointIndices)\r\n messages.push(\"paramIndex count must equal pointIndex count\");\r\n if (this.data.colorIndex && this.data.colorIndex.length !== numPointIndices)\r\n messages.push(\"colorIndex count must equal pointIndex count\");\r\n if (this.data.edgeVisible.length !== numPointIndices)\r\n messages.push(\"visibleIndex count must equal pointIndex count\");\r\n if (!Polyface.areIndicesValid(this.data.pointIndex, index0, numPointIndices, this.data.point, this.data.point ? this.data.point.length : 0))\r\n messages.push(\"invalid point indices in the last facet\");\r\n if (!Polyface.areIndicesValid(this.data.normalIndex, index0, numPointIndices, this.data.normal, this.data.normal ? this.data.normal.length : 0))\r\n messages.push(\"invalid normal indices in the last facet\");\r\n if (!Polyface.areIndicesValid(this.data.paramIndex, index0, numPointIndices, this.data.param, this.data.param ? this.data.param.length : 0))\r\n messages.push(\"invalid param indices in the last facet\");\r\n if (!Polyface.areIndicesValid(this.data.colorIndex, index0, numPointIndices, this.data.color, this.data.color ? this.data.color.length : 0))\r\n messages.push(\"invalid color indices in the last facet\");\r\n return 0 === messages.length;\r\n }\r\n\r\n /**\r\n * Announce the end of construction of a facet.\r\n * * Optionally check for:\r\n * * Same number of indices among all active index arrays -- point, normal, param, color\r\n * * All indices for the latest facet are within bounds of the respective data arrays.\r\n * * In error cases, all index arrays are trimmed back to the size when previous facet was terminated.\r\n * * A return value of `undefined` is normal. Otherwise, a string array of error messages is returned.\r\n */\r\n public terminateFacet(validateAllIndices: boolean = true): string[] | undefined {\r\n const numFacets = this._facetStart.length - 1;\r\n // number of indices in accepted facets\r\n const lengthA = this._facetStart[numFacets];\r\n // number of indices in all facets (accepted facet plus the last facet to be accepted)\r\n const lengthB = this.data.pointIndex.length;\r\n if (validateAllIndices) {\r\n const messages: string[] = [];\r\n if (lengthB < lengthA + 2)\r\n messages.push(\"Less than 3 indices in the last facet\");\r\n this.validateAllIndices(lengthA, messages);\r\n if (messages.length > 0) {\r\n this.data.trimAllIndexArrays(lengthA);\r\n return messages;\r\n }\r\n }\r\n this._facetStart.push(lengthB); // append start index of the future facet\r\n return undefined;\r\n }\r\n /** Number of facets (read-only property). */\r\n public override get facetCount(): number {\r\n return this._facetStart.length - 1;\r\n }\r\n /** Number of faces (read-only property). */\r\n public get faceCount(): number {\r\n return this.data.faceCount;\r\n }\r\n /** Number of points (read-only property). */\r\n public get pointCount(): number {\r\n return this.data.pointCount;\r\n }\r\n /** Number of colors (read-only property). */\r\n public get colorCount(): number {\r\n return this.data.colorCount;\r\n }\r\n /** Number of parameters (read-only property). */\r\n public get paramCount(): number {\r\n return this.data.paramCount;\r\n }\r\n /** Number of normals (read-only property). */\r\n public get normalCount(): number {\r\n return this.data.normalCount;\r\n }\r\n /** Test if `index` is a valid facet index. */\r\n public isValidFacetIndex(index: number): boolean {\r\n return index >= 0 && index < this.facetCount;\r\n }\r\n /** Return the number of edges in a particular facet. */\r\n public numEdgeInFacet(facetIndex: number): number {\r\n if (this.isValidFacetIndex(facetIndex))\r\n return this._facetStart[facetIndex + 1] - this._facetStart[facetIndex];\r\n return 0;\r\n }\r\n /** ASSUME valid facet index. Return start index of facet in pointIndex arrays. */\r\n public facetIndex0(index: number): number {\r\n return this._facetStart[index];\r\n }\r\n /** ASSUME valid facet index. Return one past end index of facet in pointIndex arrays. */\r\n public facetIndex1(index: number): number {\r\n return this._facetStart[index + 1];\r\n }\r\n /** Create a visitor for this polyface */\r\n public createVisitor(numWrap: number = 0): IndexedPolyfaceVisitor {\r\n return IndexedPolyfaceVisitor.create(this, numWrap);\r\n }\r\n /** Return the range of (optionally transformed) points in this mesh. */\r\n public override range(transform?: Transform, result?: Range3d): Range3d {\r\n return this.data.range(result, transform);\r\n }\r\n /** Extend `range` with coordinates from this mesh. */\r\n public extendRange(range: Range3d, transform?: Transform): void {\r\n this.data.range(range, transform);\r\n }\r\n /**\r\n * Given the index of a facet, return the data pertaining to the face it is a part of.\r\n * @deprecated in 4.x. Use [[IndexedPolyface.tryGetFaceData]], which verifies the index is in range.\r\n */\r\n public getFaceDataByFacetIndex(facetIndex: number): FacetFaceData {\r\n return this.data.face[this._facetToFaceData[facetIndex]];\r\n }\r\n /**\r\n * Set new FacetFaceData.\r\n * * All terminated facets since the last face declaration will be mapped to a single new FacetFaceData object using\r\n * facetToFaceData[]. FacetFaceData holds the 2D range of the face. Returns `true` if successful, `false` otherwise.\r\n */\r\n public setNewFaceData(endFacetIndex: number = 0): boolean {\r\n const facetStart = this._facetToFaceData.length;\r\n if (facetStart >= this._facetStart.length)\r\n return false;\r\n if (0 === endFacetIndex) // the default for endFacetIndex is really the last facet\r\n endFacetIndex = this._facetStart.length; // last facet index corresponds to the future facet\r\n const faceData = FacetFaceData.createNull();\r\n const visitor = IndexedPolyfaceVisitor.create(this, 0);\r\n if (!visitor.moveToReadIndex(facetStart)) { // move visitor to first facet of new face\r\n return false;\r\n }\r\n // if parameter range is provided (by the polyface planeSet clipper) then use it\r\n const paramDefined = this.data.param !== undefined;\r\n const setParamRange: boolean = faceData.paramRange.isNull && paramDefined;\r\n do {\r\n if (setParamRange && visitor.param !== undefined)\r\n visitor.param.extendRange(faceData.paramRange);\r\n } while (visitor.moveToNextFacet() && visitor.currentReadIndex() < endFacetIndex);\r\n if (paramDefined && !(this.data.param!.length === 0) && faceData.paramDistanceRange.isNull)\r\n faceData.setParamDistanceRangeFromNewFaceData(this, facetStart, endFacetIndex);\r\n this.data.face.push(faceData);\r\n const faceDataIndex = this.data.face.length - 1;\r\n for (let i = this._facetToFaceData.length; i < endFacetIndex; i++)\r\n this._facetToFaceData.push(0 === this._facetStart[i] ? 0 : faceDataIndex);\r\n return true;\r\n }\r\n /** Second step of double dispatch: call `handler.handleIndexedPolyface(this)`. */\r\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\r\n return handler.handleIndexedPolyface(this);\r\n }\r\n}\r\n\r\n/**\r\n * A PolyfaceVisitor manages data while walking through facets.\r\n * * The polyface visitor holds data for one facet at a time.\r\n * * The caller can request the position in the addressed polyfaceData as a \"readIndex\".\r\n * * The readIndex values (as numbers) are not promised to be sequential (i.e., it might be a simple facet count\r\n * or might have \"gaps\" at the whim of the particular PolyfaceVisitor implementation).\r\n * @public\r\n */\r\nexport interface PolyfaceVisitor extends PolyfaceData {\r\n /** Load data for the facet with given index. */\r\n moveToReadIndex(index: number): boolean;\r\n /** Return the readIndex of the currently loaded facet. */\r\n currentReadIndex(): number;\r\n /** Load data for the next facet. */\r\n moveToNextFacet(): boolean;\r\n /** Reset to initial state for reading all facets sequentially with moveToNextFacet. */\r\n reset(): void;\r\n /** Return the point index of vertex i within the currently loaded facet. */\r\n clientPointIndex(i: number): number;\r\n /** Return the param index of vertex i within the currently loaded facet. */\r\n clientParamIndex(i: number): number;\r\n /** Return the normal index of vertex i within the currently loaded facet. */\r\n clientNormalIndex(i: number): number;\r\n /** Return the color index of vertex i within the currently loaded facet. */\r\n clientColorIndex(i: number): number;\r\n /** Return the aux data index of vertex i within the currently loaded facet. */\r\n clientAuxIndex(i: number): number;\r\n /** Return the client polyface. */\r\n clientPolyface(): Polyface | undefined;\r\n /**\r\n * Set the number of vertices replicated in visitor arrays (both data and index arrays).\r\n * * 0,1,2 are the most common as numWrap.\r\n * * Example: suppose `[6,7,8]` is the pointIndex array representing a triangle. First edge would be `6,7`. Second\r\n * edge is `7,8`. Third edge is `8,6`. To access `6` for the third edge, we have to go back to the start of array.\r\n * Therefore, it is useful to store `6` at the end of pointIndex array, i.e., `[6,7,8,6]` meaning `numWrap = 1`.\r\n * * Continuing this example, `numWrap = 2` (i.e., `[6,7,8,6,7]`) is useful when each vertex visit requires\r\n * the next two points, e.g., to form two adjacent vectors for a cross product.\r\n */\r\n setNumWrap(numWrap: number): void;\r\n /** Clear the contents of all arrays. Use this along with `pushDataFrom` to build up new facets. */\r\n clearArrays(): void;\r\n /** Transfer data from a specified index of the other visitor as new data in this visitor. */\r\n pushDataFrom(other: PolyfaceVisitor, index: number): void;\r\n /**\r\n * Transfer interpolated data from the other visitor.\r\n * * All data values are interpolated at `fraction` between `other` values at `index0` and `index1`.\r\n */\r\n pushInterpolatedDataFrom(other: PolyfaceVisitor, index0: number, fraction: number, index1: number): void;\r\n /**\r\n * Return the number of facets this visitor is able to visit.\r\n * * Allows implementers to improve the efficiency of e.g., [[PolyfaceQuery.visitorClientFacetCount]].\r\n */\r\n getVisitableFacetCount?(): number;\r\n}\r\n"]}
1
+ {"version":3,"file":"Polyface.js","sourceRoot":"","sources":["../../../src/polyface/Polyface.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,2BAA2B;AAE3B,0DAAuD;AACvD,0CAAuC;AAEvC,mEAAgE;AAChE,qEAAkE;AAElE,mEAAkE;AAClE,6DAAyD;AAGzD,mDAAgD;AAChD,qEAAkE;AAClE,iDAA8C;AAE9C;;;;GAIG;AACH,MAAsB,QAAS,SAAQ,6BAAa;IAKlD,kBAAkB;IAClB,YAAsB,IAAkB;QACtC,KAAK,EAAE,CAAC;QANV,wCAAwC;QACxB,qBAAgB,GAAG,UAAU,CAAC;QAM5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAMD,8EAA8E;IAC9E,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC5B,CAAC;IACD,IAAW,QAAQ,CAAC,KAAc;QAChC,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IAC7B,CAAC;IACD;;;;OAIG;IACH,IAAW,eAAe;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC;IACnC,CAAC;IACD,IAAW,eAAe,CAAC,KAAa;QACtC,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;IACpC,CAAC;IACD;;;;;;;;;;OAUG;IACI,MAAM,CAAC,eAAe,CAC3B,OAA6B,EAC7B,cAAsB,EACtB,cAAsB,EACtB,IAAS,EACT,UAAkB;QAElB,IAAI,OAAO,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS;YAC7C,OAAO,IAAI,CAAC;QACd,IAAI,OAAO,KAAK,SAAS,IAAI,IAAI,KAAK,S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CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;QAC5E,OAAO,IAAI,CAAC;IACd,CAAC;IACD,kFAAkF;IAC3E,yBAAyB,CAAC,OAAwB;QACvD,OAAO,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;CACF;AA5gBD,0CA4gBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Polyface\r\n */\r\n\r\n// cspell:word internaldocs\r\n\r\nimport { GeometryQuery } from \"../curve/GeometryQuery\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GeometryHandler } from \"../geometry3d/GeometryHandler\";\r\nimport { GrowableXYArray } from \"../geometry3d/GrowableXYArray\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { Point2d } from \"../geometry3d/Point2dVector2d\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { NumberArray } from \"../geometry3d/PointHelpers\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { FacetFaceData } from \"./FacetFaceData\";\r\nimport { IndexedPolyfaceVisitor } from \"./IndexedPolyfaceVisitor\";\r\nimport { PolyfaceData } from \"./PolyfaceData\";\r\n\r\n/**\r\n * A Polyface is an abstract mesh structure (of unspecified implementation) that provides a PolyfaceVisitor\r\n * to iterate over its facets.\r\n * @public\r\n */\r\nexport abstract class Polyface extends GeometryQuery {\r\n /** String name for schema properties */\r\n public readonly geometryCategory = \"polyface\";\r\n /** Underlying polyface data. */\r\n public data: PolyfaceData;\r\n /** Constructor */\r\n protected constructor(data: PolyfaceData) {\r\n super();\r\n this.data = data;\r\n }\r\n /**\r\n * Create and return a visitor for this concrete polyface.\r\n * @param numWrap the number of vertices to replicate in visitor arrays.\r\n */\r\n public abstract createVisitor(numWrap: number): PolyfaceVisitor;\r\n /** Flag indicating if the mesh display must assume both sides are visible. */\r\n public get twoSided() {\r\n return this.data.twoSided;\r\n }\r\n public set twoSided(value: boolean) {\r\n this.data.twoSided = value;\r\n }\r\n /**\r\n * Flag indicating if the mesh closure is unknown (0), open sheet (1), closed solid (2).\r\n * * A boundary edge of a mesh is defined as an edge with only one connected facet.\r\n * * Closed solid is a mesh with no boundary edge. Open sheet is a mesh that has boundary edge(s).\r\n */\r\n public get expectedClosure(): number {\r\n return this.data.expectedClosure;\r\n }\r\n public set expectedClosure(value: number) {\r\n this.data.expectedClosure = value;\r\n }\r\n /**\r\n * Check validity of indices into a data array.\r\n * * It is valid to have both indices and data undefined.\r\n * * It is NOT valid for just one to be defined.\r\n * * Index values at indices[indexPositionA <= i < indexPositionB] must be valid indices to the data array.\r\n * @param indices array of indices.\r\n * @param indexPositionA first index to test.\r\n * @param indexPositionB one past final index to test.\r\n * @param data data array.\r\n * @param dataLength length of data array.\r\n */\r\n public static areIndicesValid(\r\n indices: number[] | undefined,\r\n indexPositionA: number,\r\n indexPositionB: number,\r\n data: any,\r\n dataLength: number,\r\n ): boolean {\r\n if (indices === undefined && data === undefined)\r\n return true;\r\n if (indices === undefined || data === undefined)\r\n return false;\r\n if (indexPositionA < 0 || indexPositionA >= indices.length)\r\n return false;\r\n if (indexPositionB <= indexPositionA || indexPositionB > indices.length)\r\n return false;\r\n for (let i = indexPositionA; i < indexPositionB; i++)\r\n if (indices[i] < 0 || indices[i] >= dataLength)\r\n return false;\r\n return true;\r\n }\r\n /** Returns true if this polyface has no facets. */\r\n public abstract get isEmpty(): boolean;\r\n /** Returns the number of facets of this polyface. Subclasses should override. */\r\n public get facetCount(): number | undefined {\r\n return undefined;\r\n }\r\n}\r\n\r\n/**\r\n * An `IndexedPolyface` is a set of facets which can have normal, param, and color arrays with independent point,\r\n * normal, param, and color indices.\r\n * @public\r\n */\r\nexport class IndexedPolyface extends Polyface { // more info can be found at geometry/internaldocs/Polyface.md\r\n /**\r\n * Start indices of all facets of the polyface.\r\n * * Each element is an index to the `this.data.pointIndex` array entry for a specific facet.\r\n * * The facet count is `_facetStart.length - 1`.\r\n * * The face loop for the i_th facet consists of the entries in `this.data.pointIndex` at indices `_facetStart[i]`\r\n * up to (but not including) `_facetStart[i + 1]`.\r\n * * Note the array is initialized with one entry (value 0).\r\n */\r\n protected _facetStart: number[];\r\n /**\r\n * Index to the `this.data.face` array entry for a specific facet.\r\n * * `_facetToFaceData` has one entry per facet.\r\n */\r\n protected _facetToFaceData: number[];\r\n /**\r\n * Constructor for a new polyface.\r\n * @param data PolyfaceData arrays to capture.\r\n * @param facetStart optional array of facet start indices (e.g. known during clone)\r\n * @param facetToFacetData optional array of face identifiers (e.g. known during clone)\r\n */\r\n protected constructor(data: PolyfaceData, facetStart?: number[], facetToFaceData?: number[]) {\r\n super(data);\r\n if (facetStart)\r\n this._facetStart = facetStart.slice(); // deep copy\r\n else {\r\n this._facetStart = [];\r\n this._facetStart.push(0);\r\n }\r\n if (facetToFaceData)\r\n this._facetToFaceData = facetToFaceData.slice(); // deep copy\r\n else\r\n this._facetToFaceData = [];\r\n }\r\n /** Test if other is an instance of `IndexedPolyface` */\r\n public isSameGeometryClass(other: any): boolean {\r\n return other instanceof IndexedPolyface;\r\n }\r\n /** Tests for equivalence between two IndexedPolyfaces. */\r\n public override isAlmostEqual(other: any): boolean {\r\n if (other instanceof IndexedPolyface) {\r\n return this.data.isAlmostEqual(other.data) &&\r\n NumberArray.isExactEqual(this._facetStart, other._facetStart) &&\r\n NumberArray.isExactEqual(this._facetToFaceData, other._facetToFaceData);\r\n }\r\n return false;\r\n }\r\n /** Returns true if either the point array or the point index array is empty. */\r\n public get isEmpty(): boolean {\r\n return this.data.pointCount === 0 || this.data.pointIndex.length === 0;\r\n }\r\n /**\r\n * Transform the mesh.\r\n * * If `transform` is a mirror, also reverse the index order around each facet.\r\n * * Note that this method always returns true. If transforming the normals fails (due to singular matrix or zero\r\n * normal), the original normal(s) are left unchanged.\r\n */\r\n public tryTransformInPlace(transform: Transform): boolean {\r\n this.data.tryTransformInPlace(transform);\r\n if (transform.matrix.determinant() < 0)\r\n this.reverseIndices();\r\n return true;\r\n }\r\n /** Reverse indices for a single facet. */\r\n public reverseSingleFacet(facetId: number) {\r\n this.data.reverseIndicesSingleFacet(facetId, this._facetStart);\r\n }\r\n /** Return a deep clone. */\r\n public clone(): IndexedPolyface {\r\n return new IndexedPolyface(this.data.clone(), this._facetStart.slice(), this._facetToFaceData.slice());\r\n }\r\n /**\r\n * Return a deep clone with transformed points and normals.\r\n * @see [[IndexedPolyface.tryTransformInPlace]] for details of how transform is done.\r\n */\r\n public cloneTransformed(transform: Transform): IndexedPolyface { // we know tryTransformInPlace succeeds.\r\n const result = this.clone();\r\n result.tryTransformInPlace(transform);\r\n return result;\r\n }\r\n /** Reverse the order of indices around all facets. */\r\n public reverseIndices() {\r\n this.data.reverseIndices(this._facetStart);\r\n }\r\n /** Reverse the direction of all normal vectors. */\r\n public reverseNormals() {\r\n this.data.reverseNormals();\r\n }\r\n /**\r\n * Return face data using a facet index.\r\n * * Returns `undefined` if none found.\r\n * * This is the REFERENCE to the FacetFaceData not a copy.\r\n */\r\n public tryGetFaceData(i: number): FacetFaceData | undefined {\r\n if (i < 0 || i >= this._facetToFaceData.length)\r\n return undefined;\r\n const faceIndex = this._facetToFaceData[i];\r\n if (faceIndex < 0 || faceIndex >= this.data.face.length)\r\n return undefined;\r\n return this.data.face[faceIndex];\r\n }\r\n /**\r\n * Add facets from `source` to `this` polyface.\r\n * * Optionally reverse facet indices as per `PolyfaceData.reverseIndicesSingleFacet()` with `preserveStart = false` and\r\n * invert source normals.\r\n * * Optionally apply a `transform` to points and normals.\r\n * * Will only copy param, normal, color, and face data if we are already tracking them AND/OR the source contains them.\r\n */\r\n public addIndexedPolyface(source: IndexedPolyface, reversed: boolean, transform: Transform | undefined) {\r\n const numSourceFacets = source.facetCount;\r\n // add point, point index, and edge visibility data\r\n // note that there is no need to build an intermediate index map since all points are added\r\n const startOfNewPoints = this.data.point.length;\r\n const xyz = Point3d.create();\r\n for (let i = 0; i < source.data.point.length; i++) {\r\n source.data.point.getPoint3dAtUncheckedPointIndex(i, xyz);\r\n if (transform) {\r\n transform.multiplyPoint3d(xyz, xyz);\r\n this.addPoint(xyz);\r\n } else\r\n this.addPoint(xyz);\r\n }\r\n for (let i = 0; i < numSourceFacets; i++) {\r\n const i0 = source._facetStart[i];\r\n const i1 = source._facetStart[i + 1];\r\n if (reversed) {\r\n for (let j = i1; j-- > i0;) { // visibility is transferred from far vertex, e.g., -abc-d => dc-b-a\r\n this.addPointIndex(\r\n startOfNewPoints + source.data.pointIndex[j],\r\n source.data.edgeVisible[j > i0 ? j - 1 : i1 - 1],\r\n );\r\n }\r\n } else {\r\n for (let j = i0; j < i1; j++) {\r\n this.addPointIndex(\r\n startOfNewPoints + source.data.pointIndex[j],\r\n source.data.edgeVisible[j],\r\n );\r\n }\r\n }\r\n this.terminateFacet(false);\r\n }\r\n // add param and param index data\r\n if (undefined !== this.data.param && undefined !== source.data.param && undefined !== source.data.paramIndex) {\r\n const startOfNewParams = this.data.param.length;\r\n this.data.param.pushFromGrowableXYArray(source.data.param);\r\n for (let i = 0; i < numSourceFacets; i++) { // expect facet start and ends for points to match normals\r\n const i0 = source._facetStart[i];\r\n const i1 = source._facetStart[i + 1];\r\n if (reversed) {\r\n for (let j = i1; j-- > i0;)\r\n this.addParamIndex(startOfNewParams + source.data.paramIndex[j]);\r\n } else {\r\n for (let j = i0; j < i1; j++)\r\n this.addParamIndex(startOfNewParams + source.data.paramIndex[j]);\r\n }\r\n }\r\n }\r\n // add normal and normal index data\r\n if (undefined !== this.data.normal && undefined !== source.data.normal && undefined !== source.data.normalIndex) {\r\n const startOfNewNormals = this.data.normal.length;\r\n for (let i = 0; i < source.data.normal.length; i++) {\r\n const sourceNormal = source.data.normal.getVector3dAtCheckedVectorIndex(i)!;\r\n if (transform)\r\n transform.multiplyVector(sourceNormal, sourceNormal);\r\n if (reversed)\r\n sourceNormal.scaleInPlace(-1.0);\r\n this.addNormal(sourceNormal);\r\n }\r\n for (let i = 0; i < numSourceFacets; i++) { // expect facet start and ends for points to match normals\r\n const i0 = source._facetStart[i];\r\n const i1 = source._facetStart[i + 1];\r\n if (reversed) {\r\n for (let j = i1; j-- > i0;)\r\n this.addNormalIndex(startOfNewNormals + source.data.normalIndex[j]);\r\n } else {\r\n for (let j = i0; j < i1; j++)\r\n this.addNormalIndex(startOfNewNormals + source.data.normalIndex[j]);\r\n }\r\n }\r\n }\r\n // add color and color index data\r\n if (undefined !== this.data.color && undefined !== source.data.color && undefined !== source.data.colorIndex) {\r\n const startOfNewColors = this.data.color.length;\r\n for (const sourceColor of source.data.color)\r\n this.addColor(sourceColor);\r\n for (let i = 0; i < numSourceFacets; i++) { // expect facet start and ends for points to match colors\r\n const i0 = source._facetStart[i];\r\n const i1 = source._facetStart[i + 1];\r\n if (reversed) {\r\n for (let j = i1; j-- > i0;)\r\n this.addColorIndex(startOfNewColors + source.data.colorIndex[j]);\r\n } else {\r\n for (let j = i0; j < i1; j++)\r\n this.addColorIndex(startOfNewColors + source.data.colorIndex[j]);\r\n }\r\n }\r\n }\r\n // add face and facetToFace index data\r\n if (source.data.face.length !== 0) {\r\n const startOfNewFaceData = this.data.face.length;\r\n for (const face of source.data.face) {\r\n const sourceFaceData = face.clone();\r\n this.data.face.push(sourceFaceData);\r\n }\r\n for (const facetToFaceIdx of source._facetToFaceData) {\r\n this._facetToFaceData.push(startOfNewFaceData + facetToFaceIdx);\r\n }\r\n }\r\n }\r\n /**\r\n * Return the total number of indices in zero-terminated style, which includes\r\n * * all the indices in the packed zero-based table.\r\n * * one additional index for the zero-terminator of each facet.\r\n * @note Note that all index arrays (pointIndex, normalIndex, paramIndex, colorIndex) have the same counts, so there\r\n * is not a separate query for each of them.\r\n */\r\n public get zeroTerminatedIndexCount(): number {\r\n return this.data.pointIndex.length + this._facetStart.length - 1;\r\n }\r\n /**\r\n * Create an empty facet set with coordinate and index data to be supplied later.\r\n * @param needNormals `true` to allocate empty normal data and index arrays; `false` (default) to leave undefined.\r\n * @param needParams `true` to allocate empty uv parameter data and index arrays; `false` (default) to leave undefined.\r\n * @param needColors `true` to allocate empty color data and index arrays; `false` (default) to leave undefined.\r\n * @param twoSided `true` if the facets are to be considered viewable from the back; `false` (default) if not.\r\n */\r\n public static create(\r\n needNormals: boolean = false,\r\n needParams: boolean = false,\r\n needColors: boolean = false,\r\n twoSided: boolean = false,\r\n ): IndexedPolyface {\r\n return new IndexedPolyface(new PolyfaceData(needNormals, needParams, needColors, twoSided));\r\n }\r\n /**\r\n * Add (a clone of) a point to point array.\r\n * @param point the point.\r\n * @param priorIndex (optional) index of prior point to check for possible duplicate value.\r\n * @returns the zero-based index of the added or duplicate point.\r\n */\r\n public addPoint(point: Point3d, priorIndex?: number): number {\r\n if (priorIndex !== undefined) {\r\n const distance = this.data.point.distanceIndexToPoint(priorIndex, point);\r\n if (distance !== undefined && Geometry.isSmallMetricDistance(distance))\r\n return priorIndex;\r\n }\r\n this.data.point.pushXYZ(point.x, point.y, point.z);\r\n return this.data.point.length - 1;\r\n }\r\n /**\r\n * Add a point to point array.\r\n * @param x the x coordinate of point.\r\n * @param y the y coordinate of point.\r\n * @param z the z coordinate of point.\r\n * @returns the zero-based index of the added point.\r\n */\r\n public addPointXYZ(x: number, y: number, z: number): number {\r\n this.data.point.pushXYZ(x, y, z);\r\n return this.data.point.length - 1;\r\n }\r\n /**\r\n * Add (a clone of) a uv parameter to the parameter array.\r\n * @param param the parameter.\r\n * @returns zero-based index of the added param.\r\n */\r\n public addParam(param: Point2d): number {\r\n if (!this.data.param)\r\n this.data.param = new GrowableXYArray();\r\n this.data.param.push(param);\r\n return this.data.param.length - 1;\r\n }\r\n /**\r\n * Add a uv parameter to the parameter array.\r\n * @param u the u part of parameter.\r\n * @param v the v part of parameter.\r\n * @param priorIndexA first index to check for possible duplicate value.\r\n * @param priorIndexB second index to check for possible duplicate value.\r\n * @returns zero-based index of the added or duplicate parameter.\r\n */\r\n public addParamUV(u: number, v: number, priorIndexA?: number, priorIndexB?: number): number {\r\n if (!this.data.param)\r\n this.data.param = new GrowableXYArray();\r\n if (priorIndexA !== undefined && this.data.isAlmostEqualParamIndexUV(priorIndexA, u, v))\r\n return priorIndexA;\r\n if (priorIndexB !== undefined && this.data.isAlmostEqualParamIndexUV(priorIndexB, u, v))\r\n return priorIndexB;\r\n this.data.param.pushXY(u, v);\r\n return this.data.param.length - 1;\r\n }\r\n /**\r\n * Add (a clone of) a normal vector to the normal array.\r\n * @param normal the normal vector.\r\n * @param priorIndexA first index to check for possible duplicate value.\r\n * @param priorIndexB second index to check for possible duplicate value.\r\n * @returns zero-based index of the added or duplicate normal.\r\n */\r\n public addNormal(normal: Vector3d, priorIndexA?: number, priorIndexB?: number): number {\r\n // check if `normal` is duplicate of `dataNormal` at index `i`\r\n const normalIsDuplicate = (i: number) => {\r\n const distance = this.data.normal!.distanceIndexToPoint(i, normal);\r\n return distance !== undefined && Geometry.isSmallMetricDistance(distance);\r\n };\r\n if (this.data.normal !== undefined) {\r\n if (priorIndexA !== undefined && normalIsDuplicate(priorIndexA))\r\n return priorIndexA;\r\n if (priorIndexB !== undefined && normalIsDuplicate(priorIndexB))\r\n return priorIndexB;\r\n // check the tail index for possible duplicate\r\n if (priorIndexA !== undefined || priorIndexB !== undefined) {\r\n const tailIndex = this.data.normal.length - 1;\r\n if (normalIsDuplicate(tailIndex))\r\n return tailIndex;\r\n }\r\n }\r\n return this.addNormalXYZ(normal.x, normal.y, normal.z);\r\n }\r\n /**\r\n * Add a normal vector to the normal array.\r\n * @param x the x coordinate of normal.\r\n * @param y the y coordinate of normal.\r\n * @param z the z coordinate of normal.\r\n * @returns zero-based index of the added normal vector.\r\n */\r\n public addNormalXYZ(x: number, y: number, z: number): number {\r\n if (!this.data.normal)\r\n this.data.normal = new GrowableXYZArray();\r\n this.data.normal.pushXYZ(x, y, z);\r\n return this.data.normal.length - 1;\r\n }\r\n /**\r\n * Add a color to the color array\r\n * @param color the color.\r\n * @returns zero-based index of the added color.\r\n */\r\n public addColor(color: number): number {\r\n if (!this.data.color)\r\n this.data.color = [];\r\n this.data.color.push(color);\r\n return this.data.color.length - 1;\r\n }\r\n /** Add a point index with edge visibility flag. */\r\n public addPointIndex(index: number, visible: boolean = true): void {\r\n this.data.pointIndex.push(index);\r\n this.data.edgeVisible.push(visible);\r\n }\r\n /** Add a normal index. */\r\n public addNormalIndex(index: number): void {\r\n if (!this.data.normalIndex)\r\n this.data.normalIndex = [];\r\n this.data.normalIndex.push(index);\r\n }\r\n /** Add a param index. */\r\n public addParamIndex(index: number): void {\r\n if (!this.data.paramIndex)\r\n this.data.paramIndex = [];\r\n this.data.paramIndex.push(index);\r\n }\r\n /** Add a color index. */\r\n public addColorIndex(index: number): void {\r\n if (!this.data.colorIndex)\r\n this.data.colorIndex = [];\r\n this.data.colorIndex.push(index);\r\n }\r\n /**\r\n * Clean up the open facet.\r\n * @deprecated in 4.x to remove nebulous \"open facet\" concept from the API. Call [[PolyfaceData.trimAllIndexArrays]]\r\n * instead.\r\n */\r\n public cleanupOpenFacet(): void {\r\n this.data.trimAllIndexArrays(this.data.pointIndex.length);\r\n }\r\n\r\n /**\r\n * Validate (the tail of) the active index arrays: point, normal, param, color.\r\n * @param index0 optional offset into the index arrays at which to start validating indices. Default 0.\r\n * @param errors optional array appended with error message(s) if invalid indices are encountered\r\n * @return whether the indices are valid\r\n */\r\n public validateAllIndices(index0: number = 0, errors?: string[]): boolean {\r\n const numPointIndices = this.data.pointIndex.length;\r\n const messages = errors ?? [];\r\n if (this.data.normalIndex && this.data.normalIndex.length !== numPointIndices)\r\n messages.push(\"normalIndex count must match pointIndex count\");\r\n if (this.data.paramIndex && this.data.paramIndex.length !== numPointIndices)\r\n messages.push(\"paramIndex count must equal pointIndex count\");\r\n if (this.data.colorIndex && this.data.colorIndex.length !== numPointIndices)\r\n messages.push(\"colorIndex count must equal pointIndex count\");\r\n if (this.data.edgeVisible.length !== numPointIndices)\r\n messages.push(\"visibleIndex count must equal pointIndex count\");\r\n if (!Polyface.areIndicesValid(this.data.pointIndex, index0, numPointIndices, this.data.point, this.data.point ? this.data.point.length : 0))\r\n messages.push(\"invalid point indices in the last facet\");\r\n if (!Polyface.areIndicesValid(this.data.normalIndex, index0, numPointIndices, this.data.normal, this.data.normal ? this.data.normal.length : 0))\r\n messages.push(\"invalid normal indices in the last facet\");\r\n if (!Polyface.areIndicesValid(this.data.paramIndex, index0, numPointIndices, this.data.param, this.data.param ? this.data.param.length : 0))\r\n messages.push(\"invalid param indices in the last facet\");\r\n if (!Polyface.areIndicesValid(this.data.colorIndex, index0, numPointIndices, this.data.color, this.data.color ? this.data.color.length : 0))\r\n messages.push(\"invalid color indices in the last facet\");\r\n return 0 === messages.length;\r\n }\r\n\r\n /**\r\n * Announce the end of construction of a facet.\r\n * * Optionally check for:\r\n * * Same number of indices among all active index arrays -- point, normal, param, color\r\n * * All indices for the latest facet are within bounds of the respective data arrays.\r\n * * In error cases, all index arrays are trimmed back to the size when previous facet was terminated.\r\n * * A return value of `undefined` is normal. Otherwise, a string array of error messages is returned.\r\n */\r\n public terminateFacet(validateAllIndices: boolean = true): string[] | undefined {\r\n const numFacets = this._facetStart.length - 1;\r\n // number of indices in accepted facets\r\n const lengthA = this._facetStart[numFacets];\r\n // number of indices in all facets (accepted facet plus the last facet to be accepted)\r\n const lengthB = this.data.pointIndex.length;\r\n if (validateAllIndices) {\r\n const messages: string[] = [];\r\n if (lengthB < lengthA + 2)\r\n messages.push(\"Less than 3 indices in the last facet\");\r\n this.validateAllIndices(lengthA, messages);\r\n if (messages.length > 0) {\r\n this.data.trimAllIndexArrays(lengthA);\r\n return messages;\r\n }\r\n }\r\n this._facetStart.push(lengthB); // append start index of the future facet\r\n return undefined;\r\n }\r\n /** Number of facets (read-only property). */\r\n public override get facetCount(): number {\r\n return this._facetStart.length - 1;\r\n }\r\n /** Number of faces (read-only property). */\r\n public get faceCount(): number {\r\n return this.data.faceCount;\r\n }\r\n /** Number of points (read-only property). */\r\n public get pointCount(): number {\r\n return this.data.pointCount;\r\n }\r\n /** Number of colors (read-only property). */\r\n public get colorCount(): number {\r\n return this.data.colorCount;\r\n }\r\n /** Number of parameters (read-only property). */\r\n public get paramCount(): number {\r\n return this.data.paramCount;\r\n }\r\n /** Number of normals (read-only property). */\r\n public get normalCount(): number {\r\n return this.data.normalCount;\r\n }\r\n /** Test if `index` is a valid facet index. */\r\n public isValidFacetIndex(index: number): boolean {\r\n return index >= 0 && index < this.facetCount;\r\n }\r\n /** Return the number of edges in a particular facet. */\r\n public numEdgeInFacet(facetIndex: number): number {\r\n if (this.isValidFacetIndex(facetIndex))\r\n return this._facetStart[facetIndex + 1] - this._facetStart[facetIndex];\r\n return 0;\r\n }\r\n /** ASSUME valid facet index. Return start index of facet in pointIndex arrays. */\r\n public facetIndex0(index: number): number {\r\n return this._facetStart[index];\r\n }\r\n /** ASSUME valid facet index. Return one past end index of facet in pointIndex arrays. */\r\n public facetIndex1(index: number): number {\r\n return this._facetStart[index + 1];\r\n }\r\n /** Create a visitor for this polyface */\r\n public createVisitor(numWrap: number = 0): IndexedPolyfaceVisitor {\r\n return IndexedPolyfaceVisitor.create(this, numWrap);\r\n }\r\n /** Return the range of (optionally transformed) points in this mesh. */\r\n public override range(transform?: Transform, result?: Range3d): Range3d {\r\n return this.data.range(result, transform);\r\n }\r\n /** Extend `range` with coordinates from this mesh. */\r\n public extendRange(range: Range3d, transform?: Transform): void {\r\n this.data.range(range, transform);\r\n }\r\n /**\r\n * Given the index of a facet, return the data pertaining to the face it is a part of.\r\n * @deprecated in 4.x. Use [[IndexedPolyface.tryGetFaceData]], which verifies the index is in range.\r\n */\r\n public getFaceDataByFacetIndex(facetIndex: number): FacetFaceData {\r\n return this.data.face[this._facetToFaceData[facetIndex]];\r\n }\r\n /**\r\n * Set new FacetFaceData.\r\n * * All terminated facets since the last face declaration will be mapped to a single new FacetFaceData object using\r\n * facetToFaceData[]. FacetFaceData holds the 2D range of the face. Returns `true` if successful, `false` otherwise.\r\n */\r\n public setNewFaceData(endFacetIndex: number = 0): boolean {\r\n const facetStart = this._facetToFaceData.length;\r\n if (facetStart >= this._facetStart.length)\r\n return false;\r\n if (0 === endFacetIndex) // the default for endFacetIndex is really the last facet\r\n endFacetIndex = this._facetStart.length; // last facet index corresponds to the future facet\r\n const faceData = FacetFaceData.createNull();\r\n const visitor = IndexedPolyfaceVisitor.create(this, 0);\r\n if (!visitor.moveToReadIndex(facetStart)) { // move visitor to first facet of new face\r\n return false;\r\n }\r\n // if parameter range is provided (by the polyface planeSet clipper) then use it\r\n const paramDefined = this.data.param !== undefined;\r\n const setParamRange: boolean = faceData.paramRange.isNull && paramDefined;\r\n do {\r\n if (setParamRange && visitor.param !== undefined)\r\n visitor.param.extendRange(faceData.paramRange);\r\n } while (visitor.moveToNextFacet() && visitor.currentReadIndex() < endFacetIndex);\r\n if (paramDefined && !(this.data.param!.length === 0) && faceData.paramDistanceRange.isNull)\r\n faceData.setParamDistanceRangeFromNewFaceData(this, facetStart, endFacetIndex);\r\n this.data.face.push(faceData);\r\n const faceDataIndex = this.data.face.length - 1;\r\n for (let i = this._facetToFaceData.length; i < endFacetIndex; i++)\r\n this._facetToFaceData.push(0 === this._facetStart[i] ? 0 : faceDataIndex);\r\n return true;\r\n }\r\n /** Second step of double dispatch: call `handler.handleIndexedPolyface(this)`. */\r\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\r\n return handler.handleIndexedPolyface(this);\r\n }\r\n}\r\n\r\n/**\r\n * A PolyfaceVisitor manages data while walking through facets.\r\n * * The polyface visitor holds data for one facet at a time.\r\n * * The caller can request the position in the addressed polyfaceData as a \"readIndex\".\r\n * * The readIndex values (as numbers) are not promised to be sequential (i.e., it might be a simple facet count\r\n * or might have \"gaps\" at the whim of the particular PolyfaceVisitor implementation).\r\n * @public\r\n */\r\nexport interface PolyfaceVisitor extends PolyfaceData {\r\n /** Load data for the facet with given index. */\r\n moveToReadIndex(index: number): boolean;\r\n /** Return the readIndex of the currently loaded facet. */\r\n currentReadIndex(): number;\r\n /** Load data for the next facet. */\r\n moveToNextFacet(): boolean;\r\n /** Reset to initial state for reading all facets sequentially with moveToNextFacet. */\r\n reset(): void;\r\n /** Return the point index of vertex i within the currently loaded facet. */\r\n clientPointIndex(i: number): number;\r\n /** Return the param index of vertex i within the currently loaded facet. */\r\n clientParamIndex(i: number): number;\r\n /** Return the normal index of vertex i within the currently loaded facet. */\r\n clientNormalIndex(i: number): number;\r\n /** Return the color index of vertex i within the currently loaded facet. */\r\n clientColorIndex(i: number): number;\r\n /** Return the aux data index of vertex i within the currently loaded facet. */\r\n clientAuxIndex(i: number): number;\r\n /** Return the client polyface. */\r\n clientPolyface(): Polyface | undefined;\r\n /**\r\n * Set the number of vertices replicated in visitor arrays (both data and index arrays).\r\n * * 0,1,2 are the most common as numWrap.\r\n * * Example: suppose `[6,7,8]` is the pointIndex array representing a triangle. First edge would be `6,7`. Second\r\n * edge is `7,8`. Third edge is `8,6`. To access `6` for the third edge, we have to go back to the start of array.\r\n * Therefore, it is useful to store `6` at the end of pointIndex array, i.e., `[6,7,8,6]` meaning `numWrap = 1`.\r\n * * Continuing this example, `numWrap = 2` (i.e., `[6,7,8,6,7]`) is useful when each vertex visit requires\r\n * the next two points, e.g., to form two adjacent vectors for a cross product.\r\n */\r\n setNumWrap(numWrap: number): void;\r\n /** Clear the contents of all arrays. Use this along with `pushDataFrom` to build up new facets. */\r\n clearArrays(): void;\r\n /** Transfer data from a specified index of the other visitor as new data in this visitor. */\r\n pushDataFrom(other: PolyfaceVisitor, index: number): void;\r\n /**\r\n * Transfer interpolated data from the other visitor.\r\n * * All data values are interpolated at `fraction` between `other` values at `index0` and `index1`.\r\n */\r\n pushInterpolatedDataFrom(other: PolyfaceVisitor, index0: number, fraction: number, index1: number): void;\r\n /**\r\n * Return the number of facets this visitor is able to visit.\r\n * * Allows implementers to improve the efficiency of e.g., [[PolyfaceQuery.visitorClientFacetCount]].\r\n */\r\n getVisitableFacetCount?(): number;\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PolyfaceBuilder.d.ts","sourceRoot":"","sources":["../../../src/polyface/PolyfaceBuilder.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAIvC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMnD,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAG1E,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAO,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAW,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,wBA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AE,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,GAAE,OAAe,GACtG,IAAI;IAYP;;;;;;;;;;;OAWG;IACI,aAAa,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,IAAI;IAqH9G;;;;;;;;;;;OAWG;WACW,4BAA4B,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,eAAe,GAAG,SAAS;IAMnH;;;;;;;;;;OAUG;IACI,wCAAwC,CAC7C,OAAO,EAAE,OAAO,EAAE,GAAG,YAAY,GAAG,oBAAoB,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,YAAY,GAAG,oBAAoB,GACjH,IAAI;IAQP,OAAO,CAAC,yBAAyB;IAwBjC;;;;;;;;;OASG;IACI,eAAe,CACpB,UAAU,EAAE,oBAAoB,GAAG,OAAO,EAAE,GAAG,cAAc,EAC7D,WAAW,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,EACnC,cAAc,GAAE,MAAW,GAC1B,IAAI;IAeP,wGAAwG;IACxG,OAAO,CAAC,cAAc;IAUtB;;;;MAIE;IACF,OAAO,CAAC,YAAY;IA0CpB;;;;;;;;OAQG;IACI,uBAAuB,CAC5B,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,GAAE,OAAe,GAChF,OAAO;CAyCX"}
@@ -1080,17 +1080,28 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
1080
1080
  }
1081
1081
  /** Construct facets for a rotational sweep. */
1082
1082
  addRotationalSweep(surface) {
1083
- const contour = surface.getCurves();
1084
- const section0 = StrokeCountChain_1.StrokeCountSection.createForParityRegionOrChain(contour, this._options);
1083
+ const contour = surface.getSweepContourRef();
1084
+ const section0 = StrokeCountChain_1.StrokeCountSection.createForParityRegionOrChain(contour.getCurves(), this._options);
1085
1085
  const baseStrokes = section0.getStrokes();
1086
+ // ensure sweep is positive for buildRotationalNormalsInLineStrings
1086
1087
  const axis = surface.cloneAxisRay();
1088
+ const sweepAngle = surface.getSweep();
1089
+ if (sweepAngle.radians < 0.0) {
1090
+ axis.direction.scaleInPlace(-1);
1091
+ sweepAngle.setRadians(-sweepAngle.radians);
1092
+ }
1093
+ // swingVector points in the direction of positive sweep
1087
1094
  const perpendicularVector = CylindricalRange_1.CylindricalRangeQuery.computeMaxVectorFromRay(axis, baseStrokes);
1088
1095
  const swingVector = axis.direction.crossProduct(perpendicularVector);
1096
+ // ensure contour computed normal is aligned with swingVector for buildRotationalNormalsInLineStrings
1097
+ const contourNormalAgreesWithSwingDir = contour.localToWorld.matrix.dotColumnZ(swingVector) > 0;
1098
+ if (!contourNormalAgreesWithSwingDir)
1099
+ baseStrokes.reverseInPlace();
1089
1100
  if (this._options.needNormals)
1090
1101
  CylindricalRange_1.CylindricalRangeQuery.buildRotationalNormalsInLineStrings(baseStrokes, axis, swingVector);
1091
1102
  const maxDistance = perpendicularVector.magnitude();
1092
- const maxPath = Math.abs(maxDistance * surface.getSweep().radians);
1093
- let numStep = StrokeOptions_1.StrokeOptions.applyAngleTol(this._options, 1, surface.getSweep().radians, undefined);
1103
+ const maxPath = Math.abs(maxDistance * sweepAngle.radians);
1104
+ let numStep = StrokeOptions_1.StrokeOptions.applyAngleTol(this._options, 1, sweepAngle.radians, undefined);
1094
1105
  numStep = StrokeOptions_1.StrokeOptions.applyMaxEdgeLength(this._options, numStep, maxPath);
1095
1106
  for (let i = 1; i <= numStep; i++) {
1096
1107
  const transformA = surface.getFractionalRotationTransform((i - 1) / numStep);
@@ -1098,11 +1109,10 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
1098
1109
  this.addBetweenRotatedStrokeSets(baseStrokes, transformA, i - 1, transformB, i);
1099
1110
  }
1100
1111
  if (surface.capped) {
1101
- const capContour = surface.getSweepContourRef();
1102
- capContour.purgeFacets();
1103
- capContour.emitFacets(this, true, undefined);
1104
- // final loop pass left transformA at end
1105
- capContour.emitFacets(this, false, surface.getFractionalRotationTransform(1.0));
1112
+ contour.purgeFacets();
1113
+ const reverseNearCap = contourNormalAgreesWithSwingDir;
1114
+ contour.emitFacets(this, reverseNearCap, undefined);
1115
+ contour.emitFacets(this, !reverseNearCap, surface.getFractionalRotationTransform(1.0));
1106
1116
  }
1107
1117
  }
1108
1118
  /** Construct facets for any planar region. */
@@ -1166,9 +1176,9 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
1166
1176
  const normalIndices = ls.ensureEmptyNormalIndices();
1167
1177
  const normalIndex0 = this.findOrAddNormalInLineString(ls, 0, transform);
1168
1178
  normalIndices.push(normalIndex0);
1169
- let normalIndexA = normalIndex0;
1170
- let normalIndexB;
1171
1179
  if (n > 1) {
1180
+ let normalIndexA = normalIndex0;
1181
+ let normalIndexB;
1172
1182
  for (let i = 1; i + 1 < n; i++) {
1173
1183
  normalIndexB = this.findOrAddNormalInLineString(ls, i, transform, normalIndexA);
1174
1184
  normalIndices.push(normalIndexB);
@@ -1183,9 +1193,9 @@ class PolyfaceBuilder extends GeometryHandler_1.NullGeometryHandler {
1183
1193
  const uvIndices = ls.ensureEmptyUVIndices();
1184
1194
  const uvIndex0 = this.findOrAddParamInLineString(ls, 0, vParam);
1185
1195
  uvIndices.push(uvIndex0);
1186
- let uvIndexA = uvIndex0;
1187
- let uvIndexB;
1188
1196
  if (n > 1) {
1197
+ let uvIndexA = uvIndex0;
1198
+ let uvIndexB;
1189
1199
  for (let i = 1; i + 1 < n; i++) {
1190
1200
  uvIndexB = this.findOrAddParamInLineString(ls, i, vParam, uvIndexA);
1191
1201
  uvIndices.push(uvIndexB);