@itwin/core-geometry 3.0.0-dev.84 → 3.0.0-dev.88
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 +1049 -1049
- package/LICENSE.md +9 -9
- package/README.md +17 -17
- package/lib/cjs/Constant.js.map +1 -1
- package/lib/cjs/clipping/ClipVector.d.ts +0 -1
- package/lib/cjs/clipping/ClipVector.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipVector.js +0 -1
- package/lib/cjs/clipping/ClipVector.js.map +1 -1
- package/lib/cjs/core-geometry.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts +2 -2
- package/lib/cjs/geometry3d/Point3dArrayCarrier.js +2 -2
- package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
- package/lib/cjs/topology/ChainMerge.js.map +1 -1
- package/lib/cjs/topology/Graph.d.ts +35 -6
- package/lib/cjs/topology/Graph.d.ts.map +1 -1
- package/lib/cjs/topology/Graph.js +90 -10
- package/lib/cjs/topology/Graph.js.map +1 -1
- package/lib/cjs/topology/HalfEdgeGraphSearch.js.map +1 -1
- package/lib/cjs/topology/HalfEdgeGraphValidation.js.map +1 -1
- package/lib/cjs/topology/HalfEdgePointInGraphSearch.js.map +1 -1
- package/lib/cjs/topology/HalfEdgePriorityQueue.js.map +1 -1
- package/lib/cjs/topology/MaskManager.js.map +1 -1
- package/lib/cjs/topology/Merging.d.ts +44 -9
- package/lib/cjs/topology/Merging.d.ts.map +1 -1
- package/lib/cjs/topology/Merging.js +110 -22
- package/lib/cjs/topology/Merging.js.map +1 -1
- package/lib/cjs/topology/RegularizeFace.js.map +1 -1
- package/lib/cjs/topology/Triangulation.js.map +1 -1
- package/lib/esm/Constant.js.map +1 -1
- package/lib/esm/clipping/ClipVector.d.ts +0 -1
- package/lib/esm/clipping/ClipVector.d.ts.map +1 -1
- package/lib/esm/clipping/ClipVector.js +0 -1
- package/lib/esm/clipping/ClipVector.js.map +1 -1
- package/lib/esm/core-geometry.js.map +1 -1
- package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts +2 -2
- package/lib/esm/geometry3d/Point3dArrayCarrier.js +2 -2
- package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
- package/lib/esm/topology/ChainMerge.js.map +1 -1
- package/lib/esm/topology/Graph.d.ts +35 -6
- package/lib/esm/topology/Graph.d.ts.map +1 -1
- package/lib/esm/topology/Graph.js +90 -10
- package/lib/esm/topology/Graph.js.map +1 -1
- package/lib/esm/topology/HalfEdgeGraphSearch.js.map +1 -1
- package/lib/esm/topology/HalfEdgeGraphValidation.js.map +1 -1
- package/lib/esm/topology/HalfEdgePointInGraphSearch.js.map +1 -1
- package/lib/esm/topology/HalfEdgePriorityQueue.js.map +1 -1
- package/lib/esm/topology/MaskManager.js.map +1 -1
- package/lib/esm/topology/Merging.d.ts +44 -9
- package/lib/esm/topology/Merging.d.ts.map +1 -1
- package/lib/esm/topology/Merging.js +110 -22
- package/lib/esm/topology/Merging.js.map +1 -1
- package/lib/esm/topology/RegularizeFace.js.map +1 -1
- package/lib/esm/topology/Triangulation.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HalfEdgeGraphSearch.js","sourceRoot":"","sources":["../../../src/topology/HalfEdgeGraphSearch.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAY,aAAa,EAAE,YAAY,EAAmD,MAAM,SAAS,CAAC;AACjH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAQhE;GACG;AACH,MAAM,OAAO,kBAAkB;IAG7B;;;;OAIG;IACH,YAAmB,IAAkB,EAAE,cAAuB,IAAI;QAChE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,YAAY,GAAG,WAAW,CA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BAAqB,GAAG,UAAU,CAAC;YACvC,SAAU;gBACR,IAAI,qBAAqB,CAAC,OAAO,CAAC,SAAS,CAAC;oBAC1C,OAAO;gBACT,IAAI,cAAc,CAAC,qBAAqB,CAAC,EAAE;oBACzC,IAAI,GAAG,qBAAqB,CAAC;oBAC7B,MAAM;iBACP;gBACD,qBAAqB,GAAG,qBAAqB,CAAC,iBAAiB,CAAC;gBAChE,IAAI,qBAAqB,KAAK,UAAU;oBACtC,MAAM;aACT;SACF;IACH,CAAC;IACD;;;;;;;;;;;OAWG;IACI,MAAM,CAAC,mCAAmC,CAAC,KAAoB,EAAE,YAA0B;QAChG,MAAM,KAAK,GAAiB,EAAE,CAAC;QAC/B,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACvC,MAAM,cAAc,GAAG,CAAC,IAAc,EAAW,EAAE;YACjD,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACvF,CAAC,CAAC;QACF,MAAM,sBAAsB,GAAG,CAAC,IAAc,EAAE,OAAe,EAAE,EAAE;YACjE,IAAI,OAAO,KAAK,CAAC;gBACf,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACjB,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,YAAY,EAAE;YACrC,IAAI,CAAC,mCAAmC,CAAC,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,sBAAsB,CAAC,CAAC;SACnG;QACD,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Topology\n */\n\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask, HalfEdgeToBooleanFunction, NodeToNumberFunction } from \"./Graph\";\nimport { SignedDataSummary } from \"./SignedDataSummary\";\nimport { XYParitySearchContext } from \"./XYParitySearchContext\";\n\n/**\n * Interface for an object that executes boolean tests on edges.\n */\nexport interface HalfEdgeTestObject {\n testEdge(h: HalfEdge): boolean;\n}\n/**\n */\nexport class HalfEdgeMaskTester {\n private _targetMask: HalfEdgeMask;\n private _targetValue: boolean;\n /**\n *\n * @param mask mask to test in `testEdge` function\n * @param targetValue value to match for true return\n */\n public constructor(mask: HalfEdgeMask, targetValue: boolean = true) {\n this._targetMask = mask;\n this._targetValue = targetValue;\n }\n /** Return true if the value of the targetMask matches the targetValue */\n public testEdge(edge: HalfEdge): boolean {\n return edge.isMaskSet(this._targetMask) === this._targetValue;\n }\n\n}\n// Search services for HalfEdgeGraph\nexport class HalfEdgeGraphSearch {\n\n /**\n * * for each node of face, set the mask push to allNodesStack\n * * push the faceSeed on onePerFaceStack[]\n */\n private static pushAndMaskAllNodesInFace(faceSeed: HalfEdge, mask: number, allNodeStack: HalfEdge[], onePerFaceStack: HalfEdge[]) {\n onePerFaceStack.push(faceSeed);\n faceSeed.collectAroundFace((node: HalfEdge) => {\n node.setMask(mask);\n allNodeStack.push(node);\n });\n }\n\n /**\n * Search an array of faceSeed nodes for the face with the most negative area.\n * @param oneCandidateNodePerFace array containing one node from each face to be considered.\n */\n public static findMinimumAreaFace(oneCandidateNodePerFace: HalfEdgeGraph | HalfEdge[],\n faceAreaFunction?: NodeToNumberFunction): HalfEdge {\n const summary = HalfEdgeGraphSearch.collectFaceAreaSummary(oneCandidateNodePerFace, false, faceAreaFunction);\n return summary.largestNegativeItem!;\n }\n /**\n * static method for face area computation -- useful as function parameter in collect FaceAreaSummary.\n * * This simply calls `node.signedFaceArea ()`\n * @param node instance for signedFaceArea call.\n */\n public static signedFaceArea(node: HalfEdge): number { return node.signedFaceArea(); }\n /**\n *\n * Return a summary structure data about face (or other numeric quantity if the caller's areaFunction returns other value)\n * * The default areaFunction computes area of polygonal face.\n * * Callers with curved edge graphs must supply their own area function.\n * @param source graph or array of nodes to examine\n * @param collectAllNodes flag to pass to the SignedDataSummary constructor to control collection of nodes.\n * @param areaFunction function to all to obtain area (or other numeric value)\n */\n public static collectFaceAreaSummary(source: HalfEdgeGraph | HalfEdge[], collectAllNodes: boolean = false,\n areaFunction: NodeToNumberFunction = HalfEdgeGraphSearch.signedFaceArea): SignedDataSummary<HalfEdge> {\n const result = new SignedDataSummary<HalfEdge>(collectAllNodes);\n let allFaces: HalfEdge[];\n\n if (source instanceof HalfEdgeGraph)\n allFaces = source.collectFaceLoops();\n else\n allFaces = source;\n\n for (const node of allFaces) {\n const area = areaFunction(node);\n result.announceItem(node, area);\n }\n return result;\n }\n\n /**\n * * Test if the graph is triangulated.\n * * Return false if:\n * * Positive area face with more than 3 edges\n * * more than 1 negative area face with `allowMultipleNegativeAreaFaces` false\n * * 2-edge faces are ignored.\n */\n public static isTriangulatedCCW(source: HalfEdgeGraph | HalfEdge[], allowMultipleNegativeAreaFaces: boolean = true, numPositiveExceptionsAllowed = 0): boolean {\n let allFaces: HalfEdge[];\n\n if (source instanceof HalfEdgeGraph)\n allFaces = source.collectFaceLoops();\n else\n allFaces = source;\n let numNegative = 0;\n let numPositiveExceptions = 0;\n for (const node of allFaces) {\n const numEdges = node.countEdgesAroundFace();\n if (numEdges >= 3) {\n const area = node.signedFaceArea();\n if (area > 0) {\n if (numEdges > 3) {\n numPositiveExceptions++;\n if (numPositiveExceptions > numPositiveExceptionsAllowed)\n return false;\n }\n } else {\n numNegative++;\n if (numNegative > 1) {\n if (!allowMultipleNegativeAreaFaces)\n return false;\n }\n }\n }\n }\n return true;\n }\n\n /**\n * Search to all accessible faces from given seed.\n * * The returned array contains one representative node in each face of the connected component.\n * * If (nonnull) parity mask is given, on return:\n * * It is entirely set or entirely clear around each face\n * * It is entirely set on all faces that are an even number of face-to-face steps away from the seed.\n * * It is entirely clear on all faces that are an odd number of face-to-face steps away from the seed.\n * @param seedEdge first edge to search.\n * @param visitMask mask applied to all faces as visited.\n * @param parityMask mask to apply (a) to first face, (b) to faces with alternating parity during the search.\n */\n private static parityFloodFromSeed(seedEdge: HalfEdge, visitMask: HalfEdgeMask, parityEdgeTester: HalfEdgeTestObject | undefined, parityMask: HalfEdgeMask): HalfEdge[] {\n const faces: HalfEdge[] = [];\n if (seedEdge.isMaskSet(visitMask)) return faces; // empty\n\n const allMasks = parityMask | visitMask;\n const stack: HalfEdge[] = [];\n // arbitrarily call the seed face exterior ... others will alternate as visited.\n HalfEdgeGraphSearch.pushAndMaskAllNodesInFace(seedEdge, allMasks, stack, faces); // Start with exterior as mask\n while (stack.length > 0) {\n const p = stack.pop()!;\n const mate = p.edgeMate;\n if (!mate)\n continue;\n if (!mate.isMaskSet(visitMask)) {\n let newState = p.isMaskSet(parityMask);\n if (!parityEdgeTester || parityEdgeTester.testEdge(p))\n newState = !newState;\n HalfEdgeGraphSearch.pushAndMaskAllNodesInFace(mate, newState ? allMasks : visitMask, stack, faces);\n }\n }\n return faces;\n }\n /**\n * * Search the given faces for the one with the minimum area.\n * * If the mask in that face is OFF, toggle it on (all half edges of) all the faces.\n * * In a properly merged planar subdivision there should be only one true negative area face per component.\n * @param graph parent graph\n * @param parityMask mask which was previously set with alternating parity, but with an arbitrary start face.\n * @param faces array of faces to search.\n */\n private static correctParityInSingleComponent(_graph: HalfEdgeGraph, mask: HalfEdgeMask, faces: HalfEdge[]) {\n const exteriorHalfEdge = HalfEdgeGraphSearch.findMinimumAreaFace(faces);\n if (!exteriorHalfEdge) {\n } else if (exteriorHalfEdge.isMaskSet(mask)) {\n // all should be well .. nothing to do.\n } else {\n // TOGGLE around the face (assuming all are consistent with the seed)\n for (const faceSeed of faces) {\n if (faceSeed.isMaskSet(mask)) {\n faceSeed.clearMaskAroundFace(mask);\n } else {\n faceSeed.setMaskAroundFace(mask);\n }\n }\n }\n }\n /** Apply correctParityInSingleComponent to each array in components. (Quick exit if mask in NULL_MASK) */\n private static correctParityInComponentArrays(graph: HalfEdgeGraph, mask: HalfEdgeMask, components: HalfEdge[][]) {\n if (mask === HalfEdgeMask.NULL_MASK)\n return;\n for (const facesInComponent of components)\n HalfEdgeGraphSearch.correctParityInSingleComponent(graph, mask, facesInComponent);\n }\n /**\n * Collect arrays gathering faces by connected component.\n * @param graph graph to inspect\n * @param parityEdgeTester (optional) function to test of an edge is a parity change.\n * @param parityMask (optional, along with boundaryTestFunction) mask to apply indicating parity. If this is Mask.NULL_MASK, there is no record of parity.\n */\n public static collectConnectedComponentsWithExteriorParityMasks(graph: HalfEdgeGraph, parityEdgeTester: HalfEdgeTestObject | undefined, parityMask: HalfEdgeMask = HalfEdgeMask.NULL_MASK): HalfEdge[][] {\n const components = [];\n const visitMask = HalfEdgeMask.VISITED;\n const allMasks = parityMask | visitMask;\n graph.clearMask(allMasks);\n for (const faceSeed of graph.allHalfEdges) {\n if (!faceSeed.isMaskSet(HalfEdgeMask.VISITED)) {\n const newFaces = HalfEdgeGraphSearch.parityFloodFromSeed(faceSeed, visitMask, parityEdgeTester, parityMask);\n components.push(newFaces);\n }\n }\n HalfEdgeGraphSearch.correctParityInComponentArrays(graph, parityMask, components);\n return components;\n }\n /**\n * Test if (x,y) is inside (1), on an edge (0) or outside (-1) a face.\n * @param seedNode any node on the face loop\n * @param x x coordinate of test point.\n * @param y y coordinate of test point.\n */\n public static pointInOrOnFaceXY(seedNode: HalfEdge, x: number, y: number): number | undefined {\n const context = new XYParitySearchContext(x, y);\n // walk around looking for an accepted node to start the search (seedNode is usually ok!)\n let nodeA = seedNode;\n let nodeB = seedNode.faceSuccessor;\n for (; ; nodeA = nodeB) {\n if (context.tryStartEdge(nodeA.x, nodeA.y, nodeB.x, nodeB.y))\n break;\n if (nodeB === seedNode) {\n // umm.. the face is all on the x axis?\n return context.classifyCounts();\n }\n nodeB = nodeA.faceSuccessor;\n }\n\n // nodeB is the real start node for search ... emit ends of each edge around the face,\n // stopping after emitting nodeB as an edge end.\n let node = nodeB.faceSuccessor;\n for (; ;) {\n if (!context.advance(node.x, node.y)) {\n return context.classifyCounts();\n }\n if (node === nodeB)\n break;\n node = node.faceSuccessor;\n }\n return context.classifyCounts();\n }\n /**\n * Announce nodes that are \"extended face boundary\" by conditions (usually mask of node and mate) in test functions.\n * * After each node, the next candidate in reached by looking \"around the head vertex loop\" for the next boundary.\n * * \"Around the vertex\" from nodeA means\n * * First look at nodeA.faceSuccessor;\n * * Then look at vertexPredecessor around that vertex loop.\n * * Each accepted node is passed to announceNode, and marked with the visit mask.\n * * The counter of the announceEdge function is zero for the first edge, then increases with each edge.\n * @param seed start node.\n * @param isBoundaryEdge\n * @param announceEdge\n */\n public static collectExtendedBoundaryLoopFromSeed(seed: HalfEdge, visitMask: HalfEdgeMask, isBoundaryEdge: HalfEdgeToBooleanFunction,\n announceEdge: (edge: HalfEdge, counter: number) => void) {\n let counter = 0;\n while (!seed.getMask(visitMask) && isBoundaryEdge(seed)) {\n announceEdge(seed, counter++);\n seed.setMask(visitMask);\n const vertexBase = seed.faceSuccessor;\n let candidateAroundVertex = vertexBase;\n for (; ;) {\n if (candidateAroundVertex.getMask(visitMask))\n return;\n if (isBoundaryEdge(candidateAroundVertex)) {\n seed = candidateAroundVertex;\n break;\n }\n candidateAroundVertex = candidateAroundVertex.vertexPredecessor;\n if (candidateAroundVertex === vertexBase)\n break;\n }\n }\n }\n /**\n * Collect arrays of nodes \"around the boundary\" of a graph with extraneous (non-boundary) edges.\n * * The \"boundary\" is nodes that do NOT have the exterior mask, but whose mates DO have the exterior mask.\n * * After each node, the next candidate in reached by looking \"around the head vertex loop\" for the next boundary.\n * * \"Around the vertex\" from nodeA means\n * * First look at nodeA.faceSuccessor;\n * * Then look at vertexPredecessor around that vertex loop.\n * * Each accepted node is passed to announceNode, and marked with the visit mask.\n * @param seed start node.\n * @param isBoundaryNode\n * @param announceNode\n */\n public static collectExtendedBoundaryLoopsInGraph(graph: HalfEdgeGraph, exteriorMask: HalfEdgeMask): HalfEdge[][] {\n const loops: HalfEdge[][] = [];\n const visitMask = graph.grabMask(true);\n const isBoundaryEdge = (edge: HalfEdge): boolean => {\n return edge.getMask(exteriorMask) === 0 && edge.edgeMate.getMask(exteriorMask) !== 0;\n };\n const announceEdgeInBoundary = (edge: HalfEdge, counter: number) => {\n if (counter === 0)\n loops.push([]);\n loops[loops.length - 1].push(edge);\n };\n for (const seed of graph.allHalfEdges) {\n this.collectExtendedBoundaryLoopFromSeed(seed, visitMask, isBoundaryEdge, announceEdgeInBoundary);\n }\n graph.dropMask(visitMask);\n return loops;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"HalfEdgeGraphSearch.js","sourceRoot":"","sources":["../../../src/topology/HalfEdgeGraphSearch.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAY,aAAa,EAAE,YAAY,EAAmD,MAAM,SAAS,CAAC;AACjH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAQhE;GACG;AACH,MAAM,OAAO,kBAAkB;IAG7B;;;;OAIG;IACH,YAAmB,IAAkB,EAAE,cAAuB,IAAI;QAChE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IACD,yEAAyE;IAClE,QAAQ,CAAC,IAAc;QAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC,YAAY,CAAC;IAChE,CAAC;CAEF;AACD,oCAAoC;AACpC,MAAM,OAAO,mBAAmB;IAE9B;;;OAGG;IACK,MAAM,CAAC,yBAA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iB,CAAC;gBAChE,IAAI,qBAAqB,KAAK,UAAU;oBACtC,MAAM;aACT;SACF;IACH,CAAC;IACD;;;;;;;;;;;OAWG;IACI,MAAM,CAAC,mCAAmC,CAAC,KAAoB,EAAE,YAA0B;QAChG,MAAM,KAAK,GAAiB,EAAE,CAAC;QAC/B,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACvC,MAAM,cAAc,GAAG,CAAC,IAAc,EAAW,EAAE;YACjD,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACvF,CAAC,CAAC;QACF,MAAM,sBAAsB,GAAG,CAAC,IAAc,EAAE,OAAe,EAAE,EAAE;YACjE,IAAI,OAAO,KAAK,CAAC;gBACf,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACjB,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,YAAY,EAAE;YACrC,IAAI,CAAC,mCAAmC,CAAC,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,sBAAsB,CAAC,CAAC;SACnG;QACD,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Topology\r\n */\r\n\r\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask, HalfEdgeToBooleanFunction, NodeToNumberFunction } from \"./Graph\";\r\nimport { SignedDataSummary } from \"./SignedDataSummary\";\r\nimport { XYParitySearchContext } from \"./XYParitySearchContext\";\r\n\r\n/**\r\n * Interface for an object that executes boolean tests on edges.\r\n */\r\nexport interface HalfEdgeTestObject {\r\n testEdge(h: HalfEdge): boolean;\r\n}\r\n/**\r\n */\r\nexport class HalfEdgeMaskTester {\r\n private _targetMask: HalfEdgeMask;\r\n private _targetValue: boolean;\r\n /**\r\n *\r\n * @param mask mask to test in `testEdge` function\r\n * @param targetValue value to match for true return\r\n */\r\n public constructor(mask: HalfEdgeMask, targetValue: boolean = true) {\r\n this._targetMask = mask;\r\n this._targetValue = targetValue;\r\n }\r\n /** Return true if the value of the targetMask matches the targetValue */\r\n public testEdge(edge: HalfEdge): boolean {\r\n return edge.isMaskSet(this._targetMask) === this._targetValue;\r\n }\r\n\r\n}\r\n// Search services for HalfEdgeGraph\r\nexport class HalfEdgeGraphSearch {\r\n\r\n /**\r\n * * for each node of face, set the mask push to allNodesStack\r\n * * push the faceSeed on onePerFaceStack[]\r\n */\r\n private static pushAndMaskAllNodesInFace(faceSeed: HalfEdge, mask: number, allNodeStack: HalfEdge[], onePerFaceStack: HalfEdge[]) {\r\n onePerFaceStack.push(faceSeed);\r\n faceSeed.collectAroundFace((node: HalfEdge) => {\r\n node.setMask(mask);\r\n allNodeStack.push(node);\r\n });\r\n }\r\n\r\n /**\r\n * Search an array of faceSeed nodes for the face with the most negative area.\r\n * @param oneCandidateNodePerFace array containing one node from each face to be considered.\r\n */\r\n public static findMinimumAreaFace(oneCandidateNodePerFace: HalfEdgeGraph | HalfEdge[],\r\n faceAreaFunction?: NodeToNumberFunction): HalfEdge {\r\n const summary = HalfEdgeGraphSearch.collectFaceAreaSummary(oneCandidateNodePerFace, false, faceAreaFunction);\r\n return summary.largestNegativeItem!;\r\n }\r\n /**\r\n * static method for face area computation -- useful as function parameter in collect FaceAreaSummary.\r\n * * This simply calls `node.signedFaceArea ()`\r\n * @param node instance for signedFaceArea call.\r\n */\r\n public static signedFaceArea(node: HalfEdge): number { return node.signedFaceArea(); }\r\n /**\r\n *\r\n * Return a summary structure data about face (or other numeric quantity if the caller's areaFunction returns other value)\r\n * * The default areaFunction computes area of polygonal face.\r\n * * Callers with curved edge graphs must supply their own area function.\r\n * @param source graph or array of nodes to examine\r\n * @param collectAllNodes flag to pass to the SignedDataSummary constructor to control collection of nodes.\r\n * @param areaFunction function to all to obtain area (or other numeric value)\r\n */\r\n public static collectFaceAreaSummary(source: HalfEdgeGraph | HalfEdge[], collectAllNodes: boolean = false,\r\n areaFunction: NodeToNumberFunction = HalfEdgeGraphSearch.signedFaceArea): SignedDataSummary<HalfEdge> {\r\n const result = new SignedDataSummary<HalfEdge>(collectAllNodes);\r\n let allFaces: HalfEdge[];\r\n\r\n if (source instanceof HalfEdgeGraph)\r\n allFaces = source.collectFaceLoops();\r\n else\r\n allFaces = source;\r\n\r\n for (const node of allFaces) {\r\n const area = areaFunction(node);\r\n result.announceItem(node, area);\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * * Test if the graph is triangulated.\r\n * * Return false if:\r\n * * Positive area face with more than 3 edges\r\n * * more than 1 negative area face with `allowMultipleNegativeAreaFaces` false\r\n * * 2-edge faces are ignored.\r\n */\r\n public static isTriangulatedCCW(source: HalfEdgeGraph | HalfEdge[], allowMultipleNegativeAreaFaces: boolean = true, numPositiveExceptionsAllowed = 0): boolean {\r\n let allFaces: HalfEdge[];\r\n\r\n if (source instanceof HalfEdgeGraph)\r\n allFaces = source.collectFaceLoops();\r\n else\r\n allFaces = source;\r\n let numNegative = 0;\r\n let numPositiveExceptions = 0;\r\n for (const node of allFaces) {\r\n const numEdges = node.countEdgesAroundFace();\r\n if (numEdges >= 3) {\r\n const area = node.signedFaceArea();\r\n if (area > 0) {\r\n if (numEdges > 3) {\r\n numPositiveExceptions++;\r\n if (numPositiveExceptions > numPositiveExceptionsAllowed)\r\n return false;\r\n }\r\n } else {\r\n numNegative++;\r\n if (numNegative > 1) {\r\n if (!allowMultipleNegativeAreaFaces)\r\n return false;\r\n }\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Search to all accessible faces from given seed.\r\n * * The returned array contains one representative node in each face of the connected component.\r\n * * If (nonnull) parity mask is given, on return:\r\n * * It is entirely set or entirely clear around each face\r\n * * It is entirely set on all faces that are an even number of face-to-face steps away from the seed.\r\n * * It is entirely clear on all faces that are an odd number of face-to-face steps away from the seed.\r\n * @param seedEdge first edge to search.\r\n * @param visitMask mask applied to all faces as visited.\r\n * @param parityMask mask to apply (a) to first face, (b) to faces with alternating parity during the search.\r\n */\r\n private static parityFloodFromSeed(seedEdge: HalfEdge, visitMask: HalfEdgeMask, parityEdgeTester: HalfEdgeTestObject | undefined, parityMask: HalfEdgeMask): HalfEdge[] {\r\n const faces: HalfEdge[] = [];\r\n if (seedEdge.isMaskSet(visitMask)) return faces; // empty\r\n\r\n const allMasks = parityMask | visitMask;\r\n const stack: HalfEdge[] = [];\r\n // arbitrarily call the seed face exterior ... others will alternate as visited.\r\n HalfEdgeGraphSearch.pushAndMaskAllNodesInFace(seedEdge, allMasks, stack, faces); // Start with exterior as mask\r\n while (stack.length > 0) {\r\n const p = stack.pop()!;\r\n const mate = p.edgeMate;\r\n if (!mate)\r\n continue;\r\n if (!mate.isMaskSet(visitMask)) {\r\n let newState = p.isMaskSet(parityMask);\r\n if (!parityEdgeTester || parityEdgeTester.testEdge(p))\r\n newState = !newState;\r\n HalfEdgeGraphSearch.pushAndMaskAllNodesInFace(mate, newState ? allMasks : visitMask, stack, faces);\r\n }\r\n }\r\n return faces;\r\n }\r\n /**\r\n * * Search the given faces for the one with the minimum area.\r\n * * If the mask in that face is OFF, toggle it on (all half edges of) all the faces.\r\n * * In a properly merged planar subdivision there should be only one true negative area face per component.\r\n * @param graph parent graph\r\n * @param parityMask mask which was previously set with alternating parity, but with an arbitrary start face.\r\n * @param faces array of faces to search.\r\n */\r\n private static correctParityInSingleComponent(_graph: HalfEdgeGraph, mask: HalfEdgeMask, faces: HalfEdge[]) {\r\n const exteriorHalfEdge = HalfEdgeGraphSearch.findMinimumAreaFace(faces);\r\n if (!exteriorHalfEdge) {\r\n } else if (exteriorHalfEdge.isMaskSet(mask)) {\r\n // all should be well .. nothing to do.\r\n } else {\r\n // TOGGLE around the face (assuming all are consistent with the seed)\r\n for (const faceSeed of faces) {\r\n if (faceSeed.isMaskSet(mask)) {\r\n faceSeed.clearMaskAroundFace(mask);\r\n } else {\r\n faceSeed.setMaskAroundFace(mask);\r\n }\r\n }\r\n }\r\n }\r\n /** Apply correctParityInSingleComponent to each array in components. (Quick exit if mask in NULL_MASK) */\r\n private static correctParityInComponentArrays(graph: HalfEdgeGraph, mask: HalfEdgeMask, components: HalfEdge[][]) {\r\n if (mask === HalfEdgeMask.NULL_MASK)\r\n return;\r\n for (const facesInComponent of components)\r\n HalfEdgeGraphSearch.correctParityInSingleComponent(graph, mask, facesInComponent);\r\n }\r\n /**\r\n * Collect arrays gathering faces by connected component.\r\n * @param graph graph to inspect\r\n * @param parityEdgeTester (optional) function to test of an edge is a parity change.\r\n * @param parityMask (optional, along with boundaryTestFunction) mask to apply indicating parity. If this is Mask.NULL_MASK, there is no record of parity.\r\n */\r\n public static collectConnectedComponentsWithExteriorParityMasks(graph: HalfEdgeGraph, parityEdgeTester: HalfEdgeTestObject | undefined, parityMask: HalfEdgeMask = HalfEdgeMask.NULL_MASK): HalfEdge[][] {\r\n const components = [];\r\n const visitMask = HalfEdgeMask.VISITED;\r\n const allMasks = parityMask | visitMask;\r\n graph.clearMask(allMasks);\r\n for (const faceSeed of graph.allHalfEdges) {\r\n if (!faceSeed.isMaskSet(HalfEdgeMask.VISITED)) {\r\n const newFaces = HalfEdgeGraphSearch.parityFloodFromSeed(faceSeed, visitMask, parityEdgeTester, parityMask);\r\n components.push(newFaces);\r\n }\r\n }\r\n HalfEdgeGraphSearch.correctParityInComponentArrays(graph, parityMask, components);\r\n return components;\r\n }\r\n /**\r\n * Test if (x,y) is inside (1), on an edge (0) or outside (-1) a face.\r\n * @param seedNode any node on the face loop\r\n * @param x x coordinate of test point.\r\n * @param y y coordinate of test point.\r\n */\r\n public static pointInOrOnFaceXY(seedNode: HalfEdge, x: number, y: number): number | undefined {\r\n const context = new XYParitySearchContext(x, y);\r\n // walk around looking for an accepted node to start the search (seedNode is usually ok!)\r\n let nodeA = seedNode;\r\n let nodeB = seedNode.faceSuccessor;\r\n for (; ; nodeA = nodeB) {\r\n if (context.tryStartEdge(nodeA.x, nodeA.y, nodeB.x, nodeB.y))\r\n break;\r\n if (nodeB === seedNode) {\r\n // umm.. the face is all on the x axis?\r\n return context.classifyCounts();\r\n }\r\n nodeB = nodeA.faceSuccessor;\r\n }\r\n\r\n // nodeB is the real start node for search ... emit ends of each edge around the face,\r\n // stopping after emitting nodeB as an edge end.\r\n let node = nodeB.faceSuccessor;\r\n for (; ;) {\r\n if (!context.advance(node.x, node.y)) {\r\n return context.classifyCounts();\r\n }\r\n if (node === nodeB)\r\n break;\r\n node = node.faceSuccessor;\r\n }\r\n return context.classifyCounts();\r\n }\r\n /**\r\n * Announce nodes that are \"extended face boundary\" by conditions (usually mask of node and mate) in test functions.\r\n * * After each node, the next candidate in reached by looking \"around the head vertex loop\" for the next boundary.\r\n * * \"Around the vertex\" from nodeA means\r\n * * First look at nodeA.faceSuccessor;\r\n * * Then look at vertexPredecessor around that vertex loop.\r\n * * Each accepted node is passed to announceNode, and marked with the visit mask.\r\n * * The counter of the announceEdge function is zero for the first edge, then increases with each edge.\r\n * @param seed start node.\r\n * @param isBoundaryEdge\r\n * @param announceEdge\r\n */\r\n public static collectExtendedBoundaryLoopFromSeed(seed: HalfEdge, visitMask: HalfEdgeMask, isBoundaryEdge: HalfEdgeToBooleanFunction,\r\n announceEdge: (edge: HalfEdge, counter: number) => void) {\r\n let counter = 0;\r\n while (!seed.getMask(visitMask) && isBoundaryEdge(seed)) {\r\n announceEdge(seed, counter++);\r\n seed.setMask(visitMask);\r\n const vertexBase = seed.faceSuccessor;\r\n let candidateAroundVertex = vertexBase;\r\n for (; ;) {\r\n if (candidateAroundVertex.getMask(visitMask))\r\n return;\r\n if (isBoundaryEdge(candidateAroundVertex)) {\r\n seed = candidateAroundVertex;\r\n break;\r\n }\r\n candidateAroundVertex = candidateAroundVertex.vertexPredecessor;\r\n if (candidateAroundVertex === vertexBase)\r\n break;\r\n }\r\n }\r\n }\r\n /**\r\n * Collect arrays of nodes \"around the boundary\" of a graph with extraneous (non-boundary) edges.\r\n * * The \"boundary\" is nodes that do NOT have the exterior mask, but whose mates DO have the exterior mask.\r\n * * After each node, the next candidate in reached by looking \"around the head vertex loop\" for the next boundary.\r\n * * \"Around the vertex\" from nodeA means\r\n * * First look at nodeA.faceSuccessor;\r\n * * Then look at vertexPredecessor around that vertex loop.\r\n * * Each accepted node is passed to announceNode, and marked with the visit mask.\r\n * @param seed start node.\r\n * @param isBoundaryNode\r\n * @param announceNode\r\n */\r\n public static collectExtendedBoundaryLoopsInGraph(graph: HalfEdgeGraph, exteriorMask: HalfEdgeMask): HalfEdge[][] {\r\n const loops: HalfEdge[][] = [];\r\n const visitMask = graph.grabMask(true);\r\n const isBoundaryEdge = (edge: HalfEdge): boolean => {\r\n return edge.getMask(exteriorMask) === 0 && edge.edgeMate.getMask(exteriorMask) !== 0;\r\n };\r\n const announceEdgeInBoundary = (edge: HalfEdge, counter: number) => {\r\n if (counter === 0)\r\n loops.push([]);\r\n loops[loops.length - 1].push(edge);\r\n };\r\n for (const seed of graph.allHalfEdges) {\r\n this.collectExtendedBoundaryLoopFromSeed(seed, visitMask, isBoundaryEdge, announceEdgeInBoundary);\r\n }\r\n graph.dropMask(visitMask);\r\n return loops;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HalfEdgeGraphValidation.js","sourceRoot":"","sources":["../../../src/topology/HalfEdgeGraphValidation.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAQ/F,oCAAoC;AACpC;;GAEG;AACH,MAAM,OAAO,wBAAwB;IAAr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CAAC,OAAO,CAAC,IAAI,CAAC;gBACrD,OAAO,KAAK,CAAC;SAChB;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Topology\n */\n// cspell:word FSFP\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask } from \"./Graph\";\n\n// Search services for HalfEdgeGraph\n/** HalfEdgePointerInspector has methods to check HalfEdge objects for pointer errors.\n * * For a one-step test of the whole graph,\n */\nexport class HalfEdgePointerInspector {\n public numUndefinedEdgeMate: number = 0;\n public numUndefinedFS: number = 0;\n public numUndefinedFP: number = 0;\n public numFSFPError: number = 0;\n public numMatePairError: number = 0;\n public numTested: number = 0;\n public numWithMatchedEdgeMate: number = 0;\n /** Clear all counts */\n public clearCounts() {\n this.numUndefinedEdgeMate = 0;\n this.numUndefinedFP = 0;\n this.numUndefinedFS = 0;\n this.numFSFPError = 0;\n this.numMatePairError = 0;\n this.numWithMatchedEdgeMate = 0;\n this.numTested = 0;\n }\n /** Inspect a single half edge. Increment counters according to the half edge's pointers. */\n public inspectHalfEdge(he: HalfEdge) {\n this.numTested++;\n if (he.facePredecessor === undefined) this.numUndefinedFP++;\n else if (he.facePredecessor.faceSuccessor !== he) this.numFSFPError++;\n\n if (he.faceSuccessor === undefined) this.numUndefinedFS++;\n else if (he.faceSuccessor.facePredecessor !== he) this.numFSFPError++;\n\n if (he.edgeMate === undefined) this.numUndefinedEdgeMate++;\n else if (he.edgeMate.edgeMate === he) this.numWithMatchedEdgeMate++;\n else this.numMatePairError++;\n }\n /** Return true if all pointer pairings are correct for a complete half edge graph:\n * * For each he: `he.edgeMate.edgeMate === he`\n * * For each he: `he.faceSuccessor.facePredecessor !== he`\n * * For each he: `he.facePredecessor.faceSuccessor !== he`\n */\n public get isValidClosedHalfEdgeGraph(): boolean {\n return this.numWithMatchedEdgeMate === this.numTested\n && this.numUndefinedFS === 0\n && this.numUndefinedFP === 0\n && this.numFSFPError === 0\n && this.numMatePairError === 0;\n }\n /** Return true if all counts are correct for a half edge graph that has complete pairings:\n * * For each he: `he.edgeMate.edgeMate === he`\n * * For each he: `he.faceSuccessor.facePredecessor !== he`\n * * For each he: `he.facePredecessor.faceSuccessor !== he`\n */\n public get isValidHalfEdgeGraphAllowRaggedBoundary(): boolean {\n return this.numWithMatchedEdgeMate + this.numUndefinedEdgeMate === this.numTested\n && this.numUndefinedFS === 0\n && this.numUndefinedFP === 0\n && this.numFSFPError === 0\n && this.numMatePairError === 0;\n }\n /** inspect all half edges of graph.\n * All pointer counts are left in member vars for later inspection.\n */\n public inspectHalfEdges(graph: HalfEdgeGraph) {\n this.clearCounts();\n for (const he of graph.allHalfEdges) this.inspectHalfEdge(he);\n\n }\n /** Inspect a graph's pointer properties.\n * @param expectAllMates [in] true for \"complete\" graph with\n * @returns true if all pointers are valid\n */\n public static inspectGraph(graph: HalfEdgeGraph, expectAllMates: boolean): boolean {\n const inspector = new HalfEdgePointerInspector();\n inspector.inspectHalfEdges(graph);\n if (expectAllMates) return inspector.isValidClosedHalfEdgeGraph;\n return inspector.isValidHalfEdgeGraphAllowRaggedBoundary;\n }\n}\n/** static methods to inspect mask consistency properties in HalfEdgeGraph. */\nexport class HalfEdgeMaskValidation {\n /**\n * Test if a mask is used consistently around faces.\n * * At the low level, there is no actual traversal around faces. It is only necessary to verify that the mask matches for each HalfEdge and its faceSuccessor.\n * @returns Return true if mask is \"all or nothing around all faces\"\n *\n */\n public static isMaskConsistentAroundAllFaces(graph: HalfEdgeGraph, mask: HalfEdgeMask): boolean {\n for (const he of graph.allHalfEdges) {\n if (he.faceSuccessor.getMask(mask) !== he.getMask(mask))\n return false;\n }\n return true;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"HalfEdgeGraphValidation.js","sourceRoot":"","sources":["../../../src/topology/Hal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EAAE,IAAI,KAAK,CAAC,YAAY,EAAE;YACnC,IAAI,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;gBACrD,OAAO,KAAK,CAAC;SAChB;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Topology\r\n */\r\n// cspell:word FSFP\r\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask } from \"./Graph\";\r\n\r\n// Search services for HalfEdgeGraph\r\n/** HalfEdgePointerInspector has methods to check HalfEdge objects for pointer errors.\r\n * * For a one-step test of the whole graph,\r\n */\r\nexport class HalfEdgePointerInspector {\r\n public numUndefinedEdgeMate: number = 0;\r\n public numUndefinedFS: number = 0;\r\n public numUndefinedFP: number = 0;\r\n public numFSFPError: number = 0;\r\n public numMatePairError: number = 0;\r\n public numTested: number = 0;\r\n public numWithMatchedEdgeMate: number = 0;\r\n /** Clear all counts */\r\n public clearCounts() {\r\n this.numUndefinedEdgeMate = 0;\r\n this.numUndefinedFP = 0;\r\n this.numUndefinedFS = 0;\r\n this.numFSFPError = 0;\r\n this.numMatePairError = 0;\r\n this.numWithMatchedEdgeMate = 0;\r\n this.numTested = 0;\r\n }\r\n /** Inspect a single half edge. Increment counters according to the half edge's pointers. */\r\n public inspectHalfEdge(he: HalfEdge) {\r\n this.numTested++;\r\n if (he.facePredecessor === undefined) this.numUndefinedFP++;\r\n else if (he.facePredecessor.faceSuccessor !== he) this.numFSFPError++;\r\n\r\n if (he.faceSuccessor === undefined) this.numUndefinedFS++;\r\n else if (he.faceSuccessor.facePredecessor !== he) this.numFSFPError++;\r\n\r\n if (he.edgeMate === undefined) this.numUndefinedEdgeMate++;\r\n else if (he.edgeMate.edgeMate === he) this.numWithMatchedEdgeMate++;\r\n else this.numMatePairError++;\r\n }\r\n /** Return true if all pointer pairings are correct for a complete half edge graph:\r\n * * For each he: `he.edgeMate.edgeMate === he`\r\n * * For each he: `he.faceSuccessor.facePredecessor !== he`\r\n * * For each he: `he.facePredecessor.faceSuccessor !== he`\r\n */\r\n public get isValidClosedHalfEdgeGraph(): boolean {\r\n return this.numWithMatchedEdgeMate === this.numTested\r\n && this.numUndefinedFS === 0\r\n && this.numUndefinedFP === 0\r\n && this.numFSFPError === 0\r\n && this.numMatePairError === 0;\r\n }\r\n /** Return true if all counts are correct for a half edge graph that has complete pairings:\r\n * * For each he: `he.edgeMate.edgeMate === he`\r\n * * For each he: `he.faceSuccessor.facePredecessor !== he`\r\n * * For each he: `he.facePredecessor.faceSuccessor !== he`\r\n */\r\n public get isValidHalfEdgeGraphAllowRaggedBoundary(): boolean {\r\n return this.numWithMatchedEdgeMate + this.numUndefinedEdgeMate === this.numTested\r\n && this.numUndefinedFS === 0\r\n && this.numUndefinedFP === 0\r\n && this.numFSFPError === 0\r\n && this.numMatePairError === 0;\r\n }\r\n /** inspect all half edges of graph.\r\n * All pointer counts are left in member vars for later inspection.\r\n */\r\n public inspectHalfEdges(graph: HalfEdgeGraph) {\r\n this.clearCounts();\r\n for (const he of graph.allHalfEdges) this.inspectHalfEdge(he);\r\n\r\n }\r\n /** Inspect a graph's pointer properties.\r\n * @param expectAllMates [in] true for \"complete\" graph with\r\n * @returns true if all pointers are valid\r\n */\r\n public static inspectGraph(graph: HalfEdgeGraph, expectAllMates: boolean): boolean {\r\n const inspector = new HalfEdgePointerInspector();\r\n inspector.inspectHalfEdges(graph);\r\n if (expectAllMates) return inspector.isValidClosedHalfEdgeGraph;\r\n return inspector.isValidHalfEdgeGraphAllowRaggedBoundary;\r\n }\r\n}\r\n/** static methods to inspect mask consistency properties in HalfEdgeGraph. */\r\nexport class HalfEdgeMaskValidation {\r\n /**\r\n * Test if a mask is used consistently around faces.\r\n * * At the low level, there is no actual traversal around faces. It is only necessary to verify that the mask matches for each HalfEdge and its faceSuccessor.\r\n * @returns Return true if mask is \"all or nothing around all faces\"\r\n *\r\n */\r\n public static isMaskConsistentAroundAllFaces(graph: HalfEdgeGraph, mask: HalfEdgeMask): boolean {\r\n for (const he of graph.allHalfEdges) {\r\n if (he.faceSuccessor.getMask(mask) !== he.getMask(mask))\r\n return false;\r\n }\r\n return true;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HalfEdgePointInGraphSearch.js","sourceRoot":"","sources":["../../../src/topology/HalfEdgePointInGraphSearch.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAW,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAGlE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,yDAAyD;AACzD,MAAM,CAAN,IAAY,iBAOX;AAPD,WAAY,iBAAiB;IAC3B,mEAAS,CAAA;IACT,mFAAiB,CAAA;IACjB,+EAAe,CAAA;IACf,qEAAU,CAAA;IACV,+EAAe,CAAA;IACf,6EAAc,CAAA;AAChB,CAAC,EAPW,iBAAiB,KAAjB,iBAAiB,QAO5B;AACD,wDAAwD;AAExD,MAAM,OAAO,kBAAkB;IAE7B,YAAoB,GAAW;QAC7B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IACM,MAAM,CAAC,MAAM,CAAC,MAAc,QAAQ,CAAC,mBAAmB;QAC7D,OAAO,IAAI,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IACO,KAAK;QACX,OAAO,sBAAsB,CAAC,MAAM,EAAE,CAAC;IACzC,CAAC;IACD,8BAA8B;IAC9B,uCAAuC;IAChC,aAAa,CACl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AY,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACtC,OAAO,gBAAgB,IAAI,IAAI,CAAC,IAAI,CAAC;IACvC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Topology\n */\n\nimport { Geometry } from \"../Geometry\";\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\nimport { Ray3d } from \"../geometry3d/Ray3d\";\nimport { HalfEdge } from \"./Graph\";\nimport { NodeXYZUV } from \"./HalfEdgeNodeXYZUV\";\nimport { HalfEdgePositionDetail } from \"./HalfEdgePositionDetail\";\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum RayClassification {\n RC_NoHits,\n RC_TargetOnVertex,\n RC_TargetOnEdge,\n RC_Bracket,\n RC_TargetBefore,\n RC_TargetAfter,\n}\n/* eslint-enable @typescript-eslint/naming-convention */\n\nexport class PointSearchContext {\n private _tol: number;\n private constructor(tol: number) {\n this._tol = tol;\n }\n public static create(tol: number = Geometry.smallMetricDistance) {\n return new PointSearchContext(tol);\n }\n private panic(): HalfEdgePositionDetail {\n return HalfEdgePositionDetail.create();\n }\n // From given edge start point\n // The edgeHit is reused as the result.\n public reAimFromEdge(\n edgeHit: HalfEdgePositionDetail,\n ray: Ray3d,\n targetDistance: number): HalfEdgePositionDetail {\n const nodeA = edgeHit.node!;\n const dataA = NodeXYZUV.createNodeAndRayOrigin(nodeA, ray);\n const dataB = NodeXYZUV.createNodeAndRayOrigin(nodeA.edgeMate, ray);\n const sideA = -dataA.classifyV(0.0, this._tol);\n const sideB = -dataB.classifyV(0.0, this._tol);\n let result;\n if (sideA * sideB < 0) {\n // Simple crossing -- just aim into a face\n if (sideA > 0) {\n result = edgeHit.resetAsFace(dataA.node);\n } else {\n result = edgeHit.resetAsFace(dataB.node);\n }\n } else if (sideA === 0 || sideB === 0) {\n // The usual case is both 0 i.e. ray is clearly along the edge.\n\n const alongA = dataA.classifyU(targetDistance, this._tol);\n const alongB = dataB.classifyU(targetDistance, this._tol);\n if (alongA === 0 && sideA === 0) {\n result = edgeHit.resetAsVertex(dataA.node);\n result.setITag(1);\n } else if (alongB === 0 && sideB === 0) {\n result = edgeHit.resetAsVertex(dataB.node);\n result.setITag(1);\n } else if (alongA * alongB < 0) {\n // target is within edge\n // (.. This is written for the case where both sideA and sideB are zero.\n // If only one is zero, this computes a close edge point but the strong \"on\" conclusion might be wrong)\n\n const edgeFraction = (targetDistance - dataA.u) / (dataB.u - dataA.u);\n result = edgeHit.resetAtEdgeAndFraction(dataA.node, edgeFraction);\n result.setITag(1);\n } else if (alongA < 0 && alongB < 0) {\n // target is beyond the edge -- move towards it.\n if (dataA.u > dataB.u)\n result = edgeHit.resetAsVertex(dataA.node);\n else\n result = edgeHit.resetAsVertex(dataB.node);\n } else {\n // This shouldn't happen -- maybe as if the initial edge point was not within the edge???\n if (Math.abs(dataA.u) < this._tol\n && Math.abs(dataA.v) < this._tol\n ) {\n result = edgeHit.resetAsVertex(dataA.node); // , dataA);\n } else if (Math.abs(dataB.u) < this._tol\n && Math.abs(dataB.v) < this._tol\n ) {\n result = edgeHit.resetAsVertex(dataB.node);\n } else {\n edgeHit.resetAsUnknown();\n result = this.panic();\n }\n }\n } else {\n // Both vertices are to same side of the line. This can't happen for edge point between nodes.\n edgeHit.resetAsUnknown();\n result = this.panic();\n }\n return result;\n }\n\n // From given edge start point, pick vertex or edge side for proceeding along ray.\n // RAY IS ASSUMED TO START AT THE VERTEX PRECISELY !!!!\n public reAimFromVertex(\n searchBase: HalfEdgePositionDetail,\n ray: Ray3d,\n targetDistance: number): HalfEdgePositionDetail {\n const vertexNode = searchBase.node;\n let result;\n let outboundEdge = vertexNode!;\n do {\n // DPoint3d xyzBase;\n // vu_getDPoint3d(& xyzBase, outboundEdge);\n const data0 = NodeXYZUV.createNodeAndRayOrigin(outboundEdge.faceSuccessor, ray);\n const data1 = NodeXYZUV.createNodeAndRayOrigin(outboundEdge.facePredecessor, ray);\n const u0 = data0.u;\n // double u1 = data1.GetU ();\n const v0 = data0.v;\n const v1 = data1.v;\n if (Math.abs(v0) < this._tol) {\n if (Math.abs(u0 - targetDistance) < this._tol) {\n // Direct hit at far end\n result = searchBase.resetAsVertex(data0.node);\n result.setITag(1);\n return result;\n } else if (u0 > targetDistance) {\n // Direct hig within edge\n const edgeFraction = targetDistance / u0;\n result = searchBase.resetAtEdgeAndFraction(outboundEdge, edgeFraction);\n return result;\n } else if (Math.abs(u0) <= this._tol) {\n // Unexpected direct hit on the base of the search, but call it a hit....\n result = searchBase.resetAsVertex(outboundEdge);\n result.setITag(1);\n return result;\n } else if (u0 > this._tol) {\n // Advance to vertex ...\n // double edgeFraction = targetDistance / u0;\n result = searchBase.resetAsVertex(data0.node);\n return result;\n } else {\n // Search direction is exactly opposite this edge.\n // See if the other side of the sector is turned even beyond that ...\n if (v1 > this._tol) {\n result = searchBase.resetAsFace(outboundEdge, outboundEdge);\n return result;\n }\n }\n } else if (v0 < -this._tol) {\n if (v1 > this._tol) {\n // The usual simple entry into an angle < 180\n result = searchBase.resetAsFace(outboundEdge, outboundEdge);\n return result;\n }\n }\n // NEEDS WORK: angle >= 180 cases !!!!\n outboundEdge = outboundEdge.vertexSuccessor;\n } while (outboundEdge !== vertexNode);\n return this.panic();\n }\n\n // Visit all edges around face.\n // reset lastBefore and firstAfter describing progress towards target distance on ray.\n public reAimAroundFace(\n faceNode: HalfEdge,\n ray: Ray3d,\n targetDistance: number, // !< distance to target point\n lastBefore: HalfEdgePositionDetail, // CALLER CREATED -- reset as first hit on negative side of ray.\n firstAfter: HalfEdgePositionDetail): RayClassification { // ! CALLER CREATED -- reset as first hit on positive side of ray.\n\n lastBefore.resetAsUndefinedWithTag(-Number.MAX_VALUE);\n firstAfter.resetAsUndefinedWithTag(Number.MAX_VALUE);\n const data0 = NodeXYZUV.createNodeAndRayOrigin(faceNode, ray);\n let data1;\n let node0 = faceNode;\n do {\n const node1 = node0.faceSuccessor;\n data1 = NodeXYZUV.createNodeAndRayOrigin(node1, ray, data1);\n const u0 = data0.u;\n const u1 = data1.u;\n const v0 = data0.v;\n const v1 = data1.v;\n if (Math.abs(v1) < this._tol) {\n // Vertex hit ...\n const vertexHit = HalfEdgePositionDetail.createVertex(node1);\n vertexHit.setDTag(u1);\n if (Math.abs(u1 - targetDistance) < this._tol) {\n firstAfter.setFrom(vertexHit);\n lastBefore.setFrom(vertexHit);\n return RayClassification.RC_TargetOnVertex;\n }\n if (u1 > targetDistance && u1 < firstAfter.getDTag()!)\n firstAfter.setFrom(vertexHit);\n if (u1 < targetDistance && u1 > lastBefore.getDTag()!)\n lastBefore.setFrom(vertexHit);\n } else if (v0 * v1 < 0.0) {\n // Edge Crossing ...\n const edgeFraction = - v0 / (v1 - v0);\n const uEdge = Geometry.interpolate(u0, edgeFraction, u1);\n const edgeHit = HalfEdgePositionDetail.createEdgeAtFraction(data0.node, edgeFraction);\n edgeHit.setDTag(uEdge);\n if (Math.abs(uEdge - targetDistance) <= this._tol) {\n firstAfter.setFrom(edgeHit);\n lastBefore.setFrom(edgeHit);\n return RayClassification.RC_TargetOnEdge;\n }\n if (uEdge > targetDistance && uEdge < firstAfter.getDTag()!) {\n firstAfter.setFrom(edgeHit);\n firstAfter.setITag(v0 > 0.0 ? -1 : 1);\n }\n if (uEdge < targetDistance && uEdge > lastBefore.getDTag()!) {\n lastBefore.setFrom(edgeHit);\n lastBefore.setDTag(uEdge);\n }\n }\n data0.setFrom(data1);\n node0 = node0.faceSuccessor;\n } while (node0 !== faceNode);\n\n const afterTag = firstAfter.getITag();\n firstAfter.setITag(0);\n lastBefore.setITag(0);\n if (lastBefore.isUnclassified) {\n if (firstAfter.isUnclassified)\n return RayClassification.RC_NoHits;\n return RayClassification.RC_TargetBefore;\n }\n if (firstAfter.isUnclassified\n || (firstAfter.isEdge && afterTag && afterTag < 0)) {\n return RayClassification.RC_TargetAfter;\n } else {\n return RayClassification.RC_Bracket;\n }\n }\n\n // Return false if target is reached !!!!\n /**\n * Set (replace contents) ray with\n * * `origin` at start\n * * `direction` is unit vector from start towards target\n * * `a` is distance from start to target.\n * @param start existing position\n * @param target target xy coordinates\n * @param ray ray to update\n */\n public setSearchRay(start: HalfEdgePositionDetail, target: Point3d, ray: Ray3d): boolean {\n ray.origin.setFromPoint3d(start);\n Vector3d.createStartEnd(ray.origin, target, ray.direction);\n ray.direction.z = 0.0;\n const distanceToTarget = ray.direction.magnitudeXY();\n ray.a = ray.direction.magnitude();\n ray.direction.scaleInPlace(1 / ray.a);\n return distanceToTarget >= this._tol;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"HalfEdgePointInGraphSearch.js","sourceRoot":"","sources":["../../../src/topology/HalfEdgePointInGraphSearch.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAW,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAGlE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,yDAAyD;AACzD,MAAM,CAAN,IAAY,iBAOX;AAPD,WAAY,iBAAiB;IAC3B,mEAAS,CAAA;IACT,mFAAiB,CAAA;IACjB,+EAAe,CAAA;IACf,qEAAU,CAAA;IACV,+EAAe,CAAA;IACf,6EAAc,CAAA;AAChB,CAAC,EAPW,iBAAiB,KAAjB,iBAAiB,QAO5B;AACD,wDAAwD;AAExD,MAAM,OAAO,kBAAkB;IAE7B,YAAoB,GAAW;QAC7B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IACM,MAAM,CAAC,MAAM,CAAC,MAAc,QAAQ,CAAC,mBAAmB;QAC7D,OAAO,IAAI,kBAAkB,CAAC,G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AAC,SAAS,CAAC,WAAW,EAAE,CAAC;QACrD,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;QAClC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACtC,OAAO,gBAAgB,IAAI,IAAI,CAAC,IAAI,CAAC;IACvC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Topology\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { HalfEdge } from \"./Graph\";\r\nimport { NodeXYZUV } from \"./HalfEdgeNodeXYZUV\";\r\nimport { HalfEdgePositionDetail } from \"./HalfEdgePositionDetail\";\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\nexport enum RayClassification {\r\n RC_NoHits,\r\n RC_TargetOnVertex,\r\n RC_TargetOnEdge,\r\n RC_Bracket,\r\n RC_TargetBefore,\r\n RC_TargetAfter,\r\n}\r\n/* eslint-enable @typescript-eslint/naming-convention */\r\n\r\nexport class PointSearchContext {\r\n private _tol: number;\r\n private constructor(tol: number) {\r\n this._tol = tol;\r\n }\r\n public static create(tol: number = Geometry.smallMetricDistance) {\r\n return new PointSearchContext(tol);\r\n }\r\n private panic(): HalfEdgePositionDetail {\r\n return HalfEdgePositionDetail.create();\r\n }\r\n // From given edge start point\r\n // The edgeHit is reused as the result.\r\n public reAimFromEdge(\r\n edgeHit: HalfEdgePositionDetail,\r\n ray: Ray3d,\r\n targetDistance: number): HalfEdgePositionDetail {\r\n const nodeA = edgeHit.node!;\r\n const dataA = NodeXYZUV.createNodeAndRayOrigin(nodeA, ray);\r\n const dataB = NodeXYZUV.createNodeAndRayOrigin(nodeA.edgeMate, ray);\r\n const sideA = -dataA.classifyV(0.0, this._tol);\r\n const sideB = -dataB.classifyV(0.0, this._tol);\r\n let result;\r\n if (sideA * sideB < 0) {\r\n // Simple crossing -- just aim into a face\r\n if (sideA > 0) {\r\n result = edgeHit.resetAsFace(dataA.node);\r\n } else {\r\n result = edgeHit.resetAsFace(dataB.node);\r\n }\r\n } else if (sideA === 0 || sideB === 0) {\r\n // The usual case is both 0 i.e. ray is clearly along the edge.\r\n\r\n const alongA = dataA.classifyU(targetDistance, this._tol);\r\n const alongB = dataB.classifyU(targetDistance, this._tol);\r\n if (alongA === 0 && sideA === 0) {\r\n result = edgeHit.resetAsVertex(dataA.node);\r\n result.setITag(1);\r\n } else if (alongB === 0 && sideB === 0) {\r\n result = edgeHit.resetAsVertex(dataB.node);\r\n result.setITag(1);\r\n } else if (alongA * alongB < 0) {\r\n // target is within edge\r\n // (.. This is written for the case where both sideA and sideB are zero.\r\n // If only one is zero, this computes a close edge point but the strong \"on\" conclusion might be wrong)\r\n\r\n const edgeFraction = (targetDistance - dataA.u) / (dataB.u - dataA.u);\r\n result = edgeHit.resetAtEdgeAndFraction(dataA.node, edgeFraction);\r\n result.setITag(1);\r\n } else if (alongA < 0 && alongB < 0) {\r\n // target is beyond the edge -- move towards it.\r\n if (dataA.u > dataB.u)\r\n result = edgeHit.resetAsVertex(dataA.node);\r\n else\r\n result = edgeHit.resetAsVertex(dataB.node);\r\n } else {\r\n // This shouldn't happen -- maybe as if the initial edge point was not within the edge???\r\n if (Math.abs(dataA.u) < this._tol\r\n && Math.abs(dataA.v) < this._tol\r\n ) {\r\n result = edgeHit.resetAsVertex(dataA.node); // , dataA);\r\n } else if (Math.abs(dataB.u) < this._tol\r\n && Math.abs(dataB.v) < this._tol\r\n ) {\r\n result = edgeHit.resetAsVertex(dataB.node);\r\n } else {\r\n edgeHit.resetAsUnknown();\r\n result = this.panic();\r\n }\r\n }\r\n } else {\r\n // Both vertices are to same side of the line. This can't happen for edge point between nodes.\r\n edgeHit.resetAsUnknown();\r\n result = this.panic();\r\n }\r\n return result;\r\n }\r\n\r\n // From given edge start point, pick vertex or edge side for proceeding along ray.\r\n // RAY IS ASSUMED TO START AT THE VERTEX PRECISELY !!!!\r\n public reAimFromVertex(\r\n searchBase: HalfEdgePositionDetail,\r\n ray: Ray3d,\r\n targetDistance: number): HalfEdgePositionDetail {\r\n const vertexNode = searchBase.node;\r\n let result;\r\n let outboundEdge = vertexNode!;\r\n do {\r\n // DPoint3d xyzBase;\r\n // vu_getDPoint3d(& xyzBase, outboundEdge);\r\n const data0 = NodeXYZUV.createNodeAndRayOrigin(outboundEdge.faceSuccessor, ray);\r\n const data1 = NodeXYZUV.createNodeAndRayOrigin(outboundEdge.facePredecessor, ray);\r\n const u0 = data0.u;\r\n // double u1 = data1.GetU ();\r\n const v0 = data0.v;\r\n const v1 = data1.v;\r\n if (Math.abs(v0) < this._tol) {\r\n if (Math.abs(u0 - targetDistance) < this._tol) {\r\n // Direct hit at far end\r\n result = searchBase.resetAsVertex(data0.node);\r\n result.setITag(1);\r\n return result;\r\n } else if (u0 > targetDistance) {\r\n // Direct hig within edge\r\n const edgeFraction = targetDistance / u0;\r\n result = searchBase.resetAtEdgeAndFraction(outboundEdge, edgeFraction);\r\n return result;\r\n } else if (Math.abs(u0) <= this._tol) {\r\n // Unexpected direct hit on the base of the search, but call it a hit....\r\n result = searchBase.resetAsVertex(outboundEdge);\r\n result.setITag(1);\r\n return result;\r\n } else if (u0 > this._tol) {\r\n // Advance to vertex ...\r\n // double edgeFraction = targetDistance / u0;\r\n result = searchBase.resetAsVertex(data0.node);\r\n return result;\r\n } else {\r\n // Search direction is exactly opposite this edge.\r\n // See if the other side of the sector is turned even beyond that ...\r\n if (v1 > this._tol) {\r\n result = searchBase.resetAsFace(outboundEdge, outboundEdge);\r\n return result;\r\n }\r\n }\r\n } else if (v0 < -this._tol) {\r\n if (v1 > this._tol) {\r\n // The usual simple entry into an angle < 180\r\n result = searchBase.resetAsFace(outboundEdge, outboundEdge);\r\n return result;\r\n }\r\n }\r\n // NEEDS WORK: angle >= 180 cases !!!!\r\n outboundEdge = outboundEdge.vertexSuccessor;\r\n } while (outboundEdge !== vertexNode);\r\n return this.panic();\r\n }\r\n\r\n // Visit all edges around face.\r\n // reset lastBefore and firstAfter describing progress towards target distance on ray.\r\n public reAimAroundFace(\r\n faceNode: HalfEdge,\r\n ray: Ray3d,\r\n targetDistance: number, // !< distance to target point\r\n lastBefore: HalfEdgePositionDetail, // CALLER CREATED -- reset as first hit on negative side of ray.\r\n firstAfter: HalfEdgePositionDetail): RayClassification { // ! CALLER CREATED -- reset as first hit on positive side of ray.\r\n\r\n lastBefore.resetAsUndefinedWithTag(-Number.MAX_VALUE);\r\n firstAfter.resetAsUndefinedWithTag(Number.MAX_VALUE);\r\n const data0 = NodeXYZUV.createNodeAndRayOrigin(faceNode, ray);\r\n let data1;\r\n let node0 = faceNode;\r\n do {\r\n const node1 = node0.faceSuccessor;\r\n data1 = NodeXYZUV.createNodeAndRayOrigin(node1, ray, data1);\r\n const u0 = data0.u;\r\n const u1 = data1.u;\r\n const v0 = data0.v;\r\n const v1 = data1.v;\r\n if (Math.abs(v1) < this._tol) {\r\n // Vertex hit ...\r\n const vertexHit = HalfEdgePositionDetail.createVertex(node1);\r\n vertexHit.setDTag(u1);\r\n if (Math.abs(u1 - targetDistance) < this._tol) {\r\n firstAfter.setFrom(vertexHit);\r\n lastBefore.setFrom(vertexHit);\r\n return RayClassification.RC_TargetOnVertex;\r\n }\r\n if (u1 > targetDistance && u1 < firstAfter.getDTag()!)\r\n firstAfter.setFrom(vertexHit);\r\n if (u1 < targetDistance && u1 > lastBefore.getDTag()!)\r\n lastBefore.setFrom(vertexHit);\r\n } else if (v0 * v1 < 0.0) {\r\n // Edge Crossing ...\r\n const edgeFraction = - v0 / (v1 - v0);\r\n const uEdge = Geometry.interpolate(u0, edgeFraction, u1);\r\n const edgeHit = HalfEdgePositionDetail.createEdgeAtFraction(data0.node, edgeFraction);\r\n edgeHit.setDTag(uEdge);\r\n if (Math.abs(uEdge - targetDistance) <= this._tol) {\r\n firstAfter.setFrom(edgeHit);\r\n lastBefore.setFrom(edgeHit);\r\n return RayClassification.RC_TargetOnEdge;\r\n }\r\n if (uEdge > targetDistance && uEdge < firstAfter.getDTag()!) {\r\n firstAfter.setFrom(edgeHit);\r\n firstAfter.setITag(v0 > 0.0 ? -1 : 1);\r\n }\r\n if (uEdge < targetDistance && uEdge > lastBefore.getDTag()!) {\r\n lastBefore.setFrom(edgeHit);\r\n lastBefore.setDTag(uEdge);\r\n }\r\n }\r\n data0.setFrom(data1);\r\n node0 = node0.faceSuccessor;\r\n } while (node0 !== faceNode);\r\n\r\n const afterTag = firstAfter.getITag();\r\n firstAfter.setITag(0);\r\n lastBefore.setITag(0);\r\n if (lastBefore.isUnclassified) {\r\n if (firstAfter.isUnclassified)\r\n return RayClassification.RC_NoHits;\r\n return RayClassification.RC_TargetBefore;\r\n }\r\n if (firstAfter.isUnclassified\r\n || (firstAfter.isEdge && afterTag && afterTag < 0)) {\r\n return RayClassification.RC_TargetAfter;\r\n } else {\r\n return RayClassification.RC_Bracket;\r\n }\r\n }\r\n\r\n // Return false if target is reached !!!!\r\n /**\r\n * Set (replace contents) ray with\r\n * * `origin` at start\r\n * * `direction` is unit vector from start towards target\r\n * * `a` is distance from start to target.\r\n * @param start existing position\r\n * @param target target xy coordinates\r\n * @param ray ray to update\r\n */\r\n public setSearchRay(start: HalfEdgePositionDetail, target: Point3d, ray: Ray3d): boolean {\r\n ray.origin.setFromPoint3d(start);\r\n Vector3d.createStartEnd(ray.origin, target, ray.direction);\r\n ray.direction.z = 0.0;\r\n const distanceToTarget = ray.direction.magnitudeXY();\r\n ray.a = ray.direction.magnitude();\r\n ray.direction.scaleInPlace(1 / ray.a);\r\n return distanceToTarget >= this._tol;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@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AI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC9B,MAAM,EAAE,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;YAC7B,IAAI,EAAE,IAAI,CAAC,EAAE;gBACX,+BAA+B;gBAC/B,IAAI,OAAO,GAAG,CAAC;oBACb,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBAChC,OAAO,EAAE,CAAC;aACX;iBAAM;gBACL,mBAAmB;aACpB;SACF;QACD,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,OAAO,CAAC;IACpC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Topology\n */\nimport { OrderedComparator, PriorityQueue } from \"@itwin/core-bentley\";\nimport { HalfEdge } from \"./Graph\";\nimport { HalfEdgeGraphOps } from \"./Merging\";\n\n/**\n * * Combination of a priority queue of HalfEdges with\n * * Additional \"active\" array to carry edges that have been removed from the queue but are still to be\n * inspected (possibly many times)\n * * The priority queue default sort is Y-then-X lexical sort.\n * * Caller has direct access to the queue and array.\n * * Methods are added here only to do things that involve both the queue and the array.\n * @internal\n */\nexport class HalfEdgePriorityQueueWithPartnerArray {\n public priorityQueue: PriorityQueue<HalfEdge>;\n public activeEdges: HalfEdge[];\n public constructor(\n compare: OrderedComparator<HalfEdge> = HalfEdgeGraphOps.compareNodesYXUp) {\n this.priorityQueue = new PriorityQueue(compare);\n this.activeEdges = [];\n }\n /** Read a member from the queue and transfer to the active array. */\n public popQueueToArray(): HalfEdge | undefined {\n if (this.priorityQueue.isEmpty)\n return undefined;\n const x = this.priorityQueue.pop()!;\n this.activeEdges.push(x);\n return x;\n }\n /** Pop the last entry and put it back as replacement for current entry at index i.\n * * Effectively remove active member at index i\n * * The array order is changed.\n * * constant time.\n */\n public popArrayToArrayIndex(i: number) {\n const n = this.activeEdges.length;\n if (i < n) {\n const x = this.activeEdges.pop()!;\n this.activeEdges[i] = x;\n }\n }\n /**\n * * Scan the active array.\n * * remove edges whose top y is below y\n * * (pack all remaining ones back towards the beginning)\n */\n public removeArrayMembersWithY1Below(y: number) {\n let numKeep = 0;\n const n = this.activeEdges.length;\n for (let i = 0; i < n; i++) {\n const q = this.activeEdges[i];\n const yB = q.faceSuccessor.y;\n if (yB >= y) {\n // copy [i] forward to [target]\n if (numKeep < i)\n this.activeEdges[numKeep] = q;\n numKeep++;\n } else {\n // let it go by !!!\n }\n }\n this.activeEdges.length = numKeep;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"HalfEdgePriorityQueue.js","sourceRoot":"","sources":["../../../src/topology/HalfEdgePriorityQueue.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AACH,OAAO,EAAqB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,OAAO,qCAAqC;IAGhD,YACE,UAAuC,gBAAgB,CAAC,gBAAgB;QACxE,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IACD,qEAAqE;IAC9D,eAAe;QACpB,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO;YAC5B,OAAO,SAAS,CAAC;QACnB,MAAM,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,EAAG,CAAC;QACpC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACzB,OAAO,CAAC,CAAC;IACX,CAAC;IACD;;;;OAIG;IACI,oBAAoB,CAAC,CAAS;QACnC,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;QAClC,IAAI,CAAC,GAAG,CAAC,EAAE;YACT,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,EAAG,CAAC;YAClC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;SACzB;IACH,CAAC;IACD;;;;OAIG;IACI,6BAA6B,CAAC,CAAS;QAC5C,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YAC1B,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC9B,MAAM,EAAE,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;YAC7B,IAAI,EAAE,IAAI,CAAC,EAAE;gBACX,+BAA+B;gBAC/B,IAAI,OAAO,GAAG,CAAC;oBACb,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBAChC,OAAO,EAAE,CAAC;aACX;iBAAM;gBACL,mBAAmB;aACpB;SACF;QACD,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,OAAO,CAAC;IACpC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Topology\r\n */\r\nimport { OrderedComparator, PriorityQueue } from \"@itwin/core-bentley\";\r\nimport { HalfEdge } from \"./Graph\";\r\nimport { HalfEdgeGraphOps } from \"./Merging\";\r\n\r\n/**\r\n * * Combination of a priority queue of HalfEdges with\r\n * * Additional \"active\" array to carry edges that have been removed from the queue but are still to be\r\n * inspected (possibly many times)\r\n * * The priority queue default sort is Y-then-X lexical sort.\r\n * * Caller has direct access to the queue and array.\r\n * * Methods are added here only to do things that involve both the queue and the array.\r\n * @internal\r\n */\r\nexport class HalfEdgePriorityQueueWithPartnerArray {\r\n public priorityQueue: PriorityQueue<HalfEdge>;\r\n public activeEdges: HalfEdge[];\r\n public constructor(\r\n compare: OrderedComparator<HalfEdge> = HalfEdgeGraphOps.compareNodesYXUp) {\r\n this.priorityQueue = new PriorityQueue(compare);\r\n this.activeEdges = [];\r\n }\r\n /** Read a member from the queue and transfer to the active array. */\r\n public popQueueToArray(): HalfEdge | undefined {\r\n if (this.priorityQueue.isEmpty)\r\n return undefined;\r\n const x = this.priorityQueue.pop()!;\r\n this.activeEdges.push(x);\r\n return x;\r\n }\r\n /** Pop the last entry and put it back as replacement for current entry at index i.\r\n * * Effectively remove active member at index i\r\n * * The array order is changed.\r\n * * constant time.\r\n */\r\n public popArrayToArrayIndex(i: number) {\r\n const n = this.activeEdges.length;\r\n if (i < n) {\r\n const x = this.activeEdges.pop()!;\r\n this.activeEdges[i] = x;\r\n }\r\n }\r\n /**\r\n * * Scan the active array.\r\n * * remove edges whose top y is below y\r\n * * (pack all remaining ones back towards the beginning)\r\n */\r\n public removeArrayMembersWithY1Below(y: number) {\r\n let numKeep = 0;\r\n const n = this.activeEdges.length;\r\n for (let i = 0; i < n; i++) {\r\n const q = this.activeEdges[i];\r\n const yB = q.faceSuccessor.y;\r\n if (yB >= y) {\r\n // copy [i] forward to [target]\r\n if (numKeep < i)\r\n this.activeEdges[numKeep] = q;\r\n numKeep++;\r\n } else {\r\n // let it go by !!!\r\n }\r\n }\r\n this.activeEdges.length = numKeep;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaskManager.js","sourceRoot":"","sources":["../../../src/topology/MaskManager.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AACH;;;;;;GAMG;AACH,MAAM,OAAO,WAAW;IAItB;;OAEG;IACH,YAAoB,SAAiB,EAAE,aAAqB;QAC1D,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,MAAM,CAAC,SAAiB;QACpC,kCAAkC;QAClC,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE;YAC3B,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,EAAE;gBAC/B,SAAS,GAAG,OAAO,CAAC;gBACpB,MAAM;aACP;YACD,OAAO,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;SAC1B;QACD,IAAI,SAAS,KAAK,CAAC;YACjB,OAAO,SAAS,CAAC;QACnB,OAAO,IAAI,WAAW,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC/C,CAAC;IACD;;OAEG;IACI,QAAQ;QACb,IAAI,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC;QAC/B,IAAI,IAAI,CAAC,UAAU,KAAK,CAAC;YACvB,OAAO,CAAC,CAAC;QACX,OAAO,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;YAC9B,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC;QAEnB,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IACD;;OAEG;IACI,QAAQ,CAAC,IAAY;QAC1B,IAAI,IAAI,IAAI,CAAC,kBAAkB,CAAC,CAAI,0CAA0C;QAC9E,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC;IAC1B,CAAC;CAEF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Topology\n */\n/**\n * Methods to \"grab and drop\" mask bits.\n * * Caller code (e.g. HalfEdgeGraph) initializes with a block of bits to be managed.\n * * Callers borrow and return masks with \"grabMask\" and \"dropMask\"\n * * Callers must exercise grab/drop balance discipline.\n * @internal\n */\nexport class MaskManager {\n private _freeMasks: number;\n private _originalFreeMasks: number;\n private _firstFreeMask: number;\n /**\n * @param freeMasks caller-defined block of bits that are to be managed.\n */\n private constructor(freeMasks: number, firstFreeMask: number) {\n this._originalFreeMasks = freeMasks;\n this._freeMasks = freeMasks;\n this._firstFreeMask = firstFreeMask;\n }\n /** Create a MaskManager.\n * Typical use: MaskManager.create (0xFFFF0000)\n * * This makes bits 16 through 31 available to be borrowed, with lower bits available for fixed usage.\n */\n public static create(freeMasks: number): MaskManager | undefined {\n // look for first bit up to bit 31\n let firstFree = 0;\n let testBit = 0x01;\n for (let i = 0; i < 32; i++) {\n if ((testBit & freeMasks) !== 0) {\n firstFree = testBit;\n break;\n }\n testBit = (testBit << 1);\n }\n if (firstFree === 0)\n return undefined;\n return new MaskManager(freeMasks, firstFree);\n }\n /**\n * Find a mask bit that is not \"in use\".\n */\n public grabMask(): number {\n let mask = this._firstFreeMask;\n if (this._freeMasks === 0)\n return 0;\n while (!(mask & this._freeMasks))\n mask = mask << 1;\n\n this._freeMasks &= ~mask;\n return mask;\n }\n /**\n * Find a mask bit that is not \"in use\".\n */\n public dropMask(mask: number) {\n mask &= this._originalFreeMasks; // prevent \"drop\" of mask not in the pool.\n this._freeMasks |= mask;\n }\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MaskManager.js","sourceRoot":"","sources":["../../../src/topology/MaskManager.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AACH;;;;;;GAMG;AACH,MAAM,OAAO,WAAW;IAItB;;OAEG;IACH,YAAoB,SAAiB,EAAE,aAAqB;QAC1D,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,MAAM,CAAC,SAAiB;QACpC,kCAAkC;QAClC,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE;YAC3B,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,EAAE;gBAC/B,SAAS,GAAG,OAAO,CAAC;gBACpB,MAAM;aACP;YACD,OAAO,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;SAC1B;QACD,IAAI,SAAS,KAAK,CAAC;YACjB,OAAO,SAAS,CAAC;QACnB,OAAO,IAAI,WAAW,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC/C,CAAC;IACD;;OAEG;IACI,QAAQ;QACb,IAAI,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC;QAC/B,IAAI,IAAI,CAAC,UAAU,KAAK,CAAC;YACvB,OAAO,CAAC,CAAC;QACX,OAAO,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;YAC9B,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC;QAEnB,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IACD;;OAEG;IACI,QAAQ,CAAC,IAAY;QAC1B,IAAI,IAAI,IAAI,CAAC,kBAAkB,CAAC,CAAI,0CAA0C;QAC9E,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC;IAC1B,CAAC;CAEF","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 Topology\r\n */\r\n/**\r\n * Methods to \"grab and drop\" mask bits.\r\n * * Caller code (e.g. HalfEdgeGraph) initializes with a block of bits to be managed.\r\n * * Callers borrow and return masks with \"grabMask\" and \"dropMask\"\r\n * * Callers must exercise grab/drop balance discipline.\r\n * @internal\r\n */\r\nexport class MaskManager {\r\n private _freeMasks: number;\r\n private _originalFreeMasks: number;\r\n private _firstFreeMask: number;\r\n /**\r\n * @param freeMasks caller-defined block of bits that are to be managed.\r\n */\r\n private constructor(freeMasks: number, firstFreeMask: number) {\r\n this._originalFreeMasks = freeMasks;\r\n this._freeMasks = freeMasks;\r\n this._firstFreeMask = firstFreeMask;\r\n }\r\n /** Create a MaskManager.\r\n * Typical use: MaskManager.create (0xFFFF0000)\r\n * * This makes bits 16 through 31 available to be borrowed, with lower bits available for fixed usage.\r\n */\r\n public static create(freeMasks: number): MaskManager | undefined {\r\n // look for first bit up to bit 31\r\n let firstFree = 0;\r\n let testBit = 0x01;\r\n for (let i = 0; i < 32; i++) {\r\n if ((testBit & freeMasks) !== 0) {\r\n firstFree = testBit;\r\n break;\r\n }\r\n testBit = (testBit << 1);\r\n }\r\n if (firstFree === 0)\r\n return undefined;\r\n return new MaskManager(freeMasks, firstFree);\r\n }\r\n /**\r\n * Find a mask bit that is not \"in use\".\r\n */\r\n public grabMask(): number {\r\n let mask = this._firstFreeMask;\r\n if (this._freeMasks === 0)\r\n return 0;\r\n while (!(mask & this._freeMasks))\r\n mask = mask << 1;\r\n\r\n this._freeMasks &= ~mask;\r\n return mask;\r\n }\r\n /**\r\n * Find a mask bit that is not \"in use\".\r\n */\r\n public dropMask(mask: number) {\r\n mask &= this._originalFreeMasks; // prevent \"drop\" of mask not in the pool.\r\n this._freeMasks |= mask;\r\n }\r\n\r\n}\r\n"]}
|
|
@@ -30,16 +30,8 @@ export declare class HalfEdgeGraphOps {
|
|
|
30
30
|
*/
|
|
31
31
|
static crossProductToTargets(base: HalfEdge, targetA: HalfEdge, targetB: HalfEdge): number;
|
|
32
32
|
static graphRange(graph: HalfEdgeGraph): Range3d;
|
|
33
|
-
/** Returns an array of
|
|
33
|
+
/** Returns an array of all nodes (both ends) of edges created from segments. */
|
|
34
34
|
static segmentArrayToGraphEdges(segments: LineSegment3d[], returnGraph: HalfEdgeGraph, mask: HalfEdgeMask): HalfEdge[];
|
|
35
|
-
/**
|
|
36
|
-
* * For each face with positive area . . . add edges as needed so that each face has one definitely lower node and one definite upper node.
|
|
37
|
-
* * Hence tracing edges from the low node, there is a sequence of upward edges, reaching the upper, then a sequence of downward edges reaching the low node.
|
|
38
|
-
* * This is an essential step for subsequent triangulation.
|
|
39
|
-
*
|
|
40
|
-
* @param graph
|
|
41
|
-
*/
|
|
42
|
-
static formMonotoneFaces(graph: HalfEdgeGraph): void;
|
|
43
35
|
/**
|
|
44
36
|
* * Visit all nodes in `graph`.
|
|
45
37
|
* * invoke `pinch(node, vertexPredecessor)`
|
|
@@ -47,6 +39,49 @@ export declare class HalfEdgeGraphOps {
|
|
|
47
39
|
* @param graph graph to modify
|
|
48
40
|
*/
|
|
49
41
|
static isolateAllEdges(graph: HalfEdgeGraph): void;
|
|
42
|
+
/**
|
|
43
|
+
* Compute convexity of a sector of a super-face.
|
|
44
|
+
* @param base node whose edge is to be tested for removal
|
|
45
|
+
* @param ignore edges with this mask (on either side) are ignored for the purposes of computing convexity
|
|
46
|
+
* @param barrier edges with this mask (on either side) will not be removed
|
|
47
|
+
* @return whether removing the edge at base would create a convex sector in the super-face
|
|
48
|
+
*/
|
|
49
|
+
private static isSectorConvexAfterEdgeRemoval;
|
|
50
|
+
/**
|
|
51
|
+
* Mask edges between faces if the union of the faces is convex.
|
|
52
|
+
* Uses a greedy algorithm with no regard to quality of resulting convex faces.
|
|
53
|
+
* Best results when input faces are convex.
|
|
54
|
+
* @param graph graph to examine and mark
|
|
55
|
+
* @param mark the mask used to mark (both sides of) removable edges
|
|
56
|
+
* @param barrier edges with this mask (on either side) will not be marked. Defaults to HalfEdgeMask.BOUNDARY_EDGE.
|
|
57
|
+
* @return number of edges masked (half the number of HalfEdges masked)
|
|
58
|
+
*/
|
|
59
|
+
static markRemovableEdgesToExpandConvexFaces(graph: HalfEdgeGraph, mark: HalfEdgeMask, barrier?: HalfEdgeMask): number;
|
|
60
|
+
/**
|
|
61
|
+
* Collect edges between faces if the union of the faces is convex.
|
|
62
|
+
* Uses a greedy algorithm with no regard to quality of resulting convex faces.
|
|
63
|
+
* Best results when input faces are convex.
|
|
64
|
+
* @param graph graph to examine
|
|
65
|
+
* @param barrier edges with this mask (on either side) will not be collected. Defaults to HalfEdgeMask.BOUNDARY_EDGE.
|
|
66
|
+
* @return one HalfEdge per removable edge
|
|
67
|
+
*/
|
|
68
|
+
static collectRemovableEdgesToExpandConvexFaces(graph: HalfEdgeGraph, barrier?: HalfEdgeMask): HalfEdge[] | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Remove edges between faces if the union of the faces is convex.
|
|
71
|
+
* Uses a greedy algorithm with no regard to quality of resulting convex faces.
|
|
72
|
+
* Best results when input faces are convex.
|
|
73
|
+
* @param graph graph to modify
|
|
74
|
+
* @param barrier edges with this mask (on either side) will not be removed. Defaults to HalfEdgeMask.BOUNDARY_EDGE.
|
|
75
|
+
* @return number of edges deleted
|
|
76
|
+
*/
|
|
77
|
+
static expandConvexFaces(graph: HalfEdgeGraph, barrier?: HalfEdgeMask): number;
|
|
78
|
+
/**
|
|
79
|
+
* Test desired faces for convexity.
|
|
80
|
+
* @param graph graph to examine
|
|
81
|
+
* @param avoid faces with this mask will not be examined. Defaults to HalfEdgeMask.EXTERIOR.
|
|
82
|
+
* @return whether every face in the graph is convex
|
|
83
|
+
*/
|
|
84
|
+
static isEveryFaceConvex(graph: HalfEdgeGraph, avoid?: HalfEdgeMask): boolean;
|
|
50
85
|
}
|
|
51
86
|
/**
|
|
52
87
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Merging.d.ts","sourceRoot":"","sources":["../../../src/topology/Merging.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIvD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGhE,OAAO,EAAE,0BAA0B,EAAgB,MAAM,iBAAiB,CAAC;AAE3E,qBAAa,cAAc;IAClB,SAAS,SAAK;IACd,mBAAmB,SAAK;IACxB,QAAQ,SAAK;IACb,SAAS,SAAK;IACd,OAAO,SAAK;IACZ,OAAO,SAAK;;CAGpB;AAED;;;GAGG;AACH,qBAAa,gBAAgB;IAE3B,iFAAiF;WACnE,gBAAgB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ;IAgBvD,mIAAmI;WACrH,UAAU,CAAC,KAAK,EAAE,QAAQ;IAQxC;;;;OAIG;WACW,qBAAqB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM;WAOnF,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IAOvD,
|
|
1
|
+
{"version":3,"file":"Merging.d.ts","sourceRoot":"","sources":["../../../src/topology/Merging.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIvD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGhE,OAAO,EAAE,0BAA0B,EAAgB,MAAM,iBAAiB,CAAC;AAE3E,qBAAa,cAAc;IAClB,SAAS,SAAK;IACd,mBAAmB,SAAK;IACxB,QAAQ,SAAK;IACb,SAAS,SAAK;IACd,OAAO,SAAK;IACZ,OAAO,SAA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C,MAAM,CAAC,kBAAkB;IAKjC,OAAO,CAAC,MAAM,CAAC,mCAAmC;IAyBlD;;;;OAIG;WACW,sBAAsB,CAAC,KAAK,EAAE,aAAa,GAAG,cAAc;IA+C1E;;;;;;;;OAQG;WACW,qBAAqB,CAAC,YAAY,EAAE,aAAa,EAAE,GAAG,aAAa;IAUjF;;;;OAIG;WACW,mBAAmB,CAAC,MAAM,EAAE,0BAA0B,EAAE,UAAU,GAAE,OAAc,EAAE,IAAI,GAAE,YAAwC,GAAG,aAAa,GAAG,SAAS;CAiB7K"}
|
|
@@ -68,7 +68,7 @@ export class HalfEdgeGraphOps {
|
|
|
68
68
|
}
|
|
69
69
|
return range;
|
|
70
70
|
}
|
|
71
|
-
/** Returns an array of
|
|
71
|
+
/** Returns an array of all nodes (both ends) of edges created from segments. */
|
|
72
72
|
static segmentArrayToGraphEdges(segments, returnGraph, mask) {
|
|
73
73
|
const result = [];
|
|
74
74
|
let idxCounter = 0;
|
|
@@ -83,27 +83,6 @@ export class HalfEdgeGraphOps {
|
|
|
83
83
|
}
|
|
84
84
|
return result;
|
|
85
85
|
}
|
|
86
|
-
/**
|
|
87
|
-
* * For each face with positive area . . . add edges as needed so that each face has one definitely lower node and one definite upper node.
|
|
88
|
-
* * Hence tracing edges from the low node, there is a sequence of upward edges, reaching the upper, then a sequence of downward edges reaching the low node.
|
|
89
|
-
* * This is an essential step for subsequent triangulation.
|
|
90
|
-
*
|
|
91
|
-
* @param graph
|
|
92
|
-
*/
|
|
93
|
-
static formMonotoneFaces(graph) {
|
|
94
|
-
const allFaces = graph.collectFaceLoops();
|
|
95
|
-
graph.clearMask(HalfEdgeMask.VISITED);
|
|
96
|
-
// For every face, break the face down into monotone sections
|
|
97
|
-
for (const node of allFaces) {
|
|
98
|
-
if (node.isMaskSet(HalfEdgeMask.VISITED))
|
|
99
|
-
continue;
|
|
100
|
-
const area = node.signedFaceArea();
|
|
101
|
-
if (area <= 0.0) {
|
|
102
|
-
node.setMaskAroundFace(HalfEdgeMask.VISITED);
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
86
|
/**
|
|
108
87
|
* * Visit all nodes in `graph`.
|
|
109
88
|
* * invoke `pinch(node, vertexPredecessor)`
|
|
@@ -116,6 +95,115 @@ export class HalfEdgeGraphOps {
|
|
|
116
95
|
HalfEdge.pinch(nodeA, nodeB);
|
|
117
96
|
}
|
|
118
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Compute convexity of a sector of a super-face.
|
|
100
|
+
* @param base node whose edge is to be tested for removal
|
|
101
|
+
* @param ignore edges with this mask (on either side) are ignored for the purposes of computing convexity
|
|
102
|
+
* @param barrier edges with this mask (on either side) will not be removed
|
|
103
|
+
* @return whether removing the edge at base would create a convex sector in the super-face
|
|
104
|
+
*/
|
|
105
|
+
static isSectorConvexAfterEdgeRemoval(base, ignore, barrier) {
|
|
106
|
+
let vs = base;
|
|
107
|
+
do { // loop ccw around vertex looking for a super-face predecessor
|
|
108
|
+
if (vs.isMaskSet(barrier) || vs.edgeMate.isMaskSet(barrier))
|
|
109
|
+
break;
|
|
110
|
+
vs = vs.vertexSuccessor;
|
|
111
|
+
} while (vs !== base && vs.isMaskSet(ignore));
|
|
112
|
+
if (vs === base)
|
|
113
|
+
return false;
|
|
114
|
+
let vp = base;
|
|
115
|
+
do { // loop cw around vertex looking for a super-face successor
|
|
116
|
+
if (vp.isMaskSet(barrier) || vp.edgeMate.isMaskSet(barrier))
|
|
117
|
+
break;
|
|
118
|
+
vp = vp.vertexPredecessor;
|
|
119
|
+
} while (vp !== base && vp.isMaskSet(ignore));
|
|
120
|
+
if (vp === base)
|
|
121
|
+
return false;
|
|
122
|
+
return HalfEdge.isSectorConvex(vs.edgeMate, base, vp.faceSuccessor);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Mask edges between faces if the union of the faces is convex.
|
|
126
|
+
* Uses a greedy algorithm with no regard to quality of resulting convex faces.
|
|
127
|
+
* Best results when input faces are convex.
|
|
128
|
+
* @param graph graph to examine and mark
|
|
129
|
+
* @param mark the mask used to mark (both sides of) removable edges
|
|
130
|
+
* @param barrier edges with this mask (on either side) will not be marked. Defaults to HalfEdgeMask.BOUNDARY_EDGE.
|
|
131
|
+
* @return number of edges masked (half the number of HalfEdges masked)
|
|
132
|
+
*/
|
|
133
|
+
static markRemovableEdgesToExpandConvexFaces(graph, mark, barrier = HalfEdgeMask.BOUNDARY_EDGE) {
|
|
134
|
+
if (HalfEdgeMask.NULL_MASK === mark)
|
|
135
|
+
return 0;
|
|
136
|
+
const visit = graph.grabMask(true);
|
|
137
|
+
let numMarked = 0;
|
|
138
|
+
for (const node of graph.allHalfEdges) {
|
|
139
|
+
if (!node.isMaskSet(visit)) {
|
|
140
|
+
if (!node.isMaskSet(barrier) && !node.edgeMate.isMaskSet(barrier)) {
|
|
141
|
+
if (this.isSectorConvexAfterEdgeRemoval(node, mark, barrier) && this.isSectorConvexAfterEdgeRemoval(node.edgeMate, mark, barrier)) {
|
|
142
|
+
node.setMaskAroundEdge(mark);
|
|
143
|
+
++numMarked;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
node.setMaskAroundEdge(visit);
|
|
148
|
+
}
|
|
149
|
+
return numMarked;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Collect edges between faces if the union of the faces is convex.
|
|
153
|
+
* Uses a greedy algorithm with no regard to quality of resulting convex faces.
|
|
154
|
+
* Best results when input faces are convex.
|
|
155
|
+
* @param graph graph to examine
|
|
156
|
+
* @param barrier edges with this mask (on either side) will not be collected. Defaults to HalfEdgeMask.BOUNDARY_EDGE.
|
|
157
|
+
* @return one HalfEdge per removable edge
|
|
158
|
+
*/
|
|
159
|
+
static collectRemovableEdgesToExpandConvexFaces(graph, barrier = HalfEdgeMask.BOUNDARY_EDGE) {
|
|
160
|
+
const removable = [];
|
|
161
|
+
const mark = graph.grabMask(true);
|
|
162
|
+
if (0 < this.markRemovableEdgesToExpandConvexFaces(graph, mark, barrier)) {
|
|
163
|
+
const visited = graph.grabMask(true);
|
|
164
|
+
for (const node of graph.allHalfEdges) {
|
|
165
|
+
if (node.isMaskSet(mark) && !node.isMaskSet(visited)) {
|
|
166
|
+
node.setMaskAroundEdge(visited);
|
|
167
|
+
removable.push(node);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
graph.dropMask(visited);
|
|
171
|
+
}
|
|
172
|
+
graph.dropMask(mark);
|
|
173
|
+
return removable;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Remove edges between faces if the union of the faces is convex.
|
|
177
|
+
* Uses a greedy algorithm with no regard to quality of resulting convex faces.
|
|
178
|
+
* Best results when input faces are convex.
|
|
179
|
+
* @param graph graph to modify
|
|
180
|
+
* @param barrier edges with this mask (on either side) will not be removed. Defaults to HalfEdgeMask.BOUNDARY_EDGE.
|
|
181
|
+
* @return number of edges deleted
|
|
182
|
+
*/
|
|
183
|
+
static expandConvexFaces(graph, barrier = HalfEdgeMask.BOUNDARY_EDGE) {
|
|
184
|
+
const mark = graph.grabMask(true);
|
|
185
|
+
const numRemovedEdges = this.markRemovableEdgesToExpandConvexFaces(graph, mark, barrier);
|
|
186
|
+
if (numRemovedEdges > 0)
|
|
187
|
+
graph.yankAndDeleteEdges((node) => node.getMask(mark));
|
|
188
|
+
graph.dropMask(mark);
|
|
189
|
+
return numRemovedEdges;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Test desired faces for convexity.
|
|
193
|
+
* @param graph graph to examine
|
|
194
|
+
* @param avoid faces with this mask will not be examined. Defaults to HalfEdgeMask.EXTERIOR.
|
|
195
|
+
* @return whether every face in the graph is convex
|
|
196
|
+
*/
|
|
197
|
+
static isEveryFaceConvex(graph, avoid = HalfEdgeMask.EXTERIOR) {
|
|
198
|
+
const allFaces = graph.collectFaceLoops();
|
|
199
|
+
for (const node of allFaces) {
|
|
200
|
+
if (node.isMaskedAroundFace(avoid))
|
|
201
|
+
continue;
|
|
202
|
+
if (!node.isFaceConvex())
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
119
207
|
}
|
|
120
208
|
/**
|
|
121
209
|
* @internal
|