コード例 #1
0
        private void CloneMeshWithPartition(ISpatialPartition <int> partition)
        {
            TriangleMeshShape meshShape = (TriangleMeshShape)_meshShape.Clone();

            meshShape.Partition = partition;

            TriangleMeshShape clone = meshShape.Clone() as TriangleMeshShape;

            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.Mesh);
            Assert.IsTrue(clone.Mesh is TriangleMesh);
            Assert.AreSame(_mesh, clone.Mesh);
            Assert.AreEqual(_mesh.NumberOfTriangles, clone.Mesh.NumberOfTriangles);
            for (int i = 0; i < _mesh.NumberOfTriangles; i++)
            {
                Triangle t = _mesh.GetTriangle(i);

                Triangle tCloned = clone.Mesh.GetTriangle(i);

                Assert.AreEqual(t.Vertex0, tCloned.Vertex0);
                Assert.AreEqual(t.Vertex1, tCloned.Vertex1);
                Assert.AreEqual(t.Vertex2, tCloned.Vertex2);
            }

            Assert.IsNotNull(clone.Partition);
            Assert.IsInstanceOf(partition.GetType(), clone.Partition);
            Assert.AreEqual(_mesh.NumberOfTriangles, clone.Partition.Count);
            Assert.AreNotSame(partition, clone.Partition);
        }
コード例 #2
0
        public void Clone()
        {
            TriangleMeshShape clone = _meshShape.Clone() as TriangleMeshShape;

            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.Mesh);
            Assert.IsTrue(clone.Mesh is TriangleMesh);
            Assert.AreSame(_mesh, clone.Mesh);
            Assert.AreEqual(_mesh.NumberOfTriangles, clone.Mesh.NumberOfTriangles);
            for (int i = 0; i < _mesh.NumberOfTriangles; i++)
            {
                Triangle t = _mesh.GetTriangle(i);

                Triangle tCloned = clone.Mesh.GetTriangle(i);

                Assert.AreEqual(t.Vertex0, tCloned.Vertex0);
                Assert.AreEqual(t.Vertex1, tCloned.Vertex1);
                Assert.AreEqual(t.Vertex2, tCloned.Vertex2);
            }
            Assert.AreEqual(_meshShape.GetAabb(Pose.Identity).Minimum, clone.GetAabb(Pose.Identity).Minimum);
            Assert.AreEqual(_meshShape.GetAabb(Pose.Identity).Maximum, clone.GetAabb(Pose.Identity).Maximum);
        }