Пример #1
0
        public static void test_remove_change_construct()
        {
            DMesh3 testMesh = TestUtil.LoadTestInputMesh("bunny_open_base.obj");

            Random r = new Random(31337);
            //int N = 100;
            int N = 10;

            int[] indices = TestUtil.RandomIndices(N, r, testMesh.MaxVertexID);
            for (int ii = 0; ii < N; ++ii)
            {
                MeshFaceSelection selection = new MeshFaceSelection(testMesh);
                selection.SelectVertexOneRing(indices[ii]);
                selection.ExpandToOneRingNeighbours(8);

                RemoveTrianglesMeshChange change = new RemoveTrianglesMeshChange();
                change.InitializeFromExisting(testMesh, selection);

                DMesh3 removed = new DMesh3(testMesh);
                MeshEditor.RemoveTriangles(removed, selection);

                DMesh3 changeCopy = new DMesh3(testMesh);
                change.Apply(changeCopy);
                changeCopy.CheckValidity(true);

                if (!changeCopy.IsSameMesh(removed, true))
                {
                    System.Console.WriteLine("FAILED copy.IsSameMesh() 1");
                }

                change.Revert(changeCopy);
                changeCopy.CheckValidity(false);

                if (!changeCopy.IsSameMesh(testMesh, true))
                {
                    System.Console.WriteLine("FAILED copy.IsSameMesh() 1");
                }
            }

            System.Console.WriteLine("test_remove_change_construct ok");
        }