@itwin/core-geometry 3.4.0-dev.8 → 3.5.0-dev.11
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 +30 -1
- package/lib/cjs/clipping/ClipPrimitive.d.ts +3 -3
- package/lib/cjs/clipping/ClipPrimitive.js +3 -3
- package/lib/cjs/clipping/ClipPrimitive.js.map +1 -1
- package/lib/cjs/clipping/ClipUtils.d.ts +1 -1
- package/lib/cjs/clipping/ClipUtils.js +1 -1
- package/lib/cjs/clipping/ClipUtils.js.map +1 -1
- package/lib/cjs/clipping/ClipVector.d.ts +1 -1
- package/lib/cjs/clipping/ClipVector.js +1 -1
- package/lib/cjs/clipping/ClipVector.js.map +1 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts +16 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.js +43 -1
- 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/LineString3d.d.ts +3 -0
- package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineString3d.js +24 -0
- package/lib/cjs/curve/LineString3d.js.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.js +16 -4
- package/lib/cjs/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts +4 -1
- package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/MultiChainCollector.js +26 -1
- package/lib/cjs/curve/internalContexts/MultiChainCollector.js.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.d.ts +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +3 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +3 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts +8 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.js +37 -3
- package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.d.ts +11 -3
- package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.js +44 -6
- package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
- package/lib/cjs/geometry3d/PolylineOps.d.ts +5 -0
- package/lib/cjs/geometry3d/PolylineOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PolylineOps.js +20 -0
- package/lib/cjs/geometry3d/PolylineOps.js.map +1 -1
- package/lib/cjs/numerics/ClusterableArray.d.ts +4 -4
- package/lib/cjs/numerics/ClusterableArray.js +5 -5
- package/lib/cjs/numerics/ClusterableArray.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts +3 -3
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.js +8 -6
- package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.d.ts +69 -11
- package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js +163 -15
- package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/cjs/serialization/BGFBWriter.d.ts.map +1 -1
- package/lib/cjs/serialization/BGFBWriter.js +1 -0
- package/lib/cjs/serialization/BGFBWriter.js.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.d.ts +11 -0
- package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.js +51 -0
- package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.d.ts +23 -15
- package/lib/cjs/serialization/IModelJsonSchema.d.ts.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.js +17 -8
- package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/cjs/solid/Box.d.ts +4 -4
- package/lib/cjs/solid/Box.d.ts.map +1 -1
- package/lib/cjs/solid/Box.js +7 -7
- package/lib/cjs/solid/Box.js.map +1 -1
- package/lib/cjs/topology/Graph.d.ts +3 -3
- package/lib/cjs/topology/Graph.d.ts.map +1 -1
- package/lib/cjs/topology/Graph.js +2 -2
- package/lib/cjs/topology/Graph.js.map +1 -1
- package/lib/cjs/topology/HalfEdgeGraphSearch.d.ts +2 -2
- package/lib/cjs/topology/HalfEdgeGraphSearch.js +2 -2
- package/lib/cjs/topology/HalfEdgeGraphSearch.js.map +1 -1
- package/lib/cjs/topology/Merging.d.ts +5 -1
- package/lib/cjs/topology/Merging.d.ts.map +1 -1
- package/lib/cjs/topology/Merging.js +27 -15
- package/lib/cjs/topology/Merging.js.map +1 -1
- package/lib/cjs/topology/SpaceTriangulation.d.ts +47 -0
- package/lib/cjs/topology/SpaceTriangulation.d.ts.map +1 -0
- package/lib/cjs/topology/SpaceTriangulation.js +135 -0
- package/lib/cjs/topology/SpaceTriangulation.js.map +1 -0
- package/lib/esm/clipping/ClipPrimitive.d.ts +3 -3
- package/lib/esm/clipping/ClipPrimitive.js +3 -3
- package/lib/esm/clipping/ClipPrimitive.js.map +1 -1
- package/lib/esm/clipping/ClipUtils.d.ts +1 -1
- package/lib/esm/clipping/ClipUtils.js +1 -1
- package/lib/esm/clipping/ClipUtils.js.map +1 -1
- package/lib/esm/clipping/ClipVector.d.ts +1 -1
- package/lib/esm/clipping/ClipVector.js +1 -1
- package/lib/esm/clipping/ClipVector.js.map +1 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.d.ts +16 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.js +43 -1
- 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/LineString3d.d.ts +3 -0
- package/lib/esm/curve/LineString3d.d.ts.map +1 -1
- package/lib/esm/curve/LineString3d.js +24 -0
- package/lib/esm/curve/LineString3d.js.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.js +16 -4
- package/lib/esm/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts +4 -1
- package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/MultiChainCollector.js +26 -1
- package/lib/esm/curve/internalContexts/MultiChainCollector.js.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.d.ts +1 -1
- package/lib/esm/geometry3d/AngleSweep.js +1 -1
- package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +3 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +3 -1
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts +8 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.js +37 -3
- package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.d.ts +11 -3
- package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.js +44 -6
- package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
- package/lib/esm/geometry3d/PolylineOps.d.ts +5 -0
- package/lib/esm/geometry3d/PolylineOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/PolylineOps.js +20 -0
- package/lib/esm/geometry3d/PolylineOps.js.map +1 -1
- package/lib/esm/numerics/ClusterableArray.d.ts +4 -4
- package/lib/esm/numerics/ClusterableArray.js +5 -5
- package/lib/esm/numerics/ClusterableArray.js.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.d.ts +3 -3
- package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.js +8 -6
- package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.d.ts +69 -11
- package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js +164 -16
- package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/esm/serialization/BGFBWriter.d.ts.map +1 -1
- package/lib/esm/serialization/BGFBWriter.js +1 -0
- package/lib/esm/serialization/BGFBWriter.js.map +1 -1
- package/lib/esm/serialization/GeometrySamples.d.ts +11 -0
- package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/esm/serialization/GeometrySamples.js +51 -0
- package/lib/esm/serialization/GeometrySamples.js.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.d.ts +23 -15
- package/lib/esm/serialization/IModelJsonSchema.d.ts.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.js +17 -8
- package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/esm/solid/Box.d.ts +4 -4
- package/lib/esm/solid/Box.d.ts.map +1 -1
- package/lib/esm/solid/Box.js +7 -7
- package/lib/esm/solid/Box.js.map +1 -1
- package/lib/esm/topology/Graph.d.ts +3 -3
- package/lib/esm/topology/Graph.d.ts.map +1 -1
- package/lib/esm/topology/Graph.js +2 -2
- package/lib/esm/topology/Graph.js.map +1 -1
- package/lib/esm/topology/HalfEdgeGraphSearch.d.ts +2 -2
- package/lib/esm/topology/HalfEdgeGraphSearch.js +2 -2
- package/lib/esm/topology/HalfEdgeGraphSearch.js.map +1 -1
- package/lib/esm/topology/Merging.d.ts +5 -1
- package/lib/esm/topology/Merging.d.ts.map +1 -1
- package/lib/esm/topology/Merging.js +27 -15
- package/lib/esm/topology/Merging.js.map +1 -1
- package/lib/esm/topology/SpaceTriangulation.d.ts +47 -0
- package/lib/esm/topology/SpaceTriangulation.d.ts.map +1 -0
- package/lib/esm/topology/SpaceTriangulation.js +131 -0
- package/lib/esm/topology/SpaceTriangulation.js.map +1 -0
- package/package.json +8 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PolygonOps.js","sourceRoot":"","sources":["../../../src/geometry3d/PolygonOps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,0CAA+D;AAC/D,qDAAkD;AAClD,mDAAgD;AAChD,6EAA0E;AAC1E,iDAA8C;AAC9C,yDAAsD;AACtD,iEAA6F;AAC7F,uDAAsD;AACtD,+DAA4D;AAC5D,uDAAsD;AAEtD,mCAAgC;AAChC,uDAAoD;AAGpD;;;GAGG;AACH,MAAa,OAAO;IASlB,YAAmB,GAAqB;QACtC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;QAChD,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,CAAC;IACD;;;OAGG;IACI,MAAM,CA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AAG,GAAG,WAAW,IAAI,EAAE,IAAI,GAAG,EAAE;wBACtC,oDAAoD;qBACrD;yBAAM;wBACL,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;qBACtC;iBACF;gBACD,IAAI,EAAE,IAAI,CAAC;oBACT,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAClB,IAAI,GAAG,yBAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;gBAChC,EAAE,GAAG,EAAE,CAAC;aACT;SACF;QAED,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE;YACpB,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;SAChB;aAAM,IAAI,WAAW,GAAG,CAAC,EAAE;YAC1B,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;YACf,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;gBACvB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAChB;YACD,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;SACjB;IACH,CAAC;;AA3FH,wDA4FC;AA3FgB,gCAAS,GAAY,yBAAO,CAAC,MAAM,EAAE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\nimport { Geometry, PlaneAltitudeEvaluator } from \"../Geometry\";\r\nimport { Matrix4d } from \"../geometry4d/Matrix4d\";\r\nimport { Point4d } from \"../geometry4d/Point4d\";\r\nimport { XYParitySearchContext } from \"../topology/XYParitySearchContext\";\r\nimport { FrameBuilder } from \"./FrameBuilder\";\r\nimport { GrowableXYZArray } from \"./GrowableXYZArray\";\r\nimport { IndexedReadWriteXYZCollection, IndexedXYZCollection } from \"./IndexedXYZCollection\";\r\nimport { Point2d, Vector2d } from \"./Point2dVector2d\";\r\nimport { Point3dArrayCarrier } from \"./Point3dArrayCarrier\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { Range1d, Range3d } from \"./Range\";\r\nimport { Ray3d } from \"./Ray3d\";\r\nimport { SortablePolygon } from \"./SortablePolygon\";\r\nimport { XAndY } from \"./XYZProps\";\r\n\r\n/**\r\n * Carrier for a loop extracted from clip operation, annotated for sorting\r\n * @internal\r\n */\r\nexport class CutLoop {\r\n /* All points of the loop */\r\n public xyz: GrowableXYZArray;\r\n /* ray within point of \"on\" edge */\r\n public edge?: Ray3d;\r\n public sortCoordinate0: number;\r\n public sortCoordinate1: number;\r\n public sortDelta: number;\r\n public isNotch: boolean;\r\n public constructor(xyz: GrowableXYZArray) {\r\n this.xyz = xyz;\r\n this.edge = undefined;\r\n this.sortCoordinate0 = this.sortCoordinate1 = 0;\r\n this.sortDelta = 0;\r\n this.isNotch = false;\r\n }\r\n /**\r\n * Create a `CutLoop` structure annotated with the vector from last point to first.\r\n * @param xyz coordinates to capture\r\n */\r\n public static createCaptureWithReturnEdge(xyz: GrowableXYZArray): CutLoop {\r\n const result = new CutLoop(xyz);\r\n if (xyz.length >= 2)\r\n result.edge = Ray3d.createStartEnd(xyz.front()!, xyz.back()!);\r\n return result;\r\n }\r\n /**\r\n * Set up coordinates for sort steps:\r\n * * Make `sortCoordinate0` and `sortCoordinate` the (algebraically sorted) start and end fractions along the ray\r\n * * Make `sortDelta` the oriented difference of those two\r\n * * Hence sorting on the coordinates puts loops in left-to-right order by the their edge vector leftmost point.\r\n */\r\n public setSortCoordinates(ray: Ray3d) {\r\n this.sortDelta = this.edge!.direction.dotProduct(ray.direction);\r\n const a = ray.dotProductToPoint(this.edge!.origin);\r\n if (this.sortDelta >= 0) {\r\n this.sortCoordinate0 = a;\r\n this.sortCoordinate1 = a + this.sortDelta;\r\n } else {\r\n this.sortCoordinate0 = a + this.sortDelta; // and sortDelta is negative !!!\r\n this.sortCoordinate1 = a;\r\n\r\n }\r\n }\r\n /** Return\r\n * * 0 if other sort limits are not strictly contained in this.\r\n * * 1 if other sort limits are strictly contained with same direction\r\n * * -1 if other sort limits are strictly contained in opposite direction.\r\n */\r\n public containsSortLimits(other: CutLoop): number {\r\n if (other.sortCoordinate0 >= this.sortCoordinate1\r\n || other.sortCoordinate0 <= this.sortCoordinate0\r\n || other.sortCoordinate1 <= this.sortCoordinate0\r\n || other.sortCoordinate1 >= this.sortCoordinate1)\r\n return 0;\r\n return this.sortDelta * other.sortDelta > 0 ? 1 : -1;\r\n }\r\n /**\r\n * * push coordinates from other onto this\r\n * * reset this.sortCoordinate0 to other.sortCoordinate1\r\n * @param other new coordinates\r\n */\r\n public absorb(other: CutLoop) {\r\n this.xyz.pushFromGrowableXYZArray(other.xyz);\r\n this.sortCoordinate0 = other.sortCoordinate1;\r\n }\r\n /** Comparison function for system sort function applied to an array of CutLoop .... */\r\n public static sortFunction(loopA: CutLoop, loopB: CutLoop): number {\r\n const q = loopA.sortCoordinate0 - loopB.sortCoordinate0;\r\n return q > 0 ? 1 : -1;\r\n }\r\n\r\n /** Return first point coordinates.\r\n * * For type checking, assume array is not empty.\r\n */\r\n public front(result?: Point3d): Point3d { return this.xyz.front(result)!; }\r\n /** Return last point coordinates.\r\n * * For type checking, assume array is not empty.\r\n */\r\n public back(result?: Point3d): Point3d { return this.xyz.back(result)!; }\r\n\r\n}\r\n/**\r\n * Context to hold an array of input loops and apply sort logic.\r\n * * This is used when a non-convex face is clipped by a plane\r\n * * Simple convex clip logic in this case generates double-back edges that need to be eliminated.\r\n * * This class manages the elimination.\r\n * * Usage pattern is:\r\n * @internal\r\n */\r\nexport class CutLoopMergeContext {\r\n /** Array (filled by user code) of loops being sorted. Contents are subject to being changed during sort. */\r\n public inputLoops: CutLoop[];\r\n /** Array (filled by sortAndMergeLoops) of reorganized loops. */\r\n public outputLoops: CutLoop[];\r\n // Initialize with empty loop arrays.\r\n public constructor() {\r\n this.inputLoops = [];\r\n this.outputLoops = [];\r\n }\r\n /**\r\n * * Search all start and end points for the one most distant from point0.\r\n */\r\n private mostDistantPoint(point0: Point3d, workPoint: Point3d, resultPoint: Point3d) {\r\n let dMax = -1.0;\r\n resultPoint.setZero();\r\n let d;\r\n for (const loop of this.inputLoops) {\r\n loop.front(workPoint);\r\n d = workPoint.distanceSquared(point0);\r\n if (d > dMax) {\r\n dMax = d;\r\n resultPoint.setFromPoint3d(workPoint);\r\n }\r\n loop.back(workPoint);\r\n d = workPoint.distanceSquared(point0);\r\n if (d > dMax) {\r\n dMax = d;\r\n resultPoint.setFromPoint3d(workPoint);\r\n }\r\n }\r\n }\r\n /**\r\n * * Find a long (probably longest) edge through start and end points of inputs.\r\n * * Setup sortCoordinate0 and sortCoordinate1 along that edge for each loop\r\n * * sort all inputLoop members by sortCoordinate0.\r\n */\r\n private sortInputs() {\r\n if (this.inputLoops.length > 0 && this.inputLoops[0].xyz.length > 0) {\r\n const point0 = this.inputLoops[0].xyz.front()!;\r\n const workPoint = Point3d.create();\r\n const point1 = Point3d.create();\r\n // point0 could be in the middle. Find the most distant point ...\r\n this.mostDistantPoint(point0, workPoint, point1);\r\n // And again from point1 to get to the other extreme . .\r\n this.mostDistantPoint(point1, workPoint, point0);\r\n const sortRay = Ray3d.createStartEnd(point0, point1);\r\n sortRay.direction.normalizeInPlace();\r\n for (const loop of this.inputLoops)\r\n loop.setSortCoordinates(sortRay);\r\n this.inputLoops.sort(CutLoop.sortFunction);\r\n\r\n }\r\n }\r\n /**\r\n * * sort all input loops by coordinate along the cut edge\r\n * * sweep left to right, using start and end coordinates to decide if loops are outer or hole, and combine holes into their containing outer loops.\r\n */\r\n public sortAndMergeLoops() {\r\n this.sortInputs();\r\n const inputs = this.inputLoops;\r\n const outputs = this.outputLoops;\r\n const stack = [];\r\n outputs.length = 0;\r\n for (const candidate of inputs) {\r\n candidate.isNotch = false;\r\n // candidate must be either (a) absorbed in to of stack or (b) pushed onto stack.\r\n // If pushed, must have indication of natch state.\r\n for (; stack.length > 0;) {\r\n const topOfStack = stack[stack.length - 1];\r\n const containment = topOfStack.containsSortLimits(candidate);\r\n if (containment === 0) {\r\n if (!topOfStack.isNotch)\r\n outputs.push(topOfStack);\r\n stack.pop();\r\n continue; // a larger topOfStack may have appeared !\r\n candidate.isNotch = false;\r\n } else if (containment === 1) {\r\n candidate.isNotch = false;\r\n break;\r\n } else {\r\n topOfStack.absorb(candidate);\r\n candidate.isNotch = true;\r\n break;\r\n }\r\n }\r\n stack.push(candidate);\r\n }\r\n // Anything on stack must be complete ...\r\n for (const p of stack) {\r\n if (!p.isNotch)\r\n outputs.push(p);\r\n }\r\n }\r\n}\r\n/** Static class for operations that treat an array of points as a polygon (with area!) */\r\n/**\r\n * Various (static method) computations for arrays of points interpreted as a polygon.\r\n * @public\r\n */\r\nexport class PolygonOps {\r\n /** Sum areas of triangles from points[0] to each far edge.\r\n * * Consider triangles from points[0] to each edge.\r\n * * Sum the areas(absolute, without regard to orientation) all these triangles.\r\n * @returns sum of absolute triangle areas.\r\n */\r\n public static sumTriangleAreas(points: Point3d[] | GrowableXYZArray): number {\r\n let s = 0;\r\n const n = points.length;\r\n if (Array.isArray(points)) {\r\n if (n >= 3) {\r\n const origin = points[0];\r\n const vector0 = origin.vectorTo(points[1]);\r\n let vector1 = Vector3d.create();\r\n // This will work with or without closure edge. If closure is given, the last vector is 000.\r\n for (let i = 2; i < n; i++) {\r\n vector1 = origin.vectorTo(points[i], vector1);\r\n s += vector0.crossProductMagnitude(vector1);\r\n vector0.setFrom(vector1);\r\n }\r\n }\r\n return s * 0.5;\r\n }\r\n const crossVector = Vector3d.create();\r\n for (let i = 2; i < n; i++) {\r\n points.crossProductIndexIndexIndex(0, i - 1, i, crossVector);\r\n s += crossVector.magnitude();\r\n }\r\n return s * 0.5;\r\n }\r\n /** Sum areas of triangles from points[0] to each far edge.\r\n * * Consider triangles from points[0] to each edge.\r\n * * Sum the areas(absolute, without regard to orientation) all these triangles.\r\n * @returns sum of absolute triangle areas.\r\n */\r\n public static sumTriangleAreasXY(points: Point3d[]): number {\r\n let s = 0.0;\r\n const n = points.length;\r\n if (n >= 3) {\r\n const origin = points[0];\r\n const vector0 = origin.vectorTo(points[1]);\r\n let vector1 = Vector3d.create();\r\n // This will work with or without closure edge. If closure is given, the last vector is 000.\r\n for (let i = 2; i < n; i++) {\r\n vector1 = origin.vectorTo(points[i], vector1);\r\n s += vector0.crossProductXY(vector1);\r\n vector0.setFrom(vector1);\r\n }\r\n }\r\n s *= 0.5;\r\n // console.log (\"polygon area \", s, points);\r\n return s;\r\n }\r\n /** These values are the integrated area moment products [xx,xy,xz, x]\r\n * for a right triangle in the first quadrant at the origin -- (0,0),(1,0),(0,1)\r\n */\r\n private static readonly _triangleMomentWeights = Matrix4d.createRowValues(2.0 / 24.0, 1.0 / 24.0, 0, 4.0 / 24.0, 1.0 / 24.0, 2.0 / 24.0, 0, 4.0 / 24.0, 0, 0, 0, 0, 4.0 / 24.0, 4.0 / 24.0, 0, 12.0 / 24.0);\r\n /** These values are the integrated volume moment products [xx,xy,xz, x, yx,yy,yz,y, zx,zy,zz,z,x,y,z,1]\r\n * for a tetrahedron in the first quadrant at the origin -- (0,00),(1,0,0),(0,1,0),(0,0,1)\r\n */\r\n private static readonly _tetrahedralMomentWeights = Matrix4d.createRowValues(\r\n 1.0 / 60.0, 1.0 / 120, 1.0 / 120, 1.0 / 24.0,\r\n 1.0 / 120, 1.0 / 60.0, 1.0 / 120, 1.0 / 24.0,\r\n 1.0 / 120, 1.0 / 120, 1.0 / 60.0, 1.0 / 24.0,\r\n 1.0 / 24.0, 1.0 / 24.0, 1.0 / 24.0, 1.0 / 6.0);\r\n // statics for shared reuse.\r\n // many methods use these.\r\n // only use them in \"leaf\" methods that are certain not to call other users . . .\r\n private static _vector0 = Vector3d.create();\r\n private static _vector1 = Vector3d.create();\r\n private static _vector2 = Vector3d.create();\r\n private static _vectorOrigin = Vector3d.create();\r\n private static _normal = Vector3d.create();\r\n private static _matrixA = Matrix4d.createIdentity();\r\n private static _matrixB = Matrix4d.createIdentity();\r\n private static _matrixC = Matrix4d.createIdentity();\r\n /** return a vector which is perpendicular to the polygon and has magnitude equal to the polygon area. */\r\n public static areaNormalGo(points: IndexedXYZCollection, result?: Vector3d): Vector3d | undefined {\r\n if (!result)\r\n result = new Vector3d();\r\n const n = points.length;\r\n if (n === 3) {\r\n points.crossProductIndexIndexIndex(0, 1, 2, result);\r\n } else if (n >= 3) {\r\n result.setZero();\r\n // This will work with or without closure edge. If closure is given, the last vector is 000.\r\n for (let i = 2; i < n; i++) {\r\n points.accumulateCrossProductIndexIndexIndex(0, i - 1, i, result);\r\n }\r\n }\r\n // ALL BRANCHES SUM FULL CROSS PRODUCTS AND EXPECT SCALE HERE\r\n result.scaleInPlace(0.5);\r\n return result;\r\n }\r\n /** return a vector which is perpendicular to the polygon and has magnitude equal to the polygon area. */\r\n public static areaNormal(points: Point3d[], result?: Vector3d): Vector3d {\r\n if (!result)\r\n result = Vector3d.create();\r\n PolygonOps.areaNormalGo(new Point3dArrayCarrier(points), result);\r\n return result;\r\n }\r\n /** return the area of the polygon.\r\n * * This assumes the polygon is planar\r\n * * This does NOT assume the polygon is on the xy plane.\r\n */\r\n public static area(points: Point3d[]): number {\r\n return PolygonOps.areaNormal(points).magnitude();\r\n }\r\n /** return the projected XY area of the polygon. */\r\n public static areaXY(points: Point3d[] | IndexedXYZCollection): number {\r\n let area = 0.0;\r\n if (points instanceof IndexedXYZCollection) {\r\n if (points.length > 2) {\r\n const x0 = points.getXAtUncheckedPointIndex(0);\r\n const y0 = points.getYAtUncheckedPointIndex(0);\r\n let u1 = points.getXAtUncheckedPointIndex(1) - x0;\r\n let v1 = points.getYAtUncheckedPointIndex(1) - y0;\r\n let u2, v2;\r\n for (let i = 1; i + 1 < points.length; i++, u1 = u2, v1 = v2) {\r\n u2 = points.getXAtUncheckedPointIndex(i) - x0;\r\n v2 = points.getYAtUncheckedPointIndex(i) - y0;\r\n area += Geometry.crossProductXYXY(u1, v1, u2, v2);\r\n }\r\n }\r\n } else {\r\n for (let i = 1; i + 1 < points.length; i++)\r\n area += points[0].crossProductToPointsXY(points[i], points[i + 1]);\r\n }\r\n return 0.5 * area;\r\n }\r\n /** Sum the areaXY () values for multiple polygons */\r\n public static sumAreaXY(polygons: Point3d[][]): number{\r\n let s = 0.0;\r\n for (const p of polygons)\r\n s += this.areaXY(p);\r\n return s;\r\n }\r\n /**\r\n * Return a Ray3d with (assuming the polygon is planar and not self-intersecting)\r\n * * origin at the centroid of the (3D) polygon\r\n * * normal is a unit vector perpendicular to the plane\r\n * * 'a' member is the area.\r\n * @param points\r\n */\r\n public static centroidAreaNormal(points: IndexedXYZCollection | Point3d[]): Ray3d | undefined {\r\n if (Array.isArray(points)) {\r\n const carrier = new Point3dArrayCarrier(points);\r\n return this.centroidAreaNormal(carrier);\r\n }\r\n const n = points.length;\r\n if (n === 3) {\r\n const normal = points.crossProductIndexIndexIndex(0, 1, 2)!;\r\n const a = 0.5 * normal.magnitude();\r\n const centroid = points.getPoint3dAtCheckedPointIndex(0)!;\r\n points.accumulateScaledXYZ(1, 1.0, centroid);\r\n points.accumulateScaledXYZ(2, 1.0, centroid);\r\n centroid.scaleInPlace(1.0 / 3.0);\r\n const result = Ray3d.createCapture(centroid, normal);\r\n if (result.tryNormalizeInPlaceWithAreaWeight(a))\r\n return result;\r\n return undefined;\r\n }\r\n if (n >= 3) {\r\n\r\n const areaNormal = Vector3d.createZero();\r\n // This will work with or without closure edge. If closure is given, the last vector is 000.\r\n for (let i = 2; i < n; i++) {\r\n points.accumulateCrossProductIndexIndexIndex(0, i - 1, i, areaNormal);\r\n }\r\n areaNormal.normalizeInPlace();\r\n\r\n const origin = points.getPoint3dAtCheckedPointIndex(0)!;\r\n const vector0 = Vector3d.create();\r\n const vector1 = Vector3d.create();\r\n points.vectorXYAndZIndex(origin, 1, vector0);\r\n let cross = Vector3d.create();\r\n const centroidSum = Vector3d.createZero();\r\n const normalSum = Vector3d.createZero();\r\n let signedTriangleArea;\r\n // This will work with or without closure edge. If closure is given, the last vector is 000.\r\n for (let i = 2; i < n; i++) {\r\n points.vectorXYAndZIndex(origin, i, vector1);\r\n cross = vector0.crossProduct(vector1, cross);\r\n signedTriangleArea = areaNormal.dotProduct(cross); // well, actually twice the area.\r\n normalSum.addInPlace(cross); // this grows to twice the area\r\n const b = signedTriangleArea / 6.0;\r\n centroidSum.plus2Scaled(vector0, b, vector1, b, centroidSum);\r\n vector0.setFrom(vector1);\r\n }\r\n const area = 0.5 * normalSum.magnitude();\r\n const inverseArea = Geometry.conditionalDivideFraction(1, area);\r\n if (inverseArea !== undefined) {\r\n const result = Ray3d.createCapture(origin.plusScaled(centroidSum, inverseArea), normalSum);\r\n result.tryNormalizeInPlaceWithAreaWeight(area);\r\n return result;\r\n }\r\n }\r\n return undefined;\r\n }\r\n // Has the potential to be combined with centroidAreaNormal for point3d array and Ray3d return listed above...\r\n // Returns undefined if given point array less than 3 or if not safe to divide at any point\r\n /**\r\n * * Return (in caller-allocated centroid) the centroid of the xy polygon.\r\n * * Return (as function value) the area\r\n */\r\n public static centroidAndAreaXY(points: Point2d[], centroid: Point2d): number | undefined {\r\n let area = 0.0;\r\n centroid.set(0, 0);\r\n if (points.length < 3)\r\n return undefined;\r\n const origin = points[0];\r\n let vectorSum = Vector2d.create(0, 0); // == sum ((U+V)/3) * (U CROSS V)/2 -- but leave out divisions\r\n let areaSum = 0.0; // == sum (U CROSS V) / 2 -- but leave out divisions\r\n for (let i = 1; i + 1 < points.length; i++) {\r\n const vector0 = origin.vectorTo(points[i]);\r\n const vector1 = origin.vectorTo(points[i + 1]);\r\n const tempArea = vector0.crossProduct(vector1);\r\n vectorSum = vectorSum.plus(vector0.plus(vector1).scale(tempArea));\r\n areaSum += tempArea;\r\n }\r\n area = areaSum * 0.5;\r\n const a = Geometry.conditionalDivideFraction(1.0, 6.0 * area);\r\n if (a === undefined) {\r\n centroid.setFrom(origin);\r\n return undefined;\r\n }\r\n centroid.setFrom(origin.plusScaled(vectorSum, a));\r\n return area;\r\n }\r\n /**\r\n * Return a unit normal to the plane of the polygon.\r\n * @param points array of points around the polygon.\r\n * @param result caller-allocated result vector.\r\n */\r\n public static unitNormal(points: IndexedXYZCollection, result: Vector3d): boolean {\r\n let n = points.length;\r\n if (n > 1 && points.getPoint3dAtUncheckedPointIndex(0).isExactEqual(points.getPoint3dAtUncheckedPointIndex(n - 1)))\r\n --n; // ignore closure point\r\n if (n === 3) {\r\n points.crossProductIndexIndexIndex(0, 1, 2, result);\r\n return result.normalizeInPlace();\r\n }\r\n if (n === 4) {\r\n // cross product of diagonals is more stable than from single of the points . . .\r\n points.vectorIndexIndex(0, 2, PolygonOps._vector0);\r\n points.vectorIndexIndex(1, 3, PolygonOps._vector1);\r\n PolygonOps._vector0.crossProduct(PolygonOps._vector1, result);\r\n return result.normalizeInPlace();\r\n }\r\n // more than 4 points ... no shortcuts ...\r\n PolygonOps.areaNormalGo(points, result);\r\n return result.normalizeInPlace();\r\n }\r\n /** Accumulate to the matrix of area products of a polygon with respect to an origin.\r\n * The polygon is assumed to be planar and non-self-intersecting.\r\n */\r\n /** Accumulate to the matrix of area products of a polygon with respect to an origin.\r\n * * The polygon is assumed to be planar and non-self-intersecting.\r\n * * Accumulated values are integrals over triangles from point 0 of the polygon to other edges of the polygon.\r\n * * Integral over each triangle is transformed to integrals from the given origin.\r\n * @param points array of points around the polygon. Final closure point is not needed.\r\n * @param origin origin for global accumulation.\r\n * @param moments 4x4 matrix where products are accumulated.\r\n */\r\n public static addSecondMomentAreaProducts(points: IndexedXYZCollection, origin: Point3d, moments: Matrix4d) {\r\n this.addSecondMomentTransformedProducts(PolygonOps._triangleMomentWeights, points, origin, 2, moments);\r\n }\r\n\r\n /** Accumulate to the matrix of volume products of a polygon with respect to an origin.\r\n * * The polygon is assumed to be planar and non-self-intersecting.\r\n * * Accumulated values are integrals over tetrahedra from the origin to triangles on the polygon.\r\n * @param points array of points around the polygon. Final closure point is not needed.\r\n * @param origin origin for tetrahedra\r\n * @param moments 4x4 matrix where products are accumulated.\r\n */\r\n public static addSecondMomentVolumeProducts(points: IndexedXYZCollection, origin: Point3d, moments: Matrix4d) {\r\n this.addSecondMomentTransformedProducts(PolygonOps._tetrahedralMomentWeights, points, origin, 3, moments);\r\n }\r\n /** Return the matrix of area products of a polygon with respect to an origin.\r\n * The polygon is assumed to be planar and non-self-intersecting.\r\n * * `frameType===2` has xy vectors in the plane of the polygon, plus a unit normal z. (Used for area integrals)\r\n * * `frameType===3` has vectors from origin to 3 points in the triangle. (Used for volume integrals)\r\n */\r\n private static addSecondMomentTransformedProducts(firstQuadrantMoments: Matrix4d, points: IndexedXYZCollection, origin: Point3d,\r\n frameType: 2 | 3,\r\n moments: Matrix4d) {\r\n const unitNormal = PolygonOps._normal;\r\n if (PolygonOps.unitNormal(points, unitNormal)) {\r\n // The direction of the normal makes the various detJ values positive or negative so that non-convex polygons\r\n // sum correctly.\r\n const vector01 = PolygonOps._vector0;\r\n const vector02 = PolygonOps._vector1;\r\n const vector03 = PolygonOps._vector2;\r\n const placement = PolygonOps._matrixA;\r\n const matrixAB = PolygonOps._matrixB;\r\n const matrixABC = PolygonOps._matrixC;\r\n const vectorOrigin = points.vectorXYAndZIndex(origin, 0, PolygonOps._vectorOrigin)!;\r\n const numPoints = points.length;\r\n let detJ = 0;\r\n for (let i2 = 2; i2 < numPoints; i2++) {\r\n if (frameType === 2) {\r\n points.vectorIndexIndex(0, i2 - 1, vector01);\r\n points.vectorIndexIndex(0, i2, vector02);\r\n detJ = unitNormal.tripleProduct(vector01, vector02);\r\n placement.setOriginAndVectors(vectorOrigin, vector01, vector02, unitNormal);\r\n placement.multiplyMatrixMatrix(firstQuadrantMoments, matrixAB);\r\n matrixAB.multiplyMatrixMatrixTranspose(placement, matrixABC);\r\n moments.addScaledInPlace(matrixABC, detJ);\r\n } else if (frameType === 3) {\r\n points.vectorXYAndZIndex(origin, 0, vector01);\r\n points.vectorXYAndZIndex(origin, i2 - 1, vector02);\r\n points.vectorXYAndZIndex(origin, i2, vector03);\r\n detJ = vector01.tripleProduct(vector02, vector03);\r\n placement.setOriginAndVectors(origin, vector01, vector02, vector03);\r\n placement.multiplyMatrixMatrix(firstQuadrantMoments, matrixAB);\r\n matrixAB.multiplyMatrixMatrixTranspose(placement, matrixABC);\r\n moments.addScaledInPlace(matrixABC, detJ);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** Test the direction of turn at the vertices of the polygon, ignoring z-coordinates.\r\n *\r\n * * For a polygon without self intersections, this is a convexity and orientation test: all positive is convex and counterclockwise,\r\n * all negative is convex and clockwise\r\n * * Beware that a polygon which turns through more than a full turn can cross itself and close, but is not convex\r\n * * Returns 1 if all turns are to the left, -1 if all to the right, and 0 if there are any zero or reverse turns\r\n */\r\n public static testXYPolygonTurningDirections(pPointArray: Point2d[] | Point3d[]): number {\r\n // Reduce count by trailing duplicates; leaves iLast at final index\r\n let numPoint = pPointArray.length;\r\n let iLast = numPoint - 1;\r\n while (iLast > 1 && pPointArray[iLast].x === pPointArray[0].x && pPointArray[iLast].y === pPointArray[0].y) {\r\n numPoint = iLast--;\r\n }\r\n if (numPoint > 2) {\r\n let vector0 = Point2d.create(pPointArray[iLast].x - pPointArray[iLast - 1].x, pPointArray[iLast].y - pPointArray[iLast - 1].y);\r\n const vector1 = Point2d.create(pPointArray[0].x - pPointArray[iLast].x, pPointArray[0].y - pPointArray[iLast].y);\r\n const baseArea = vector0.x * vector1.y - vector0.y * vector1.x;\r\n // In a convex polygon, all successive-vector cross products will\r\n // have the same sign as the base area, hence all products will be\r\n // positive.\r\n for (let i1 = 1; i1 < numPoint; i1++) {\r\n vector0 = vector1.clone();\r\n Point2d.create(pPointArray[i1].x - pPointArray[i1 - 1].x, pPointArray[i1].y - pPointArray[i1 - 1].y, vector1);\r\n const currArea = vector0.x * vector1.y - vector0.y * vector1.x;\r\n if (currArea * baseArea <= 0.0)\r\n return 0;\r\n }\r\n // Fall out with all signs same as base area\r\n return baseArea > 0.0 ? 1 : -1;\r\n }\r\n return 0;\r\n }\r\n /**\r\n * Test if point (x,y) is IN, OUT or ON a polygon.\r\n * @return (1) for in, (-1) for OUT, (0) for ON\r\n * @param x x coordinate\r\n * @param y y coordinate\r\n * @param points array of xy coordinates.\r\n */\r\n public static classifyPointInPolygon(x: number, y: number, points: XAndY[]): number | undefined {\r\n const context = new XYParitySearchContext(x, y);\r\n let i0 = 0;\r\n const n = points.length;\r\n let i1;\r\n let iLast = -1;\r\n // walk to an acceptable start index ...\r\n for (i0 = 0; i0 < n; i0++) {\r\n i1 = i0 + 1;\r\n if (i1 >= n)\r\n i1 = 0;\r\n if (context.tryStartEdge(points[i0].x, points[i0].y, points[i1].x, points[i1].y)) {\r\n iLast = i1;\r\n break;\r\n }\r\n }\r\n if (iLast < 0)\r\n return undefined;\r\n for (let i = 1; i <= n; i++) {\r\n i1 = iLast + i;\r\n if (i1 >= n)\r\n i1 -= n;\r\n if (!context.advance(points[i1].x, points[i1].y))\r\n return context.classifyCounts();\r\n }\r\n return context.classifyCounts();\r\n }\r\n /**\r\n * Test if point (x,y) is IN, OUT or ON a polygon.\r\n * @return (1) for in, (-1) for OUT, (0) for ON\r\n * @param x x coordinate\r\n * @param y y coordinate\r\n * @param points array of xy coordinates.\r\n */\r\n public static classifyPointInPolygonXY(x: number, y: number, points: IndexedXYZCollection): number | undefined {\r\n const context = new XYParitySearchContext(x, y);\r\n let i0 = 0;\r\n const n = points.length;\r\n let i1;\r\n let iLast = -1;\r\n // walk to an acceptable start index ...\r\n for (i0 = 0; i0 < n; i0++) {\r\n i1 = i0 + 1;\r\n if (i1 >= n)\r\n i1 = 0;\r\n if (context.tryStartEdge(points.getXAtUncheckedPointIndex(i0), points.getYAtUncheckedPointIndex(i0), points.getXAtUncheckedPointIndex(i1), points.getYAtUncheckedPointIndex(i1))) {\r\n iLast = i1;\r\n break;\r\n }\r\n }\r\n if (iLast < 0)\r\n return undefined;\r\n for (let i = 1; i <= n; i++) {\r\n i1 = iLast + i;\r\n if (i1 >= n)\r\n i1 -= n;\r\n if (!context.advance(points.getXAtUncheckedPointIndex(i1), points.getYAtUncheckedPointIndex(i1)))\r\n return context.classifyCounts();\r\n }\r\n return context.classifyCounts();\r\n }\r\n\r\n /**\r\n * Reverse loops as necessary to make them all have CCW orientation for given outward normal.\r\n * @param loops\r\n * @param outwardNormal\r\n * @return the number of loops reversed.\r\n */\r\n public static orientLoopsCCWForOutwardNormalInPlace(loops: IndexedReadWriteXYZCollection | IndexedReadWriteXYZCollection[], outwardNormal: Vector3d): number {\r\n if (loops instanceof IndexedXYZCollection)\r\n return this.orientLoopsCCWForOutwardNormalInPlace([loops], outwardNormal);\r\n const orientations: number[] = [];\r\n const unitNormal = Vector3d.create();\r\n // orient individually ... (no hole analysis)\r\n let numReverse = 0;\r\n for (const loop of loops) {\r\n if (this.unitNormal(loop, unitNormal)) {\r\n const q = unitNormal.dotProduct(outwardNormal);\r\n orientations.push(q);\r\n if (q <= 0.0)\r\n loop.reverseInPlace();\r\n numReverse++;\r\n } else {\r\n orientations.push(0.0);\r\n }\r\n }\r\n return numReverse;\r\n }\r\n /**\r\n * Reverse loops as necessary to make them all have CCW orientation for given outward normal.\r\n * * Return an array of arrays which capture the input pointers.\r\n * * In each first level array:\r\n * * The first loop is an outer loop.\r\n * * all subsequent loops are holes\r\n * * The outer loop is CCW\r\n * * The holes are CW.\r\n * * Call RegionOps.sortOuterAndHoleLoopsXY to have the result returned as a UnionRegion\r\n * @param loops multiple loops to sort and reverse.\r\n */\r\n public static sortOuterAndHoleLoopsXY(loops: IndexedReadWriteXYZCollection[]): IndexedReadWriteXYZCollection[][] {\r\n const loopAndArea: SortablePolygon[] = [];\r\n for (const loop of loops) {\r\n SortablePolygon.pushPolygon(loopAndArea, loop);\r\n }\r\n return SortablePolygon.sortAsArrayOfArrayOfPolygons(loopAndArea);\r\n }\r\n\r\n /**\r\n * Exactly like `sortOuterAndHoleLoopsXY` but allows loops in any plane.\r\n * @param loops multiple loops to sort and reverse.\r\n * @param defaultNormal optional normal for the loops, if known\r\n */\r\n public static sortOuterAndHoleLoops(loops: IndexedReadWriteXYZCollection[], defaultNormal: Vector3d | undefined): IndexedReadWriteXYZCollection[][] {\r\n const localToWorld = FrameBuilder.createRightHandedFrame(defaultNormal, loops);\r\n const worldToLocal = localToWorld?.inverse();\r\n\r\n const xyLoops: GrowableXYZArray[] = [];\r\n if (worldToLocal !== undefined) {\r\n // transform into plane so we can ignore z in the sort\r\n for (const loop of loops) {\r\n const xyLoop = new GrowableXYZArray(loop.length);\r\n for (const point of loop.points)\r\n xyLoop.push(worldToLocal.multiplyPoint3d(point));\r\n xyLoops.push(xyLoop);\r\n }\r\n }\r\n const xySortedLoopsArray = PolygonOps.sortOuterAndHoleLoopsXY(xyLoops);\r\n\r\n const sortedLoopsArray: GrowableXYZArray[][] = [];\r\n if (localToWorld !== undefined) {\r\n for (const xySortedLoops of xySortedLoopsArray) {\r\n const sortedLoops: GrowableXYZArray[] = [];\r\n for (const xySortedLoop of xySortedLoops) {\r\n const sortedLoop = new GrowableXYZArray(xySortedLoop.length);\r\n for (const point of xySortedLoop.points)\r\n sortedLoop.push(localToWorld.multiplyPoint3d(point));\r\n sortedLoops.push(sortedLoop);\r\n }\r\n sortedLoopsArray.push(sortedLoops);\r\n }\r\n }\r\n return sortedLoopsArray;\r\n }\r\n}\r\n\r\n/**\r\n * `IndexedXYZCollectionPolygonOps` class contains _static_ methods for typical operations on polygons carried as `IndexedXyZCollection`\r\n * @public\r\n */\r\nexport class IndexedXYZCollectionPolygonOps {\r\n private static _xyz0Work: Point3d = Point3d.create();\r\n private static _xyz1Work: Point3d = Point3d.create();\r\n private static _xyz2Work: Point3d = Point3d.create();\r\n /**\r\n * Split a (convex) polygon into 2 parts based on altitude evaluations.\r\n * * POSITIVE ALTITUDE IS IN\r\n * @param plane any `PlaneAltitudeEvaluator` object that can evaluate `plane.altitude(xyz)` for distance from the plane.\r\n * @param xyz original polygon\r\n * @param xyzPositive array to receive inside part (altitude > 0)\r\n * @param xyzNegative array to receive outside part\r\n * @param altitudeRange min and max altitudes encountered.\r\n */\r\n public static splitConvexPolygonInsideOutsidePlane(plane: PlaneAltitudeEvaluator,\r\n xyz: IndexedReadWriteXYZCollection,\r\n xyzPositive: IndexedReadWriteXYZCollection,\r\n xyzNegative: IndexedReadWriteXYZCollection, altitudeRange: Range1d) {\r\n const xyz0 = IndexedXYZCollectionPolygonOps._xyz0Work;\r\n const xyz1 = IndexedXYZCollectionPolygonOps._xyz1Work;\r\n const xyzInterpolated = IndexedXYZCollectionPolygonOps._xyz2Work;\r\n const n = xyz.length;\r\n xyzPositive.clear();\r\n xyzNegative.clear();\r\n // let numSplit = 0;\r\n const fractionTol = 1.0e-8;\r\n if (n > 2) {\r\n xyz.back(xyz0);\r\n altitudeRange.setNull();\r\n let a0 = plane.altitude(xyz0);\r\n altitudeRange.extendX(a0);\r\n // if (a0 >= 0.0)\r\n // work.push_back (xyz0);\r\n for (let i1 = 0; i1 < n; i1++) {\r\n xyz.getPoint3dAtUncheckedPointIndex(i1, xyz1);\r\n const a1 = plane.altitude(xyz1);\r\n altitudeRange.extendX(a1);\r\n let nearZero = false;\r\n if (a0 * a1 < 0.0) {\r\n // simple crossing. . .\r\n const f = - a0 / (a1 - a0);\r\n if (f > 1.0 - fractionTol && a1 >= 0.0) {\r\n // the endpoint will be saved -- avoid the duplicate\r\n nearZero = true;\r\n } else {\r\n xyz0.interpolate(f, xyz1, xyzInterpolated);\r\n xyzPositive.push(xyzInterpolated);\r\n xyzNegative.push(xyzInterpolated);\r\n }\r\n // numSplit++;\r\n }\r\n if (a1 >= 0.0 || nearZero)\r\n xyzPositive.push(xyz1);\r\n if (a1 <= 0.0 || nearZero)\r\n xyzNegative.push(xyz1);\r\n xyz0.setFromPoint3d(xyz1);\r\n a0 = a1;\r\n }\r\n }\r\n }\r\n /**\r\n * Clip a polygon to one side of a plane.\r\n * * Results with 2 or fewer points are ignored.\r\n * * Other than ensuring capacity in the arrays, there are no object allocations during execution of this function.\r\n * * plane is passed as unrolled Point4d (ax,ay,az,aw) point (x,y,z) acts as homogeneous (x,y,z,1)\r\n * * `keepPositive === true` selects positive altitudes.\r\n * @param plane any type that has `plane.altitude`\r\n * @param xyz input points.\r\n * @param work work buffer\r\n * @param tolerance tolerance for \"on plane\" decision.\r\n * @return the number of crossings. If this is larger than 2, the result is \"correct\" in a parity sense but may have overlapping (hence cancelling) parts.\r\n */\r\n public static clipConvexPolygonInPlace(plane: PlaneAltitudeEvaluator, xyz: GrowableXYZArray, work: GrowableXYZArray, keepPositive: boolean = true, tolerance: number = Geometry.smallMetricDistance): number {\r\n work.clear();\r\n const s = keepPositive ? 1.0 : -1.0;\r\n const n = xyz.length;\r\n let numNegative = 0;\r\n const fractionTol = 1.0e-8;\r\n const b = -tolerance;\r\n let numCrossings = 0;\r\n if (xyz.length > 1) {\r\n let a1;\r\n let index0 = xyz.length - 1;\r\n let a0 = s * xyz.evaluateUncheckedIndexPlaneAltitude(index0, plane);\r\n if (Math.abs(a0) < tolerance)\r\n a0 = 0;\r\n // if (a0 >= 0.0)\r\n // work.push_back (xyz0);\r\n for (let index1 = 0; index1 < n; a0 = a1, index0 = index1++) {\r\n a1 = s * xyz.evaluateUncheckedIndexPlaneAltitude(index1, plane);\r\n if (Math.abs(a1) < tolerance)\r\n a1 = 0;\r\n if (a1 < 0)\r\n numNegative++;\r\n if (a0 * a1 < 0.0) {\r\n // simple crossing . . .\r\n const f = - a0 / (a1 - a0);\r\n if (f > 1.0 - fractionTol && a1 >= 0.0) {\r\n // the endpoint will be saved -- avoid the duplicate\r\n } else {\r\n work.pushInterpolatedFromGrowableXYZArray(xyz, index0, f, index1);\r\n if (a1 > 0)\r\n numCrossings++; // \"out to in\"\r\n }\r\n }\r\n if (a1 >= b) {\r\n work.pushFromGrowableXYZArray(xyz, index1);\r\n if (a0 < -b) {\r\n numCrossings++; // \"in to out\"\r\n }\r\n }\r\n index0 = index1;\r\n a0 = a1;\r\n }\r\n }\r\n\r\n if (work.length <= 2) {\r\n xyz.clear();\r\n } else if (numNegative > 0) {\r\n xyz.clear();\r\n xyz.pushFromGrowableXYZArray(work);\r\n }\r\n work.clear();\r\n return numCrossings;\r\n }\r\n\r\n /**\r\n * * Input a \"clipped\" polygon (from clipConvexPolygonInPlace) with more than 2 crossings, i.e. is from a non-convex polygon with configurations like:\r\n * * multiple distinct polygons\r\n * * single polygon, but cut lines overlap and cancel by parity rules.\r\n * * return 1 or more polygons, each having first and last points \"on\" the plane and intermediate points \"off\"\r\n * * `minChainLength` indicates the shortest chain to be returned.\r\n * @internal\r\n */\r\n public static gatherCutLoopsFromPlaneClip(plane: PlaneAltitudeEvaluator, xyz: GrowableXYZArray, minChainLength: number = 3, tolerance: number = Geometry.smallMetricDistance): CutLoopMergeContext {\r\n const result: CutLoopMergeContext = new CutLoopMergeContext();\r\n // find the first on-plane point\r\n let firstOnPlaneIndex = 0;\r\n const n = xyz.length;\r\n for (; firstOnPlaneIndex < n; firstOnPlaneIndex++) {\r\n const a = xyz.evaluateUncheckedIndexPlaneAltitude(firstOnPlaneIndex, plane);\r\n if (Math.abs(a) <= tolerance)\r\n break;\r\n }\r\n if (firstOnPlaneIndex === n)\r\n return result;\r\n // find contiguous blocks of \"off plane\" points with on-plane points at their end.\r\n let candidateA = firstOnPlaneIndex;\r\n while (candidateA < n) {\r\n const currentChain = new GrowableXYZArray();\r\n currentChain.pushFromGrowableXYZArray(xyz, candidateA);\r\n let candidateB = candidateA + 1;\r\n while (candidateB < n) {\r\n currentChain.pushFromGrowableXYZArray(xyz, candidateB);\r\n const a = xyz.evaluateUncheckedIndexPlaneAltitude(candidateB, plane);\r\n if (Math.abs(a) <= tolerance) {\r\n break;\r\n }\r\n candidateB++;\r\n }\r\n if (candidateB === n)\r\n for (let i = 0; i <= firstOnPlaneIndex; i++)\r\n currentChain.pushFromGrowableXYZArray(xyz, i);\r\n if (currentChain.length >= minChainLength)\r\n result.inputLoops.push(CutLoop.createCaptureWithReturnEdge(currentChain));\r\n candidateA = candidateB;\r\n }\r\n return result;\r\n }\r\n /**\r\n * * Input the loops from `gatherCutLoopsFromClipPlane`\r\n * * Consolidate loops for reentrant configurations.\r\n * * WARNING: The output reuses and modifies input loops whenever possible.\r\n * @internal\r\n */\r\n public static reorderCutLoops(loops: CutLoopMergeContext) {\r\n // Simple case: all loops have common orientation\r\n if (loops.inputLoops.length === 1)\r\n return;\r\n // Simple cases: 2 loops . . .\r\n if (loops.inputLoops.length === 2) {\r\n // if edges are in the same direction, it must be a pair of unrelated loop . . .\r\n if (loops.inputLoops[0].edge!.direction.dotProduct(loops.inputLoops[1].edge!.direction) > 0) {\r\n loops.outputLoops.push(loops.inputLoops[0]);\r\n loops.outputLoops.push(loops.inputLoops[1]);\r\n return;\r\n }\r\n // twist the two loops into 1,\r\n const source = loops.inputLoops[1].xyz;\r\n const dest = loops.inputLoops[0].xyz;\r\n dest.pushFromGrowableXYZArray(source);\r\n loops.outputLoops.push(loops.inputLoops[0]);\r\n return;\r\n }\r\n // 3 or more loops.\r\n loops.sortAndMergeLoops();\r\n //\r\n }\r\n /**\r\n * Return the intersection of the plane with a range cube.\r\n * @param range\r\n * @param xyzOut intersection polygon. This is convex.\r\n * @return reference to xyz if the polygon still has points; undefined if all points are clipped away.\r\n */\r\n public static intersectRangeConvexPolygonInPlace(range: Range3d, xyz: GrowableXYZArray): GrowableXYZArray | undefined {\r\n if (range.isNull)\r\n return undefined;\r\n const work = new GrowableXYZArray();\r\n const plane = Point4d.create();\r\n plane.set(0, 0, -1, range.high.z);\r\n this.clipConvexPolygonInPlace(plane, xyz, work, true);\r\n if (xyz.length === 0)\r\n return undefined;\r\n\r\n plane.set(0, 0, 1, -range.low.z);\r\n this.clipConvexPolygonInPlace(plane, xyz, work, true);\r\n if (xyz.length === 0)\r\n return undefined;\r\n\r\n plane.set(0, -1, 0, range.high.y);\r\n this.clipConvexPolygonInPlace(plane, xyz, work, true);\r\n if (xyz.length === 0)\r\n return undefined;\r\n\r\n plane.set(0, 1, 0, -range.low.y);\r\n this.clipConvexPolygonInPlace(plane, xyz, work, true);\r\n if (xyz.length === 0)\r\n return undefined;\r\n\r\n plane.set(-1, 0, 0, range.high.x);\r\n this.clipConvexPolygonInPlace(plane, xyz, work, true);\r\n if (xyz.length === 0)\r\n return undefined;\r\n\r\n plane.set(1, 0, 0, -range.low.x);\r\n this.clipConvexPolygonInPlace(plane, xyz, work, true);\r\n if (xyz.length === 0)\r\n return undefined;\r\n\r\n return xyz;\r\n }\r\n}\r\n/**\r\n * `Point3dArrayPolygonOps` class contains _static_ methods for typical operations on polygons carried as `Point3d[]`\r\n * @public\r\n */\r\nexport class Point3dArrayPolygonOps {\r\n private static _xyz0Work: Point3d = Point3d.create();\r\n // private static _xyz1Work: Point3d = Point3d.create();\r\n // private static _xyz2Work: Point3d = Point3d.create();\r\n /**\r\n * Split a (convex) polygon into 2 parts.\r\n * @param xyz original polygon\r\n * @param xyzIn array to receive inside part\r\n * @param xyzOut array to receive outside part\r\n * @param altitudeRange min and max altitudes encountered.\r\n */\r\n public static convexPolygonSplitInsideOutsidePlane(plane: PlaneAltitudeEvaluator, xyz: Point3d[], xyzIn: Point3d[], xyzOut: Point3d[], altitudeRange: Range1d) {\r\n const xyzCarrier = new Point3dArrayCarrier(xyz);\r\n const xyzInCarrier = new Point3dArrayCarrier(xyzIn);\r\n const xyzOutCarrier = new Point3dArrayCarrier(xyzOut);\r\n IndexedXYZCollectionPolygonOps.splitConvexPolygonInsideOutsidePlane(plane, xyzCarrier, xyzInCarrier, xyzOutCarrier, altitudeRange);\r\n\r\n }\r\n\r\n /** Return an array containing\r\n * * All points that are exactly on the plane.\r\n * * Crossing points between adjacent points that are (strictly) on opposite sides.\r\n */\r\n public static polygonPlaneCrossings(plane: PlaneAltitudeEvaluator, xyz: Point3d[], crossings: Point3d[]) {\r\n crossings.length = 0;\r\n if (xyz.length >= 2) {\r\n const xyz0 = this._xyz0Work;\r\n xyz0.setFromPoint3d(xyz[xyz.length - 1]);\r\n let a0 = plane.altitude(xyz0);\r\n for (const xyz1 of xyz) {\r\n const a1 = plane.altitude(xyz1);\r\n if (a0 * a1 < 0.0) {\r\n // simple crossing. . .\r\n const f = - a0 / (a1 - a0);\r\n crossings.push(xyz0.interpolate(f, xyz1));\r\n }\r\n if (a1 === 0.0) { // IMPORTANT -- every point is directly tested here\r\n crossings.push(xyz1.clone());\r\n }\r\n xyz0.setFromPoint3d(xyz1);\r\n a0 = a1;\r\n }\r\n }\r\n }\r\n /**\r\n * Clip a polygon, returning the clip result in the same object.\r\n * @param xyz input/output polygon\r\n * @param work scratch object\r\n * @param tolerance tolerance for on-plane decision.\r\n */\r\n public static convexPolygonClipInPlace(plane: PlaneAltitudeEvaluator, xyz: Point3d[], work: Point3d[] | undefined, tolerance: number = Geometry.smallMetricDistance) {\r\n if (work === undefined)\r\n work = [];\r\n work.length = 0;\r\n let numNegative = 0;\r\n const fractionTol = 1.0e-8;\r\n const b = -tolerance;\r\n if (xyz.length > 2) {\r\n let xyz0 = xyz[xyz.length - 1];\r\n let a0 = plane.altitude(xyz0);\r\n // if (a0 >= 0.0)\r\n // work.push_back (xyz0);\r\n for (const xyz1 of xyz) {\r\n const a1 = plane.altitude(xyz1);\r\n if (a1 < 0)\r\n numNegative++;\r\n if (a0 * a1 < 0.0) {\r\n // simple crossing . . .\r\n const f = - a0 / (a1 - a0);\r\n if (f > 1.0 - fractionTol && a1 >= 0.0) {\r\n // the endpoint will be saved -- avoid the duplicate\r\n } else {\r\n work.push(xyz0.interpolate(f, xyz1));\r\n }\r\n }\r\n if (a1 >= b)\r\n work.push(xyz1);\r\n xyz0 = Point3d.createFrom(xyz1);\r\n a0 = a1;\r\n }\r\n }\r\n\r\n if (work.length <= 2) {\r\n xyz.length = 0;\r\n } else if (numNegative > 0) {\r\n xyz.length = 0;\r\n for (const xyzI of work) {\r\n xyz.push(xyzI);\r\n }\r\n work.length = 0;\r\n }\r\n }\r\n}\r\n"]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IAAI,CAAC,CAAC;gBAChC,EAAE,GAAG,EAAE,CAAC;aACT;SACF;QAED,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE;YACpB,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;SAChB;aAAM,IAAI,WAAW,GAAG,CAAC,EAAE;YAC1B,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;YACf,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;gBACvB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAChB;YACD,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;SACjB;IACH,CAAC;;AA3FH,wDA4FC;AA3FgB,gCAAS,GAAY,yBAAO,CAAC,MAAM,EAAE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\nimport { Geometry, PlaneAltitudeEvaluator } from \"../Geometry\";\r\nimport { Matrix4d } from \"../geometry4d/Matrix4d\";\r\nimport { Point4d } from \"../geometry4d/Point4d\";\r\nimport { XYParitySearchContext } from \"../topology/XYParitySearchContext\";\r\nimport { FrameBuilder } from \"./FrameBuilder\";\r\nimport { GrowableXYZArray } from \"./GrowableXYZArray\";\r\nimport { IndexedReadWriteXYZCollection, IndexedXYZCollection } from \"./IndexedXYZCollection\";\r\nimport { Point2d, Vector2d } from \"./Point2dVector2d\";\r\nimport { Point3dArrayCarrier } from \"./Point3dArrayCarrier\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { Range1d, Range3d } from \"./Range\";\r\nimport { Ray3d } from \"./Ray3d\";\r\nimport { SortablePolygon } from \"./SortablePolygon\";\r\nimport { XAndY } from \"./XYZProps\";\r\n\r\n/**\r\n * Carrier for a loop extracted from clip operation, annotated for sorting\r\n * @internal\r\n */\r\nexport class CutLoop {\r\n /* All points of the loop */\r\n public xyz: GrowableXYZArray;\r\n /* ray within point of \"on\" edge */\r\n public edge?: Ray3d;\r\n public sortCoordinate0: number;\r\n public sortCoordinate1: number;\r\n public sortDelta: number;\r\n public isNotch: boolean;\r\n public constructor(xyz: GrowableXYZArray) {\r\n this.xyz = xyz;\r\n this.edge = undefined;\r\n this.sortCoordinate0 = this.sortCoordinate1 = 0;\r\n this.sortDelta = 0;\r\n this.isNotch = false;\r\n }\r\n /**\r\n * Create a `CutLoop` structure annotated with the vector from last point to first.\r\n * @param xyz coordinates to capture\r\n */\r\n public static createCaptureWithReturnEdge(xyz: GrowableXYZArray): CutLoop {\r\n const result = new CutLoop(xyz);\r\n if (xyz.length >= 2)\r\n result.edge = Ray3d.createStartEnd(xyz.front()!, xyz.back()!);\r\n return result;\r\n }\r\n /**\r\n * Set up coordinates for sort steps:\r\n * * Make `sortCoordinate0` and `sortCoordinate` the (algebraically sorted) start and end fractions along the ray\r\n * * Make `sortDelta` the oriented difference of those two\r\n * * Hence sorting on the coordinates puts loops in left-to-right order by the their edge vector leftmost point.\r\n */\r\n public setSortCoordinates(ray: Ray3d) {\r\n this.sortDelta = this.edge!.direction.dotProduct(ray.direction);\r\n const a = ray.dotProductToPoint(this.edge!.origin);\r\n if (this.sortDelta >= 0) {\r\n this.sortCoordinate0 = a;\r\n this.sortCoordinate1 = a + this.sortDelta;\r\n } else {\r\n this.sortCoordinate0 = a + this.sortDelta; // and sortDelta is negative !!!\r\n this.sortCoordinate1 = a;\r\n\r\n }\r\n }\r\n /** Return\r\n * * 0 if other sort limits are not strictly contained in this.\r\n * * 1 if other sort limits are strictly contained with same direction\r\n * * -1 if other sort limits are strictly contained in opposite direction.\r\n */\r\n public containsSortLimits(other: CutLoop): number {\r\n if (other.sortCoordinate0 >= this.sortCoordinate1\r\n || other.sortCoordinate0 <= this.sortCoordinate0\r\n || other.sortCoordinate1 <= this.sortCoordinate0\r\n || other.sortCoordinate1 >= this.sortCoordinate1)\r\n return 0;\r\n return this.sortDelta * other.sortDelta > 0 ? 1 : -1;\r\n }\r\n /**\r\n * * push coordinates from other onto this\r\n * * reset this.sortCoordinate0 to other.sortCoordinate1\r\n * @param other new coordinates\r\n */\r\n public absorb(other: CutLoop) {\r\n this.xyz.pushFromGrowableXYZArray(other.xyz);\r\n this.sortCoordinate0 = other.sortCoordinate1;\r\n }\r\n /** Comparison function for system sort function applied to an array of CutLoop .... */\r\n public static sortFunction(loopA: CutLoop, loopB: CutLoop): number {\r\n const q = loopA.sortCoordinate0 - loopB.sortCoordinate0;\r\n return q > 0 ? 1 : -1;\r\n }\r\n\r\n /** Return first point coordinates.\r\n * * For type checking, assume array is not empty.\r\n */\r\n public front(result?: Point3d): Point3d { return this.xyz.front(result)!; }\r\n /** Return last point coordinates.\r\n * * For type checking, assume array is not empty.\r\n */\r\n public back(result?: Point3d): Point3d { return this.xyz.back(result)!; }\r\n\r\n}\r\n/**\r\n * Context to hold an array of input loops and apply sort logic.\r\n * * This is used when a non-convex face is clipped by a plane\r\n * * Simple convex clip logic in this case generates double-back edges that need to be eliminated.\r\n * * This class manages the elimination.\r\n * * Usage pattern is:\r\n * @internal\r\n */\r\nexport class CutLoopMergeContext {\r\n /** Array (filled by user code) of loops being sorted. Contents are subject to being changed during sort. */\r\n public inputLoops: CutLoop[];\r\n /** Array (filled by sortAndMergeLoops) of reorganized loops. */\r\n public outputLoops: CutLoop[];\r\n // Initialize with empty loop arrays.\r\n public constructor() {\r\n this.inputLoops = [];\r\n this.outputLoops = [];\r\n }\r\n /**\r\n * * Search all start and end points for the one most distant from point0.\r\n */\r\n private mostDistantPoint(point0: Point3d, workPoint: Point3d, resultPoint: Point3d) {\r\n let dMax = -1.0;\r\n resultPoint.setZero();\r\n let d;\r\n for (const loop of this.inputLoops) {\r\n loop.front(workPoint);\r\n d = workPoint.distanceSquared(point0);\r\n if (d > dMax) {\r\n dMax = d;\r\n resultPoint.setFromPoint3d(workPoint);\r\n }\r\n loop.back(workPoint);\r\n d = workPoint.distanceSquared(point0);\r\n if (d > dMax) {\r\n dMax = d;\r\n resultPoint.setFromPoint3d(workPoint);\r\n }\r\n }\r\n }\r\n /**\r\n * * Find a long (probably longest) edge through start and end points of inputs.\r\n * * Setup sortCoordinate0 and sortCoordinate1 along that edge for each loop\r\n * * sort all inputLoop members by sortCoordinate0.\r\n */\r\n private sortInputs() {\r\n if (this.inputLoops.length > 0 && this.inputLoops[0].xyz.length > 0) {\r\n const point0 = this.inputLoops[0].xyz.front()!;\r\n const workPoint = Point3d.create();\r\n const point1 = Point3d.create();\r\n // point0 could be in the middle. Find the most distant point ...\r\n this.mostDistantPoint(point0, workPoint, point1);\r\n // And again from point1 to get to the other extreme . .\r\n this.mostDistantPoint(point1, workPoint, point0);\r\n const sortRay = Ray3d.createStartEnd(point0, point1);\r\n sortRay.direction.normalizeInPlace();\r\n for (const loop of this.inputLoops)\r\n loop.setSortCoordinates(sortRay);\r\n this.inputLoops.sort(CutLoop.sortFunction);\r\n\r\n }\r\n }\r\n /**\r\n * * sort all input loops by coordinate along the cut edge\r\n * * sweep left to right, using start and end coordinates to decide if loops are outer or hole, and combine holes into their containing outer loops.\r\n */\r\n public sortAndMergeLoops() {\r\n this.sortInputs();\r\n const inputs = this.inputLoops;\r\n const outputs = this.outputLoops;\r\n const stack = [];\r\n outputs.length = 0;\r\n for (const candidate of inputs) {\r\n candidate.isNotch = false;\r\n // candidate must be either (a) absorbed in to of stack or (b) pushed onto stack.\r\n // If pushed, must have indication of natch state.\r\n for (; stack.length > 0;) {\r\n const topOfStack = stack[stack.length - 1];\r\n const containment = topOfStack.containsSortLimits(candidate);\r\n if (containment === 0) {\r\n if (!topOfStack.isNotch)\r\n outputs.push(topOfStack);\r\n stack.pop();\r\n continue; // a larger topOfStack may have appeared !\r\n candidate.isNotch = false;\r\n } else if (containment === 1) {\r\n candidate.isNotch = false;\r\n break;\r\n } else {\r\n topOfStack.absorb(candidate);\r\n candidate.isNotch = true;\r\n break;\r\n }\r\n }\r\n stack.push(candidate);\r\n }\r\n // Anything on stack must be complete ...\r\n for (const p of stack) {\r\n if (!p.isNotch)\r\n outputs.push(p);\r\n }\r\n }\r\n}\r\n/** Static class for operations that treat an array of points as a polygon (with area!) */\r\n/**\r\n * Various (static method) computations for arrays of points interpreted as a polygon.\r\n * @public\r\n */\r\nexport class PolygonOps {\r\n /** Sum areas of triangles from points[0] to each far edge.\r\n * * Consider triangles from points[0] to each edge.\r\n * * Sum the absolute areas (without regard to orientation) all these triangles.\r\n * @returns sum of absolute triangle areas.\r\n */\r\n public static sumTriangleAreas(points: Point3d[] | GrowableXYZArray): number {\r\n let s = 0;\r\n const n = points.length;\r\n if (Array.isArray(points)) {\r\n if (n >= 3) {\r\n const origin = points[0];\r\n const vector0 = origin.vectorTo(points[1]);\r\n let vector1 = Vector3d.create();\r\n // This will work with or without closure edge. If closure is given, the last vector is 000.\r\n for (let i = 2; i < n; i++) {\r\n vector1 = origin.vectorTo(points[i], vector1);\r\n s += vector0.crossProductMagnitude(vector1);\r\n vector0.setFrom(vector1);\r\n }\r\n }\r\n return s * 0.5;\r\n }\r\n const crossVector = Vector3d.create();\r\n for (let i = 2; i < n; i++) {\r\n points.crossProductIndexIndexIndex(0, i - 1, i, crossVector);\r\n s += crossVector.magnitude();\r\n }\r\n return s * 0.5;\r\n }\r\n /** Sum areas of triangles from points[0] to each far edge, as viewed with upVector pointing up.\r\n * * Consider triangles from points[0] to each edge.\r\n * * Sum the areas perpendicular to the upVector.\r\n * * If the upVector is near-zero length, a simple z vector is used.\r\n * @returns sum of triangle areas.\r\n */\r\n public static sumTriangleAreasPerpendicularToUpVector(points: Point3d[] | GrowableXYZArray, upVector: Vector3d): number {\r\n let scale = upVector.magnitude ();\r\n if (scale < Geometry.smallMetricDistance) {\r\n upVector = Vector3d.create (0,0,1);\r\n scale = 1.0;\r\n }\r\n\r\n let s = 0;\r\n const n = points.length;\r\n if (Array.isArray(points)) {\r\n if (n >= 3) {\r\n const origin = points[0];\r\n const vector0 = origin.vectorTo(points[1]);\r\n let vector1 = Vector3d.create();\r\n // This will work with or without closure edge. If closure is given, the last vector is 000.\r\n for (let i = 2; i < n; i++) {\r\n vector1 = origin.vectorTo(points[i], vector1);\r\n s += vector0.tripleProduct(vector1, upVector);\r\n vector0.setFrom(vector1);\r\n }\r\n }\r\n return s * 0.5 / scale;\r\n }\r\n const crossVector = Vector3d.create();\r\n for (let i = 2; i < n; i++) {\r\n points.crossProductIndexIndexIndex(0, i - 1, i, crossVector);\r\n s += crossVector.dotProduct(upVector);\r\n }\r\n return s * 0.5 / scale;\r\n }\r\n\r\n /** Sum areas of triangles from points[0] to each far edge.\r\n * * Consider triangles from points[0] to each edge.\r\n * * Sum the signed areas of all these triangles. (An area can be negative at a concave corner.)\r\n * @returns sum of signed triangle areas.\r\n */\r\n public static sumTriangleAreasXY(points: Point3d[]): number {\r\n let s = 0.0;\r\n const n = points.length;\r\n if (n >= 3) {\r\n const origin = points[0];\r\n const vector0 = origin.vectorTo(points[1]);\r\n let vector1 = Vector3d.create();\r\n // This will work with or without closure edge. If closure is given, the last vector is 000.\r\n for (let i = 2; i < n; i++) {\r\n vector1 = origin.vectorTo(points[i], vector1);\r\n s += vector0.crossProductXY(vector1);\r\n vector0.setFrom(vector1);\r\n }\r\n }\r\n s *= 0.5;\r\n // console.log (\"polygon area \", s, points);\r\n return s;\r\n }\r\n /** These values are the integrated area moment products [xx,xy,xz, x]\r\n * for a right triangle in the first quadrant at the origin -- (0,0),(1,0),(0,1)\r\n */\r\n private static readonly _triangleMomentWeights = Matrix4d.createRowValues(2.0 / 24.0, 1.0 / 24.0, 0, 4.0 / 24.0, 1.0 / 24.0, 2.0 / 24.0, 0, 4.0 / 24.0, 0, 0, 0, 0, 4.0 / 24.0, 4.0 / 24.0, 0, 12.0 / 24.0);\r\n /** These values are the integrated volume moment products [xx,xy,xz, x, yx,yy,yz,y, zx,zy,zz,z,x,y,z,1]\r\n * for a tetrahedron in the first quadrant at the origin -- (0,00),(1,0,0),(0,1,0),(0,0,1)\r\n */\r\n private static readonly _tetrahedralMomentWeights = Matrix4d.createRowValues(\r\n 1.0 / 60.0, 1.0 / 120, 1.0 / 120, 1.0 / 24.0,\r\n 1.0 / 120, 1.0 / 60.0, 1.0 / 120, 1.0 / 24.0,\r\n 1.0 / 120, 1.0 / 120, 1.0 / 60.0, 1.0 / 24.0,\r\n 1.0 / 24.0, 1.0 / 24.0, 1.0 / 24.0, 1.0 / 6.0);\r\n // statics for shared reuse.\r\n // many methods use these.\r\n // only use them in \"leaf\" methods that are certain not to call other users . . .\r\n private static _vector0 = Vector3d.create();\r\n private static _vector1 = Vector3d.create();\r\n private static _vector2 = Vector3d.create();\r\n private static _vectorOrigin = Vector3d.create();\r\n private static _normal = Vector3d.create();\r\n private static _matrixA = Matrix4d.createIdentity();\r\n private static _matrixB = Matrix4d.createIdentity();\r\n private static _matrixC = Matrix4d.createIdentity();\r\n /** return a vector which is perpendicular to the polygon and has magnitude equal to the polygon area. */\r\n public static areaNormalGo(points: IndexedXYZCollection, result?: Vector3d): Vector3d | undefined {\r\n if (!result)\r\n result = new Vector3d();\r\n else\r\n result.setZero();\r\n const n = points.length;\r\n if (n === 3) {\r\n points.crossProductIndexIndexIndex(0, 1, 2, result);\r\n } else if (n > 3) {\r\n // This will work with or without closure edge. If closure is given, the last vector is 000.\r\n for (let i = 2; i < n; i++) {\r\n points.accumulateCrossProductIndexIndexIndex(0, i - 1, i, result);\r\n }\r\n }\r\n // ALL BRANCHES SUM FULL CROSS PRODUCTS AND EXPECT SCALE HERE\r\n result.scaleInPlace(0.5);\r\n return result.isZero ? undefined : result;\r\n }\r\n /** return a vector which is perpendicular to the polygon and has magnitude equal to the polygon area. */\r\n public static areaNormal(points: Point3d[], result?: Vector3d): Vector3d {\r\n if (!result)\r\n result = Vector3d.create();\r\n PolygonOps.areaNormalGo(new Point3dArrayCarrier(points), result);\r\n return result;\r\n }\r\n /** return the area of the polygon.\r\n * * This assumes the polygon is planar\r\n * * This does NOT assume the polygon is on the xy plane.\r\n */\r\n public static area(points: Point3d[]): number {\r\n return PolygonOps.areaNormal(points).magnitude();\r\n }\r\n /** return the projected XY area of the polygon. */\r\n public static areaXY(points: Point3d[] | IndexedXYZCollection): number {\r\n let area = 0.0;\r\n if (points instanceof IndexedXYZCollection) {\r\n if (points.length > 2) {\r\n const x0 = points.getXAtUncheckedPointIndex(0);\r\n const y0 = points.getYAtUncheckedPointIndex(0);\r\n let u1 = points.getXAtUncheckedPointIndex(1) - x0;\r\n let v1 = points.getYAtUncheckedPointIndex(1) - y0;\r\n let u2, v2;\r\n for (let i = 1; i + 1 < points.length; i++, u1 = u2, v1 = v2) {\r\n u2 = points.getXAtUncheckedPointIndex(i) - x0;\r\n v2 = points.getYAtUncheckedPointIndex(i) - y0;\r\n area += Geometry.crossProductXYXY(u1, v1, u2, v2);\r\n }\r\n }\r\n } else {\r\n for (let i = 1; i + 1 < points.length; i++)\r\n area += points[0].crossProductToPointsXY(points[i], points[i + 1]);\r\n }\r\n return 0.5 * area;\r\n }\r\n /** Sum the areaXY () values for multiple polygons */\r\n public static sumAreaXY(polygons: Point3d[][]): number{\r\n let s = 0.0;\r\n for (const p of polygons)\r\n s += this.areaXY(p);\r\n return s;\r\n }\r\n /**\r\n * Return a Ray3d with (assuming the polygon is planar and not self-intersecting)\r\n * * origin at the centroid of the (3D) polygon\r\n * * normal is a unit vector perpendicular to the plane\r\n * * 'a' member is the area.\r\n * @param points\r\n */\r\n public static centroidAreaNormal(points: IndexedXYZCollection | Point3d[]): Ray3d | undefined {\r\n if (Array.isArray(points)) {\r\n const carrier = new Point3dArrayCarrier(points);\r\n return this.centroidAreaNormal(carrier);\r\n }\r\n const n = points.length;\r\n if (n === 3) {\r\n const normal = points.crossProductIndexIndexIndex(0, 1, 2)!;\r\n const a = 0.5 * normal.magnitude();\r\n const centroid = points.getPoint3dAtCheckedPointIndex(0)!;\r\n points.accumulateScaledXYZ(1, 1.0, centroid);\r\n points.accumulateScaledXYZ(2, 1.0, centroid);\r\n centroid.scaleInPlace(1.0 / 3.0);\r\n const result = Ray3d.createCapture(centroid, normal);\r\n if (result.tryNormalizeInPlaceWithAreaWeight(a))\r\n return result;\r\n return undefined;\r\n }\r\n if (n >= 3) {\r\n\r\n const areaNormal = Vector3d.createZero();\r\n // This will work with or without closure edge. If closure is given, the last vector is 000.\r\n for (let i = 2; i < n; i++) {\r\n points.accumulateCrossProductIndexIndexIndex(0, i - 1, i, areaNormal);\r\n }\r\n areaNormal.normalizeInPlace();\r\n\r\n const origin = points.getPoint3dAtCheckedPointIndex(0)!;\r\n const vector0 = Vector3d.create();\r\n const vector1 = Vector3d.create();\r\n points.vectorXYAndZIndex(origin, 1, vector0);\r\n let cross = Vector3d.create();\r\n const centroidSum = Vector3d.createZero();\r\n const normalSum = Vector3d.createZero();\r\n let signedTriangleArea;\r\n // This will work with or without closure edge. If closure is given, the last vector is 000.\r\n for (let i = 2; i < n; i++) {\r\n points.vectorXYAndZIndex(origin, i, vector1);\r\n cross = vector0.crossProduct(vector1, cross);\r\n signedTriangleArea = areaNormal.dotProduct(cross); // well, actually twice the area.\r\n normalSum.addInPlace(cross); // this grows to twice the area\r\n const b = signedTriangleArea / 6.0;\r\n centroidSum.plus2Scaled(vector0, b, vector1, b, centroidSum);\r\n vector0.setFrom(vector1);\r\n }\r\n const area = 0.5 * normalSum.magnitude();\r\n const inverseArea = Geometry.conditionalDivideFraction(1, area);\r\n if (inverseArea !== undefined) {\r\n const result = Ray3d.createCapture(origin.plusScaled(centroidSum, inverseArea), normalSum);\r\n result.tryNormalizeInPlaceWithAreaWeight(area);\r\n return result;\r\n }\r\n }\r\n return undefined;\r\n }\r\n // Has the potential to be combined with centroidAreaNormal for point3d array and Ray3d return listed above...\r\n // Returns undefined if given point array less than 3 or if not safe to divide at any point\r\n /**\r\n * * Return (in caller-allocated centroid) the centroid of the xy polygon.\r\n * * Return (as function value) the area\r\n */\r\n public static centroidAndAreaXY(points: Point2d[], centroid: Point2d): number | undefined {\r\n let area = 0.0;\r\n centroid.set(0, 0);\r\n if (points.length < 3)\r\n return undefined;\r\n const origin = points[0];\r\n let vectorSum = Vector2d.create(0, 0); // == sum ((U+V)/3) * (U CROSS V)/2 -- but leave out divisions\r\n let areaSum = 0.0; // == sum (U CROSS V) / 2 -- but leave out divisions\r\n for (let i = 1; i + 1 < points.length; i++) {\r\n const vector0 = origin.vectorTo(points[i]);\r\n const vector1 = origin.vectorTo(points[i + 1]);\r\n const tempArea = vector0.crossProduct(vector1);\r\n vectorSum = vectorSum.plus(vector0.plus(vector1).scale(tempArea));\r\n areaSum += tempArea;\r\n }\r\n area = areaSum * 0.5;\r\n const a = Geometry.conditionalDivideFraction(1.0, 6.0 * area);\r\n if (a === undefined) {\r\n centroid.setFrom(origin);\r\n return undefined;\r\n }\r\n centroid.setFrom(origin.plusScaled(vectorSum, a));\r\n return area;\r\n }\r\n /**\r\n * Return a unit normal to the plane of the polygon.\r\n * @param points array of points around the polygon.\r\n * @param result caller-allocated result vector.\r\n * @return true if and only if result has unit length\r\n */\r\n public static unitNormal(points: IndexedXYZCollection, result: Vector3d): boolean {\r\n result.setZero();\r\n let n = points.length;\r\n if (n > 1 && points.getPoint3dAtUncheckedPointIndex(0).isExactEqual(points.getPoint3dAtUncheckedPointIndex(n - 1)))\r\n --n; // ignore closure point\r\n if (n === 3) {\r\n points.crossProductIndexIndexIndex(0, 1, 2, result);\r\n return result.normalizeInPlace();\r\n }\r\n if (n === 4) {\r\n // cross product of diagonals is more stable than from single of the points . . .\r\n points.vectorIndexIndex(0, 2, PolygonOps._vector0);\r\n points.vectorIndexIndex(1, 3, PolygonOps._vector1);\r\n PolygonOps._vector0.crossProduct(PolygonOps._vector1, result);\r\n return result.normalizeInPlace();\r\n }\r\n // more than 4 points ... no shortcuts ...\r\n PolygonOps.areaNormalGo(points, result);\r\n return result.normalizeInPlace();\r\n }\r\n /** Accumulate to the matrix of area products of a polygon with respect to an origin.\r\n * The polygon is assumed to be planar and non-self-intersecting.\r\n */\r\n /** Accumulate to the matrix of area products of a polygon with respect to an origin.\r\n * * The polygon is assumed to be planar and non-self-intersecting.\r\n * * Accumulated values are integrals over triangles from point 0 of the polygon to other edges of the polygon.\r\n * * Integral over each triangle is transformed to integrals from the given origin.\r\n * @param points array of points around the polygon. Final closure point is not needed.\r\n * @param origin origin for global accumulation.\r\n * @param moments 4x4 matrix where products are accumulated.\r\n */\r\n public static addSecondMomentAreaProducts(points: IndexedXYZCollection, origin: Point3d, moments: Matrix4d) {\r\n this.addSecondMomentTransformedProducts(PolygonOps._triangleMomentWeights, points, origin, 2, moments);\r\n }\r\n\r\n /** Accumulate to the matrix of volume products of a polygon with respect to an origin.\r\n * * The polygon is assumed to be planar and non-self-intersecting.\r\n * * Accumulated values are integrals over tetrahedra from the origin to triangles on the polygon.\r\n * @param points array of points around the polygon. Final closure point is not needed.\r\n * @param origin origin for tetrahedra\r\n * @param moments 4x4 matrix where products are accumulated.\r\n */\r\n public static addSecondMomentVolumeProducts(points: IndexedXYZCollection, origin: Point3d, moments: Matrix4d) {\r\n this.addSecondMomentTransformedProducts(PolygonOps._tetrahedralMomentWeights, points, origin, 3, moments);\r\n }\r\n /** Return the matrix of area products of a polygon with respect to an origin.\r\n * The polygon is assumed to be planar and non-self-intersecting.\r\n * * `frameType===2` has xy vectors in the plane of the polygon, plus a unit normal z. (Used for area integrals)\r\n * * `frameType===3` has vectors from origin to 3 points in the triangle. (Used for volume integrals)\r\n */\r\n private static addSecondMomentTransformedProducts(firstQuadrantMoments: Matrix4d, points: IndexedXYZCollection, origin: Point3d,\r\n frameType: 2 | 3,\r\n moments: Matrix4d) {\r\n const unitNormal = PolygonOps._normal;\r\n if (PolygonOps.unitNormal(points, unitNormal)) {\r\n // The direction of the normal makes the various detJ values positive or negative so that non-convex polygons\r\n // sum correctly.\r\n const vector01 = PolygonOps._vector0;\r\n const vector02 = PolygonOps._vector1;\r\n const vector03 = PolygonOps._vector2;\r\n const placement = PolygonOps._matrixA;\r\n const matrixAB = PolygonOps._matrixB;\r\n const matrixABC = PolygonOps._matrixC;\r\n const vectorOrigin = points.vectorXYAndZIndex(origin, 0, PolygonOps._vectorOrigin)!;\r\n const numPoints = points.length;\r\n let detJ = 0;\r\n for (let i2 = 2; i2 < numPoints; i2++) {\r\n if (frameType === 2) {\r\n points.vectorIndexIndex(0, i2 - 1, vector01);\r\n points.vectorIndexIndex(0, i2, vector02);\r\n detJ = unitNormal.tripleProduct(vector01, vector02);\r\n placement.setOriginAndVectors(vectorOrigin, vector01, vector02, unitNormal);\r\n placement.multiplyMatrixMatrix(firstQuadrantMoments, matrixAB);\r\n matrixAB.multiplyMatrixMatrixTranspose(placement, matrixABC);\r\n moments.addScaledInPlace(matrixABC, detJ);\r\n } else if (frameType === 3) {\r\n points.vectorXYAndZIndex(origin, 0, vector01);\r\n points.vectorXYAndZIndex(origin, i2 - 1, vector02);\r\n points.vectorXYAndZIndex(origin, i2, vector03);\r\n detJ = vector01.tripleProduct(vector02, vector03);\r\n placement.setOriginAndVectors(origin, vector01, vector02, vector03);\r\n placement.multiplyMatrixMatrix(firstQuadrantMoments, matrixAB);\r\n matrixAB.multiplyMatrixMatrixTranspose(placement, matrixABC);\r\n moments.addScaledInPlace(matrixABC, detJ);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** Test the direction of turn at the vertices of the polygon, ignoring z-coordinates.\r\n *\r\n * * For a polygon without self intersections, this is a convexity and orientation test: all positive is convex and counterclockwise,\r\n * all negative is convex and clockwise\r\n * * Beware that a polygon which turns through more than a full turn can cross itself and close, but is not convex\r\n * * Returns 1 if all turns are to the left, -1 if all to the right, and 0 if there are any zero or reverse turns\r\n */\r\n public static testXYPolygonTurningDirections(pPointArray: Point2d[] | Point3d[]): number {\r\n // Reduce count by trailing duplicates; leaves iLast at final index\r\n let numPoint = pPointArray.length;\r\n let iLast = numPoint - 1;\r\n while (iLast > 1 && pPointArray[iLast].x === pPointArray[0].x && pPointArray[iLast].y === pPointArray[0].y) {\r\n numPoint = iLast--;\r\n }\r\n if (numPoint > 2) {\r\n let vector0 = Point2d.create(pPointArray[iLast].x - pPointArray[iLast - 1].x, pPointArray[iLast].y - pPointArray[iLast - 1].y);\r\n const vector1 = Point2d.create(pPointArray[0].x - pPointArray[iLast].x, pPointArray[0].y - pPointArray[iLast].y);\r\n const baseArea = vector0.x * vector1.y - vector0.y * vector1.x;\r\n // In a convex polygon, all successive-vector cross products will\r\n // have the same sign as the base area, hence all products will be\r\n // positive.\r\n for (let i1 = 1; i1 < numPoint; i1++) {\r\n vector0 = vector1.clone();\r\n Point2d.create(pPointArray[i1].x - pPointArray[i1 - 1].x, pPointArray[i1].y - pPointArray[i1 - 1].y, vector1);\r\n const currArea = vector0.x * vector1.y - vector0.y * vector1.x;\r\n if (currArea * baseArea <= 0.0)\r\n return 0;\r\n }\r\n // Fall out with all signs same as base area\r\n return baseArea > 0.0 ? 1 : -1;\r\n }\r\n return 0;\r\n }\r\n /**\r\n * Test if point (x,y) is IN, OUT or ON a polygon.\r\n * @return (1) for in, (-1) for OUT, (0) for ON\r\n * @param x x coordinate\r\n * @param y y coordinate\r\n * @param points array of xy coordinates.\r\n */\r\n public static classifyPointInPolygon(x: number, y: number, points: XAndY[]): number | undefined {\r\n const context = new XYParitySearchContext(x, y);\r\n let i0 = 0;\r\n const n = points.length;\r\n let i1;\r\n let iLast = -1;\r\n // walk to an acceptable start index ...\r\n for (i0 = 0; i0 < n; i0++) {\r\n i1 = i0 + 1;\r\n if (i1 >= n)\r\n i1 = 0;\r\n if (context.tryStartEdge(points[i0].x, points[i0].y, points[i1].x, points[i1].y)) {\r\n iLast = i1;\r\n break;\r\n }\r\n }\r\n if (iLast < 0)\r\n return undefined;\r\n for (let i = 1; i <= n; i++) {\r\n i1 = iLast + i;\r\n if (i1 >= n)\r\n i1 -= n;\r\n if (!context.advance(points[i1].x, points[i1].y))\r\n return context.classifyCounts();\r\n }\r\n return context.classifyCounts();\r\n }\r\n /**\r\n * Test if point (x,y) is IN, OUT or ON a polygon.\r\n * @return (1) for in, (-1) for OUT, (0) for ON\r\n * @param x x coordinate\r\n * @param y y coordinate\r\n * @param points array of xy coordinates.\r\n */\r\n public static classifyPointInPolygonXY(x: number, y: number, points: IndexedXYZCollection): number | undefined {\r\n const context = new XYParitySearchContext(x, y);\r\n let i0 = 0;\r\n const n = points.length;\r\n let i1;\r\n let iLast = -1;\r\n // walk to an acceptable start index ...\r\n for (i0 = 0; i0 < n; i0++) {\r\n i1 = i0 + 1;\r\n if (i1 >= n)\r\n i1 = 0;\r\n if (context.tryStartEdge(points.getXAtUncheckedPointIndex(i0), points.getYAtUncheckedPointIndex(i0), points.getXAtUncheckedPointIndex(i1), points.getYAtUncheckedPointIndex(i1))) {\r\n iLast = i1;\r\n break;\r\n }\r\n }\r\n if (iLast < 0)\r\n return undefined;\r\n for (let i = 1; i <= n; i++) {\r\n i1 = iLast + i;\r\n if (i1 >= n)\r\n i1 -= n;\r\n if (!context.advance(points.getXAtUncheckedPointIndex(i1), points.getYAtUncheckedPointIndex(i1)))\r\n return context.classifyCounts();\r\n }\r\n return context.classifyCounts();\r\n }\r\n\r\n /**\r\n * Reverse loops as necessary to make them all have CCW orientation for given outward normal.\r\n * @param loops\r\n * @param outwardNormal\r\n * @return the number of loops reversed.\r\n */\r\n public static orientLoopsCCWForOutwardNormalInPlace(loops: IndexedReadWriteXYZCollection | IndexedReadWriteXYZCollection[], outwardNormal: Vector3d): number {\r\n if (loops instanceof IndexedXYZCollection)\r\n return this.orientLoopsCCWForOutwardNormalInPlace([loops], outwardNormal);\r\n const orientations: number[] = [];\r\n const unitNormal = Vector3d.create();\r\n // orient individually ... (no hole analysis)\r\n let numReverse = 0;\r\n for (const loop of loops) {\r\n if (this.unitNormal(loop, unitNormal)) {\r\n const q = unitNormal.dotProduct(outwardNormal);\r\n orientations.push(q);\r\n if (q <= 0.0)\r\n loop.reverseInPlace();\r\n numReverse++;\r\n } else {\r\n orientations.push(0.0);\r\n }\r\n }\r\n return numReverse;\r\n }\r\n /**\r\n * Reverse loops as necessary to make them all have CCW orientation for given outward normal.\r\n * * Return an array of arrays which capture the input pointers.\r\n * * In each first level array:\r\n * * The first loop is an outer loop.\r\n * * all subsequent loops are holes\r\n * * The outer loop is CCW\r\n * * The holes are CW.\r\n * * Call RegionOps.sortOuterAndHoleLoopsXY to have the result returned as a UnionRegion\r\n * @param loops multiple loops to sort and reverse.\r\n */\r\n public static sortOuterAndHoleLoopsXY(loops: IndexedReadWriteXYZCollection[]): IndexedReadWriteXYZCollection[][] {\r\n const loopAndArea: SortablePolygon[] = [];\r\n for (const loop of loops) {\r\n SortablePolygon.pushPolygon(loopAndArea, loop);\r\n }\r\n return SortablePolygon.sortAsArrayOfArrayOfPolygons(loopAndArea);\r\n }\r\n\r\n /**\r\n * Exactly like `sortOuterAndHoleLoopsXY` but allows loops in any plane.\r\n * @param loops multiple loops to sort and reverse.\r\n * @param defaultNormal optional normal for the loops, if known\r\n */\r\n public static sortOuterAndHoleLoops(loops: IndexedReadWriteXYZCollection[], defaultNormal: Vector3d | undefined): IndexedReadWriteXYZCollection[][] {\r\n const localToWorld = FrameBuilder.createRightHandedFrame(defaultNormal, loops);\r\n const worldToLocal = localToWorld?.inverse();\r\n\r\n const xyLoops: GrowableXYZArray[] = [];\r\n if (worldToLocal !== undefined) {\r\n // transform into plane so we can ignore z in the sort\r\n for (const loop of loops) {\r\n const xyLoop = new GrowableXYZArray(loop.length);\r\n for (const point of loop.points)\r\n xyLoop.push(worldToLocal.multiplyPoint3d(point));\r\n xyLoops.push(xyLoop);\r\n }\r\n }\r\n const xySortedLoopsArray = PolygonOps.sortOuterAndHoleLoopsXY(xyLoops);\r\n\r\n const sortedLoopsArray: GrowableXYZArray[][] = [];\r\n if (localToWorld !== undefined) {\r\n for (const xySortedLoops of xySortedLoopsArray) {\r\n const sortedLoops: GrowableXYZArray[] = [];\r\n for (const xySortedLoop of xySortedLoops) {\r\n const sortedLoop = new GrowableXYZArray(xySortedLoop.length);\r\n for (const point of xySortedLoop.points)\r\n sortedLoop.push(localToWorld.multiplyPoint3d(point));\r\n sortedLoops.push(sortedLoop);\r\n }\r\n sortedLoopsArray.push(sortedLoops);\r\n }\r\n }\r\n return sortedLoopsArray;\r\n }\r\n}\r\n\r\n/**\r\n * `IndexedXYZCollectionPolygonOps` class contains _static_ methods for typical operations on polygons carried as `IndexedXyZCollection`\r\n * @public\r\n */\r\nexport class IndexedXYZCollectionPolygonOps {\r\n private static _xyz0Work: Point3d = Point3d.create();\r\n private static _xyz1Work: Point3d = Point3d.create();\r\n private static _xyz2Work: Point3d = Point3d.create();\r\n /**\r\n * Split a (convex) polygon into 2 parts based on altitude evaluations.\r\n * * POSITIVE ALTITUDE IS IN\r\n * @param plane any `PlaneAltitudeEvaluator` object that can evaluate `plane.altitude(xyz)` for distance from the plane.\r\n * @param xyz original polygon\r\n * @param xyzPositive array to receive inside part (altitude > 0)\r\n * @param xyzNegative array to receive outside part\r\n * @param altitudeRange min and max altitudes encountered.\r\n */\r\n public static splitConvexPolygonInsideOutsidePlane(plane: PlaneAltitudeEvaluator,\r\n xyz: IndexedReadWriteXYZCollection,\r\n xyzPositive: IndexedReadWriteXYZCollection,\r\n xyzNegative: IndexedReadWriteXYZCollection, altitudeRange: Range1d) {\r\n const xyz0 = IndexedXYZCollectionPolygonOps._xyz0Work;\r\n const xyz1 = IndexedXYZCollectionPolygonOps._xyz1Work;\r\n const xyzInterpolated = IndexedXYZCollectionPolygonOps._xyz2Work;\r\n const n = xyz.length;\r\n xyzPositive.clear();\r\n xyzNegative.clear();\r\n // let numSplit = 0;\r\n const fractionTol = 1.0e-8;\r\n if (n > 2) {\r\n xyz.back(xyz0);\r\n altitudeRange.setNull();\r\n let a0 = plane.altitude(xyz0);\r\n altitudeRange.extendX(a0);\r\n // if (a0 >= 0.0)\r\n // work.push_back (xyz0);\r\n for (let i1 = 0; i1 < n; i1++) {\r\n xyz.getPoint3dAtUncheckedPointIndex(i1, xyz1);\r\n const a1 = plane.altitude(xyz1);\r\n altitudeRange.extendX(a1);\r\n let nearZero = false;\r\n if (a0 * a1 < 0.0) {\r\n // simple crossing. . .\r\n const f = - a0 / (a1 - a0);\r\n if (f > 1.0 - fractionTol && a1 >= 0.0) {\r\n // the endpoint will be saved -- avoid the duplicate\r\n nearZero = true;\r\n } else {\r\n xyz0.interpolate(f, xyz1, xyzInterpolated);\r\n xyzPositive.push(xyzInterpolated);\r\n xyzNegative.push(xyzInterpolated);\r\n }\r\n // numSplit++;\r\n }\r\n if (a1 >= 0.0 || nearZero)\r\n xyzPositive.push(xyz1);\r\n if (a1 <= 0.0 || nearZero)\r\n xyzNegative.push(xyz1);\r\n xyz0.setFromPoint3d(xyz1);\r\n a0 = a1;\r\n }\r\n }\r\n }\r\n /**\r\n * Clip a polygon to one side of a plane.\r\n * * Results with 2 or fewer points are ignored.\r\n * * Other than ensuring capacity in the arrays, there are no object allocations during execution of this function.\r\n * * plane is passed as unrolled Point4d (ax,ay,az,aw) point (x,y,z) acts as homogeneous (x,y,z,1)\r\n * * `keepPositive === true` selects positive altitudes.\r\n * @param plane any type that has `plane.altitude`\r\n * @param xyz input points.\r\n * @param work work buffer\r\n * @param tolerance tolerance for \"on plane\" decision.\r\n * @return the number of crossings. If this is larger than 2, the result is \"correct\" in a parity sense but may have overlapping (hence cancelling) parts.\r\n */\r\n public static clipConvexPolygonInPlace(plane: PlaneAltitudeEvaluator, xyz: GrowableXYZArray, work: GrowableXYZArray, keepPositive: boolean = true, tolerance: number = Geometry.smallMetricDistance): number {\r\n work.clear();\r\n const s = keepPositive ? 1.0 : -1.0;\r\n const n = xyz.length;\r\n let numNegative = 0;\r\n const fractionTol = 1.0e-8;\r\n const b = -tolerance;\r\n let numCrossings = 0;\r\n if (xyz.length > 1) {\r\n let a1;\r\n let index0 = xyz.length - 1;\r\n let a0 = s * xyz.evaluateUncheckedIndexPlaneAltitude(index0, plane);\r\n if (Math.abs(a0) < tolerance)\r\n a0 = 0;\r\n // if (a0 >= 0.0)\r\n // work.push_back (xyz0);\r\n for (let index1 = 0; index1 < n; a0 = a1, index0 = index1++) {\r\n a1 = s * xyz.evaluateUncheckedIndexPlaneAltitude(index1, plane);\r\n if (Math.abs(a1) < tolerance)\r\n a1 = 0;\r\n if (a1 < 0)\r\n numNegative++;\r\n if (a0 * a1 < 0.0) {\r\n // simple crossing . . .\r\n const f = - a0 / (a1 - a0);\r\n if (f > 1.0 - fractionTol && a1 >= 0.0) {\r\n // the endpoint will be saved -- avoid the duplicate\r\n } else {\r\n work.pushInterpolatedFromGrowableXYZArray(xyz, index0, f, index1);\r\n if (a1 > 0)\r\n numCrossings++; // \"out to in\"\r\n }\r\n }\r\n if (a1 >= b) {\r\n work.pushFromGrowableXYZArray(xyz, index1);\r\n if (a0 < -b) {\r\n numCrossings++; // \"in to out\"\r\n }\r\n }\r\n index0 = index1;\r\n a0 = a1;\r\n }\r\n }\r\n\r\n if (work.length <= 2) {\r\n xyz.clear();\r\n } else if (numNegative > 0) {\r\n xyz.clear();\r\n xyz.pushFromGrowableXYZArray(work);\r\n }\r\n work.clear();\r\n return numCrossings;\r\n }\r\n\r\n /**\r\n * * Input a \"clipped\" polygon (from clipConvexPolygonInPlace) with more than 2 crossings, i.e. is from a non-convex polygon with configurations like:\r\n * * multiple distinct polygons\r\n * * single polygon, but cut lines overlap and cancel by parity rules.\r\n * * return 1 or more polygons, each having first and last points \"on\" the plane and intermediate points \"off\"\r\n * * `minChainLength` indicates the shortest chain to be returned.\r\n * @internal\r\n */\r\n public static gatherCutLoopsFromPlaneClip(plane: PlaneAltitudeEvaluator, xyz: GrowableXYZArray, minChainLength: number = 3, tolerance: number = Geometry.smallMetricDistance): CutLoopMergeContext {\r\n const result: CutLoopMergeContext = new CutLoopMergeContext();\r\n // find the first on-plane point\r\n let firstOnPlaneIndex = 0;\r\n const n = xyz.length;\r\n for (; firstOnPlaneIndex < n; firstOnPlaneIndex++) {\r\n const a = xyz.evaluateUncheckedIndexPlaneAltitude(firstOnPlaneIndex, plane);\r\n if (Math.abs(a) <= tolerance)\r\n break;\r\n }\r\n if (firstOnPlaneIndex === n)\r\n return result;\r\n // find contiguous blocks of \"off plane\" points with on-plane points at their end.\r\n let candidateA = firstOnPlaneIndex;\r\n while (candidateA < n) {\r\n const currentChain = new GrowableXYZArray();\r\n currentChain.pushFromGrowableXYZArray(xyz, candidateA);\r\n let candidateB = candidateA + 1;\r\n while (candidateB < n) {\r\n currentChain.pushFromGrowableXYZArray(xyz, candidateB);\r\n const a = xyz.evaluateUncheckedIndexPlaneAltitude(candidateB, plane);\r\n if (Math.abs(a) <= tolerance) {\r\n break;\r\n }\r\n candidateB++;\r\n }\r\n if (candidateB === n)\r\n for (let i = 0; i <= firstOnPlaneIndex; i++)\r\n currentChain.pushFromGrowableXYZArray(xyz, i);\r\n if (currentChain.length >= minChainLength)\r\n result.inputLoops.push(CutLoop.createCaptureWithReturnEdge(currentChain));\r\n candidateA = candidateB;\r\n }\r\n return result;\r\n }\r\n /**\r\n * * Input the loops from `gatherCutLoopsFromClipPlane`\r\n * * Consolidate loops for reentrant configurations.\r\n * * WARNING: The output reuses and modifies input loops whenever possible.\r\n * @internal\r\n */\r\n public static reorderCutLoops(loops: CutLoopMergeContext) {\r\n // Simple case: all loops have common orientation\r\n if (loops.inputLoops.length === 1)\r\n return;\r\n // Simple cases: 2 loops . . .\r\n if (loops.inputLoops.length === 2) {\r\n // if edges are in the same direction, it must be a pair of unrelated loop . . .\r\n if (loops.inputLoops[0].edge!.direction.dotProduct(loops.inputLoops[1].edge!.direction) > 0) {\r\n loops.outputLoops.push(loops.inputLoops[0]);\r\n loops.outputLoops.push(loops.inputLoops[1]);\r\n return;\r\n }\r\n // twist the two loops into 1,\r\n const source = loops.inputLoops[1].xyz;\r\n const dest = loops.inputLoops[0].xyz;\r\n dest.pushFromGrowableXYZArray(source);\r\n loops.outputLoops.push(loops.inputLoops[0]);\r\n return;\r\n }\r\n // 3 or more loops.\r\n loops.sortAndMergeLoops();\r\n //\r\n }\r\n /**\r\n * Return the intersection of the plane with a range cube.\r\n * @param range\r\n * @param xyzOut intersection polygon. This is convex.\r\n * @return reference to xyz if the polygon still has points; undefined if all points are clipped away.\r\n */\r\n public static intersectRangeConvexPolygonInPlace(range: Range3d, xyz: GrowableXYZArray): GrowableXYZArray | undefined {\r\n if (range.isNull)\r\n return undefined;\r\n const work = new GrowableXYZArray();\r\n const plane = Point4d.create();\r\n plane.set(0, 0, -1, range.high.z);\r\n this.clipConvexPolygonInPlace(plane, xyz, work, true);\r\n if (xyz.length === 0)\r\n return undefined;\r\n\r\n plane.set(0, 0, 1, -range.low.z);\r\n this.clipConvexPolygonInPlace(plane, xyz, work, true);\r\n if (xyz.length === 0)\r\n return undefined;\r\n\r\n plane.set(0, -1, 0, range.high.y);\r\n this.clipConvexPolygonInPlace(plane, xyz, work, true);\r\n if (xyz.length === 0)\r\n return undefined;\r\n\r\n plane.set(0, 1, 0, -range.low.y);\r\n this.clipConvexPolygonInPlace(plane, xyz, work, true);\r\n if (xyz.length === 0)\r\n return undefined;\r\n\r\n plane.set(-1, 0, 0, range.high.x);\r\n this.clipConvexPolygonInPlace(plane, xyz, work, true);\r\n if (xyz.length === 0)\r\n return undefined;\r\n\r\n plane.set(1, 0, 0, -range.low.x);\r\n this.clipConvexPolygonInPlace(plane, xyz, work, true);\r\n if (xyz.length === 0)\r\n return undefined;\r\n\r\n return xyz;\r\n }\r\n}\r\n/**\r\n * `Point3dArrayPolygonOps` class contains _static_ methods for typical operations on polygons carried as `Point3d[]`\r\n * @public\r\n */\r\nexport class Point3dArrayPolygonOps {\r\n private static _xyz0Work: Point3d = Point3d.create();\r\n // private static _xyz1Work: Point3d = Point3d.create();\r\n // private static _xyz2Work: Point3d = Point3d.create();\r\n /**\r\n * Split a (convex) polygon into 2 parts.\r\n * @param xyz original polygon\r\n * @param xyzIn array to receive inside part\r\n * @param xyzOut array to receive outside part\r\n * @param altitudeRange min and max altitudes encountered.\r\n */\r\n public static convexPolygonSplitInsideOutsidePlane(plane: PlaneAltitudeEvaluator, xyz: Point3d[], xyzIn: Point3d[], xyzOut: Point3d[], altitudeRange: Range1d) {\r\n const xyzCarrier = new Point3dArrayCarrier(xyz);\r\n const xyzInCarrier = new Point3dArrayCarrier(xyzIn);\r\n const xyzOutCarrier = new Point3dArrayCarrier(xyzOut);\r\n IndexedXYZCollectionPolygonOps.splitConvexPolygonInsideOutsidePlane(plane, xyzCarrier, xyzInCarrier, xyzOutCarrier, altitudeRange);\r\n\r\n }\r\n\r\n /** Return an array containing\r\n * * All points that are exactly on the plane.\r\n * * Crossing points between adjacent points that are (strictly) on opposite sides.\r\n */\r\n public static polygonPlaneCrossings(plane: PlaneAltitudeEvaluator, xyz: Point3d[], crossings: Point3d[]) {\r\n crossings.length = 0;\r\n if (xyz.length >= 2) {\r\n const xyz0 = this._xyz0Work;\r\n xyz0.setFromPoint3d(xyz[xyz.length - 1]);\r\n let a0 = plane.altitude(xyz0);\r\n for (const xyz1 of xyz) {\r\n const a1 = plane.altitude(xyz1);\r\n if (a0 * a1 < 0.0) {\r\n // simple crossing. . .\r\n const f = - a0 / (a1 - a0);\r\n crossings.push(xyz0.interpolate(f, xyz1));\r\n }\r\n if (a1 === 0.0) { // IMPORTANT -- every point is directly tested here\r\n crossings.push(xyz1.clone());\r\n }\r\n xyz0.setFromPoint3d(xyz1);\r\n a0 = a1;\r\n }\r\n }\r\n }\r\n /**\r\n * Clip a polygon, returning the clip result in the same object.\r\n * @param xyz input/output polygon\r\n * @param work scratch object\r\n * @param tolerance tolerance for on-plane decision.\r\n */\r\n public static convexPolygonClipInPlace(plane: PlaneAltitudeEvaluator, xyz: Point3d[], work: Point3d[] | undefined, tolerance: number = Geometry.smallMetricDistance) {\r\n if (work === undefined)\r\n work = [];\r\n work.length = 0;\r\n let numNegative = 0;\r\n const fractionTol = 1.0e-8;\r\n const b = -tolerance;\r\n if (xyz.length > 2) {\r\n let xyz0 = xyz[xyz.length - 1];\r\n let a0 = plane.altitude(xyz0);\r\n // if (a0 >= 0.0)\r\n // work.push_back (xyz0);\r\n for (const xyz1 of xyz) {\r\n const a1 = plane.altitude(xyz1);\r\n if (a1 < 0)\r\n numNegative++;\r\n if (a0 * a1 < 0.0) {\r\n // simple crossing . . .\r\n const f = - a0 / (a1 - a0);\r\n if (f > 1.0 - fractionTol && a1 >= 0.0) {\r\n // the endpoint will be saved -- avoid the duplicate\r\n } else {\r\n work.push(xyz0.interpolate(f, xyz1));\r\n }\r\n }\r\n if (a1 >= b)\r\n work.push(xyz1);\r\n xyz0 = Point3d.createFrom(xyz1);\r\n a0 = a1;\r\n }\r\n }\r\n\r\n if (work.length <= 2) {\r\n xyz.length = 0;\r\n } else if (numNegative > 0) {\r\n xyz.length = 0;\r\n for (const xyzI of work) {\r\n xyz.push(xyzI);\r\n }\r\n work.length = 0;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -64,5 +64,10 @@ export declare class PolylineOps {
|
|
|
64
64
|
* @param data points.
|
|
65
65
|
*/
|
|
66
66
|
static addClosurePoint(data: Point3d[] | Point3d[][]): void;
|
|
67
|
+
/**
|
|
68
|
+
* Remove closure points a polyline or array of polylines
|
|
69
|
+
* @param data points.
|
|
70
|
+
*/
|
|
71
|
+
static removeClosurePoint(data: Point3d[] | Point3d[][]): void;
|
|
67
72
|
}
|
|
68
73
|
//# sourceMappingURL=PolylineOps.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PolylineOps.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/PolylineOps.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC;;;GAGG;AACH,qBAAa,WAAW;IACtB;;;OAGG;WACW,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO;IAOzD;;;;;;OAMG;WACW,oBAAoB,CAAC,MAAM,EAAE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G;WACW,sBAAsB,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,EAAE;IAM3F;;;;;;;OAOG;WACW,+BAA+B,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,MAAU,GAAG,OAAO,EAAE;IAYrH,OAAO,CAAC,MAAM,CAAC,kCAAkC;IAOjD;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAiCvC;;;SAGK;WACY,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,MAAM,GAAE,OAAe,EAAE,SAAS,GAAE,MAAqC,GAAG,OAAO,EAAE;IAmCxI;;;OAGG;WACY,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,EAAE;IAgB5D;;;OAGG;WACY,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,EAAE;CAgBhE"}
|
|
@@ -192,6 +192,26 @@ class PolylineOps {
|
|
|
192
192
|
data.push(q0.clone());
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Remove closure points a polyline or array of polylines
|
|
197
|
+
* @param data points.
|
|
198
|
+
*/
|
|
199
|
+
static removeClosurePoint(data) {
|
|
200
|
+
if (data.length === 0)
|
|
201
|
+
return;
|
|
202
|
+
const q0 = data[0];
|
|
203
|
+
if (Array.isArray(q0)) {
|
|
204
|
+
for (const child of data) {
|
|
205
|
+
if (Array.isArray(child))
|
|
206
|
+
this.removeClosurePoint(child);
|
|
207
|
+
}
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const q1 = data[data.length - 1];
|
|
211
|
+
if (q0 instanceof Point3dVector3d_1.Point3d && q1 instanceof Point3dVector3d_1.Point3d && q0.isAlmostEqual(q1)) {
|
|
212
|
+
data.pop();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
195
215
|
}
|
|
196
216
|
exports.PolylineOps = PolylineOps;
|
|
197
217
|
//# sourceMappingURL=PolylineOps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PolylineOps.js","sourceRoot":"","sources":["../../../src/geometry3d/PolylineOps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,0CAAuC;AACvC,yDAAsD;AACtD,uDAA4C;AAC5C,uFAA+E;AAC/E,mCAAkC;AAElC,sBAAsB;AACtB;;;GAGG;AACH,MAAa,WAAW;IACtB;;;OAGG;IACI,MAAM,CAAC,eAAe,CAAC,MAAiB;QAC7C,MAAM,KAAK,GAAG,eAAO,CAAC,UAAU,EAAE,CAAC;QACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAClD;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD;;;;;;OAMG;IACI,MAAM,CAAC,oBAAoB,CAAC,MAAiB,EAAE,cAAsB;QAC1E,OAAO,4DAA0B,CAAC,gCAAgC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC7F,CAAC;IACD;;;;;OAKG;IACI,MAAM,CAAC,kBAAkB,CAAC,MAAiB,EAAE,aAAqB;QACvE,MAAM,IAAI,GAAG,mCAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7C,4DAA0B,CAAC,gCAAgC,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QACjF,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;IAChC,CAAC;IACD;;;;;OAKG;IACI,MAAM,CAAC,sBAAsB,CAAC,MAAiB,EAAE,eAAuB;QAC7E,MAAM,IAAI,GAAG,mCAAgB,CAAC,MAAM,CAAC,M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C;SACtC;IACH,CAAC;CAEF;AA7KD,kCA6KC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GrowableXYZArray } from \"./GrowableXYZArray\";\r\nimport { Point3d } from \"./Point3dVector3d\";\r\nimport { PolylineCompressionContext } from \"./PolylineCompressionByEdgeOffset\";\r\nimport { Range1d } from \"./Range\";\r\n\r\n// cspell:word Puecker\r\n/**\r\n * PolylineOps is a collection of static methods operating on polylines.\r\n * @public\r\n */\r\nexport class PolylineOps {\r\n /**\r\n * Return a Range1d with the shortest and longest edge lengths of the polyline.\r\n * @param points points to examine.\r\n */\r\n public static edgeLengthRange(points: Point3d[]): Range1d {\r\n const range = Range1d.createNull();\r\n for (let i = 1; i < points.length; i++) {\r\n range.extendX(points[i - 1].distance(points[i]));\r\n }\r\n return range;\r\n }\r\n /**\r\n * Return a simplified subset of given points.\r\n * * Points are removed by the Douglas-Puecker algorithm, viz https://en.wikipedia.org/wiki/Ramer–Douglas–Peucker_algorithm\r\n * * This is a global search, with multiple passes over the data.\r\n * @param source\r\n * @param chordTolerance\r\n */\r\n public static compressByChordError(source: Point3d[], chordTolerance: number): Point3d[] {\r\n return PolylineCompressionContext.compressPoint3dArrayByChordError(source, chordTolerance);\r\n }\r\n /**\r\n * Return a simplified subset of given points, omitting points if very close to their neighbors.\r\n * * This is a local search, with a single pass over the data.\r\n * @param source input points\r\n * @param maxEdgeLength\r\n */\r\n public static compressShortEdges(source: Point3d[], maxEdgeLength: number): Point3d[] {\r\n const dest = GrowableXYZArray.create(source);\r\n PolylineCompressionContext.compressInPlaceByShortEdgeLength(dest, maxEdgeLength);\r\n return dest.getPoint3dArray();\r\n }\r\n /**\r\n * Return a simplified subset of given points, omitting points of the triangle with adjacent points is small.\r\n * * This is a local search, with a single pass over the data.\r\n * @param source input points\r\n * @param maxEdgeLength\r\n */\r\n public static compressSmallTriangles(source: Point3d[], maxTriangleArea: number): Point3d[] {\r\n const dest = GrowableXYZArray.create(source);\r\n PolylineCompressionContext.compressInPlaceBySmallTriangleArea(dest, maxTriangleArea);\r\n return dest.getPoint3dArray();\r\n }\r\n\r\n /**\r\n * Return a simplified subset of given points, omitting points if close to the edge between neighboring points before and after\r\n * * This is a local search, with a single pass over the data for each pass.\r\n * @param source input points\r\n * @param maxDistance omit points if this close to edge between points before and after\r\n * @param numPass max number of times to run the filter. numPass=2 is observed to behave well.\r\n *\r\n */\r\n public static compressByPerpendicularDistance(source: Point3d[], maxDistance: number, numPass: number = 2): Point3d[] {\r\n const dest = GrowableXYZArray.create(source);\r\n let num0 = dest.length;\r\n for (let pass = 0; pass < numPass; pass++) {\r\n PolylineCompressionContext.compressInPlaceByPerpendicularDistance(dest, maxDistance);\r\n const num1 = dest.length;\r\n if (num1 === num0)\r\n break;\r\n num0 = num1;\r\n }\r\n return dest.getPoint3dArray();\r\n }\r\n private static squaredDistanceToInterpolatedPoint(pointQ: Point3d, point0: Point3d, fraction: number, point1: Point3d): number {\r\n const g = 1.0 - fraction;\r\n const dx = pointQ.x - (g * point0.x + fraction * point1.x);\r\n const dy = pointQ.y - (g * point0.y + fraction * point1.y);\r\n const dz = pointQ.z - (g * point0.z + fraction * point1.z);\r\n return dx * dx + dy * dy + dz * dz;\r\n }\r\n /**\r\n * test if either\r\n * * points[indexA] matches pointQ\r\n * * line from points[indexA] to points[indexB] overlaps points[indexA] to pointQ\r\n * @param points\r\n * @param pointQ\r\n * @param tolerance\r\n */\r\n private static isDanglerConfiguration(points: Point3d[], indexA: number, indexB: number,pointQ: Point3d, squaredDistanceTolerance: number): boolean {\r\n if (indexA < 0 || indexA >= points.length)\r\n return false;\r\n const pointA = points[indexA];\r\n // simple point match ...\r\n const d2Q = pointA.distanceSquared(pointQ);\r\n if (d2Q <= squaredDistanceTolerance)\r\n return true;\r\n if (indexB < 0 || indexB >= points.length)\r\n return false;\r\n const pointB = points[indexB];\r\n // The expensive test .. does newPoint double back to an interior or extrapolation of the final dest segment?\r\n //\r\n // or pointQ\r\n const dot = pointA.dotVectorsToTargets(pointB, pointQ);\r\n // simple case -- pointB..pointA..pointQ continues forward\r\n if (dot <= 0.0)\r\n return false;\r\n const d2B = pointA.distanceSquared(pointB);\r\n let distanceSquared;\r\n if (d2Q >= d2B) {\r\n // pointB----------------------------------->>>>>>> pointA\r\n // pointQ<<<<---------------------------------------------------------\r\n const fraction = dot / d2Q; // safe to divide because of earlier d2Q test.\r\n distanceSquared = this.squaredDistanceToInterpolatedPoint(pointB, pointA, fraction, pointQ);\r\n } else {\r\n // pointB----------------------------------->>>>>>> pointA\r\n // pointQ<<<<----------------------\r\n const fraction = dot / d2B;\r\n distanceSquared = this.squaredDistanceToInterpolatedPoint(pointQ, pointA, fraction, pointB);\r\n }\r\n return distanceSquared < squaredDistanceTolerance;\r\n }\r\n/**\r\n * Return a simplified subset of given points, omitting points on \"danglers\" that depart and return on a single path.\r\n * @param source input points\r\n */\r\n public static compressDanglers(source: Point3d[], closed: boolean = false, tolerance: number = Geometry.smallMetricDistance): Point3d[] {\r\n let n = source.length;\r\n const squaredDistanceTolerance = tolerance * tolerance;\r\n if (closed)\r\n while (n > 1 && source[n - 1].distanceSquared(source[0]) <= squaredDistanceTolerance)\r\n n--;\r\n const dest = [];\r\n dest.push(source[0].clone());\r\n for (let i = 1; i < n; i++){\r\n const newPoint = source[i];\r\n while (this.isDanglerConfiguration(dest, dest.length - 1, dest.length - 2, newPoint, squaredDistanceTolerance))\r\n dest.pop();\r\n dest.push(newPoint.clone());\r\n }\r\n if (closed) {\r\n // No purge moving backwards. Last point\r\n let leftIndex = 0;\r\n let rightIndex = dest.length - 1;\r\n while (rightIndex > leftIndex + 2) {\r\n if (this.isDanglerConfiguration(dest, leftIndex, leftIndex + 1, dest[rightIndex], squaredDistanceTolerance)) {\r\n leftIndex++;\r\n } else if (this.isDanglerConfiguration(dest, rightIndex, rightIndex - 1, dest[leftIndex], squaredDistanceTolerance)) {\r\n rightIndex--;\r\n } else {\r\n break;\r\n }\r\n }\r\n if (rightIndex + 1 < dest.length)\r\n dest.length = rightIndex + 1;\r\n if (leftIndex > 0) {\r\n dest.splice(0, leftIndex);\r\n }\r\n }\r\n return dest;\r\n }\r\n /**\r\n * Add closure points to a polyline or array of polylines\r\n * @param data points.\r\n */\r\n public static addClosurePoint(data: Point3d[] | Point3d[][]) {\r\n if (data.length === 0)\r\n return;\r\n const q0 = data[0];\r\n if (Array.isArray(q0)) {\r\n for (const child of data) {\r\n if (Array.isArray(child))\r\n this.addClosurePoint(child);\r\n }\r\n return;\r\n }\r\n const q1 = data[data.length - 1];\r\n if (q0 instanceof Point3d && q1 instanceof Point3d && !q0.isAlmostEqual (q1)) {\r\n (data as Point3d[]).push(q0.clone());\r\n }\r\n }\r\n\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"PolylineOps.js","sourceRoot":"","sources":["../../../src/geometry3d/PolylineOps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,0CAAuC;AACvC,yDAAsD;AACtD,uDAA4C;AAC5C,uFAA+E;AAC/E,mCAAkC;AAElC,sBAAsB;AACtB;;;GAGG;AACH,MAAa,WAAW;IACtB;;;OAGG;IACI,MAAM,CAAC,eAAe,CAAC,MAAiB;QAC7C,MAAM,KAAK,GAAG,eAAO,CAAC,UAAU,EAAE,CAAC;QACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAClD;QACD,OAAO,KAAK,CAAC;IACf,CAAC;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OAAO;QACT,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACnB,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;YACrB,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE;gBACxB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;oBACtB,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;aAC/B;YACD,OAAO;SACR;QACD,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjC,IAAI,EAAE,YAAY,yBAAO,IAAI,EAAE,YAAY,yBAAO,IAAI,CAAC,EAAE,CAAC,aAAa,CAAE,EAAE,CAAC,EAAE;YAC3E,IAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;SACtC;IACH,CAAC;IACD;;;OAGG;IACK,MAAM,CAAC,kBAAkB,CAAC,IAA6B;QAC7D,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YACnB,OAAO;QACT,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACnB,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;YACrB,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE;gBACxB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;oBACtB,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;aAClC;YACD,OAAO;SACR;QACD,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjC,IAAI,EAAE,YAAY,yBAAO,IAAI,EAAE,YAAY,yBAAO,IAAI,EAAE,CAAC,aAAa,CAAE,EAAE,CAAC,EAAE;YAC1E,IAAkB,CAAC,GAAG,EAAG,CAAC;SAC5B;IACD,CAAC;CACJ;AAhMD,kCAgMC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GrowableXYZArray } from \"./GrowableXYZArray\";\r\nimport { Point3d } from \"./Point3dVector3d\";\r\nimport { PolylineCompressionContext } from \"./PolylineCompressionByEdgeOffset\";\r\nimport { Range1d } from \"./Range\";\r\n\r\n// cspell:word Puecker\r\n/**\r\n * PolylineOps is a collection of static methods operating on polylines.\r\n * @public\r\n */\r\nexport class PolylineOps {\r\n /**\r\n * Return a Range1d with the shortest and longest edge lengths of the polyline.\r\n * @param points points to examine.\r\n */\r\n public static edgeLengthRange(points: Point3d[]): Range1d {\r\n const range = Range1d.createNull();\r\n for (let i = 1; i < points.length; i++) {\r\n range.extendX(points[i - 1].distance(points[i]));\r\n }\r\n return range;\r\n }\r\n /**\r\n * Return a simplified subset of given points.\r\n * * Points are removed by the Douglas-Puecker algorithm, viz https://en.wikipedia.org/wiki/Ramer–Douglas–Peucker_algorithm\r\n * * This is a global search, with multiple passes over the data.\r\n * @param source\r\n * @param chordTolerance\r\n */\r\n public static compressByChordError(source: Point3d[], chordTolerance: number): Point3d[] {\r\n return PolylineCompressionContext.compressPoint3dArrayByChordError(source, chordTolerance);\r\n }\r\n /**\r\n * Return a simplified subset of given points, omitting points if very close to their neighbors.\r\n * * This is a local search, with a single pass over the data.\r\n * @param source input points\r\n * @param maxEdgeLength\r\n */\r\n public static compressShortEdges(source: Point3d[], maxEdgeLength: number): Point3d[] {\r\n const dest = GrowableXYZArray.create(source);\r\n PolylineCompressionContext.compressInPlaceByShortEdgeLength(dest, maxEdgeLength);\r\n return dest.getPoint3dArray();\r\n }\r\n /**\r\n * Return a simplified subset of given points, omitting points of the triangle with adjacent points is small.\r\n * * This is a local search, with a single pass over the data.\r\n * @param source input points\r\n * @param maxEdgeLength\r\n */\r\n public static compressSmallTriangles(source: Point3d[], maxTriangleArea: number): Point3d[] {\r\n const dest = GrowableXYZArray.create(source);\r\n PolylineCompressionContext.compressInPlaceBySmallTriangleArea(dest, maxTriangleArea);\r\n return dest.getPoint3dArray();\r\n }\r\n\r\n /**\r\n * Return a simplified subset of given points, omitting points if close to the edge between neighboring points before and after\r\n * * This is a local search, with a single pass over the data for each pass.\r\n * @param source input points\r\n * @param maxDistance omit points if this close to edge between points before and after\r\n * @param numPass max number of times to run the filter. numPass=2 is observed to behave well.\r\n *\r\n */\r\n public static compressByPerpendicularDistance(source: Point3d[], maxDistance: number, numPass: number = 2): Point3d[] {\r\n const dest = GrowableXYZArray.create(source);\r\n let num0 = dest.length;\r\n for (let pass = 0; pass < numPass; pass++) {\r\n PolylineCompressionContext.compressInPlaceByPerpendicularDistance(dest, maxDistance);\r\n const num1 = dest.length;\r\n if (num1 === num0)\r\n break;\r\n num0 = num1;\r\n }\r\n return dest.getPoint3dArray();\r\n }\r\n private static squaredDistanceToInterpolatedPoint(pointQ: Point3d, point0: Point3d, fraction: number, point1: Point3d): number {\r\n const g = 1.0 - fraction;\r\n const dx = pointQ.x - (g * point0.x + fraction * point1.x);\r\n const dy = pointQ.y - (g * point0.y + fraction * point1.y);\r\n const dz = pointQ.z - (g * point0.z + fraction * point1.z);\r\n return dx * dx + dy * dy + dz * dz;\r\n }\r\n /**\r\n * test if either\r\n * * points[indexA] matches pointQ\r\n * * line from points[indexA] to points[indexB] overlaps points[indexA] to pointQ\r\n * @param points\r\n * @param pointQ\r\n * @param tolerance\r\n */\r\n private static isDanglerConfiguration(points: Point3d[], indexA: number, indexB: number,pointQ: Point3d, squaredDistanceTolerance: number): boolean {\r\n if (indexA < 0 || indexA >= points.length)\r\n return false;\r\n const pointA = points[indexA];\r\n // simple point match ...\r\n const d2Q = pointA.distanceSquared(pointQ);\r\n if (d2Q <= squaredDistanceTolerance)\r\n return true;\r\n if (indexB < 0 || indexB >= points.length)\r\n return false;\r\n const pointB = points[indexB];\r\n // The expensive test .. does newPoint double back to an interior or extrapolation of the final dest segment?\r\n //\r\n // or pointQ\r\n const dot = pointA.dotVectorsToTargets(pointB, pointQ);\r\n // simple case -- pointB..pointA..pointQ continues forward\r\n if (dot <= 0.0)\r\n return false;\r\n const d2B = pointA.distanceSquared(pointB);\r\n let distanceSquared;\r\n if (d2Q >= d2B) {\r\n // pointB----------------------------------->>>>>>> pointA\r\n // pointQ<<<<---------------------------------------------------------\r\n const fraction = dot / d2Q; // safe to divide because of earlier d2Q test.\r\n distanceSquared = this.squaredDistanceToInterpolatedPoint(pointB, pointA, fraction, pointQ);\r\n } else {\r\n // pointB----------------------------------->>>>>>> pointA\r\n // pointQ<<<<----------------------\r\n const fraction = dot / d2B;\r\n distanceSquared = this.squaredDistanceToInterpolatedPoint(pointQ, pointA, fraction, pointB);\r\n }\r\n return distanceSquared < squaredDistanceTolerance;\r\n }\r\n/**\r\n * Return a simplified subset of given points, omitting points on \"danglers\" that depart and return on a single path.\r\n * @param source input points\r\n */\r\n public static compressDanglers(source: Point3d[], closed: boolean = false, tolerance: number = Geometry.smallMetricDistance): Point3d[] {\r\n let n = source.length;\r\n const squaredDistanceTolerance = tolerance * tolerance;\r\n if (closed)\r\n while (n > 1 && source[n - 1].distanceSquared(source[0]) <= squaredDistanceTolerance)\r\n n--;\r\n const dest = [];\r\n dest.push(source[0].clone());\r\n for (let i = 1; i < n; i++){\r\n const newPoint = source[i];\r\n while (this.isDanglerConfiguration(dest, dest.length - 1, dest.length - 2, newPoint, squaredDistanceTolerance))\r\n dest.pop();\r\n dest.push(newPoint.clone());\r\n }\r\n if (closed) {\r\n // No purge moving backwards. Last point\r\n let leftIndex = 0;\r\n let rightIndex = dest.length - 1;\r\n while (rightIndex > leftIndex + 2) {\r\n if (this.isDanglerConfiguration(dest, leftIndex, leftIndex + 1, dest[rightIndex], squaredDistanceTolerance)) {\r\n leftIndex++;\r\n } else if (this.isDanglerConfiguration(dest, rightIndex, rightIndex - 1, dest[leftIndex], squaredDistanceTolerance)) {\r\n rightIndex--;\r\n } else {\r\n break;\r\n }\r\n }\r\n if (rightIndex + 1 < dest.length)\r\n dest.length = rightIndex + 1;\r\n if (leftIndex > 0) {\r\n dest.splice(0, leftIndex);\r\n }\r\n }\r\n return dest;\r\n }\r\n /**\r\n * Add closure points to a polyline or array of polylines\r\n * @param data points.\r\n */\r\n public static addClosurePoint(data: Point3d[] | Point3d[][]) {\r\n if (data.length === 0)\r\n return;\r\n const q0 = data[0];\r\n if (Array.isArray(q0)) {\r\n for (const child of data) {\r\n if (Array.isArray(child))\r\n this.addClosurePoint(child);\r\n }\r\n return;\r\n }\r\n const q1 = data[data.length - 1];\r\n if (q0 instanceof Point3d && q1 instanceof Point3d && !q0.isAlmostEqual (q1)) {\r\n (data as Point3d[]).push(q0.clone());\r\n }\r\n }\r\n /**\r\n * Remove closure points a polyline or array of polylines\r\n * @param data points.\r\n */\r\n public static removeClosurePoint(data: Point3d[] | Point3d[][]) {\r\n if (data.length === 0)\r\n return;\r\n const q0 = data[0];\r\n if (Array.isArray(q0)) {\r\n for (const child of data) {\r\n if (Array.isArray(child))\r\n this.removeClosurePoint(child);\r\n }\r\n return;\r\n }\r\n const q1 = data[data.length - 1];\r\n if (q0 instanceof Point3d && q1 instanceof Point3d && q0.isAlmostEqual (q1)) {\r\n (data as Point3d[]).pop ();\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -56,7 +56,7 @@ export declare class ClusterableArray extends GrowableBlockedArray {
|
|
|
56
56
|
*
|
|
57
57
|
* ** simple coordinate blocks (x,y) or (x,y,z) would work fine but have occasional performance problems because points with same x would generate big blocks of
|
|
58
58
|
* candidates for clusters.
|
|
59
|
-
* ** The usual solution is to u value which is a dot product along some skew direction and have the blocks contain (u,x,y) or (u,x,y,z) for 2d versus 3d.
|
|
59
|
+
* ** The usual solution is to sort by u value, which is a dot product along some skew direction, and have the blocks contain (u,x,y) or (u,x,y,z) for 2d versus 3d.
|
|
60
60
|
* ** apply setupPrimaryClusterSort to prepare that!!!
|
|
61
61
|
* * After a simple lexical sort, consecutive blocks that are within tolerance in the 0 component
|
|
62
62
|
* are inspected. Within that candidate set, all blocks that are within tolerance for ALL components are clustered.
|
|
@@ -88,9 +88,9 @@ export declare class ClusterableArray extends GrowableBlockedArray {
|
|
|
88
88
|
*/
|
|
89
89
|
createIndexClusterToClusterStart(clusteredBlocks: Uint32Array): Uint32Array;
|
|
90
90
|
/**
|
|
91
|
-
* Sort terminator-delimited subsets of an array of indices into the table, using a single
|
|
92
|
-
* @param blockedIndices
|
|
93
|
-
* @param
|
|
91
|
+
* Sort terminator-delimited subsets of an array of indices into the table, using a single data value as sort key.
|
|
92
|
+
* @param blockedIndices indices, organized as blocks of good indices terminated by the clusterTerminator. Each block is individually sorted on return.
|
|
93
|
+
* @param dataIndex index of the data key, e.g., if the sort key is the first extraData (angle) after x and y coordinate data, pass dataIndex = 2.
|
|
94
94
|
*/
|
|
95
95
|
sortSubsetsBySingleKey(blockedIndices: Uint32Array, dataIndex: number): void;
|
|
96
96
|
/**
|
|
@@ -123,7 +123,7 @@ class ClusterableArray extends GrowableBlockedArray_1.GrowableBlockedArray {
|
|
|
123
123
|
*
|
|
124
124
|
* ** simple coordinate blocks (x,y) or (x,y,z) would work fine but have occasional performance problems because points with same x would generate big blocks of
|
|
125
125
|
* candidates for clusters.
|
|
126
|
-
* ** The usual solution is to u value which is a dot product along some skew direction and have the blocks contain (u,x,y) or (u,x,y,z) for 2d versus 3d.
|
|
126
|
+
* ** The usual solution is to sort by u value, which is a dot product along some skew direction, and have the blocks contain (u,x,y) or (u,x,y,z) for 2d versus 3d.
|
|
127
127
|
* ** apply setupPrimaryClusterSort to prepare that!!!
|
|
128
128
|
* * After a simple lexical sort, consecutive blocks that are within tolerance in the 0 component
|
|
129
129
|
* are inspected. Within that candidate set, all blocks that are within tolerance for ALL components are clustered.
|
|
@@ -281,9 +281,9 @@ class ClusterableArray extends GrowableBlockedArray_1.GrowableBlockedArray {
|
|
|
281
281
|
return clusterToClusterStart;
|
|
282
282
|
}
|
|
283
283
|
/**
|
|
284
|
-
* Sort terminator-delimited subsets of an array of indices into the table, using a single
|
|
285
|
-
* @param blockedIndices
|
|
286
|
-
* @param
|
|
284
|
+
* Sort terminator-delimited subsets of an array of indices into the table, using a single data value as sort key.
|
|
285
|
+
* @param blockedIndices indices, organized as blocks of good indices terminated by the clusterTerminator. Each block is individually sorted on return.
|
|
286
|
+
* @param dataIndex index of the data key, e.g., if the sort key is the first extraData (angle) after x and y coordinate data, pass dataIndex = 2.
|
|
287
287
|
*/
|
|
288
288
|
sortSubsetsBySingleKey(blockedIndices, dataIndex) {
|
|
289
289
|
const dataOffset = 1 + dataIndex;
|
|
@@ -293,7 +293,7 @@ class ClusterableArray extends GrowableBlockedArray_1.GrowableBlockedArray {
|
|
|
293
293
|
const numK = blockedIndices.length;
|
|
294
294
|
for (let kEnd = 0; kEnd < numK; kEnd++) {
|
|
295
295
|
if (blockedIndices[kEnd] === ClusterableArray.clusterTerminator) {
|
|
296
|
-
// sort blockedIndices[kBegin
|
|
296
|
+
// bubble sort blockedIndices[kBegin <= k < kEnd].
|
|
297
297
|
// (search for minimum remaining, swap . . )
|
|
298
298
|
for (let k0 = kBegin; k0 + 1 < kEnd; k0++) {
|
|
299
299
|
key0 = this.getWithinBlock(blockedIndices[k0], dataOffset);
|