示例#1
0
        public void ToStream_ToFile()
        {
            // Arrange
            IMesh          mesh          = CreateMesh4();
            IMeshConverter meshConverter = new StlMeshConverter();

            // Act
            using (Stream stream = meshConverter.ToStream(mesh))
                using (FileStream fileStream = File.Create(@"c:\Temp\testout.stl"))
                {
                    stream.CopyTo(fileStream);
                }
        }
示例#2
0
        public void ToStream_OneFace_4Vertices()
        {
            // Arrange
            IMesh          mesh          = CreateMesh4();
            IMeshConverter meshConverter = new StlMeshConverter();

            // Act
            Stream stream = meshConverter.ToStream(mesh);

            // Assert
            byte[] bytes = StreamHelper.GetAllBytes(stream);
            Assert.AreEqual(ComputeExpectedNumberOfBytes(2), bytes.Length);

            byte[] numberOfTriangles = bytes.Skip(80).Take(4).ToArray();
            Assert.AreEqual(2, numberOfTriangles[0]);
            Assert.AreEqual(0, numberOfTriangles[1]);
            Assert.AreEqual(0, numberOfTriangles[2]);
            Assert.AreEqual(0, numberOfTriangles[3]);

            stream.Dispose();
        }