Exemple #1
0
        public void Clone()
        {
            CompositeShape compositeShape = new CompositeShape();
              for (int i = 0; i < 10; i++)
              {
            Pose pose = new Pose(new Vector3F(i, i, i));
            PointShape point = new PointShape(i, i, i);
            GeometricObject geometry = new GeometricObject(point, pose);
            compositeShape.Children.Add(geometry);
              }

              CompositeShape clone = compositeShape.Clone() as CompositeShape;
              Assert.IsNotNull(clone);
              Assert.AreEqual(10, clone.Children.Count);
              for (int i = 0; i < 10; i++)
              {
            Assert.IsNotNull(clone.Children[i]);
            Assert.AreNotSame(compositeShape.Children[i], clone.Children[i]);
            Assert.IsTrue(clone.Children[i] is GeometricObject);
            Assert.AreEqual(compositeShape.Children[i].Pose, clone.Children[i].Pose);
            Assert.IsNotNull(clone.Children[i].Shape);
            Assert.AreNotSame(compositeShape.Children[i].Shape, clone.Children[i].Shape);
            Assert.IsTrue(clone.Children[i].Shape is PointShape);
            Assert.AreEqual(((PointShape)compositeShape.Children[i].Shape).Position, ((PointShape)clone.Children[i].Shape).Position);
              }

              Assert.AreEqual(compositeShape.GetAabb(Pose.Identity).Minimum, clone.GetAabb(Pose.Identity).Minimum);
              Assert.AreEqual(compositeShape.GetAabb(Pose.Identity).Maximum, clone.GetAabb(Pose.Identity).Maximum);
        }
Exemple #2
0
        public void Clone()
        {
            CompositeShape compositeShape = new CompositeShape();

            for (int i = 0; i < 10; i++)
            {
                Pose            pose     = new Pose(new Vector3(i, i, i));
                PointShape      point    = new PointShape(i, i, i);
                GeometricObject geometry = new GeometricObject(point, pose);
                compositeShape.Children.Add(geometry);
            }

            CompositeShape clone = compositeShape.Clone() as CompositeShape;

            Assert.IsNotNull(clone);
            Assert.AreEqual(10, clone.Children.Count);
            for (int i = 0; i < 10; i++)
            {
                Assert.IsNotNull(clone.Children[i]);
                Assert.AreNotSame(compositeShape.Children[i], clone.Children[i]);
                Assert.IsTrue(clone.Children[i] is GeometricObject);
                Assert.AreEqual(compositeShape.Children[i].Pose, clone.Children[i].Pose);
                Assert.IsNotNull(clone.Children[i].Shape);
                Assert.AreNotSame(compositeShape.Children[i].Shape, clone.Children[i].Shape);
                Assert.IsTrue(clone.Children[i].Shape is PointShape);
                Assert.AreEqual(((PointShape)compositeShape.Children[i].Shape).Position, ((PointShape)clone.Children[i].Shape).Position);
            }

            Assert.AreEqual(compositeShape.GetAabb(Pose.Identity).Minimum, clone.GetAabb(Pose.Identity).Minimum);
            Assert.AreEqual(compositeShape.GetAabb(Pose.Identity).Maximum, clone.GetAabb(Pose.Identity).Maximum);
        }