Fix error of cross-section cloning strategy
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperLogics.Models.Analyses;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
@@ -36,6 +37,7 @@ namespace StructureHelperLogic.Models.Analyses
|
||||
public object Clone()
|
||||
{
|
||||
CrossSectionNdmAnalysis newAnalysis = new();
|
||||
var project = ProgramSetting.CurrentProject;
|
||||
updateStrategy.Update(newAnalysis, this);
|
||||
var currentVersion = VersionProcessor.GetCurrentVersion().AnalysisVersion as ICloneable;
|
||||
ISaveable newCrossSection = currentVersion.Clone() as ISaveable;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
public class CrossSection : ICrossSection
|
||||
{
|
||||
private ICloneStrategy<ICrossSection> cloneStrategy = new CrossSectionCloneStrategy();
|
||||
private ICloneStrategy<ICrossSection> cloneStrategy;
|
||||
private IUpdateStrategy<ICrossSection> updateStrategy = new CrossSectionUpdateStrategy();
|
||||
public ICrossSectionRepository SectionRepository { get; set; } = new CrossSectionRepository();
|
||||
|
||||
@@ -27,9 +27,7 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
//var newItem = new CrossSection();
|
||||
//updateStrategy.Update(newItem, this);
|
||||
//return newItem;
|
||||
cloneStrategy = new CrossSectionCloneStrategy();
|
||||
return cloneStrategy.GetClone(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
|
||||
namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
@@ -12,13 +13,19 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
this.repositoryCloneStrategy = repositoryCloneStrategy;
|
||||
}
|
||||
|
||||
public CrossSectionCloneStrategy() : this (new CrossSectionRepositoryCloneStrategy())
|
||||
public CrossSectionCloneStrategy(ICloningStrategy cloningStrategy) : this (new CrossSectionRepositoryCloneStrategy(cloningStrategy))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public CrossSectionCloneStrategy() : this (new DeepCloningStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ICrossSection GetClone(ICrossSection sourceObject)
|
||||
{
|
||||
var project = ProgramSetting.CurrentProject;
|
||||
ICrossSectionRepository newRepository = repositoryCloneStrategy.GetClone(sourceObject.SectionRepository);
|
||||
targetObject = new()
|
||||
{
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Parameters;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperLogics.Models.Materials.Logics;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives.Logics;
|
||||
|
||||
@@ -36,13 +33,9 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
this.calculatorsUpdateStrategy = calculatorsUpdateStrategy;
|
||||
}
|
||||
|
||||
public CrossSectionRepositoryCloneStrategy() : this (
|
||||
new DeepCloningStrategy(),
|
||||
new HasForceActionUpdateCloningStrategy(null),
|
||||
new HasMaterialsUpdateCloningStrategy(null),
|
||||
new HasPrimitivesUpdateCloningStrategy(null),
|
||||
new HasCalculatorsUpdateCloningStrategy(null))
|
||||
public CrossSectionRepositoryCloneStrategy(ICloningStrategy cloningStrategy)
|
||||
{
|
||||
this.cloningStrategy = cloningStrategy;
|
||||
forcesUpdateStrategy = new HasForceActionUpdateCloningStrategy(cloningStrategy);
|
||||
materialsUpdateStrategy = new HasMaterialsUpdateCloningStrategy(cloningStrategy);
|
||||
primitivesUpdateStrategy = new HasPrimitivesUpdateCloningStrategy(cloningStrategy);
|
||||
@@ -51,6 +44,7 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
|
||||
public ICrossSectionRepository GetClone(ICrossSectionRepository sourceObject)
|
||||
{
|
||||
var project = ProgramSetting.CurrentProject;
|
||||
targetRepository = new();
|
||||
forcesUpdateStrategy.Update(targetRepository, sourceObject);
|
||||
materialsUpdateStrategy.Update(targetRepository, sourceObject);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives.Logics;
|
||||
@@ -31,6 +32,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics
|
||||
|
||||
public void Update(IForceCalculator targetObject, IForceCalculator sourceObject)
|
||||
{
|
||||
var project = ProgramSetting.CurrentProject;
|
||||
CheckObject.IsNull(cloningStrategy);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Parameters;
|
||||
using StructureHelperCommon.Services;
|
||||
@@ -21,14 +22,6 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
private IUpdateStrategy<ICrackCalculator> crackCalculatorUpdateStrategy;
|
||||
private IUpdateStrategy<ILimitCurvesCalculator> limitCurvesCalculatorUpdateStrategy;
|
||||
|
||||
public HasCalculatorsUpdateCloningStrategy(ICloningStrategy cloningStrategy) : this(
|
||||
cloningStrategy,
|
||||
new ForceCalculatorUpdateCloningStrategy(cloningStrategy),
|
||||
new CrackCalculatorUpdateCloningStrategy(cloningStrategy),
|
||||
new LimitCurvesCalculatorUpdateCloningStrategy(cloningStrategy)
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
public HasCalculatorsUpdateCloningStrategy(
|
||||
ICloningStrategy cloningStrategy,
|
||||
@@ -42,8 +35,18 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
this.limitCurvesCalculatorUpdateStrategy = limitCurvesCalculatorUpdateStrategy;
|
||||
}
|
||||
|
||||
public HasCalculatorsUpdateCloningStrategy(ICloningStrategy cloningStrategy) : this(
|
||||
cloningStrategy,
|
||||
new ForceCalculatorUpdateCloningStrategy(cloningStrategy),
|
||||
new CrackCalculatorUpdateCloningStrategy(cloningStrategy),
|
||||
new LimitCurvesCalculatorUpdateCloningStrategy(cloningStrategy)
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
public void Update(IHasCalculators targetObject, IHasCalculators sourceObject)
|
||||
{
|
||||
var project = ProgramSetting.CurrentProject;
|
||||
CheckObject.IsNull(cloningStrategy);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
@@ -52,8 +55,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
foreach (var calculator in sourceObject.Calculators)
|
||||
{
|
||||
//to do Change to cloning strategy
|
||||
//var newCalculator = cloningStrategy.Clone(calculator);
|
||||
var newCalculator = calculator.Clone() as ICalculator;
|
||||
var newCalculator = cloningStrategy.Clone(calculator);
|
||||
//var newCalculator = calculator.Clone() as ICalculator;
|
||||
if (calculator is IForceCalculator forceCalculator)
|
||||
{
|
||||
forceCalculatorUpdateStrategy.Update(newCalculator as IForceCalculator, forceCalculator);
|
||||
|
||||
@@ -68,11 +68,14 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
Message = "Mx = " + item.DesignForceTuple.ForceTuple.Mx.ToString() + "N*m, My = " + item.DesignForceTuple.ForceTuple.My.ToString() + "N*m, Nz =" + item.DesignForceTuple.ForceTuple.Nz.ToString() + "N, ",
|
||||
Priority = priority
|
||||
};
|
||||
ndmRow.Elements[2].Value = new StringLogEntry()
|
||||
if (item.LoaderResults is not null)
|
||||
{
|
||||
Message = "Kx = " + item.LoaderResults.StrainMatrix.Kx + "(1/m), Ky = " + item.LoaderResults.StrainMatrix.Ky + "(1/m), EpsZ = " + item.LoaderResults.StrainMatrix.EpsZ + "(dimensionless)",
|
||||
Priority = priority
|
||||
};
|
||||
ndmRow.Elements[2].Value = new StringLogEntry()
|
||||
{
|
||||
Message = "Kx = " + item.LoaderResults.StrainMatrix.Kx + "(1/m), Ky = " + item.LoaderResults.StrainMatrix.Ky + "(1/m), EpsZ = " + item.LoaderResults.StrainMatrix.EpsZ + "(dimensionless)",
|
||||
Priority = priority
|
||||
};
|
||||
}
|
||||
ndmRow.Elements[3].Value = new StringLogEntry()
|
||||
{
|
||||
Message = item.Description,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
|
||||
@@ -30,6 +31,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
|
||||
|
||||
private void ProcessPrimitive(IHasPrimitives targetObject, INdmPrimitive primitive)
|
||||
{
|
||||
var project = ProgramSetting.CurrentProject;
|
||||
var newPrimitive = cloningStrategy.Clone(primitive);
|
||||
if (primitive.NdmElement.HeadMaterial is not null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user