< Summary

Line coverage
98%
Covered lines: 54
Uncovered lines: 1
Coverable lines: 55
Total lines: 117
Line coverage: 98.1%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
get_HeaderText()100%11100%
get_Vertices()100%11100%
get_ParameterSpaceVertices()100%11100%
get_VertexNormals()100%11100%
get_TextureVertices()100%11100%
get_Points()100%11100%
get_Lines()100%11100%
get_Faces()100%11100%
get_Curves()100%11100%
get_Curves2D()100%11100%
get_Surfaces()100%11100%
get_SurfaceConnections()100%11100%
get_DefaultGroup()100%11100%
get_Groups()100%11100%
get_MergingGroupResolutions()100%11100%
get_MapLibraries()100%11100%
get_MaterialLibraries()100%11100%
get_ShadowObjectFileName()100%11100%
get_TraceObjectFileName()100%11100%
FromFile(...)100%22100%
FromStream(...)100%11100%
WriteTo(...)50%2.02283.33%
WriteTo(...)100%22100%

File(s)

https://raw.githubusercontent.com/JeremyAnsel/JeremyAnsel.Media.WavefrontObj/dbbfcd213b7c54f49194f82fcd56e790cca193c3/JeremyAnsel.Media.WavefrontObj/JeremyAnsel.Media.WavefrontObj/ObjFile.cs

#LineLine coverage
 1// <copyright file="ObjFile.cs" company="Jérémy Ansel">
 2// Copyright (c) 2017, 2019 Jérémy Ansel
 3// </copyright>
 4// <license>
 5// Licensed under the MIT license. See LICENSE.txt
 6// </license>
 7
 8using System.Text;
 9
 10namespace JeremyAnsel.Media.WavefrontObj
 11{
 12    public class ObjFile
 13    {
 103514        public ObjFile()
 15        {
 103516            this.Vertices = new List<ObjVertex>();
 103517            this.ParameterSpaceVertices = new List<ObjVector3>();
 103518            this.VertexNormals = new List<ObjVector3>();
 103519            this.TextureVertices = new List<ObjVector3>();
 103520            this.Points = new List<ObjPoint>();
 103521            this.Lines = new List<ObjLine>();
 103522            this.Faces = new List<ObjFace>();
 103523            this.Curves = new List<ObjCurve>();
 103524            this.Curves2D = new List<ObjCurve2D>();
 103525            this.Surfaces = new List<ObjSurface>();
 103526            this.SurfaceConnections = new List<ObjSurfaceConnection>();
 103527            this.DefaultGroup = new ObjGroup();
 103528            this.Groups = new List<ObjGroup>();
 103529            this.MergingGroupResolutions = new Dictionary<int, float>();
 103530            this.MapLibraries = new List<string>();
 103531            this.MaterialLibraries = new List<string>();
 103532        }
 33
 52234        public string? HeaderText { get; set; }
 35
 232536        public List<ObjVertex> Vertices { get; private set; }
 37
 182438        public List<ObjVector3> ParameterSpaceVertices { get; private set; }
 39
 129640        public List<ObjVector3> VertexNormals { get; private set; }
 41
 131742        public List<ObjVector3> TextureVertices { get; private set; }
 43
 151844        public List<ObjPoint> Points { get; private set; }
 45
 132046        public List<ObjLine> Lines { get; private set; }
 47
 141048        public List<ObjFace> Faces { get; private set; }
 49
 174650        public List<ObjCurve> Curves { get; private set; }
 51
 155752        public List<ObjCurve2D> Curves2D { get; private set; }
 53
 144954        public List<ObjSurface> Surfaces { get; private set; }
 55
 128456        public List<ObjSurfaceConnection> SurfaceConnections { get; private set; }
 57
 148858        public ObjGroup DefaultGroup { get; private set; }
 59
 149460        public List<ObjGroup> Groups { get; private set; }
 61
 107762        public Dictionary<int, float> MergingGroupResolutions { get; private set; }
 63
 127564        public List<string> MapLibraries { get; private set; }
 65
 126966        public List<string> MaterialLibraries { get; private set; }
 67
 25268        public string? ShadowObjectFileName { get; set; }
 69
 22870        public string? TraceObjectFileName { get; set; }
 71
 72        public static ObjFile FromFile(string? path)
 73        {
 674            if (path == null)
 75            {
 376                throw new ArgumentNullException(nameof(path));
 77            }
 78
 379            using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
 80            {
 381                return ObjFileReader.FromStream(stream);
 82            }
 383        }
 84
 85        public static ObjFile FromStream(Stream? stream)
 86        {
 81687            return ObjFileReader.FromStream(stream);
 88        }
 89
 90        public void WriteTo(string? path)
 91        {
 392            if (path == null)
 93            {
 094                throw new ArgumentNullException(nameof(path));
 95            }
 96
 397            using (var writer = new StreamWriter(path))
 98            {
 399                ObjFileWriter.Write(this, writer);
 3100            }
 3101        }
 102
 103        public void WriteTo(Stream? stream)
 104        {
 216105            if (stream == null)
 106            {
 3107                throw new ArgumentNullException(nameof(stream));
 108            }
 109
 213110            using (var writer = new StreamWriter(stream, new UTF8Encoding(false, true), 1024, true))
 111            {
 213112                ObjFileWriter.Write(this, writer);
 213113            }
 213114        }
 115    }
 116}
 117