@itwin/core-geometry 5.0.0-dev.112 → 5.0.0-dev.114
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/lib/cjs/clipping/ClipPlane.d.ts +7 -5
- package/lib/cjs/clipping/ClipPlane.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipPlane.js +9 -5
- package/lib/cjs/clipping/ClipPlane.js.map +1 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.js +12 -23
- package/lib/cjs/clipping/ConvexClipPlaneSet.js.map +1 -1
- package/lib/cjs/core-geometry.d.ts +1 -0
- package/lib/cjs/core-geometry.d.ts.map +1 -1
- package/lib/cjs/core-geometry.js +1 -0
- package/lib/cjs/core-geometry.js.map +1 -1
- package/lib/cjs/curve/Arc3d.d.ts +53 -31
- package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
- package/lib/cjs/curve/Arc3d.js +55 -36
- package/lib/cjs/curve/Arc3d.js.map +1 -1
- package/lib/cjs/curve/CurveCollection.d.ts +2 -0
- package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCollection.js +14 -0
- package/lib/cjs/curve/CurveCollection.js.map +1 -1
- package/lib/cjs/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineSegment3d.js +1 -0
- package/lib/cjs/curve/LineSegment3d.js.map +1 -1
- package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
- package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js +10 -5
- package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.js +7 -2
- package/lib/cjs/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +38 -28
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +38 -28
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.d.ts +14 -11
- package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js +14 -11
- package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts +7 -2
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.js +20 -2
- package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +2 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.js +7 -3
- package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/cjs/geometry3d/Plane3d.d.ts +2 -0
- package/lib/cjs/geometry3d/Plane3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Plane3d.js +6 -1
- package/lib/cjs/geometry3d/Plane3d.js.map +1 -1
- package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.d.ts +2 -0
- package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.js +6 -1
- package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.js.map +1 -1
- package/lib/cjs/geometry3d/Plane3dByOriginAndVectors.d.ts +8 -2
- package/lib/cjs/geometry3d/Plane3dByOriginAndVectors.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Plane3dByOriginAndVectors.js +18 -10
- package/lib/cjs/geometry3d/Plane3dByOriginAndVectors.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +3 -3
- package/lib/cjs/geometry3d/Point3dVector3d.js +3 -3
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts +7 -7
- package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.js +66 -26
- package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.d.ts +49 -2
- package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.js +38 -2
- package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
- package/lib/cjs/geometry3d/PolylineCompressionByEdgeOffset.d.ts +13 -6
- package/lib/cjs/geometry3d/PolylineCompressionByEdgeOffset.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PolylineCompressionByEdgeOffset.js +16 -9
- package/lib/cjs/geometry3d/PolylineCompressionByEdgeOffset.js.map +1 -1
- package/lib/cjs/geometry3d/PolylineOps.d.ts +5 -4
- package/lib/cjs/geometry3d/PolylineOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PolylineOps.js +5 -4
- package/lib/cjs/geometry3d/PolylineOps.js.map +1 -1
- package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Ray3d.js +11 -23
- package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
- package/lib/cjs/geometry3d/Transform.d.ts +21 -2
- package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Transform.js +32 -13
- package/lib/cjs/geometry3d/Transform.js.map +1 -1
- package/lib/cjs/geometry4d/Point4d.d.ts +4 -2
- package/lib/cjs/geometry4d/Point4d.d.ts.map +1 -1
- package/lib/cjs/geometry4d/Point4d.js +17 -13
- package/lib/cjs/geometry4d/Point4d.js.map +1 -1
- package/lib/cjs/polyface/FacetOrientation.d.ts +1 -1
- package/lib/cjs/polyface/FacetOrientation.js +1 -1
- package/lib/cjs/polyface/FacetOrientation.js.map +1 -1
- package/lib/cjs/polyface/IndexedEdgeMatcher.d.ts +55 -40
- package/lib/cjs/polyface/IndexedEdgeMatcher.d.ts.map +1 -1
- package/lib/cjs/polyface/IndexedEdgeMatcher.js +83 -75
- package/lib/cjs/polyface/IndexedEdgeMatcher.js.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts +15 -14
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js +47 -38
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceWalker.d.ts +26 -19
- package/lib/cjs/polyface/IndexedPolyfaceWalker.d.ts.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceWalker.js +47 -32
- package/lib/cjs/polyface/IndexedPolyfaceWalker.js.map +1 -1
- package/lib/cjs/polyface/Polyface.d.ts +17 -3
- package/lib/cjs/polyface/Polyface.d.ts.map +1 -1
- package/lib/cjs/polyface/Polyface.js +16 -0
- package/lib/cjs/polyface/Polyface.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.js +2 -2
- package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceClip.d.ts +19 -18
- package/lib/cjs/polyface/PolyfaceClip.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceClip.js +39 -42
- package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.d.ts +116 -75
- package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js +312 -228
- package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/cjs/polyface/RangeTree/RangeTreeNode.d.ts +3 -3
- package/lib/cjs/polyface/RangeTree/RangeTreeNode.d.ts.map +1 -1
- package/lib/cjs/polyface/RangeTree/RangeTreeNode.js +3 -3
- package/lib/cjs/polyface/RangeTree/RangeTreeNode.js.map +1 -1
- package/lib/cjs/polyface/multiclip/SweepLineStringToFacetContext.d.ts +7 -6
- package/lib/cjs/polyface/multiclip/SweepLineStringToFacetContext.d.ts.map +1 -1
- package/lib/cjs/polyface/multiclip/SweepLineStringToFacetContext.js +8 -9
- package/lib/cjs/polyface/multiclip/SweepLineStringToFacetContext.js.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
- package/lib/cjs/topology/ChainMerge.d.ts +1 -1
- package/lib/cjs/topology/ChainMerge.js +1 -1
- package/lib/cjs/topology/ChainMerge.js.map +1 -1
- package/lib/esm/clipping/ClipPlane.d.ts +7 -5
- package/lib/esm/clipping/ClipPlane.d.ts.map +1 -1
- package/lib/esm/clipping/ClipPlane.js +9 -5
- package/lib/esm/clipping/ClipPlane.js.map +1 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.js +12 -23
- package/lib/esm/clipping/ConvexClipPlaneSet.js.map +1 -1
- package/lib/esm/core-geometry.d.ts +1 -0
- package/lib/esm/core-geometry.d.ts.map +1 -1
- package/lib/esm/core-geometry.js +1 -0
- package/lib/esm/core-geometry.js.map +1 -1
- package/lib/esm/curve/Arc3d.d.ts +53 -31
- package/lib/esm/curve/Arc3d.d.ts.map +1 -1
- package/lib/esm/curve/Arc3d.js +55 -36
- package/lib/esm/curve/Arc3d.js.map +1 -1
- package/lib/esm/curve/CurveCollection.d.ts +2 -0
- package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
- package/lib/esm/curve/CurveCollection.js +14 -0
- package/lib/esm/curve/CurveCollection.js.map +1 -1
- package/lib/esm/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/esm/curve/LineSegment3d.js +1 -0
- package/lib/esm/curve/LineSegment3d.js.map +1 -1
- package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
- package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js +10 -5
- package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.js +7 -2
- package/lib/esm/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +38 -28
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +38 -28
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.d.ts +14 -11
- package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.js +14 -11
- package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts +7 -2
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.js +20 -2
- package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +2 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.js +7 -3
- package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/esm/geometry3d/Plane3d.d.ts +2 -0
- package/lib/esm/geometry3d/Plane3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Plane3d.js +6 -1
- package/lib/esm/geometry3d/Plane3d.js.map +1 -1
- package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.d.ts +2 -0
- package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.d.ts.map +1 -1
- package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.js +6 -1
- package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.js.map +1 -1
- package/lib/esm/geometry3d/Plane3dByOriginAndVectors.d.ts +8 -2
- package/lib/esm/geometry3d/Plane3dByOriginAndVectors.d.ts.map +1 -1
- package/lib/esm/geometry3d/Plane3dByOriginAndVectors.js +18 -10
- package/lib/esm/geometry3d/Plane3dByOriginAndVectors.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +3 -3
- package/lib/esm/geometry3d/Point3dVector3d.js +3 -3
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts +7 -7
- package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.js +66 -26
- package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.d.ts +49 -2
- package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.js +38 -2
- package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
- package/lib/esm/geometry3d/PolylineCompressionByEdgeOffset.d.ts +13 -6
- package/lib/esm/geometry3d/PolylineCompressionByEdgeOffset.d.ts.map +1 -1
- package/lib/esm/geometry3d/PolylineCompressionByEdgeOffset.js +16 -9
- package/lib/esm/geometry3d/PolylineCompressionByEdgeOffset.js.map +1 -1
- package/lib/esm/geometry3d/PolylineOps.d.ts +5 -4
- package/lib/esm/geometry3d/PolylineOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/PolylineOps.js +5 -4
- package/lib/esm/geometry3d/PolylineOps.js.map +1 -1
- package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Ray3d.js +11 -23
- package/lib/esm/geometry3d/Ray3d.js.map +1 -1
- package/lib/esm/geometry3d/Transform.d.ts +21 -2
- package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
- package/lib/esm/geometry3d/Transform.js +32 -13
- package/lib/esm/geometry3d/Transform.js.map +1 -1
- package/lib/esm/geometry4d/Point4d.d.ts +4 -2
- package/lib/esm/geometry4d/Point4d.d.ts.map +1 -1
- package/lib/esm/geometry4d/Point4d.js +17 -13
- package/lib/esm/geometry4d/Point4d.js.map +1 -1
- package/lib/esm/polyface/FacetOrientation.d.ts +1 -1
- package/lib/esm/polyface/FacetOrientation.js +1 -1
- package/lib/esm/polyface/FacetOrientation.js.map +1 -1
- package/lib/esm/polyface/IndexedEdgeMatcher.d.ts +55 -40
- package/lib/esm/polyface/IndexedEdgeMatcher.d.ts.map +1 -1
- package/lib/esm/polyface/IndexedEdgeMatcher.js +83 -75
- package/lib/esm/polyface/IndexedEdgeMatcher.js.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts +15 -14
- package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js +47 -38
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceWalker.d.ts +26 -19
- package/lib/esm/polyface/IndexedPolyfaceWalker.d.ts.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceWalker.js +47 -32
- package/lib/esm/polyface/IndexedPolyfaceWalker.js.map +1 -1
- package/lib/esm/polyface/Polyface.d.ts +17 -3
- package/lib/esm/polyface/Polyface.d.ts.map +1 -1
- package/lib/esm/polyface/Polyface.js +16 -0
- package/lib/esm/polyface/Polyface.js.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.js +2 -2
- package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/esm/polyface/PolyfaceClip.d.ts +19 -18
- package/lib/esm/polyface/PolyfaceClip.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceClip.js +39 -42
- package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.d.ts +116 -75
- package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js +313 -229
- package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/esm/polyface/RangeTree/RangeTreeNode.d.ts +3 -3
- package/lib/esm/polyface/RangeTree/RangeTreeNode.d.ts.map +1 -1
- package/lib/esm/polyface/RangeTree/RangeTreeNode.js +3 -3
- package/lib/esm/polyface/RangeTree/RangeTreeNode.js.map +1 -1
- package/lib/esm/polyface/multiclip/SweepLineStringToFacetContext.d.ts +7 -6
- package/lib/esm/polyface/multiclip/SweepLineStringToFacetContext.d.ts.map +1 -1
- package/lib/esm/polyface/multiclip/SweepLineStringToFacetContext.js +8 -9
- package/lib/esm/polyface/multiclip/SweepLineStringToFacetContext.js.map +1 -1
- package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/esm/serialization/GeometrySamples.js.map +1 -1
- package/lib/esm/topology/ChainMerge.d.ts +1 -1
- package/lib/esm/topology/ChainMerge.js +1 -1
- package/lib/esm/topology/ChainMerge.js.map +1 -1
- package/package.json +3 -3
|
@@ -9,97 +9,107 @@ exports.IndexedEdgeMatcher = exports.SortableEdge = void 0;
|
|
|
9
9
|
* @module Polyface
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* *
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* * [2] is facet index (or another number to associate with this edge).
|
|
12
|
+
* Represent an [[IndexedPolyface]] edge as:
|
|
13
|
+
* * vertex start index and vertex end index (CCW order around its facet)
|
|
14
|
+
* * an additional number to associate with the edge (e.g., facet index)
|
|
15
|
+
* @public
|
|
17
16
|
*/
|
|
18
|
-
class SortableEdge
|
|
17
|
+
class SortableEdge {
|
|
18
|
+
_v;
|
|
19
|
+
_a;
|
|
20
|
+
/** Constructor. */
|
|
21
|
+
constructor(startVertex, endVertex, facetIndex) {
|
|
22
|
+
this._v = [startVertex, endVertex];
|
|
23
|
+
this._a = facetIndex;
|
|
24
|
+
}
|
|
25
|
+
/** Clone the edge. */
|
|
26
|
+
clone() {
|
|
27
|
+
return new SortableEdge(this._v[0], this._v[1], this._a);
|
|
28
|
+
}
|
|
19
29
|
/** Return the vertex index that appears first in the order stored. */
|
|
20
|
-
get
|
|
21
|
-
return this[0];
|
|
30
|
+
get startVertex() {
|
|
31
|
+
return this._v[0];
|
|
22
32
|
}
|
|
23
33
|
/** Return the vertex index that appears second in the order stored. */
|
|
24
|
-
get
|
|
25
|
-
return this[1];
|
|
34
|
+
get endVertex() {
|
|
35
|
+
return this._v[1];
|
|
26
36
|
}
|
|
27
37
|
/**
|
|
28
38
|
* Return the facet index.
|
|
29
39
|
* * This value is carried along during matching. Typically it is a facet index, but it does not have to be.
|
|
30
40
|
*/
|
|
31
41
|
get facetIndex() {
|
|
32
|
-
return this
|
|
42
|
+
return this._a;
|
|
33
43
|
}
|
|
34
|
-
/** return true if
|
|
44
|
+
/** return true if `startVertex` is less than `endVertex`. */
|
|
35
45
|
get isLowHigh() {
|
|
36
|
-
return this[0] < this[1];
|
|
46
|
+
return this._v[0] < this._v[1];
|
|
37
47
|
}
|
|
38
48
|
/** Return the vertex index with lower numeric value. */
|
|
39
|
-
get
|
|
40
|
-
return this
|
|
49
|
+
get lowVertex() {
|
|
50
|
+
return this.isLowHigh ? this._v[0] : this._v[1];
|
|
41
51
|
}
|
|
42
52
|
/** Return the vertex index with higher numeric value. */
|
|
43
|
-
get
|
|
44
|
-
return this
|
|
53
|
+
get highVertex() {
|
|
54
|
+
return this.isLowHigh ? this._v[1] : this._v[0];
|
|
55
|
+
}
|
|
56
|
+
/** Return true if edgeA and edgeB traverse the same edge in the same direction. */
|
|
57
|
+
static areSameEdge(edgeA, edgeB) {
|
|
58
|
+
return edgeA._v[0] === edgeB._v[0] && edgeA._v[1] === edgeB._v[1];
|
|
45
59
|
}
|
|
46
|
-
/** Return true if
|
|
60
|
+
/** Return true if edgeA and edgeB traverse the same edge in opposite directions. */
|
|
47
61
|
static areDirectedPartners(edgeA, edgeB) {
|
|
48
|
-
return edgeA[0] === edgeB[1] && edgeA[1] === edgeB[0];
|
|
62
|
+
return edgeA._v[0] === edgeB._v[1] && edgeA._v[1] === edgeB._v[0];
|
|
49
63
|
}
|
|
50
|
-
/** Return true if
|
|
64
|
+
/** Return true if edgeA and edgeB traverse the same edge in the same or opposite directions. */
|
|
51
65
|
static areUndirectedPartners(edgeA, edgeB) {
|
|
52
|
-
return (edgeA
|
|
66
|
+
return this.areSameEdge(edgeA, edgeB) || this.areDirectedPartners(edgeA, edgeB);
|
|
53
67
|
}
|
|
54
68
|
/**
|
|
55
|
-
* Return numeric relationship
|
|
56
|
-
* * 1 if they share start and end in the same order.
|
|
57
|
-
* * -1 if they share start and end in reversed order.
|
|
69
|
+
* Return numeric identifier for the relationship between edgeA and edgeB:
|
|
70
|
+
* * 1 if they share start and end vertex indices in the same order.
|
|
71
|
+
* * -1 if they share start and end vertex indices in reversed order.
|
|
58
72
|
* * 0 otherwise.
|
|
59
73
|
*/
|
|
60
74
|
static relativeOrientation(edgeA, edgeB) {
|
|
61
|
-
if (edgeA
|
|
75
|
+
if (this.areSameEdge(edgeA, edgeB))
|
|
62
76
|
return 1;
|
|
63
|
-
if (edgeA
|
|
77
|
+
if (this.areDirectedPartners(edgeA, edgeB))
|
|
64
78
|
return -1;
|
|
65
79
|
return 0;
|
|
66
80
|
}
|
|
81
|
+
/** Whether the start and end vertex indices are equal. */
|
|
67
82
|
get isNullEdge() {
|
|
68
|
-
return this[0] === this[1];
|
|
83
|
+
return this._v[0] === this._v[1];
|
|
69
84
|
}
|
|
70
85
|
/**
|
|
71
86
|
* Lexical comparison of two edges.
|
|
72
|
-
* * If the edges have the same vertex pair (in same or opposite order) they will end up adjacent in a sort.
|
|
73
|
-
* * If the edges have 0 or 1 shared vertex indices, the one with lowest low comes first.
|
|
87
|
+
* * If the edges have the same vertex index pair (in same or opposite order) they will end up adjacent in a sort.
|
|
74
88
|
* @param edgeA first edge
|
|
75
89
|
* @param edgeB second edge
|
|
76
90
|
*/
|
|
77
91
|
static lessThan(edgeA, edgeB) {
|
|
78
92
|
// primary compare is based on indirect indices
|
|
79
|
-
const lowA = edgeA.
|
|
80
|
-
const lowB = edgeB.
|
|
93
|
+
const lowA = edgeA.lowVertex;
|
|
94
|
+
const lowB = edgeB.lowVertex;
|
|
81
95
|
if (lowA < lowB)
|
|
82
96
|
return -1;
|
|
83
97
|
if (lowB < lowA)
|
|
84
98
|
return 1;
|
|
85
|
-
const highA = edgeA.
|
|
86
|
-
const highB = edgeB.
|
|
99
|
+
const highA = edgeA.highVertex;
|
|
100
|
+
const highB = edgeB.highVertex;
|
|
87
101
|
if (highA < highB)
|
|
88
102
|
return -1;
|
|
89
103
|
if (highB < highA)
|
|
90
104
|
return 1;
|
|
91
105
|
// undirected indices match ... use directed vertexIndexA
|
|
92
|
-
return edgeA.
|
|
93
|
-
}
|
|
94
|
-
constructor(vertexA, vertexB, facetIndex) {
|
|
95
|
-
super(3);
|
|
96
|
-
this[0] = vertexA;
|
|
97
|
-
this[1] = vertexB;
|
|
98
|
-
this[2] = facetIndex;
|
|
106
|
+
return edgeA.startVertex - edgeB.startVertex;
|
|
99
107
|
}
|
|
108
|
+
/** Return the edge data as a JSON array. */
|
|
100
109
|
toJSON() {
|
|
101
|
-
return [this[0], this[1], this
|
|
110
|
+
return [this._v[0], this._v[1], this._a];
|
|
102
111
|
}
|
|
112
|
+
/** Return the edge cluster in JSON format. */
|
|
103
113
|
static clusterToJSON(data) {
|
|
104
114
|
if (data instanceof SortableEdge)
|
|
105
115
|
return data.toJSON();
|
|
@@ -107,6 +117,7 @@ class SortableEdge extends Float64Array {
|
|
|
107
117
|
for (const edge of data)
|
|
108
118
|
result.push(edge.toJSON());
|
|
109
119
|
}
|
|
120
|
+
/** Return the edge cluster array in JSON format. */
|
|
110
121
|
static clusterArrayToJSON(data) {
|
|
111
122
|
const result = [];
|
|
112
123
|
for (const cluster of data)
|
|
@@ -116,11 +127,14 @@ class SortableEdge extends Float64Array {
|
|
|
116
127
|
}
|
|
117
128
|
exports.SortableEdge = SortableEdge;
|
|
118
129
|
/**
|
|
119
|
-
* An IndexedEdgeMatcher carries an array of edge start
|
|
120
|
-
*
|
|
130
|
+
* An IndexedEdgeMatcher carries an array of edge start and end indices for sorting and subsequent analyses,
|
|
131
|
+
* such as testing for closed mesh.
|
|
132
|
+
* @public
|
|
121
133
|
*/
|
|
122
134
|
class IndexedEdgeMatcher {
|
|
135
|
+
/** The array of edges to be sorted. */
|
|
123
136
|
edges;
|
|
137
|
+
/** Constructor. Call [[addEdge]] or [[addPath]] to populate `edges`. */
|
|
124
138
|
constructor() {
|
|
125
139
|
this.edges = [];
|
|
126
140
|
}
|
|
@@ -137,22 +151,22 @@ class IndexedEdgeMatcher {
|
|
|
137
151
|
return edge;
|
|
138
152
|
}
|
|
139
153
|
/**
|
|
140
|
-
* Push edges
|
|
141
|
-
*
|
|
142
|
-
* @param
|
|
154
|
+
* Push edges along a path.
|
|
155
|
+
* * Typically used to add edges around a facet.
|
|
156
|
+
* @param vertexIndices array of vertex indices along an open or closed path.
|
|
157
|
+
* @param facetIndex value to set on each edge pushed.
|
|
143
158
|
* @param closeLoop true to add an edge from last to first vertex.
|
|
144
159
|
*/
|
|
145
|
-
addPath(
|
|
146
|
-
if (
|
|
160
|
+
addPath(vertexIndices, facetIndex, closeLoop) {
|
|
161
|
+
if (vertexIndices.length === 0)
|
|
147
162
|
return;
|
|
148
|
-
const m =
|
|
149
|
-
for (let i = 0; i < m; i++)
|
|
150
|
-
this.addEdge(
|
|
151
|
-
}
|
|
163
|
+
const m = vertexIndices.length - 1;
|
|
164
|
+
for (let i = 0; i < m; i++)
|
|
165
|
+
this.addEdge(vertexIndices[i], vertexIndices[i + 1], facetIndex);
|
|
152
166
|
if (closeLoop)
|
|
153
|
-
this.addEdge(
|
|
167
|
+
this.addEdge(vertexIndices[m], vertexIndices[0], facetIndex);
|
|
154
168
|
}
|
|
155
|
-
/** Sort the
|
|
169
|
+
/** Sort the edges. */
|
|
156
170
|
sort() {
|
|
157
171
|
this.edges.sort((edgeA, edgeB) => SortableEdge.lessThan(edgeA, edgeB));
|
|
158
172
|
}
|
|
@@ -171,20 +185,18 @@ class IndexedEdgeMatcher {
|
|
|
171
185
|
}
|
|
172
186
|
}
|
|
173
187
|
/**
|
|
174
|
-
* Sort the edges, and
|
|
175
|
-
*
|
|
176
|
-
* *
|
|
177
|
-
* * Any combination of the
|
|
188
|
+
* Sort the edges, and collect up to four categories of edges: manifold pairs, singletons, null edges,
|
|
189
|
+
* and everything else.
|
|
190
|
+
* * Caller should allocate arrays of interest.
|
|
191
|
+
* * Any combination of the arrays may be `undefined`, indicating that category is to be ignored.
|
|
192
|
+
* * Any combination of the arrays may be aliased as the same target, in which case the aliased categories are
|
|
178
193
|
* merged into the target.
|
|
179
|
-
* * For instance, to ignore manifold pairs and collect all
|
|
180
|
-
* `
|
|
181
|
-
*
|
|
182
|
-
* @param
|
|
183
|
-
*
|
|
184
|
-
* @param
|
|
185
|
-
* @param nullEdges optional array to receive arrays of null edges (same start and end vertex)
|
|
186
|
-
* @param allOtherClusters optional array to receive arrays in which all the edges are partners in an undirected sense
|
|
187
|
-
* but not a simple directed pair.
|
|
194
|
+
* * For instance, to ignore manifold pairs and collect all other edges in a single array:
|
|
195
|
+
* `const foo = []; matcher.sortAndCollectClusters(undefined, foo, foo, foo);`
|
|
196
|
+
* @param manifoldPairs array to receive pairs of properly mated edges, i.e. mesh interior edges.
|
|
197
|
+
* @param singletons array to receive edges that have no partner, i.e., mesh boundary edges.
|
|
198
|
+
* @param nullEdges array to receive arrays of matched null edges, for which start === end vertex index.
|
|
199
|
+
* @param allOtherClusters array to receive arrays of edges that are partners in an undirected, non-manifold sense.
|
|
188
200
|
*/
|
|
189
201
|
sortAndCollectClusters(manifoldPairs, singletons, nullEdges, allOtherClusters) {
|
|
190
202
|
this.sort();
|
|
@@ -205,18 +217,14 @@ class IndexedEdgeMatcher {
|
|
|
205
217
|
SortableEdge.areUndirectedPartners(baseEdge, this.edges[index1]); index1++) {
|
|
206
218
|
clusterLength++;
|
|
207
219
|
}
|
|
208
|
-
if (this.edges[index0].isNullEdge)
|
|
220
|
+
if (this.edges[index0].isNullEdge)
|
|
209
221
|
this.collectSortableEdgeCluster(index0, index0 + clusterLength, nullEdges);
|
|
210
|
-
|
|
211
|
-
else if (clusterLength === 2 && SortableEdge.areDirectedPartners(baseEdge, this.edges[index0 + 1])) {
|
|
222
|
+
else if (clusterLength === 2 && SortableEdge.areDirectedPartners(baseEdge, this.edges[index0 + 1]))
|
|
212
223
|
this.collectSortableEdgeCluster(index0, index0 + clusterLength, manifoldPairs);
|
|
213
|
-
|
|
214
|
-
else if (clusterLength === 1) {
|
|
224
|
+
else if (clusterLength === 1)
|
|
215
225
|
this.collectSortableEdgeCluster(index0, index0 + 1, singletons);
|
|
216
|
-
|
|
217
|
-
else {
|
|
226
|
+
else
|
|
218
227
|
this.collectSortableEdgeCluster(index0, index0 + clusterLength, allOtherClusters);
|
|
219
|
-
}
|
|
220
228
|
}
|
|
221
229
|
}
|
|
222
230
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexedEdgeMatcher.js","sourceRoot":"","sources":["../../../src/polyface/IndexedEdgeMatcher.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH;;;;;;GAMG;AACH,MAAa,YAAa,SAAQ,YAAY;IAC5C,uEAAuE;IACvE,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IACD,wEAAwE;IACxE,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IACD;;;OAGG;IACH,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IACD,6DAA6D;IAC7D,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IACD,wDAAwD;IACxD,IAAW,cAAc;QACvB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AAC;CACF;AAjGD,gDAiGC","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\n/**\n * * For boundary sorting, an edge is a (packed!) Float64Array.\n * * Fixed entry positions are:\n * * [0] is start vertex index (in CCW order around its facet)\n * * [1] is end vertex index (in CCW order around its facet)\n * * [2] is facet index (or another number to associate with this edge).\n */\nexport class SortableEdge extends Float64Array {\n /** Return the vertex index that appears first in the order stored. */\n public get vertexIndexA(): number {\n return this[0];\n }\n /** Return the vertex index that appears second in the order stored. */\n public get vertexIndexB(): number {\n return this[1];\n }\n /**\n * Return the facet index.\n * * This value is carried along during matching. Typically it is a facet index, but it does not have to be.\n */\n public get facetIndex(): number {\n return this[2];\n }\n /** return true if vertexIndexA is less than vertexIndexB. */\n public get isLowHigh(): boolean {\n return this[0] < this[1];\n }\n /** Return the vertex index with lower numeric value. */\n public get lowVertexIndex(): number {\n return this[0] < this[1] ? this[0] : this[1];\n }\n /** Return the vertex index with higher numeric value. */\n public get highVertexIndex(): number {\n return this[0] > this[1] ? this[0] : this[1];\n }\n /** Return true if the vertices edgeA and edgeB are the same vertex indices in opposite order. */\n public static areDirectedPartners(edgeA: SortableEdge, edgeB: SortableEdge): boolean {\n return edgeA[0] === edgeB[1] && edgeA[1] === edgeB[0];\n }\n /** Return true if the vertices edgeA and edgeB are the same vertex indices with no consideration of order. */\n public static areUndirectedPartners(edgeA: SortableEdge, edgeB: SortableEdge): boolean {\n return (edgeA[0] === edgeB[0] && edgeA[1] === edgeB[1]) || ((edgeA[0] === edgeB[1] && edgeA[1] === edgeB[0]));\n }\n /**\n * Return numeric relationship of edgeA and edgeB:\n * * 1 if they share start and end in the same order.\n * * -1 if they share start and end in reversed order.\n * * 0 otherwise.\n */\n public static relativeOrientation(edgeA: SortableEdge, edgeB: SortableEdge): number {\n if (edgeA[0] === edgeB[0] && edgeA[1] === edgeB[1]) return 1;\n if (edgeA[0] === edgeB[1] && edgeA[1] === edgeB[0]) return -1;\n return 0;\n }\n\n public get isNullEdge(): boolean {\n return this[0] === this[1];\n }\n /**\n * Lexical comparison of two edges.\n * * If the edges have the same vertex pair (in same or opposite order) they will end up adjacent in a sort.\n * * If the edges have 0 or 1 shared vertex indices, the one with lowest low comes first.\n * @param edgeA first edge\n * @param edgeB second edge\n */\n public static lessThan(edgeA: SortableEdge, edgeB: SortableEdge): number {\n // primary compare is based on indirect indices\n const lowA = edgeA.lowVertexIndex;\n const lowB = edgeB.lowVertexIndex;\n if (lowA < lowB)\n return -1;\n if (lowB < lowA)\n return 1;\n const highA = edgeA.highVertexIndex;\n const highB = edgeB.highVertexIndex;\n if (highA < highB)\n return -1;\n if (highB < highA)\n return 1;\n // undirected indices match ... use directed vertexIndexA\n return edgeA.vertexIndexA - edgeB.vertexIndexA;\n }\n public constructor(vertexA: number, vertexB: number, facetIndex: number) {\n super(3);\n this[0] = vertexA;\n this[1] = vertexB;\n this[2] = facetIndex;\n }\n public toJSON(): any {\n return [this[0], this[1], this[2]];\n }\n public static clusterToJSON(data: SortableEdgeCluster): any {\n if (data instanceof SortableEdge)\n return data.toJSON();\n const result = [];\n for (const edge of data) result.push(edge.toJSON());\n }\n public static clusterArrayToJSON(data: SortableEdgeCluster[]) {\n const result = [];\n for (const cluster of data)\n result.push(SortableEdge.clusterToJSON(cluster));\n return result;\n }\n}\nexport type SortableEdgeCluster = SortableEdge | SortableEdge[];\n/**\n * An IndexedEdgeMatcher carries an array of edge start & end indices for sorting and subsequent analyses\n * (such as testing for closed mesh).\n */\nexport class IndexedEdgeMatcher {\n public edges: SortableEdge[];\n\n constructor() {\n this.edges = [];\n }\n /**\n * Push a new edge.\n * @param vertexA start vertex\n * @param vertexB end vertex\n * @param facetIndex value to carry along during matching\n * @returns the edge pushed onto the `edges` array\n */\n public addEdge(vertexA: number, vertexB: number, facetIndex: number): SortableEdge {\n const edge = new SortableEdge(vertexA, vertexB, facetIndex);\n this.edges.push(edge);\n return edge;\n }\n /**\n * Push edges all around a facet, returning to vertexArray[0].\n * @param vertexArray array of vertex indices around facet\n * @param facetIndex value to carry along during matching\n * @param closeLoop true to add an edge from last to first vertex.\n */\n public addPath(vertexArray: number[], facetIndex: number, closeLoop: boolean = true) {\n if (vertexArray.length === 0) return;\n const m = vertexArray.length - 1;\n for (let i = 0; i < m; i++) {\n this.addEdge(vertexArray[i], vertexArray[i + 1], facetIndex);\n }\n if (closeLoop)\n this.addEdge(vertexArray[m], vertexArray[0], facetIndex);\n }\n /** Sort the edge index array. */\n public sort() {\n this.edges.sort((edgeA, edgeB) => SortableEdge.lessThan(edgeA, edgeB));\n }\n /** Create a single or compound SortableEdgeCluster in dest. */\n private collectSortableEdgeCluster(index0: number, index1: number, dest: SortableEdgeCluster[] | undefined) {\n if (dest !== undefined && index1 > index0) {\n if (index1 === index0 + 1) {\n dest.push(this.edges[index0]);\n } else {\n const cluster = [];\n for (let i = index0; i < index1; i++)\n cluster.push(this.edges[i]);\n dest.push(cluster);\n }\n }\n }\n /**\n * Sort the edges, and look for three categories of paired edges:\n * * caller must allocate all result arrays of interest.\n * * Any combination of the result arrays may be `undefined`, indicating that category is to be ignored.\n * * Any combination of the result arrays may be aliased as the same target, in which case those to categories are\n * merged into the target.\n * * For instance, to ignore manifold pairs and collect all others (singleton, null, and other) as a single array\n * `allOther`, create `const allOther = []` as an empty array and call\n * `sortAndCollectClusters (undefined, allOther, allOther, allOther);`\n * @param manifoldPairs optional array to receive pairs of properly mated SortableEdgePairs, i.e. simple interior\n * edges adjacent to two facets in opposing directions.\n * @param singletons optional array to receive edges that are simple boundary edges.\n * @param nullEdges optional array to receive arrays of null edges (same start and end vertex)\n * @param allOtherClusters optional array to receive arrays in which all the edges are partners in an undirected sense\n * but not a simple directed pair.\n */\n public sortAndCollectClusters(\n manifoldPairs: SortableEdgeCluster[] | undefined,\n singletons?: SortableEdgeCluster[],\n nullEdges?: SortableEdgeCluster[],\n allOtherClusters?: SortableEdgeCluster[],\n ): void {\n this.sort();\n if (manifoldPairs) manifoldPairs.length = 0;\n if (singletons) singletons.length = 0;\n if (nullEdges) nullEdges.length = 0;\n if (allOtherClusters) allOtherClusters.length = 0;\n const n = this.edges.length;\n let clusterLength;\n for (let index0 = 0; index0 < n; index0 += clusterLength) {\n const baseEdge = this.edges[index0];\n clusterLength = 1;\n for (let index1 = index0 + 1; index1 < n &&\n SortableEdge.areUndirectedPartners(baseEdge, this.edges[index1]); index1++) {\n clusterLength++;\n }\n if (this.edges[index0].isNullEdge) {\n this.collectSortableEdgeCluster(index0, index0 + clusterLength, nullEdges);\n } else if (clusterLength === 2 && SortableEdge.areDirectedPartners(baseEdge, this.edges[index0 + 1])) {\n this.collectSortableEdgeCluster(index0, index0 + clusterLength, manifoldPairs);\n } else if (clusterLength === 1) {\n this.collectSortableEdgeCluster(index0, index0 + 1, singletons);\n } else {\n this.collectSortableEdgeCluster(index0, index0 + clusterLength, allOtherClusters);\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IndexedEdgeMatcher.js","sourceRoot":"","sources":["../../../src/polyface/IndexedEdgeMatcher.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH;;;;;GAKG;AACH,MAAa,YAAY;IACf,EAAE,CAAW;IACb,EAAE,CAAS;IAEnB,mBAAmB;IACnB,YAAmB,WAAmB,EAAE,SAAiB,EAAE,UAAkB;QAC3E,IAAI,CAAC,EAAE,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACnC,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC;IACvB,CAAC;IACD,sBAAsB;IACf,KAAK;QACV,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3D,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a,KAAK,CAAC;gBAC1B,IAAI,CAAC,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;;gBAEhE,IAAI,CAAC,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,EAAE,gBAAgB,CAAC,CAAC;QACtF,CAAC;IACH,CAAC;CACF;AApGD,gDAoGC","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\n/**\n * Represent an [[IndexedPolyface]] edge as:\n * * vertex start index and vertex end index (CCW order around its facet)\n * * an additional number to associate with the edge (e.g., facet index)\n * @public\n */\nexport class SortableEdge {\n private _v: number[];\n private _a: number;\n\n /** Constructor. */\n public constructor(startVertex: number, endVertex: number, facetIndex: number) {\n this._v = [startVertex, endVertex];\n this._a = facetIndex;\n }\n /** Clone the edge. */\n public clone(): SortableEdge {\n return new SortableEdge(this._v[0], this._v[1], this._a);\n }\n /** Return the vertex index that appears first in the order stored. */\n public get startVertex(): number {\n return this._v[0];\n }\n /** Return the vertex index that appears second in the order stored. */\n public get endVertex(): number {\n return this._v[1];\n }\n /**\n * Return the facet index.\n * * This value is carried along during matching. Typically it is a facet index, but it does not have to be.\n */\n public get facetIndex(): number {\n return this._a;\n }\n /** return true if `startVertex` is less than `endVertex`. */\n public get isLowHigh(): boolean {\n return this._v[0] < this._v[1];\n }\n /** Return the vertex index with lower numeric value. */\n public get lowVertex(): number {\n return this.isLowHigh ? this._v[0] : this._v[1];\n }\n /** Return the vertex index with higher numeric value. */\n public get highVertex(): number {\n return this.isLowHigh ? this._v[1] : this._v[0];\n }\n /** Return true if edgeA and edgeB traverse the same edge in the same direction. */\n private static areSameEdge(edgeA: SortableEdge, edgeB: SortableEdge): boolean {\n return edgeA._v[0] === edgeB._v[0] && edgeA._v[1] === edgeB._v[1];\n }\n /** Return true if edgeA and edgeB traverse the same edge in opposite directions. */\n public static areDirectedPartners(edgeA: SortableEdge, edgeB: SortableEdge): boolean {\n return edgeA._v[0] === edgeB._v[1] && edgeA._v[1] === edgeB._v[0];\n }\n /** Return true if edgeA and edgeB traverse the same edge in the same or opposite directions. */\n public static areUndirectedPartners(edgeA: SortableEdge, edgeB: SortableEdge): boolean {\n return this.areSameEdge(edgeA, edgeB) || this.areDirectedPartners(edgeA, edgeB);\n }\n /**\n * Return numeric identifier for the relationship between edgeA and edgeB:\n * * 1 if they share start and end vertex indices in the same order.\n * * -1 if they share start and end vertex indices in reversed order.\n * * 0 otherwise.\n */\n public static relativeOrientation(edgeA: SortableEdge, edgeB: SortableEdge): number {\n if (this.areSameEdge(edgeA, edgeB))\n return 1;\n if (this.areDirectedPartners(edgeA, edgeB))\n return -1;\n return 0;\n }\n /** Whether the start and end vertex indices are equal. */\n public get isNullEdge(): boolean {\n return this._v[0] === this._v[1];\n }\n /**\n * Lexical comparison of two edges.\n * * If the edges have the same vertex index pair (in same or opposite order) they will end up adjacent in a sort.\n * @param edgeA first edge\n * @param edgeB second edge\n */\n public static lessThan(edgeA: SortableEdge, edgeB: SortableEdge): number {\n // primary compare is based on indirect indices\n const lowA = edgeA.lowVertex;\n const lowB = edgeB.lowVertex;\n if (lowA < lowB)\n return -1;\n if (lowB < lowA)\n return 1;\n const highA = edgeA.highVertex;\n const highB = edgeB.highVertex;\n if (highA < highB)\n return -1;\n if (highB < highA)\n return 1;\n // undirected indices match ... use directed vertexIndexA\n return edgeA.startVertex - edgeB.startVertex;\n }\n /** Return the edge data as a JSON array. */\n public toJSON(): any {\n return [this._v[0], this._v[1], this._a];\n }\n /** Return the edge cluster in JSON format. */\n public static clusterToJSON(data: SortableEdgeCluster): any {\n if (data instanceof SortableEdge)\n return data.toJSON();\n const result = [];\n for (const edge of data)\n result.push(edge.toJSON());\n }\n /** Return the edge cluster array in JSON format. */\n public static clusterArrayToJSON(data: SortableEdgeCluster[]) {\n const result = [];\n for (const cluster of data)\n result.push(SortableEdge.clusterToJSON(cluster));\n return result;\n }\n}\n\n/**\n * Union type for a single [[SortableEdge]] or a (matched) array of them.\n * @public\n */\nexport type SortableEdgeCluster = SortableEdge | SortableEdge[];\n\n/**\n * An IndexedEdgeMatcher carries an array of edge start and end indices for sorting and subsequent analyses,\n * such as testing for closed mesh.\n * @public\n */\nexport class IndexedEdgeMatcher {\n /** The array of edges to be sorted. */\n public edges: SortableEdge[];\n /** Constructor. Call [[addEdge]] or [[addPath]] to populate `edges`. */\n public constructor() {\n this.edges = [];\n }\n /**\n * Push a new edge.\n * @param vertexA start vertex\n * @param vertexB end vertex\n * @param facetIndex value to carry along during matching\n * @returns the edge pushed onto the `edges` array\n */\n public addEdge(vertexA: number, vertexB: number, facetIndex: number): SortableEdge {\n const edge = new SortableEdge(vertexA, vertexB, facetIndex);\n this.edges.push(edge);\n return edge;\n }\n /**\n * Push edges along a path.\n * * Typically used to add edges around a facet.\n * @param vertexIndices array of vertex indices along an open or closed path.\n * @param facetIndex value to set on each edge pushed.\n * @param closeLoop true to add an edge from last to first vertex.\n */\n public addPath(vertexIndices: number[], facetIndex: number, closeLoop: boolean) {\n if (vertexIndices.length === 0)\n return;\n const m = vertexIndices.length - 1;\n for (let i = 0; i < m; i++)\n this.addEdge(vertexIndices[i], vertexIndices[i + 1], facetIndex);\n if (closeLoop)\n this.addEdge(vertexIndices[m], vertexIndices[0], facetIndex);\n }\n /** Sort the edges. */\n public sort() {\n this.edges.sort((edgeA, edgeB) => SortableEdge.lessThan(edgeA, edgeB));\n }\n /** Create a single or compound SortableEdgeCluster in dest. */\n private collectSortableEdgeCluster(index0: number, index1: number, dest: SortableEdgeCluster[] | undefined) {\n if (dest !== undefined && index1 > index0) {\n if (index1 === index0 + 1) {\n dest.push(this.edges[index0]);\n } else {\n const cluster = [];\n for (let i = index0; i < index1; i++)\n cluster.push(this.edges[i]);\n dest.push(cluster);\n }\n }\n }\n /**\n * Sort the edges, and collect up to four categories of edges: manifold pairs, singletons, null edges,\n * and everything else.\n * * Caller should allocate arrays of interest.\n * * Any combination of the arrays may be `undefined`, indicating that category is to be ignored.\n * * Any combination of the arrays may be aliased as the same target, in which case the aliased categories are\n * merged into the target.\n * * For instance, to ignore manifold pairs and collect all other edges in a single array:\n * `const foo = []; matcher.sortAndCollectClusters(undefined, foo, foo, foo);`\n * @param manifoldPairs array to receive pairs of properly mated edges, i.e. mesh interior edges.\n * @param singletons array to receive edges that have no partner, i.e., mesh boundary edges.\n * @param nullEdges array to receive arrays of matched null edges, for which start === end vertex index.\n * @param allOtherClusters array to receive arrays of edges that are partners in an undirected, non-manifold sense.\n */\n public sortAndCollectClusters(\n manifoldPairs?: SortableEdgeCluster[],\n singletons?: SortableEdgeCluster[],\n nullEdges?: SortableEdgeCluster[],\n allOtherClusters?: SortableEdgeCluster[],\n ): void {\n this.sort();\n if (manifoldPairs)\n manifoldPairs.length = 0;\n if (singletons)\n singletons.length = 0;\n if (nullEdges)\n nullEdges.length = 0;\n if (allOtherClusters)\n allOtherClusters.length = 0;\n const n = this.edges.length;\n let clusterLength;\n for (let index0 = 0; index0 < n; index0 += clusterLength) {\n const baseEdge = this.edges[index0];\n clusterLength = 1;\n for (let index1 = index0 + 1; index1 < n &&\n SortableEdge.areUndirectedPartners(baseEdge, this.edges[index1]); index1++) {\n clusterLength++;\n }\n if (this.edges[index0].isNullEdge)\n this.collectSortableEdgeCluster(index0, index0 + clusterLength, nullEdges);\n else if (clusterLength === 2 && SortableEdge.areDirectedPartners(baseEdge, this.edges[index0 + 1]))\n this.collectSortableEdgeCluster(index0, index0 + clusterLength, manifoldPairs);\n else if (clusterLength === 1)\n this.collectSortableEdgeCluster(index0, index0 + 1, singletons);\n else\n this.collectSortableEdgeCluster(index0, index0 + clusterLength, allOtherClusters);\n }\n }\n}\n"]}
|
|
@@ -40,7 +40,7 @@ export declare class IndexedPolyfaceVisitor extends PolyfaceData implements Poly
|
|
|
40
40
|
moveToReadIndex(facetIndex: number): boolean;
|
|
41
41
|
/** Advance the iterator to a the 'next' facet in the client polyface. */
|
|
42
42
|
moveToNextFacet(): boolean;
|
|
43
|
-
/**
|
|
43
|
+
/** Restart the visitor at the first facet. */
|
|
44
44
|
reset(): void;
|
|
45
45
|
/**
|
|
46
46
|
* Attempts to extract the distance parameter for the given vertex `index` on the current facet.
|
|
@@ -73,6 +73,8 @@ export declare class IndexedPolyfaceVisitor extends PolyfaceData implements Poly
|
|
|
73
73
|
* * All data values are interpolated at `fraction` between `other` values at `index0` and `index1`.
|
|
74
74
|
*/
|
|
75
75
|
pushInterpolatedDataFrom(other: PolyfaceVisitor, index0: number, fraction: number, index1: number): void;
|
|
76
|
+
/** Create a visitor for a subset of the facets visitable by the instance. */
|
|
77
|
+
createSubsetVisitor(facetIndices: number[], numWrap?: number): IndexedPolyfaceSubsetVisitor;
|
|
76
78
|
}
|
|
77
79
|
/**
|
|
78
80
|
* An `IndexedPolyfaceSubsetVisitor` is an `IndexedPolyfaceVisitor` which only visits a subset of facets in the polyface.
|
|
@@ -81,38 +83,37 @@ export declare class IndexedPolyfaceVisitor extends PolyfaceData implements Poly
|
|
|
81
83
|
* @public
|
|
82
84
|
*/
|
|
83
85
|
export declare class IndexedPolyfaceSubsetVisitor extends IndexedPolyfaceVisitor {
|
|
84
|
-
private
|
|
85
|
-
private
|
|
86
|
-
private
|
|
86
|
+
private _facetIndices;
|
|
87
|
+
private _currentSubsetIndex;
|
|
88
|
+
private _nextSubsetIndex;
|
|
87
89
|
private constructor();
|
|
88
90
|
private isValidSubsetIndex;
|
|
89
91
|
/**
|
|
90
92
|
* Create a visitor for iterating a subset of the facets of `polyface`.
|
|
91
93
|
* @param polyface reference to the client polyface, supplying facets
|
|
92
|
-
* @param
|
|
94
|
+
* @param facetIndices array of indices of facets in the client polyface to visit. This array is cloned.
|
|
93
95
|
* @param numWrap number of vertices replicated in the visitor arrays to facilitate simpler caller code. Default is zero.
|
|
94
96
|
*/
|
|
95
|
-
static createSubsetVisitor(polyface: IndexedPolyface,
|
|
97
|
+
static createSubsetVisitor(polyface: IndexedPolyface, facetIndices: number[], numWrap?: number): IndexedPolyfaceSubsetVisitor;
|
|
96
98
|
/**
|
|
97
99
|
* Advance the iterator to a particular facet in the subset of client polyface facets.
|
|
98
|
-
* @param
|
|
99
|
-
* the client polyface.
|
|
100
|
+
* @param subsetIndex index into the subset array, not to be confused with the client facet index.
|
|
100
101
|
* @return whether the iterator was successfully moved.
|
|
101
102
|
*/
|
|
102
|
-
moveToReadIndex(
|
|
103
|
+
moveToReadIndex(subsetIndex: number): boolean;
|
|
103
104
|
/**
|
|
104
105
|
* Advance the iterator to the next facet in the subset of client polyface facets.
|
|
105
106
|
* @return whether the iterator was successfully moved.
|
|
106
107
|
*/
|
|
107
108
|
moveToNextFacet(): boolean;
|
|
108
|
-
/**
|
|
109
|
+
/** Restart the visitor at the first facet. */
|
|
109
110
|
reset(): void;
|
|
110
111
|
/**
|
|
111
|
-
* Return the
|
|
112
|
-
* @param
|
|
113
|
-
* @return valid client polyface facet index, or `undefined` if invalid
|
|
112
|
+
* Return the client polyface facet index (aka "readIndex") for the given subset index.
|
|
113
|
+
* @param subsetIndex index into the subset array. Default is the subset index of the currently visited facet.
|
|
114
|
+
* @return valid client polyface facet index, or `undefined` if invalid subset index.
|
|
114
115
|
*/
|
|
115
|
-
parentFacetIndex(
|
|
116
|
+
parentFacetIndex(subsetIndex?: number): number | undefined;
|
|
116
117
|
/** Return the number of facets this visitor is able to visit. */
|
|
117
118
|
getVisitableFacetCount(): number;
|
|
118
119
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexedPolyfaceVisitor.d.ts","sourceRoot":"","sources":["../../../src/polyface/IndexedPolyfaceVisitor.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO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BAA4B;CAGtG;AAED;;;;;GAKG;AACH,qBAAa,4BAA6B,SAAQ,sBAAsB;IACtE,OAAO,CAAC,aAAa,CAAW;IAChC,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,gBAAgB,CAAS;IAEjC,OAAO;IAOP,OAAO,CAAC,kBAAkB;IAG1B;;;;;OAKG;WACW,mBAAmB,CAC/B,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,MAAU,GACrE,4BAA4B;IAG/B;;;;OAIG;IACa,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAQ7D;;;OAGG;IACa,eAAe,IAAI,OAAO;IAM1C,8CAA8C;IAC9B,KAAK,IAAI,IAAI;IAM7B;;;;OAIG;IACI,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAKjE,iEAAiE;IACjD,sBAAsB,IAAI,MAAM;IAGhD;;;;;;;;;;;;MAYE;WACY,sBAAsB,CAClC,IAAI,EAAE,eAAe,GAAG,sBAAsB,EAC9C,aAAa,GAAE,QAA2B,EAC1C,SAAS,GAAE,KAAgC,EAC3C,OAAO,GAAE,MAAU,GAClB,4BAA4B;CAiBhC"}
|
|
@@ -34,10 +34,10 @@ class IndexedPolyfaceVisitor extends PolyfaceData_1.PolyfaceData {
|
|
|
34
34
|
this.auxData = polyface.data.auxData.createForVisitor();
|
|
35
35
|
if (polyface.data.edgeMateIndex)
|
|
36
36
|
this.edgeMateIndex = [];
|
|
37
|
-
this.reset();
|
|
38
37
|
this._numEdges = 0;
|
|
39
38
|
this._nextFacetIndex = 0;
|
|
40
39
|
this._currentFacetIndex = -1;
|
|
40
|
+
this.reset();
|
|
41
41
|
}
|
|
42
42
|
/** Return the client polyface object. */
|
|
43
43
|
clientPolyface() {
|
|
@@ -74,11 +74,14 @@ class IndexedPolyfaceVisitor extends PolyfaceData_1.PolyfaceData {
|
|
|
74
74
|
moveToReadIndex(facetIndex) {
|
|
75
75
|
if (!this._polyface.isValidFacetIndex(facetIndex))
|
|
76
76
|
return false;
|
|
77
|
-
|
|
77
|
+
const numEdges = this._polyface.numEdgeInFacet(facetIndex);
|
|
78
|
+
if (this._currentFacetIndex !== facetIndex || numEdges + this._numWrap !== this.pointCount) {
|
|
79
|
+
this._currentFacetIndex = facetIndex;
|
|
80
|
+
this._numEdges = numEdges;
|
|
81
|
+
this.resizeAllArrays(this._numEdges + this._numWrap);
|
|
82
|
+
this.gatherIndexedData(this._polyface.data, this._polyface.facetIndex0(this._currentFacetIndex), this._polyface.facetIndex1(this._currentFacetIndex), this._numWrap);
|
|
83
|
+
}
|
|
78
84
|
this._nextFacetIndex = facetIndex + 1;
|
|
79
|
-
this._numEdges = this._polyface.numEdgeInFacet(facetIndex);
|
|
80
|
-
this.resizeAllArrays(this._numEdges + this._numWrap);
|
|
81
|
-
this.gatherIndexedData(this._polyface.data, this._polyface.facetIndex0(this._currentFacetIndex), this._polyface.facetIndex1(this._currentFacetIndex), this._numWrap);
|
|
82
85
|
return true;
|
|
83
86
|
}
|
|
84
87
|
/** Advance the iterator to a the 'next' facet in the client polyface. */
|
|
@@ -88,7 +91,7 @@ class IndexedPolyfaceVisitor extends PolyfaceData_1.PolyfaceData {
|
|
|
88
91
|
this._nextFacetIndex++;
|
|
89
92
|
return true;
|
|
90
93
|
}
|
|
91
|
-
/**
|
|
94
|
+
/** Restart the visitor at the first facet. */
|
|
92
95
|
reset() {
|
|
93
96
|
this.moveToReadIndex(0);
|
|
94
97
|
this._nextFacetIndex = 0; // so immediate moveToNextFacet stays here.
|
|
@@ -187,6 +190,10 @@ class IndexedPolyfaceVisitor extends PolyfaceData_1.PolyfaceData {
|
|
|
187
190
|
this.color.push(Geometry_1.Geometry.interpolateColor(other.color[index0], fraction, other.color[index1]));
|
|
188
191
|
// TODO: auxData? taggedNumericData?
|
|
189
192
|
}
|
|
193
|
+
/** Create a visitor for a subset of the facets visitable by the instance. */
|
|
194
|
+
createSubsetVisitor(facetIndices, numWrap = 0) {
|
|
195
|
+
return IndexedPolyfaceSubsetVisitor.createSubsetVisitor(this._polyface, facetIndices, numWrap);
|
|
196
|
+
}
|
|
190
197
|
}
|
|
191
198
|
exports.IndexedPolyfaceVisitor = IndexedPolyfaceVisitor;
|
|
192
199
|
/**
|
|
@@ -196,38 +203,38 @@ exports.IndexedPolyfaceVisitor = IndexedPolyfaceVisitor;
|
|
|
196
203
|
* @public
|
|
197
204
|
*/
|
|
198
205
|
class IndexedPolyfaceSubsetVisitor extends IndexedPolyfaceVisitor {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
constructor(polyface,
|
|
206
|
+
_facetIndices;
|
|
207
|
+
_currentSubsetIndex; // index within _facetIndices, or -1 after construction
|
|
208
|
+
_nextSubsetIndex; // index within _facetIndices
|
|
209
|
+
constructor(polyface, facetIndices, numWrap) {
|
|
203
210
|
super(polyface, numWrap);
|
|
204
|
-
this.
|
|
205
|
-
this.
|
|
206
|
-
this.
|
|
211
|
+
this._facetIndices = facetIndices.slice();
|
|
212
|
+
this._currentSubsetIndex = -1;
|
|
213
|
+
this._nextSubsetIndex = 0;
|
|
214
|
+
this.reset();
|
|
207
215
|
}
|
|
208
216
|
isValidSubsetIndex(index) {
|
|
209
|
-
return
|
|
217
|
+
return index >= 0 && index < this._facetIndices.length;
|
|
210
218
|
}
|
|
211
219
|
/**
|
|
212
220
|
* Create a visitor for iterating a subset of the facets of `polyface`.
|
|
213
221
|
* @param polyface reference to the client polyface, supplying facets
|
|
214
|
-
* @param
|
|
222
|
+
* @param facetIndices array of indices of facets in the client polyface to visit. This array is cloned.
|
|
215
223
|
* @param numWrap number of vertices replicated in the visitor arrays to facilitate simpler caller code. Default is zero.
|
|
216
224
|
*/
|
|
217
|
-
static createSubsetVisitor(polyface,
|
|
218
|
-
return new IndexedPolyfaceSubsetVisitor(polyface,
|
|
225
|
+
static createSubsetVisitor(polyface, facetIndices, numWrap = 0) {
|
|
226
|
+
return new IndexedPolyfaceSubsetVisitor(polyface, facetIndices, numWrap);
|
|
219
227
|
}
|
|
220
228
|
/**
|
|
221
229
|
* Advance the iterator to a particular facet in the subset of client polyface facets.
|
|
222
|
-
* @param
|
|
223
|
-
* the client polyface.
|
|
230
|
+
* @param subsetIndex index into the subset array, not to be confused with the client facet index.
|
|
224
231
|
* @return whether the iterator was successfully moved.
|
|
225
232
|
*/
|
|
226
|
-
moveToReadIndex(
|
|
227
|
-
if (this.isValidSubsetIndex(
|
|
228
|
-
this.
|
|
229
|
-
this.
|
|
230
|
-
return super.moveToReadIndex(this.
|
|
233
|
+
moveToReadIndex(subsetIndex) {
|
|
234
|
+
if (this.isValidSubsetIndex(subsetIndex)) {
|
|
235
|
+
this._currentSubsetIndex = subsetIndex;
|
|
236
|
+
this._nextSubsetIndex = subsetIndex + 1;
|
|
237
|
+
return super.moveToReadIndex(this._facetIndices[subsetIndex]);
|
|
231
238
|
}
|
|
232
239
|
return false;
|
|
233
240
|
}
|
|
@@ -236,29 +243,31 @@ class IndexedPolyfaceSubsetVisitor extends IndexedPolyfaceVisitor {
|
|
|
236
243
|
* @return whether the iterator was successfully moved.
|
|
237
244
|
*/
|
|
238
245
|
moveToNextFacet() {
|
|
239
|
-
if (this.
|
|
240
|
-
return this.moveToReadIndex(this.
|
|
241
|
-
this.
|
|
246
|
+
if (this._nextSubsetIndex !== this._currentSubsetIndex)
|
|
247
|
+
return this.moveToReadIndex(this._nextSubsetIndex);
|
|
248
|
+
this._nextSubsetIndex++;
|
|
242
249
|
return true;
|
|
243
250
|
}
|
|
244
|
-
/**
|
|
251
|
+
/** Restart the visitor at the first facet. */
|
|
245
252
|
reset() {
|
|
246
|
-
this.
|
|
247
|
-
|
|
253
|
+
if (this._facetIndices) { // avoid crash during super ctor when we aren't yet initialized
|
|
254
|
+
this.moveToReadIndex(0);
|
|
255
|
+
this._nextSubsetIndex = 0; // so immediate moveToNextFacet stays here.
|
|
256
|
+
}
|
|
248
257
|
}
|
|
249
258
|
/**
|
|
250
|
-
* Return the
|
|
251
|
-
* @param
|
|
252
|
-
* @return valid client polyface facet index, or `undefined` if invalid
|
|
259
|
+
* Return the client polyface facet index (aka "readIndex") for the given subset index.
|
|
260
|
+
* @param subsetIndex index into the subset array. Default is the subset index of the currently visited facet.
|
|
261
|
+
* @return valid client polyface facet index, or `undefined` if invalid subset index.
|
|
253
262
|
*/
|
|
254
|
-
parentFacetIndex(
|
|
255
|
-
if (undefined ===
|
|
256
|
-
|
|
257
|
-
return this.isValidSubsetIndex(
|
|
263
|
+
parentFacetIndex(subsetIndex) {
|
|
264
|
+
if (undefined === subsetIndex)
|
|
265
|
+
subsetIndex = this._currentSubsetIndex;
|
|
266
|
+
return this.isValidSubsetIndex(subsetIndex) ? this._facetIndices[subsetIndex] : undefined;
|
|
258
267
|
}
|
|
259
268
|
/** Return the number of facets this visitor is able to visit. */
|
|
260
269
|
getVisitableFacetCount() {
|
|
261
|
-
return this.
|
|
270
|
+
return this._facetIndices.length;
|
|
262
271
|
}
|
|
263
272
|
/**
|
|
264
273
|
* Create a visitor for those mesh facets with normal in the same half-space as the given vector.
|