Beispiel #1
0
        public void WeldVertices()
        {
            TriangleMesh mesh = new TriangleMesh();
              Assert.AreEqual(0, mesh.WeldVertices());

              mesh.Add(new Triangle(new Vector3F(1, 2, 3), new Vector3F(3, 4, 5), new Vector3F(1.00001f, 2.00001f, 3f)), false);

              Assert.AreEqual(3, mesh.Vertices.Count);

              Assert.Throws(typeof(ArgumentOutOfRangeException), () => mesh.WeldVertices(-0.1f));

              Assert.AreEqual(1, mesh.WeldVertices(0.0001f));
              Assert.AreEqual(2, mesh.Vertices.Count);

              var w = Stopwatch.StartNew();
              mesh = new SphereShape(0.5f).GetMesh(0.001f, 7);
              w.Stop();
              //Assert.AreEqual(0, w.Elapsed.TotalMilliseconds);

              for (int i = 0; i < mesh.Vertices.Count; i++)
              {
            for (int j = i + 1; j < mesh.Vertices.Count; j++)
            {
              Assert.IsFalse(Vector3F.AreNumericallyEqual(mesh.Vertices[i], mesh.Vertices[j]));
            }
              }

              // Second time does nothing.
              Assert.AreEqual(0, mesh.WeldVertices());
        }