Fix removing primitives
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
using netDxf.Entities;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Curvatures;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public class CrossSectionRepositoryCheckLogic : CheckEntityLogic<ICrossSectionRepository>
|
||||
{
|
||||
private bool result;
|
||||
private
|
||||
ICheckEntityLogic<IHasForcesAndPrimitives> primitivesCheckLogic;
|
||||
ICheckEntityLogic<IHasForcesAndPrimitives> PrimitivesCheckLogic => primitivesCheckLogic ??= new RepositoryHasForcesAndPrimitivesCheckLogic(Entity) { TraceLogger = TraceLogger};
|
||||
public override bool Check()
|
||||
{
|
||||
result = true;
|
||||
CheckObject.ThrowIfNull(Entity);
|
||||
foreach (var item in Entity.Calculators)
|
||||
{
|
||||
if (item is IForceCalculator forceCalculator)
|
||||
{
|
||||
ProcessCalculatorInputData(forceCalculator.InputData);
|
||||
}
|
||||
else if (item is ICrackCalculator crackCalculator)
|
||||
{
|
||||
ProcessCalculatorInputData(crackCalculator.InputData);
|
||||
}
|
||||
else if (item is IValueDiagramCalculator valueDiagramCalculator)
|
||||
{
|
||||
ProcessCalculatorInputData(valueDiagramCalculator.InputData);
|
||||
}
|
||||
else if (item is ICurvatureCalculator curvatureCalculator)
|
||||
{
|
||||
ProcessCalculatorInputData(curvatureCalculator.InputData);
|
||||
}
|
||||
else
|
||||
{
|
||||
// skip
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void ProcessCalculatorInputData(IHasForcesAndPrimitives inputData)
|
||||
{
|
||||
PrimitivesCheckLogic.Entity = inputData;
|
||||
if (PrimitivesCheckLogic.Check() == false)
|
||||
{
|
||||
CheckResult += "\n" + PrimitivesCheckLogic.CheckResult;
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public class RepositoryHasForcesAndPrimitivesCheckLogic : CheckEntityLogic<IHasForcesAndPrimitives>
|
||||
{
|
||||
|
||||
ICheckEntityLogic<IHasPrimitives> primitivesCheckLogic;
|
||||
ICheckEntityLogic<IHasPrimitives> PrimitivesCheckLogic => primitivesCheckLogic ??= new RepositoryHasPrimitivesCheckLogic(Repository) { TraceLogger = TraceLogger };
|
||||
public ICrossSectionRepository Repository { get; }
|
||||
|
||||
public RepositoryHasForcesAndPrimitivesCheckLogic(ICrossSectionRepository repository)
|
||||
{
|
||||
Repository = repository;
|
||||
}
|
||||
|
||||
public override bool Check()
|
||||
{
|
||||
CheckObject.ThrowIfNull(Repository);
|
||||
CheckObject.ThrowIfNull(Entity);
|
||||
bool result = true;
|
||||
PrimitivesCheckLogic.Entity = Entity;
|
||||
if (PrimitivesCheckLogic.Check() == false)
|
||||
{
|
||||
CheckResult += "\n";
|
||||
CheckResult += PrimitivesCheckLogic.CheckResult;
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public class RepositoryHasPrimitivesCheckLogic : CheckEntityLogic<IHasPrimitives>
|
||||
{
|
||||
public ICrossSectionRepository Repository { get; }
|
||||
|
||||
public RepositoryHasPrimitivesCheckLogic(ICrossSectionRepository crossSectionRepository)
|
||||
{
|
||||
Repository = crossSectionRepository;
|
||||
}
|
||||
|
||||
public override bool Check()
|
||||
{
|
||||
bool result = true;
|
||||
CheckObject.ThrowIfNull(Repository);
|
||||
CheckObject.ThrowIfNull(Entity);
|
||||
foreach (var primitive in Entity.Primitives)
|
||||
{
|
||||
if (! Repository.Primitives.Contains(primitive))
|
||||
{
|
||||
TraceMessage($"Repository does not contain primitive Id = {primitive.Id}, Name = {primitive.Name}");
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user