private static void TestWithCloseNumber(double closeEnough) { Console.WriteLine($"test_MeshMeshCut_rounding: {closeEnough}"); var shape = test_Bool.MakeBox( center: new Vector3d(0, 0, 0), size: new Vector3d(2, 2, 2) ); var tool = test_Bool.MakeBox( center: new Vector3d(0, 0, closeEnough), size: new Vector3d(1, 1, 1) ); MeshTransforms.Translate(shape, new Vector3d(1, 1, 1)); MeshTransforms.Translate(tool, new Vector3d(1, 1, 1)); var error = false; DMesh3 ret; using (var c = new ConsoleColorController()) { var meshCut = new MeshMeshCut(); meshCut.Target = shape; meshCut.CutMesh = tool; meshCut.Compute(); ret = meshCut.Target; if (!ret.IsClosed()) { error = TestUtil.ConsoleError("Mesh is not closed.", ret) || error; } meshCut.RemoveContained(); if (ret.IsClosed()) { error = TestUtil.ConsoleError("Mesh should not be closed.", ret) || error; } if (ret.BoundaryEdgeIndices().Count() != 8) { error = TestUtil.ConsoleError($"Mesh should have 8 open edges. It has {ret.BoundaryEdgeIndices().Count()}.", ret) || error; } } if (!error) { Console.WriteLine("ok"); } }
internal static void test_cut_contained() { Console.WriteLine("Testing cut Contained."); DMesh3 b1 = TestUtil.LoadTestInputMesh("box1.obj"); DMesh3 b2 = TestUtil.LoadTestInputMesh("box2.obj"); Stopwatch s = new Stopwatch(); s.Start(); var mBool = new MeshMeshCut(); mBool.Target = b1; mBool.CutMesh = b2; mBool.Compute(); mBool.RemoveContained(); Console.WriteLine($"Done in {s.ElapsedMilliseconds} ms. "); var outF = TestUtil.WriteTestOutputMesh(mBool.Target, "MeshOps_CutRemoveContained.obj"); Console.WriteLine($"Written to: {outF}"); }
internal static void test_cut_forStudy() { Console.WriteLine("Testing cut coplanar."); DMesh3 b1 = TestUtil.LoadTestInputMesh("Tri1.obj"); DMesh3 b2 = TestUtil.LoadTestInputMesh("Tri2.obj"); Stopwatch s = new Stopwatch(); s.Start(); var meshCut = new MeshMeshCut(); meshCut.Target = b1; meshCut.CutMesh = b2; meshCut.Compute(); meshCut.RemoveContained(); Console.WriteLine($"Done in {s.ElapsedMilliseconds} ms. "); var outF = TestUtil.WriteTestOutputMesh(meshCut.Target, "MeshOps_CutForStudy.obj"); Console.WriteLine($"Written to: {outF}"); }
private static void testCoplanar(bool invert, string outFileName) { var b1 = test_Bool.MakeBox( center: new Vector3d(0, 0, 0), size: new Vector3d(1, 1, 1) ); var b2 = test_Bool.MakeBox( center: new Vector3d(0, 0, .5), size: new Vector3d(1.0, 1.0, 1) ); Stopwatch s = new Stopwatch(); s.Start(); var meshCut = new MeshMeshCut(); meshCut.AttemptPlanarRemoval = true; if (invert) { meshCut.Target = b2; meshCut.CutMesh = b1; } else { meshCut.Target = b1; meshCut.CutMesh = b2; } meshCut.Compute(); meshCut.RemoveContained(); Console.WriteLine($"Done in {s.ElapsedMilliseconds} ms. "); var outF = TestUtil.WriteTestOutputMesh(meshCut.Target, outFileName); Console.WriteLine($"Written to: {outF}"); }