@itwin/core-geometry 4.0.0-dev.23 → 4.0.0-dev.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -2
- package/lib/cjs/Geometry.d.ts +23 -0
- package/lib/cjs/Geometry.d.ts.map +1 -1
- package/lib/cjs/Geometry.js +25 -1
- package/lib/cjs/Geometry.js.map +1 -1
- 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/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/BarycentricTriangle.d.ts +195 -8
- package/lib/cjs/geometry3d/BarycentricTriangle.d.ts.map +1 -1
- package/lib/cjs/geometry3d/BarycentricTriangle.js +459 -11
- package/lib/cjs/geometry3d/BarycentricTriangle.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.d.ts +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.js +2 -2
- 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/IndexedXYCollection.d.ts +22 -7
- package/lib/cjs/geometry3d/IndexedXYCollection.d.ts.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYCollection.js +41 -5
- package/lib/cjs/geometry3d/IndexedXYCollection.js.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +58 -4
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.js +102 -4
- package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts +10 -0
- package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point2dArrayCarrier.js +14 -0
- package/lib/cjs/geometry3d/Point2dArrayCarrier.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/Point3dArrayCarrier.d.ts +0 -6
- package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dArrayCarrier.js +0 -6
- package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +6 -8
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts +14 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.js +33 -1
- package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.d.ts +120 -10
- package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.js +413 -13
- 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.d.ts +264 -0
- package/lib/cjs/polyface/FacetLocationDetail.d.ts.map +1 -0
- package/lib/cjs/polyface/FacetLocationDetail.js +376 -0
- package/lib/cjs/polyface/FacetLocationDetail.js.map +1 -0
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts +2 -5
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js +5 -2
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts +20 -14
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.js +21 -17
- package/lib/cjs/polyface/PolyfaceBuilder.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/PolyfaceData.d.ts +1 -1
- package/lib/cjs/polyface/PolyfaceData.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.d.ts +22 -1
- package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js +52 -2
- 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/Sphere.d.ts +5 -5
- package/lib/cjs/solid/Sphere.js +5 -5
- package/lib/cjs/solid/Sphere.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/Geometry.d.ts +23 -0
- package/lib/esm/Geometry.d.ts.map +1 -1
- package/lib/esm/Geometry.js +24 -0
- package/lib/esm/Geometry.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/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/BarycentricTriangle.d.ts +195 -8
- package/lib/esm/geometry3d/BarycentricTriangle.d.ts.map +1 -1
- package/lib/esm/geometry3d/BarycentricTriangle.js +459 -12
- package/lib/esm/geometry3d/BarycentricTriangle.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.d.ts +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.js +2 -2
- 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/IndexedXYCollection.d.ts +22 -7
- package/lib/esm/geometry3d/IndexedXYCollection.d.ts.map +1 -1
- package/lib/esm/geometry3d/IndexedXYCollection.js +41 -5
- package/lib/esm/geometry3d/IndexedXYCollection.js.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +58 -4
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.js +103 -5
- package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts +10 -0
- package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point2dArrayCarrier.js +14 -0
- package/lib/esm/geometry3d/Point2dArrayCarrier.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/Point3dArrayCarrier.d.ts +0 -6
- package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dArrayCarrier.js +0 -6
- package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +6 -8
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts +14 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.js +33 -1
- package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.d.ts +120 -10
- package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.js +412 -13
- 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.d.ts +264 -0
- package/lib/esm/polyface/FacetLocationDetail.d.ts.map +1 -0
- package/lib/esm/polyface/FacetLocationDetail.js +369 -0
- package/lib/esm/polyface/FacetLocationDetail.js.map +1 -0
- package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts +2 -5
- package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js +5 -2
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.d.ts +20 -14
- package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.js +21 -17
- package/lib/esm/polyface/PolyfaceBuilder.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/PolyfaceData.d.ts +1 -1
- package/lib/esm/polyface/PolyfaceData.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceData.js.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.d.ts +22 -1
- package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js +52 -2
- 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/Sphere.d.ts +5 -5
- package/lib/esm/solid/Sphere.js +5 -5
- package/lib/esm/solid/Sphere.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
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module Polyface
|
|
7
|
+
*/
|
|
8
|
+
import { Point2d } from "../geometry3d/Point2dVector2d";
|
|
9
|
+
import { Vector3d } from "../geometry3d/Point3dVector3d";
|
|
10
|
+
import { TriangleLocationDetail } from "../geometry3d/BarycentricTriangle";
|
|
11
|
+
import { Geometry } from "../Geometry";
|
|
12
|
+
import { PolygonLocationDetail, PolygonOps } from "../geometry3d/PolygonOps";
|
|
13
|
+
import { NumberArray } from "../geometry3d/PointHelpers";
|
|
14
|
+
/** Options for computing and processing facet intersection methods.
|
|
15
|
+
* @see PolyfaceQuery.intersectRay3d
|
|
16
|
+
*/
|
|
17
|
+
export class FacetIntersectOptions {
|
|
18
|
+
/** constructor with defaults */
|
|
19
|
+
constructor() {
|
|
20
|
+
this.distanceTolerance = Geometry.smallMetricDistance;
|
|
21
|
+
this.parameterTolerance = Geometry.smallFraction;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Implementation of `FacetLocationDetail` for a triangular facet.
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export class TriangularFacetLocationDetail {
|
|
29
|
+
/** captures the detail if provided */
|
|
30
|
+
constructor(facetIndex = -1, detail) {
|
|
31
|
+
this._facetIndex = facetIndex;
|
|
32
|
+
this._detail = detail ? detail : TriangleLocationDetail.create();
|
|
33
|
+
}
|
|
34
|
+
/** Invalidate this detail. */
|
|
35
|
+
invalidate(deep = true) {
|
|
36
|
+
this._facetIndex = -1;
|
|
37
|
+
if (deep)
|
|
38
|
+
this._detail.invalidate();
|
|
39
|
+
this._normal = undefined;
|
|
40
|
+
this._param = undefined;
|
|
41
|
+
this._color = undefined;
|
|
42
|
+
}
|
|
43
|
+
/** Create a detail.
|
|
44
|
+
* @param result optional pre-allocated object to fill and return
|
|
45
|
+
*/
|
|
46
|
+
static create(facetIndex, detail, result) {
|
|
47
|
+
if (undefined === result)
|
|
48
|
+
return new TriangularFacetLocationDetail(facetIndex, detail);
|
|
49
|
+
result.invalidate(false); // detail might be owned by result!
|
|
50
|
+
result._facetIndex = facetIndex;
|
|
51
|
+
if (undefined !== detail)
|
|
52
|
+
result._detail.copyContentsFrom(detail);
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
/** Get the facet index. */
|
|
56
|
+
get facetIndex() {
|
|
57
|
+
return this._facetIndex;
|
|
58
|
+
}
|
|
59
|
+
/** Get the edge count of this facet. */
|
|
60
|
+
get edgeCount() {
|
|
61
|
+
return 3;
|
|
62
|
+
}
|
|
63
|
+
/** Get the world coordinates of the point. */
|
|
64
|
+
get point() {
|
|
65
|
+
return this._detail.world;
|
|
66
|
+
}
|
|
67
|
+
/** Get the application-specific number. */
|
|
68
|
+
get a() {
|
|
69
|
+
return this._detail.a;
|
|
70
|
+
}
|
|
71
|
+
/** Get the projection of the point onto the closest facet edge. */
|
|
72
|
+
get closestEdge() {
|
|
73
|
+
return { startVertexIndex: this._detail.closestEdgeIndex, edgeParam: this._detail.closestEdgeParam };
|
|
74
|
+
}
|
|
75
|
+
/** Test validity of fields other than _detail. */
|
|
76
|
+
get _isValid() {
|
|
77
|
+
return this._facetIndex >= 0;
|
|
78
|
+
}
|
|
79
|
+
/** Whether this instance specifies a valid location. */
|
|
80
|
+
get isValid() {
|
|
81
|
+
return this._isValid && this._detail.isValid;
|
|
82
|
+
}
|
|
83
|
+
/** Whether the facet is convex. */
|
|
84
|
+
get isConvex() {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
/** Whether the point is inside or on the polygon. */
|
|
88
|
+
get isInsideOrOn() {
|
|
89
|
+
return this._isValid && this._detail.isInsideOrOn;
|
|
90
|
+
}
|
|
91
|
+
/** Get the code that classifies the location of the point with respect to the facet. */
|
|
92
|
+
get classify() {
|
|
93
|
+
return this._detail.classify;
|
|
94
|
+
}
|
|
95
|
+
/** Clone the instance */
|
|
96
|
+
clone() {
|
|
97
|
+
const detail = new TriangularFacetLocationDetail();
|
|
98
|
+
detail.copyContentsFrom(this);
|
|
99
|
+
return detail;
|
|
100
|
+
}
|
|
101
|
+
/** Set the instance contents from the other detail.
|
|
102
|
+
* @param other detail to clone
|
|
103
|
+
*/
|
|
104
|
+
copyContentsFrom(other) {
|
|
105
|
+
this._facetIndex = other._facetIndex;
|
|
106
|
+
this._detail.copyContentsFrom(other._detail);
|
|
107
|
+
this._normal = other._normal?.clone();
|
|
108
|
+
this._param = other._param?.clone();
|
|
109
|
+
this._color = other._color;
|
|
110
|
+
}
|
|
111
|
+
/** Get normal interpolated from facet data.
|
|
112
|
+
* @param facetNormals used to compute the normal cache
|
|
113
|
+
* @returns reference to cached normal
|
|
114
|
+
*/
|
|
115
|
+
getNormal(facetNormals) {
|
|
116
|
+
if (this._detail.isValid && undefined === this._normal && undefined !== facetNormals) {
|
|
117
|
+
this._normal = Vector3d.create();
|
|
118
|
+
const scales = [this._detail.local.x, this._detail.local.y, this._detail.local.z];
|
|
119
|
+
facetNormals.linearCombination(scales, this._normal);
|
|
120
|
+
}
|
|
121
|
+
return this._normal;
|
|
122
|
+
}
|
|
123
|
+
/** Get uv parameter interpolated from facet data.
|
|
124
|
+
* @param facetParams used to compute the uv parameter cache
|
|
125
|
+
* @returns reference to cached uv parameter
|
|
126
|
+
*/
|
|
127
|
+
getParam(facetParams) {
|
|
128
|
+
if (this._detail.isValid && undefined === this._param && undefined !== facetParams) {
|
|
129
|
+
this._param = Point2d.create();
|
|
130
|
+
const scales = [this._detail.local.x, this._detail.local.y, this._detail.local.z];
|
|
131
|
+
facetParams.linearCombination(scales, this._param);
|
|
132
|
+
}
|
|
133
|
+
return this._param;
|
|
134
|
+
}
|
|
135
|
+
/** Get color interpolated from facet data.
|
|
136
|
+
* * Assumes barycentric coordinates are already computed in the TriangleLocationDetail member.
|
|
137
|
+
* @param facetColors used to compute the color cache
|
|
138
|
+
* @returns cached color
|
|
139
|
+
*/
|
|
140
|
+
getColor(facetColors) {
|
|
141
|
+
if (this._detail.isValid && undefined === this._color && undefined !== facetColors) {
|
|
142
|
+
const scales = [this._detail.local.x, this._detail.local.y, this._detail.local.z];
|
|
143
|
+
this._color = NumberArray.linearCombinationOfColors(facetColors, scales);
|
|
144
|
+
}
|
|
145
|
+
return this._color;
|
|
146
|
+
}
|
|
147
|
+
/** Get the barycentric coordinates of this location.
|
|
148
|
+
* @returns cached barycentric coordinates
|
|
149
|
+
*/
|
|
150
|
+
getBarycentricCoordinates() {
|
|
151
|
+
return [this._detail.local.x, this._detail.local.y, this._detail.local.z];
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Implementation of `FacetLocationDetail` for a non-convex facet.
|
|
156
|
+
* * Facet vertex data interpolation is not available.
|
|
157
|
+
* @public
|
|
158
|
+
*/
|
|
159
|
+
export class NonConvexFacetLocationDetail {
|
|
160
|
+
/** captures the detail if provided */
|
|
161
|
+
constructor(facetIndex = -1, edgeCount = 0, detail) {
|
|
162
|
+
this._facetIndex = facetIndex;
|
|
163
|
+
this._edgeCount = edgeCount;
|
|
164
|
+
this._detail = detail ? detail : PolygonLocationDetail.create();
|
|
165
|
+
}
|
|
166
|
+
/** Invalidate this detail. */
|
|
167
|
+
invalidate(deep = true) {
|
|
168
|
+
this._facetIndex = -1;
|
|
169
|
+
this._edgeCount = 0;
|
|
170
|
+
if (deep)
|
|
171
|
+
this._detail.invalidate();
|
|
172
|
+
}
|
|
173
|
+
/** Create a detail.
|
|
174
|
+
* @param result optional pre-allocated object to fill and return
|
|
175
|
+
*/
|
|
176
|
+
static create(facetIndex, edgeCount, detail, result) {
|
|
177
|
+
if (undefined === result)
|
|
178
|
+
return new NonConvexFacetLocationDetail(facetIndex, edgeCount, detail);
|
|
179
|
+
result.invalidate(false); // detail might be owned by result!
|
|
180
|
+
result._facetIndex = facetIndex;
|
|
181
|
+
result._edgeCount = edgeCount;
|
|
182
|
+
if (undefined !== detail && result._detail !== detail)
|
|
183
|
+
result._detail.copyContentsFrom(detail);
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
/** Get the facet index. */
|
|
187
|
+
get facetIndex() {
|
|
188
|
+
return this._facetIndex;
|
|
189
|
+
}
|
|
190
|
+
/** Get the edge count of this facet. */
|
|
191
|
+
get edgeCount() {
|
|
192
|
+
return this._edgeCount;
|
|
193
|
+
}
|
|
194
|
+
/** Get the world coordinates of the point. */
|
|
195
|
+
get point() {
|
|
196
|
+
return this._detail.point;
|
|
197
|
+
}
|
|
198
|
+
/** Get the application-specific number. */
|
|
199
|
+
get a() {
|
|
200
|
+
return this._detail.a;
|
|
201
|
+
}
|
|
202
|
+
/** Get the projection of the point onto the closest facet edge. */
|
|
203
|
+
get closestEdge() {
|
|
204
|
+
return { startVertexIndex: this._detail.closestEdgeIndex, edgeParam: this._detail.closestEdgeParam };
|
|
205
|
+
}
|
|
206
|
+
/** Test validity of fields other than _detail. */
|
|
207
|
+
get _isValid() {
|
|
208
|
+
return this._facetIndex >= 0 && this._edgeCount >= 3;
|
|
209
|
+
}
|
|
210
|
+
/** Whether this instance specifies a valid location. */
|
|
211
|
+
get isValid() {
|
|
212
|
+
return this._isValid && this._detail.isValid;
|
|
213
|
+
}
|
|
214
|
+
/** Whether the facet is convex. */
|
|
215
|
+
get isConvex() {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
/** Whether the point is inside or on the polygon. */
|
|
219
|
+
get isInsideOrOn() {
|
|
220
|
+
return this._isValid && this._detail.isInsideOrOn;
|
|
221
|
+
}
|
|
222
|
+
/** Get the code that classifies the location of the point with respect to the facet. */
|
|
223
|
+
get classify() {
|
|
224
|
+
return this._detail.code;
|
|
225
|
+
}
|
|
226
|
+
/** Clone the instance */
|
|
227
|
+
clone() {
|
|
228
|
+
const detail = new NonConvexFacetLocationDetail();
|
|
229
|
+
detail.copyContentsFrom(this);
|
|
230
|
+
return detail;
|
|
231
|
+
}
|
|
232
|
+
/** Set the instance contents from the other detail.
|
|
233
|
+
* @param other detail to clone
|
|
234
|
+
*/
|
|
235
|
+
copyContentsFrom(other) {
|
|
236
|
+
this._facetIndex = other._facetIndex;
|
|
237
|
+
this._edgeCount = other._edgeCount;
|
|
238
|
+
this._detail.copyContentsFrom(other._detail);
|
|
239
|
+
}
|
|
240
|
+
/** Interpolated data is not defined for a non-convex facet.
|
|
241
|
+
* @returns undefined
|
|
242
|
+
*/
|
|
243
|
+
getNormal() {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
/** Interpolated data is not defined for a non-convex facet.
|
|
247
|
+
* @returns undefined
|
|
248
|
+
*/
|
|
249
|
+
getParam() {
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
/** Interpolated data is not defined for a non-convex facet.
|
|
253
|
+
* @returns undefined
|
|
254
|
+
*/
|
|
255
|
+
getColor() {
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
/** Barycentric coordinates are not defined for a non-convex facet.
|
|
259
|
+
* @returns undefined
|
|
260
|
+
*/
|
|
261
|
+
getBarycentricCoordinates() {
|
|
262
|
+
return undefined;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Implementation of `FacetLocationDetail` for a convex facet.
|
|
267
|
+
* * If `edgeCount` is 3, `TriangularFacetLocationDetail` is more efficient.
|
|
268
|
+
* @public
|
|
269
|
+
*/
|
|
270
|
+
export class ConvexFacetLocationDetail extends NonConvexFacetLocationDetail {
|
|
271
|
+
/** captures the detail if provided */
|
|
272
|
+
constructor(facetIndex = -1, edgeCount = 0, detail) {
|
|
273
|
+
super(facetIndex, edgeCount, detail);
|
|
274
|
+
}
|
|
275
|
+
/** Invalidate this detail. */
|
|
276
|
+
invalidate(deep = true) {
|
|
277
|
+
super.invalidate(deep);
|
|
278
|
+
this._normal = undefined;
|
|
279
|
+
this._param = undefined;
|
|
280
|
+
this._color = undefined;
|
|
281
|
+
this._barycentricCoordinates = undefined;
|
|
282
|
+
}
|
|
283
|
+
/** Create a detail.
|
|
284
|
+
* @param result optional pre-allocated object to fill and return
|
|
285
|
+
*/
|
|
286
|
+
static create(facetIndex, edgeCount, detail, result) {
|
|
287
|
+
if (undefined === result)
|
|
288
|
+
return new ConvexFacetLocationDetail(facetIndex, edgeCount, detail);
|
|
289
|
+
return super.create(facetIndex, edgeCount, detail, result);
|
|
290
|
+
}
|
|
291
|
+
/** Whether the facet is convex. */
|
|
292
|
+
get isConvex() {
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
/** Clone the instance */
|
|
296
|
+
clone() {
|
|
297
|
+
const detail = new ConvexFacetLocationDetail();
|
|
298
|
+
detail.copyContentsFrom(this);
|
|
299
|
+
return detail;
|
|
300
|
+
}
|
|
301
|
+
/** Set the instance contents from the other detail.
|
|
302
|
+
* @param other detail to clone
|
|
303
|
+
*/
|
|
304
|
+
copyContentsFrom(other) {
|
|
305
|
+
super.copyContentsFrom(other);
|
|
306
|
+
this._normal = other._normal?.clone();
|
|
307
|
+
this._param = other._param?.clone();
|
|
308
|
+
this._color = other._color;
|
|
309
|
+
this._barycentricCoordinates = other._barycentricCoordinates?.slice();
|
|
310
|
+
}
|
|
311
|
+
/** Get normal interpolated from facet data.
|
|
312
|
+
* @param facetNormals used to compute the normal cache
|
|
313
|
+
* @param facetVertices used to compute the barycentric coordinate cache
|
|
314
|
+
* @param distanceTolerance used to compute the barycentric coordinate cache
|
|
315
|
+
* @returns reference to cached normal
|
|
316
|
+
*/
|
|
317
|
+
getNormal(facetNormals, facetVertices, distanceTolerance = Geometry.smallMetricDistance) {
|
|
318
|
+
if (this._detail.isValid && undefined === this._normal && undefined !== facetNormals) {
|
|
319
|
+
const scales = this.getBarycentricCoordinates(facetVertices, distanceTolerance);
|
|
320
|
+
if (undefined !== scales) {
|
|
321
|
+
this._normal = Vector3d.create();
|
|
322
|
+
facetNormals.linearCombination(scales, this._normal);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return this._normal;
|
|
326
|
+
}
|
|
327
|
+
/** Get uv parameter interpolated from facet data.
|
|
328
|
+
* @param facetParams used to compute the uv parameter cache
|
|
329
|
+
* @param facetVertices used to compute the barycentric coordinate cache
|
|
330
|
+
* @param distanceTolerance used to compute the barycentric coordinate cache
|
|
331
|
+
* @returns reference to cached uv parameter
|
|
332
|
+
*/
|
|
333
|
+
getParam(facetParams, facetVertices, distanceTolerance = Geometry.smallMetricDistance) {
|
|
334
|
+
if (this._detail.isValid && undefined === this._param && undefined !== facetParams) {
|
|
335
|
+
const scales = this.getBarycentricCoordinates(facetVertices, distanceTolerance);
|
|
336
|
+
if (undefined !== scales) {
|
|
337
|
+
this._param = Point2d.create();
|
|
338
|
+
facetParams.linearCombination(scales, this._param);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return this._param;
|
|
342
|
+
}
|
|
343
|
+
/** Get color interpolated from facet data.
|
|
344
|
+
* @param facetColors used to compute the color cache
|
|
345
|
+
* @param facetVertices used to compute the barycentric coordinate cache
|
|
346
|
+
* @param distanceTolerance used to compute the barycentric coordinate cache
|
|
347
|
+
* @returns cached color
|
|
348
|
+
*/
|
|
349
|
+
getColor(facetColors, facetVertices, distanceTolerance = Geometry.smallMetricDistance) {
|
|
350
|
+
if (this._detail.isValid && undefined === this._color && undefined !== facetColors) {
|
|
351
|
+
const scales = this.getBarycentricCoordinates(facetVertices, distanceTolerance);
|
|
352
|
+
if (undefined !== scales)
|
|
353
|
+
this._color = NumberArray.linearCombinationOfColors(facetColors, scales);
|
|
354
|
+
}
|
|
355
|
+
return this._color;
|
|
356
|
+
}
|
|
357
|
+
/** Get the barycentric coordinates of this location, if they have been computed.
|
|
358
|
+
* @param facetVertices used to compute the barycentric coordinate cache
|
|
359
|
+
* @param distanceTolerance used to compute the barycentric coordinate cache
|
|
360
|
+
* @returns cached barycentric coordinates
|
|
361
|
+
*/
|
|
362
|
+
getBarycentricCoordinates(facetVertices, distanceTolerance = Geometry.smallMetricDistance) {
|
|
363
|
+
if (this._detail.isValid && undefined === this._barycentricCoordinates && undefined !== facetVertices) {
|
|
364
|
+
this._barycentricCoordinates = PolygonOps.convexBarycentricCoordinates(facetVertices, this._detail.point, distanceTolerance);
|
|
365
|
+
}
|
|
366
|
+
return this._barycentricCoordinates;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
//# sourceMappingURL=FacetLocationDetail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FacetLocationDetail.js","sourceRoot":"","sources":["../../../src/polyface/FacetLocationDetail.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GA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D,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IACD;;;;;OAKG;IACa,QAAQ,CAAC,WAAsB,EAAE,aAAoC,EAAE,oBAA4B,QAAQ,CAAC,mBAAmB;QAC7I,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,SAAS,KAAK,IAAI,CAAC,MAAM,IAAI,SAAS,KAAK,WAAW,EAAE;YAClF,MAAM,MAAM,GAAG,IAAI,CAAC,yBAAyB,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;YAChF,IAAI,SAAS,KAAK,MAAM;gBACtB,IAAI,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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Polyface\n */\n\nimport { Point2d } from \"../geometry3d/Point2dVector2d\";\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\nimport { TriangleLocationDetail } from \"../geometry3d/BarycentricTriangle\";\nimport { Geometry, PolygonLocation } from \"../Geometry\";\nimport { PolyfaceVisitor } from \"./Polyface\";\nimport { PolygonLocationDetail, PolygonOps } from \"../geometry3d/PolygonOps\";\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\nimport { IndexedXYCollection } from \"../geometry3d/IndexedXYCollection\";\nimport { NumberArray } from \"../geometry3d/PointHelpers\";\n\n/** Callback for processing the detail for an intersected facet.\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`.\n * @param visitor at currently intersected facet\n * @returns true to accept this intersection and stop processing; false to continue to the next facet\n */\nexport type FacetIntersectCallback = (detail: FacetLocationDetail, visitor: PolyfaceVisitor) => boolean;\n\n/** Options for computing and processing facet intersection methods.\n * @see PolyfaceQuery.intersectRay3d\n */\nexport class FacetIntersectOptions {\n /** distance tolerance for testing coincidence with facet boundary */\n public distanceTolerance: number;\n /** fractional tolerance for snapping barycentric coordinates to a triangular facet edge */\n public parameterTolerance: number;\n /** whether to compute the normal at the intersection point */\n public needNormal?: boolean;\n /** whether to compute the uv parameter at the intersection point */\n public needParam?: boolean;\n /** whether to compute the color at the intersection point */\n public needColor?: boolean;\n /** whether to compute the barycentric coordinates of the point for a convex facet */\n public needBarycentricCoordinates?: boolean;\n /** optional callback to accept an intersected facet */\n public acceptIntersection?: FacetIntersectCallback;\n /** constructor with defaults */\n public constructor() {\n this.distanceTolerance = Geometry.smallMetricDistance;\n this.parameterTolerance = Geometry.smallFraction;\n }\n}\n/**\n * Carries data about a point in the plane of a facet of a mesh.\n * @see PolyfaceQuery.intersectRay3d\n * @public\n */\nexport interface FacetLocationDetail {\n /** Get the index of the referenced facet. */\n get facetIndex(): number;\n /** Get the number of edges of this facet. */\n get edgeCount(): number;\n /** Get the world coordinates of the point. */\n get point(): Point3d;\n /** Get the application-specific number. */\n get a(): number;\n /** Get the projection of the point onto the closest facet edge. */\n get closestEdge(): { startVertexIndex: number, edgeParam: number };\n /** Whether this instance specifies a valid location. */\n get isValid(): boolean;\n /** Whether the facet is convex. */\n get isConvex(): boolean;\n /** Whether the point is inside or on the facet. */\n get isInsideOrOn(): boolean;\n /** Get the code that classifies the location of the point with respect to the facet. */\n get classify(): PolygonLocation;\n /** Clone the instance */\n clone(): FacetLocationDetail;\n /** Set the instance contents from the other detail */\n copyContentsFrom(other: FacetLocationDetail): void;\n /** Get reference to cached normal interpolated from facet data. Inputs may be used to compute the cache. */\n getNormal(facetNormals?: IndexedXYZCollection, facetVertices?: IndexedXYZCollection, distanceTolerance?: number): Vector3d | undefined;\n /** Get reference to cached uv parameter interpolated from facet data. Inputs may be used to compute the cache. */\n getParam(facetParams?: IndexedXYCollection, facetVertices?: IndexedXYZCollection, distanceTolerance?: number): Point2d | undefined;\n /** Get cached color interpolated from facet data. Inputs may be used to compute the cache. */\n getColor(facetColors?: number[], facetVertices?: IndexedXYZCollection, distanceTolerance?: number): number | undefined;\n /** Get reference to cached barycentric coordinates of the point. Inputs may be used to compute the cache. */\n getBarycentricCoordinates(facetVertices?: IndexedXYZCollection, distanceTolerance?: number): number[] | undefined;\n}\n\n/**\n * Implementation of `FacetLocationDetail` for a triangular facet.\n * @public\n */\nexport class TriangularFacetLocationDetail implements FacetLocationDetail {\n private _facetIndex: number;\n private _detail: TriangleLocationDetail;\n private _normal?: Vector3d;\n private _param?: Point2d;\n private _color?: number;\n\n /** captures the detail if provided */\n private constructor(facetIndex: number = -1, detail?: TriangleLocationDetail) {\n this._facetIndex = facetIndex;\n this._detail = detail ? detail : TriangleLocationDetail.create();\n }\n /** Invalidate this detail. */\n public invalidate(deep: boolean = true) {\n this._facetIndex = -1;\n if (deep)\n this._detail.invalidate();\n this._normal = undefined;\n this._param = undefined;\n this._color = undefined;\n }\n /** Create a detail.\n * @param result optional pre-allocated object to fill and return\n */\n public static create(facetIndex: number, detail?: TriangleLocationDetail, result?: TriangularFacetLocationDetail): TriangularFacetLocationDetail {\n if (undefined === result)\n return new TriangularFacetLocationDetail(facetIndex, detail);\n result.invalidate(false); // detail might be owned by result!\n result._facetIndex = facetIndex;\n if (undefined !== detail)\n result._detail.copyContentsFrom(detail);\n return result;\n }\n /** Get the facet index. */\n public get facetIndex(): number {\n return this._facetIndex;\n }\n /** Get the edge count of this facet. */\n public get edgeCount(): number {\n return 3;\n }\n /** Get the world coordinates of the point. */\n public get point(): Point3d {\n return this._detail.world;\n }\n /** Get the application-specific number. */\n public get a(): number {\n return this._detail.a;\n }\n /** Get the projection of the point onto the closest facet edge. */\n public get closestEdge(): { startVertexIndex: number, edgeParam: number } {\n return { startVertexIndex: this._detail.closestEdgeIndex, edgeParam: this._detail.closestEdgeParam };\n }\n /** Test validity of fields other than _detail. */\n private get _isValid(): boolean {\n return this._facetIndex >= 0;\n }\n /** Whether this instance specifies a valid location. */\n public get isValid(): boolean {\n return this._isValid && this._detail.isValid;\n }\n /** Whether the facet is convex. */\n public get isConvex(): boolean {\n return true;\n }\n /** Whether the point is inside or on the polygon. */\n public get isInsideOrOn(): boolean {\n return this._isValid && this._detail.isInsideOrOn;\n }\n /** Get the code that classifies the location of the point with respect to the facet. */\n public get classify(): PolygonLocation {\n return this._detail.classify;\n }\n /** Clone the instance */\n public clone(): TriangularFacetLocationDetail {\n const detail = new TriangularFacetLocationDetail();\n detail.copyContentsFrom(this);\n return detail;\n }\n /** Set the instance contents from the other detail.\n * @param other detail to clone\n */\n public copyContentsFrom(other: TriangularFacetLocationDetail) {\n this._facetIndex = other._facetIndex;\n this._detail.copyContentsFrom(other._detail);\n this._normal = other._normal?.clone();\n this._param = other._param?.clone();\n this._color = other._color;\n }\n /** Get normal interpolated from facet data.\n * @param facetNormals used to compute the normal cache\n * @returns reference to cached normal\n */\n public getNormal(facetNormals?: IndexedXYZCollection): Vector3d | undefined {\n if (this._detail.isValid && undefined === this._normal && undefined !== facetNormals) {\n this._normal = Vector3d.create();\n const scales = [this._detail.local.x, this._detail.local.y, this._detail.local.z];\n facetNormals.linearCombination(scales, this._normal);\n }\n return this._normal;\n }\n /** Get uv parameter interpolated from facet data.\n * @param facetParams used to compute the uv parameter cache\n * @returns reference to cached uv parameter\n */\n public getParam(facetParams?: IndexedXYCollection): Point2d | undefined {\n if (this._detail.isValid && undefined === this._param && undefined !== facetParams) {\n this._param = Point2d.create();\n const scales = [this._detail.local.x, this._detail.local.y, this._detail.local.z];\n facetParams.linearCombination(scales, this._param);\n }\n return this._param;\n }\n /** Get color interpolated from facet data.\n * * Assumes barycentric coordinates are already computed in the TriangleLocationDetail member.\n * @param facetColors used to compute the color cache\n * @returns cached color\n */\n public getColor(facetColors?: number[]): number | undefined {\n if (this._detail.isValid && undefined === this._color && undefined !== facetColors) {\n const scales = [this._detail.local.x, this._detail.local.y, this._detail.local.z];\n this._color = NumberArray.linearCombinationOfColors(facetColors, scales);\n }\n return this._color;\n }\n /** Get the barycentric coordinates of this location.\n * @returns cached barycentric coordinates\n */\n public getBarycentricCoordinates(): number[] {\n return [this._detail.local.x, this._detail.local.y, this._detail.local.z];\n }\n}\n/**\n * Implementation of `FacetLocationDetail` for a non-convex facet.\n * * Facet vertex data interpolation is not available.\n * @public\n */\nexport class NonConvexFacetLocationDetail implements FacetLocationDetail {\n private _facetIndex: number;\n private _edgeCount: number;\n protected _detail: PolygonLocationDetail;\n\n /** captures the detail if provided */\n protected constructor(facetIndex: number = -1, edgeCount: number = 0, detail?: PolygonLocationDetail) {\n this._facetIndex = facetIndex;\n this._edgeCount = edgeCount;\n this._detail = detail ? detail : PolygonLocationDetail.create();\n }\n /** Invalidate this detail. */\n public invalidate(deep: boolean = true) {\n this._facetIndex = -1;\n this._edgeCount = 0;\n if (deep)\n this._detail.invalidate();\n }\n /** Create a detail.\n * @param result optional pre-allocated object to fill and return\n */\n public static create(facetIndex: number, edgeCount: number, detail?: PolygonLocationDetail, result?: NonConvexFacetLocationDetail): NonConvexFacetLocationDetail {\n if (undefined === result)\n return new NonConvexFacetLocationDetail(facetIndex, edgeCount, detail);\n result.invalidate(false); // detail might be owned by result!\n result._facetIndex = facetIndex;\n result._edgeCount = edgeCount;\n if (undefined !== detail && result._detail !== detail)\n result._detail.copyContentsFrom(detail);\n return result;\n }\n /** Get the facet index. */\n public get facetIndex(): number {\n return this._facetIndex;\n }\n /** Get the edge count of this facet. */\n public get edgeCount(): number {\n return this._edgeCount;\n }\n /** Get the world coordinates of the point. */\n public get point(): Point3d {\n return this._detail.point;\n }\n /** Get the application-specific number. */\n public get a(): number {\n return this._detail.a;\n }\n /** Get the projection of the point onto the closest facet edge. */\n public get closestEdge(): { startVertexIndex: number, edgeParam: number } {\n return { startVertexIndex: this._detail.closestEdgeIndex, edgeParam: this._detail.closestEdgeParam };\n }\n /** Test validity of fields other than _detail. */\n private get _isValid(): boolean {\n return this._facetIndex >= 0 && this._edgeCount >= 3;\n }\n /** Whether this instance specifies a valid location. */\n public get isValid(): boolean {\n return this._isValid && this._detail.isValid;\n }\n /** Whether the facet is convex. */\n public get isConvex(): boolean {\n return false;\n }\n /** Whether the point is inside or on the polygon. */\n public get isInsideOrOn(): boolean {\n return this._isValid && this._detail.isInsideOrOn;\n }\n /** Get the code that classifies the location of the point with respect to the facet. */\n public get classify(): PolygonLocation {\n return this._detail.code;\n }\n /** Clone the instance */\n public clone(): NonConvexFacetLocationDetail {\n const detail = new NonConvexFacetLocationDetail();\n detail.copyContentsFrom(this);\n return detail;\n }\n /** Set the instance contents from the other detail.\n * @param other detail to clone\n */\n public copyContentsFrom(other: NonConvexFacetLocationDetail) {\n this._facetIndex = other._facetIndex;\n this._edgeCount = other._edgeCount;\n this._detail.copyContentsFrom(other._detail);\n }\n /** Interpolated data is not defined for a non-convex facet.\n * @returns undefined\n */\n public getNormal(): Vector3d | undefined {\n return undefined;\n }\n /** Interpolated data is not defined for a non-convex facet.\n * @returns undefined\n */\n public getParam(): Point2d | undefined {\n return undefined;\n }\n /** Interpolated data is not defined for a non-convex facet.\n * @returns undefined\n */\n public getColor(): number | undefined {\n return undefined;\n }\n /** Barycentric coordinates are not defined for a non-convex facet.\n * @returns undefined\n */\n public getBarycentricCoordinates(): number[] | undefined {\n return undefined;\n }\n}\n/**\n * Implementation of `FacetLocationDetail` for a convex facet.\n * * If `edgeCount` is 3, `TriangularFacetLocationDetail` is more efficient.\n * @public\n */\nexport class ConvexFacetLocationDetail extends NonConvexFacetLocationDetail {\n private _normal?: Vector3d;\n private _param?: Point2d;\n private _color?: number;\n private _barycentricCoordinates?: number[];\n\n /** captures the detail if provided */\n private constructor(facetIndex: number = -1, edgeCount: number = 0, detail?: PolygonLocationDetail) {\n super(facetIndex, edgeCount, detail);\n }\n /** Invalidate this detail. */\n public override invalidate(deep: boolean = true) {\n super.invalidate(deep);\n this._normal = undefined;\n this._param = undefined;\n this._color = undefined;\n this._barycentricCoordinates = undefined;\n }\n /** Create a detail.\n * @param result optional pre-allocated object to fill and return\n */\n public static override create(facetIndex: number, edgeCount: number, detail?: PolygonLocationDetail, result?: ConvexFacetLocationDetail): ConvexFacetLocationDetail {\n if (undefined === result)\n return new ConvexFacetLocationDetail(facetIndex, edgeCount, detail);\n return super.create(facetIndex, edgeCount, detail, result);\n }\n /** Whether the facet is convex. */\n public override get isConvex(): boolean {\n return true;\n }\n /** Clone the instance */\n public override clone(): ConvexFacetLocationDetail {\n const detail = new ConvexFacetLocationDetail();\n detail.copyContentsFrom(this);\n return detail;\n }\n /** Set the instance contents from the other detail.\n * @param other detail to clone\n */\n public override copyContentsFrom(other: ConvexFacetLocationDetail) {\n super.copyContentsFrom(other);\n this._normal = other._normal?.clone();\n this._param = other._param?.clone();\n this._color = other._color;\n this._barycentricCoordinates = other._barycentricCoordinates?.slice();\n }\n /** Get normal interpolated from facet data.\n * @param facetNormals used to compute the normal cache\n * @param facetVertices used to compute the barycentric coordinate cache\n * @param distanceTolerance used to compute the barycentric coordinate cache\n * @returns reference to cached normal\n */\n public override getNormal(facetNormals?: IndexedXYZCollection, facetVertices?: IndexedXYZCollection, distanceTolerance: number = Geometry.smallMetricDistance): Vector3d | undefined {\n if (this._detail.isValid && undefined === this._normal && undefined !== facetNormals) {\n const scales = this.getBarycentricCoordinates(facetVertices, distanceTolerance);\n if (undefined !== scales) {\n this._normal = Vector3d.create();\n facetNormals.linearCombination(scales, this._normal);\n }\n }\n return this._normal;\n }\n /** Get uv parameter interpolated from facet data.\n * @param facetParams used to compute the uv parameter cache\n * @param facetVertices used to compute the barycentric coordinate cache\n * @param distanceTolerance used to compute the barycentric coordinate cache\n * @returns reference to cached uv parameter\n */\n public override getParam(facetParams?: IndexedXYCollection, facetVertices?: IndexedXYZCollection, distanceTolerance: number = Geometry.smallMetricDistance): Point2d | undefined {\n if (this._detail.isValid && undefined === this._param && undefined !== facetParams) {\n const scales = this.getBarycentricCoordinates(facetVertices, distanceTolerance);\n if (undefined !== scales) {\n this._param = Point2d.create();\n facetParams.linearCombination(scales, this._param);\n }\n }\n return this._param;\n }\n /** Get color interpolated from facet data.\n * @param facetColors used to compute the color cache\n * @param facetVertices used to compute the barycentric coordinate cache\n * @param distanceTolerance used to compute the barycentric coordinate cache\n * @returns cached color\n */\n public override getColor(facetColors?: number[], facetVertices?: IndexedXYZCollection, distanceTolerance: number = Geometry.smallMetricDistance): number | undefined {\n if (this._detail.isValid && undefined === this._color && undefined !== facetColors) {\n const scales = this.getBarycentricCoordinates(facetVertices, distanceTolerance);\n if (undefined !== scales)\n this._color = NumberArray.linearCombinationOfColors(facetColors, scales);\n }\n return this._color;\n }\n /** Get the barycentric coordinates of this location, if they have been computed.\n * @param facetVertices used to compute the barycentric coordinate cache\n * @param distanceTolerance used to compute the barycentric coordinate cache\n * @returns cached barycentric coordinates\n */\n public override getBarycentricCoordinates(facetVertices?: IndexedXYZCollection, distanceTolerance: number = Geometry.smallMetricDistance): number[] | undefined {\n if (this._detail.isValid && undefined === this._barycentricCoordinates && undefined !== facetVertices) {\n this._barycentricCoordinates = PolygonOps.convexBarycentricCoordinates(facetVertices, this._detail.point, distanceTolerance);\n }\n return this._barycentricCoordinates;\n }\n}\n"]}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Polyface
|
|
3
|
-
*/
|
|
4
1
|
import { Point2d } from "../geometry3d/Point2dVector2d";
|
|
5
|
-
import { PolyfaceData } from "./PolyfaceData";
|
|
6
2
|
import { IndexedPolyface, Polyface, PolyfaceVisitor } from "./Polyface";
|
|
3
|
+
import { PolyfaceData } from "./PolyfaceData";
|
|
7
4
|
/**
|
|
8
5
|
* An `IndexedPolyfaceVisitor` is an iterator-like object that "visits" facets of a mesh.
|
|
9
6
|
* * The visitor extends a `PolyfaceData ` class, so it can at any time hold all the data of a single facet.
|
|
@@ -21,7 +18,7 @@ export declare class IndexedPolyfaceVisitor extends PolyfaceData implements Poly
|
|
|
21
18
|
/** Set the number of vertices duplicated (e.g. 1 for start and end) in arrays in the visitor. */
|
|
22
19
|
setNumWrap(numWrap: number): void;
|
|
23
20
|
/** Return the number of edges in the current facet.
|
|
24
|
-
* *
|
|
21
|
+
* * Note that if this visitor has `numWrap` greater than zero, the number of edges is smaller than the number of points.
|
|
25
22
|
*/
|
|
26
23
|
get numEdgesThisFacet(): number;
|
|
27
24
|
/** Create a visitor for iterating the facets of `polyface`, with indicated number of points to be added to each facet to produce closed point arrays
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexedPolyfaceVisitor.d.ts","sourceRoot":"","sources":["../../../src/polyface/IndexedPolyfaceVisitor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IndexedPolyfaceVisitor.d.ts","sourceRoot":"","sources":["../../../src/polyface/IndexedPolyfaceVisitor.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI9C;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,YAAa,YAAW,eAAe;IACjF,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,eAAe,CA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MAAM,GAAG,IAAI;IAShE;;OAEG;IACI,wBAAwB,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;CAShH;AAoBD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAgBhF;AAED;;;;;;;GAOG;AACH,qBAAa,4BAA6B,SAAQ,sBAAsB;IACtE,OAAO,CAAC,mBAAmB,CAAW;IAEtC,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO;IAKP;;;;;;OAMG;WACW,mBAAmB,CAAC,QAAQ,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,4BAA4B;IAGzI,wEAAwE;IACxD,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAO7D,wEAAwE;IACxD,eAAe,IAAI,OAAO;IAU1C,sEAAsE;IACtD,KAAK,IAAI,IAAI;IAG7B,oFAAoF;IAC7E,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAMjE"}
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module Polyface
|
|
7
|
+
*/
|
|
6
8
|
import { Geometry } from "../Geometry";
|
|
9
|
+
import { PolyfaceData } from "./PolyfaceData";
|
|
7
10
|
/* eslint-disable @itwin/prefer-get */
|
|
8
11
|
/**
|
|
9
12
|
* An `IndexedPolyfaceVisitor` is an iterator-like object that "visits" facets of a mesh.
|
|
@@ -28,7 +31,7 @@ export class IndexedPolyfaceVisitor extends PolyfaceData {
|
|
|
28
31
|
/** Set the number of vertices duplicated (e.g. 1 for start and end) in arrays in the visitor. */
|
|
29
32
|
setNumWrap(numWrap) { this._numWrap = numWrap; }
|
|
30
33
|
/** Return the number of edges in the current facet.
|
|
31
|
-
* *
|
|
34
|
+
* * Note that if this visitor has `numWrap` greater than zero, the number of edges is smaller than the number of points.
|
|
32
35
|
*/
|
|
33
36
|
get numEdgesThisFacet() { return this._numEdges; }
|
|
34
37
|
/** Create a visitor for iterating the facets of `polyface`, with indicated number of points to be added to each facet to produce closed point arrays
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexedPolyfaceVisitor.js","sourceRoot":"","sources":["../../../src/polyface/IndexedPolyfaceVisitor.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAM/F,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,sCAAsC;AACtC;;;;GAIG;AACH,MAAM,OAAO,sBAAuB,SAAQ,YAAY;IAMtD,0EAA0E;IAC1E,YAAsB,MAAuB,EAAE,OAAe;QAC5D,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,GAAG,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC5G,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO;YACrB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAExD,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,eAAe,GAAG,CAA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AAmB,CAAC,MAAM,EAAE;YACtE,IAAI,CAAC,gBAAgB,GAAG,WAAW,CAAC;YACpC,OAAO,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,mBAAmB,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;SACvE;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,wEAAwE;IACxD,eAAe;QAC7B,IAAI,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE;YAC3D,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YAC3D,IAAI,MAAM,EAAE;gBACV,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACxB,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,sEAAsE;IACtD,KAAK;QACnB,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;IAC5B,CAAC;IACD,oFAAoF;IAC7E,gBAAgB,CAAC,WAAmB;QACzC,IAAI,WAAW,IAAI,CAAC,IAAI,WAAW,IAAI,IAAI,CAAC,gBAAgB,EAAE;YAC5D,OAAO,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;SAC9C;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Polyface\n */\nimport { Point2d } from \"../geometry3d/Point2dVector2d\";\nimport { PolyfaceData } from \"./PolyfaceData\";\nimport { IndexedPolyface, Polyface, PolyfaceVisitor } from \"./Polyface\";\nimport { Geometry } from \"../Geometry\";\n/* eslint-disable @itwin/prefer-get */\n/**\n * An `IndexedPolyfaceVisitor` is an iterator-like object that \"visits\" facets of a mesh.\n * * The visitor extends a `PolyfaceData ` class, so it can at any time hold all the data of a single facet.\n * @public\n */\nexport class IndexedPolyfaceVisitor extends PolyfaceData implements PolyfaceVisitor {\n private _currentFacetIndex: number;\n private _nextFacetIndex: number;\n private _numWrap: number;\n private _numEdges: number;\n private _polyface: IndexedPolyface;\n // to be called from static factory method that validates the polyface ...\n protected constructor(facets: IndexedPolyface, numWrap: number) {\n super(facets.data.normalCount > 0, facets.data.paramCount > 0, facets.data.colorCount > 0, facets.twoSided);\n this._polyface = facets;\n this._numWrap = numWrap;\n if (facets.data.auxData)\n this.auxData = facets.data.auxData.createForVisitor();\n\n this.reset();\n this._numEdges = 0;\n this._nextFacetIndex = 0;\n this._currentFacetIndex = -1;\n\n }\n /** Return the client polyface object. */\n public clientPolyface(): Polyface { return this._polyface; }\n /** Set the number of vertices duplicated (e.g. 1 for start and end) in arrays in the visitor. */\n public setNumWrap(numWrap: number) { this._numWrap = numWrap; }\n\n /** Return the number of edges in the current facet.\n * * Not that if this visitor has `numWrap` greater than zero, the number of edges is smaller than the number of points.\n */\n public get numEdgesThisFacet(): number { return this._numEdges; }\n /** Create a visitor for iterating the facets of `polyface`, with indicated number of points to be added to each facet to produce closed point arrays\n * Typical wrap counts are:\n * * 0 -- leave the point arrays with \"missing final edge\"\n * * 1 -- add point 0 as closure point\n * * 2 -- add points 0 and 1 as closure and wrap point. This is useful when vertex visit requires two adjacent vectors, e.g. for cross products.\n */\n public static create(polyface: IndexedPolyface, numWrap: number): IndexedPolyfaceVisitor {\n return new IndexedPolyfaceVisitor(polyface, numWrap);\n }\n /** Advance the iterator to a particular facet in the client polyface */\n public moveToReadIndex(facetIndex: number): boolean {\n if (!this._polyface.isValidFacetIndex(facetIndex))\n return false;\n this._currentFacetIndex = facetIndex;\n this._nextFacetIndex = facetIndex + 1;\n this._numEdges = this._polyface.numEdgeInFacet(facetIndex);\n this.resizeAllDataArrays(this._numEdges + this._numWrap);\n this.gatherIndexedData(this._polyface.data, this._polyface.facetIndex0(this._currentFacetIndex), this._polyface.facetIndex1(this._currentFacetIndex), this._numWrap);\n return true;\n }\n /** Advance the iterator to a the 'next' facet in the client polyface */\n public moveToNextFacet(): boolean {\n if (this._nextFacetIndex !== this._currentFacetIndex)\n return this.moveToReadIndex(this._nextFacetIndex);\n this._nextFacetIndex++;\n return true;\n }\n\n /** Reset the iterator to start at the first facet of the polyface. */\n public reset(): void {\n this.moveToReadIndex(0);\n this._nextFacetIndex = 0; // so immediate moveToNextFacet stays here.\n }\n\n /**\n * Attempts to extract the distance parameter for the given vertex index on the current facet\n * Returns the distance parameter as a point. Returns undefined on failure.\n */\n public tryGetDistanceParameter(index: number, result?: Point2d): Point2d | undefined {\n if (index >= this.numEdgesThisFacet)\n return undefined;\n\n if (this.param === undefined || this._polyface.data.face.length === 0)\n return undefined;\n\n const faceData = this._polyface.tryGetFaceData(this._currentFacetIndex);\n if (!faceData)\n return undefined;\n return faceData.convertParamXYToDistance(this.param.getXAtUncheckedPointIndex(index), this.param.getYAtUncheckedPointIndex(index), result);\n }\n\n /**\n * Attempts to extract the normalized parameter (0,1) for the given vertex index on the current facet.\n * Returns the normalized parameter as a point. Returns undefined on failure.\n */\n public tryGetNormalizedParameter(index: number, result?: Point2d): Point2d | undefined {\n if (index >= this.numEdgesThisFacet)\n return undefined;\n\n if (this.param === undefined || this._polyface.data.face.length === 0)\n return undefined;\n\n const faceData = this._polyface.tryGetFaceData(this._currentFacetIndex);\n if (!faceData)\n return undefined;\n return faceData.convertParamXYToNormalized(this.param.getXAtUncheckedPointIndex(index), this.param.getYAtUncheckedPointIndex(index), result);\n }\n /** Return the index (in the client polyface) of the current facet */\n public currentReadIndex(): number { return this._currentFacetIndex; }\n /** Return the point index of vertex i within the currently loaded facet */\n public clientPointIndex(i: number): number { return this.pointIndex[i]; }\n /** Return the param index of vertex i within the currently loaded facet */\n public clientParamIndex(i: number): number { return this.paramIndex ? this.paramIndex[i] : -1; }\n /** Return the normal index of vertex i within the currently loaded facet */\n public clientNormalIndex(i: number): number { return this.normalIndex ? this.normalIndex[i] : -1; }\n /** Return the color index of vertex i within the currently loaded facet */\n public clientColorIndex(i: number): number { return this.colorIndex ? this.colorIndex[i] : -1; }\n /** Return the aux data index of vertex i within the currently loaded facet */\n public clientAuxIndex(i: number): number { return this.auxData ? this.auxData.indices[i] : -1; }\n\n /** clear the contents of all arrays. Use this along with transferDataFrom methods to build up new facets */\n public clearArrays(): void {\n if (this.point !== undefined)\n this.point.length = 0;\n if (this.param !== undefined)\n this.param.length = 0;\n if (this.normal !== undefined)\n this.normal.length = 0;\n if (this.color !== undefined)\n this.color.length = 0;\n }\n /** transfer data from a specified index of the other visitor as new data in this visitor. */\n public pushDataFrom(other: PolyfaceVisitor, index: number): void {\n this.point.pushFromGrowableXYZArray(other.point, index);\n if (this.color && other.color && index < other.color.length)\n this.color.push(other.color[index]);\n if (this.param && other.param && index < other.param.length)\n this.param.pushFromGrowableXYArray(other.param, index);\n if (this.normal && other.normal && index < other.normal.length)\n this.normal.pushFromGrowableXYZArray(other.normal, index);\n }\n /** transfer interpolated data from the other visitor.\n * * all data values are interpolated at `fraction` between `other` values at index0 and index1.\n */\n public pushInterpolatedDataFrom(other: PolyfaceVisitor, index0: number, fraction: number, index1: number): void {\n this.point.pushInterpolatedFromGrowableXYZArray(other.point, index0, fraction, index1);\n if (this.color && other.color && index0 < other.color.length && index1 < other.color.length)\n this.color.push(interpolateColor(other.color[index0], fraction, other.color[index1]));\n if (this.param && other.param && index0 < other.param.length && index1 < other.param.length)\n this.param.pushInterpolatedFromGrowableXYArray(other.param, index0, fraction, index1);\n if (this.normal && other.normal && index0 < other.normal.length && index1 < other.normal.length)\n this.normal.pushInterpolatedFromGrowableXYZArray(other.normal, index0, fraction, index1);\n }\n}\n/**\n * * shift to right by shiftBits.\n * * mask off the low 8 bits\n * * interpolate the number\n * * truncate to floor\n * * shift left\n * * Hence all numbers in and out of the floating point are 0..255.\n * @param color0\n * @param fraction\n * @param color1\n * @param shiftBits\n */\nfunction interpolateByte(color0: number, fraction: number, color1: number, shiftBits: number): number {\n color0 = (color0 >>> shiftBits) & 0xFF;\n color1 = (color1 >>> shiftBits) & 0xFF;\n const color = Math.floor(color0 + fraction * (color1 - color0)) & 0xFF;\n return color << shiftBits;\n}\n\n/**\n * Interpolate each byte of color0 and color1 as integers.\n * @param color0 32 bit color (e.g. rgb+transparency)\n * @param fraction fractional position. This is clamped to 0..1 to prevent byte values outside their 0..255 range.\n * @param color1\n * @param shiftBits\n * @internal\n */\nexport function interpolateColor(color0: number, fraction: number, color1: number) {\n // don't allow fractions outside the individual byte ranges.\n fraction = Geometry.clamp(fraction, 0, 1);\n // interpolate each byte in place ....\n /*\n const byte0 = interpolateLowByte(color0 & 0xFF, fraction, color1 & 0xFF);\n const byte1 = interpolateLowByte((color0 & 0xFF00) >>> 8, fraction, (color1 & 0xFF00) >>> 8) << 8;\n const byte2 = interpolateLowByte((color0 & 0xFF0000) >>> 16, fraction, (color1 & 0xFF0000) >>> 16) << 16;\n const byte3 = interpolateLowByte((color0 & 0xFF000000) >>> 24, fraction, (color1 & 0xFF000000) >>> 24) << 24;\n */\n const byte0 = interpolateByte(color0, fraction, color1, 0);\n const byte1 = interpolateByte(color0, fraction, color1, 8);\n const byte2 = interpolateByte(color0, fraction, color1, 16);\n const byte3 = interpolateByte(color0, fraction, color1, 24);\n\n return (byte0 | byte1 | byte2 | byte3);\n}\n\n/**\n * An `IndexedPolyfaceSubsetVisitor` is an IndexedPolyfaceVisitor which only visits a subset of facets in the polyface.\n * * The subset is defined by an array of facet indices provided when this visitor is created.\n * * Within the subset visitor, \"facetIndex\" is understood as index within the subset array:\n * * moveToNextFacet moves only within the subset\n * * moveToReadIndex(i) moves underlying visitor's parentFacetIndex(i)\n * @public\n */\nexport class IndexedPolyfaceSubsetVisitor extends IndexedPolyfaceVisitor {\n private _parentFacetIndices: number[];\n // index WITHIN THE _parentFacetIndices array.\n private _nextActiveIndex: number;\n private constructor(polyface: IndexedPolyface, activeFacetIndices: number[], numWrap: number) {\n super(polyface, numWrap);\n this._parentFacetIndices = activeFacetIndices.slice();\n this._nextActiveIndex = 0;\n }\n /** Create a visitor for iterating a subset of the facets of `polyface`, with indicated number of points to be added to each facet to produce closed point arrays\n * * Typical wrap counts are:\n * * 0 -- leave the point arrays with \"missing final edge\"\n * * 1 -- add point 0 as closure point\n * * 2 -- add points 0 and 1 as closure and wrap point. This is useful when vertex visit requires two adjacent vectors, e.g. for cross products.\n * * The activeFacetIndices array indicates all facets to be visited.\n */\n public static createSubsetVisitor(polyface: IndexedPolyface, activeFacetIndices: number[], numWrap: number): IndexedPolyfaceSubsetVisitor {\n return new IndexedPolyfaceSubsetVisitor(polyface, activeFacetIndices, numWrap);\n }\n /** Advance the iterator to a particular facet in the client polyface */\n public override moveToReadIndex(activeIndex: number): boolean {\n if (activeIndex >= 0 && activeIndex <= this._parentFacetIndices.length) {\n this._nextActiveIndex = activeIndex;\n return super.moveToReadIndex(this._parentFacetIndices[activeIndex++]);\n }\n return false;\n }\n /** Advance the iterator to a the 'next' facet in the client polyface */\n public override moveToNextFacet(): boolean {\n if (this._nextActiveIndex < this._parentFacetIndices.length) {\n const result = this.moveToReadIndex(this._nextActiveIndex);\n if (result) {\n this._nextActiveIndex++;\n return true;\n }\n }\n return false;\n }\n /** Reset the iterator to start at the first facet of the polyface. */\n public override reset(): void {\n this._nextActiveIndex = 0;\n }\n /** return the parent facet index of the indicated index within the active facets */\n public parentFacetIndex(activeIndex: number): number | undefined {\n if (activeIndex >= 0 && activeIndex <= this._nextActiveIndex) {\n return this._parentFacetIndices[activeIndex];\n }\n return undefined;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IndexedPolyfaceVisitor.js","sourceRoot":"","sources":["../../../src/polyface/IndexedPolyfaceVisitor.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,sC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;IACD,oFAAoF;IAC7E,gBAAgB,CAAC,WAAmB;QACzC,IAAI,WAAW,IAAI,CAAC,IAAI,WAAW,IAAI,IAAI,CAAC,gBAAgB,EAAE;YAC5D,OAAO,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;SAC9C;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Polyface\n */\n\nimport { Geometry } from \"../Geometry\";\nimport { Point2d } from \"../geometry3d/Point2dVector2d\";\nimport { IndexedPolyface, Polyface, PolyfaceVisitor } from \"./Polyface\";\nimport { PolyfaceData } from \"./PolyfaceData\";\n\n/* eslint-disable @itwin/prefer-get */\n\n/**\n * An `IndexedPolyfaceVisitor` is an iterator-like object that \"visits\" facets of a mesh.\n * * The visitor extends a `PolyfaceData ` class, so it can at any time hold all the data of a single facet.\n * @public\n */\nexport class IndexedPolyfaceVisitor extends PolyfaceData implements PolyfaceVisitor {\n private _currentFacetIndex: number;\n private _nextFacetIndex: number;\n private _numWrap: number;\n private _numEdges: number;\n private _polyface: IndexedPolyface;\n // to be called from static factory method that validates the polyface ...\n protected constructor(facets: IndexedPolyface, numWrap: number) {\n super(facets.data.normalCount > 0, facets.data.paramCount > 0, facets.data.colorCount > 0, facets.twoSided);\n this._polyface = facets;\n this._numWrap = numWrap;\n if (facets.data.auxData)\n this.auxData = facets.data.auxData.createForVisitor();\n\n this.reset();\n this._numEdges = 0;\n this._nextFacetIndex = 0;\n this._currentFacetIndex = -1;\n\n }\n /** Return the client polyface object. */\n public clientPolyface(): Polyface { return this._polyface; }\n /** Set the number of vertices duplicated (e.g. 1 for start and end) in arrays in the visitor. */\n public setNumWrap(numWrap: number) { this._numWrap = numWrap; }\n\n /** Return the number of edges in the current facet.\n * * Note that if this visitor has `numWrap` greater than zero, the number of edges is smaller than the number of points.\n */\n public get numEdgesThisFacet(): number { return this._numEdges; }\n /** Create a visitor for iterating the facets of `polyface`, with indicated number of points to be added to each facet to produce closed point arrays\n * Typical wrap counts are:\n * * 0 -- leave the point arrays with \"missing final edge\"\n * * 1 -- add point 0 as closure point\n * * 2 -- add points 0 and 1 as closure and wrap point. This is useful when vertex visit requires two adjacent vectors, e.g. for cross products.\n */\n public static create(polyface: IndexedPolyface, numWrap: number): IndexedPolyfaceVisitor {\n return new IndexedPolyfaceVisitor(polyface, numWrap);\n }\n /** Advance the iterator to a particular facet in the client polyface */\n public moveToReadIndex(facetIndex: number): boolean {\n if (!this._polyface.isValidFacetIndex(facetIndex))\n return false;\n this._currentFacetIndex = facetIndex;\n this._nextFacetIndex = facetIndex + 1;\n this._numEdges = this._polyface.numEdgeInFacet(facetIndex);\n this.resizeAllDataArrays(this._numEdges + this._numWrap);\n this.gatherIndexedData(this._polyface.data, this._polyface.facetIndex0(this._currentFacetIndex), this._polyface.facetIndex1(this._currentFacetIndex), this._numWrap);\n return true;\n }\n /** Advance the iterator to a the 'next' facet in the client polyface */\n public moveToNextFacet(): boolean {\n if (this._nextFacetIndex !== this._currentFacetIndex)\n return this.moveToReadIndex(this._nextFacetIndex);\n this._nextFacetIndex++;\n return true;\n }\n\n /** Reset the iterator to start at the first facet of the polyface. */\n public reset(): void {\n this.moveToReadIndex(0);\n this._nextFacetIndex = 0; // so immediate moveToNextFacet stays here.\n }\n\n /**\n * Attempts to extract the distance parameter for the given vertex index on the current facet\n * Returns the distance parameter as a point. Returns undefined on failure.\n */\n public tryGetDistanceParameter(index: number, result?: Point2d): Point2d | undefined {\n if (index >= this.numEdgesThisFacet)\n return undefined;\n\n if (this.param === undefined || this._polyface.data.face.length === 0)\n return undefined;\n\n const faceData = this._polyface.tryGetFaceData(this._currentFacetIndex);\n if (!faceData)\n return undefined;\n return faceData.convertParamXYToDistance(this.param.getXAtUncheckedPointIndex(index), this.param.getYAtUncheckedPointIndex(index), result);\n }\n\n /**\n * Attempts to extract the normalized parameter (0,1) for the given vertex index on the current facet.\n * Returns the normalized parameter as a point. Returns undefined on failure.\n */\n public tryGetNormalizedParameter(index: number, result?: Point2d): Point2d | undefined {\n if (index >= this.numEdgesThisFacet)\n return undefined;\n\n if (this.param === undefined || this._polyface.data.face.length === 0)\n return undefined;\n\n const faceData = this._polyface.tryGetFaceData(this._currentFacetIndex);\n if (!faceData)\n return undefined;\n return faceData.convertParamXYToNormalized(this.param.getXAtUncheckedPointIndex(index), this.param.getYAtUncheckedPointIndex(index), result);\n }\n /** Return the index (in the client polyface) of the current facet */\n public currentReadIndex(): number { return this._currentFacetIndex; }\n /** Return the point index of vertex i within the currently loaded facet */\n public clientPointIndex(i: number): number { return this.pointIndex[i]; }\n /** Return the param index of vertex i within the currently loaded facet */\n public clientParamIndex(i: number): number { return this.paramIndex ? this.paramIndex[i] : -1; }\n /** Return the normal index of vertex i within the currently loaded facet */\n public clientNormalIndex(i: number): number { return this.normalIndex ? this.normalIndex[i] : -1; }\n /** Return the color index of vertex i within the currently loaded facet */\n public clientColorIndex(i: number): number { return this.colorIndex ? this.colorIndex[i] : -1; }\n /** Return the aux data index of vertex i within the currently loaded facet */\n public clientAuxIndex(i: number): number { return this.auxData ? this.auxData.indices[i] : -1; }\n\n /** clear the contents of all arrays. Use this along with transferDataFrom methods to build up new facets */\n public clearArrays(): void {\n if (this.point !== undefined)\n this.point.length = 0;\n if (this.param !== undefined)\n this.param.length = 0;\n if (this.normal !== undefined)\n this.normal.length = 0;\n if (this.color !== undefined)\n this.color.length = 0;\n }\n /** transfer data from a specified index of the other visitor as new data in this visitor. */\n public pushDataFrom(other: PolyfaceVisitor, index: number): void {\n this.point.pushFromGrowableXYZArray(other.point, index);\n if (this.color && other.color && index < other.color.length)\n this.color.push(other.color[index]);\n if (this.param && other.param && index < other.param.length)\n this.param.pushFromGrowableXYArray(other.param, index);\n if (this.normal && other.normal && index < other.normal.length)\n this.normal.pushFromGrowableXYZArray(other.normal, index);\n }\n /** transfer interpolated data from the other visitor.\n * * all data values are interpolated at `fraction` between `other` values at index0 and index1.\n */\n public pushInterpolatedDataFrom(other: PolyfaceVisitor, index0: number, fraction: number, index1: number): void {\n this.point.pushInterpolatedFromGrowableXYZArray(other.point, index0, fraction, index1);\n if (this.color && other.color && index0 < other.color.length && index1 < other.color.length)\n this.color.push(interpolateColor(other.color[index0], fraction, other.color[index1]));\n if (this.param && other.param && index0 < other.param.length && index1 < other.param.length)\n this.param.pushInterpolatedFromGrowableXYArray(other.param, index0, fraction, index1);\n if (this.normal && other.normal && index0 < other.normal.length && index1 < other.normal.length)\n this.normal.pushInterpolatedFromGrowableXYZArray(other.normal, index0, fraction, index1);\n }\n}\n/**\n * * shift to right by shiftBits.\n * * mask off the low 8 bits\n * * interpolate the number\n * * truncate to floor\n * * shift left\n * * Hence all numbers in and out of the floating point are 0..255.\n * @param color0\n * @param fraction\n * @param color1\n * @param shiftBits\n */\nfunction interpolateByte(color0: number, fraction: number, color1: number, shiftBits: number): number {\n color0 = (color0 >>> shiftBits) & 0xFF;\n color1 = (color1 >>> shiftBits) & 0xFF;\n const color = Math.floor(color0 + fraction * (color1 - color0)) & 0xFF;\n return color << shiftBits;\n}\n\n/**\n * Interpolate each byte of color0 and color1 as integers.\n * @param color0 32 bit color (e.g. rgb+transparency)\n * @param fraction fractional position. This is clamped to 0..1 to prevent byte values outside their 0..255 range.\n * @param color1\n * @param shiftBits\n * @internal\n */\nexport function interpolateColor(color0: number, fraction: number, color1: number) {\n // don't allow fractions outside the individual byte ranges.\n fraction = Geometry.clamp(fraction, 0, 1);\n // interpolate each byte in place ....\n /*\n const byte0 = interpolateLowByte(color0 & 0xFF, fraction, color1 & 0xFF);\n const byte1 = interpolateLowByte((color0 & 0xFF00) >>> 8, fraction, (color1 & 0xFF00) >>> 8) << 8;\n const byte2 = interpolateLowByte((color0 & 0xFF0000) >>> 16, fraction, (color1 & 0xFF0000) >>> 16) << 16;\n const byte3 = interpolateLowByte((color0 & 0xFF000000) >>> 24, fraction, (color1 & 0xFF000000) >>> 24) << 24;\n */\n const byte0 = interpolateByte(color0, fraction, color1, 0);\n const byte1 = interpolateByte(color0, fraction, color1, 8);\n const byte2 = interpolateByte(color0, fraction, color1, 16);\n const byte3 = interpolateByte(color0, fraction, color1, 24);\n\n return (byte0 | byte1 | byte2 | byte3);\n}\n\n/**\n * An `IndexedPolyfaceSubsetVisitor` is an IndexedPolyfaceVisitor which only visits a subset of facets in the polyface.\n * * The subset is defined by an array of facet indices provided when this visitor is created.\n * * Within the subset visitor, \"facetIndex\" is understood as index within the subset array:\n * * moveToNextFacet moves only within the subset\n * * moveToReadIndex(i) moves underlying visitor's parentFacetIndex(i)\n * @public\n */\nexport class IndexedPolyfaceSubsetVisitor extends IndexedPolyfaceVisitor {\n private _parentFacetIndices: number[];\n // index WITHIN THE _parentFacetIndices array.\n private _nextActiveIndex: number;\n private constructor(polyface: IndexedPolyface, activeFacetIndices: number[], numWrap: number) {\n super(polyface, numWrap);\n this._parentFacetIndices = activeFacetIndices.slice();\n this._nextActiveIndex = 0;\n }\n /** Create a visitor for iterating a subset of the facets of `polyface`, with indicated number of points to be added to each facet to produce closed point arrays\n * * Typical wrap counts are:\n * * 0 -- leave the point arrays with \"missing final edge\"\n * * 1 -- add point 0 as closure point\n * * 2 -- add points 0 and 1 as closure and wrap point. This is useful when vertex visit requires two adjacent vectors, e.g. for cross products.\n * * The activeFacetIndices array indicates all facets to be visited.\n */\n public static createSubsetVisitor(polyface: IndexedPolyface, activeFacetIndices: number[], numWrap: number): IndexedPolyfaceSubsetVisitor {\n return new IndexedPolyfaceSubsetVisitor(polyface, activeFacetIndices, numWrap);\n }\n /** Advance the iterator to a particular facet in the client polyface */\n public override moveToReadIndex(activeIndex: number): boolean {\n if (activeIndex >= 0 && activeIndex <= this._parentFacetIndices.length) {\n this._nextActiveIndex = activeIndex;\n return super.moveToReadIndex(this._parentFacetIndices[activeIndex++]);\n }\n return false;\n }\n /** Advance the iterator to a the 'next' facet in the client polyface */\n public override moveToNextFacet(): boolean {\n if (this._nextActiveIndex < this._parentFacetIndices.length) {\n const result = this.moveToReadIndex(this._nextActiveIndex);\n if (result) {\n this._nextActiveIndex++;\n return true;\n }\n }\n return false;\n }\n /** Reset the iterator to start at the first facet of the polyface. */\n public override reset(): void {\n this._nextActiveIndex = 0;\n }\n /** return the parent facet index of the indicated index within the active facets */\n public parentFacetIndex(activeIndex: number): number | undefined {\n if (activeIndex >= 0 && activeIndex <= this._nextActiveIndex) {\n return this._parentFacetIndices[activeIndex];\n }\n return undefined;\n }\n}\n"]}
|