< Summary

Information
Class: JeremyAnsel.Media.WavefrontObj.ObjFileReaderContext
Assembly: JeremyAnsel.Media.WavefrontObj
File(s): C:\projects\jeremyansel-media-wavefrontobj\JeremyAnsel.Media.WavefrontObj\JeremyAnsel.Media.WavefrontObj\ObjFileReaderContext.cs
Line coverage
100%
Covered lines: 59
Uncovered lines: 0
Coverable lines: 59
Total lines: 121
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

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Settings()100%11100%
get_ObjectName()100%11100%
set_ObjectName(...)100%11100%
get_LevelOfDetail()100%11100%
set_LevelOfDetail(...)100%11100%
get_MapName()100%11100%
set_MapName(...)100%11100%
get_MaterialName()100%11100%
set_MaterialName(...)100%11100%
get_SmoothingGroupNumber()100%11100%
set_SmoothingGroupNumber(...)100%11100%
get_IsBevelInterpolationEnabled()100%11100%
set_IsBevelInterpolationEnabled(...)100%11100%
get_IsColorInterpolationEnabled()100%11100%
set_IsColorInterpolationEnabled(...)100%11100%
get_IsDissolveInterpolationEnabled()100%11100%
set_IsDissolveInterpolationEnabled(...)100%11100%
get_MergingGroupNumber()100%11100%
set_MergingGroupNumber(...)100%11100%
get_FreeFormType()100%11100%
set_FreeFormType(...)100%11100%
get_IsRationalForm()100%11100%
set_IsRationalForm(...)100%11100%
get_DegreeU()100%11100%
set_DegreeU(...)100%11100%
get_DegreeV()100%11100%
set_DegreeV(...)100%11100%
get_BasicMatrixU()100%11100%
set_BasicMatrixU(...)100%11100%
get_BasicMatrixV()100%11100%
set_BasicMatrixV(...)100%11100%
get_StepU()100%11100%
set_StepU(...)100%11100%
get_StepV()100%11100%
set_StepV(...)100%11100%
get_CurveApproximationTechnique()100%11100%
set_CurveApproximationTechnique(...)100%11100%
get_SurfaceApproximationTechnique()100%11100%
set_SurfaceApproximationTechnique(...)100%11100%
get_CurrentFreeFormElement()100%11100%
set_CurrentFreeFormElement(...)100%11100%
get_GroupNames()100%11100%
set_GroupNames(...)100%11100%
GetCurrentGroups()100%66100%
ApplyAttributesToElement(...)100%11100%
ApplyAttributesToPolygonalElement(...)100%11100%
ApplyAttributesToFreeFormElement(...)100%11100%

File(s)

C:\projects\jeremyansel-media-wavefrontobj\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
 10internal class ObjFileReaderContext
 11{
 12    private readonly ObjFile _obj;
 13
 414    public ObjFileReaderContext(ObjFile obj, ObjFileReaderSettings settings)
 15    {
 416        _obj = obj;
 417        Settings = settings;
 18
 419        GroupNames = new List<string>();
 420    }
 21
 422    public ObjFileReaderSettings Settings { get; }
 23
 424    public string? ObjectName { get; set; }
 25
 426    public int LevelOfDetail { get; set; }
 27
 428    public string? MapName { get; set; }
 29
 430    public string? MaterialName { get; set; }
 31
 432    public long SmoothingGroupNumber { get; set; }
 33
 434    public bool IsBevelInterpolationEnabled { get; set; }
 35
 436    public bool IsColorInterpolationEnabled { get; set; }
 37
 438    public bool IsDissolveInterpolationEnabled { get; set; }
 39
 440    public int MergingGroupNumber { get; set; }
 41
 442    public ObjFreeFormType FreeFormType { get; set; }
 43
 444    public bool IsRationalForm { get; set; }
 45
 446    public int DegreeU { get; set; }
 47
 448    public int DegreeV { get; set; }
 49
 450    public float[]? BasicMatrixU { get; set; }
 51
 452    public float[]? BasicMatrixV { get; set; }
 53
 454    public float StepU { get; set; }
 55
 456    public float StepV { get; set; }
 57
 458    public ObjApproximationTechnique? CurveApproximationTechnique { get; set; }
 59
 460    public ObjApproximationTechnique? SurfaceApproximationTechnique { get; set; }
 61
 462    public ObjFreeFormElement? CurrentFreeFormElement { get; set; }
 63
 464    public List<string> GroupNames { get; private set; }
 65
 66    public List<ObjGroup> GetCurrentGroups()
 67    {
 468        var groups = new List<ObjGroup>();
 69
 470        foreach (var name in this.GroupNames)
 71        {
 472            var group = _obj.Groups.FirstOrDefault(t => string.Equals(t.Name, name, StringComparison.Ordinal));
 73
 474            if (group == null)
 75            {
 476                group = new ObjGroup(name);
 477                _obj.Groups.Add(group);
 78            }
 79
 480            groups.Add(group);
 81        }
 82
 483        if (groups.Count == 0)
 84        {
 485            groups.Add(_obj.DefaultGroup);
 86        }
 87
 488        return groups;
 89    }
 90
 91    public void ApplyAttributesToElement(ObjElement element)
 92    {
 493        element.ObjectName = this.ObjectName;
 494        element.LevelOfDetail = this.LevelOfDetail;
 495        element.MapName = this.MapName;
 496        element.MaterialName = this.MaterialName;
 497    }
 98
 99    public void ApplyAttributesToPolygonalElement(ObjPolygonalElement element)
 100    {
 4101        element.SmoothingGroupNumber = this.SmoothingGroupNumber;
 4102        element.IsBevelInterpolationEnabled = this.IsBevelInterpolationEnabled;
 4103        element.IsColorInterpolationEnabled = this.IsColorInterpolationEnabled;
 4104        element.IsDissolveInterpolationEnabled = this.IsDissolveInterpolationEnabled;
 4105    }
 106
 107    public void ApplyAttributesToFreeFormElement(ObjFreeFormElement element)
 108    {
 4109        element.MergingGroupNumber = this.MergingGroupNumber;
 4110        element.FreeFormType = this.FreeFormType;
 4111        element.IsRationalForm = this.IsRationalForm;
 4112        element.DegreeU = this.DegreeU;
 4113        element.DegreeV = this.DegreeV;
 4114        element.BasicMatrixU = this.BasicMatrixU;
 4115        element.BasicMatrixV = this.BasicMatrixV;
 4116        element.StepU = this.StepU;
 4117        element.StepV = this.StepV;
 4118        element.CurveApproximationTechnique = this.CurveApproximationTechnique;
 4119        element.SurfaceApproximationTechnique = this.SurfaceApproximationTechnique;
 4120    }
 121}

Methods/Properties

.ctor(JeremyAnsel.Media.WavefrontObj.ObjFile, JeremyAnsel.Media.WavefrontObj.ObjFileReaderSettings)
get_Settings()
get_ObjectName()
set_ObjectName(string)
get_LevelOfDetail()
set_LevelOfDetail(int)
get_MapName()
set_MapName(string)
get_MaterialName()
set_MaterialName(string)
get_SmoothingGroupNumber()
set_SmoothingGroupNumber(long)
get_IsBevelInterpolationEnabled()
set_IsBevelInterpolationEnabled(bool)
get_IsColorInterpolationEnabled()
set_IsColorInterpolationEnabled(bool)
get_IsDissolveInterpolationEnabled()
set_IsDissolveInterpolationEnabled(bool)
get_MergingGroupNumber()
set_MergingGroupNumber(int)
get_FreeFormType()
set_FreeFormType(JeremyAnsel.Media.WavefrontObj.ObjFreeFormType)
get_IsRationalForm()
set_IsRationalForm(bool)
get_DegreeU()
set_DegreeU(int)
get_DegreeV()
set_DegreeV(int)
get_BasicMatrixU()
set_BasicMatrixU(float[])
get_BasicMatrixV()
set_BasicMatrixV(float[])
get_StepU()
set_StepU(float)
get_StepV()
set_StepV(float)
get_CurveApproximationTechnique()
set_CurveApproximationTechnique(JeremyAnsel.Media.WavefrontObj.ObjApproximationTechnique)
get_SurfaceApproximationTechnique()
set_SurfaceApproximationTechnique(JeremyAnsel.Media.WavefrontObj.ObjApproximationTechnique)
get_CurrentFreeFormElement()
set_CurrentFreeFormElement(JeremyAnsel.Media.WavefrontObj.ObjFreeFormElement)
get_GroupNames()
set_GroupNames(System.Collections.Generic.List<string>)
GetCurrentGroups()
ApplyAttributesToElement(JeremyAnsel.Media.WavefrontObj.ObjElement)
ApplyAttributesToPolygonalElement(JeremyAnsel.Media.WavefrontObj.ObjPolygonalElement)
ApplyAttributesToFreeFormElement(JeremyAnsel.Media.WavefrontObj.ObjFreeFormElement)