Check logic for rebar ndm was created

This commit is contained in:
RedikultsevEvg
2024-08-02 23:29:50 +05:00
parent 35b4000f64
commit e7c7211f54
22 changed files with 675 additions and 82 deletions

View File

@@ -92,7 +92,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
My = point3D.Y
};
logic.Tuple = tuple;
logic.NdmCollection = Ndms;
logic.SectionNdmCollection = Ndms;
try
{
if (logger is not null)

View File

@@ -5,11 +5,13 @@ using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Materials;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.NdmCalculations.Primitives.Logics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Animation;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
@@ -19,6 +21,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
public class CheckCrackCalculatorInputDataLogic : ICheckInputDataLogic<CrackInputData>
{
private bool result;
private ICheckPrimitiveCollectionLogic checkPrimitiveCollectionLogic;
public CrackInputData InputData { get; set; }
@@ -26,11 +29,17 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
public string CheckResult { get; private set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public CheckCrackCalculatorInputDataLogic(CrackInputData inputData)
public CheckCrackCalculatorInputDataLogic(ICheckPrimitiveCollectionLogic checkPrimitiveCollectionLogic)
{
InputData = inputData;
CheckResult = string.Empty;
this.checkPrimitiveCollectionLogic = checkPrimitiveCollectionLogic;
}
public CheckCrackCalculatorInputDataLogic() : this (new CheckPrimitiveCollectionLogic())
{
}
public bool Check()
{
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug);
@@ -41,6 +50,22 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
return result;
}
private void CheckPrimitives()
{
if (checkPrimitiveCollectionLogic is null)
{
throw new StructureHelperException(ErrorStrings.ParameterIsNull + ": check primitive logic");
}
checkPrimitiveCollectionLogic.HasPrimitives = InputData;
checkPrimitiveCollectionLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger();
if (checkPrimitiveCollectionLogic.Check() == false)
{
result = false;
CheckResult += checkPrimitiveCollectionLogic.CheckResult;
TraceLogger?.AddMessage(checkPrimitiveCollectionLogic.CheckResult, TraceLogStatuses.Error);
}
}
private void CheckActions()
{
if (InputData.ForceActions is null || (!InputData.ForceActions.Any()))
@@ -52,54 +77,6 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
};
}
private void CheckPrimitives()
{
if (InputData.Primitives is null || (!InputData.Primitives.Any()))
{
result = false;
string message = "Calculator does not contain any primitives\n";
CheckResult += message;
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
}
else
{
foreach (var primitive in InputData.Primitives)
{
if (primitive is RebarPrimitive rebar)
{
CheckRebar(rebar);
}
}
}
}
private void CheckRebar(RebarPrimitive rebar)
{
if (rebar.HostPrimitive is null)
{
result = false;
string message = $"Primitive {rebar.Name} does not have a host\n";
CheckResult += message;
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
}
else
{
bool isPrimitivesContainRebarHost = InputData.Primitives.Contains(rebar.HostPrimitive);
if (isPrimitivesContainRebarHost == false)
{
result = false;
string message = $"Host {rebar.Name} ({rebar.HostPrimitive.Name}) is not included in primitives\n";
CheckResult += message;
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
}
}
if (rebar.HostPrimitive.HeadMaterial.HelperMaterial is not ICrackedMaterial)
{
result = false;
string message = $"Material of host of {rebar.Name} ({rebar.HostPrimitive.HeadMaterial.Name}) does not support cracking\n";
CheckResult += message;
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
}
}
}
}

View File

@@ -10,11 +10,15 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
/// <inheritdoc/>
public class CheckTupleCalculatorInputData : ICheckInputDataLogic<TupleCrackInputData>
{
private string checkResult;
private bool result;
const string userDataIsNull = "User crack input data is null";
private const string CollectionOfPrimitivesIsNull = "Collection does not have any primitives";
private string? checkResult;
private bool result;
/// <inheritdoc/>
public TupleCrackInputData InputData { get; set; }
@@ -22,15 +26,42 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
public IShiftTraceLogger? TraceLogger { get; set; }
public CheckTupleCalculatorInputData(TupleCrackInputData inputData)
{
InputData = inputData;
}
public bool Check()
{
result = true;
checkResult = string.Empty;
if (InputData is null)
{
result = false;
string v = ErrorStrings.ParameterIsNull + ": InputData";
checkResult += v;
TraceLogger?.AddMessage(v, TraceLogStatuses.Error);
return false;
}
CheckPrimitives();
CheckUserData();
return result;
}
private void CheckPrimitives()
{
if (InputData.Primitives is null || !InputData.Primitives.Any())
{
result = false;
checkResult += CollectionOfPrimitivesIsNull;
TraceLogger?.AddMessage(CollectionOfPrimitivesIsNull, TraceLogStatuses.Error);
}
}
private void CheckUserData()
{
if (InputData.UserCrackInputData is null)
{
result = false;
checkResult += userDataIsNull;
TraceLogger?.AddMessage(userDataIsNull, TraceLogStatuses.Error);
}
}
}
}

View File

@@ -37,12 +37,19 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
Name = string.Empty;
}
public CrackCalculator(CrackInputData inputData) : this(inputData, new CheckCrackCalculatorInputDataLogic(inputData)) { }
public CrackCalculator(CrackInputData inputData)
: this(inputData,
new CheckCrackCalculatorInputDataLogic()
{ InputData = inputData}
) { }
public object Clone()
{
CrackInputData crackInputData = new CrackInputData();
var checkDataLogic = new CheckCrackCalculatorInputDataLogic(InputData);
var checkDataLogic = new CheckCrackCalculatorInputDataLogic()
{
InputData = InputData
};
var newItem = new CrackCalculator(crackInputData, checkDataLogic);
updateStrategy.Update(newItem, this);
return newItem;

View File

@@ -9,13 +9,21 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
/// <inheritdoc/>
public class CrackedConcreteNdmLogic : ISectionCrackedLogic
{
/// <inheritdoc/>
public INdm ConcreteNdm { get; set; }
/// <inheritdoc/>
public IForceTuple Tuple { get; set; }
public IEnumerable<INdm> NdmCollection { get;set; }
/// <inheritdoc/>
public IEnumerable<INdm> CheckedNdmCollection { get; set; }
/// <inheritdoc/>
public IEnumerable<INdm> SectionNdmCollection { get; set; }
/// <inheritdoc/>
public IShiftTraceLogger? TraceLogger { get; set; }
/// <inheritdoc/>
public bool IsSectionCracked()
{
throw new NotImplementedException();

View File

@@ -33,7 +33,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
var actualTuple = ForceTupleService.InterpolateTuples(EndTuple, StartTuple, factor);
sectionCrackedLogic.Tuple = actualTuple;
sectionCrackedLogic.NdmCollection = NdmCollection;
sectionCrackedLogic.SectionNdmCollection = NdmCollection;
return sectionCrackedLogic.IsSectionCracked();
}
}

View File

@@ -9,10 +9,27 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
/// <summary>
/// Logic for checking collection of ndms for appearance of crack
/// </summary>
public interface ISectionCrackedLogic : ILogic
{
/// <summary>
/// Force tuple for checking of cracks appearence
/// </summary>
IForceTuple Tuple { get; set; }
IEnumerable<INdm> NdmCollection { get; set; }
/// <summary>
/// Collection of ndms which is checking fo cracking
/// </summary>
IEnumerable<INdm> CheckedNdmCollection { get; set; }
/// <summary>
/// Full ndms collection of cross-section
/// </summary>
IEnumerable<INdm> SectionNdmCollection { get; set; }
/// <summary>
/// Returns result of checking of cracks appearence
/// </summary>
/// <returns>True if Checked collectition contains cracked elements</returns>
bool IsSectionCracked();
}
}

View File

@@ -9,12 +9,13 @@ using System.Diagnostics.Eventing.Reader;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
/// <inheritdoc/>
internal class SectionCrackedLogic : ISectionCrackedLogic
{
static readonly IStressLogic stressLogic = new StressLogic();
public IForceTuple Tuple { get; set; }
public IEnumerable<INdm> CheckedNdmCollection { get; set; }
public IEnumerable<INdm> NdmCollection { get; set; }
public IEnumerable<INdm> SectionNdmCollection { get; set; }
public Accuracy Accuracy { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
@@ -39,7 +40,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{
Accuracy = Accuracy,
Tuple = Tuple,
NdmCollection = NdmCollection
NdmCollection = SectionNdmCollection
};
var calculator = new ForceTupleCalculator() { InputData = inputData };
if (TraceLogger is not null)
@@ -57,7 +58,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
IEnumerable<INdm> checkedNdmCollection;
if (CheckedNdmCollection is null)
{
checkedNdmCollection = NdmCollection;
checkedNdmCollection = SectionNdmCollection;
}
else
{

View File

@@ -150,7 +150,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{
var sectionCrackedLogic = new SectionCrackedLogic()
{
NdmCollection = ndms,
SectionNdmCollection = ndms,
CheckedNdmCollection = new List<INdm>() { concreteNdm },
//TraceLogger = TraceLogger?.GetSimilarTraceLogger(100)
};

View File

@@ -2,6 +2,7 @@
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
@@ -33,6 +34,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
private StrainTuple shortDefaultStrainTuple;
private double longLength;
private double shortLength;
private ICheckInputDataLogic<TupleCrackInputData> checkInputDataLogic;
public string Name { get; set; }
public TupleCrackInputData InputData { get; set; }
@@ -40,6 +42,16 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
public IShiftTraceLogger? TraceLogger { get; set; }
public TupleCrackCalculator(ICheckInputDataLogic<TupleCrackInputData> checkInputDataLogic)
{
this.checkInputDataLogic = checkInputDataLogic;
}
public TupleCrackCalculator() : this (new CheckTupleCalculatorInputData())
{
}
public void Run()
{
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
@@ -73,9 +85,12 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
private void ProcessCalculations()
{
CheckInputData();
Triangulate();
Triangulate();
if (CheckInputData() == false)
{
return;
}
longDefaultStrainTuple = CalcStrainMatrix(InputData.LongTermTuple as ForceTuple, crackableNdms);
shortDefaultStrainTuple = CalcStrainMatrix(InputData.LongTermTuple as ForceTuple, crackableNdms);
GetLengthBeetwenCracks();
@@ -183,12 +198,17 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
elasticNdms = triangulationLogic.GetElasticNdmCollection();
}
private void CheckInputData()
private bool CheckInputData()
{
if (InputData.Primitives is null || InputData.Primitives.Count == 0)
checkInputDataLogic.InputData = InputData;
if (checkInputDataLogic.Check() == false)
{
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": input data doesn't have any primitives");
}
result.IsValid = false;
result.Description += checkInputDataLogic.CheckResult;
TraceLogger?.AddMessage($"Input data is not correct: {checkInputDataLogic.CheckResult}", TraceLogStatuses.Error);
return false;
};
return true;
}
public object Clone()

View File

@@ -0,0 +1,11 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperLogics.NdmCalculations.Triangulations;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
public interface IRebarPrimitive : IPointPrimitive, IHasHostPrimitive
{
Ndm GetConcreteNdm(ITriangulationOptions triangulationOptions);
RebarNdm GetRebarNdm(ITriangulationOptions triangulationOptions);
}
}

View File

@@ -0,0 +1,92 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Materials;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
{
public class CheckPrimitiveCollectionLogic : ICheckPrimitiveCollectionLogic
{
private const string collectionDoesntHaveAnyPrimitives = "Calculator does not contain any primitives\n";
private const string checkRebarLogic = ": check rebar logic";
private string checkResult;
private bool result;
private ICheckRebarPrimitiveLogic checkRebarPrimitiveLogic;
public IHasPrimitives HasPrimitives { get; set; }
public string CheckResult => checkResult;
public IShiftTraceLogger? TraceLogger { get; set; }
public CheckPrimitiveCollectionLogic(IShiftTraceLogger shiftTraceLogger, ICheckRebarPrimitiveLogic checkRebarPrimitiveLogic)
{
TraceLogger = shiftTraceLogger;
this.checkRebarPrimitiveLogic = checkRebarPrimitiveLogic;
}
public CheckPrimitiveCollectionLogic() : this (new ShiftTraceLogger(), new CheckRebarPrimitiveLogic())
{
}
public bool Check()
{
result = true;
checkResult = string.Empty;
CheckPrimitives();
return result;
}
private void CheckPrimitives()
{
if (HasPrimitives.Primitives is null || (!HasPrimitives.Primitives.Any()))
{
result = false;
checkResult += collectionDoesntHaveAnyPrimitives;
TraceLogger?.AddMessage(collectionDoesntHaveAnyPrimitives, TraceLogStatuses.Error);
}
else
{
foreach (var primitive in HasPrimitives.Primitives)
{
if (primitive is IRebarPrimitive rebar)
{
CheckRebar(rebar);
}
}
}
}
private void CheckRebar(IRebarPrimitive rebar)
{
if (checkRebarPrimitiveLogic is null)
{
throw new StructureHelperException(ErrorStrings.ParameterIsNull + checkRebarLogic);
}
checkRebarPrimitiveLogic.RebarPrimitive = rebar;
checkRebarPrimitiveLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger();
if (checkRebarPrimitiveLogic.Check() == false)
{
result = false;
checkResult += checkRebarPrimitiveLogic.CheckResult;
return;
}
bool isPrimitivesContainRebarHost = HasPrimitives.Primitives.Contains(rebar.HostPrimitive);
if (isPrimitivesContainRebarHost == false)
{
result = false;
string message = $"Host {rebar.Name} ({rebar.HostPrimitive.Name}) is not included in primitives\n";
checkResult += message;
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
}
}
}
}

View File

@@ -0,0 +1,72 @@
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Materials;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
{
public class CheckRebarPrimitiveLogic : ICheckRebarPrimitiveLogic
{
private string checkResult;
private bool result;
public IRebarPrimitive RebarPrimitive { get; set; }
public string CheckResult => checkResult;
public IShiftTraceLogger? TraceLogger { get; set; }
public CheckRebarPrimitiveLogic(IShiftTraceLogger traceLogger)
{
TraceLogger = traceLogger;
}
public CheckRebarPrimitiveLogic() : this (new ShiftTraceLogger())
{
}
public bool Check()
{
result = true;
checkResult = string.Empty;
CheckRebar();
return result;
}
private void CheckRebar()
{
if (RebarPrimitive.HostPrimitive is null)
{
result = false;
string message = $"Primitive {RebarPrimitive.Name} does not have a host\n";
checkResult += message;
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
return;
}
if (RebarPrimitive.HostPrimitive is IHasDivisionSize division)
{
if (!division.IsPointInside(RebarPrimitive.Center))
{
result = false;
string message = $"Primitive of rebar {RebarPrimitive.Name} is out of its host {RebarPrimitive.HostPrimitive.Name}";
checkResult += message;
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
}
}
if (RebarPrimitive.HostPrimitive.HeadMaterial.HelperMaterial is not ICrackedMaterial)
{
result = false;
string message = $"Material of host of {RebarPrimitive.Name} ({RebarPrimitive.HostPrimitive.HeadMaterial.Name}) does not support cracking\n";
checkResult += message;
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
}
}
}
}

View File

@@ -0,0 +1,14 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
{
public interface ICheckPrimitiveCollectionLogic : ICheckLogic
{
IHasPrimitives HasPrimitives { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
{
public interface ICheckRebarPrimitiveLogic : ICheckLogic
{
IRebarPrimitive RebarPrimitive { get; set; }
}
}

View File

@@ -20,7 +20,7 @@ using System.Windows.Media.Media3D;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
/// <inheritdoc/>
public class RebarPrimitive : IPointPrimitive, IHasHostPrimitive
public class RebarPrimitive : IRebarPrimitive
{
static readonly RebarUpdateStrategy updateStrategy = new();
@@ -30,17 +30,21 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
public IPoint2D Center { get; private set; }
/// <inheritdoc/>
public IHeadMaterial? HeadMaterial { get; set; }
/// <inheritdoc/>
public bool Triangulate { get; set; }
/// <inheritdoc/>
public StrainTuple UsersPrestrain { get; private set; }
/// <inheritdoc/>
public StrainTuple AutoPrestrain { get; private set; }
/// <inheritdoc/>
public IVisualProperty VisualProperty { get; private set; }
/// <inheritdoc/>
public Guid Id { get; set; }
/// <inheritdoc/>
public double Area { get; set; }
/// <inheritdoc/>
public INdmPrimitive HostPrimitive { get; set; }
/// <inheritdoc/>
public ICrossSection? CrossSection { get; set; }
@@ -57,7 +61,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
}
public RebarPrimitive() : this(Guid.NewGuid())
{
}
public object Clone()