Add value diagram windows and view models
This commit is contained in:
@@ -1,10 +1,4 @@
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces.BeamShearActions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.BeamShears
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
|
||||
namespace StructureHelperLogics.Models.Templates.CrossSections
|
||||
@@ -10,12 +11,36 @@ namespace StructureHelperLogics.Models.Templates.CrossSections
|
||||
public IEnumerable<ICalculator> GetNdmCalculators()
|
||||
{
|
||||
var calculators = new List<ICalculator>();
|
||||
var forceCalculator = new ForceCalculator()
|
||||
ForceCalculator forceCalculator = GetForceCalculator();
|
||||
calculators.Add(forceCalculator);
|
||||
CrackCalculator crackCalculator = GetCrackCalculator();
|
||||
calculators.Add(crackCalculator);
|
||||
ValueDiagramCalculator diagramCalculator = GetDiagramCalculator();
|
||||
calculators.Add(diagramCalculator);
|
||||
return calculators;
|
||||
}
|
||||
|
||||
private ValueDiagramCalculator GetDiagramCalculator()
|
||||
{
|
||||
ValueDiagramCalculator diagramCalculator = new(Guid.NewGuid()) { Name = "New value diagram calcualtor"};
|
||||
ValueDiagramEntity diagramEntity = new(Guid.NewGuid()) { Name = "New diagram" };
|
||||
diagramEntity.ValueDigram.Point2DRange.StartPoint.Y = 0.25;
|
||||
diagramEntity.ValueDigram.Point2DRange.EndPoint.Y = - 0.25;
|
||||
diagramCalculator.InputData.Digrams.Add(diagramEntity);
|
||||
return diagramCalculator;
|
||||
}
|
||||
|
||||
private static ForceCalculator GetForceCalculator()
|
||||
{
|
||||
return new ForceCalculator()
|
||||
{
|
||||
Name = "New Force Calculator",
|
||||
TraceLogger = new ShiftTraceLogger()
|
||||
};
|
||||
calculators.Add(forceCalculator);
|
||||
}
|
||||
|
||||
private static CrackCalculator GetCrackCalculator()
|
||||
{
|
||||
var newInputData = new CrackCalculatorInputData();
|
||||
var checkLogic = new CheckCrackCalculatorInputDataLogic
|
||||
{
|
||||
@@ -28,8 +53,7 @@ namespace StructureHelperLogics.Models.Templates.CrossSections
|
||||
TraceLogger = new ShiftTraceLogger()
|
||||
};
|
||||
crackCalculator.InputData = newInputData;
|
||||
calculators.Add(crackCalculator);
|
||||
return calculators;
|
||||
return crackCalculator;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Templates.RCs;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
@@ -67,6 +68,10 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
|
||||
{
|
||||
crackCalculator.InputData.ForceActions.AddRange(combinations);
|
||||
}
|
||||
if (calculator is IValueDiagramCalculator diagramCalculator)
|
||||
{
|
||||
diagramCalculator.InputData.ForceActions.AddRange(combinations);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void AddAllPrimitivesToCalculator()
|
||||
@@ -81,6 +86,10 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
|
||||
{
|
||||
crackCalculator.InputData.Primitives.AddRange(primitives);
|
||||
}
|
||||
if (calculator is IValueDiagramCalculator diagramCalculator)
|
||||
{
|
||||
diagramCalculator.InputData.Primitives.AddRange(primitives);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
@@ -33,6 +34,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Logics
|
||||
{
|
||||
new CrackCalculatorUpdateStrategy().Update(crackCalculator, (CrackCalculator)sourceObject);
|
||||
}
|
||||
else if (targetObject is IValueDiagramCalculator diagramCalculator)
|
||||
{
|
||||
new ValueDiagramCalculatorUpdateStrategy().Update(diagramCalculator, (IValueDiagramCalculator)sourceObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorCommonProcessor.ObjectTypeIsUnknown(typeof(INdmPrimitive), sourceObject.GetType());
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
public interface IValueDigram : ISaveable
|
||||
public interface IValueDiagram : ISaveable, ICloneable
|
||||
{
|
||||
IPoint2DRange Point2DRange { get; }
|
||||
public int StepNumber { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,6 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
public interface IValueDiagramCalculator : ICalculator
|
||||
{
|
||||
|
||||
IValueDiagramCalculatorInputData InputData { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.States;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
@@ -8,13 +8,13 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
/// <summary>
|
||||
/// Implements input data for Value diagram calculator
|
||||
/// </summary>
|
||||
public interface IValueDiagramCalculatorInputData : ISaveable, IHasForceActions, IHasPrimitives
|
||||
public interface IValueDiagramCalculatorInputData : ISaveable, IInputData, IHasForceActions, IHasPrimitives
|
||||
{
|
||||
IStateCalcTermPair StateTermPair { get; set; }
|
||||
/// <summary>
|
||||
/// Collection of diagram for calculation
|
||||
/// </summary>
|
||||
List<IValueDigram> Digrams { get; }
|
||||
List<IValueDiagramEntity> Digrams { get; }
|
||||
bool CheckStrainLimit { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
IValueDiagramCalculatorInputData? InputData { get; set; }
|
||||
List<IPoint2D> Points { get; set; }
|
||||
List<IForceTupleCalculatorResult> ForceTupleResults { get; set; }
|
||||
List<IExtendedForceTupleCalculatorResult> ForceTupleResults { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
public interface IValueDiagramEntity : ISaveable, ICloneable
|
||||
{
|
||||
string Name { get; set; }
|
||||
bool IsTaken { get; set; }
|
||||
IValueDiagram ValueDigram { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
public class ValueDiagramCalculatorInputDataUpdateStrategy : IParentUpdateStrategy<IValueDiagramCalculatorInputData>
|
||||
{
|
||||
private IUpdateStrategy<IValueDiagramEntity> entityUpdateStrategy;
|
||||
|
||||
public ValueDiagramCalculatorInputDataUpdateStrategy(IUpdateStrategy<IValueDiagramEntity> entityUpdateStrategy)
|
||||
{
|
||||
this.entityUpdateStrategy = entityUpdateStrategy;
|
||||
}
|
||||
|
||||
public ValueDiagramCalculatorInputDataUpdateStrategy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool UpdateChildren { get; set; } = true;
|
||||
|
||||
public void Update(IValueDiagramCalculatorInputData targetObject, IValueDiagramCalculatorInputData sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.CheckStrainLimit = sourceObject.CheckStrainLimit;
|
||||
targetObject.StateTermPair.LimitState = sourceObject.StateTermPair.LimitState;
|
||||
targetObject.StateTermPair.CalcTerm = sourceObject.StateTermPair.CalcTerm;
|
||||
if (UpdateChildren == true)
|
||||
{
|
||||
targetObject.Primitives.Clear();
|
||||
targetObject.Primitives.AddRange(sourceObject.Primitives);
|
||||
targetObject.ForceActions.Clear();
|
||||
targetObject.ForceActions.AddRange(sourceObject.ForceActions);
|
||||
targetObject.Digrams.Clear();
|
||||
entityUpdateStrategy ??= new ValueDiagramEntityUpdateStrategy();
|
||||
foreach (var entity in sourceObject.Digrams)
|
||||
{
|
||||
var newItem = entity.Clone() as IValueDiagramEntity;
|
||||
targetObject.Digrams.Add(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
public class ValueDiagramCalculatorUpdateStrategy : IParentUpdateStrategy<IValueDiagramCalculator>
|
||||
{
|
||||
private IUpdateStrategy<IValueDiagramCalculatorInputData> inputDataUpdateStrategy;
|
||||
public bool UpdateChildren { get; set; } = true;
|
||||
|
||||
public void Update(IValueDiagramCalculator targetObject, IValueDiagramCalculator sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Name = sourceObject.Name;
|
||||
targetObject.ShowTraceData = sourceObject.ShowTraceData;
|
||||
if (UpdateChildren == true)
|
||||
{
|
||||
CheckObject.IsNull(targetObject.InputData, ": target value diagram calculator input data");
|
||||
CheckObject.IsNull(sourceObject.InputData, ": source value diagram calculator input data");
|
||||
inputDataUpdateStrategy ??= new ValueDiagramCalculatorInputDataUpdateStrategy();
|
||||
inputDataUpdateStrategy.Update(targetObject.InputData, sourceObject.InputData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
public class ValueDiagramEntityUpdateStrategy : IParentUpdateStrategy<IValueDiagramEntity>
|
||||
{
|
||||
private IUpdateStrategy<IValueDiagram> valueDiagramUpdateStrategy;
|
||||
|
||||
public ValueDiagramEntityUpdateStrategy(IUpdateStrategy<IValueDiagram> valueDiagramUpdateStrategy)
|
||||
{
|
||||
this.valueDiagramUpdateStrategy = valueDiagramUpdateStrategy;
|
||||
}
|
||||
|
||||
public ValueDiagramEntityUpdateStrategy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool UpdateChildren { get; set; } = true;
|
||||
|
||||
public void Update(IValueDiagramEntity targetObject, IValueDiagramEntity sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.IsTaken = sourceObject.IsTaken;
|
||||
targetObject.Name = sourceObject.Name;
|
||||
if (UpdateChildren == true)
|
||||
{
|
||||
valueDiagramUpdateStrategy ??= new ValueDiagramUpdateStrategy();
|
||||
valueDiagramUpdateStrategy.Update(targetObject.ValueDigram, sourceObject.ValueDigram);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
internal class ValueDiagramUpdateStrategy : IParentUpdateStrategy<IValueDiagram>
|
||||
{
|
||||
private IUpdateStrategy<IPoint2DRange> rangeUpdateStrategy;
|
||||
public bool UpdateChildren { get; set; } = true;
|
||||
|
||||
public void Update(IValueDiagram targetObject, IValueDiagram sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.StepNumber = sourceObject.StepNumber;
|
||||
if (UpdateChildren == true)
|
||||
{
|
||||
rangeUpdateStrategy ??= new Point2DRangeUpdateStrategy();
|
||||
rangeUpdateStrategy.Update(targetObject.Point2DRange, sourceObject.Point2DRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
public class ValueDiagram : IValueDiagram
|
||||
{
|
||||
public Guid Id { get; }
|
||||
public int StepNumber { get; set; } = 50;
|
||||
public IPoint2DRange Point2DRange { get; } = new Point2DRange(Guid.NewGuid());
|
||||
|
||||
|
||||
public ValueDiagram(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
ValueDiagram newItem = new(Guid.NewGuid());
|
||||
var updateStrategy = new ValueDiagramUpdateStrategy();
|
||||
updateStrategy.Update(newItem, this);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,14 +11,17 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
public class ValueDiagramCalculator : IValueDiagramCalculator
|
||||
{
|
||||
private IValueDiagramCalculatorResult result;
|
||||
|
||||
public Guid Id { get; }
|
||||
public string Name { get; set; }
|
||||
public bool ShowTraceData { get; set; }
|
||||
|
||||
public IResult Result => throw new NotImplementedException();
|
||||
public IResult Result => result;
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public Guid Id { get; }
|
||||
public IValueDiagramCalculatorInputData InputData { get; set; } = new ValueDiagramCalculatorInputData(Guid.NewGuid());
|
||||
|
||||
public ValueDiagramCalculator(Guid id)
|
||||
{
|
||||
@@ -27,7 +30,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
ValueDiagramCalculator newItem = new ValueDiagramCalculator(Guid.NewGuid());
|
||||
var updateLogic = new ValueDiagramCalculatorUpdateStrategy();
|
||||
updateLogic.Update(newItem, this);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
public Guid Id { get; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public List<IValueDigram> Digrams { get; } = [];
|
||||
public List<IValueDiagramEntity> Digrams { get; } = [];
|
||||
/// <inheritdoc/>
|
||||
public List<IForceAction> ForceActions { get; } = [];
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
|
||||
public List<IPoint2D> Points { get; set; } = [];
|
||||
|
||||
public List<IForceTupleCalculatorResult> ForceTupleResults { get; set; } = [];
|
||||
public List<IExtendedForceTupleCalculatorResult> ForceTupleResults { get; set; } = [];
|
||||
|
||||
public bool IsValid { get; set; } = true;
|
||||
public string? Description { get; set; } = string.Empty;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
public class ValueDiagramEntity : IValueDiagramEntity
|
||||
{
|
||||
public Guid Id { get; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public bool IsTaken { get; set; } = true;
|
||||
|
||||
public IValueDiagram ValueDigram { get; set; } = new ValueDiagram(Guid.NewGuid());
|
||||
|
||||
public ValueDiagramEntity(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
ValueDiagramEntity newItem = new ValueDiagramEntity(Guid.NewGuid());
|
||||
var updateStrategy = new ValueDiagramEntityUpdateStrategy();
|
||||
updateStrategy.Update(newItem, this);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,11 @@
|
||||
using netDxf;
|
||||
using netDxf.Entities;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using netDxf.Entities;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services.Exports;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public class GetPrimitivesByDxfEntities : IObjectConvertStrategy<List<INdmPrimitive>, IEnumerable<EntityObject>>
|
||||
public class DxfEntitiesToNdmPrimitivesConvertStrategy : IObjectConvertStrategy<List<INdmPrimitive>, IEnumerable<EntityObject>>
|
||||
{
|
||||
private const double metresToMillimeters = 1000.0;
|
||||
private List<INdmPrimitive> primitives = [];
|
||||
@@ -68,7 +65,6 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
primitive = ellipse;
|
||||
}
|
||||
primitive.Center = new Point2D(circle.Center.X / metresToMillimeters, circle.Center.Y / metresToMillimeters);
|
||||
|
||||
return primitive;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public class GetPrimitivesByFile : IGetPrimitivesLogic
|
||||
public class GetPrimitivesByFile : IImportFromFileLogic
|
||||
{
|
||||
private List<INdmPrimitive> primitives = [];
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
importEntitiesLogic.Import();
|
||||
if (importEntitiesLogic.Entities.Count != 0)
|
||||
{
|
||||
var primitivesLogic = new GetPrimitivesByDxfEntities();
|
||||
var primitivesLogic = new DxfEntitiesToNdmPrimitivesConvertStrategy();
|
||||
primitives = primitivesLogic.Convert(importEntitiesLogic.Entities);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
using netDxf.Entities;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services.Exports;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public class NdmPrimitivesToDxfEntitiesConvertStrategy : IObjectConvertStrategy<List<(EntityObject, LayerNames)>, IEnumerable<INdmPrimitive>>
|
||||
{
|
||||
private const double metresToMillimeters = 1000.0;
|
||||
private List<(EntityObject, LayerNames)> entities = [];
|
||||
private IShapeConvertStrategy<EntityObject, IShape> shapeConvertStrategy = new ShapeToDxfEntityConvertStrategy() { Scale = metresToMillimeters };
|
||||
|
||||
|
||||
public List<(EntityObject, LayerNames)> Convert(IEnumerable<INdmPrimitive> source)
|
||||
{
|
||||
entities.Clear();
|
||||
foreach (var ndmPrimitive in source)
|
||||
{
|
||||
shapeConvertStrategy.Dx = ndmPrimitive.Center.X;
|
||||
shapeConvertStrategy.Dy = ndmPrimitive.Center.Y;
|
||||
if (ndmPrimitive is IRectangleNdmPrimitive rectangleNdmPrimitive)
|
||||
{
|
||||
var rectangle = shapeConvertStrategy.Convert(rectangleNdmPrimitive);
|
||||
entities.Add((rectangle, LayerNames.StructiralPrimitives));
|
||||
}
|
||||
else if (ndmPrimitive is IShapeNdmPrimitive shapeNdmPrimitive)
|
||||
{
|
||||
var polygon = shapeConvertStrategy.Convert(shapeNdmPrimitive.Shape);
|
||||
entities.Add((polygon, LayerNames.StructiralPrimitives));
|
||||
}
|
||||
else if (ndmPrimitive is IEllipseNdmPrimitive ellipseNdmPrimitive)
|
||||
{
|
||||
CircleShape circleShape = new CircleShape() { Diameter = ellipseNdmPrimitive.Width};
|
||||
var circle = shapeConvertStrategy.Convert(circleShape);
|
||||
entities.Add((circle, LayerNames.StructiralPrimitives));
|
||||
}
|
||||
else if (ndmPrimitive is IRebarNdmPrimitive rebar)
|
||||
{
|
||||
LayerNames layerName = LayerNames.StructuralRebars;
|
||||
convertPoint(rebar, layerName);
|
||||
}
|
||||
else if (ndmPrimitive is IPointNdmPrimitive point)
|
||||
{
|
||||
LayerNames layerName = LayerNames.StructiralPrimitives;
|
||||
convertPoint(point, layerName);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(ndmPrimitive));
|
||||
}
|
||||
}
|
||||
return entities;
|
||||
}
|
||||
|
||||
private void convertPoint(IPointNdmPrimitive point, LayerNames layerName)
|
||||
{
|
||||
double diameter = Math.Sqrt(point.Area / Math.PI * 4.0);
|
||||
CircleShape circleShape = new CircleShape() { Diameter = diameter };
|
||||
var circle = shapeConvertStrategy.Convert(circleShape);
|
||||
entities.Add((circle, layerName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,6 +77,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
if (shape is ILinePolygonShape polygon)
|
||||
{
|
||||
var newShape = PolygonGeometryUtils.GetTransfromedPolygon(polygon, Center.X, Center.Y);
|
||||
newShape.IsClosed = true;
|
||||
var calculator = new PolygonCalculator();
|
||||
return calculator.ContainsPoint(newShape, point);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user