Exemplo n.º 1
0
        public static void SimpleCreateG3DTest()
        {
            // Should be a tetrahedron
            var vertexBuffer = TestGeometries.TestTetrahedronVertices.ToVertexAttribute();
            var indexBuffer  = TestGeometries.TestTetrahedronIndices.ToIndexAttribute();

            CheckAttribute(vertexBuffer, Association.assoc_vertex, AttributeType.attr_vertex, DataType.dt_float32, 3);
            CheckAttribute(indexBuffer, Association.assoc_corner, AttributeType.attr_index, DataType.dt_int32, 1);
            var g3d = G3D.Create(vertexBuffer, indexBuffer);

            Assert.AreEqual(4, vertexBuffer.Count);
            Assert.AreEqual(12, indexBuffer.Count);
            var g = g3d.ToIGeometry();

            CheckTestTetrahedron(g);
            var b  = g.ToBFast();
            var g2 = b.ToG3D();

            CheckTestTetrahedron(g2.ToIGeometry());
            var tmpPath = Path.GetTempFileName();

            g.WriteG3D(tmpPath);
            var g3 = G3DExtensions.ReadFromFile(tmpPath);

            CheckTestTetrahedron(g3.ToIGeometry());
        }
Exemplo n.º 2
0
        public static void TestWritingGeometry(IGeometry g, string outputFolder, string fileName)
        {
            // Try writing to an OBJ: using DMesh, using Helix, using my OBJ writer
            // Try writing to a G3D
            // Time the different writing
            // Try conversions back from the different forms. and the reading.
            //
            TestGeometries.OutputIGeometryStats(g);

            var baseFileName   = Path.GetFileName(fileName);
            var outputFileName = Path.Combine(outputFolder, baseFileName);

            Console.WriteLine("Testing Ara 3D native writer");
            TestWritingFile(outputFileName + ".ara.obj", f => g.WriteObj(f, false));

            var g3dFileName = outputFileName + ".ara.g3d";

            TestWritingFile(g3dFileName, g.WriteG3D);

            Console.WriteLine("Testing G3 Sharp writer");
            TestWritingFile(outputFileName + ".g3.obj", f => g.ToG3Sharp().WriteFile(f));
            TestWritingFile(outputFileName + ".g3.stl", f => g.ToG3Sharp().WriteFileBinary(f));

            // TODO: test writing using Helix

            // Check that reading the G3D back-in yields the same IGeometry
            var g2 = Util.TimeIt(() => G3DExtensions.ReadFromFile(g3dFileName).ToIGeometry(), "Reading time for G3D");

            TestGeometries.CompareGeometries(g, g2);
        }