< Summary

Line coverage
100%
Covered lines: 59
Uncovered lines: 0
Coverable lines: 59
Total lines: 123
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

https://raw.githubusercontent.com/JeremyAnsel/JeremyAnsel.Media.WavefrontObj/7b5b951766c69f14731a856f32198cdbf1fc6847/JeremyAnsel.Media.WavefrontObj/JeremyAnsel.Media.WavefrontObj/ObjFileReaderContext.cs

#LineLine coverage
 1// <copyright file="ObjFileReaderContext.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
 8namespace JeremyAnsel.Media.WavefrontObj
 9{
 10    internal class ObjFileReaderContext
 11    {
 12        private ObjFile obj;
 13
 114014        public ObjFileReaderContext(ObjFile obj, ObjFileReaderSettings settings)
 15        {
 114016            this.obj = obj;
 114017            this.Settings = settings;
 18
 114019            this.GroupNames = new List<string>();
 114020        }
 21
 11622        public ObjFileReaderSettings Settings { get; }
 23
 60824        public string? ObjectName { get; set; }
 25
 60426        public int LevelOfDetail { get; set; }
 27
 60828        public string? MapName { get; set; }
 29
 61230        public string? MaterialName { get; set; }
 31
 15232        public long SmoothingGroupNumber { get; set; }
 33
 14834        public bool IsBevelInterpolationEnabled { get; set; }
 35
 14836        public bool IsColorInterpolationEnabled { get; set; }
 37
 14838        public bool IsDissolveInterpolationEnabled { get; set; }
 39
 53640        public int MergingGroupNumber { get; set; }
 41
 48842        public ObjFreeFormType FreeFormType { get; set; }
 43
 49644        public bool IsRationalForm { get; set; }
 45
 48046        public int DegreeU { get; set; }
 47
 48048        public int DegreeV { get; set; }
 49
 45250        public float[]? BasicMatrixU { get; set; }
 51
 45252        public float[]? BasicMatrixV { get; set; }
 53
 45654        public float StepU { get; set; }
 55
 45656        public float StepV { get; set; }
 57
 48458        public ObjApproximationTechnique? CurveApproximationTechnique { get; set; }
 59
 48860        public ObjApproximationTechnique? SurfaceApproximationTechnique { get; set; }
 61
 76862        public ObjFreeFormElement? CurrentFreeFormElement { get; set; }
 63
 204864        public List<string> GroupNames { get; private set; }
 65
 66        public List<ObjGroup> GetCurrentGroups()
 67        {
 68868            var groups = new List<ObjGroup>();
 69
 164070            foreach (var name in this.GroupNames)
 71            {
 18872                var group = obj.Groups.FirstOrDefault(t => string.Equals(t.Name, name, StringComparison.Ordinal));
 73
 13274                if (group == null)
 75                {
 10476                    group = new ObjGroup(name);
 10477                    obj.Groups.Add(group);
 78                }
 79
 13280                groups.Add(group);
 81            }
 82
 68883            if (groups.Count == 0)
 84            {
 58085                groups.Add(obj.DefaultGroup);
 86            }
 87
 68888            return groups;
 89        }
 90
 91        public void ApplyAttributesToElement(ObjElement element)
 92        {
 57293            element.ObjectName = this.ObjectName;
 57294            element.LevelOfDetail = this.LevelOfDetail;
 57295            element.MapName = this.MapName;
 57296            element.MaterialName = this.MaterialName;
 57297        }
 98
 99        public void ApplyAttributesToPolygonalElement(ObjPolygonalElement element)
 100        {
 124101            element.SmoothingGroupNumber = this.SmoothingGroupNumber;
 124102            element.IsBevelInterpolationEnabled = this.IsBevelInterpolationEnabled;
 124103            element.IsColorInterpolationEnabled = this.IsColorInterpolationEnabled;
 124104            element.IsDissolveInterpolationEnabled = this.IsDissolveInterpolationEnabled;
 124105        }
 106
 107        public void ApplyAttributesToFreeFormElement(ObjFreeFormElement element)
 108        {
 448109            element.MergingGroupNumber = this.MergingGroupNumber;
 448110            element.FreeFormType = this.FreeFormType;
 448111            element.IsRationalForm = this.IsRationalForm;
 448112            element.DegreeU = this.DegreeU;
 448113            element.DegreeV = this.DegreeV;
 448114            element.BasicMatrixU = this.BasicMatrixU;
 448115            element.BasicMatrixV = this.BasicMatrixV;
 448116            element.StepU = this.StepU;
 448117            element.StepV = this.StepV;
 448118            element.CurveApproximationTechnique = this.CurveApproximationTechnique;
 448119            element.SurfaceApproximationTechnique = this.SurfaceApproximationTechnique;
 448120        }
 121    }
 122}
 123