Add inclined rebar
This commit is contained in:
@@ -11,22 +11,24 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
|
||||
{
|
||||
public class CheckPrimitiveCollectionLogic : ICheckPrimitiveCollectionLogic
|
||||
public class CheckPrimitiveCollectionLogic : ICheckEntityLogic<IHasPrimitives>
|
||||
{
|
||||
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;
|
||||
private ICheckEntityLogic<IRebarNdmPrimitive> checkRebarPrimitiveLogic;
|
||||
|
||||
public IHasPrimitives HasPrimitives { get; set; }
|
||||
public IHasPrimitives Entity { get; set; }
|
||||
|
||||
public string CheckResult => checkResult;
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public CheckPrimitiveCollectionLogic(IShiftTraceLogger shiftTraceLogger, ICheckRebarPrimitiveLogic checkRebarPrimitiveLogic)
|
||||
public CheckPrimitiveCollectionLogic(
|
||||
IShiftTraceLogger shiftTraceLogger,
|
||||
ICheckEntityLogic<IRebarNdmPrimitive> checkRebarPrimitiveLogic)
|
||||
{
|
||||
TraceLogger = shiftTraceLogger;
|
||||
this.checkRebarPrimitiveLogic = checkRebarPrimitiveLogic;
|
||||
@@ -47,7 +49,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
|
||||
|
||||
private void CheckPrimitives()
|
||||
{
|
||||
if (HasPrimitives.Primitives is null || (!HasPrimitives.Primitives.Any()))
|
||||
if (Entity.Primitives is null || (!Entity.Primitives.Any()))
|
||||
{
|
||||
result = false;
|
||||
checkResult += collectionDoesntHaveAnyPrimitives;
|
||||
@@ -55,7 +57,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var primitive in HasPrimitives.Primitives)
|
||||
foreach (var primitive in Entity.Primitives)
|
||||
{
|
||||
if (primitive is IRebarNdmPrimitive rebar)
|
||||
{
|
||||
@@ -71,7 +73,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ParameterIsNull + checkRebarLogic);
|
||||
}
|
||||
checkRebarPrimitiveLogic.RebarPrimitive = rebar;
|
||||
checkRebarPrimitiveLogic.Entity = rebar;
|
||||
checkRebarPrimitiveLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger();
|
||||
if (checkRebarPrimitiveLogic.Check() == false)
|
||||
{
|
||||
@@ -79,7 +81,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
|
||||
checkResult += checkRebarPrimitiveLogic.CheckResult;
|
||||
return;
|
||||
}
|
||||
bool isPrimitivesContainRebarHost = HasPrimitives.Primitives.Contains(rebar.HostPrimitive);
|
||||
bool isPrimitivesContainRebarHost = Entity.Primitives.Contains(rebar.HostPrimitive);
|
||||
if (isPrimitivesContainRebarHost == false)
|
||||
{
|
||||
result = false;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using System;
|
||||
@@ -9,12 +10,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
|
||||
{
|
||||
public class CheckRebarPrimitiveLogic : ICheckRebarPrimitiveLogic
|
||||
public class CheckRebarPrimitiveLogic : ICheckEntityLogic<IRebarNdmPrimitive>
|
||||
{
|
||||
private string checkResult;
|
||||
private bool result;
|
||||
|
||||
public IRebarNdmPrimitive RebarPrimitive { get; set; }
|
||||
public bool CheckRebarPlacement { get; set; } = true;
|
||||
public bool CheckRebarHostMaterial { get; set; } = true;
|
||||
public IRebarNdmPrimitive Entity { get; set; }
|
||||
|
||||
public string CheckResult => checkResult;
|
||||
|
||||
@@ -40,33 +43,47 @@ namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
|
||||
|
||||
private void CheckRebar()
|
||||
{
|
||||
if (RebarPrimitive.HostPrimitive is null)
|
||||
if (Entity.HostPrimitive is null)
|
||||
{
|
||||
result = false;
|
||||
string message = $"Primitive {RebarPrimitive.Name} does not have a host\n";
|
||||
string message = $"Primitive {Entity.Name} does not have a host\n";
|
||||
checkResult += message;
|
||||
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (RebarPrimitive.HostPrimitive is IHasDivisionSize division)
|
||||
if (CheckRebarPlacement == true)
|
||||
{
|
||||
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);
|
||||
}
|
||||
CheckIfRebarInsideHostPrimitive();
|
||||
}
|
||||
if (CheckRebarHostMaterial == true)
|
||||
{
|
||||
CheckIfRemarMaterialIsCrackedMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
if (RebarPrimitive.HostPrimitive.NdmElement.HeadMaterial.HelperMaterial is not ICrackedMaterial)
|
||||
private void CheckIfRemarMaterialIsCrackedMaterial()
|
||||
{
|
||||
if (Entity.HostPrimitive.NdmElement.HeadMaterial.HelperMaterial is not ICrackedMaterial)
|
||||
{
|
||||
result = false;
|
||||
string message = $"Material of host of {RebarPrimitive.Name} ({RebarPrimitive.HostPrimitive.NdmElement.HeadMaterial.Name}) does not support cracking\n";
|
||||
string message = $"Material of host of {Entity.Name} ({Entity.HostPrimitive.NdmElement.HeadMaterial.Name}) does not support cracking\n";
|
||||
checkResult += message;
|
||||
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckIfRebarInsideHostPrimitive()
|
||||
{
|
||||
if (Entity.HostPrimitive is IHasDivisionSize division)
|
||||
{
|
||||
if (!division.IsPointInside(Entity.Center))
|
||||
{
|
||||
result = false;
|
||||
string message = $"Primitive of rebar {Entity.Name} is out of its host {Entity.HostPrimitive.Name}";
|
||||
checkResult += message;
|
||||
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
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; }
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
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
|
||||
{
|
||||
IRebarNdmPrimitive RebarPrimitive { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user