Exemple #1
0
        public void WriteBinary()
        {
            STLDocument stl1 = new STLDocument("WriteBinary", new List <Facet>()
            {
                new Facet(new Normal(0, 0, 1), new List <Vertex>()
                {
                    new Vertex(0, 0, 0),
                    new Vertex(-10, -10, 0),
                    new Vertex(-10, 0, 0)
                }, 0)
            });
            STLDocument stl2 = null;

            byte[] stl1Data = null;
            byte[] stl2Data = null;

            using (MemoryStream stream = new MemoryStream())
            {
                stl1.WriteBinary(stream);
                stl1Data = stream.ToArray();
            }

            using (MemoryStream stream = new MemoryStream(stl1Data))
            {
                stl2     = STLDocument.Read(stream);
                stl2Data = stream.ToArray();
            }

            Assert.IsTrue(stl1.Equals(stl2));
            Assert.IsTrue(stl1Data.SequenceEqual(stl2Data));
        }
        public void WriteBinary__ToStream__Then__Read__FromStream__ProducesSameDocument()
        {
            STLDocument stl1 = new STLDocument("WriteBinary", new List <Facet>()
            {
                new Facet(new Normal(0, 0, 1), new List <Vertex>()
                {
                    new Vertex(0, 0, 0),
                    new Vertex(-10, -10, 0),
                    new Vertex(-10, 0, 0)
                }, 0)
            });
            STLDocument stl2;

            byte[] stl1Data;
            byte[] stl2Data;

            using (var stream = new MemoryStream())
            {
                stl1.WriteBinary(stream);
                stl1Data = stream.ToArray();
            }

            using (var stream = new MemoryStream(stl1Data))
            {
                stl2     = STLDocument.Read(stream);
                stl2Data = stream.ToArray();
            }

            CompareSTLs(stl1, stl2, true);
            Assert.True(stl1Data.SequenceEqual(stl2Data));
        }
Exemple #3
0
        public void WriteBinary()
        {
            STLDocument stl1 = new STLDocument("WriteBinary", new List<Facet>()
            {
                new Facet(new Normal( 0, 0, 1), new List<Vertex>()
                {
                    new Vertex( 0, 0, 0),
                    new Vertex(-10, -10, 0),
                    new Vertex(-10, 0, 0)
                }, 0)
            });
            STLDocument stl2 = null;
            byte[] stl1Data = null;
            byte[] stl2Data = null;

            using (MemoryStream stream = new MemoryStream())
            {
                stl1.WriteBinary(stream);
                stl1Data = stream.ToArray();
            }

            using (MemoryStream stream = new MemoryStream(stl1Data))
            {
                stl2 = STLDocument.Read(stream);
                stl2Data = stream.ToArray();
            }

            Assert.IsTrue(stl1.Equals(stl2));
            Assert.IsTrue(stl1Data.SequenceEqual(stl2Data));
        }