/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { DMesh3_goo goo = null; DMesh3_goo cut = null; bool cap = false; DA.GetData(0, ref goo); DA.GetData(1, ref cut); DA.GetData(2, ref cap); DMesh3 ms = new DMesh3(goo.Value); g3.MeshMeshCut cutter = new g3.MeshMeshCut(); cutter.Target = new DMesh3(goo.Value); cutter.CutMesh = new DMesh3(cut.Value); cutter.Compute(); if (cap) { cutter.RemoveContained(); } DA.SetData(0, cutter.CutMesh); }
void split_missing(MeshMeshCut fromOp, MeshMeshCut toOp, DMesh3 fromMesh, DMesh3 toMesh, HashSet <int> fromVerts, HashSet <int> toVerts) { List <int> missing = new List <int>(); foreach (int vid in fromVerts) { Vector3d v = fromMesh.GetVertex(vid); int near_vid = find_nearest_vertex(toMesh, v, toVerts); if (near_vid == DMesh3.InvalidID) { missing.Add(vid); } } foreach (int vid in missing) { Vector3d v = fromMesh.GetVertex(vid); int near_eid = find_nearest_edge(toMesh, v, toVerts); if (near_eid == DMesh3.InvalidID) { System.Console.WriteLine("could not find edge to split?"); continue; } DMesh3.EdgeSplitInfo splitInfo; MeshResult result = toMesh.SplitEdge(near_eid, out splitInfo); if (result != MeshResult.Ok) { System.Console.WriteLine("edge split failed"); continue; } toMesh.SetVertex(splitInfo.vNew, v); toVerts.Add(splitInfo.vNew); } }
public bool Compute() { // 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 }; cutTargetOp.Compute(); cutTargetOp.RemoveContained(); cutTargetMesh = cutTargetOp.Target; cutToolOp = new MeshMeshCut() { Target = new DMesh3(Tool), CutMesh = Target, VertexSnapTol = VertexSnapTol }; cutToolOp.Compute(); cutToolOp.RemoveContained(); cutToolMesh = cutToolOp.Target; resolve_vtx_pairs(); Result = cutToolMesh; MeshEditor.Append(Result, cutTargetMesh); return(true); }
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); }