Exemplo n.º 1
0
        public void ReadWrite(string modelPath)
        {
            // Arrange
            var reader = new StlBinaryContentReader();
            var writer = new StlBinaryContentWriter();
            var file   = File.ReadAllBytes(modelPath);
            var stream = new MemoryStream(file);

            // Act
            var input  = reader.Read(stream);
            var output = writer.Write(input);

            // Assert
            Assert.Equal(file.Length, output.Length);
        }
Exemplo n.º 2
0
        public void Write_Operation_Subtract()
        {
            // Arrange
            var reader = new StlBinaryContentReader();
            var writer = new StlBinaryContentWriter();

            var file   = File.ReadAllBytes("./assets/models/shape_operation_subtract.stl");
            var stream = new MemoryStream(file);
            var input  = reader.Read(stream);

            // Act
            var shape1 = new Cube(new Vector3(0, 0, 0), new Vector3(1, 1, 1));
            var shape2 = new Cube(new Vector3(0.8f, 0.8f, 0), new Vector3(1, 1, 1));
            var shape  = shape1.Do(ShapeOperation.Subtract, shape2);

            var output = writer.Write(shape);

            // Assert
            Assert.Equal(file.Length, output.Length);
            Assert.Null(input.Name);
            Assert.Equal(input.Vertices.Length, shape.Vertices.Length);
            Assert.Equal(input.Indices.Length, shape.Indices.Length);
        }