Exemple #1
0
        public void Surface_Equal_True_ForTwoTriangles_SharedVertices2()
        {
            // ARRANGE
            ListSurface s1 = new ListSurface();

            s1.AddVertex(new Vector3(0, 0, 0));
            s1.AddVertex(new Vector3(1, 0, 0));
            s1.AddVertex(new Vector3(0, 1, 0));
            s1.AddVertex(new Vector3(1, 1, 0));
            s1.AddTriangle(0, 1, 2);
            s1.AddTriangle(0, 1, 3);
            ListSurface s2 = new ListSurface();

            s2.AddVertex(new Vector3(0, 0, 0));
            s2.AddVertex(new Vector3(1, 0, 0));
            s2.AddVertex(new Vector3(0, 1, 0));
            s2.AddVertex(new Vector3(1, 0, 0));
            s2.AddVertex(new Vector3(1, 1, 0));
            s2.AddTriangle(0, 1, 2);
            s2.AddTriangle(0, 3, 4);

            // ACT
            bool areEqual = ListSurface.AreSurfacesEquivalent(s1, s2);

            // ASSERT
            Assert.IsTrue(areEqual);
        }
Exemple #2
0
        public void Surface_Equal_False_ForOneVsTwoTriangles()
        {
            // ARRANGE
            ListSurface s1 = new ListSurface();

            s1.AddVertex(new Vector3(0, 0, 0));
            s1.AddVertex(new Vector3(1, 0, 0));
            s1.AddVertex(new Vector3(1, 1, 0));
            s1.AddTriangle(0, 1, 2);
            ListSurface s2 = new ListSurface();

            s2.AddVertex(new Vector3(0, 0, 0));
            s2.AddVertex(new Vector3(1, 0, 0));
            s2.AddVertex(new Vector3(0, 1, 0));
            s2.AddVertex(new Vector3(0, 0, 0));
            s2.AddVertex(new Vector3(1, 0, 0));
            s2.AddVertex(new Vector3(1, 1, 0));
            s2.AddTriangle(0, 1, 2);
            s2.AddTriangle(3, 4, 5);

            // ACT
            bool areEqual = ListSurface.AreSurfacesEquivalent(s1, s2);

            // ASSERT
            Assert.IsFalse(areEqual);
        }
Exemple #3
0
        /// <summary>
        /// Tests a specific example of a cell. Assumes that delta in the grid is 1, origin is 0 and isovalue is 0
        /// </summary>
        public static bool TestSpecific(float[,,] cells, IEnumerable <ListSurface> expecteds)
        {
            ArrayGrid   grid = new ArrayGrid(cells, Vector3.Zero, Vector3.One);
            ListSurface s    = new ListSurface();

            MarchingCubes.MarchIntoSurface(grid, 0, s);

            foreach (ListSurface e in expecteds)
            {
                if (ListSurface.AreSurfacesEquivalent(e, s))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #4
0
        public void GridGenerateSurface_SingleValue1_OtherValueMinus1_Iso0_GeneratesCorrectTriangle()
        {
            // ARRANGE
            ArrayGrid   grid     = GenerateSingle(1, -1, 0);
            ListSurface expected = new ListSurface();

            expected.AddVertex(new Vector3(0.5f, 0, 0));
            expected.AddVertex(new Vector3(0, 0.5f, 0));
            expected.AddVertex(new Vector3(0, 0, 0.5f));
            expected.AddTriangle(0, 1, 2);

            // ACT
            ListSurface s = new ListSurface();

            MarchingCubes.MarchIntoSurface(grid, 0, s);
            bool areEqual = ListSurface.AreSurfacesEquivalent(expected, s);

            // ASSERT
            Assert.IsTrue(areEqual);
        }
Exemple #5
0
        public void Surface_Equal_FalseForDifferentWindingsTriangle3()
        {
            // ARRANGE
            ListSurface s1 = new ListSurface();

            s1.AddVertex(new Vector3(0, 0, 0));
            s1.AddVertex(new Vector3(1, 0, 0));
            s1.AddVertex(new Vector3(0, 1, 0));
            s1.AddTriangle(0, 1, 2);
            ListSurface s2 = new ListSurface();

            s2.AddVertex(new Vector3(0, 0, 0));
            s2.AddVertex(new Vector3(1, 0, 0));
            s2.AddVertex(new Vector3(0, 1, 0));
            s2.AddTriangle(1, 0, 2);

            // ACT
            bool areEqual = ListSurface.AreSurfacesEquivalent(s1, s2);

            // ASSERT
            Assert.IsFalse(areEqual);
        }
Exemple #6
0
        public void Surface_Equal_TrueForSameWindingsTriangle2()
        {
            // ARRANGE
            ListSurface s1 = new ListSurface();

            s1.AddVertex(new Vector3(0, 0, 0));
            s1.AddVertex(new Vector3(1, 0, 0));
            s1.AddVertex(new Vector3(0, 1, 0));
            s1.AddTriangle(0, 1, 2);
            ListSurface s2 = new ListSurface();

            s2.AddVertex(new Vector3(0, 0, 0));
            s2.AddVertex(new Vector3(1, 0, 0));
            s2.AddVertex(new Vector3(0, 1, 0));
            s2.AddTriangle(2, 0, 1);

            // ACT
            bool areEqual = ListSurface.AreSurfacesEquivalent(s1, s2);

            // ASSERT
            Assert.IsTrue(areEqual);
        }