< 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/636b700b450d7d3262bf9218a7cc67966be4ced8/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
 112414        public ObjFileReaderContext(ObjFile obj, ObjFileReaderSettings settings)
 15        {
 112416            this.obj = obj;
 112417            this.Settings = settings;
 18
 112419            this.GroupNames = new List<string>();
 112420        }
 21
 11622        public ObjFileReaderSettings Settings { get; }
 23
 60424        public string? ObjectName { get; set; }
 25
 60026        public int LevelOfDetail { get; set; }
 27
 60428        public string? MapName { get; set; }
 29
 60430        public string? MaterialName { get; set; }
 31
 14832        public long SmoothingGroupNumber { get; set; }
 33
 14434        public bool IsBevelInterpolationEnabled { get; set; }
 35
 14436        public bool IsColorInterpolationEnabled { get; set; }
 37
 14438        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
 202864        public List<string> GroupNames { get; private set; }
 65
 66        public List<ObjGroup> GetCurrentGroups()
 67        {
 68468            var groups = new List<ObjGroup>();
 69
 163270            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
 68483            if (groups.Count == 0)
 84            {
 57685                groups.Add(obj.DefaultGroup);
 86            }
 87
 68488            return groups;
 89        }
 90
 91        public void ApplyAttributesToElement(ObjElement element)
 92        {
 56893            element.ObjectName = this.ObjectName;
 56894            element.LevelOfDetail = this.LevelOfDetail;
 56895            element.MapName = this.MapName;
 56896            element.MaterialName = this.MaterialName;
 56897        }
 98
 99        public void ApplyAttributesToPolygonalElement(ObjPolygonalElement element)
 100        {
 120101            element.SmoothingGroupNumber = this.SmoothingGroupNumber;
 120102            element.IsBevelInterpolationEnabled = this.IsBevelInterpolationEnabled;
 120103            element.IsColorInterpolationEnabled = this.IsColorInterpolationEnabled;
 120104            element.IsDissolveInterpolationEnabled = this.IsDissolveInterpolationEnabled;
 120105        }
 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