@itwin/core-geometry 4.0.0-dev.24 → 4.0.0-dev.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -2
- package/lib/cjs/bspline/BSplineCurveOps.js +4 -5
- package/lib/cjs/bspline/BSplineCurveOps.js.map +1 -1
- package/lib/cjs/bspline/InterpolationCurve3d.js +7 -10
- package/lib/cjs/bspline/InterpolationCurve3d.js.map +1 -1
- package/lib/cjs/clipping/ClipPrimitive.js +2 -2
- package/lib/cjs/clipping/ClipPrimitive.js.map +1 -1
- package/lib/cjs/clipping/ClipUtils.js +4 -4
- package/lib/cjs/clipping/ClipUtils.js.map +1 -1
- package/lib/cjs/clipping/internalContexts/LineStringOffsetClipperContext.js +2 -2
- package/lib/cjs/clipping/internalContexts/LineStringOffsetClipperContext.js.map +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/cjs/curve/CurveCollection.js +1 -1
- package/lib/cjs/curve/CurveCollection.js.map +1 -1
- package/lib/cjs/curve/Loop.d.ts +2 -2
- package/lib/cjs/curve/Loop.d.ts.map +1 -1
- package/lib/cjs/curve/Loop.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +2 -1
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +3 -2
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +2 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js +3 -2
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/cjs/curve/StrokeOptions.js +1 -2
- package/lib/cjs/curve/StrokeOptions.js.map +1 -1
- package/lib/cjs/curve/spiral/DirectSpiral3d.js +1 -2
- package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
- package/lib/cjs/curve/spiral/IntegratedSpiral3d.js +1 -2
- package/lib/cjs/curve/spiral/IntegratedSpiral3d.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableFloat64Array.js +2 -2
- package/lib/cjs/geometry3d/GrowableFloat64Array.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.js +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.js +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.js +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/cjs/geometry3d/Point2dVector2d.js +4 -6
- package/lib/cjs/geometry3d/Point2dVector2d.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +37 -39
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +41 -45
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.js +1 -1
- package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
- package/lib/cjs/geometry3d/Ray3d.js +1 -1
- package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
- package/lib/cjs/polyface/AuxData.js +1 -1
- package/lib/cjs/polyface/AuxData.js.map +1 -1
- package/lib/cjs/polyface/FacetLocationDetail.js +5 -7
- package/lib/cjs/polyface/FacetLocationDetail.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceClip.js +6 -7
- package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js +11 -11
- package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/cjs/serialization/BGFBReader.js +4 -4
- package/lib/cjs/serialization/BGFBReader.js.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.js +1 -2
- package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/cjs/solid/SweepContour.js +1 -1
- package/lib/cjs/solid/SweepContour.js.map +1 -1
- package/lib/cjs/topology/Triangulation.js +1 -1
- package/lib/cjs/topology/Triangulation.js.map +1 -1
- package/lib/esm/bspline/BSplineCurveOps.js +4 -5
- package/lib/esm/bspline/BSplineCurveOps.js.map +1 -1
- package/lib/esm/bspline/InterpolationCurve3d.js +7 -10
- package/lib/esm/bspline/InterpolationCurve3d.js.map +1 -1
- package/lib/esm/clipping/ClipPrimitive.js +2 -2
- package/lib/esm/clipping/ClipPrimitive.js.map +1 -1
- package/lib/esm/clipping/ClipUtils.js +4 -4
- package/lib/esm/clipping/ClipUtils.js.map +1 -1
- package/lib/esm/clipping/internalContexts/LineStringOffsetClipperContext.js +2 -2
- package/lib/esm/clipping/internalContexts/LineStringOffsetClipperContext.js.map +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.js +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/esm/curve/CurveCollection.js +1 -1
- package/lib/esm/curve/CurveCollection.js.map +1 -1
- package/lib/esm/curve/Loop.d.ts +2 -2
- package/lib/esm/curve/Loop.d.ts.map +1 -1
- package/lib/esm/curve/Loop.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +2 -1
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +3 -2
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +2 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.js +3 -2
- package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/esm/curve/StrokeOptions.js +1 -2
- package/lib/esm/curve/StrokeOptions.js.map +1 -1
- package/lib/esm/curve/spiral/DirectSpiral3d.js +1 -2
- package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
- package/lib/esm/curve/spiral/IntegratedSpiral3d.js +1 -2
- package/lib/esm/curve/spiral/IntegratedSpiral3d.js.map +1 -1
- package/lib/esm/geometry3d/GrowableFloat64Array.js +2 -2
- package/lib/esm/geometry3d/GrowableFloat64Array.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.js +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.js +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.js +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/esm/geometry3d/Point2dVector2d.js +4 -6
- package/lib/esm/geometry3d/Point2dVector2d.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +37 -39
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +41 -45
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.js +1 -1
- package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
- package/lib/esm/geometry3d/Ray3d.js +1 -1
- package/lib/esm/geometry3d/Ray3d.js.map +1 -1
- package/lib/esm/polyface/AuxData.js +1 -1
- package/lib/esm/polyface/AuxData.js.map +1 -1
- package/lib/esm/polyface/FacetLocationDetail.js +5 -7
- package/lib/esm/polyface/FacetLocationDetail.js.map +1 -1
- package/lib/esm/polyface/PolyfaceClip.js +6 -7
- package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js +11 -11
- package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/esm/serialization/BGFBReader.js +4 -4
- package/lib/esm/serialization/BGFBReader.js.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.js +1 -2
- package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/esm/solid/SweepContour.js +1 -1
- package/lib/esm/solid/SweepContour.js.map +1 -1
- package/lib/esm/topology/Triangulation.js +1 -1
- package/lib/esm/topology/Triangulation.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ray3d.js","sourceRoot":"","sources":["../../../src/geometry3d/Ray3d.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AACH,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACpH,OAAO,EAAE,SAAS,EAAmB,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAW,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC;;;;;GAKG;AACH,MAAM,OAAO,KAAK;IAOhB,sCAAsC;IACtC,YAAoB,MAAe,EAAE,SAAmB;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;IACrB,CAAC;IACO,MAAM,CAAC,OAAO,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;QACrF,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EA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,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;SACnE;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\nimport { CurveCurveApproachType, CurveLocationDetail, CurveLocationDetailPair } from \"../curve/CurveLocationDetail\";\r\nimport { AxisOrder, BeJSONFunctions, Geometry } from \"../Geometry\";\r\nimport { SmallSystem } from \"../numerics/Polynomials\";\r\nimport { Matrix3d } from \"./Matrix3d\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"./Plane3dByOriginAndUnitNormal\";\r\nimport { Vector2d } from \"./Point2dVector2d\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { Range1d, Range3d } from \"./Range\";\r\nimport { Transform } from \"./Transform\";\r\nimport { XYAndZ } from \"./XYZProps\";\r\n\r\n/** A Ray3d contains\r\n * * an origin point.\r\n * * a direction vector. The vector is NOT required to be normalized.\r\n * * an optional weight (number).\r\n * @public\r\n */\r\nexport class Ray3d implements BeJSONFunctions {\r\n /** The ray origin */\r\n public origin: Point3d;\r\n /** The ray direction. This is commonly (but not always) a unit vector. */\r\n public direction: Vector3d;\r\n /** Numeric annotation. */\r\n public a?: number; // optional, e.g. weight.\r\n // constructor captures references !!!\r\n private constructor(origin: Point3d, direction: Vector3d) {\r\n this.origin = origin;\r\n this.direction = direction;\r\n this.a = undefined;\r\n }\r\n private static _create(x: number, y: number, z: number, u: number, v: number, w: number) {\r\n return new Ray3d(Point3d.create(x, y, z), Vector3d.create(u, v, w));\r\n }\r\n /** Create a ray on the x axis. */\r\n public static createXAxis(): Ray3d { return Ray3d._create(0, 0, 0, 1, 0, 0); }\r\n /** Create a ray on the y axis. */\r\n public static createYAxis(): Ray3d { return Ray3d._create(0, 0, 0, 0, 1, 0); }\r\n /** Create a ray on the z axis. */\r\n public static createZAxis(): Ray3d { return Ray3d._create(0, 0, 0, 0, 0, 1); }\r\n /** Create a ray with all zeros. */\r\n public static createZero(result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setZero();\r\n result.direction.setZero();\r\n return result;\r\n }\r\n return new Ray3d(Point3d.createZero(), Vector3d.createZero());\r\n }\r\n /** Test for nearly equal rays. */\r\n public isAlmostEqual(other: Ray3d): boolean {\r\n return this.origin.isAlmostEqual(other.origin) && this.direction.isAlmostEqual(other.direction);\r\n }\r\n /** Create a ray from origin and direction. */\r\n public static create(origin: Point3d, direction: Vector3d, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.set(origin, direction);\r\n return result;\r\n }\r\n return new Ray3d(origin.clone(), direction.clone());\r\n }\r\n /**\r\n * Given a homogeneous point and its derivative components, construct a Ray3d with cartesian coordinates and derivatives.\r\n * @param weightedPoint `[x,y,z,w]` parts of weighted point.\r\n * @param weightedDerivative `[x,y,z,w]` derivatives\r\n * @param result\r\n */\r\n public static createWeightedDerivative(weightedPoint: Float64Array, weightedDerivative: Float64Array, result?: Ray3d): Ray3d | undefined {\r\n const w = weightedPoint[3];\r\n const dw = weightedDerivative[3];\r\n const x = weightedPoint[0];\r\n const y = weightedPoint[1];\r\n const z = weightedPoint[2];\r\n const dx = weightedDerivative[0] * w - weightedPoint[0] * dw;\r\n const dy = weightedDerivative[1] * w - weightedPoint[1] * dw;\r\n const dz = weightedDerivative[2] * w - weightedPoint[2] * dw;\r\n if (Geometry.isSmallMetricDistance(w))\r\n return undefined;\r\n const divW = 1.0 / w;\r\n const divWW = divW * divW;\r\n return Ray3d.createXYZUVW(x * divW, y * divW, z * divW, dx * divWW, dy * divWW, dz * divWW, result);\r\n }\r\n /** Create from coordinates of the origin and direction. */\r\n public static createXYZUVW(originX: number, originY: number, originZ: number, directionX: number, directionY: number, directionZ: number, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.getOriginRef().set(originX, originY, originZ);\r\n result.getDirectionRef().set(directionX, directionY, directionZ);\r\n return result;\r\n }\r\n return new Ray3d(Point3d.create(originX, originY, originZ), Vector3d.create(directionX, directionY, directionZ));\r\n }\r\n /** Capture origin and direction in a new Ray3d. */\r\n public static createCapture(origin: Point3d, direction: Vector3d): Ray3d {\r\n return new Ray3d(origin, direction);\r\n }\r\n /** Create from (clones of) origin, direction, and numeric weight. */\r\n public static createPointVectorNumber(origin: Point3d, direction: Vector3d, a: number, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setFrom(origin);\r\n result.direction.setFrom(direction);\r\n result.a = a;\r\n return result;\r\n }\r\n result = new Ray3d(origin.clone(), direction.clone());\r\n result.a = a;\r\n return result;\r\n }\r\n /** Create from origin and target. The direction vector is the full length (non-unit) vector from origin to target. */\r\n public static createStartEnd(origin: Point3d, target: Point3d, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setFrom(origin);\r\n result.direction.setStartEnd(origin, target);\r\n return result;\r\n }\r\n return new Ray3d(origin.clone(), Vector3d.createStartEnd(origin, target));\r\n }\r\n /** Return a reference to the ray's origin. */\r\n public getOriginRef(): Point3d { return this.origin; }\r\n /** Return a reference to the ray's direction vector. */\r\n public getDirectionRef(): Vector3d { return this.direction; }\r\n /** copy coordinates from origin and direction. */\r\n public set(origin: Point3d, direction: Vector3d): void {\r\n this.origin.setFrom(origin);\r\n this.direction.setFrom(direction);\r\n }\r\n /** Clone the ray. */\r\n public clone(result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.set(this.origin.clone(), this.direction.clone());\r\n return result;\r\n }\r\n return new Ray3d(this.origin.clone(), this.direction.clone());\r\n }\r\n /** Create a clone and return the transform of the clone. */\r\n public cloneTransformed(transform: Transform): Ray3d {\r\n return new Ray3d(transform.multiplyPoint3d(this.origin), transform.multiplyVector(this.direction));\r\n }\r\n\r\n /** Create a clone and return the inverse transform of the clone. */\r\n public cloneInverseTransformed(transform: Transform): Ray3d | undefined {\r\n const origin = transform.multiplyInversePoint3d(this.origin);\r\n const direction = transform.matrix.multiplyInverseXYZAsVector3d(this.direction.x, this.direction.y, this.direction.z);\r\n if (undefined !== origin && undefined !== direction)\r\n return new Ray3d(origin, direction);\r\n return undefined;\r\n }\r\n\r\n /** Apply a transform in place. */\r\n public transformInPlace(transform: Transform) {\r\n transform.multiplyPoint3d(this.origin, this.origin);\r\n transform.multiplyVector(this.direction, this.direction);\r\n }\r\n /** Copy data from another ray. */\r\n public setFrom(source: Ray3d): void { this.set(source.origin, source.direction); }\r\n /** * fraction 0 is the ray origin.\r\n * * fraction 1 is at the end of the direction vector when placed at the origin.\r\n * @returns Return a point at fractional position along the ray.\r\n */\r\n public fractionToPoint(fraction: number, result?: Point3d): Point3d { return this.origin.plusScaled(this.direction, fraction, result); }\r\n /** Return the dot product of the ray's direction vector with a vector from the ray origin to the space point. */\r\n public dotProductToPoint(spacePoint: Point3d): number { return this.direction.dotProductStartEnd(this.origin, spacePoint); }\r\n /**\r\n * Return the fractional coordinate (along the direction vector) of the spacePoint projected to the ray.\r\n */\r\n public pointToFraction(spacePoint: Point3d): number {\r\n return Geometry.safeDivideFraction(this.direction.dotProductStartEnd(this.origin, spacePoint), this.direction.magnitudeSquared(), 0);\r\n }\r\n /**\r\n *\r\n * Return the spacePoint projected onto the ray.\r\n */\r\n public projectPointToRay(spacePoint: Point3d): Point3d {\r\n return this.origin.plusScaled(this.direction, this.pointToFraction(spacePoint));\r\n }\r\n /** Return a transform for rigid axes\r\n * at ray origin with z in ray direction. If the direction vector is zero, axes default to identity (from createHeadsUpTriad)\r\n */\r\n public toRigidZFrame(): Transform | undefined {\r\n const axes = Matrix3d.createRigidHeadsUp(this.direction, AxisOrder.ZXY);\r\n return Transform.createOriginAndMatrix(this.origin, axes);\r\n }\r\n /**\r\n * Convert {origin:[x,y,z], direction:[u,v,w]} to a Ray3d.\r\n */\r\n public setFromJSON(json?: any) {\r\n if (!json) {\r\n this.origin.set(0, 0, 0);\r\n this.direction.set(0, 0, 1);\r\n return;\r\n }\r\n this.origin.setFromJSON(json.origin);\r\n this.direction.setFromJSON(json.direction);\r\n }\r\n /**\r\n * try to scale the direction vector to a given magnitude.\r\n * @returns Returns false if ray direction is a zero vector.\r\n */\r\n public trySetDirectionMagnitudeInPlace(magnitude: number = 1.0): boolean {\r\n if (this.direction.tryNormalizeInPlace()) {\r\n this.direction.scaleInPlace(magnitude);\r\n return true;\r\n }\r\n this.direction.setZero();\r\n this.a = 0.0;\r\n return false;\r\n }\r\n /**\r\n * * If parameter `a` is clearly nonzero and the direction vector can be normalized,\r\n * * save the parameter `a` as the optional `a` member of the ray.\r\n * * normalize the ray's direction vector\r\n * * If parameter `a` is nearly zero,\r\n * * Set the `a` member to zero\r\n * * Set the ray's direction vector to zero.\r\n * @param a area to be saved.\r\n */\r\n // input a ray and \"a\" understood as an area.\r\n // if a is clearly nonzero metric squared and the vector can be normalized, install those and return true.\r\n // otherwise set ray.z to zero and zero the vector of the ray and return false.\r\n public tryNormalizeInPlaceWithAreaWeight(a: number): boolean {\r\n const tolerance = Geometry.smallMetricDistanceSquared;\r\n this.a = a;\r\n if (Math.abs(a) > tolerance && this.direction.tryNormalizeInPlace(tolerance))\r\n return true;\r\n this.direction.setZero();\r\n this.a = 0.0;\r\n return false;\r\n }\r\n /**\r\n * Convert an Angle to a JSON object.\r\n * @return {*} [origin,normal]\r\n */\r\n public toJSON(): any { return { origin: this.origin.toJSON(), direction: this.direction.toJSON() }; }\r\n /** Create a new ray from json object. See `setFromJSON` for json structure; */\r\n public static fromJSON(json?: any) {\r\n const result = Ray3d.createXAxis();\r\n result.setFromJSON(json);\r\n return result;\r\n }\r\n /** return distance from the ray to point in space */\r\n public distance(spacePoint: Point3d): number {\r\n const uu = this.direction.magnitudeSquared();\r\n const uv = this.dotProductToPoint(spacePoint);\r\n const aa = Geometry.inverseMetricDistanceSquared(uu);\r\n if (aa)\r\n return Math.sqrt(this.origin.distanceSquared(spacePoint) - uv * uv * aa);\r\n else\r\n return Math.sqrt(this.origin.distanceSquared(spacePoint));\r\n }\r\n /**\r\n * Return the intersection of the unbounded ray with a plane.\r\n * Stores the point of intersection in the result point given as a parameter,\r\n * and returns the parameter along the ray where the intersection occurs.\r\n * Returns undefined if the ray and plane are parallel or coplanar.\r\n */\r\n public intersectionWithPlane(plane: Plane3dByOriginAndUnitNormal, result?: Point3d): number | undefined {\r\n const vectorA = Vector3d.createStartEnd(plane.getOriginRef(), this.origin);\r\n const uDotN = this.direction.dotProduct(plane.getNormalRef());\r\n const nDotN = this.direction.magnitudeSquared();\r\n const aDotN = vectorA.dotProduct(plane.getNormalRef());\r\n const division = Geometry.conditionalDivideFraction(-aDotN, uDotN);\r\n if (undefined === division)\r\n return undefined;\r\n const division1 = Geometry.conditionalDivideFraction(nDotN, uDotN);\r\n if (undefined === division1)\r\n return undefined;\r\n if (result) {\r\n this.origin.plusScaled(this.direction, division, result);\r\n }\r\n return division;\r\n }\r\n\r\n /**\r\n * * Find intersection of the ray with a Range3d.\r\n * * return the range of fractions (on the ray) which are \"inside\" the range.\r\n * * Note that a range is always returned; if there is no intersection it is indicated by the test `result.sNull`\r\n */\r\n public intersectionWithRange3d(range: Range3d, result?: Range1d): Range1d {\r\n if (range.isNull)\r\n return Range1d.createNull(result);\r\n const interval = Range1d.createXX(-Geometry.largeCoordinateResult, Geometry.largeCoordinateResult, result);\r\n if (interval.clipLinearMapToInterval(this.origin.x, this.direction.x, range.low.x, range.high.x)\r\n && interval.clipLinearMapToInterval(this.origin.y, this.direction.y, range.low.y, range.high.y)\r\n && interval.clipLinearMapToInterval(this.origin.z, this.direction.z, range.low.z, range.high.z))\r\n return interval;\r\n return interval;\r\n }\r\n\r\n /** Construct a vector from `ray.origin` to target point.\r\n * * return the part of the vector that is perpendicular to `ray.direction`.\r\n * * i.e. return the shortest vector from the ray to the point.\r\n */\r\n public perpendicularPartOfVectorToTarget(targetPoint: XYAndZ, result?: Vector3d): Vector3d {\r\n const vectorV = Vector3d.createStartEnd(this.origin, targetPoint);\r\n const uu = this.direction.magnitudeSquared();\r\n const uv = this.direction.dotProductStartEnd(this.origin, targetPoint);\r\n const fraction = Geometry.safeDivideFraction(uv, uu, 0.0);\r\n return vectorV.plusScaled(this.direction, -fraction, result);\r\n }\r\n /** Determine if two rays intersect, are fully overlapped, parallel but no coincident, or skew\r\n * * Return a CurveLocationDetailPair which\r\n * * contains fraction and point on each ray.\r\n * * has (in the CurveLocationDetailPair structure, as member approachType) annotation indicating one of these relationships\r\n * * CurveCurveApproachType.Intersection -- the rays have a simple intersection, at fractions indicated in detailA and detailB\r\n * * CurveCurveApproachType.PerpendicularChord -- there is pair of where the rays have closest approach. The rays are skew in space.\r\n * * CurveCurveApproachType.CoincidentGeometry -- the rays are the same unbounded line in space. The fractions and points are a representative single common point.\r\n * * CurveCurveApproachType.Parallel -- the rays are parallel (and not coincident). The two points are at the minimum distance\r\n */\r\n public static closestApproachRay3dRay3d(rayA: Ray3d, rayB: Ray3d): CurveLocationDetailPair {\r\n const intersectionFractions = Vector2d.create();\r\n let fractionA, fractionB;\r\n let pointA, pointB;\r\n let pairType;\r\n if (SmallSystem.ray3dXYZUVWClosestApproachUnbounded(\r\n rayA.origin.x, rayA.origin.y, rayA.origin.z, rayA.direction.x, rayA.direction.y, rayA.direction.z,\r\n rayB.origin.x, rayB.origin.y, rayB.origin.z, rayB.direction.x, rayB.direction.y, rayB.direction.z, intersectionFractions)) {\r\n fractionA = intersectionFractions.x;\r\n fractionB = intersectionFractions.y;\r\n pointA = rayA.fractionToPoint(fractionA);\r\n pointB = rayB.fractionToPoint(fractionB);\r\n pairType = pointA.isAlmostEqualMetric(pointB) ? CurveCurveApproachType.Intersection : CurveCurveApproachType.PerpendicularChord;\r\n } else {\r\n fractionB = 0.0;\r\n fractionA = rayA.pointToFraction(rayB.origin);\r\n pointA = rayA.fractionToPoint(fractionA);\r\n pointB = rayB.fractionToPoint(fractionB);\r\n pairType = pointA.isAlmostEqualMetric(pointB) ? CurveCurveApproachType.CoincidentGeometry : CurveCurveApproachType.ParallelGeometry;\r\n }\r\n const pair = CurveLocationDetailPair.createCapture(\r\n CurveLocationDetail.createRayFractionPoint(rayA, fractionA, rayA.fractionToPoint(fractionA)),\r\n CurveLocationDetail.createRayFractionPoint(rayB, fractionB, rayB.fractionToPoint(fractionB)));\r\n pair.approachType = pairType;\r\n return pair;\r\n }\r\n\r\n /**\r\n * Return a ray with `ray.origin` interpolated between pt1 and pt2 at the given fraction\r\n * and `ray.direction` set to the vector from pt1 to pt2 multiplied by the given scale factor.\r\n * @param pt1 start point of interpolation.\r\n * @param fraction fractional position between points.\r\n * @param pt2 endpoint of interpolation.\r\n * @param tangentScale scale factor to apply to the startToEnd vector.\r\n * @param result optional receiver.\r\n */\r\n public static interpolatePointAndTangent(pt1: XYAndZ, fraction: number, pt2: XYAndZ, tangentScale: number, result?: Ray3d): Ray3d {\r\n result = result ?? Ray3d.createZero();\r\n const dx = pt2.x - pt1.x;\r\n const dy = pt2.y - pt1.y;\r\n const dz = pt2.z - pt1.z;\r\n result.direction.set(tangentScale * dx, tangentScale * dy, tangentScale * dz);\r\n if (fraction <= 0.5)\r\n result.origin.set(pt1.x + fraction * dx, pt1.y + fraction * dy, pt1.z + fraction * dz);\r\n else {\r\n const t: number = fraction - 1.0;\r\n result.origin.set(pt2.x + t * dx, pt2.y + t * dy, pt2.z + t * dz);\r\n }\r\n return result;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Ray3d.js","sourceRoot":"","sources":["../../../src/geometry3d/Ray3d.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AACH,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACpH,OAAO,EAAE,SAAS,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AC,0BAA0B,CAAC,GAAW,EAAE,QAAgB,EAAE,GAAW,EAAE,YAAoB,EAAE,MAAc;QACvH,MAAM,GAAG,MAAM,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACtC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACzB,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACzB,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,GAAG,EAAE,EAAE,YAAY,GAAG,EAAE,EAAE,YAAY,GAAG,EAAE,CAAC,CAAC;QAC9E,IAAI,QAAQ,IAAI,GAAG;YACjB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,QAAQ,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,QAAQ,GAAG,EAAE,CAAC,CAAC;aACpF;YACH,MAAM,CAAC,GAAW,QAAQ,GAAG,GAAG,CAAC;YACjC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;SACnE;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\nimport { CurveCurveApproachType, CurveLocationDetail, CurveLocationDetailPair } from \"../curve/CurveLocationDetail\";\r\nimport { AxisOrder, BeJSONFunctions, Geometry } from \"../Geometry\";\r\nimport { SmallSystem } from \"../numerics/Polynomials\";\r\nimport { Matrix3d } from \"./Matrix3d\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"./Plane3dByOriginAndUnitNormal\";\r\nimport { Vector2d } from \"./Point2dVector2d\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { Range1d, Range3d } from \"./Range\";\r\nimport { Transform } from \"./Transform\";\r\nimport { XYAndZ } from \"./XYZProps\";\r\n\r\n/** A Ray3d contains\r\n * * an origin point.\r\n * * a direction vector. The vector is NOT required to be normalized.\r\n * * an optional weight (number).\r\n * @public\r\n */\r\nexport class Ray3d implements BeJSONFunctions {\r\n /** The ray origin */\r\n public origin: Point3d;\r\n /** The ray direction. This is commonly (but not always) a unit vector. */\r\n public direction: Vector3d;\r\n /** Numeric annotation. */\r\n public a?: number; // optional, e.g. weight.\r\n // constructor captures references !!!\r\n private constructor(origin: Point3d, direction: Vector3d) {\r\n this.origin = origin;\r\n this.direction = direction;\r\n this.a = undefined;\r\n }\r\n private static _create(x: number, y: number, z: number, u: number, v: number, w: number) {\r\n return new Ray3d(Point3d.create(x, y, z), Vector3d.create(u, v, w));\r\n }\r\n /** Create a ray on the x axis. */\r\n public static createXAxis(): Ray3d { return Ray3d._create(0, 0, 0, 1, 0, 0); }\r\n /** Create a ray on the y axis. */\r\n public static createYAxis(): Ray3d { return Ray3d._create(0, 0, 0, 0, 1, 0); }\r\n /** Create a ray on the z axis. */\r\n public static createZAxis(): Ray3d { return Ray3d._create(0, 0, 0, 0, 0, 1); }\r\n /** Create a ray with all zeros. */\r\n public static createZero(result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setZero();\r\n result.direction.setZero();\r\n return result;\r\n }\r\n return new Ray3d(Point3d.createZero(), Vector3d.createZero());\r\n }\r\n /** Test for nearly equal rays. */\r\n public isAlmostEqual(other: Ray3d): boolean {\r\n return this.origin.isAlmostEqual(other.origin) && this.direction.isAlmostEqual(other.direction);\r\n }\r\n /** Create a ray from origin and direction. */\r\n public static create(origin: Point3d, direction: Vector3d, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.set(origin, direction);\r\n return result;\r\n }\r\n return new Ray3d(origin.clone(), direction.clone());\r\n }\r\n /**\r\n * Given a homogeneous point and its derivative components, construct a Ray3d with cartesian coordinates and derivatives.\r\n * @param weightedPoint `[x,y,z,w]` parts of weighted point.\r\n * @param weightedDerivative `[x,y,z,w]` derivatives\r\n * @param result\r\n */\r\n public static createWeightedDerivative(weightedPoint: Float64Array, weightedDerivative: Float64Array, result?: Ray3d): Ray3d | undefined {\r\n const w = weightedPoint[3];\r\n const dw = weightedDerivative[3];\r\n const x = weightedPoint[0];\r\n const y = weightedPoint[1];\r\n const z = weightedPoint[2];\r\n const dx = weightedDerivative[0] * w - weightedPoint[0] * dw;\r\n const dy = weightedDerivative[1] * w - weightedPoint[1] * dw;\r\n const dz = weightedDerivative[2] * w - weightedPoint[2] * dw;\r\n if (Geometry.isSmallMetricDistance(w))\r\n return undefined;\r\n const divW = 1.0 / w;\r\n const divWW = divW * divW;\r\n return Ray3d.createXYZUVW(x * divW, y * divW, z * divW, dx * divWW, dy * divWW, dz * divWW, result);\r\n }\r\n /** Create from coordinates of the origin and direction. */\r\n public static createXYZUVW(originX: number, originY: number, originZ: number, directionX: number, directionY: number, directionZ: number, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.getOriginRef().set(originX, originY, originZ);\r\n result.getDirectionRef().set(directionX, directionY, directionZ);\r\n return result;\r\n }\r\n return new Ray3d(Point3d.create(originX, originY, originZ), Vector3d.create(directionX, directionY, directionZ));\r\n }\r\n /** Capture origin and direction in a new Ray3d. */\r\n public static createCapture(origin: Point3d, direction: Vector3d): Ray3d {\r\n return new Ray3d(origin, direction);\r\n }\r\n /** Create from (clones of) origin, direction, and numeric weight. */\r\n public static createPointVectorNumber(origin: Point3d, direction: Vector3d, a: number, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setFrom(origin);\r\n result.direction.setFrom(direction);\r\n result.a = a;\r\n return result;\r\n }\r\n result = new Ray3d(origin.clone(), direction.clone());\r\n result.a = a;\r\n return result;\r\n }\r\n /** Create from origin and target. The direction vector is the full length (non-unit) vector from origin to target. */\r\n public static createStartEnd(origin: Point3d, target: Point3d, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setFrom(origin);\r\n result.direction.setStartEnd(origin, target);\r\n return result;\r\n }\r\n return new Ray3d(origin.clone(), Vector3d.createStartEnd(origin, target));\r\n }\r\n /** Return a reference to the ray's origin. */\r\n public getOriginRef(): Point3d { return this.origin; }\r\n /** Return a reference to the ray's direction vector. */\r\n public getDirectionRef(): Vector3d { return this.direction; }\r\n /** copy coordinates from origin and direction. */\r\n public set(origin: Point3d, direction: Vector3d): void {\r\n this.origin.setFrom(origin);\r\n this.direction.setFrom(direction);\r\n }\r\n /** Clone the ray. */\r\n public clone(result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.set(this.origin.clone(), this.direction.clone());\r\n return result;\r\n }\r\n return new Ray3d(this.origin.clone(), this.direction.clone());\r\n }\r\n /** Create a clone and return the transform of the clone. */\r\n public cloneTransformed(transform: Transform): Ray3d {\r\n return new Ray3d(transform.multiplyPoint3d(this.origin), transform.multiplyVector(this.direction));\r\n }\r\n\r\n /** Create a clone and return the inverse transform of the clone. */\r\n public cloneInverseTransformed(transform: Transform): Ray3d | undefined {\r\n const origin = transform.multiplyInversePoint3d(this.origin);\r\n const direction = transform.matrix.multiplyInverseXYZAsVector3d(this.direction.x, this.direction.y, this.direction.z);\r\n if (undefined !== origin && undefined !== direction)\r\n return new Ray3d(origin, direction);\r\n return undefined;\r\n }\r\n\r\n /** Apply a transform in place. */\r\n public transformInPlace(transform: Transform) {\r\n transform.multiplyPoint3d(this.origin, this.origin);\r\n transform.multiplyVector(this.direction, this.direction);\r\n }\r\n /** Copy data from another ray. */\r\n public setFrom(source: Ray3d): void { this.set(source.origin, source.direction); }\r\n /** * fraction 0 is the ray origin.\r\n * * fraction 1 is at the end of the direction vector when placed at the origin.\r\n * @returns Return a point at fractional position along the ray.\r\n */\r\n public fractionToPoint(fraction: number, result?: Point3d): Point3d { return this.origin.plusScaled(this.direction, fraction, result); }\r\n /** Return the dot product of the ray's direction vector with a vector from the ray origin to the space point. */\r\n public dotProductToPoint(spacePoint: Point3d): number { return this.direction.dotProductStartEnd(this.origin, spacePoint); }\r\n /**\r\n * Return the fractional coordinate (along the direction vector) of the spacePoint projected to the ray.\r\n */\r\n public pointToFraction(spacePoint: Point3d): number {\r\n return Geometry.safeDivideFraction(this.direction.dotProductStartEnd(this.origin, spacePoint), this.direction.magnitudeSquared(), 0);\r\n }\r\n /**\r\n *\r\n * Return the spacePoint projected onto the ray.\r\n */\r\n public projectPointToRay(spacePoint: Point3d): Point3d {\r\n return this.origin.plusScaled(this.direction, this.pointToFraction(spacePoint));\r\n }\r\n /** Return a transform for rigid axes\r\n * at ray origin with z in ray direction. If the direction vector is zero, axes default to identity (from createHeadsUpTriad)\r\n */\r\n public toRigidZFrame(): Transform | undefined {\r\n const axes = Matrix3d.createRigidHeadsUp(this.direction, AxisOrder.ZXY);\r\n return Transform.createOriginAndMatrix(this.origin, axes);\r\n }\r\n /**\r\n * Convert {origin:[x,y,z], direction:[u,v,w]} to a Ray3d.\r\n */\r\n public setFromJSON(json?: any) {\r\n if (!json) {\r\n this.origin.set(0, 0, 0);\r\n this.direction.set(0, 0, 1);\r\n return;\r\n }\r\n this.origin.setFromJSON(json.origin);\r\n this.direction.setFromJSON(json.direction);\r\n }\r\n /**\r\n * try to scale the direction vector to a given magnitude.\r\n * @returns Returns false if ray direction is a zero vector.\r\n */\r\n public trySetDirectionMagnitudeInPlace(magnitude: number = 1.0): boolean {\r\n if (this.direction.tryNormalizeInPlace()) {\r\n this.direction.scaleInPlace(magnitude);\r\n return true;\r\n }\r\n this.direction.setZero();\r\n this.a = 0.0;\r\n return false;\r\n }\r\n /**\r\n * * If parameter `a` is clearly nonzero and the direction vector can be normalized,\r\n * * save the parameter `a` as the optional `a` member of the ray.\r\n * * normalize the ray's direction vector\r\n * * If parameter `a` is nearly zero,\r\n * * Set the `a` member to zero\r\n * * Set the ray's direction vector to zero.\r\n * @param a area to be saved.\r\n */\r\n // input a ray and \"a\" understood as an area.\r\n // if a is clearly nonzero metric squared and the vector can be normalized, install those and return true.\r\n // otherwise set ray.z to zero and zero the vector of the ray and return false.\r\n public tryNormalizeInPlaceWithAreaWeight(a: number): boolean {\r\n const tolerance = Geometry.smallMetricDistanceSquared;\r\n this.a = a;\r\n if (Math.abs(a) > tolerance && this.direction.tryNormalizeInPlace(tolerance))\r\n return true;\r\n this.direction.setZero();\r\n this.a = 0.0;\r\n return false;\r\n }\r\n /**\r\n * Convert an Angle to a JSON object.\r\n * @return {*} [origin,normal]\r\n */\r\n public toJSON(): any { return { origin: this.origin.toJSON(), direction: this.direction.toJSON() }; }\r\n /** Create a new ray from json object. See `setFromJSON` for json structure; */\r\n public static fromJSON(json?: any) {\r\n const result = Ray3d.createXAxis();\r\n result.setFromJSON(json);\r\n return result;\r\n }\r\n /** return distance from the ray to point in space */\r\n public distance(spacePoint: Point3d): number {\r\n const uu = this.direction.magnitudeSquared();\r\n const uv = this.dotProductToPoint(spacePoint);\r\n const aa = Geometry.inverseMetricDistanceSquared(uu);\r\n if (aa)\r\n return Math.sqrt(this.origin.distanceSquared(spacePoint) - uv * uv * aa);\r\n else\r\n return Math.sqrt(this.origin.distanceSquared(spacePoint));\r\n }\r\n /**\r\n * Return the intersection of the unbounded ray with a plane.\r\n * Stores the point of intersection in the result point given as a parameter,\r\n * and returns the parameter along the ray where the intersection occurs.\r\n * Returns undefined if the ray and plane are parallel or coplanar.\r\n */\r\n public intersectionWithPlane(plane: Plane3dByOriginAndUnitNormal, result?: Point3d): number | undefined {\r\n const vectorA = Vector3d.createStartEnd(plane.getOriginRef(), this.origin);\r\n const uDotN = this.direction.dotProduct(plane.getNormalRef());\r\n const nDotN = this.direction.magnitudeSquared();\r\n const aDotN = vectorA.dotProduct(plane.getNormalRef());\r\n const division = Geometry.conditionalDivideFraction(-aDotN, uDotN);\r\n if (undefined === division)\r\n return undefined;\r\n const division1 = Geometry.conditionalDivideFraction(nDotN, uDotN);\r\n if (undefined === division1)\r\n return undefined;\r\n if (result) {\r\n this.origin.plusScaled(this.direction, division, result);\r\n }\r\n return division;\r\n }\r\n\r\n /**\r\n * * Find intersection of the ray with a Range3d.\r\n * * return the range of fractions (on the ray) which are \"inside\" the range.\r\n * * Note that a range is always returned; if there is no intersection it is indicated by the test `result.sNull`\r\n */\r\n public intersectionWithRange3d(range: Range3d, result?: Range1d): Range1d {\r\n if (range.isNull)\r\n return Range1d.createNull(result);\r\n const interval = Range1d.createXX(-Geometry.largeCoordinateResult, Geometry.largeCoordinateResult, result);\r\n if (interval.clipLinearMapToInterval(this.origin.x, this.direction.x, range.low.x, range.high.x)\r\n && interval.clipLinearMapToInterval(this.origin.y, this.direction.y, range.low.y, range.high.y)\r\n && interval.clipLinearMapToInterval(this.origin.z, this.direction.z, range.low.z, range.high.z))\r\n return interval;\r\n return interval;\r\n }\r\n\r\n /** Construct a vector from `ray.origin` to target point.\r\n * * return the part of the vector that is perpendicular to `ray.direction`.\r\n * * i.e. return the shortest vector from the ray to the point.\r\n */\r\n public perpendicularPartOfVectorToTarget(targetPoint: XYAndZ, result?: Vector3d): Vector3d {\r\n const vectorV = Vector3d.createStartEnd(this.origin, targetPoint);\r\n const uu = this.direction.magnitudeSquared();\r\n const uv = this.direction.dotProductStartEnd(this.origin, targetPoint);\r\n const fraction = Geometry.safeDivideFraction(uv, uu, 0.0);\r\n return vectorV.plusScaled(this.direction, -fraction, result);\r\n }\r\n /** Determine if two rays intersect, are fully overlapped, parallel but no coincident, or skew\r\n * * Return a CurveLocationDetailPair which\r\n * * contains fraction and point on each ray.\r\n * * has (in the CurveLocationDetailPair structure, as member approachType) annotation indicating one of these relationships\r\n * * CurveCurveApproachType.Intersection -- the rays have a simple intersection, at fractions indicated in detailA and detailB\r\n * * CurveCurveApproachType.PerpendicularChord -- there is pair of where the rays have closest approach. The rays are skew in space.\r\n * * CurveCurveApproachType.CoincidentGeometry -- the rays are the same unbounded line in space. The fractions and points are a representative single common point.\r\n * * CurveCurveApproachType.Parallel -- the rays are parallel (and not coincident). The two points are at the minimum distance\r\n */\r\n public static closestApproachRay3dRay3d(rayA: Ray3d, rayB: Ray3d): CurveLocationDetailPair {\r\n const intersectionFractions = Vector2d.create();\r\n let fractionA, fractionB;\r\n let pointA, pointB;\r\n let pairType;\r\n if (SmallSystem.ray3dXYZUVWClosestApproachUnbounded(\r\n rayA.origin.x, rayA.origin.y, rayA.origin.z, rayA.direction.x, rayA.direction.y, rayA.direction.z,\r\n rayB.origin.x, rayB.origin.y, rayB.origin.z, rayB.direction.x, rayB.direction.y, rayB.direction.z, intersectionFractions)) {\r\n fractionA = intersectionFractions.x;\r\n fractionB = intersectionFractions.y;\r\n pointA = rayA.fractionToPoint(fractionA);\r\n pointB = rayB.fractionToPoint(fractionB);\r\n pairType = pointA.isAlmostEqualMetric(pointB) ? CurveCurveApproachType.Intersection : CurveCurveApproachType.PerpendicularChord;\r\n } else {\r\n fractionB = 0.0;\r\n fractionA = rayA.pointToFraction(rayB.origin);\r\n pointA = rayA.fractionToPoint(fractionA);\r\n pointB = rayB.fractionToPoint(fractionB);\r\n pairType = pointA.isAlmostEqualMetric(pointB) ? CurveCurveApproachType.CoincidentGeometry : CurveCurveApproachType.ParallelGeometry;\r\n }\r\n const pair = CurveLocationDetailPair.createCapture(\r\n CurveLocationDetail.createRayFractionPoint(rayA, fractionA, rayA.fractionToPoint(fractionA)),\r\n CurveLocationDetail.createRayFractionPoint(rayB, fractionB, rayB.fractionToPoint(fractionB)));\r\n pair.approachType = pairType;\r\n return pair;\r\n }\r\n\r\n /**\r\n * Return a ray with `ray.origin` interpolated between pt1 and pt2 at the given fraction\r\n * and `ray.direction` set to the vector from pt1 to pt2 multiplied by the given scale factor.\r\n * @param pt1 start point of interpolation.\r\n * @param fraction fractional position between points.\r\n * @param pt2 endpoint of interpolation.\r\n * @param tangentScale scale factor to apply to the startToEnd vector.\r\n * @param result optional receiver.\r\n */\r\n public static interpolatePointAndTangent(pt1: XYAndZ, fraction: number, pt2: XYAndZ, tangentScale: number, result?: Ray3d): Ray3d {\r\n result = result ?? Ray3d.createZero();\r\n const dx = pt2.x - pt1.x;\r\n const dy = pt2.y - pt1.y;\r\n const dz = pt2.z - pt1.z;\r\n result.direction.set(tangentScale * dx, tangentScale * dy, tangentScale * dz);\r\n if (fraction <= 0.5)\r\n result.origin.set(pt1.x + fraction * dx, pt1.y + fraction * dy, pt1.z + fraction * dz);\r\n else {\r\n const t: number = fraction - 1.0;\r\n result.origin.set(pt2.x + t * dx, pt2.y + t * dy, pt2.z + t * dz);\r\n }\r\n return result;\r\n }\r\n}\r\n"]}
|
|
@@ -199,7 +199,7 @@ export class PolyfaceAuxData {
|
|
|
199
199
|
break;
|
|
200
200
|
}
|
|
201
201
|
case AuxChannelDataType.Normal: {
|
|
202
|
-
inverseRot = inverseRot
|
|
202
|
+
inverseRot = inverseRot ?? rot.inverse();
|
|
203
203
|
if (!inverseRot)
|
|
204
204
|
return false;
|
|
205
205
|
transformPoints(data.values, (point) => inverseRot.multiplyTransposeVectorInPlace(point));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuxData.js","sourceRoot":"","sources":["../../../src/polyface/AuxData.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAU/F,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,yCAAyC;AACzC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;GAGG;AACH,MAAM,CAAN,IAAY,kBAiBX;AAjBD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,+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AAC,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;KACzB;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\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\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 /** Construct a new [[AuxChannelData]] from input value and vertex values. */\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 /** Create a [[AuxChannel]] */\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 [[entriesPerValue]] is `1`. */\r\n public get isScalar(): boolean {\r\n return this.dataType === AuxChannelDataType.Distance || this.dataType === AuxChannelDataType.Scalar;\r\n }\r\n\r\n /** The number of values in `data.values` per entry - 1 for scalar and distance types, 3 for normal and vector types. */\r\n public get entriesPerValue(): number {\r\n return this.isScalar ? 1 : 3;\r\n }\r\n\r\n /** The number of entries in `data.values`. */\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/** 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: the vertex position, normal\r\n * and possibly texture parameter. `PolyfaceAuxData` provides supplemental data that is generally computed\r\n * in an analysis program or other external data source. This can be scalar data used to either override the vertex colors through, or\r\n * XYZ data used to deform the mesh by adjusting the vertex positions and/or normals.\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 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;AAU/F,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,yCAAyC;AACzC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;GAGG;AACH,MAAM,CAAN,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,KAAlB,kBAAkB,QAiB7B;AAED;;EAEE;AACF,MAAM,OAAO,cAAc;IAMzB,6EAA6E;IAC7E,YAAY,KAAa,EAAE,MAA+B;QACxD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,MAAM,YAAY,YAAY,EAAE;YAClC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;YACjB,KAAK,MAAM,CAAC,IAAI,MAAM;gBAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SAC7C;;YACC,IAAI,CAAC,MAAM,GAAG,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CAAC;wBACzC,IAAI,CAAC,UAAU;4BACX,OAAO,KAAK,CAAC;wBAEjB,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,UAAW,CAAC,8BAA8B,CAAC,KAAK,CAAC,CAAC,CAAC;wBAC3F,MAAM;qBACP;oBACD,KAAK,kBAAkB,CAAC,MAAM,CAAC,CAAC;wBAC9B,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;wBAC1E,MAAM;qBACP;iBACF;aACF;SACF;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,SAAS,eAAe,CAAC,MAAgB,EAAE,SAAmC;IAC5E,MAAM,KAAK,GAAG,IAAI,OAAO,EAAE,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACzC,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;KACzB;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\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\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 /** Construct a new [[AuxChannelData]] from input value and vertex values. */\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 /** Create a [[AuxChannel]] */\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 [[entriesPerValue]] is `1`. */\r\n public get isScalar(): boolean {\r\n return this.dataType === AuxChannelDataType.Distance || this.dataType === AuxChannelDataType.Scalar;\r\n }\r\n\r\n /** The number of values in `data.values` per entry - 1 for scalar and distance types, 3 for normal and vector types. */\r\n public get entriesPerValue(): number {\r\n return this.isScalar ? 1 : 3;\r\n }\r\n\r\n /** The number of entries in `data.values`. */\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/** 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: the vertex position, normal\r\n * and possibly texture parameter. `PolyfaceAuxData` provides supplemental data that is generally computed\r\n * in an analysis program or other external data source. This can be scalar data used to either override the vertex colors through, or\r\n * XYZ data used to deform the mesh by adjusting the vertex positions and/or normals.\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 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"]}
|
|
@@ -102,11 +102,10 @@ export class TriangularFacetLocationDetail {
|
|
|
102
102
|
* @param other detail to clone
|
|
103
103
|
*/
|
|
104
104
|
copyContentsFrom(other) {
|
|
105
|
-
var _a, _b;
|
|
106
105
|
this._facetIndex = other._facetIndex;
|
|
107
106
|
this._detail.copyContentsFrom(other._detail);
|
|
108
|
-
this._normal =
|
|
109
|
-
this._param =
|
|
107
|
+
this._normal = other._normal?.clone();
|
|
108
|
+
this._param = other._param?.clone();
|
|
110
109
|
this._color = other._color;
|
|
111
110
|
}
|
|
112
111
|
/** Get normal interpolated from facet data.
|
|
@@ -303,12 +302,11 @@ export class ConvexFacetLocationDetail extends NonConvexFacetLocationDetail {
|
|
|
303
302
|
* @param other detail to clone
|
|
304
303
|
*/
|
|
305
304
|
copyContentsFrom(other) {
|
|
306
|
-
var _a, _b, _c;
|
|
307
305
|
super.copyContentsFrom(other);
|
|
308
|
-
this._normal =
|
|
309
|
-
this._param =
|
|
306
|
+
this._normal = other._normal?.clone();
|
|
307
|
+
this._param = other._param?.clone();
|
|
310
308
|
this._color = other._color;
|
|
311
|
-
this._barycentricCoordinates =
|
|
309
|
+
this._barycentricCoordinates = other._barycentricCoordinates?.slice();
|
|
312
310
|
}
|
|
313
311
|
/** Get normal interpolated from facet data.
|
|
314
312
|
* @param facetNormals used to compute the normal cache
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FacetLocationDetail.js","sourceRoot":"","sources":["../../../src/polyface/FacetLocationDetail.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAW,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAmB,MAAM,aAAa,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAG7E,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AASzD;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAehC,gCAAgC;IAChC;QACE,IAAI,CAAC,iBA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I,CAAC,MAAM,GAAG,WAAW,CAAC,yBAAyB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;SAC5E;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IACD;;;;MAIE;IACc,yBAAyB,CAAC,aAAoC,EAAE,oBAA4B,QAAQ,CAAC,mBAAmB;QACtI,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,SAAS,KAAK,IAAI,CAAC,uBAAuB,IAAI,SAAS,KAAK,aAAa,EAAE;YACrG,IAAI,CAAC,uBAAuB,GAAG,UAAU,CAAC,4BAA4B,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;SAC9H;QACD,OAAO,IAAI,CAAC,uBAAuB,CAAC;IACtC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Polyface\r\n */\r\n\r\nimport { Point2d } from \"../geometry3d/Point2dVector2d\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { TriangleLocationDetail } from \"../geometry3d/BarycentricTriangle\";\r\nimport { Geometry, PolygonLocation } from \"../Geometry\";\r\nimport { PolyfaceVisitor } from \"./Polyface\";\r\nimport { PolygonLocationDetail, PolygonOps } from \"../geometry3d/PolygonOps\";\r\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { IndexedXYCollection } from \"../geometry3d/IndexedXYCollection\";\r\nimport { NumberArray } from \"../geometry3d/PointHelpers\";\r\n\r\n/** Callback for processing the detail for an intersected facet.\r\n * @param detail reference to the intersection data, with `detail.IsInsideOn === true`. Note that `detail` is owned by the caller; to persist, use `detail.clone`.\r\n * @param visitor at currently intersected facet\r\n * @returns true to accept this intersection and stop processing; false to continue to the next facet\r\n */\r\nexport type FacetIntersectCallback = (detail: FacetLocationDetail, visitor: PolyfaceVisitor) => boolean;\r\n\r\n/** Options for computing and processing facet intersection methods.\r\n * @see PolyfaceQuery.intersectRay3d\r\n */\r\nexport class FacetIntersectOptions {\r\n /** distance tolerance for testing coincidence with facet boundary */\r\n public distanceTolerance: number;\r\n /** fractional tolerance for snapping barycentric coordinates to a triangular facet edge */\r\n public parameterTolerance: number;\r\n /** whether to compute the normal at the intersection point */\r\n public needNormal?: boolean;\r\n /** whether to compute the uv parameter at the intersection point */\r\n public needParam?: boolean;\r\n /** whether to compute the color at the intersection point */\r\n public needColor?: boolean;\r\n /** whether to compute the barycentric coordinates of the point for a convex facet */\r\n public needBarycentricCoordinates?: boolean;\r\n /** optional callback to accept an intersected facet */\r\n public acceptIntersection?: FacetIntersectCallback;\r\n /** constructor with defaults */\r\n public constructor() {\r\n this.distanceTolerance = Geometry.smallMetricDistance;\r\n this.parameterTolerance = Geometry.smallFraction;\r\n }\r\n}\r\n/**\r\n * Carries data about a point in the plane of a facet of a mesh.\r\n * @see PolyfaceQuery.intersectRay3d\r\n * @public\r\n */\r\nexport interface FacetLocationDetail {\r\n /** Get the index of the referenced facet. */\r\n get facetIndex(): number;\r\n /** Get the number of edges of this facet. */\r\n get edgeCount(): number;\r\n /** Get the world coordinates of the point. */\r\n get point(): Point3d;\r\n /** Get the application-specific number. */\r\n get a(): number;\r\n /** Get the projection of the point onto the closest facet edge. */\r\n get closestEdge(): { startVertexIndex: number, edgeParam: number };\r\n /** Whether this instance specifies a valid location. */\r\n get isValid(): boolean;\r\n /** Whether the facet is convex. */\r\n get isConvex(): boolean;\r\n /** Whether the point is inside or on the facet. */\r\n get isInsideOrOn(): boolean;\r\n /** Get the code that classifies the location of the point with respect to the facet. */\r\n get classify(): PolygonLocation;\r\n /** Clone the instance */\r\n clone(): FacetLocationDetail;\r\n /** Set the instance contents from the other detail */\r\n copyContentsFrom(other: FacetLocationDetail): void;\r\n /** Get reference to cached normal interpolated from facet data. Inputs may be used to compute the cache. */\r\n getNormal(facetNormals?: IndexedXYZCollection, facetVertices?: IndexedXYZCollection, distanceTolerance?: number): Vector3d | undefined;\r\n /** Get reference to cached uv parameter interpolated from facet data. Inputs may be used to compute the cache. */\r\n getParam(facetParams?: IndexedXYCollection, facetVertices?: IndexedXYZCollection, distanceTolerance?: number): Point2d | undefined;\r\n /** Get cached color interpolated from facet data. Inputs may be used to compute the cache. */\r\n getColor(facetColors?: number[], facetVertices?: IndexedXYZCollection, distanceTolerance?: number): number | undefined;\r\n /** Get reference to cached barycentric coordinates of the point. Inputs may be used to compute the cache. */\r\n getBarycentricCoordinates(facetVertices?: IndexedXYZCollection, distanceTolerance?: number): number[] | undefined;\r\n}\r\n\r\n/**\r\n * Implementation of `FacetLocationDetail` for a triangular facet.\r\n * @public\r\n */\r\nexport class TriangularFacetLocationDetail implements FacetLocationDetail {\r\n private _facetIndex: number;\r\n private _detail: TriangleLocationDetail;\r\n private _normal?: Vector3d;\r\n private _param?: Point2d;\r\n private _color?: number;\r\n\r\n /** captures the detail if provided */\r\n private constructor(facetIndex: number = -1, detail?: TriangleLocationDetail) {\r\n this._facetIndex = facetIndex;\r\n this._detail = detail ? detail : TriangleLocationDetail.create();\r\n }\r\n /** Invalidate this detail. */\r\n public invalidate(deep: boolean = true) {\r\n this._facetIndex = -1;\r\n if (deep)\r\n this._detail.invalidate();\r\n this._normal = undefined;\r\n this._param = undefined;\r\n this._color = undefined;\r\n }\r\n /** Create a detail.\r\n * @param result optional pre-allocated object to fill and return\r\n */\r\n public static create(facetIndex: number, detail?: TriangleLocationDetail, result?: TriangularFacetLocationDetail): TriangularFacetLocationDetail {\r\n if (undefined === result)\r\n return new TriangularFacetLocationDetail(facetIndex, detail);\r\n result.invalidate(false); // detail might be owned by result!\r\n result._facetIndex = facetIndex;\r\n if (undefined !== detail)\r\n result._detail.copyContentsFrom(detail);\r\n return result;\r\n }\r\n /** Get the facet index. */\r\n public get facetIndex(): number {\r\n return this._facetIndex;\r\n }\r\n /** Get the edge count of this facet. */\r\n public get edgeCount(): number {\r\n return 3;\r\n }\r\n /** Get the world coordinates of the point. */\r\n public get point(): Point3d {\r\n return this._detail.world;\r\n }\r\n /** Get the application-specific number. */\r\n public get a(): number {\r\n return this._detail.a;\r\n }\r\n /** Get the projection of the point onto the closest facet edge. */\r\n public get closestEdge(): { startVertexIndex: number, edgeParam: number } {\r\n return { startVertexIndex: this._detail.closestEdgeIndex, edgeParam: this._detail.closestEdgeParam };\r\n }\r\n /** Test validity of fields other than _detail. */\r\n private get _isValid(): boolean {\r\n return this._facetIndex >= 0;\r\n }\r\n /** Whether this instance specifies a valid location. */\r\n public get isValid(): boolean {\r\n return this._isValid && this._detail.isValid;\r\n }\r\n /** Whether the facet is convex. */\r\n public get isConvex(): boolean {\r\n return true;\r\n }\r\n /** Whether the point is inside or on the polygon. */\r\n public get isInsideOrOn(): boolean {\r\n return this._isValid && this._detail.isInsideOrOn;\r\n }\r\n /** Get the code that classifies the location of the point with respect to the facet. */\r\n public get classify(): PolygonLocation {\r\n return this._detail.classify;\r\n }\r\n /** Clone the instance */\r\n public clone(): TriangularFacetLocationDetail {\r\n const detail = new TriangularFacetLocationDetail();\r\n detail.copyContentsFrom(this);\r\n return detail;\r\n }\r\n /** Set the instance contents from the other detail.\r\n * @param other detail to clone\r\n */\r\n public copyContentsFrom(other: TriangularFacetLocationDetail) {\r\n this._facetIndex = other._facetIndex;\r\n this._detail.copyContentsFrom(other._detail);\r\n this._normal = other._normal?.clone();\r\n this._param = other._param?.clone();\r\n this._color = other._color;\r\n }\r\n /** Get normal interpolated from facet data.\r\n * @param facetNormals used to compute the normal cache\r\n * @returns reference to cached normal\r\n */\r\n public getNormal(facetNormals?: IndexedXYZCollection): Vector3d | undefined {\r\n if (this._detail.isValid && undefined === this._normal && undefined !== facetNormals) {\r\n this._normal = Vector3d.create();\r\n const scales = [this._detail.local.x, this._detail.local.y, this._detail.local.z];\r\n facetNormals.linearCombination(scales, this._normal);\r\n }\r\n return this._normal;\r\n }\r\n /** Get uv parameter interpolated from facet data.\r\n * @param facetParams used to compute the uv parameter cache\r\n * @returns reference to cached uv parameter\r\n */\r\n public getParam(facetParams?: IndexedXYCollection): Point2d | undefined {\r\n if (this._detail.isValid && undefined === this._param && undefined !== facetParams) {\r\n this._param = Point2d.create();\r\n const scales = [this._detail.local.x, this._detail.local.y, this._detail.local.z];\r\n facetParams.linearCombination(scales, this._param);\r\n }\r\n return this._param;\r\n }\r\n /** Get color interpolated from facet data.\r\n * * Assumes barycentric coordinates are already computed in the TriangleLocationDetail member.\r\n * @param facetColors used to compute the color cache\r\n * @returns cached color\r\n */\r\n public getColor(facetColors?: number[]): number | undefined {\r\n if (this._detail.isValid && undefined === this._color && undefined !== facetColors) {\r\n const scales = [this._detail.local.x, this._detail.local.y, this._detail.local.z];\r\n this._color = NumberArray.linearCombinationOfColors(facetColors, scales);\r\n }\r\n return this._color;\r\n }\r\n /** Get the barycentric coordinates of this location.\r\n * @returns cached barycentric coordinates\r\n */\r\n public getBarycentricCoordinates(): number[] {\r\n return [this._detail.local.x, this._detail.local.y, this._detail.local.z];\r\n }\r\n}\r\n/**\r\n * Implementation of `FacetLocationDetail` for a non-convex facet.\r\n * * Facet vertex data interpolation is not available.\r\n * @public\r\n */\r\nexport class NonConvexFacetLocationDetail implements FacetLocationDetail {\r\n private _facetIndex: number;\r\n private _edgeCount: number;\r\n protected _detail: PolygonLocationDetail;\r\n\r\n /** captures the detail if provided */\r\n protected constructor(facetIndex: number = -1, edgeCount: number = 0, detail?: PolygonLocationDetail) {\r\n this._facetIndex = facetIndex;\r\n this._edgeCount = edgeCount;\r\n this._detail = detail ? detail : PolygonLocationDetail.create();\r\n }\r\n /** Invalidate this detail. */\r\n public invalidate(deep: boolean = true) {\r\n this._facetIndex = -1;\r\n this._edgeCount = 0;\r\n if (deep)\r\n this._detail.invalidate();\r\n }\r\n /** Create a detail.\r\n * @param result optional pre-allocated object to fill and return\r\n */\r\n public static create(facetIndex: number, edgeCount: number, detail?: PolygonLocationDetail, result?: NonConvexFacetLocationDetail): NonConvexFacetLocationDetail {\r\n if (undefined === result)\r\n return new NonConvexFacetLocationDetail(facetIndex, edgeCount, detail);\r\n result.invalidate(false); // detail might be owned by result!\r\n result._facetIndex = facetIndex;\r\n result._edgeCount = edgeCount;\r\n if (undefined !== detail && result._detail !== detail)\r\n result._detail.copyContentsFrom(detail);\r\n return result;\r\n }\r\n /** Get the facet index. */\r\n public get facetIndex(): number {\r\n return this._facetIndex;\r\n }\r\n /** Get the edge count of this facet. */\r\n public get edgeCount(): number {\r\n return this._edgeCount;\r\n }\r\n /** Get the world coordinates of the point. */\r\n public get point(): Point3d {\r\n return this._detail.point;\r\n }\r\n /** Get the application-specific number. */\r\n public get a(): number {\r\n return this._detail.a;\r\n }\r\n /** Get the projection of the point onto the closest facet edge. */\r\n public get closestEdge(): { startVertexIndex: number, edgeParam: number } {\r\n return { startVertexIndex: this._detail.closestEdgeIndex, edgeParam: this._detail.closestEdgeParam };\r\n }\r\n /** Test validity of fields other than _detail. */\r\n private get _isValid(): boolean {\r\n return this._facetIndex >= 0 && this._edgeCount >= 3;\r\n }\r\n /** Whether this instance specifies a valid location. */\r\n public get isValid(): boolean {\r\n return this._isValid && this._detail.isValid;\r\n }\r\n /** Whether the facet is convex. */\r\n public get isConvex(): boolean {\r\n return false;\r\n }\r\n /** Whether the point is inside or on the polygon. */\r\n public get isInsideOrOn(): boolean {\r\n return this._isValid && this._detail.isInsideOrOn;\r\n }\r\n /** Get the code that classifies the location of the point with respect to the facet. */\r\n public get classify(): PolygonLocation {\r\n return this._detail.code;\r\n }\r\n /** Clone the instance */\r\n public clone(): NonConvexFacetLocationDetail {\r\n const detail = new NonConvexFacetLocationDetail();\r\n detail.copyContentsFrom(this);\r\n return detail;\r\n }\r\n /** Set the instance contents from the other detail.\r\n * @param other detail to clone\r\n */\r\n public copyContentsFrom(other: NonConvexFacetLocationDetail) {\r\n this._facetIndex = other._facetIndex;\r\n this._edgeCount = other._edgeCount;\r\n this._detail.copyContentsFrom(other._detail);\r\n }\r\n /** Interpolated data is not defined for a non-convex facet.\r\n * @returns undefined\r\n */\r\n public getNormal(): Vector3d | undefined {\r\n return undefined;\r\n }\r\n /** Interpolated data is not defined for a non-convex facet.\r\n * @returns undefined\r\n */\r\n public getParam(): Point2d | undefined {\r\n return undefined;\r\n }\r\n /** Interpolated data is not defined for a non-convex facet.\r\n * @returns undefined\r\n */\r\n public getColor(): number | undefined {\r\n return undefined;\r\n }\r\n /** Barycentric coordinates are not defined for a non-convex facet.\r\n * @returns undefined\r\n */\r\n public getBarycentricCoordinates(): number[] | undefined {\r\n return undefined;\r\n }\r\n}\r\n/**\r\n * Implementation of `FacetLocationDetail` for a convex facet.\r\n * * If `edgeCount` is 3, `TriangularFacetLocationDetail` is more efficient.\r\n * @public\r\n */\r\nexport class ConvexFacetLocationDetail extends NonConvexFacetLocationDetail {\r\n private _normal?: Vector3d;\r\n private _param?: Point2d;\r\n private _color?: number;\r\n private _barycentricCoordinates?: number[];\r\n\r\n /** captures the detail if provided */\r\n private constructor(facetIndex: number = -1, edgeCount: number = 0, detail?: PolygonLocationDetail) {\r\n super(facetIndex, edgeCount, detail);\r\n }\r\n /** Invalidate this detail. */\r\n public override invalidate(deep: boolean = true) {\r\n super.invalidate(deep);\r\n this._normal = undefined;\r\n this._param = undefined;\r\n this._color = undefined;\r\n this._barycentricCoordinates = undefined;\r\n }\r\n /** Create a detail.\r\n * @param result optional pre-allocated object to fill and return\r\n */\r\n public static override create(facetIndex: number, edgeCount: number, detail?: PolygonLocationDetail, result?: ConvexFacetLocationDetail): ConvexFacetLocationDetail {\r\n if (undefined === result)\r\n return new ConvexFacetLocationDetail(facetIndex, edgeCount, detail);\r\n return super.create(facetIndex, edgeCount, detail, result);\r\n }\r\n /** Whether the facet is convex. */\r\n public override get isConvex(): boolean {\r\n return true;\r\n }\r\n /** Clone the instance */\r\n public override clone(): ConvexFacetLocationDetail {\r\n const detail = new ConvexFacetLocationDetail();\r\n detail.copyContentsFrom(this);\r\n return detail;\r\n }\r\n /** Set the instance contents from the other detail.\r\n * @param other detail to clone\r\n */\r\n public override copyContentsFrom(other: ConvexFacetLocationDetail) {\r\n super.copyContentsFrom(other);\r\n this._normal = other._normal?.clone();\r\n this._param = other._param?.clone();\r\n this._color = other._color;\r\n this._barycentricCoordinates = other._barycentricCoordinates?.slice();\r\n }\r\n /** Get normal interpolated from facet data.\r\n * @param facetNormals used to compute the normal cache\r\n * @param facetVertices used to compute the barycentric coordinate cache\r\n * @param distanceTolerance used to compute the barycentric coordinate cache\r\n * @returns reference to cached normal\r\n */\r\n public override getNormal(facetNormals?: IndexedXYZCollection, facetVertices?: IndexedXYZCollection, distanceTolerance: number = Geometry.smallMetricDistance): Vector3d | undefined {\r\n if (this._detail.isValid && undefined === this._normal && undefined !== facetNormals) {\r\n const scales = this.getBarycentricCoordinates(facetVertices, distanceTolerance);\r\n if (undefined !== scales) {\r\n this._normal = Vector3d.create();\r\n facetNormals.linearCombination(scales, this._normal);\r\n }\r\n }\r\n return this._normal;\r\n }\r\n /** Get uv parameter interpolated from facet data.\r\n * @param facetParams used to compute the uv parameter cache\r\n * @param facetVertices used to compute the barycentric coordinate cache\r\n * @param distanceTolerance used to compute the barycentric coordinate cache\r\n * @returns reference to cached uv parameter\r\n */\r\n public override getParam(facetParams?: IndexedXYCollection, facetVertices?: IndexedXYZCollection, distanceTolerance: number = Geometry.smallMetricDistance): Point2d | undefined {\r\n if (this._detail.isValid && undefined === this._param && undefined !== facetParams) {\r\n const scales = this.getBarycentricCoordinates(facetVertices, distanceTolerance);\r\n if (undefined !== scales) {\r\n this._param = Point2d.create();\r\n facetParams.linearCombination(scales, this._param);\r\n }\r\n }\r\n return this._param;\r\n }\r\n /** Get color interpolated from facet data.\r\n * @param facetColors used to compute the color cache\r\n * @param facetVertices used to compute the barycentric coordinate cache\r\n * @param distanceTolerance used to compute the barycentric coordinate cache\r\n * @returns cached color\r\n */\r\n public override getColor(facetColors?: number[], facetVertices?: IndexedXYZCollection, distanceTolerance: number = Geometry.smallMetricDistance): number | undefined {\r\n if (this._detail.isValid && undefined === this._color && undefined !== facetColors) {\r\n const scales = this.getBarycentricCoordinates(facetVertices, distanceTolerance);\r\n if (undefined !== scales)\r\n this._color = NumberArray.linearCombinationOfColors(facetColors, scales);\r\n }\r\n return this._color;\r\n }\r\n /** Get the barycentric coordinates of this location, if they have been computed.\r\n * @param facetVertices used to compute the barycentric coordinate cache\r\n * @param distanceTolerance used to compute the barycentric coordinate cache\r\n * @returns cached barycentric coordinates\r\n */\r\n public override getBarycentricCoordinates(facetVertices?: IndexedXYZCollection, distanceTolerance: number = Geometry.smallMetricDistance): number[] | undefined {\r\n if (this._detail.isValid && undefined === this._barycentricCoordinates && undefined !== facetVertices) {\r\n this._barycentricCoordinates = PolygonOps.convexBarycentricCoordinates(facetVertices, this._detail.point, distanceTolerance);\r\n }\r\n return this._barycentricCoordinates;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"FacetLocationDetail.js","sourceRoot":"","sources":["../../../src/polyface/FacetLocationDetail.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAW,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAmB,MAAM,aAAa,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAG7E,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AASzD;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAehC,gCAAgC;IAChC;QACE,IAAI,CAAC,iBAAiB,GAAG,QAAQ,CAAC,mBAAmB,CAAC;QACtD,IAAI,CAAC,kBAAkB,GAAG,QAAQ,CA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IACrB,CAAC;IACD;;;;MAIE;IACc,yBAAyB,CAAC,aAAoC,EAAE,oBAA4B,QAAQ,CAAC,mBAAmB;QACtI,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,SAAS,KAAK,IAAI,CAAC,uBAAuB,IAAI,SAAS,KAAK,aAAa,EAAE;YACrG,IAAI,CAAC,uBAAuB,GAAG,UAAU,CAAC,4BAA4B,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;SAC9H;QACD,OAAO,IAAI,CAAC,uBAAuB,CAAC;IACtC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Polyface\r\n */\r\n\r\nimport { Point2d } from \"../geometry3d/Point2dVector2d\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { TriangleLocationDetail } from \"../geometry3d/BarycentricTriangle\";\r\nimport { Geometry, PolygonLocation } from \"../Geometry\";\r\nimport { PolyfaceVisitor } from \"./Polyface\";\r\nimport { PolygonLocationDetail, PolygonOps } from \"../geometry3d/PolygonOps\";\r\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { IndexedXYCollection } from \"../geometry3d/IndexedXYCollection\";\r\nimport { NumberArray } from \"../geometry3d/PointHelpers\";\r\n\r\n/** Callback for processing the detail for an intersected facet.\r\n * @param detail reference to the intersection data, with `detail.IsInsideOn === true`. Note that `detail` is owned by the caller; to persist, use `detail.clone`.\r\n * @param visitor at currently intersected facet\r\n * @returns true to accept this intersection and stop processing; false to continue to the next facet\r\n */\r\nexport type FacetIntersectCallback = (detail: FacetLocationDetail, visitor: PolyfaceVisitor) => boolean;\r\n\r\n/** Options for computing and processing facet intersection methods.\r\n * @see PolyfaceQuery.intersectRay3d\r\n */\r\nexport class FacetIntersectOptions {\r\n /** distance tolerance for testing coincidence with facet boundary */\r\n public distanceTolerance: number;\r\n /** fractional tolerance for snapping barycentric coordinates to a triangular facet edge */\r\n public parameterTolerance: number;\r\n /** whether to compute the normal at the intersection point */\r\n public needNormal?: boolean;\r\n /** whether to compute the uv parameter at the intersection point */\r\n public needParam?: boolean;\r\n /** whether to compute the color at the intersection point */\r\n public needColor?: boolean;\r\n /** whether to compute the barycentric coordinates of the point for a convex facet */\r\n public needBarycentricCoordinates?: boolean;\r\n /** optional callback to accept an intersected facet */\r\n public acceptIntersection?: FacetIntersectCallback;\r\n /** constructor with defaults */\r\n public constructor() {\r\n this.distanceTolerance = Geometry.smallMetricDistance;\r\n this.parameterTolerance = Geometry.smallFraction;\r\n }\r\n}\r\n/**\r\n * Carries data about a point in the plane of a facet of a mesh.\r\n * @see PolyfaceQuery.intersectRay3d\r\n * @public\r\n */\r\nexport interface FacetLocationDetail {\r\n /** Get the index of the referenced facet. */\r\n get facetIndex(): number;\r\n /** Get the number of edges of this facet. */\r\n get edgeCount(): number;\r\n /** Get the world coordinates of the point. */\r\n get point(): Point3d;\r\n /** Get the application-specific number. */\r\n get a(): number;\r\n /** Get the projection of the point onto the closest facet edge. */\r\n get closestEdge(): { startVertexIndex: number, edgeParam: number };\r\n /** Whether this instance specifies a valid location. */\r\n get isValid(): boolean;\r\n /** Whether the facet is convex. */\r\n get isConvex(): boolean;\r\n /** Whether the point is inside or on the facet. */\r\n get isInsideOrOn(): boolean;\r\n /** Get the code that classifies the location of the point with respect to the facet. */\r\n get classify(): PolygonLocation;\r\n /** Clone the instance */\r\n clone(): FacetLocationDetail;\r\n /** Set the instance contents from the other detail */\r\n copyContentsFrom(other: FacetLocationDetail): void;\r\n /** Get reference to cached normal interpolated from facet data. Inputs may be used to compute the cache. */\r\n getNormal(facetNormals?: IndexedXYZCollection, facetVertices?: IndexedXYZCollection, distanceTolerance?: number): Vector3d | undefined;\r\n /** Get reference to cached uv parameter interpolated from facet data. Inputs may be used to compute the cache. */\r\n getParam(facetParams?: IndexedXYCollection, facetVertices?: IndexedXYZCollection, distanceTolerance?: number): Point2d | undefined;\r\n /** Get cached color interpolated from facet data. Inputs may be used to compute the cache. */\r\n getColor(facetColors?: number[], facetVertices?: IndexedXYZCollection, distanceTolerance?: number): number | undefined;\r\n /** Get reference to cached barycentric coordinates of the point. Inputs may be used to compute the cache. */\r\n getBarycentricCoordinates(facetVertices?: IndexedXYZCollection, distanceTolerance?: number): number[] | undefined;\r\n}\r\n\r\n/**\r\n * Implementation of `FacetLocationDetail` for a triangular facet.\r\n * @public\r\n */\r\nexport class TriangularFacetLocationDetail implements FacetLocationDetail {\r\n private _facetIndex: number;\r\n private _detail: TriangleLocationDetail;\r\n private _normal?: Vector3d;\r\n private _param?: Point2d;\r\n private _color?: number;\r\n\r\n /** captures the detail if provided */\r\n private constructor(facetIndex: number = -1, detail?: TriangleLocationDetail) {\r\n this._facetIndex = facetIndex;\r\n this._detail = detail ? detail : TriangleLocationDetail.create();\r\n }\r\n /** Invalidate this detail. */\r\n public invalidate(deep: boolean = true) {\r\n this._facetIndex = -1;\r\n if (deep)\r\n this._detail.invalidate();\r\n this._normal = undefined;\r\n this._param = undefined;\r\n this._color = undefined;\r\n }\r\n /** Create a detail.\r\n * @param result optional pre-allocated object to fill and return\r\n */\r\n public static create(facetIndex: number, detail?: TriangleLocationDetail, result?: TriangularFacetLocationDetail): TriangularFacetLocationDetail {\r\n if (undefined === result)\r\n return new TriangularFacetLocationDetail(facetIndex, detail);\r\n result.invalidate(false); // detail might be owned by result!\r\n result._facetIndex = facetIndex;\r\n if (undefined !== detail)\r\n result._detail.copyContentsFrom(detail);\r\n return result;\r\n }\r\n /** Get the facet index. */\r\n public get facetIndex(): number {\r\n return this._facetIndex;\r\n }\r\n /** Get the edge count of this facet. */\r\n public get edgeCount(): number {\r\n return 3;\r\n }\r\n /** Get the world coordinates of the point. */\r\n public get point(): Point3d {\r\n return this._detail.world;\r\n }\r\n /** Get the application-specific number. */\r\n public get a(): number {\r\n return this._detail.a;\r\n }\r\n /** Get the projection of the point onto the closest facet edge. */\r\n public get closestEdge(): { startVertexIndex: number, edgeParam: number } {\r\n return { startVertexIndex: this._detail.closestEdgeIndex, edgeParam: this._detail.closestEdgeParam };\r\n }\r\n /** Test validity of fields other than _detail. */\r\n private get _isValid(): boolean {\r\n return this._facetIndex >= 0;\r\n }\r\n /** Whether this instance specifies a valid location. */\r\n public get isValid(): boolean {\r\n return this._isValid && this._detail.isValid;\r\n }\r\n /** Whether the facet is convex. */\r\n public get isConvex(): boolean {\r\n return true;\r\n }\r\n /** Whether the point is inside or on the polygon. */\r\n public get isInsideOrOn(): boolean {\r\n return this._isValid && this._detail.isInsideOrOn;\r\n }\r\n /** Get the code that classifies the location of the point with respect to the facet. */\r\n public get classify(): PolygonLocation {\r\n return this._detail.classify;\r\n }\r\n /** Clone the instance */\r\n public clone(): TriangularFacetLocationDetail {\r\n const detail = new TriangularFacetLocationDetail();\r\n detail.copyContentsFrom(this);\r\n return detail;\r\n }\r\n /** Set the instance contents from the other detail.\r\n * @param other detail to clone\r\n */\r\n public copyContentsFrom(other: TriangularFacetLocationDetail) {\r\n this._facetIndex = other._facetIndex;\r\n this._detail.copyContentsFrom(other._detail);\r\n this._normal = other._normal?.clone();\r\n this._param = other._param?.clone();\r\n this._color = other._color;\r\n }\r\n /** Get normal interpolated from facet data.\r\n * @param facetNormals used to compute the normal cache\r\n * @returns reference to cached normal\r\n */\r\n public getNormal(facetNormals?: IndexedXYZCollection): Vector3d | undefined {\r\n if (this._detail.isValid && undefined === this._normal && undefined !== facetNormals) {\r\n this._normal = Vector3d.create();\r\n const scales = [this._detail.local.x, this._detail.local.y, this._detail.local.z];\r\n facetNormals.linearCombination(scales, this._normal);\r\n }\r\n return this._normal;\r\n }\r\n /** Get uv parameter interpolated from facet data.\r\n * @param facetParams used to compute the uv parameter cache\r\n * @returns reference to cached uv parameter\r\n */\r\n public getParam(facetParams?: IndexedXYCollection): Point2d | undefined {\r\n if (this._detail.isValid && undefined === this._param && undefined !== facetParams) {\r\n this._param = Point2d.create();\r\n const scales = [this._detail.local.x, this._detail.local.y, this._detail.local.z];\r\n facetParams.linearCombination(scales, this._param);\r\n }\r\n return this._param;\r\n }\r\n /** Get color interpolated from facet data.\r\n * * Assumes barycentric coordinates are already computed in the TriangleLocationDetail member.\r\n * @param facetColors used to compute the color cache\r\n * @returns cached color\r\n */\r\n public getColor(facetColors?: number[]): number | undefined {\r\n if (this._detail.isValid && undefined === this._color && undefined !== facetColors) {\r\n const scales = [this._detail.local.x, this._detail.local.y, this._detail.local.z];\r\n this._color = NumberArray.linearCombinationOfColors(facetColors, scales);\r\n }\r\n return this._color;\r\n }\r\n /** Get the barycentric coordinates of this location.\r\n * @returns cached barycentric coordinates\r\n */\r\n public getBarycentricCoordinates(): number[] {\r\n return [this._detail.local.x, this._detail.local.y, this._detail.local.z];\r\n }\r\n}\r\n/**\r\n * Implementation of `FacetLocationDetail` for a non-convex facet.\r\n * * Facet vertex data interpolation is not available.\r\n * @public\r\n */\r\nexport class NonConvexFacetLocationDetail implements FacetLocationDetail {\r\n private _facetIndex: number;\r\n private _edgeCount: number;\r\n protected _detail: PolygonLocationDetail;\r\n\r\n /** captures the detail if provided */\r\n protected constructor(facetIndex: number = -1, edgeCount: number = 0, detail?: PolygonLocationDetail) {\r\n this._facetIndex = facetIndex;\r\n this._edgeCount = edgeCount;\r\n this._detail = detail ? detail : PolygonLocationDetail.create();\r\n }\r\n /** Invalidate this detail. */\r\n public invalidate(deep: boolean = true) {\r\n this._facetIndex = -1;\r\n this._edgeCount = 0;\r\n if (deep)\r\n this._detail.invalidate();\r\n }\r\n /** Create a detail.\r\n * @param result optional pre-allocated object to fill and return\r\n */\r\n public static create(facetIndex: number, edgeCount: number, detail?: PolygonLocationDetail, result?: NonConvexFacetLocationDetail): NonConvexFacetLocationDetail {\r\n if (undefined === result)\r\n return new NonConvexFacetLocationDetail(facetIndex, edgeCount, detail);\r\n result.invalidate(false); // detail might be owned by result!\r\n result._facetIndex = facetIndex;\r\n result._edgeCount = edgeCount;\r\n if (undefined !== detail && result._detail !== detail)\r\n result._detail.copyContentsFrom(detail);\r\n return result;\r\n }\r\n /** Get the facet index. */\r\n public get facetIndex(): number {\r\n return this._facetIndex;\r\n }\r\n /** Get the edge count of this facet. */\r\n public get edgeCount(): number {\r\n return this._edgeCount;\r\n }\r\n /** Get the world coordinates of the point. */\r\n public get point(): Point3d {\r\n return this._detail.point;\r\n }\r\n /** Get the application-specific number. */\r\n public get a(): number {\r\n return this._detail.a;\r\n }\r\n /** Get the projection of the point onto the closest facet edge. */\r\n public get closestEdge(): { startVertexIndex: number, edgeParam: number } {\r\n return { startVertexIndex: this._detail.closestEdgeIndex, edgeParam: this._detail.closestEdgeParam };\r\n }\r\n /** Test validity of fields other than _detail. */\r\n private get _isValid(): boolean {\r\n return this._facetIndex >= 0 && this._edgeCount >= 3;\r\n }\r\n /** Whether this instance specifies a valid location. */\r\n public get isValid(): boolean {\r\n return this._isValid && this._detail.isValid;\r\n }\r\n /** Whether the facet is convex. */\r\n public get isConvex(): boolean {\r\n return false;\r\n }\r\n /** Whether the point is inside or on the polygon. */\r\n public get isInsideOrOn(): boolean {\r\n return this._isValid && this._detail.isInsideOrOn;\r\n }\r\n /** Get the code that classifies the location of the point with respect to the facet. */\r\n public get classify(): PolygonLocation {\r\n return this._detail.code;\r\n }\r\n /** Clone the instance */\r\n public clone(): NonConvexFacetLocationDetail {\r\n const detail = new NonConvexFacetLocationDetail();\r\n detail.copyContentsFrom(this);\r\n return detail;\r\n }\r\n /** Set the instance contents from the other detail.\r\n * @param other detail to clone\r\n */\r\n public copyContentsFrom(other: NonConvexFacetLocationDetail) {\r\n this._facetIndex = other._facetIndex;\r\n this._edgeCount = other._edgeCount;\r\n this._detail.copyContentsFrom(other._detail);\r\n }\r\n /** Interpolated data is not defined for a non-convex facet.\r\n * @returns undefined\r\n */\r\n public getNormal(): Vector3d | undefined {\r\n return undefined;\r\n }\r\n /** Interpolated data is not defined for a non-convex facet.\r\n * @returns undefined\r\n */\r\n public getParam(): Point2d | undefined {\r\n return undefined;\r\n }\r\n /** Interpolated data is not defined for a non-convex facet.\r\n * @returns undefined\r\n */\r\n public getColor(): number | undefined {\r\n return undefined;\r\n }\r\n /** Barycentric coordinates are not defined for a non-convex facet.\r\n * @returns undefined\r\n */\r\n public getBarycentricCoordinates(): number[] | undefined {\r\n return undefined;\r\n }\r\n}\r\n/**\r\n * Implementation of `FacetLocationDetail` for a convex facet.\r\n * * If `edgeCount` is 3, `TriangularFacetLocationDetail` is more efficient.\r\n * @public\r\n */\r\nexport class ConvexFacetLocationDetail extends NonConvexFacetLocationDetail {\r\n private _normal?: Vector3d;\r\n private _param?: Point2d;\r\n private _color?: number;\r\n private _barycentricCoordinates?: number[];\r\n\r\n /** captures the detail if provided */\r\n private constructor(facetIndex: number = -1, edgeCount: number = 0, detail?: PolygonLocationDetail) {\r\n super(facetIndex, edgeCount, detail);\r\n }\r\n /** Invalidate this detail. */\r\n public override invalidate(deep: boolean = true) {\r\n super.invalidate(deep);\r\n this._normal = undefined;\r\n this._param = undefined;\r\n this._color = undefined;\r\n this._barycentricCoordinates = undefined;\r\n }\r\n /** Create a detail.\r\n * @param result optional pre-allocated object to fill and return\r\n */\r\n public static override create(facetIndex: number, edgeCount: number, detail?: PolygonLocationDetail, result?: ConvexFacetLocationDetail): ConvexFacetLocationDetail {\r\n if (undefined === result)\r\n return new ConvexFacetLocationDetail(facetIndex, edgeCount, detail);\r\n return super.create(facetIndex, edgeCount, detail, result);\r\n }\r\n /** Whether the facet is convex. */\r\n public override get isConvex(): boolean {\r\n return true;\r\n }\r\n /** Clone the instance */\r\n public override clone(): ConvexFacetLocationDetail {\r\n const detail = new ConvexFacetLocationDetail();\r\n detail.copyContentsFrom(this);\r\n return detail;\r\n }\r\n /** Set the instance contents from the other detail.\r\n * @param other detail to clone\r\n */\r\n public override copyContentsFrom(other: ConvexFacetLocationDetail) {\r\n super.copyContentsFrom(other);\r\n this._normal = other._normal?.clone();\r\n this._param = other._param?.clone();\r\n this._color = other._color;\r\n this._barycentricCoordinates = other._barycentricCoordinates?.slice();\r\n }\r\n /** Get normal interpolated from facet data.\r\n * @param facetNormals used to compute the normal cache\r\n * @param facetVertices used to compute the barycentric coordinate cache\r\n * @param distanceTolerance used to compute the barycentric coordinate cache\r\n * @returns reference to cached normal\r\n */\r\n public override getNormal(facetNormals?: IndexedXYZCollection, facetVertices?: IndexedXYZCollection, distanceTolerance: number = Geometry.smallMetricDistance): Vector3d | undefined {\r\n if (this._detail.isValid && undefined === this._normal && undefined !== facetNormals) {\r\n const scales = this.getBarycentricCoordinates(facetVertices, distanceTolerance);\r\n if (undefined !== scales) {\r\n this._normal = Vector3d.create();\r\n facetNormals.linearCombination(scales, this._normal);\r\n }\r\n }\r\n return this._normal;\r\n }\r\n /** Get uv parameter interpolated from facet data.\r\n * @param facetParams used to compute the uv parameter cache\r\n * @param facetVertices used to compute the barycentric coordinate cache\r\n * @param distanceTolerance used to compute the barycentric coordinate cache\r\n * @returns reference to cached uv parameter\r\n */\r\n public override getParam(facetParams?: IndexedXYCollection, facetVertices?: IndexedXYZCollection, distanceTolerance: number = Geometry.smallMetricDistance): Point2d | undefined {\r\n if (this._detail.isValid && undefined === this._param && undefined !== facetParams) {\r\n const scales = this.getBarycentricCoordinates(facetVertices, distanceTolerance);\r\n if (undefined !== scales) {\r\n this._param = Point2d.create();\r\n facetParams.linearCombination(scales, this._param);\r\n }\r\n }\r\n return this._param;\r\n }\r\n /** Get color interpolated from facet data.\r\n * @param facetColors used to compute the color cache\r\n * @param facetVertices used to compute the barycentric coordinate cache\r\n * @param distanceTolerance used to compute the barycentric coordinate cache\r\n * @returns cached color\r\n */\r\n public override getColor(facetColors?: number[], facetVertices?: IndexedXYZCollection, distanceTolerance: number = Geometry.smallMetricDistance): number | undefined {\r\n if (this._detail.isValid && undefined === this._color && undefined !== facetColors) {\r\n const scales = this.getBarycentricCoordinates(facetVertices, distanceTolerance);\r\n if (undefined !== scales)\r\n this._color = NumberArray.linearCombinationOfColors(facetColors, scales);\r\n }\r\n return this._color;\r\n }\r\n /** Get the barycentric coordinates of this location, if they have been computed.\r\n * @param facetVertices used to compute the barycentric coordinate cache\r\n * @param distanceTolerance used to compute the barycentric coordinate cache\r\n * @returns cached barycentric coordinates\r\n */\r\n public override getBarycentricCoordinates(facetVertices?: IndexedXYZCollection, distanceTolerance: number = Geometry.smallMetricDistance): number[] | undefined {\r\n if (this._detail.isValid && undefined === this._barycentricCoordinates && undefined !== facetVertices) {\r\n this._barycentricCoordinates = PolygonOps.convexBarycentricCoordinates(facetVertices, this._detail.point, distanceTolerance);\r\n }\r\n return this._barycentricCoordinates;\r\n }\r\n}\r\n"]}
|
|
@@ -153,11 +153,11 @@ export class PolyfaceClip {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
if (outsideShards.length === 0) {
|
|
156
|
-
builderA
|
|
156
|
+
builderA?.addPolygonGrowableXYZArray(visitor.point);
|
|
157
157
|
}
|
|
158
158
|
else if (insideShards.length === 0) {
|
|
159
159
|
// the facet spanned clippers but is intact outside
|
|
160
|
-
builderB
|
|
160
|
+
builderB?.addPolygonGrowableXYZArray(visitor.point);
|
|
161
161
|
}
|
|
162
162
|
else {
|
|
163
163
|
const localToWorld = FrameBuilder.createRightHandedFrame(undefined, visitor.point);
|
|
@@ -250,7 +250,7 @@ export class PolyfaceClip {
|
|
|
250
250
|
const insidePart = clipper.clipInsidePushOutside(visitor.point, outsideParts, cache);
|
|
251
251
|
if (insidePart === undefined) {
|
|
252
252
|
// everything is out ... outsideParts might be fragmented. Save only the original polygon
|
|
253
|
-
builderB
|
|
253
|
+
builderB?.addPolygonGrowableXYZArray(visitor.point);
|
|
254
254
|
cache.dropToCache(insidePart);
|
|
255
255
|
cache.dropAllToCache(outsideParts);
|
|
256
256
|
}
|
|
@@ -325,16 +325,15 @@ export class PolyfaceClip {
|
|
|
325
325
|
if (destination.builderB)
|
|
326
326
|
destination.builderB.toggleReversedFacetFlag();
|
|
327
327
|
contour.announceFacets((facets) => {
|
|
328
|
-
var _a, _b;
|
|
329
328
|
const visitor = facets.createVisitor();
|
|
330
329
|
// The contour facets are convex .. easy clip ..
|
|
331
330
|
for (visitor.reset(); visitor.moveToNextFacet();) {
|
|
332
331
|
polygonA.clear();
|
|
333
332
|
polygonA.pushFromGrowableXYZArray(visitor.point);
|
|
334
|
-
clipper
|
|
333
|
+
clipper?.clipConvexPolygonInPlace(polygonA, polygonB);
|
|
335
334
|
if (polygonA.length > 2) {
|
|
336
|
-
|
|
337
|
-
|
|
335
|
+
destination.builderA?.addPolygonGrowableXYZArray(polygonA);
|
|
336
|
+
destination.builderB?.addPolygonGrowableXYZArray(polygonA);
|
|
338
337
|
}
|
|
339
338
|
}
|
|
340
339
|
}, undefined);
|