< Summary

Line coverage
100%
Covered lines: 57
Uncovered lines: 0
Coverable lines: 57
Total lines: 120
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/dbbfcd213b7c54f49194f82fcd56e790cca193c3/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
 81614        public ObjFileReaderContext(ObjFile obj)
 15        {
 81616            this.obj = obj;
 17
 81618            this.GroupNames = new List<string>();
 81619        }
 20
 45321        public string? ObjectName { get; set; }
 22
 45023        public int LevelOfDetail { get; set; }
 24
 45325        public string? MapName { get; set; }
 26
 45327        public string? MaterialName { get; set; }
 28
 11129        public long SmoothingGroupNumber { get; set; }
 30
 10831        public bool IsBevelInterpolationEnabled { get; set; }
 32
 10833        public bool IsColorInterpolationEnabled { get; set; }
 34
 10835        public bool IsDissolveInterpolationEnabled { get; set; }
 36
 40237        public int MergingGroupNumber { get; set; }
 38
 36639        public ObjFreeFormType FreeFormType { get; set; }
 40
 37241        public bool IsRationalForm { get; set; }
 42
 36043        public int DegreeU { get; set; }
 44
 36045        public int DegreeV { get; set; }
 46
 33947        public float[]? BasicMatrixU { get; set; }
 48
 33949        public float[]? BasicMatrixV { get; set; }
 50
 34251        public float StepU { get; set; }
 52
 34253        public float StepV { get; set; }
 54
 36355        public ObjApproximationTechnique? CurveApproximationTechnique { get; set; }
 56
 36657        public ObjApproximationTechnique? SurfaceApproximationTechnique { get; set; }
 58
 57659        public ObjFreeFormElement? CurrentFreeFormElement { get; set; }
 60
 142561        public List<string> GroupNames { get; private set; }
 62
 63        public List<ObjGroup> GetCurrentGroups()
 64        {
 49265            var groups = new List<ObjGroup>();
 66
 112867            foreach (var name in this.GroupNames)
 68            {
 10869                var group = obj.Groups.FirstOrDefault(t => string.Equals(t.Name, name, StringComparison.Ordinal));
 70
 7271                if (group == null)
 72                {
 5173                    group = new ObjGroup(name);
 5174                    obj.Groups.Add(group);
 75                }
 76
 7277                groups.Add(group);
 78            }
 79
 49280            if (groups.Count == 0)
 81            {
 43282                groups.Add(obj.DefaultGroup);
 83            }
 84
 49285            return groups;
 86        }
 87
 88        public void ApplyAttributesToElement(ObjElement element)
 89        {
 42690            element.ObjectName = this.ObjectName;
 42691            element.LevelOfDetail = this.LevelOfDetail;
 42692            element.MapName = this.MapName;
 42693            element.MaterialName = this.MaterialName;
 42694        }
 95
 96        public void ApplyAttributesToPolygonalElement(ObjPolygonalElement element)
 97        {
 9098            element.SmoothingGroupNumber = this.SmoothingGroupNumber;
 9099            element.IsBevelInterpolationEnabled = this.IsBevelInterpolationEnabled;
 90100            element.IsColorInterpolationEnabled = this.IsColorInterpolationEnabled;
 90101            element.IsDissolveInterpolationEnabled = this.IsDissolveInterpolationEnabled;
 90102        }
 103
 104        public void ApplyAttributesToFreeFormElement(ObjFreeFormElement element)
 105        {
 336106            element.MergingGroupNumber = this.MergingGroupNumber;
 336107            element.FreeFormType = this.FreeFormType;
 336108            element.IsRationalForm = this.IsRationalForm;
 336109            element.DegreeU = this.DegreeU;
 336110            element.DegreeV = this.DegreeV;
 336111            element.BasicMatrixU = this.BasicMatrixU;
 336112            element.BasicMatrixV = this.BasicMatrixV;
 336113            element.StepU = this.StepU;
 336114            element.StepV = this.StepV;
 336115            element.CurveApproximationTechnique = this.CurveApproximationTechnique;
 336116            element.SurfaceApproximationTechnique = this.SurfaceApproximationTechnique;
 336117        }
 118    }
 119}
 120