コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
0
        public void Surface_IsClosed_False_ForSingleTriangle()
        {
            // ARRANGE
            ListSurface s = new ListSurface();

            s.AddVertex(0, 0, 0);
            s.AddVertex(0, 1, 0);
            s.AddVertex(1, 0, 0);
            s.AddTriangle(0, 1, 2);

            // ACT
            bool isClosed = s.IsClosed();

            // ASSERT
            Assert.IsFalse(isClosed);
        }
コード例 #4
0
        public void Surface_IsClosed_True_ForBackToBackTriangles()
        {
            // ARRANGE
            ListSurface s = new ListSurface();

            s.AddVertex(0, 0, 0);
            s.AddVertex(0, 1, 0);
            s.AddVertex(1, 0, 0);
            s.AddTriangle(0, 1, 2);
            s.AddTriangle(0, 2, 1);

            // ACT
            bool isClosed = s.IsClosed();

            // ASSERT
            Assert.IsTrue(isClosed);
        }
コード例 #5
0
ファイル: Case1GenTests.cs プロジェクト: Joeoc2001/MC-33
        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);
        }
コード例 #6
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);
        }
コード例 #7
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);
        }
コード例 #8
0
ファイル: SpecificTests.cs プロジェクト: Joeoc2001/MC-33
        private static void JoinInto(ListSurface into, ListSurface from)
        {
            int offset = into.GetVertexCount();

            foreach (Vector3 vertex in from.GetVertices())
            {
                into.AddVertex(vertex);
            }

            int[] triangles = from.GetTriangles();
            for (int i = 0; i < triangles.Length; i += 3)
            {
                into.AddTriangle(triangles[i] + offset,
                                 triangles[i + 1] + offset,
                                 triangles[i + 2] + offset);
            }
        }
コード例 #9
0
ファイル: SpecificTests.cs プロジェクト: Joeoc2001/MC-33
        private static ListSurface GenSurfaceFromEdges(List <Vector3> vertices, List <Tuple <int, int> > edges)
        {
            ListSurface surface = new ListSurface();

            foreach (Vector3 vertex in vertices)
            {
                surface.AddVertex(vertex);
            }

            List <Tuple <int, int, int> > triangles = GenTrianglesFromEdges(edges);

            foreach (Tuple <int, int, int> triangle in triangles)
            {
                surface.AddTriangle(triangle.Item1, triangle.Item2, triangle.Item3);
            }

            return(surface);
        }