コード例 #1
0
        public static void TestTriangulation()
        {
            VtIntArray indices    = new VtIntArray();
            VtIntArray faceCounts = new VtIntArray();

            faceCounts.push_back(5);
            indices.push_back(0);
            indices.push_back(1);
            indices.push_back(2);
            indices.push_back(3);
            indices.push_back(4);

            faceCounts.push_back(4);
            indices.push_back(5);
            indices.push_back(6);
            indices.push_back(7);
            indices.push_back(8);

            faceCounts.push_back(3);
            indices.push_back(9);
            indices.push_back(10);
            indices.push_back(11);

            // Degenerate face.
            faceCounts.push_back(2);
            indices.push_back(12);
            indices.push_back(13);

            UsdGeomMesh.Triangulate(indices, faceCounts);

            AssertEqual((int)faceCounts.size(), 6);

            for (int i = 0; i < faceCounts.size(); i++)
            {
                AssertEqual((int)faceCounts[i], 3);
            }

            AssertEqual((int)indices.size(), 18);

            AssertEqual(indices[0], 0);
            AssertEqual(indices[1], 1);
            AssertEqual(indices[2], 2);

            AssertEqual(indices[3], 0);
            AssertEqual(indices[4], 2);
            AssertEqual(indices[5], 3);

            AssertEqual(indices[6], 0);
            AssertEqual(indices[7], 3);
            AssertEqual(indices[8], 4);

            AssertEqual(indices[9], 5);
            AssertEqual(indices[10], 6);
            AssertEqual(indices[11], 7);

            AssertEqual(indices[12], 5);
            AssertEqual(indices[13], 7);
            AssertEqual(indices[14], 8);

            AssertEqual(indices[15], 9);
            AssertEqual(indices[16], 10);
            AssertEqual(indices[17], 11);
        }