void resolve_vtx_pairs() { //HashSet<int> targetVerts = new HashSet<int>(cutTargetOp.CutVertices); //HashSet<int> toolVerts = new HashSet<int>(cutToolOp.CutVertices); // tracking on-cut vertices is not working yet... Util.gDevAssert(Target.IsClosed() && Tool.IsClosed()); HashSet <int> targetVerts = new HashSet <int>(MeshIterators.BoundaryVertices(cutTargetMesh)); HashSet <int> toolVerts = new HashSet <int>(MeshIterators.BoundaryVertices(cutToolMesh)); split_missing(cutTargetOp, cutToolOp, cutTargetMesh, cutToolMesh, targetVerts, toolVerts); split_missing(cutToolOp, cutTargetOp, cutToolMesh, cutTargetMesh, toolVerts, targetVerts); }
public bool Compute(boolOperation op = boolOperation.Union) { if (!Target.IsClosed()) { Debug.WriteLine("Target mesh is not closed;"); } if (!Tool.IsClosed()) { Debug.WriteLine("Tool mesh is not closed;"); } Util.gDevAssert(Target.IsClosed() && Tool.IsClosed()); // Alternate strategy: // - don't do RemoveContained // - match embedded vertices, split where possible // - find min-cut path through shared edges // - remove contiguous patches that are inside both/etc (use MWN) // ** no good for coplanar regions... cutTargetOp = new MeshMeshCut() { Target = new DMesh3(Target), CutMesh = Tool, VertexSnapTol = VertexSnapTol, AttemptPlanarRemoval = AttemptPlanarRemoval }; cutTargetOp.Compute(); if (op == boolOperation.Union || op == boolOperation.Subtraction) { cutTargetOp.RemoveContained(); } else if (op == boolOperation.Intersection) { cutTargetOp.RemoveExternal(); } cutTargetMesh = cutTargetOp.Target; cutToolOp = new MeshMeshCut() { Target = new DMesh3(Tool), CutMesh = Target, VertexSnapTol = VertexSnapTol, AttemptPlanarRemoval = AttemptPlanarRemoval }; cutToolOp.Compute(); if (op == boolOperation.Union || op == boolOperation.Intersection) { cutToolOp.RemoveContained(); } else if (op == boolOperation.Subtraction) { cutToolOp.RemoveExternal(); } cutToolMesh = cutToolOp.Target; resolve_vtx_pairs(); Result = cutToolMesh; MeshEditor.Append(Result, cutTargetMesh); return(true); }