using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography.X509Certificates; using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Services.Forces; namespace StructureHelperCommon.Models.Forces { /// public class ForceCombinationList : IForceCombinationList { readonly IUpdateStrategy updateStrategy = new ActionUpdateStrategy(); /// public Guid Id { get; } /// public string Name { get; set; } /// public bool SetInGravityCenter { get; set; } /// public IPoint2D ForcePoint { get; set; } /// public List DesignForces { get; private set; } public ForceCombinationList(Guid id) { Id = id; SetInGravityCenter = true; ForcePoint = new Point2D() { X = 0, Y = 0 }; DesignForces = new List { new DesignForceTuple(LimitStates.ULS, CalcTerms.ShortTerm), new DesignForceTuple(LimitStates.ULS, CalcTerms.LongTerm), new DesignForceTuple(LimitStates.SLS, CalcTerms.ShortTerm), new DesignForceTuple(LimitStates.SLS, CalcTerms.LongTerm) }; } public ForceCombinationList() : this (Guid.NewGuid()) { } /// public object Clone() { var newItem = new ForceCombinationList(); updateStrategy.Update(newItem, this); return newItem; } /// public IForceCombinationList GetCombinations() { var result = Clone() as IForceCombinationList; result.DesignForces.Clear(); var limitStates = new List() { LimitStates.ULS, LimitStates.SLS }; var calcTerms = new List() { CalcTerms.ShortTerm, CalcTerms.LongTerm }; foreach (var limitState in limitStates) { foreach (var calcTerm in calcTerms) { var designForceTuple = new DesignForceTuple() { LimitState = limitState, CalcTerm = calcTerm }; var forceTupleList = DesignForces.Where(x => x.LimitState == limitState & x.CalcTerm == calcTerm); foreach (var item in forceTupleList) { designForceTuple.ForceTuple = ForceTupleService.SumTuples(designForceTuple.ForceTuple, item.ForceTuple) as ForceTuple; } result.DesignForces.Add(designForceTuple); } } return result; } } }