Add polygon to DTO convert strategy
This commit is contained in:
@@ -70,7 +70,7 @@ namespace DataAccess.DTOs
|
||||
|
||||
private EllipseNdmPrimitiveDTO GetNewPrimitive(IEllipseNdmPrimitive source)
|
||||
{
|
||||
EllipseNdmPrimitiveDTO newItem = new() { Id = source.Id };
|
||||
EllipseNdmPrimitiveDTO newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
newItem.NdmElement = ndmElementConvertStrategy.Convert(source.NdmElement);
|
||||
newItem.RectangleShape = rectangleShapeConvertStrategy.Convert(source.Shape as IRectangleShape);
|
||||
|
||||
@@ -55,8 +55,11 @@ namespace DataAccess.DTOs
|
||||
headMaterialConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
headMaterialConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<HeadMaterialDTO, IHeadMaterial>(this, headMaterialConvertStrategy);
|
||||
if (source.HeadMaterial != null)
|
||||
{
|
||||
var headMaterial = convertLogic.Convert(source.HeadMaterial);
|
||||
newItem.HeadMaterial = headMaterial;
|
||||
}
|
||||
forceUpdateStrategy.Update(newItem.UsersPrestrain, source.UsersPrestrain);
|
||||
(newItem.UsersPrestrain as ForceTupleDTO).Id = source.UsersPrestrain.Id;
|
||||
forceUpdateStrategy.Update(newItem.AutoPrestrain, source.AutoPrestrain);
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace DataAccess.DTOs.Converters
|
||||
private readonly IConvertStrategy<PointNdmPrimitiveDTO, IPointNdmPrimitive> pointConvertStrategy;
|
||||
private readonly IConvertStrategy<EllipseNdmPrimitiveDTO, IEllipseNdmPrimitive> ellipseConvertStrategy;
|
||||
private readonly IConvertStrategy<RectangleNdmPrimitiveDTO, IRectangleNdmPrimitive> rectangleConvertStrategy;
|
||||
private IConvertStrategy<ShapeNdmPrimitiveDTO, IShapeNdmPrimitive> shapeConvertStrategy;
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
@@ -55,10 +56,21 @@ namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
return ProcessRectangle(rectangle);
|
||||
}
|
||||
if (source is IShapeNdmPrimitive shape)
|
||||
{
|
||||
return ProcessShape(shape);
|
||||
}
|
||||
TraceLogger.AddMessage("Object type is unknown", TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source));
|
||||
}
|
||||
|
||||
private ShapeNdmPrimitiveDTO ProcessShape(IShapeNdmPrimitive shape)
|
||||
{
|
||||
shapeConvertStrategy = new DictionaryConvertStrategy<ShapeNdmPrimitiveDTO,IShapeNdmPrimitive>(this, new ShapeNdmPrimitiveToDTOConvertStrategy(this));
|
||||
ShapeNdmPrimitiveDTO shapeNdmPrimitiveDTO = shapeConvertStrategy.Convert(shape);
|
||||
return shapeNdmPrimitiveDTO;
|
||||
}
|
||||
|
||||
private RebarNdmPrimitiveDTO ProcessRebar(IRebarNdmPrimitive rebar)
|
||||
{
|
||||
rebarConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ShapeNdmPrimitiveToDTOConvertStrategy : ConvertStrategy<ShapeNdmPrimitiveDTO, IShapeNdmPrimitive>
|
||||
{
|
||||
private IUpdateStrategy<IShapeNdmPrimitive> updateStrategy;
|
||||
private IConvertStrategy<IShape, IShape> shapeConvertStrategy;
|
||||
private IConvertStrategy<NdmElementDTO, INdmElement> ndmElementConvertStrategy;
|
||||
private IConvertStrategy<Point2DDTO, IPoint2D> pointConvertStrategy;
|
||||
private IConvertStrategy<VisualPropertyDTO, IVisualProperty> visualPropsConvertStrategy;
|
||||
private IConvertStrategy<DivisionSizeDTO, IDivisionSize> divisionConvertStrategy;
|
||||
|
||||
public ShapeNdmPrimitiveToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override ShapeNdmPrimitiveDTO GetNewItem(IShapeNdmPrimitive source)
|
||||
{
|
||||
ChildClass = this;
|
||||
NewItem = new(source.Id);
|
||||
InitializeStrategies();
|
||||
updateStrategy.Update(NewItem, source);
|
||||
updateChildProperties(source);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private void updateChildProperties(IShapeNdmPrimitive source)
|
||||
{
|
||||
NewItem.SetShape(shapeConvertStrategy.Convert(source.Shape));
|
||||
NewItem.NdmElement = ndmElementConvertStrategy.Convert(source.NdmElement);
|
||||
NewItem.Center = pointConvertStrategy.Convert(source.Center);
|
||||
NewItem.VisualProperty = visualPropsConvertStrategy.Convert(source.VisualProperty);
|
||||
NewItem.DivisionSize = divisionConvertStrategy.Convert(source.DivisionSize);
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy = new ShapeNdmPrimitiveUpdateStrategy() { UpdateChildren = false };
|
||||
shapeConvertStrategy = new DictionaryConvertStrategy<IShape, IShape>(this, new ShapeToDTOConvertStrategy(this));
|
||||
ndmElementConvertStrategy = new NdmElementToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
pointConvertStrategy = new Point2DToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
visualPropsConvertStrategy = new VisualPropertyToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
divisionConvertStrategy = new DivisionSizeToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
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 DataAccess.DTOs
|
||||
{
|
||||
public class LinePolygonToDTOConvertStrategy : ConvertStrategy<LinePolygonShapeDTO, ILinePolygonShape>
|
||||
{
|
||||
private IUpdateStrategy<ILinePolygonShape> updateStrategy;
|
||||
private IConvertStrategy<VertexDTO, IVertex> vertexConvertStrategy;
|
||||
|
||||
public LinePolygonToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override LinePolygonShapeDTO GetNewItem(ILinePolygonShape source)
|
||||
{
|
||||
ChildClass = this;
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy = new LinePolygonShapeUpdateStrategy() { UpdateChildren = false };
|
||||
vertexConvertStrategy = new VertexToDTOConvertStrategy(this);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
NewItem.Clear();
|
||||
foreach (var item in source.Vertices)
|
||||
{
|
||||
VertexDTO newVertex = vertexConvertStrategy.Convert(item);
|
||||
NewItem.AddVertex(newVertex);
|
||||
}
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
private IConvertStrategy<RectangleShapeDTO, IRectangleShape> rectangleConvertStrategy;
|
||||
private IConvertStrategy<CircleShapeDTO, ICircleShape> circleConvertStrategy;
|
||||
private IConvertStrategy<LinePolygonShapeDTO, ILinePolygonShape> linePolygonToDTOConvertStrategy;
|
||||
|
||||
public ShapeToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
@@ -32,6 +33,10 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
ProcessCircle(circle);
|
||||
}
|
||||
else if (source is ILinePolygonShape linePolygon)
|
||||
{
|
||||
ProcessLinePolygon(linePolygon);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source) + ": shape type";
|
||||
@@ -40,6 +45,13 @@ namespace DataAccess.DTOs
|
||||
TraceLogger?.AddMessage($"Shape converting Id = {NewItem.Id} has been has been finished successfully", TraceLogStatuses.Debug);
|
||||
}
|
||||
|
||||
private void ProcessLinePolygon(ILinePolygonShape linePolygon)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Shape is line polygon", TraceLogStatuses.Debug);
|
||||
linePolygonToDTOConvertStrategy = new DictionaryConvertStrategy<LinePolygonShapeDTO, ILinePolygonShape>(this, new LinePolygonToDTOConvertStrategy(this));
|
||||
NewItem = linePolygonToDTOConvertStrategy.Convert(linePolygon);
|
||||
}
|
||||
|
||||
private void ProcessCircle(ICircleShape circle)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Shape is circle", TraceLogStatuses.Debug);
|
||||
@@ -0,0 +1,26 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class VertexToDTOConvertStrategy : ConvertStrategy<VertexDTO, IVertex>
|
||||
{
|
||||
private IUpdateStrategy<IVertex> updateStrategy;
|
||||
private IConvertStrategy<Point2DDTO, IPoint2D> pointConvertStrategy;
|
||||
|
||||
public VertexToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override VertexDTO GetNewItem(IVertex source)
|
||||
{
|
||||
ChildClass = this;
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy = new VertexUpdateStrategy() { UpdateChildren = false };
|
||||
pointConvertStrategy = new Point2DToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
updateStrategy.Update(NewItem, source);
|
||||
NewItem.Point = pointConvertStrategy.Convert(source.Point);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,8 @@
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class VisualPropertyToDTOConvertStrategy : IConvertStrategy<VisualPropertyDTO, IVisualProperty>
|
||||
{
|
||||
|
||||
@@ -11,6 +11,11 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
private IRectangleShape shape = new RectangleShapeDTO(Guid.Empty);
|
||||
|
||||
public EllipseNdmPrimitiveDTO(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; set; }
|
||||
[JsonProperty("Name")]
|
||||
@@ -42,7 +47,7 @@ namespace DataAccess.DTOs
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return this;
|
||||
}
|
||||
|
||||
public IEnumerable<INdm> GetNdms(ITriangulationOptions triangulationOptions)
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using Newtonsoft.Json;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ShapeNdmPrimitiveDTO : IShapeNdmPrimitive
|
||||
{
|
||||
private IShape shape;
|
||||
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; }
|
||||
[JsonProperty("Name")]
|
||||
public string? Name { get; set; }
|
||||
[JsonProperty("Shape")]
|
||||
public IShape Shape => shape;
|
||||
[JsonProperty("NdmElement")]
|
||||
public INdmElement NdmElement { get; set; }
|
||||
[JsonProperty("Center")]
|
||||
public IPoint2D Center { get; set; }
|
||||
[JsonProperty("VisualProperty")]
|
||||
public IVisualProperty VisualProperty { get; set; }
|
||||
[JsonProperty("RotationAngle")]
|
||||
public double RotationAngle { get; set; }
|
||||
[JsonProperty("DivisionSize")]
|
||||
public IDivisionSize DivisionSize { get; set; }
|
||||
[JsonIgnore]
|
||||
public ICrossSection? CrossSection { get; set; }
|
||||
public ShapeNdmPrimitiveDTO(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public IEnumerable<INdm> GetNdms(ITriangulationOptions triangulationOptions)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<INamedAreaPoint> GetValuePoints()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsPointInside(IPoint2D point)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetShape(IShape shape)
|
||||
{
|
||||
this.shape = shape;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
53
DataAccess/DTOs/DTOEntities/Shapes/LinePolygonShapeDTO.cs
Normal file
53
DataAccess/DTOs/DTOEntities/Shapes/LinePolygonShapeDTO.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using Newtonsoft.Json;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class LinePolygonShapeDTO : ILinePolygonShape
|
||||
{
|
||||
private readonly List<IVertex> _vertices = [];
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; }
|
||||
[JsonProperty("Vertices")]
|
||||
public IReadOnlyList<IVertex> Vertices => _vertices;
|
||||
[JsonProperty("IsClosed")]
|
||||
public bool IsClosed { get; set; }
|
||||
|
||||
|
||||
public LinePolygonShapeDTO(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public IVertex AddVertex(IVertex vertex)
|
||||
{
|
||||
_vertices.Add(vertex);
|
||||
return vertex;
|
||||
}
|
||||
|
||||
public IVertex AddVertexAfter(IVertex existing, IVertex vertex)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IVertex AddVertexBefore(IVertex existing, IVertex vertex)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_vertices.Clear();
|
||||
}
|
||||
|
||||
public IVertex InsertVertex(int index, IVertex vertex)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void RemoveVertex(IVertex vertex)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
23
DataAccess/DTOs/DTOEntities/Shapes/VertexDTO.cs
Normal file
23
DataAccess/DTOs/DTOEntities/Shapes/VertexDTO.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Newtonsoft.Json;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class VertexDTO : IVertex
|
||||
{
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; }
|
||||
[JsonProperty("Point")]
|
||||
public IPoint2D Point { get; set; }
|
||||
|
||||
public VertexDTO(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
{
|
||||
viewItem = new CircleViewPrimitive(circle);
|
||||
}
|
||||
else if (primitive is IShapeNDMPrimitive shapeNDMPrimitive)
|
||||
else if (primitive is IShapeNdmPrimitive shapeNDMPrimitive)
|
||||
{
|
||||
viewItem = new ShapeViewPrimitive(shapeNDMPrimitive);
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
{
|
||||
public class ShapeViewPrimitive : PrimitiveBase
|
||||
{
|
||||
IShapeNDMPrimitive shapeNDMPrimitive;
|
||||
IShapeNdmPrimitive shapeNDMPrimitive;
|
||||
|
||||
public PathGeometry PathGeometry { get; set; }
|
||||
|
||||
public ShapeViewPrimitive(IShapeNDMPrimitive shapeNDMPrimitive) : base(shapeNDMPrimitive)
|
||||
public ShapeViewPrimitive(IShapeNdmPrimitive shapeNDMPrimitive) : base(shapeNDMPrimitive)
|
||||
{
|
||||
this.shapeNDMPrimitive = shapeNDMPrimitive;
|
||||
DivisionViewModel = new HasDivisionViewModel(this.shapeNDMPrimitive.DivisionSize);
|
||||
@@ -35,7 +35,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
private void UpdatePath()
|
||||
{
|
||||
var shape = shapeNDMPrimitive.Shape;
|
||||
if (shape is not IPolygonShape polygon)
|
||||
if (shape is not ILinePolygonShape polygon)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(shape));
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ namespace StructureHelper.Windows.Forces
|
||||
{
|
||||
return model.SkipWrongRows;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
model.SkipWrongRows = value;
|
||||
|
||||
@@ -32,6 +32,10 @@ namespace StructureHelper.Windows.Forces
|
||||
}
|
||||
}
|
||||
|
||||
public int RowsNumber => Combinations.Count();
|
||||
//public double MxMin => Combinations.Min( x => x.ForceTuple.Mx);
|
||||
//public double MxMax => Combinations.Max( x => x.ForceTuple.Mx);
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
Combinations.Clear();
|
||||
@@ -41,6 +45,9 @@ namespace StructureHelper.Windows.Forces
|
||||
var combinationList = combination.DesignForces.Where(x => x.LimitState == limitState && x.CalcTerm == calcTerm).ToList();
|
||||
combinationList.ForEach(x => Combinations.Add(x));
|
||||
}
|
||||
OnPropertyChanged(nameof(RowsNumber));
|
||||
//OnPropertyChanged(nameof(MxMin));
|
||||
//OnPropertyChanged(nameof(MxMax));
|
||||
}
|
||||
|
||||
public CalcTerms CalcTerm
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
</ToolBar>
|
||||
</ToolBarTray>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="25"/>
|
||||
</Grid.RowDefinitions>
|
||||
<DataGrid x:Name="ForceGrid" Style="{StaticResource ItemsDataGrid}" ItemsSource="{Binding Combinations}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Limit state" Width="80" MinWidth="70" Binding="{Binding LimitState}"/>
|
||||
@@ -35,6 +39,14 @@
|
||||
<DataGridTextColumn Header="Force Nz" Width="100" Binding="{Binding ForceTuple.Nz, Converter={StaticResource ForceConverter}, ValidatesOnExceptions=True}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<StatusBar Grid.Row="1">
|
||||
<StatusBarItem>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Total number of combinations: "/>
|
||||
<TextBlock Text="{Binding RowsNumber}"/>
|
||||
</StackPanel>
|
||||
</StatusBarItem>
|
||||
</StatusBar>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</Window>
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
using StructureHelper.Windows.ViewModels;
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Windows.ViewModels;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using StructureHelperCommon.Services.FileServices;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace StructureHelper.Windows.Forces
|
||||
{
|
||||
public class ForceFilePropertyVM : OkCancelViewModelBase
|
||||
{
|
||||
private IColumnedFileProperty model;
|
||||
private RelayCommand openFileCommand;
|
||||
|
||||
public ForceFilePropertyVM(IColumnedFileProperty model)
|
||||
{
|
||||
@@ -59,6 +58,31 @@ namespace StructureHelper.Windows.Forces
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ICommand OpenFileCommand => openFileCommand ??= new RelayCommand(o => OpenFileMethod());
|
||||
|
||||
private void OpenFileMethod()
|
||||
{
|
||||
var result = GetFilePath();
|
||||
if (result.IsValid == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FilePath = result.FilePath;
|
||||
}
|
||||
|
||||
private OpenFileResult GetFilePath()
|
||||
{
|
||||
var inputData = new OpenFileInputData()
|
||||
{
|
||||
FilterString = "MS Excel file (*.xlsx)|*.xlsx|All Files (*.*)|*.*",
|
||||
TraceLogger = null
|
||||
};
|
||||
var fileDialog = new FileOpener(inputData);
|
||||
var fileDialogResult = fileDialog.OpenFile();
|
||||
return fileDialogResult;
|
||||
}
|
||||
|
||||
public ObservableCollection<ColumnFilePropertyVM> ColumnProperties { get; set; } = new();
|
||||
|
||||
public IColumnedFileProperty Model
|
||||
|
||||
@@ -47,7 +47,14 @@
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="File name"/>
|
||||
<TextBox Grid.Column="1" Text="{Binding FilePath}" IsEnabled="False"/>
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Text="{Binding FilePath}"/>
|
||||
<Button Grid.Column="1" Content="..." Command="{Binding OpenFileCommand}"/>
|
||||
</Grid>
|
||||
<TextBlock Grid.Row="1" Text="Skip row(s) before header"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding SkipRowBeforeHeaderCount, ValidatesOnDataErrors=True}"/>
|
||||
<TextBlock Grid.Row="2" Text="Skip row(s) of header"/>
|
||||
|
||||
@@ -24,12 +24,11 @@ namespace StructureHelper.Windows.Forces
|
||||
private IUpdateStrategy<IColumnedFileProperty> updateStrategy;
|
||||
private ICommand showDocumentCommand;
|
||||
|
||||
public ICommand FileOpen => openFileCommand ?? (
|
||||
openFileCommand = new RelayCommand(param =>
|
||||
public ICommand FileOpen => openFileCommand ??= new RelayCommand(param =>
|
||||
{
|
||||
OpenFileMethod(param);
|
||||
}
|
||||
));
|
||||
);
|
||||
|
||||
public ICommand ShowSettings => showSettingsCommand ?? (
|
||||
showSettingsCommand = new RelayCommand(param =>
|
||||
@@ -45,6 +44,10 @@ namespace StructureHelper.Windows.Forces
|
||||
}, o => SelectedItem is not null
|
||||
));
|
||||
|
||||
public ListOfFilesVM(List<IColumnedFileProperty> collection) : base(collection)
|
||||
{
|
||||
}
|
||||
|
||||
private void ShowDocumentMethod()
|
||||
{
|
||||
if (SelectedItem is null) { return; }
|
||||
@@ -66,6 +69,7 @@ namespace StructureHelper.Windows.Forces
|
||||
updateStrategy ??= new ColumnedFilePropertyUpdateStrategy();
|
||||
updateStrategy.Update(SelectedItem, clone);
|
||||
}
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private void OpenFileMethod(object param)
|
||||
@@ -81,9 +85,6 @@ namespace StructureHelper.Windows.Forces
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public ListOfFilesVM(List<IColumnedFileProperty> collection) : base(collection)
|
||||
{
|
||||
}
|
||||
|
||||
private OpenFileResult GetFilePath()
|
||||
{
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
|
||||
private ShapeNdmPrimitive GetNewPolygonPrimitive()
|
||||
{
|
||||
PolygonShape polygon = new(Guid.NewGuid());
|
||||
LinePolygonShape polygon = new(Guid.NewGuid());
|
||||
polygon.AddVertex(new Vertex(-0.2, 0.3));
|
||||
polygon.AddVertex(new Vertex(0.2, 0.3));
|
||||
polygon.AddVertex(new Vertex(0.1, 0));
|
||||
@@ -296,7 +296,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
{
|
||||
primitiveBase = new CircleViewPrimitive(ellipse);
|
||||
}
|
||||
else if (newPrimitive is IShapeNDMPrimitive shapeNDMPrimitive)
|
||||
else if (newPrimitive is IShapeNdmPrimitive shapeNDMPrimitive)
|
||||
{
|
||||
primitiveBase = new ShapeViewPrimitive(shapeNDMPrimitive);
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
|
||||
|
||||
private void ShapeEdit(object obj)
|
||||
{
|
||||
if (shape is IPolygonShape polygon)
|
||||
if (shape is ILinePolygonShape polygon)
|
||||
{
|
||||
var viewModel = new PolygonShapeViewModel(polygon, new Point2D() { X = CenterX, Y = CenterY});
|
||||
var window = new PolygonView(viewModel);
|
||||
@@ -308,7 +308,7 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
|
||||
if (window.DialogResult == true)
|
||||
{
|
||||
var newPolygon = viewModel.GetPolygonShape();
|
||||
var updateStrategy = new PolygonShapeUpdateStrategy();
|
||||
var updateStrategy = new LinePolygonShapeUpdateStrategy();
|
||||
updateStrategy.Update(polygon, newPolygon);
|
||||
primitive.Refresh();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.Shapes.Logics
|
||||
{
|
||||
public class PolygonShapeToGraphicPrimitveConvertStrategy : IObjectConvertStrategy<List<IGraphicalPrimitive>, IPolygonShape>
|
||||
public class PolygonShapeToGraphicPrimitveConvertStrategy : IObjectConvertStrategy<List<IGraphicalPrimitive>, ILinePolygonShape>
|
||||
{
|
||||
private PolygonShapeViewModel polygonShapeViewModel;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace StructureHelper.Windows.Shapes.Logics
|
||||
this.polygonShapeViewModel = polygonShapeViewModel;
|
||||
}
|
||||
|
||||
public List<IGraphicalPrimitive> Convert(IPolygonShape source)
|
||||
public List<IGraphicalPrimitive> Convert(ILinePolygonShape source)
|
||||
{
|
||||
List<IGraphicalPrimitive> primitives = new();
|
||||
var polygonPrimitive = new PolygonShapePrimitive(polygonShapeViewModel);
|
||||
|
||||
@@ -19,16 +19,16 @@ namespace StructureHelper.Windows.Shapes
|
||||
{
|
||||
private const int minVertexCount = 3;
|
||||
private readonly IPoint2D center;
|
||||
private readonly IPolygonShape polygonShape;
|
||||
private IObjectConvertStrategy<List<IGraphicalPrimitive>, IPolygonShape> logic;
|
||||
private readonly ILinePolygonShape polygonShape;
|
||||
private IObjectConvertStrategy<List<IGraphicalPrimitive>, ILinePolygonShape> logic;
|
||||
public Point2DViewModel Center { get; }
|
||||
|
||||
public PolygonShapeViewModel(IPolygonShape polygonShape) : this(polygonShape, new Point2D() { X = 0, Y = 0 }) { }
|
||||
public PolygonShapeViewModel(ILinePolygonShape polygonShape) : this(polygonShape, new Point2D() { X = 0, Y = 0 }) { }
|
||||
public VertexViewModel SelectedVertex { get; set; }
|
||||
public ObservableCollection<VertexViewModel> Vertices { get;} = new();
|
||||
public WorkPlaneRootViewModel WorkPlaneRoot { get;} = new();
|
||||
|
||||
public PolygonShapeViewModel(IPolygonShape polygonShape, IPoint2D center)
|
||||
public PolygonShapeViewModel(ILinePolygonShape polygonShape, IPoint2D center)
|
||||
{
|
||||
this.polygonShape = polygonShape;
|
||||
this.center = center;
|
||||
@@ -42,9 +42,9 @@ namespace StructureHelper.Windows.Shapes
|
||||
|
||||
private RelayCommand addVertexCommand;
|
||||
public ICommand AddVertexCommand => addVertexCommand ??= new RelayCommand(AddVertex);
|
||||
public IPolygonShape GetPolygonShape()
|
||||
public ILinePolygonShape GetPolygonShape()
|
||||
{
|
||||
IPolygonShape polygonShape = new PolygonShape(Guid.NewGuid());
|
||||
ILinePolygonShape polygonShape = new LinePolygonShape(Guid.NewGuid());
|
||||
polygonShape.Clear();
|
||||
foreach (var item in Vertices)
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
TraceLogger = convertStrategy.TraceLogger;
|
||||
}
|
||||
|
||||
public ConvertStrategy()
|
||||
protected ConvertStrategy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
|
||||
targetObject.Mx = sourceObject.Mx;
|
||||
targetObject.My = sourceObject.My;
|
||||
targetObject.Nz = sourceObject.Nz;
|
||||
|
||||
19
StructureHelperCommon/Models/Shapes/ILinePolygonShape.cs
Normal file
19
StructureHelperCommon/Models/Shapes/ILinePolygonShape.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
public interface ILinePolygonShape : IShape
|
||||
{
|
||||
IReadOnlyList<IVertex> Vertices { get; }
|
||||
bool IsClosed { get; set; }
|
||||
|
||||
IVertex AddVertex(IVertex vertex);
|
||||
IVertex InsertVertex(int index, IVertex vertex);
|
||||
IVertex AddVertexBefore(IVertex existing, IVertex vertex);
|
||||
IVertex AddVertexAfter(IVertex existing, IVertex vertex);
|
||||
|
||||
void RemoveVertex(IVertex vertex);
|
||||
void Clear();
|
||||
}
|
||||
|
||||
}
|
||||
31
StructureHelperCommon/Models/Shapes/IPolygonArcSegment.cs
Normal file
31
StructureHelperCommon/Models/Shapes/IPolygonArcSegment.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements arc segment of polygon
|
||||
/// </summary>
|
||||
public interface IPolygonArcSegment : IPolygonSegment
|
||||
{
|
||||
/// <summary>
|
||||
/// Vertex of center of arc
|
||||
/// </summary>
|
||||
IVertex Center { get; }
|
||||
/// <summary>
|
||||
/// Radius of arc segment, meters
|
||||
/// </summary>
|
||||
double Radius { get; }
|
||||
/// <summary>
|
||||
/// Start angle, Radians
|
||||
/// </summary>
|
||||
double StartAngle { get; }
|
||||
/// <summary>
|
||||
/// Sweep angle, Radians
|
||||
/// </summary>
|
||||
double SweepAngle { get; }
|
||||
}
|
||||
}
|
||||
15
StructureHelperCommon/Models/Shapes/IPolygonLineSegment.cs
Normal file
15
StructureHelperCommon/Models/Shapes/IPolygonLineSegment.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements line segment of polygon
|
||||
/// </summary>
|
||||
internal interface IPolygonLineSegment : IPolygonSegment
|
||||
{
|
||||
}
|
||||
}
|
||||
11
StructureHelperCommon/Models/Shapes/IPolygonSegment.cs
Normal file
11
StructureHelperCommon/Models/Shapes/IPolygonSegment.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
|
||||
namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
public interface IPolygonSegment : ISaveable
|
||||
{
|
||||
IVertex StartVertex { get; }
|
||||
IVertex EndVertex { get; }
|
||||
void UpdateEndFromParameters();
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,16 @@
|
||||
using System;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
public interface IPolygonShape : IShape
|
||||
/// <summary>
|
||||
/// Implements properties of polygon with diferent types of segment
|
||||
/// </summary>
|
||||
public interface IPolygonShape : ISaveable
|
||||
{
|
||||
IReadOnlyList<IVertex> Vertices { get; }
|
||||
bool IsClosed { get; set; }
|
||||
|
||||
IVertex AddVertex(IVertex vertex);
|
||||
IVertex InsertVertex(int index, IVertex vertex);
|
||||
IVertex AddVertexBefore(IVertex existing, IVertex vertex);
|
||||
IVertex AddVertexAfter(IVertex existing, IVertex vertex);
|
||||
|
||||
void RemoveVertex(IVertex vertex);
|
||||
void Clear();
|
||||
/// <summary>
|
||||
/// Collection of sements of polygon
|
||||
/// </summary>
|
||||
List<IPolygonSegment> Segments { get; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
70
StructureHelperCommon/Models/Shapes/LinePolygonShape.cs
Normal file
70
StructureHelperCommon/Models/Shapes/LinePolygonShape.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
public class LinePolygonShape : ILinePolygonShape
|
||||
{
|
||||
private readonly List<IVertex> _vertices = new();
|
||||
|
||||
public Guid Id { get; }
|
||||
public IReadOnlyList<IVertex> Vertices => _vertices;
|
||||
public bool IsClosed { get; set; } = true;
|
||||
|
||||
public LinePolygonShape(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public IVertex AddVertex(IVertex vertex)
|
||||
{
|
||||
_vertices.Add(vertex);
|
||||
return vertex;
|
||||
}
|
||||
|
||||
public IVertex InsertVertex(int index, IVertex vertex)
|
||||
{
|
||||
_vertices.Insert(index, vertex);
|
||||
return vertex;
|
||||
}
|
||||
|
||||
public IVertex AddVertexBefore(IVertex existing, IVertex vertex)
|
||||
{
|
||||
int index = CheckVertexExists(existing);
|
||||
_vertices.Insert(index, vertex);
|
||||
return vertex;
|
||||
}
|
||||
public IVertex AddVertexAfter(IVertex existing, IVertex vertex)
|
||||
{
|
||||
int index = CheckVertexExists(existing);
|
||||
_vertices.Insert(index + 1, vertex);
|
||||
return vertex;
|
||||
}
|
||||
|
||||
public void RemoveVertex(IVertex vertex)
|
||||
{
|
||||
if (!_vertices.Remove(vertex))
|
||||
throw new StructureHelperException("The specified vertex was not found in the polygon.");
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_vertices.Clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private int CheckVertexExists(IVertex existing)
|
||||
{
|
||||
int index = _vertices.IndexOf(existing);
|
||||
if (index == -1)
|
||||
{
|
||||
throw new StructureHelperException("The specified vertex was not found in the polygon.");
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,9 +9,9 @@ namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
public interface IPolygonCalculator
|
||||
{
|
||||
double GetPerimeter(IPolygonShape polygon);
|
||||
double GetArea(IPolygonShape polygon);
|
||||
bool ContainsPoint(IPolygonShape polygon, IPoint2D point);
|
||||
double GetPerimeter(ILinePolygonShape polygon);
|
||||
double GetArea(ILinePolygonShape polygon);
|
||||
bool ContainsPoint(ILinePolygonShape polygon, IPoint2D point);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes.Logics;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
public class LinePolygonShapeUpdateStrategy : IParentUpdateStrategy<ILinePolygonShape>
|
||||
{
|
||||
public bool UpdateChildren { get; set; } = true;
|
||||
|
||||
public void Update(ILinePolygonShape targetObject, ILinePolygonShape sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
|
||||
// Update simple properties
|
||||
targetObject.IsClosed = sourceObject.IsClosed;
|
||||
if (UpdateChildren == true)
|
||||
{
|
||||
// Replace vertices
|
||||
targetObject.Clear();
|
||||
foreach (var vertex in sourceObject.Vertices)
|
||||
{
|
||||
// Copy the underlying point into a new vertex
|
||||
Vertex newVertex = GetVertexClone(vertex);
|
||||
targetObject.AddVertex(newVertex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Vertex GetVertexClone(IVertex vertex)
|
||||
{
|
||||
var updateStrategy = new VertexUpdateStrategy();
|
||||
Vertex newVertex = new(Guid.NewGuid());
|
||||
updateStrategy.Update(newVertex, vertex);
|
||||
return newVertex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
public class PolygonCalculator : IPolygonCalculator
|
||||
{
|
||||
public double GetPerimeter(IPolygonShape polygon)
|
||||
public double GetPerimeter(ILinePolygonShape polygon)
|
||||
{
|
||||
if (polygon.Vertices.Count < 2)
|
||||
return 0;
|
||||
@@ -24,7 +24,7 @@ namespace StructureHelperCommon.Models.Shapes
|
||||
return perimeter;
|
||||
}
|
||||
|
||||
public double GetArea(IPolygonShape polygon)
|
||||
public double GetArea(ILinePolygonShape polygon)
|
||||
{
|
||||
if (!polygon.IsClosed || polygon.Vertices.Count < 3)
|
||||
return 0;
|
||||
@@ -41,7 +41,7 @@ namespace StructureHelperCommon.Models.Shapes
|
||||
return Math.Abs(sum) / 2.0;
|
||||
}
|
||||
|
||||
public bool ContainsPoint(IPolygonShape polygon, IPoint2D point)
|
||||
public bool ContainsPoint(ILinePolygonShape polygon, IPoint2D point)
|
||||
{
|
||||
if (!polygon.IsClosed || polygon.Vertices.Count < 3)
|
||||
return false;
|
||||
|
||||
@@ -9,10 +9,10 @@ namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
public static class PolygonGeometryUtils
|
||||
{
|
||||
public static IPolygonShape GetTratsfromedPolygon(IPolygonShape polygon, double dx, double dy)
|
||||
public static ILinePolygonShape GetTratsfromedPolygon(ILinePolygonShape polygon, double dx, double dy)
|
||||
{
|
||||
IPolygonShape newPolygon = new PolygonShape(Guid.Empty);
|
||||
var updateLogic = new PolygonShapeUpdateStrategy();
|
||||
ILinePolygonShape newPolygon = new LinePolygonShape(Guid.Empty);
|
||||
var updateLogic = new LinePolygonShapeUpdateStrategy();
|
||||
updateLogic.Update(newPolygon, polygon);
|
||||
foreach (var item in newPolygon.Vertices)
|
||||
{
|
||||
@@ -21,7 +21,7 @@ namespace StructureHelperCommon.Models.Shapes
|
||||
}
|
||||
return newPolygon;
|
||||
}
|
||||
public static bool DoPolygonsEdgesIntersect(IPolygonShape polygon)
|
||||
public static bool DoPolygonsEdgesIntersect(ILinePolygonShape polygon)
|
||||
{
|
||||
var vertices = polygon.Vertices;
|
||||
int n = vertices.Count;
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
public class PolygonShapeUpdateStrategy : IUpdateStrategy<IPolygonShape>
|
||||
{
|
||||
public void Update(IPolygonShape targetObject, IPolygonShape sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
|
||||
// Update simple properties
|
||||
targetObject.IsClosed = sourceObject.IsClosed;
|
||||
|
||||
// Replace vertices
|
||||
targetObject.Clear();
|
||||
foreach (var vertex in sourceObject.Vertices)
|
||||
{
|
||||
// Copy the underlying point into a new vertex
|
||||
Vertex newVertex = GetVertexClone(vertex);
|
||||
targetObject.AddVertex(newVertex);
|
||||
}
|
||||
}
|
||||
|
||||
private static Vertex GetVertexClone(IVertex vertex)
|
||||
{
|
||||
Point2D newVertexPoint = new(Guid.NewGuid())
|
||||
{
|
||||
X = vertex.Point.X,
|
||||
Y = vertex.Point.Y
|
||||
};
|
||||
Vertex newVertex = new(Guid.NewGuid())
|
||||
{
|
||||
Point = newVertexPoint
|
||||
};
|
||||
return newVertex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,7 +24,7 @@ namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
ProcessCircles(targetObject, sourceCircle);
|
||||
}
|
||||
else if (sourceObject is IPolygonShape sourcePolygon)
|
||||
else if (sourceObject is ILinePolygonShape sourcePolygon)
|
||||
{
|
||||
ProcessPolygon(targetObject, sourcePolygon);
|
||||
}
|
||||
@@ -34,11 +34,11 @@ namespace StructureHelperCommon.Models.Shapes
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessPolygon(IShape targetObject, IPolygonShape sourcePolygon)
|
||||
private void ProcessPolygon(IShape targetObject, ILinePolygonShape sourcePolygon)
|
||||
{
|
||||
if (targetObject is IPolygonShape targetPolygon)
|
||||
if (targetObject is ILinePolygonShape targetPolygon)
|
||||
{
|
||||
var updateLogic = new PolygonShapeUpdateStrategy();
|
||||
var updateLogic = new LinePolygonShapeUpdateStrategy();
|
||||
updateLogic.Update(targetPolygon, sourcePolygon);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
public class VertexUpdateStrategy : IParentUpdateStrategy<IVertex>
|
||||
{
|
||||
public bool UpdateChildren { get; set; } = true;
|
||||
|
||||
public void Update(IVertex targetObject, IVertex sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
if (UpdateChildren == true)
|
||||
{
|
||||
var newPoint = sourceObject.Point.Clone() as IPoint2D;
|
||||
targetObject.Point = newPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
StructureHelperCommon/Models/Shapes/PolygonArcSegment.cs
Normal file
41
StructureHelperCommon/Models/Shapes/PolygonArcSegment.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
public class PolygonArcSegment : IPolygonArcSegment
|
||||
{
|
||||
|
||||
public Guid Id { get; }
|
||||
public IVertex StartVertex { get; set; }
|
||||
public IVertex EndVertex { get; set; }
|
||||
public IVertex Center { get; }
|
||||
public double Radius { get; }
|
||||
public double StartAngle { get; }
|
||||
public double SweepAngle { get; }
|
||||
public PolygonArcSegment(Guid id, IVertex startVertex, IVertex center, double radius, double startAngleDeg, double sweepAngleDeg)
|
||||
{
|
||||
Id = id;
|
||||
StartVertex = startVertex;
|
||||
Center = center;
|
||||
Radius = radius;
|
||||
StartAngle = startAngleDeg;
|
||||
SweepAngle = sweepAngleDeg;
|
||||
EndVertex = new Vertex(Guid.NewGuid());
|
||||
UpdateEndFromParameters();
|
||||
}
|
||||
|
||||
public void UpdateEndFromParameters()
|
||||
{
|
||||
double endAngle = StartAngle + SweepAngle;
|
||||
double endVertexX = Center.Point.X + Radius * Math.Cos(endAngle);
|
||||
double endVertexY = Center.Point.Y + Radius * Math.Sin(endAngle);
|
||||
EndVertex.Point.X = endVertexX;
|
||||
EndVertex.Point.Y = endVertexY;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
22
StructureHelperCommon/Models/Shapes/PolygonLineSegment.cs
Normal file
22
StructureHelperCommon/Models/Shapes/PolygonLineSegment.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
public class PolygonLineSegment : IPolygonLineSegment
|
||||
{
|
||||
public Guid Id { get; }
|
||||
public IVertex StartVertex { get; }
|
||||
public IVertex EndVertex { get; }
|
||||
|
||||
|
||||
public PolygonLineSegment(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public void UpdateEndFromParameters()
|
||||
{
|
||||
//nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,70 +1,16 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
public class PolygonShape : IPolygonShape
|
||||
{
|
||||
private readonly List<IVertex> _vertices = new();
|
||||
|
||||
public Guid Id { get; }
|
||||
public IReadOnlyList<IVertex> Vertices => _vertices;
|
||||
public bool IsClosed { get; set; } = true;
|
||||
|
||||
public List<IPolygonSegment> Segments { get; } = [];
|
||||
public PolygonShape(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public IVertex AddVertex(IVertex vertex)
|
||||
{
|
||||
_vertices.Add(vertex);
|
||||
return vertex;
|
||||
}
|
||||
|
||||
public IVertex InsertVertex(int index, IVertex vertex)
|
||||
{
|
||||
_vertices.Insert(index, vertex);
|
||||
return vertex;
|
||||
}
|
||||
|
||||
public IVertex AddVertexBefore(IVertex existing, IVertex vertex)
|
||||
{
|
||||
int index = CheckVertexExists(existing);
|
||||
_vertices.Insert(index, vertex);
|
||||
return vertex;
|
||||
}
|
||||
public IVertex AddVertexAfter(IVertex existing, IVertex vertex)
|
||||
{
|
||||
int index = CheckVertexExists(existing);
|
||||
_vertices.Insert(index + 1, vertex);
|
||||
return vertex;
|
||||
}
|
||||
|
||||
public void RemoveVertex(IVertex vertex)
|
||||
{
|
||||
if (!_vertices.Remove(vertex))
|
||||
throw new InvalidOperationException("The specified vertex was not found in the polygon.");
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_vertices.Clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private int CheckVertexExists(IVertex existing)
|
||||
{
|
||||
int index = _vertices.IndexOf(existing);
|
||||
if (index == -1)
|
||||
{
|
||||
throw new StructureHelperException("The specified vertex was not found in the polygon.");
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public interface IShapeNDMPrimitive : INdmPrimitive, IHasDivisionSize
|
||||
public interface IShapeNdmPrimitive : INdmPrimitive, IHasDivisionSize
|
||||
{
|
||||
void SetShape(IShape shape);
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Models.Shapes.Logics;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperCommon.Services.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
internal class BaseUpdateStrategy : IUpdateStrategy<INdmPrimitive>
|
||||
{
|
||||
static readonly Point2DUpdateStrategy point2DUpdateStrategy = new();
|
||||
readonly ForceTupleUpdateStrategy tupleUpdateStrategy = new();
|
||||
readonly VisualPropsUpdateStrategy visualPropsUpdateStrategy = new();
|
||||
|
||||
public void Update(INdmPrimitive targetObject, INdmPrimitive sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Name = sourceObject.Name;
|
||||
if (sourceObject.NdmElement.HeadMaterial != null)
|
||||
{
|
||||
targetObject.NdmElement.HeadMaterial = sourceObject.NdmElement.HeadMaterial;
|
||||
}
|
||||
targetObject.NdmElement.Triangulate = sourceObject.NdmElement.Triangulate;
|
||||
point2DUpdateStrategy.Update(targetObject.Center, sourceObject.Center);
|
||||
targetObject.RotationAngle = sourceObject.RotationAngle;
|
||||
visualPropsUpdateStrategy.Update(targetObject.VisualProperty, sourceObject.VisualProperty);
|
||||
tupleUpdateStrategy.Update(targetObject.NdmElement.UsersPrestrain, sourceObject.NdmElement.UsersPrestrain);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
this.divisionPropsUpdateStrategy = divisionPropsUpdateStrategy;
|
||||
}
|
||||
public EllipsePrimitiveUpdateStrategy() : this(
|
||||
new BaseUpdateStrategy(),
|
||||
new NdmPrimitiveBaseUpdateStrategy(),
|
||||
new ShapeUpdateStrategy(),
|
||||
new DivisionSizeUpdateStrategy())
|
||||
{
|
||||
|
||||
@@ -5,10 +5,12 @@ using StructureHelperCommon.Services;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
|
||||
{
|
||||
public class NdmElementUpdateStrategy : IUpdateStrategy<INdmElement>
|
||||
public class NdmElementUpdateStrategy : IParentUpdateStrategy<INdmElement>
|
||||
{
|
||||
private readonly IUpdateStrategy<IForceTuple> tupleUpdateStrategy;
|
||||
|
||||
public bool UpdateChildren { get; set; } = true;
|
||||
|
||||
public NdmElementUpdateStrategy(IUpdateStrategy<IForceTuple> tupleUpdateStrategy)
|
||||
{
|
||||
this.tupleUpdateStrategy = tupleUpdateStrategy;
|
||||
@@ -24,12 +26,15 @@ namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
|
||||
{
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Triangulate = sourceObject.Triangulate;
|
||||
tupleUpdateStrategy.Update(targetObject.UsersPrestrain, sourceObject.UsersPrestrain);
|
||||
if (UpdateChildren == true)
|
||||
{
|
||||
if (sourceObject.HeadMaterial != null)
|
||||
{
|
||||
targetObject.HeadMaterial = sourceObject.HeadMaterial;
|
||||
}
|
||||
targetObject.Triangulate = sourceObject.Triangulate;
|
||||
tupleUpdateStrategy.Update(targetObject.UsersPrestrain, sourceObject.UsersPrestrain);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives.Logics;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
internal class NdmPrimitiveBaseUpdateStrategy : IParentUpdateStrategy<INdmPrimitive>
|
||||
{
|
||||
private IUpdateStrategy<INdmElement> ndmElementUpdateStrategy;
|
||||
private IUpdateStrategy<IPoint2D> point2DUpdateStrategy;
|
||||
private IUpdateStrategy<IVisualProperty> visualPropsUpdateStrategy;
|
||||
|
||||
public bool UpdateChildren { get; set; } = true;
|
||||
|
||||
public void Update(INdmPrimitive targetObject, INdmPrimitive sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
InitializeStrategies();
|
||||
targetObject.Name = sourceObject.Name;
|
||||
targetObject.RotationAngle = sourceObject.RotationAngle;
|
||||
targetObject.CrossSection = sourceObject.CrossSection;
|
||||
if (UpdateChildren == true)
|
||||
{
|
||||
point2DUpdateStrategy.Update(targetObject.Center, sourceObject.Center);
|
||||
visualPropsUpdateStrategy.Update(targetObject.VisualProperty, sourceObject.VisualProperty);
|
||||
ndmElementUpdateStrategy.Update(targetObject.NdmElement, sourceObject.NdmElement);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
point2DUpdateStrategy = new Point2DUpdateStrategy();
|
||||
visualPropsUpdateStrategy = new VisualPropsUpdateStrategy();
|
||||
ndmElementUpdateStrategy = new NdmElementUpdateStrategy() {UpdateChildren = UpdateChildren };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,9 +27,9 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
new EllipsePrimitiveUpdateStrategy().Update(circle, (EllipseNdmPrimitive)sourceObject);
|
||||
}
|
||||
else if (targetObject is IShapeNDMPrimitive shapePrimitive)
|
||||
else if (targetObject is IShapeNdmPrimitive shapePrimitive)
|
||||
{
|
||||
new ShapeNDMPrimitiveUpdateStrategy().Update(shapePrimitive, (IShapeNDMPrimitive)sourceObject);
|
||||
new ShapeNdmPrimitiveUpdateStrategy().Update(shapePrimitive, (IShapeNdmPrimitive)sourceObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public class PointNdmPrimitiveUpdateStrategy : IUpdateStrategy<IPointNdmPrimitive>
|
||||
{
|
||||
static readonly BaseUpdateStrategy basePrimitiveUpdateStrategy = new();
|
||||
static readonly NdmPrimitiveBaseUpdateStrategy basePrimitiveUpdateStrategy = new();
|
||||
public void Update(IPointNdmPrimitive targetObject, IPointNdmPrimitive sourceObject)
|
||||
{
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public class RebarNdmPrimitiveUpdateStrategy : IUpdateStrategy<IRebarNdmPrimitive>
|
||||
{
|
||||
static readonly BaseUpdateStrategy basePrimitiveUpdateStrategy = new();
|
||||
static readonly NdmPrimitiveBaseUpdateStrategy basePrimitiveUpdateStrategy = new();
|
||||
public void Update(IRebarNdmPrimitive targetObject, IRebarNdmPrimitive sourceObject)
|
||||
{
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
this.divisionPropsUpdateStrategy = divisionPropsUpdateStrategy;
|
||||
}
|
||||
public RectanglePrimitiveUpdateStrategy() : this(
|
||||
new BaseUpdateStrategy(),
|
||||
new NdmPrimitiveBaseUpdateStrategy(),
|
||||
new ShapeUpdateStrategy(),
|
||||
new DivisionSizeUpdateStrategy())
|
||||
{
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public class ShapeNDMPrimitiveUpdateStrategy : IUpdateStrategy<IShapeNDMPrimitive>
|
||||
public class ShapeNdmPrimitiveUpdateStrategy : IParentUpdateStrategy<IShapeNdmPrimitive>
|
||||
{
|
||||
private IUpdateStrategy<INdmPrimitive> basePrimitiveUpdateStrategy;
|
||||
private IParentUpdateStrategy<INdmPrimitive> basePrimitiveUpdateStrategy;
|
||||
private IUpdateStrategy<IDivisionSize> divisionPropsUpdateStrategy;
|
||||
private IUpdateStrategy<IShape> shapeUpdateStrategy;
|
||||
|
||||
public ShapeNDMPrimitiveUpdateStrategy(
|
||||
IUpdateStrategy<INdmPrimitive> basePrimitiveUpdateStrategy,
|
||||
public bool UpdateChildren { get; set; } = true;
|
||||
|
||||
public ShapeNdmPrimitiveUpdateStrategy(
|
||||
IParentUpdateStrategy<INdmPrimitive> basePrimitiveUpdateStrategy,
|
||||
IUpdateStrategy<IShape> shapeUpdateStrategy,
|
||||
IUpdateStrategy<IDivisionSize> divisionPropsUpdateStrategy)
|
||||
{
|
||||
@@ -25,28 +22,31 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
this.divisionPropsUpdateStrategy = divisionPropsUpdateStrategy;
|
||||
}
|
||||
|
||||
public ShapeNDMPrimitiveUpdateStrategy() : this(
|
||||
new BaseUpdateStrategy(),
|
||||
public ShapeNdmPrimitiveUpdateStrategy() : this(
|
||||
new NdmPrimitiveBaseUpdateStrategy(),
|
||||
new ShapeUpdateStrategy(),
|
||||
new DivisionSizeUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Update(IShapeNDMPrimitive targetObject, IShapeNDMPrimitive sourceObject)
|
||||
public void Update(IShapeNdmPrimitive targetObject, IShapeNdmPrimitive sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject, "source object");
|
||||
CheckObject.IsNull(targetObject, "target object");
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
InitializeStrategies();
|
||||
basePrimitiveUpdateStrategy.Update(targetObject, sourceObject);
|
||||
if (UpdateChildren == true)
|
||||
{
|
||||
divisionPropsUpdateStrategy.Update(targetObject.DivisionSize, sourceObject.DivisionSize);
|
||||
shapeUpdateStrategy.Update(targetObject.Shape, sourceObject.Shape);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
basePrimitiveUpdateStrategy ??= new BaseUpdateStrategy();
|
||||
basePrimitiveUpdateStrategy ??= new NdmPrimitiveBaseUpdateStrategy();
|
||||
basePrimitiveUpdateStrategy.UpdateChildren = UpdateChildren;
|
||||
divisionPropsUpdateStrategy ??= new DivisionSizeUpdateStrategy();
|
||||
shapeUpdateStrategy ??= new ShapeUpdateStrategy();
|
||||
}
|
||||
|
||||
@@ -4,18 +4,13 @@ using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public class ShapeNdmPrimitive : IShapeNDMPrimitive
|
||||
public class ShapeNdmPrimitive : IShapeNdmPrimitive
|
||||
{
|
||||
private IShape shape;
|
||||
private IUpdateStrategy<IShapeNDMPrimitive> updateStrategy;
|
||||
private IUpdateStrategy<IShapeNdmPrimitive> updateStrategy;
|
||||
|
||||
public Guid Id { get; }
|
||||
public string? Name { get; set; } = string.Empty;
|
||||
@@ -34,9 +29,9 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
public object Clone()
|
||||
{
|
||||
var primitive = new ShapeNdmPrimitive(Guid.NewGuid());
|
||||
PolygonShape polygon = new(Guid.NewGuid());
|
||||
LinePolygonShape polygon = new(Guid.NewGuid());
|
||||
primitive.SetShape(polygon);
|
||||
updateStrategy ??= new ShapeNDMPrimitiveUpdateStrategy();
|
||||
updateStrategy ??= new ShapeNdmPrimitiveUpdateStrategy();
|
||||
updateStrategy.Update(primitive, this);
|
||||
return primitive;
|
||||
}
|
||||
@@ -57,7 +52,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
Area = 0d
|
||||
};
|
||||
points.Add(newPoint);
|
||||
if (shape is IPolygonShape polygon)
|
||||
if (shape is ILinePolygonShape polygon)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var item in polygon.Vertices)
|
||||
@@ -77,7 +72,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
|
||||
public bool IsPointInside(IPoint2D point)
|
||||
{
|
||||
if (shape is IPolygonShape polygon)
|
||||
if (shape is ILinePolygonShape polygon)
|
||||
{
|
||||
var newShape = PolygonGeometryUtils.GetTratsfromedPolygon(polygon, Center.X, Center.Y);
|
||||
var calculator = new PolygonCalculator();
|
||||
|
||||
Reference in New Issue
Block a user