Add VisualAnalysisDTO

This commit is contained in:
Evgeny Redikultsev
2024-09-14 19:03:35 +05:00
parent 5a9e7c3c4f
commit c10d6eb94e
84 changed files with 958 additions and 410 deletions

View File

@@ -0,0 +1,30 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Projects;
namespace DataAccess.DTOs
{
public class FileVersionFromDTOConvertStrategy : IConvertStrategy<FileVersion, FileVersionDTO>
{
private IUpdateStrategy<IFileVersion> updateStrategy;
public IShiftTraceLogger TraceLogger { get; set; }
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public FileVersionFromDTOConvertStrategy(IUpdateStrategy<IFileVersion> updateStrategy)
{
this.updateStrategy = updateStrategy;
}
public FileVersionFromDTOConvertStrategy() : this(new FileVersionUpdateStrategy())
{
}
public FileVersion Convert(FileVersionDTO source)
{
FileVersion fileVersion = new(source.Id);
updateStrategy.Update(fileVersion, source);
return fileVersion;
}
}
}

View File

@@ -0,0 +1,30 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Projects;
namespace DataAccess.DTOs
{
public class FileVersionToDTOConvertStrategy : IConvertStrategy<FileVersionDTO, IFileVersion>
{
private IUpdateStrategy<IFileVersion> updateStrategy;
public IShiftTraceLogger TraceLogger { get; set; }
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public FileVersionToDTOConvertStrategy(IUpdateStrategy<IFileVersion> updateStrategy)
{
this.updateStrategy = updateStrategy;
}
public FileVersionToDTOConvertStrategy() : this(new FileVersionUpdateStrategy())
{
}
public FileVersionDTO Convert(IFileVersion source)
{
FileVersionDTO fileVersion = new(source.Id);
updateStrategy.Update(fileVersion, source);
return fileVersion;
}
}
}

View File

@@ -0,0 +1,51 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Analyses;
using StructureHelperCommon.Models.Projects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class ProjectToDTOConvertStrategy : IConvertStrategy<ProjectDTO, IProject>
{
private IUpdateStrategy<IProject> updateStrategy;
private IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertStrategy;
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public ProjectToDTOConvertStrategy(IUpdateStrategy<IProject> updateStrategy, IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertStrategy)
{
this.updateStrategy = updateStrategy;
this.convertStrategy = convertStrategy;
}
public ProjectToDTOConvertStrategy() : this(new ProjectUpdateStrategy(), new VisualAnalysisToDTOConvertStrategy())
{
}
public ProjectDTO Convert(IProject source)
{
ProjectDTO projectDTO = new(source.Id);
updateStrategy.Update(projectDTO, source);
convertStrategy.ReferenceDictionary = ReferenceDictionary;
var convertLogic = new DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>()
{
ReferenceDictionary = ReferenceDictionary,
ConvertStrategy = convertStrategy,
TraceLogger = TraceLogger
};
foreach (var item in source.VisualAnalyses)
{
var newVisualAnalysis = convertLogic.Convert(item);
projectDTO.VisualAnalyses.Add(newVisualAnalysis);
}
return projectDTO;
}
}
}

View File

@@ -0,0 +1,26 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Analyses;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
internal class VisualAnalysisToDTOConvertStrategy : IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>
{
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public VisualAnalysisDTO Convert(IVisualAnalysis source)
{
VisualAnalysisDTO visualAnalysisDTO = new()
{
Id = source.Id
};
return visualAnalysisDTO;
}
}
}

View File

@@ -1,41 +0,0 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Projects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class FileVersionDTOConvertStrategy : IConvertStrategy<FileVersion, FileVersionDTO>
{
private IUpdateStrategy<IFileVersion> updateStrategy;
public IShiftTraceLogger TraceLogger { get; set; }
public FileVersionDTOConvertStrategy(IUpdateStrategy<IFileVersion> updateStrategy)
{
this.updateStrategy = updateStrategy;
}
public FileVersionDTOConvertStrategy() : this(new FileVersionUpdateStrategy())
{
}
public FileVersionDTO ConvertTo(FileVersion source)
{
FileVersionDTO fileVersion = new(source.Id);
updateStrategy.Update(fileVersion, source);
return fileVersion;
}
public FileVersion ConvertFrom(FileVersionDTO source)
{
FileVersion fileVersion = new(source.Id);
updateStrategy.Update(fileVersion, source);
return fileVersion;
}
}
}

View File

@@ -15,8 +15,6 @@ namespace DataAccess.DTOs
{ {
[JsonProperty("Id")] [JsonProperty("Id")]
public Guid Id { get; set; } public Guid Id { get; set; }
[JsonProperty("Center")]
public IPoint2D Center { get; set; }
[JsonProperty("HeadMaterial")] [JsonProperty("HeadMaterial")]
public IHeadMaterial? HeadMaterial { get; set; } public IHeadMaterial? HeadMaterial { get; set; }
[JsonProperty("Triangulate")] [JsonProperty("Triangulate")]

View File

@@ -21,7 +21,7 @@ namespace DataAccess.DTOs
public bool IsActual { get; set; } public bool IsActual { get; set; }
[JsonProperty("VisualAnalyses")] [JsonProperty("VisualAnalyses")]
public List<IVisualAnalysis> VisualAnalyses { get; private set; } public List<IVisualAnalysis> VisualAnalyses { get; private set; } = new();
[JsonIgnore] [JsonIgnore]
public string FileName { get; set; } public string FileName { get; set; }
@@ -31,5 +31,10 @@ namespace DataAccess.DTOs
Id = id; Id = id;
} }
public ProjectDTO() : this (Guid.NewGuid())
{
}
} }
} }

View File

@@ -0,0 +1,29 @@
using Newtonsoft.Json;
using StructureHelperCommon.Models.Analyses;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class VisualAnalysisDTO : IVisualAnalysis
{
[JsonProperty("Id")]
public Guid Id { get; set; }
[JsonProperty("Analysis")]
public IAnalysis Analysis { get; set; }
public object Clone()
{
throw new NotImplementedException();
}
public void Run()
{
throw new NotImplementedException();
}
}
}

View File

@@ -52,6 +52,15 @@ namespace DataAccess.Infrastructures
refDictinary = new Dictionary<(Guid id, Type type), ISaveable>(); refDictinary = new Dictionary<(Guid id, Type type), ISaveable>();
FileVersionDTO versionDTO = GetVersionDTO(); FileVersionDTO versionDTO = GetVersionDTO();
var versionString = Serialize(versionDTO, TraceLogger); var versionString = Serialize(versionDTO, TraceLogger);
SaveStringToFile(project, versionString);
refDictinary = new Dictionary<(Guid id, Type type), ISaveable>();
ProjectDTO projectDTO = GetProjectDTO(project);
var projectString = Serialize(projectDTO, TraceLogger);
SaveStringToFile(project, projectString);
}
private void SaveStringToFile(IProject project, string versionString)
{
try try
{ {
File.WriteAllText(project.FullFileName, versionString); File.WriteAllText(project.FullFileName, versionString);
@@ -63,19 +72,36 @@ namespace DataAccess.Infrastructures
} }
} }
private FileVersionDTO GetVersionDTO() private ProjectDTO GetProjectDTO(IProject project)
{ {
FileVersionDTOConvertStrategy fileVersionDTOConvertStrategy = new() ProjectToDTOConvertStrategy convertStrategy = new()
{ {
ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger TraceLogger = TraceLogger
}; };
DictionaryConvertStrategy<FileVersion, FileVersionDTO> dictionaryConvertStrategy = new() DictionaryConvertStrategy<ProjectDTO, IProject> dictionaryConvertStrategy = new()
{
ConvertStrategy = convertStrategy,
ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger
};
return dictionaryConvertStrategy.Convert(project);
}
private FileVersionDTO GetVersionDTO()
{
FileVersionToDTOConvertStrategy fileVersionDTOConvertStrategy = new()
{
ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger
};
DictionaryConvertStrategy<FileVersionDTO,IFileVersion> dictionaryConvertStrategy = new()
{ {
ConvertStrategy = fileVersionDTOConvertStrategy, ConvertStrategy = fileVersionDTOConvertStrategy,
ReferenceDictionary = refDictinary, ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger TraceLogger = TraceLogger
}; };
var versionDTO = dictionaryConvertStrategy.ConvertTo(version as FileVersion); var versionDTO = dictionaryConvertStrategy.Convert(version);
return versionDTO; return versionDTO;
} }
@@ -85,8 +111,9 @@ namespace DataAccess.Infrastructures
{ {
Converters = new List<JsonConverter> Converters = new List<JsonConverter>
{ {
new FileVersionDTOJsonConverter(logger), // Add the specific converter
// Add other converters if needed // Add other converters if needed
new FileVersionDTOJsonConverter(logger), // Add the specific converter
new ProjectDTOJsonConverter(logger)
}, },
Formatting = Formatting.Indented, Formatting = Formatting.Indented,
PreserveReferencesHandling = PreserveReferencesHandling.All, PreserveReferencesHandling = PreserveReferencesHandling.All,

View File

@@ -0,0 +1,18 @@
using DataAccess.DTOs;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Projects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.JsonConverters
{
internal class ProjectDTOJsonConverter : BaseJsonConverter<ProjectDTO>
{
public ProjectDTOJsonConverter(IShiftTraceLogger logger) : base(logger)
{
}
}
}

View File

@@ -0,0 +1,17 @@
using DataAccess.DTOs;
using StructureHelperCommon.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.JsonConverters
{
internal class VisualAnalysisDTOJsonConverter : BaseJsonConverter<VisualAnalysisDTO>
{
public VisualAnalysisDTOJsonConverter(IShiftTraceLogger logger) : base(logger)
{
}
}
}

View File

@@ -12,16 +12,16 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
{ {
public class CircleViewPrimitive : PrimitiveBase, IHasCenter public class CircleViewPrimitive : PrimitiveBase, IHasCenter
{ {
ICirclePrimitive primitive; IEllipsePrimitive primitive;
public double Diameter public double Diameter
{ {
get get
{ {
return primitive.Diameter; return primitive.DiameterByX;
} }
set set
{ {
primitive.Diameter = value; primitive.DiameterByX = value;
RefreshPlacement(); RefreshPlacement();
} }
} }
@@ -31,13 +31,13 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
public CircleViewPrimitive(INdmPrimitive primitive) : base(primitive) public CircleViewPrimitive(INdmPrimitive primitive) : base(primitive)
{ {
if (primitive is not ICirclePrimitive) if (primitive is not IEllipsePrimitive)
{ {
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $"\nExpected: {nameof(ICirclePrimitive)}, But was: {nameof(primitive)}"); throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $"\nExpected: {nameof(IEllipsePrimitive)}, But was: {nameof(primitive)}");
} }
var circle = primitive as ICirclePrimitive; var circle = primitive as IEllipsePrimitive;
this.primitive = circle; this.primitive = circle;
DivisionViewModel = new HasDivisionViewModel(circle); DivisionViewModel = new HasDivisionViewModel(circle.DivisionSize);
} }
public override INdmPrimitive GetNdmPrimitive() public override INdmPrimitive GetNdmPrimitive()

View File

@@ -60,49 +60,49 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
} }
public bool Triangulate public bool Triangulate
{ {
get => primitive.Triangulate; get => primitive.NdmElement.Triangulate;
set set
{ {
primitive.Triangulate = value; primitive.NdmElement.Triangulate = value;
OnPropertyChanged(nameof(Triangulate)); OnPropertyChanged(nameof(Triangulate));
} }
} }
public double InvertedCenterY => - CenterY; public double InvertedCenterY => - CenterY;
public double PrestrainKx public double PrestrainKx
{ get => primitive.UsersPrestrain.Mx; { get => primitive.NdmElement.UsersPrestrain.Mx;
set set
{ {
primitive.UsersPrestrain.Mx = value; primitive.NdmElement.UsersPrestrain.Mx = value;
OnPropertyChanged(nameof(PrestrainKx)); OnPropertyChanged(nameof(PrestrainKx));
} }
} }
public double PrestrainKy public double PrestrainKy
{ get => primitive.UsersPrestrain.My; { get => primitive.NdmElement.UsersPrestrain.My;
set set
{ {
primitive.UsersPrestrain.My = value; primitive.NdmElement.UsersPrestrain.My = value;
OnPropertyChanged(nameof(PrestrainKy)); OnPropertyChanged(nameof(PrestrainKy));
} }
} }
public double PrestrainEpsZ public double PrestrainEpsZ
{ get => primitive.UsersPrestrain.Nz; { get => primitive.NdmElement.UsersPrestrain.Nz;
set set
{ {
primitive.UsersPrestrain.Nz = value; primitive.NdmElement.UsersPrestrain.Nz = value;
OnPropertyChanged(nameof(PrestrainEpsZ)); OnPropertyChanged(nameof(PrestrainEpsZ));
} }
} }
public double AutoPrestrainKx => primitive.AutoPrestrain.Mx; public double AutoPrestrainKx => primitive.NdmElement.AutoPrestrain.Mx;
public double AutoPrestrainKy => primitive.AutoPrestrain.My; public double AutoPrestrainKy => primitive.NdmElement.AutoPrestrain.My;
public double AutoPrestrainEpsZ => primitive.AutoPrestrain.Nz; public double AutoPrestrainEpsZ => primitive.NdmElement.AutoPrestrain.Nz;
public IHeadMaterial HeadMaterial public IHeadMaterial HeadMaterial
{ {
get => primitive.HeadMaterial; get => primitive.NdmElement.HeadMaterial;
set set
{ {
primitive.HeadMaterial = value; primitive.NdmElement.HeadMaterial = value;
OnPropertyChanged(nameof(HeadMaterial)); OnPropertyChanged(nameof(HeadMaterial));
OnPropertyChanged(nameof(Color)); OnPropertyChanged(nameof(Color));
} }
@@ -121,7 +121,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
public Color Color public Color Color
{ {
get => ((primitive.VisualProperty.SetMaterialColor == true) get => ((primitive.VisualProperty.SetMaterialColor == true)
& (primitive.HeadMaterial !=null))? primitive.HeadMaterial.Color : primitive.VisualProperty.Color; & (primitive.NdmElement.HeadMaterial !=null))? primitive.NdmElement.HeadMaterial.Color : primitive.VisualProperty.Color;
set set
{ {
SetMaterialColor = false; SetMaterialColor = false;

View File

@@ -30,9 +30,9 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
var rect = primitive as IRectanglePrimitive; var rect = primitive as IRectanglePrimitive;
viewItem = new RectangleViewPrimitive(rect); viewItem = new RectangleViewPrimitive(rect);
} }
else if (primitive is ICirclePrimitive) else if (primitive is IEllipsePrimitive)
{ {
var circle = primitive as ICirclePrimitive; var circle = primitive as IEllipsePrimitive;
viewItem = new CircleViewPrimitive(circle); viewItem = new CircleViewPrimitive(circle);
} }
else if (primitive is IPointPrimitive & primitive is not RebarPrimitive) else if (primitive is IPointPrimitive & primitive is not RebarPrimitive)

View File

@@ -40,7 +40,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
public RectangleViewPrimitive(IRectanglePrimitive _primitive) : base(_primitive) public RectangleViewPrimitive(IRectanglePrimitive _primitive) : base(_primitive)
{ {
primitive = _primitive; primitive = _primitive;
DivisionViewModel = new HasDivisionViewModel(primitive); DivisionViewModel = new HasDivisionViewModel(primitive.DivisionSize);
} }
public override void Refresh() public override void Refresh()
{ {

View File

@@ -139,9 +139,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{ {
var limitState = tuple.DesignForceTuple.LimitState; var limitState = tuple.DesignForceTuple.LimitState;
var calcTerm = tuple.DesignForceTuple.CalcTerm; var calcTerm = tuple.DesignForceTuple.CalcTerm;
var material = valuePoint.ndmPrimitive.HeadMaterial.GetLoaderMaterial(limitState, calcTerm); var material = valuePoint.ndmPrimitive.NdmElement.HeadMaterial.GetLoaderMaterial(limitState, calcTerm);
var userPrestrain = valuePoint.ndmPrimitive.UsersPrestrain; var userPrestrain = valuePoint.ndmPrimitive.NdmElement.UsersPrestrain;
var autoPrestrain = valuePoint.ndmPrimitive.AutoPrestrain; var autoPrestrain = valuePoint.ndmPrimitive.NdmElement.AutoPrestrain;
var ndm = new Ndm() var ndm = new Ndm()
{ {
Area = valuePoint.areaPoint.Area, Area = valuePoint.areaPoint.Area,

View File

@@ -338,7 +338,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{ {
foreach (var item in ndmPrimitives) foreach (var item in ndmPrimitives)
{ {
ForceTupleService.CopyProperties(wnd.StrainTuple, item.AutoPrestrain); ForceTupleService.CopyProperties(wnd.StrainTuple, item.NdmElement.AutoPrestrain);
} }
} }
} }
@@ -439,15 +439,21 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
var ndmRange = new List<INdm>(); var ndmRange = new List<INdm>();
foreach (var item in orderedNdmPrimitives) foreach (var item in orderedNdmPrimitives)
{ {
if (item is IHasDivisionSize) if (item is IHasDivisionSize hasDivision)
{ {
var hasDivision = item as IHasDivisionSize;
if (hasDivision.ClearUnderlying == true) if (hasDivision.DivisionSize.ClearUnderlying == true)
{ {
ndmRange.RemoveAll(x => hasDivision.IsPointInside(new Point2D() { X = x.CenterX, Y = x.CenterY }) == true); ndmRange.RemoveAll(x =>
hasDivision
.IsPointInside(new Point2D()
{
X = x.CenterX, Y = x.CenterY
}
) == true);
} }
} }
if (selectedNdmPrimitives.Contains(item) & item.Triangulate == true) if (selectedNdmPrimitives.Contains(item) & item.NdmElement.Triangulate == true)
{ {
ndmRange.AddRange(item.GetNdms(triangulationOptions)); ndmRange.AddRange(item.GetNdms(triangulationOptions));

View File

@@ -1,4 +1,5 @@
using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Analyses; using StructureHelperCommon.Models.Analyses;
using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.CrossSections;
using System; using System;
@@ -7,6 +8,7 @@ namespace StructureHelper.Windows.MainWindow.Analyses
{ {
public class VisualAnalysis : IVisualAnalysis public class VisualAnalysis : IVisualAnalysis
{ {
private IUpdateStrategy<IVisualAnalysis> updateStrategy = new VisualAnalysisUpdateStrategy();
public Guid Id { get; } public Guid Id { get; }
public IAnalysis Analysis { get; set; } public IAnalysis Analysis { get; set; }
@@ -44,5 +46,12 @@ namespace StructureHelper.Windows.MainWindow.Analyses
var window = new CrossSectionView(crossSection); var window = new CrossSectionView(crossSection);
window.ShowDialog(); window.ShowDialog();
} }
public object Clone()
{
var newAnalysis = Analysis.Clone() as IAnalysis;
VisualAnalysis newItem = new(newAnalysis);
return newItem;
}
} }
} }

View File

@@ -208,7 +208,7 @@ namespace StructureHelper.Windows.ViewModels.Materials
if (parent is IHasPrimitives) if (parent is IHasPrimitives)
{ {
var primitives = (parent as IHasPrimitives).Primitives; var primitives = (parent as IHasPrimitives).Primitives;
var primitivesWithMaterial = primitives.Where(x => x.HeadMaterial == SelectedMaterial); var primitivesWithMaterial = primitives.Where(x => x.NdmElement.HeadMaterial == SelectedMaterial);
int primitivesCount = primitivesWithMaterial.Count(); int primitivesCount = primitivesWithMaterial.Count();
if (primitivesCount > 0) if (primitivesCount > 0)
{ {

View File

@@ -48,7 +48,7 @@ namespace StructureHelper.Windows.ViewModels.Materials
public override void DeleteMethod(object parameter) public override void DeleteMethod(object parameter)
{ {
var primitives = repository.Primitives; var primitives = repository.Primitives;
var primitivesWithMaterial = primitives.Where(x => x.HeadMaterial == SelectedItem); var primitivesWithMaterial = primitives.Where(x => x.NdmElement.HeadMaterial == SelectedItem);
int primitivesCount = primitivesWithMaterial.Count(); int primitivesCount = primitivesWithMaterial.Count();
if (primitivesCount > 0) if (primitivesCount > 0)
{ {

View File

@@ -10,9 +10,9 @@ using System.Windows.Controls;
namespace StructureHelper.Windows.ViewModels.NdmCrossSections namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{ {
public class HasDivisionViewModel : ViewModelBase, IHasDivisionSize public class HasDivisionViewModel : ViewModelBase, IDivisionSize
{ {
private IHasDivisionSize primitive; private IDivisionSize primitive;
public double NdmMaxSize public double NdmMaxSize
{ {
@@ -42,7 +42,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
} }
} }
public HasDivisionViewModel(IHasDivisionSize primitive) public HasDivisionViewModel(IDivisionSize primitive)
{ {
this.primitive = primitive; this.primitive = primitive;
} }

View File

@@ -98,9 +98,9 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
} }
else if (primitiveType == PrimitiveType.Circle) else if (primitiveType == PrimitiveType.Circle)
{ {
var primitive = new CirclePrimitive var primitive = new EllipsePrimitive
{ {
Diameter = 0.5d DiameterByX = 0.5d
}; };
ndmPrimitive = primitive; ndmPrimitive = primitive;
viewPrimitive = new CircleViewPrimitive(primitive); viewPrimitive = new CircleViewPrimitive(primitive);
@@ -251,9 +251,9 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{ {
primitiveBase = new RectangleViewPrimitive(newPrimitive as IRectanglePrimitive); primitiveBase = new RectangleViewPrimitive(newPrimitive as IRectanglePrimitive);
} }
else if (newPrimitive is ICirclePrimitive) else if (newPrimitive is IEllipsePrimitive)
{ {
primitiveBase = new CircleViewPrimitive(newPrimitive as ICirclePrimitive); primitiveBase = new CircleViewPrimitive(newPrimitive as IEllipsePrimitive);
} }
else if (newPrimitive is IPointPrimitive) else if (newPrimitive is IPointPrimitive)
{ {

View File

@@ -305,7 +305,7 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
HostPrimitives = new ObservableCollection<PrimitiveBase>(); HostPrimitives = new ObservableCollection<PrimitiveBase>();
foreach (var item in sectionRepository.Primitives) foreach (var item in sectionRepository.Primitives)
{ {
if (item is RectanglePrimitive || item is CirclePrimitive) if (item is RectanglePrimitive || item is EllipsePrimitive)
{ {
CheckHost(primitive, item); CheckHost(primitive, item);
HostPrimitives.Add(PrimitiveOperations.ConvertNdmPrimitiveToPrimitiveBase(item)); HostPrimitives.Add(PrimitiveOperations.ConvertNdmPrimitiveToPrimitiveBase(item));
@@ -320,7 +320,8 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
{ {
var host = item as IHasDivisionSize; var host = item as IHasDivisionSize;
var reinforcement = ndm as RebarPrimitive; var reinforcement = ndm as RebarPrimitive;
if (host.IsPointInside(new Point2D() { X = reinforcement.Center.X, Y = reinforcement.Center.Y }) bool checkWhenPointLocatedInsideOfItsHost = host.IsPointInside(reinforcement.Center.Clone() as IPoint2D);
if (checkWhenPointLocatedInsideOfItsHost
&& reinforcement.HostPrimitive is null) && reinforcement.HostPrimitive is null)
{ {
var dialogResult = MessageBox.Show($"Primitive {reinforcement.Name} is inside primitive {item.Name}", var dialogResult = MessageBox.Show($"Primitive {reinforcement.Name} is inside primitive {item.Name}",

View File

@@ -27,5 +27,7 @@
public static string ObjectNotFound => "#0018: Object not found"; public static string ObjectNotFound => "#0018: Object not found";
public static string ErrorDuring(string operation) => string.Format("Errors appeared during {0}, see detailed information", operation); public static string ErrorDuring(string operation) => string.Format("Errors appeared during {0}, see detailed information", operation);
public static string CalculationError => "#0019: Error of calculation"; public static string CalculationError => "#0019: Error of calculation";
public static string SourceObject => "#0020: Source object";
public static string TargetObject => "#0021: Target object";
} }
} }

View File

@@ -0,0 +1,19 @@
using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public abstract class BaseUpdateStrategy<T> : IUpdateStrategy<T>
{
public abstract void Update(T targetObject, T sourceObject);
public void Check(T targetObject, T sourceObject)
{
CheckObject.IsNull(targetObject, sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; };
}
}
}

View File

@@ -17,7 +17,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
public IShiftTraceLogger? TraceLogger { get; set; } public IShiftTraceLogger? TraceLogger { get; set; }
public IConvertStrategy<T,V> ConvertStrategy { get; set; } public IConvertStrategy<T,V> ConvertStrategy { get; set; }
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public T ConvertFrom(V source) public T Convert(V source)
{ {
ICheckInputData(); ICheckInputData();
T val; T val;
@@ -31,32 +31,12 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
} }
else else
{ {
val = ConvertStrategy.ConvertFrom(source); val = ConvertStrategy.Convert(source);
ReferenceDictionary.Add(key, val); ReferenceDictionary.Add(key, val);
TraceLogger?.AddMessage($"New value of {typeof(T)} (Id = {val.Id}) was added to dictionary", TraceLogStatuses.Debug); TraceLogger?.AddMessage($"New value of {typeof(T)} (Id = {val.Id}) was added to dictionary", TraceLogStatuses.Debug);
} }
return val; return val;
} }
public V ConvertTo(T source)
{
ICheckInputData();
V val;
var key = (source.Id, typeof(V));
if (ReferenceDictionary.ContainsKey(key))
{
ISaveable existValue;
ReferenceDictionary.TryGetValue(key, out existValue);
val = (V)existValue;
TraceLogger?.AddMessage($"Value of {typeof(V)} (Id = {existValue.Id}) exists already", TraceLogStatuses.Debug);
}
else
{
val = ConvertStrategy.ConvertTo(source);
ReferenceDictionary.Add(key, val);
TraceLogger?.AddMessage($"New value of {typeof(V)} (Id = {val.Id}) was added to dictionary", TraceLogStatuses.Debug);
}
return val;
}
private void ICheckInputData() private void ICheckInputData()
{ {
if(ReferenceDictionary is null) if(ReferenceDictionary is null)

View File

@@ -11,8 +11,8 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
where T :ISaveable where T :ISaveable
where V :ISaveable where V :ISaveable
{ {
Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
IShiftTraceLogger TraceLogger { get; set; } IShiftTraceLogger TraceLogger { get; set; }
V ConvertTo(T source); T Convert(V source);
T ConvertFrom(V source);
} }
} }

View File

@@ -0,0 +1,20 @@
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
/// <summary>
/// Implement center of geometry shape on 2D plane
/// </summary>
public interface IHasCenter2D
{
/// <summary>
/// 2D point of center
/// </summary>
IPoint2D Center {get;set;}
}
}

View File

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Analyses namespace StructureHelperCommon.Models.Analyses
{ {
public class Version : IVersion public class DateVersion : IDateVersion
{ {
public DateTime DateTime { get; set; } public DateTime DateTime { get; set; }

View File

@@ -0,0 +1,22 @@
using StructureHelperCommon.Infrastructures.Exceptions;
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.Analyses
{
public class DateVersionUpdateStrategy : IUpdateStrategy<IDateVersion>
{
public void Update(IDateVersion targetObject, IDateVersion sourceObject)
{
CheckObject.IsNull(sourceObject, ErrorStrings.SourceObject);
CheckObject.IsNull(targetObject, ErrorStrings.TargetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; };
targetObject.DateTime = sourceObject.DateTime;
}
}
}

View File

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Analyses namespace StructureHelperCommon.Models.Analyses
{ {
public interface IAnalysis : ISaveable public interface IAnalysis : ISaveable, ICloneable
{ {
string Name { get; set; } string Name { get; set; }
string Tags { get; set; } string Tags { get; set; }

View File

@@ -7,9 +7,9 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Analyses namespace StructureHelperCommon.Models.Analyses
{ {
public interface IVersion public interface IDateVersion
{ {
DateTime DateTime { get; } DateTime DateTime { get; set; }
ISaveable Item { get; set; } ISaveable Item { get; set; }
} }
} }

View File

@@ -10,7 +10,7 @@ namespace StructureHelperCommon.Models.Analyses
public interface IVersionProcessor : ISaveable public interface IVersionProcessor : ISaveable
{ {
void AddVersion(ISaveable newItem); void AddVersion(ISaveable newItem);
List<IVersion> Versions { get; } List<IDateVersion> Versions { get; }
IVersion GetCurrentVersion(); IDateVersion GetCurrentVersion();
} }
} }

View File

@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Analyses namespace StructureHelperCommon.Models.Analyses
{ {
public interface IVisualAnalysis : ISaveable public interface IVisualAnalysis : ISaveable, ICloneable
{ {
IAnalysis Analysis {get;set;} IAnalysis Analysis {get;set;}
void Run(); void Run();

View File

@@ -9,7 +9,7 @@ namespace StructureHelperCommon.Models.Analyses
{ {
public class VersionProcessor : IVersionProcessor public class VersionProcessor : IVersionProcessor
{ {
public List<IVersion> Versions { get; } public List<IDateVersion> Versions { get; }
public Guid Id { get; } public Guid Id { get; }
@@ -24,14 +24,14 @@ namespace StructureHelperCommon.Models.Analyses
} }
private void AddVersion(IVersion version) private void AddVersion(IDateVersion version)
{ {
Versions.Add(version); Versions.Add(version);
} }
public void AddVersion(ISaveable newItem) public void AddVersion(ISaveable newItem)
{ {
var version = new Version() var version = new DateVersion()
{ {
DateTime = DateTime.Now, DateTime = DateTime.Now,
Item = newItem Item = newItem
@@ -40,7 +40,7 @@ namespace StructureHelperCommon.Models.Analyses
} }
public IVersion GetCurrentVersion() public IDateVersion GetCurrentVersion()
{ {
return Versions[^1]; return Versions[^1];
} }

View File

@@ -0,0 +1,18 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Analyses;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Analyses
{
public class VisualAnalysisUpdateStrategy : IUpdateStrategy<IVisualAnalysis>
{
public void Update(IVisualAnalysis targetObject, IVisualAnalysis sourceObject)
{
throw new NotImplementedException();
}
}
}

View File

@@ -12,7 +12,8 @@ namespace StructureHelperCommon.Models.Projects
{ {
public void Update(IFileVersion targetObject, IFileVersion sourceObject) public void Update(IFileVersion targetObject, IFileVersion sourceObject)
{ {
CheckObject.IsNull(targetObject, sourceObject); CheckObject.IsNull(targetObject);
CheckObject.IsNull(sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }; if (ReferenceEquals(targetObject, sourceObject)) { return; };
targetObject.VersionNumber = sourceObject.VersionNumber; targetObject.VersionNumber = sourceObject.VersionNumber;
targetObject.SubVersionNumber = sourceObject.SubVersionNumber; targetObject.SubVersionNumber = sourceObject.SubVersionNumber;

View File

@@ -0,0 +1,39 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Analyses;
using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Projects
{
public class ProjectUpdateStrategy : IUpdateStrategy<IProject>
{
private IUpdateStrategy<IVisualAnalysis> updateStrategy;
public ProjectUpdateStrategy(IUpdateStrategy<IVisualAnalysis> updateStrategy)
{
this.updateStrategy = updateStrategy;
}
public ProjectUpdateStrategy() : this(new VisualAnalysisUpdateStrategy())
{
}
public void Update(IProject targetObject, IProject sourceObject)
{
CheckObject.IsNull(sourceObject, ErrorStrings.SourceObject);
CheckObject.IsNull(targetObject, ErrorStrings.TargetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.VisualAnalyses.Clear();
foreach (var item in sourceObject.VisualAnalyses)
{
targetObject.VisualAnalyses.Add(item.Clone() as IVisualAnalysis);
}
}
}
}

View File

@@ -1,4 +1,6 @@
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -17,6 +19,8 @@ namespace StructureHelperCommon.Models.Shapes
/// <inheritdoc /> /// <inheritdoc />
public void Update(IPoint2D targetObject, IPoint2D sourceObject) public void Update(IPoint2D targetObject, IPoint2D sourceObject)
{ {
CheckObject.IsNull(sourceObject, ErrorStrings.SourceObject);
CheckObject.IsNull(targetObject, ErrorStrings.TargetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.X = sourceObject.X; targetObject.X = sourceObject.X;
targetObject.Y = sourceObject.Y; targetObject.Y = sourceObject.Y;

View File

@@ -1,4 +1,5 @@
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -11,6 +12,8 @@ namespace StructureHelperCommon.Models.Shapes
{ {
public void Update(IRectangleShape targetObject, IRectangleShape sourceObject) public void Update(IRectangleShape targetObject, IRectangleShape sourceObject)
{ {
CheckObject.IsNull(sourceObject);
CheckObject.IsNull(targetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.Width = sourceObject.Width; targetObject.Width = sourceObject.Width;
targetObject.Height = sourceObject.Height; targetObject.Height = sourceObject.Height;

View File

@@ -0,0 +1,59 @@
using StructureHelperCommon.Infrastructures.Exceptions;
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.Logics
{
public class ShapeUpdateStrategy : IUpdateStrategy<IShape>
{
public void Update(IShape targetObject, IShape sourceObject)
{
CheckObject.IsNull(targetObject);
CheckObject.IsNull(sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
if (sourceObject is IRectangleShape sourceRectangle)
{
ProcessRectangles(targetObject, sourceRectangle);
}
else if (sourceObject is ICircleShape sourceCircle)
{
ProcessCircles(targetObject, sourceCircle);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown);
}
}
private static void ProcessCircles(IShape targetObject, ICircleShape sourceCircle)
{
if (targetObject is ICircleShape targetCircle)
{
var updateLogic = new CircleShapeUpdateStrategy();
updateLogic.Update(targetCircle, sourceCircle);
}
else
{
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": target object is not circle");
}
}
private static void ProcessRectangles(IShape targetObject, IRectangleShape sourceRectangle)
{
if (targetObject is IRectangleShape targetRectangle)
{
var updateLogic = new RectangleShapeUpdateStrategy();
updateLogic.Update(targetRectangle, sourceRectangle);
}
else
{
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": target object is not rectangle");
}
}
}
}

View File

@@ -1,15 +1,12 @@
using StructureHelperCommon.Models.Analyses; using StructureHelperCommon.Models.Analyses;
using StructureHelperLogics.Models.Analyses;
using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.CrossSections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogic.Models.Analyses namespace StructureHelperLogic.Models.Analyses
{ {
public class CrossSectionNdmAnalysis : IAnalysis public class CrossSectionNdmAnalysis : IAnalysis
{ {
private CrossSectionNdmAnalysisUpdateStrategy updateStrategy = new();
public Guid Id { get; private set; } public Guid Id { get; private set; }
public string Name { get; set; } public string Name { get; set; }
public string Tags { get; set; } public string Tags { get; set; }
@@ -21,7 +18,7 @@ namespace StructureHelperLogic.Models.Analyses
VersionProcessor = versionProcessor; VersionProcessor = versionProcessor;
} }
public CrossSectionNdmAnalysis() : this(new Guid(), new VersionProcessor()) public CrossSectionNdmAnalysis() : this(Guid.NewGuid(), new VersionProcessor())
{ {
CrossSection crossSection = new CrossSection(); CrossSection crossSection = new CrossSection();
VersionProcessor.AddVersion(crossSection); VersionProcessor.AddVersion(crossSection);
@@ -29,7 +26,9 @@ namespace StructureHelperLogic.Models.Analyses
public object Clone() public object Clone()
{ {
throw new NotImplementedException(); CrossSectionNdmAnalysis newAnalysis = new();
updateStrategy.Update(newAnalysis, this);
return newAnalysis;
} }
} }
} }

View File

@@ -0,0 +1,68 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Analyses;
using StructureHelperCommon.Services;
using StructureHelperLogic.Models.Analyses;
using StructureHelperLogics.Models.CrossSections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.Analyses
{
public class CrossSectionNdmAnalysisUpdateStrategy : IUpdateStrategy<CrossSectionNdmAnalysis>
{
private IUpdateStrategy<IAnalysis> analysisUpdateStrategy;
private IUpdateStrategy<ICrossSection> crossSectionUpdateStrategy;
private IUpdateStrategy<IDateVersion> dateUpdateStrategy;
public CrossSectionNdmAnalysisUpdateStrategy(IUpdateStrategy<IAnalysis> analysisUpdateStrategy,
IUpdateStrategy<ICrossSection> crossSectionUpdateStrategy,
IUpdateStrategy<IDateVersion> dateUpdateStrategy)
{
this.analysisUpdateStrategy = analysisUpdateStrategy;
this.crossSectionUpdateStrategy = crossSectionUpdateStrategy;
this.dateUpdateStrategy = dateUpdateStrategy;
}
public CrossSectionNdmAnalysisUpdateStrategy() : this(
new AnalysisUpdateStrategy(),
new CrossSectionUpdateStrategy(),
new DateVersionUpdateStrategy())
{
}
public void Update(CrossSectionNdmAnalysis targetObject, CrossSectionNdmAnalysis sourceObject)
{
CheckObject.IsNull(sourceObject, ErrorStrings.SourceObject);
CheckObject.IsNull(targetObject, ErrorStrings.TargetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; };
analysisUpdateStrategy.Update(targetObject, sourceObject);
targetObject.VersionProcessor.Versions.Clear();
foreach (var version in sourceObject.VersionProcessor.Versions)
{
if (version.Item is ICrossSection crossSection)
{
updateVersion(targetObject, version, crossSection);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(version.Item));
}
}
}
private void updateVersion(CrossSectionNdmAnalysis targetObject, IDateVersion version, ICrossSection crossSection)
{
DateVersion newVersion = new();
dateUpdateStrategy.Update(newVersion, version);
CrossSection newCrossection = new();
crossSectionUpdateStrategy.Update(newCrossection, crossSection);
newVersion.Item = newCrossection;
targetObject.VersionProcessor.Versions.Add(newVersion);
}
}
}

View File

@@ -13,7 +13,7 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
public class CircleGeometryLogic : IRCGeometryLogic public class CircleGeometryLogic : IRCGeometryLogic
{ {
ICircleTemplate template; ICircleTemplate template;
CirclePrimitive concreteBlock; EllipsePrimitive concreteBlock;
public IEnumerable<IHeadMaterial> HeadMaterials { get; set; } public IEnumerable<IHeadMaterial> HeadMaterials { get; set; }
@@ -35,7 +35,8 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
var diameter = template.Shape.Diameter; var diameter = template.Shape.Diameter;
var concreteMaterial = HeadMaterials.ToList()[0]; var concreteMaterial = HeadMaterials.ToList()[0];
var primitives = new List<INdmPrimitive>(); var primitives = new List<INdmPrimitive>();
concreteBlock = new CirclePrimitive() { Diameter = diameter, Name = "Concrete block", HeadMaterial = concreteMaterial }; concreteBlock = new EllipsePrimitive() { DiameterByX = diameter, Name = "Concrete block"};
concreteBlock.NdmElement.HeadMaterial = concreteMaterial;
primitives.Add(concreteBlock); primitives.Add(concreteBlock);
return primitives; return primitives;
} }
@@ -56,11 +57,11 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{ {
Area = barArea, Area = barArea,
Name = "Left bottom point", Name = "Left bottom point",
HeadMaterial = reinforcementMaterial,
HostPrimitive=concreteBlock }; HostPrimitive=concreteBlock };
point.Center.X = x; point.Center.X = x;
point.Center.Y = y; point.Center.Y = y;
primitives.Add(point); primitives.Add(point);
point.NdmElement.HeadMaterial = reinforcementMaterial;
} }
return primitives; return primitives;
} }

View File

@@ -48,7 +48,8 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
private IEnumerable<INdmPrimitive> GetConcretePrimitives() private IEnumerable<INdmPrimitive> GetConcretePrimitives()
{ {
var primitives = new List<INdmPrimitive>(); var primitives = new List<INdmPrimitive>();
concreteBlock = new RectanglePrimitive(concrete) { Width = width, Height = height, Name = "Concrete block" }; concreteBlock = new RectanglePrimitive() { Width = width, Height = height, Name = "Concrete block" };
concreteBlock.NdmElement.HeadMaterial = concrete;
primitives.Add(concreteBlock); primitives.Add(concreteBlock);
return primitives; return primitives;
} }
@@ -63,9 +64,10 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{ {
Area = area1, Area = area1,
Name = "Left bottom rebar", Name = "Left bottom rebar",
HeadMaterial = reinforcement,
HostPrimitive=concreteBlock HostPrimitive=concreteBlock
}; };
point.NdmElement.HeadMaterial = reinforcement;
point.Center.X = xs[0]; point.Center.X = xs[0];
point.Center.Y = ys[0]; point.Center.Y = ys[0];
primitives.Add(point); primitives.Add(point);
@@ -73,9 +75,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{ {
Area = area1, Area = area1,
Name = "Right bottom rebar", Name = "Right bottom rebar",
HeadMaterial = reinforcement,
HostPrimitive = concreteBlock HostPrimitive = concreteBlock
}; };
point.NdmElement.HeadMaterial = reinforcement;
point.Center.X = xs[1]; point.Center.X = xs[1];
point.Center.Y = ys[0]; point.Center.Y = ys[0];
primitives.Add(point); primitives.Add(point);
@@ -83,9 +85,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{ {
Area = area2, Area = area2,
Name = "Left top rebar", Name = "Left top rebar",
HeadMaterial = reinforcement,
HostPrimitive = concreteBlock HostPrimitive = concreteBlock
}; };
point.NdmElement.HeadMaterial = reinforcement;
point.Center.X = xs[0]; point.Center.X = xs[0];
point.Center.Y = ys[1]; point.Center.Y = ys[1];
primitives.Add(point); primitives.Add(point);
@@ -93,9 +95,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{ {
Area = area2, Area = area2,
Name = "Right top rebar", Name = "Right top rebar",
HeadMaterial = reinforcement,
HostPrimitive = concreteBlock HostPrimitive = concreteBlock
}; };
point.NdmElement.HeadMaterial = reinforcement;
point.Center.X = xs[1]; point.Center.X = xs[1];
point.Center.Y = ys[1]; point.Center.Y = ys[1];
primitives.Add(point); primitives.Add(point);
@@ -115,11 +117,23 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
double dist = (xs[1] - xs[0]) / count; double dist = (xs[1] - xs[0]) / count;
for (int i = 1; i < count; i++) for (int i = 1; i < count; i++)
{ {
point = new RebarPrimitive() { Area = area1, Name = $"Bottom rebar {i}", HeadMaterial = reinforcement, HostPrimitive = concreteBlock }; point = new RebarPrimitive()
{
Area = area1,
Name = $"Bottom rebar {i}",
HostPrimitive = concreteBlock
};
point.NdmElement.HeadMaterial = reinforcement;
point.Center.X = xs[0] + dist * i; point.Center.X = xs[0] + dist * i;
point.Center.Y = ys[0]; point.Center.Y = ys[0];
primitives.Add(point); primitives.Add(point);
point = new RebarPrimitive() {Area = area2, Name = $"Top rebar {i}", HeadMaterial = reinforcement, HostPrimitive = concreteBlock }; point = new RebarPrimitive()
{
Area = area2,
Name = $"Top rebar {i}",
HostPrimitive = concreteBlock
};
point.NdmElement.HeadMaterial = reinforcement;
point.Center.X = xs[0] + dist * i; point.Center.X = xs[0] + dist * i;
point.Center.Y = ys[1]; point.Center.Y = ys[1];
primitives.Add(point); primitives.Add(point);
@@ -135,9 +149,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{ {
Area = area1, Area = area1,
Name = $"Left point {i}", Name = $"Left point {i}",
HeadMaterial = reinforcement,
HostPrimitive = concreteBlock HostPrimitive = concreteBlock
}; };
point.NdmElement.HeadMaterial = reinforcement;
point.Center.X = xs[0]; point.Center.X = xs[0];
point.Center.Y = ys[0] + dist * i; point.Center.Y = ys[0] + dist * i;
primitives.Add(point); primitives.Add(point);
@@ -145,9 +159,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{ {
Area = area1, Area = area1,
Name = $"Right point {i}", Name = $"Right point {i}",
HeadMaterial = reinforcement,
HostPrimitive = concreteBlock HostPrimitive = concreteBlock
}; };
point.NdmElement.HeadMaterial = reinforcement;
point.Center.X = xs[1]; point.Center.X = xs[1];
point.Center.Y = ys[0] + dist * i; point.Center.Y = ys[0] + dist * i;
primitives.Add(point); primitives.Add(point);

View File

@@ -26,7 +26,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.RC
inputData.CrossSectionArea = ndmPrimitive.Area; inputData.CrossSectionArea = ndmPrimitive.Area;
var diameter = Math.Sqrt(ndmPrimitive.Area / Math.PI) * 2d; var diameter = Math.Sqrt(ndmPrimitive.Area / Math.PI) * 2d;
inputData.CrossSectionPerimeter = Math.PI * diameter; inputData.CrossSectionPerimeter = Math.PI * diameter;
if (ndmPrimitive.HeadMaterial is null) if (ndmPrimitive.NdmElement.HeadMaterial is null)
{ {
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": main material is incorrect or null"); throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": main material is incorrect or null");
} }
@@ -52,7 +52,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.RC
if (primitive.HostPrimitive is not null) if (primitive.HostPrimitive is not null)
{ {
var host = primitive.HostPrimitive; var host = primitive.HostPrimitive;
var hostMaterial = host.HeadMaterial.HelperMaterial; var hostMaterial = host
.NdmElement
.HeadMaterial
.HelperMaterial;
if (hostMaterial is IConcreteLibMaterial) if (hostMaterial is IConcreteLibMaterial)
{ {
var concreteMaterial = hostMaterial as IConcreteLibMaterial; var concreteMaterial = hostMaterial as IConcreteLibMaterial;
@@ -65,9 +68,9 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.RC
private static double GetReinforcementStrength(LimitStates limitState, CalcTerms calcTerm, RebarPrimitive primitive) private static double GetReinforcementStrength(LimitStates limitState, CalcTerms calcTerm, RebarPrimitive primitive)
{ {
if (primitive.HeadMaterial.HelperMaterial is IReinforcementLibMaterial) if (primitive.NdmElement.HeadMaterial.HelperMaterial is IReinforcementLibMaterial)
{ {
var material = primitive.HeadMaterial.HelperMaterial as IReinforcementLibMaterial; var material = primitive.NdmElement.HeadMaterial.HelperMaterial as IReinforcementLibMaterial;
var strength = material.GetStrength(limitState, calcTerm).Tensile; var strength = material.GetStrength(limitState, calcTerm).Tensile;
return strength; return strength;
} }

View File

@@ -44,7 +44,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
RebarPrimitive rebarCopy = null; RebarPrimitive rebarCopy = null;
rebarCopy = Rebar.Clone() as RebarPrimitive; rebarCopy = Rebar.Clone() as RebarPrimitive;
rebarCopy.HeadMaterial = rebarCopy.HeadMaterial.Clone() as IHeadMaterial; rebarCopy.NdmElement.HeadMaterial = rebarCopy.NdmElement.HeadMaterial.Clone() as IHeadMaterial;
triangulationLogicLoc = new CrackedSectionTriangulationLogic(InputData.Primitives); triangulationLogicLoc = new CrackedSectionTriangulationLogic(InputData.Primitives);
crackableNdmsLoc = triangulationLogicLoc.GetNdmCollection(); crackableNdmsLoc = triangulationLogicLoc.GetNdmCollection();
crackedNdmsLoc = triangulationLogicLoc.GetCrackedNdmCollection(); crackedNdmsLoc = triangulationLogicLoc.GetCrackedNdmCollection();

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
/// <inheritdoc/>
public class DivisionSize : IDivisionSize
{
/// <inheritdoc/>
public double NdmMaxSize { get; set; } = 0.01d;
/// <inheritdoc/>
public int NdmMinDivision { get; set; } = 10;
/// <inheritdoc/>
public bool ClearUnderlying { get; set; } = false;
}
}

View File

@@ -9,46 +9,54 @@ using StructureHelperLogics.NdmCalculations.Triangulations;
namespace StructureHelperLogics.NdmCalculations.Primitives namespace StructureHelperLogics.NdmCalculations.Primitives
{ {
public class CirclePrimitive : ICirclePrimitive public class EllipsePrimitive : IEllipsePrimitive
{ {
static readonly CircleUpdateStrategy updateStrategy = new(); private static readonly EllipsePrimitiveUpdateStrategy updateStrategy = new();
private readonly RectangleShape rectangleShape = new();
/// <inheritdoc/> /// <inheritdoc/>
public Guid Id { get; set; } public Guid Id { get; set; }
/// <inheritdoc/> /// <inheritdoc/>
public string Name { get; set; } public string Name { get; set; }
/// <inheritdoc/> /// <inheritdoc/>
public IPoint2D Center { get; private set; } public IPoint2D Center { get; set; } = new Point2D();
public IHeadMaterial? HeadMaterial { get; set; } /// <inheritdoc/>
public StrainTuple UsersPrestrain { get; } public IVisualProperty VisualProperty { get; } = new VisualProperty { Opacity = 0.8d };
public StrainTuple AutoPrestrain { get; } /// <inheritdoc/>
public IVisualProperty VisualProperty { get; } public double DiameterByX
public double Diameter { get; set; } {
public double NdmMaxSize { get; set; } get
public int NdmMinDivision { get; set; } {
public bool ClearUnderlying { get; set; } return rectangleShape.Width;
public bool Triangulate { get; set; } }
set
{
rectangleShape.Width = value;
rectangleShape.Height = value;
}
}
/// <inheritdoc/>
public double DiameterByY { get => rectangleShape.Height; set => rectangleShape.Height = value; }
/// <inheritdoc/>
public ICrossSection? CrossSection { get; set; } public ICrossSection? CrossSection { get; set; }
/// <inheritdoc/>
public INdmElement NdmElement { get; } = new NdmElement(); public INdmElement NdmElement { get; } = new NdmElement();
/// <inheritdoc/>
public IDivisionSize DivisionSize { get; } = new DivisionSize();
/// <inheritdoc/>
public IShape Shape => rectangleShape;
public CirclePrimitive(Guid id)
public EllipsePrimitive(Guid id)
{ {
Id = id; Id = id;
Name = "New Circle"; Name = "New Circle";
NdmMaxSize = 0.01d;
NdmMinDivision = 10;
Center = new Point2D();
VisualProperty = new VisualProperty { Opacity = 0.8d };
UsersPrestrain = new StrainTuple();
AutoPrestrain = new StrainTuple();
ClearUnderlying = false;
Triangulate = true;
} }
public CirclePrimitive() : this (Guid.NewGuid()) public EllipsePrimitive() : this (Guid.NewGuid()) {}
{}
/// <inheritdoc/> /// <inheritdoc/>
public object Clone() public object Clone()
{ {
var primitive = new CirclePrimitive(); var primitive = new EllipsePrimitive();
updateStrategy.Update(primitive, this); updateStrategy.Update(primitive, this);
return primitive; return primitive;
} }
@@ -70,7 +78,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
var dX = Center.X - point.X; var dX = Center.X - point.X;
var dY = Center.Y - point.Y; var dY = Center.Y - point.Y;
var distance = Math.Sqrt(dX * dX + dY * dY); var distance = Math.Sqrt(dX * dX + dY * dY);
if (distance > Diameter / 2) { return false; } if (distance > DiameterByX / 2) { return false; }
return true; return true;
} }
@@ -88,28 +96,28 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
newPoint = new NamedAreaPoint newPoint = new NamedAreaPoint
{ {
Name = "Left", Name = "Left",
Point = new Point2D() { X = Center.X - Diameter / 2d, Y = Center.Y}, Point = new Point2D() { X = Center.X - DiameterByX / 2d, Y = Center.Y},
Area = 0d Area = 0d
}; };
points.Add(newPoint); points.Add(newPoint);
newPoint = new NamedAreaPoint newPoint = new NamedAreaPoint
{ {
Name = "Top", Name = "Top",
Point = new Point2D() { X = Center.X, Y = Center.Y + Diameter / 2d }, Point = new Point2D() { X = Center.X, Y = Center.Y + DiameterByX / 2d },
Area = 0d Area = 0d
}; };
points.Add(newPoint); points.Add(newPoint);
newPoint = new NamedAreaPoint newPoint = new NamedAreaPoint
{ {
Name = "Right", Name = "Right",
Point = new Point2D() { X = Center.X + Diameter / 2d, Y = Center.Y }, Point = new Point2D() { X = Center.X + DiameterByX / 2d, Y = Center.Y },
Area = 0d Area = 0d
}; };
points.Add(newPoint); points.Add(newPoint);
newPoint = new NamedAreaPoint newPoint = new NamedAreaPoint
{ {
Name = "Bottom", Name = "Bottom",
Point = new Point2D() { X = Center.X, Y = Center.Y - Diameter / 2d }, Point = new Point2D() { X = Center.X, Y = Center.Y - DiameterByX / 2d },
Area = 0d Area = 0d
}; };
points.Add(newPoint); points.Add(newPoint);

View File

@@ -0,0 +1,29 @@
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
/// <summary>
/// Include parameters of triangulation for shapes
/// </summary>
public interface IDivisionSize
{
/// <summary>
/// Maximum size of Ndm part
/// </summary>
double NdmMaxSize { get; set; }
/// <summary>
/// Mimimum division for sides of shape
/// </summary>
int NdmMinDivision { get; set; }
/// <summary>
/// Flag of removing ndm part which located inside shape
/// </summary>
bool ClearUnderlying { get; set; }
}
}

View File

@@ -7,7 +7,10 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives namespace StructureHelperLogics.NdmCalculations.Primitives
{ {
public interface ICirclePrimitive : INdmPrimitive, IHasDivisionSize, ICircleShape public interface IEllipsePrimitive : INdmPrimitive, IHasDivisionSize
{ {
double DiameterByX { get; set; }
double DiameterByY { get; set; }
} }
} }

View File

@@ -1,5 +1,4 @@
using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.Primitives;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -8,23 +7,10 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives namespace StructureHelperLogics.NdmCalculations.Primitives
{ {
/// <summary>
/// Include parameters of triangulation for shapes
/// </summary>
public interface IHasDivisionSize public interface IHasDivisionSize
{ {
/// <summary> ///<inheritdoc/>
/// Maximum size of Ndm part IDivisionSize DivisionSize { get; }
/// </summary>
double NdmMaxSize { get; set; }
/// <summary>
/// Mimimum division for sides of shape
/// </summary>
int NdmMinDivision { get; set; }
/// <summary>
/// Flag of removing ndm part which located inside shape
/// </summary>
bool ClearUnderlying { get; set; }
/// <summary> /// <summary>
/// Shows if point is located inside shape /// Shows if point is located inside shape
/// </summary> /// </summary>

View File

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives namespace StructureHelperLogics.NdmCalculations.Primitives
{ {
public interface ILinePrimitive : IHasDivisionSize, ILineShape public interface ILinePrimitive : IDivisionSize, ILineShape
{ {
} }
} }

View File

@@ -13,10 +13,6 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
{ {
public interface INdmElement : ISaveable, ICloneable public interface INdmElement : ISaveable, ICloneable
{ {
/// <summary>
/// Base point of primitive
/// </summary>
IPoint2D Center { get; }
/// <summary> /// <summary>
/// Material of primitive /// Material of primitive
/// </summary> /// </summary>

View File

@@ -17,38 +17,22 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
/// <summary> /// <summary>
/// Geometrical primitive which generates ndm elemtntary part /// Geometrical primitive which generates ndm elemtntary part
/// </summary> /// </summary>
public interface INdmPrimitive : ISaveable, ICloneable public interface INdmPrimitive : ISaveable, IHasCenter2D, ICloneable
{ {
/// <summary> /// <summary>
/// Name of primitive /// Name of primitive
/// </summary> /// </summary>
string? Name { get; set; } string? Name { get; set; }
INdmElement NdmElement { get;} IShape Shape { get; }
/// <summary> /// <summary>
/// Base point of primitive /// Base properties of primitive
/// </summary> /// </summary>
IPoint2D Center { get; } INdmElement NdmElement { get;}
/// <summary> /// <summary>
/// Host cross-section for primitive /// Host cross-section for primitive
/// </summary> /// </summary>
ICrossSection? CrossSection { get; set; } ICrossSection? CrossSection { get; set; }
/// <summary> /// <summary>
/// Material of primitive
/// </summary>
IHeadMaterial? HeadMaterial { get; set; }
/// <summary>
/// Flag of triangulation
/// </summary>
bool Triangulate { get; set; }
/// <summary>
/// Prestrain assigned from user
/// </summary>
StrainTuple UsersPrestrain { get; }
/// <summary>
/// Prestrain assigned from calculations
/// </summary>
StrainTuple AutoPrestrain { get; }
/// <summary>
/// Visual settings /// Visual settings
/// </summary> /// </summary>
IVisualProperty VisualProperty {get; } IVisualProperty VisualProperty {get; }

View File

@@ -23,11 +23,14 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
CheckObject.IsNull(targetObject, sourceObject); CheckObject.IsNull(targetObject, sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.Name = sourceObject.Name; targetObject.Name = sourceObject.Name;
if (sourceObject.HeadMaterial != null) targetObject.HeadMaterial = sourceObject.HeadMaterial; if (sourceObject.NdmElement.HeadMaterial != null)
targetObject.Triangulate = sourceObject.Triangulate; {
targetObject.NdmElement.HeadMaterial = sourceObject.NdmElement.HeadMaterial;
}
targetObject.NdmElement.Triangulate = sourceObject.NdmElement.Triangulate;
point2DUpdateStrategy.Update(targetObject.Center, sourceObject.Center); point2DUpdateStrategy.Update(targetObject.Center, sourceObject.Center);
visualPropsUpdateStrategy.Update(targetObject.VisualProperty, sourceObject.VisualProperty); visualPropsUpdateStrategy.Update(targetObject.VisualProperty, sourceObject.VisualProperty);
tupleUpdateStrategy.Update(targetObject.UsersPrestrain, sourceObject.UsersPrestrain); tupleUpdateStrategy.Update(targetObject.NdmElement.UsersPrestrain, sourceObject.NdmElement.UsersPrestrain);
} }
} }

View File

@@ -60,10 +60,10 @@ namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
} }
} }
if (RebarPrimitive.HostPrimitive.HeadMaterial.HelperMaterial is not ICrackedMaterial) if (RebarPrimitive.HostPrimitive.NdmElement.HeadMaterial.HelperMaterial is not ICrackedMaterial)
{ {
result = false; result = false;
string message = $"Material of host of {RebarPrimitive.Name} ({RebarPrimitive.HostPrimitive.HeadMaterial.Name}) does not support cracking\n"; string message = $"Material of host of {RebarPrimitive.Name} ({RebarPrimitive.HostPrimitive.NdmElement.HeadMaterial.Name}) does not support cracking\n";
checkResult += message; checkResult += message;
TraceLogger?.AddMessage(message, TraceLogStatuses.Error); TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
} }

View File

@@ -1,25 +0,0 @@
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.Primitives
{
internal class CircleUpdateStrategy : IUpdateStrategy<CirclePrimitive>
{
static readonly BaseUpdateStrategy basePrimitiveUpdateStrategy = new();
static readonly DivisionPropsUpdateStrategy divisionPropsUpdateStrategy = new();
static readonly CircleShapeUpdateStrategy shapeUpdateStrategy = new();
public void Update(CirclePrimitive targetObject, CirclePrimitive sourceObject)
{
if (ReferenceEquals(targetObject, sourceObject)) { return; }
basePrimitiveUpdateStrategy.Update(targetObject, sourceObject);
divisionPropsUpdateStrategy.Update(targetObject, sourceObject);
shapeUpdateStrategy.Update(targetObject, sourceObject);
}
}
}

View File

@@ -7,9 +7,9 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives namespace StructureHelperLogics.NdmCalculations.Primitives
{ {
internal class DivisionPropsUpdateStrategy : IUpdateStrategy<IHasDivisionSize> internal class DivisionPropsUpdateStrategy : IUpdateStrategy<IDivisionSize>
{ {
public void Update(IHasDivisionSize targetObject, IHasDivisionSize sourceObject) public void Update(IDivisionSize targetObject, IDivisionSize sourceObject)
{ {
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.NdmMaxSize = sourceObject.NdmMaxSize; targetObject.NdmMaxSize = sourceObject.NdmMaxSize;

View File

@@ -0,0 +1,39 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Models.Shapes.Logics;
using StructureHelperCommon.Services;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
internal class EllipsePrimitiveUpdateStrategy : IUpdateStrategy<IEllipsePrimitive>
{
private IUpdateStrategy<INdmPrimitive> basePrimitiveUpdateStrategy;
private IUpdateStrategy<IDivisionSize> divisionPropsUpdateStrategy;
private IUpdateStrategy<IShape> shapeUpdateStrategy;
public EllipsePrimitiveUpdateStrategy(IUpdateStrategy<INdmPrimitive> basePrimitiveUpdateStrategy,
IUpdateStrategy<IShape> shapeUpdateStrategy,
IUpdateStrategy<IDivisionSize> divisionPropsUpdateStrategy)
{
this.basePrimitiveUpdateStrategy = basePrimitiveUpdateStrategy;
this.shapeUpdateStrategy = shapeUpdateStrategy;
this.divisionPropsUpdateStrategy = divisionPropsUpdateStrategy;
}
public EllipsePrimitiveUpdateStrategy() : this(
new BaseUpdateStrategy(),
new ShapeUpdateStrategy(),
new DivisionPropsUpdateStrategy())
{
}
public void Update(IEllipsePrimitive targetObject, IEllipsePrimitive sourceObject)
{
CheckObject.IsNull(sourceObject, "source object");
CheckObject.IsNull(targetObject, "target object");
if (ReferenceEquals(targetObject, sourceObject)) { return; }
basePrimitiveUpdateStrategy.Update(targetObject, sourceObject);
divisionPropsUpdateStrategy.Update(targetObject.DivisionSize, sourceObject.DivisionSize);
shapeUpdateStrategy.Update(targetObject.Shape, sourceObject.Shape);
}
}
}

View File

@@ -5,21 +5,16 @@ using StructureHelperCommon.Services;
namespace StructureHelperLogics.NdmCalculations.Primitives.Logics namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
{ {
public class INdmElementUpdateStrategy : IUpdateStrategy<INdmElement> public class NdmElementUpdateStrategy : IUpdateStrategy<INdmElement>
{ {
private readonly IUpdateStrategy<IPoint2D> point2DUpdateStrategy;
private readonly IUpdateStrategy<IForceTuple> tupleUpdateStrategy; private readonly IUpdateStrategy<IForceTuple> tupleUpdateStrategy;
public INdmElementUpdateStrategy(IUpdateStrategy<IPoint2D> point2DUpdateStrategy, public NdmElementUpdateStrategy(IUpdateStrategy<IForceTuple> tupleUpdateStrategy)
IUpdateStrategy<IForceTuple> tupleUpdateStrategy)
{ {
this.point2DUpdateStrategy = point2DUpdateStrategy;
this.tupleUpdateStrategy = tupleUpdateStrategy; this.tupleUpdateStrategy = tupleUpdateStrategy;
} }
public INdmElementUpdateStrategy() : this ( public NdmElementUpdateStrategy() : this (new ForceTupleUpdateStrategy())
new Point2DUpdateStrategy(),
new ForceTupleUpdateStrategy())
{ {
} }
@@ -29,8 +24,6 @@ namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
{ {
CheckObject.IsNull(targetObject, sourceObject); CheckObject.IsNull(targetObject, sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
point2DUpdateStrategy.Update(targetObject.Center, sourceObject.Center);
if (sourceObject.HeadMaterial != null) if (sourceObject.HeadMaterial != null)
{ {
targetObject.HeadMaterial = sourceObject.HeadMaterial; targetObject.HeadMaterial = sourceObject.HeadMaterial;

View File

@@ -21,11 +21,11 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
} }
else if (targetObject is RectanglePrimitive rectangle) else if (targetObject is RectanglePrimitive rectangle)
{ {
new RectangleUpdateStrategy().Update(rectangle, (RectanglePrimitive)sourceObject); new RectanglePrimitiveUpdateStrategy().Update(rectangle, (RectanglePrimitive)sourceObject);
} }
else if (targetObject is CirclePrimitive circle) else if (targetObject is EllipsePrimitive circle)
{ {
new CircleUpdateStrategy().Update(circle, (CirclePrimitive)sourceObject); new EllipsePrimitiveUpdateStrategy().Update(circle, (EllipsePrimitive)sourceObject);
} }
else else
{ {

View File

@@ -0,0 +1,45 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Models.Shapes.Logics;
using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
internal class RectanglePrimitiveUpdateStrategy : IUpdateStrategy<IRectanglePrimitive>
{
private IUpdateStrategy<INdmPrimitive> basePrimitiveUpdateStrategy;
private IUpdateStrategy<IDivisionSize> divisionPropsUpdateStrategy;
private IUpdateStrategy<IShape> shapeUpdateStrategy;
public RectanglePrimitiveUpdateStrategy(IUpdateStrategy<INdmPrimitive> basePrimitiveUpdateStrategy,
IUpdateStrategy<IShape> shapeUpdateStrategy,
IUpdateStrategy<IDivisionSize> divisionPropsUpdateStrategy)
{
this.basePrimitiveUpdateStrategy = basePrimitiveUpdateStrategy;
this.shapeUpdateStrategy = shapeUpdateStrategy;
this.divisionPropsUpdateStrategy = divisionPropsUpdateStrategy;
}
public RectanglePrimitiveUpdateStrategy() : this(
new BaseUpdateStrategy(),
new ShapeUpdateStrategy(),
new DivisionPropsUpdateStrategy())
{
}
public void Update(IRectanglePrimitive targetObject, IRectanglePrimitive sourceObject)
{
CheckObject.IsNull(sourceObject, "source object");
CheckObject.IsNull(targetObject, "target object");
if (ReferenceEquals(targetObject, sourceObject)) { return; }
basePrimitiveUpdateStrategy.Update(targetObject, sourceObject);
divisionPropsUpdateStrategy.Update(targetObject.DivisionSize, sourceObject.DivisionSize);
shapeUpdateStrategy.Update(targetObject.Shape, sourceObject.Shape);
}
}
}

View File

@@ -1,24 +0,0 @@
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.Primitives
{
internal class RectangleUpdateStrategy : IUpdateStrategy<RectanglePrimitive>
{
static readonly BaseUpdateStrategy basePrimitiveUpdateStrategy = new();
static readonly DivisionPropsUpdateStrategy divisionPropsUpdateStrategy = new();
static readonly RectangleShapeUpdateStrategy shapeUpdateStrategy = new();
public void Update(RectanglePrimitive targetObject, RectanglePrimitive sourceObject)
{
if (ReferenceEquals(targetObject, sourceObject)) { return; }
basePrimitiveUpdateStrategy.Update(targetObject, sourceObject);
divisionPropsUpdateStrategy.Update(targetObject, sourceObject);
shapeUpdateStrategy.Update(targetObject, sourceObject);
}
}
}

View File

@@ -18,11 +18,9 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
/// <inheritdoc/> /// <inheritdoc/>
public Guid Id { get; } public Guid Id { get; }
/// <inheritdoc/> /// <inheritdoc/>
public IPoint2D Center { get; } = new Point2D();
/// <inheritdoc/>
public IHeadMaterial? HeadMaterial { get; set; } public IHeadMaterial? HeadMaterial { get; set; }
/// <inheritdoc/> /// <inheritdoc/>
public bool Triangulate { get; set; } public bool Triangulate { get; set; } = true;
/// <inheritdoc/> /// <inheritdoc/>
public StrainTuple UsersPrestrain { get; } = new(); public StrainTuple UsersPrestrain { get; } = new();
/// <inheritdoc/> /// <inheritdoc/>

View File

@@ -14,34 +14,26 @@ namespace StructureHelperLogics.Models.Primitives
static readonly PointUpdateStrategy updateStrategy = new(); static readonly PointUpdateStrategy updateStrategy = new();
public Guid Id { get; } public Guid Id { get; }
public string? Name { get; set; } public string? Name { get; set; }
public IPoint2D Center { get; private set; } public IPoint2D Center { get; set; }
public IHeadMaterial HeadMaterial { get; set; }
//public double NdmMaxSize { get; set; }
//public int NdmMinDivision { get; set; }
public StrainTuple UsersPrestrain { get; private set; }
public StrainTuple AutoPrestrain { get; private set; }
public double Area { get; set; } public double Area { get; set; }
public IVisualProperty VisualProperty { get; } public IVisualProperty VisualProperty { get; } = new VisualProperty();
public bool Triangulate { get; set; }
public ICrossSection? CrossSection { get; set; } public ICrossSection? CrossSection { get; set; }
public INdmElement NdmElement { get; } = new NdmElement(); public INdmElement NdmElement { get; } = new NdmElement();
public IShape Shape => throw new NotImplementedException();
public PointPrimitive(Guid id) public PointPrimitive(Guid id)
{ {
Id = id; Id = id;
Name = "New Point"; Name = "New Point";
Area = 0.0005d; Area = 0.0005d;
Center = new Point2D(); Center = new Point2D();
VisualProperty = new VisualProperty();
UsersPrestrain = new StrainTuple();
AutoPrestrain = new StrainTuple();
Triangulate = true;
} }
public PointPrimitive() : this (Guid.NewGuid()) public PointPrimitive() : this (Guid.NewGuid())
{} {}
public PointPrimitive(IHeadMaterial material) : this() { HeadMaterial = material; }
public object Clone() public object Clone()
{ {

View File

@@ -27,17 +27,9 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
/// <inheritdoc/> /// <inheritdoc/>
public string Name { get; set; } public string Name { get; set; }
/// <inheritdoc/> /// <inheritdoc/>
public IPoint2D Center { get; private set; } public IPoint2D Center { get; set; }
/// <inheritdoc/> /// <inheritdoc/>
public IHeadMaterial? HeadMaterial { get; set; } public IVisualProperty VisualProperty { get; private set; } = new VisualProperty();
/// <inheritdoc/>
public bool Triangulate { get; set; }
/// <inheritdoc/>
public StrainTuple UsersPrestrain { get; private set; }
/// <inheritdoc/>
public StrainTuple AutoPrestrain { get; private set; }
/// <inheritdoc/>
public IVisualProperty VisualProperty { get; private set; }
/// <inheritdoc/> /// <inheritdoc/>
public Guid Id { get; set; } public Guid Id { get; set; }
/// <inheritdoc/> /// <inheritdoc/>
@@ -49,16 +41,14 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
public INdmElement NdmElement { get; } = new NdmElement(); public INdmElement NdmElement { get; } = new NdmElement();
public IShape Shape => throw new NotImplementedException();
public RebarPrimitive(Guid id) public RebarPrimitive(Guid id)
{ {
Id = id; Id = id;
Name = "New Reinforcement"; Name = "New Reinforcement";
Area = 0.0005d; Area = 0.0005d;
Center = new Point2D(); Center = new Point2D();
VisualProperty = new VisualProperty();
UsersPrestrain = new StrainTuple();
AutoPrestrain = new StrainTuple();
Triangulate = true;
} }
public RebarPrimitive() : this(Guid.NewGuid()) public RebarPrimitive() : this(Guid.NewGuid())
{ {

View File

@@ -11,46 +11,34 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
{ {
public class RectanglePrimitive : IRectanglePrimitive public class RectanglePrimitive : IRectanglePrimitive
{ {
readonly RectangleUpdateStrategy updateStrategy = new(); private readonly RectanglePrimitiveUpdateStrategy updateStrategy = new();
private readonly RectangleShape rectangleShape = new();
public Guid Id { get;} public Guid Id { get;}
public string Name { get; set; } public string Name { get; set; }
public IHeadMaterial? HeadMaterial { get; set; } public double Width { get => rectangleShape.Width; set => rectangleShape.Width = value; }
public StrainTuple UsersPrestrain { get; private set; } public double Height { get => rectangleShape.Height; set => rectangleShape.Height = value; }
public StrainTuple AutoPrestrain { get; private set; } public double Angle { get => rectangleShape.Angle; set => rectangleShape.Angle = value; }
public double NdmMaxSize { get; set; } public IVisualProperty VisualProperty { get; } = new VisualProperty() { Opacity = 0.8d };
public int NdmMinDivision { get; set; }
public double Width { get; set; }
public double Height { get; set; }
public double Angle { get; set; }
public bool ClearUnderlying { get; set; }
public bool Triangulate { get; set; }
public IVisualProperty VisualProperty { get; }
public ICrossSection? CrossSection { get; set; } public ICrossSection? CrossSection { get; set; }
public IPoint2D Center { get; private set; } public IPoint2D Center { get; set; } = new Point2D();
public INdmElement NdmElement { get; } = new NdmElement(); public INdmElement NdmElement { get; } = new NdmElement();
public IDivisionSize DivisionSize { get; } = new DivisionSize();
public IShape Shape => rectangleShape;
public RectanglePrimitive(Guid id) public RectanglePrimitive(Guid id)
{ {
Id = id; Id = id;
Name = "New Rectangle"; Name = "New Rectangle";
NdmMaxSize = 0.01d;
NdmMinDivision = 10;
Center = new Point2D();
VisualProperty = new VisualProperty { Opacity = 0.8d};
UsersPrestrain = new StrainTuple();
AutoPrestrain = new StrainTuple();
ClearUnderlying = false;
Triangulate = true;
} }
public RectanglePrimitive() : this(Guid.NewGuid()) public RectanglePrimitive() : this(Guid.NewGuid())
{ {
} }
public RectanglePrimitive(IHeadMaterial material) : this() { HeadMaterial = material; }
public object Clone() public object Clone()
{ {
var primitive = new RectanglePrimitive(); var primitive = new RectanglePrimitive();

View File

@@ -25,14 +25,15 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
public ITriangulationOptions triangulationOptions { get; set; } public ITriangulationOptions triangulationOptions { get; set; }
public IHeadMaterial HeadMaterial { get; set; } public IHeadMaterial HeadMaterial { get; set; }
public CircleTriangulationLogicOptions(ICirclePrimitive primitive) public CircleTriangulationLogicOptions(IEllipsePrimitive primitive)
{ {
Center = primitive.Center.Clone() as Point2D; Center = primitive.Center.Clone() as Point2D;
Circle = primitive; //to do change to ellipse
NdmMaxSize = primitive.NdmMaxSize; Circle = new CircleShape() { Diameter = primitive.DiameterByX };
NdmMinDivision = primitive.NdmMinDivision; NdmMaxSize = primitive.DivisionSize.NdmMaxSize;
HeadMaterial = primitive.HeadMaterial; NdmMinDivision = primitive.DivisionSize.NdmMinDivision;
Prestrain = ForceTupleService.SumTuples(primitive.UsersPrestrain, primitive.AutoPrestrain) as StrainTuple; HeadMaterial = primitive.NdmElement.HeadMaterial;
Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
} }
} }
} }

View File

@@ -28,8 +28,8 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
{ {
Center = primitive.Center.Clone() as Point2D; Center = primitive.Center.Clone() as Point2D;
Area = primitive.Area; Area = primitive.Area;
HeadMaterial = primitive.HeadMaterial; HeadMaterial = primitive.NdmElement.HeadMaterial;
Prestrain = ForceTupleService.SumTuples(primitive.UsersPrestrain, primitive.AutoPrestrain) as StrainTuple; Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
} }
} }
} }

View File

@@ -55,11 +55,12 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
{ {
var hostPrimitive = options.HostPrimitive; var hostPrimitive = options.HostPrimitive;
var material = hostPrimitive var material = hostPrimitive
.NdmElement
.HeadMaterial .HeadMaterial
.GetLoaderMaterial(options.triangulationOptions.LimiteState, options.triangulationOptions.CalcTerm); .GetLoaderMaterial(options.triangulationOptions.LimiteState, options.triangulationOptions.CalcTerm);
var prestrain = ForceTupleService.SumTuples(hostPrimitive.UsersPrestrain, var prestrain = ForceTupleService.SumTuples(hostPrimitive.NdmElement.UsersPrestrain,
hostPrimitive.AutoPrestrain) hostPrimitive.NdmElement.AutoPrestrain)
as StrainTuple; as StrainTuple;
var concreteNdm = new Ndm var concreteNdm = new Ndm

View File

@@ -30,9 +30,9 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
{ {
Center = primitive.Center.Clone() as Point2D; Center = primitive.Center.Clone() as Point2D;
Area = primitive.Area; Area = primitive.Area;
HeadMaterial = primitive.HeadMaterial; HeadMaterial = primitive.NdmElement.HeadMaterial;
HostPrimitive = primitive.HostPrimitive; HostPrimitive = primitive.HostPrimitive;
Prestrain = ForceTupleService.SumTuples(primitive.UsersPrestrain, primitive.AutoPrestrain) as StrainTuple; Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
} }
} }
} }

View File

@@ -35,10 +35,10 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
{ {
Center = new Point2D() {X = primitive.Center.X, Y = primitive.Center.Y }; Center = new Point2D() {X = primitive.Center.X, Y = primitive.Center.Y };
Rectangle = primitive; Rectangle = primitive;
NdmMaxSize = primitive.NdmMaxSize; NdmMaxSize = primitive.DivisionSize.NdmMaxSize;
NdmMinDivision = primitive.NdmMinDivision; NdmMinDivision = primitive.DivisionSize.NdmMinDivision;
HeadMaterial = primitive.HeadMaterial; HeadMaterial = primitive.NdmElement.HeadMaterial;
Prestrain = ForceTupleService.SumTuples(primitive.UsersPrestrain, primitive.AutoPrestrain) as StrainTuple; Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
} }
} }
} }

View File

@@ -32,7 +32,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
Dictionary<Guid, IHeadMaterial> headMaterials = new Dictionary<Guid, IHeadMaterial>(); Dictionary<Guid, IHeadMaterial> headMaterials = new Dictionary<Guid, IHeadMaterial>();
foreach (var ndmPrimitive in ndmPrimitives) foreach (var ndmPrimitive in ndmPrimitives)
{ {
IHeadMaterial material = ndmPrimitive.HeadMaterial; IHeadMaterial material = ndmPrimitive.NdmElement.HeadMaterial;
if (!headMaterials.ContainsKey(material.Id)) { headMaterials.Add(material.Id, material); } if (!headMaterials.ContainsKey(material.Id)) { headMaterials.Add(material.Id, material); }
} }
return headMaterials; return headMaterials;

View File

@@ -25,7 +25,9 @@ namespace StructureHelperLogics.Services.NdmPrimitives
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error); TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage); throw new StructureHelperException(errorMessage);
} }
if (!Primitives.Any(x => x.Triangulate == true)) if (!Primitives.Any(x => x
.NdmElement
.Triangulate == true))
{ {
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": There are not primitives to triangulate"); string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": There are not primitives to triangulate");
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error); TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
@@ -33,8 +35,8 @@ namespace StructureHelperLogics.Services.NdmPrimitives
} }
foreach (var item in Primitives) foreach (var item in Primitives)
{ {
if (item.Triangulate == true & if (item.NdmElement.Triangulate == true &
item.HeadMaterial is null) item.NdmElement.HeadMaterial is null)
{ {
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Primitive: {item.Name} can't be triangulated since material is null"); string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Primitive: {item.Name} can't be triangulated since material is null");
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error); TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);

View File

@@ -9,10 +9,22 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.Services.NdmPrimitives namespace StructureHelperLogics.Services.NdmPrimitives
{ {
/// <summary>
/// Implement logic of triangulation of primitives which have parameters of division
/// </summary>
public interface IMeshHasDivisionLogic : ILogic public interface IMeshHasDivisionLogic : ILogic
{ {
List<INdm> NdmCollection { get; set; } /// <summary>
IHasDivisionSize Primitive { get; set; } /// Input collection of existing ndm parts
/// </summary>
List<INdm>? NdmCollection { get; set; }
/// <summary>
/// Input triangulated primitive
/// </summary>
IHasDivisionSize? Primitive { get; set; }
/// <summary>
/// Run process of triangulation
/// </summary>
void MeshHasDivision(); void MeshHasDivision();
} }
} }

View File

@@ -30,7 +30,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
CheckPrimitive(); CheckPrimitive();
List<INdm> ndmCollection = new(); List<INdm> ndmCollection = new();
if (Primitive.HeadMaterial.HelperMaterial is ICrackedMaterial) if (Primitive.NdmElement.HeadMaterial.HelperMaterial is ICrackedMaterial)
{ {
ProcessICracked(ndmCollection); ProcessICracked(ndmCollection);
} }
@@ -74,13 +74,13 @@ namespace StructureHelperLogics.Services.NdmPrimitives
private void SetNewMaterial(INdmPrimitive? newPrimititve) private void SetNewMaterial(INdmPrimitive? newPrimititve)
{ {
TraceLogger?.AddMessage($"Process material {newPrimititve.HeadMaterial.Name} has started"); TraceLogger?.AddMessage($"Process material {newPrimititve.NdmElement.HeadMaterial.Name} has started");
var newHeadMaterial = newPrimititve.HeadMaterial.Clone() as IHeadMaterial; var newHeadMaterial = newPrimititve.NdmElement.HeadMaterial.Clone() as IHeadMaterial;
var newMaterial = newHeadMaterial.HelperMaterial.Clone() as ICrackedMaterial; var newMaterial = newHeadMaterial.HelperMaterial.Clone() as ICrackedMaterial;
TraceLogger?.AddMessage($"Set work in tension zone for material {newPrimititve.HeadMaterial.Name}"); TraceLogger?.AddMessage($"Set work in tension zone for material {newPrimititve.NdmElement.HeadMaterial.Name}");
newMaterial.TensionForSLS = false; newMaterial.TensionForSLS = false;
newHeadMaterial.HelperMaterial = newMaterial as IHelperMaterial; newHeadMaterial.HelperMaterial = newMaterial as IHelperMaterial;
newPrimititve.HeadMaterial = newHeadMaterial; newPrimititve.NdmElement.HeadMaterial = newHeadMaterial;
} }
private List<INdm> GetNdms(INdmPrimitive primitive) private List<INdm> GetNdms(INdmPrimitive primitive)

View File

@@ -1,4 +1,6 @@
using LoaderCalculator.Data.Ndms; using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models; using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers; using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Models.Shapes;
@@ -12,30 +14,55 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.Services.NdmPrimitives namespace StructureHelperLogics.Services.NdmPrimitives
{ {
/// <inheritdoc/>
public class MeshHasDivisionLogic : IMeshHasDivisionLogic public class MeshHasDivisionLogic : IMeshHasDivisionLogic
{ {
public List<INdm> NdmCollection { get; set; } /// <inheritdoc/>
public IHasDivisionSize Primitive { get; set; } public List<INdm>? NdmCollection { get; set; }
/// <inheritdoc/>
public IHasDivisionSize? Primitive { get; set; }
/// <inheritdoc/>
public IShiftTraceLogger? TraceLogger { get; set; } public IShiftTraceLogger? TraceLogger { get; set; }
public void MeshHasDivision() public void MeshHasDivision()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
CheckInputData();
if (Primitive is IHasDivisionSize hasDivision) if (Primitive is IHasDivisionSize hasDivision)
{ {
if (hasDivision.ClearUnderlying == true) if (hasDivision.DivisionSize.ClearUnderlying == true)
{ {
TraceLogger?.AddMessage("Removing of background part has started", TraceLogStatuses.Service); TraceLogger?.AddMessage("Removing of background part has started", TraceLogStatuses.Service);
NdmCollection NdmCollection.RemoveAll(x => IsCenterInside(x, hasDivision) == true);
.RemoveAll(x => }
hasDivision }
.IsPointInside(new Point2D() }
private static bool IsCenterInside(INdm x, IHasDivisionSize hasDivision)
{
Point2D point = new Point2D()
{ {
X = x.CenterX, X = x.CenterX,
Y = x.CenterY Y = x.CenterY
}) == true); };
} return hasDivision.IsPointInside(point);
} }
private void CheckInputData()
{
if (NdmCollection is null)
{
var message = ErrorStrings.ParameterIsNull + ": input NdmCollection";
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
throw new StructureHelperException(message);
}
if (Primitive is null)
{
var message = ErrorStrings.ParameterIsNull + ": input Primitive";
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
throw new StructureHelperException(message);
}
} }
} }
} }

View File

@@ -87,7 +87,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
divisionLogic.Primitive = hasDivision; divisionLogic.Primitive = hasDivision;
divisionLogic.MeshHasDivision(); divisionLogic.MeshHasDivision();
} }
if (primitive.Triangulate == true) if (primitive.NdmElement.Triangulate == true)
{ {
meshLogic.Primitive = primitive; meshLogic.Primitive = primitive;
var ndms = meshLogic.MeshPrimitive(); var ndms = meshLogic.MeshPrimitive();

View File

@@ -75,7 +75,7 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT
//Act //Act
foreach (var item in ndmPrimitives) foreach (var item in ndmPrimitives)
{ {
ForceTupleService.CopyProperties(source, item.AutoPrestrain); ForceTupleService.CopyProperties(source, item.NdmElement.AutoPrestrain);
} }
calculator.Run(); calculator.Run();
var result2 = calculator.Result as IForcesResults; var result2 = calculator.Result as IForcesResults;

View File

@@ -77,7 +77,7 @@ namespace StructureHelperTests.UnitTests.Ndms
_mockRebarPrimitive.Setup(x => x.HostPrimitive).Returns(mockHostPrimitive.Object); _mockRebarPrimitive.Setup(x => x.HostPrimitive).Returns(mockHostPrimitive.Object);
_mockRebarPrimitive.Setup(x => x.Name).Returns("RebarName"); _mockRebarPrimitive.Setup(x => x.Name).Returns("RebarName");
mockHostPrimitive.Setup(x => x.HeadMaterial).Returns(mockHeadMaterial.Object); mockHostPrimitive.Setup(x => x.NdmElement.HeadMaterial).Returns(mockHeadMaterial.Object);
mockHeadMaterial.Setup(x => x.HelperMaterial).Returns(mockHelperMaterial.Object); mockHeadMaterial.Setup(x => x.HelperMaterial).Returns(mockHelperMaterial.Object);
// Act // Act

View File

@@ -56,7 +56,7 @@ public class CheckTupleCalculatorInputDataTests
// Arrange // Arrange
_checkTupleCalculatorInputData.InputData = new TupleCrackInputData _checkTupleCalculatorInputData.InputData = new TupleCrackInputData
{ {
Primitives = new List<INdmPrimitive> { new CirclePrimitive() }, // Assuming at least one valid primitive Primitives = new List<INdmPrimitive> { new EllipsePrimitive() }, // Assuming at least one valid primitive
UserCrackInputData = null UserCrackInputData = null
}; };
@@ -74,7 +74,7 @@ public class CheckTupleCalculatorInputDataTests
// Arrange // Arrange
_checkTupleCalculatorInputData.InputData = new TupleCrackInputData _checkTupleCalculatorInputData.InputData = new TupleCrackInputData
{ {
Primitives = new List<INdmPrimitive> { new CirclePrimitive() }, // Assuming at least one valid primitive Primitives = new List<INdmPrimitive> { new EllipsePrimitive() }, // Assuming at least one valid primitive
UserCrackInputData = new UserCrackInputData() // Assuming this is valid UserCrackInputData = new UserCrackInputData() // Assuming this is valid
}; };

View File

@@ -66,14 +66,23 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
//Arrange //Arrange
ProgramSetting.NatSystem = NatSystems.RU; ProgramSetting.NatSystem = NatSystems.RU;
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40); var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40);
var mainBlock = new RectanglePrimitive() { Width = width, Height = height, HeadMaterial = material }; var mainBlock = new RectanglePrimitive()
{
Width = width,
Height = height,
};
mainBlock.NdmElement.HeadMaterial = material;
mainBlock.Center.X = centerX; mainBlock.Center.X = centerX;
mainBlock.Center.Y = centerY; mainBlock.Center.Y = centerY;
mainBlock.VisualProperty.ZIndex = 0; mainBlock.VisualProperty.ZIndex = 0;
var opening = new RectanglePrimitive() var opening = new RectanglePrimitive()
{ Width = 0.3d, Height = 0.2d, {
HeadMaterial = material, Triangulate = triangOpening, Width = 0.3d,
ClearUnderlying = true}; Height = 0.2d
};
opening.DivisionSize.ClearUnderlying = true;
opening.NdmElement.HeadMaterial = material;
opening.NdmElement.Triangulate = triangOpening;
opening.VisualProperty.ZIndex = 1; opening.VisualProperty.ZIndex = 1;
var primitives = new List<INdmPrimitive>() { mainBlock, opening }; var primitives = new List<INdmPrimitive>() { mainBlock, opening };
//Act //Act
@@ -100,19 +109,28 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
//Arrange //Arrange
ProgramSetting.NatSystem = NatSystems.RU; ProgramSetting.NatSystem = NatSystems.RU;
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40); var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40);
var mainBlock = new RectanglePrimitive() {Width = width, Height = height, HeadMaterial = material }; var mainBlock = new RectanglePrimitive()
{
Width = width,
Height = height
};
mainBlock.NdmElement.HeadMaterial = material;
mainBlock.Center.X = centerX; mainBlock.Center.X = centerX;
mainBlock.Center.Y = centerY; mainBlock.Center.Y = centerY;
mainBlock.VisualProperty.ZIndex = 0; mainBlock.VisualProperty.ZIndex = 0;
var opening = new CirclePrimitive() var opening = new EllipsePrimitive()
{ {
Diameter = 0.3d, DiameterByX = 0.3d
HeadMaterial = material,
Triangulate = triangOpening,
ClearUnderlying = true
}; };
opening.DivisionSize.ClearUnderlying = true;
opening.NdmElement.HeadMaterial = material;
opening.NdmElement.Triangulate = triangOpening;
opening.VisualProperty.ZIndex = 1; opening.VisualProperty.ZIndex = 1;
var primitives = new List<INdmPrimitive>() { mainBlock, opening }; var primitives = new List<INdmPrimitive>()
{
mainBlock,
opening
};
//Act //Act
triangulateLogic = new TriangulatePrimitiveLogic() triangulateLogic = new TriangulatePrimitiveLogic()
{ {
@@ -137,18 +155,19 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
//Arrange //Arrange
ProgramSetting.NatSystem = NatSystems.RU; ProgramSetting.NatSystem = NatSystems.RU;
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40); var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40);
var mainBlock = new CirclePrimitive() { Diameter = diameter, HeadMaterial = material }; var mainBlock = new EllipsePrimitive() { DiameterByX = diameter};
mainBlock.NdmElement.HeadMaterial = material;
mainBlock.Center.X = centerX; mainBlock.Center.X = centerX;
mainBlock.Center.Y = centerY; mainBlock.Center.Y = centerY;
mainBlock.VisualProperty.ZIndex = 0; mainBlock.VisualProperty.ZIndex = 0;
var opening = new RectanglePrimitive() var opening = new RectanglePrimitive()
{ {
Width = 0.3d, Width = 0.3d,
Height = 0.2d, Height = 0.2d
HeadMaterial = material,
Triangulate = triangOpening,
ClearUnderlying = true
}; };
opening.DivisionSize.ClearUnderlying = true;
opening.NdmElement.HeadMaterial = material;
opening.NdmElement.Triangulate = triangOpening;
opening.VisualProperty.ZIndex = 1; opening.VisualProperty.ZIndex = 1;
var primitives = new List<INdmPrimitive>() { mainBlock, opening }; var primitives = new List<INdmPrimitive>() { mainBlock, opening };
//Act //Act

View File

@@ -26,7 +26,8 @@ namespace StructureHelperTests.ViewModelTests
{ {
//Arrange //Arrange
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40); var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40);
var primitive = new RectanglePrimitive(material); var primitive = new RectanglePrimitive();
primitive.NdmElement.HeadMaterial = material;
var primitiveBase = new RectangleViewPrimitive(primitive); var primitiveBase = new RectangleViewPrimitive(primitive);
//Act //Act
var vm = new PrimitivePropertiesViewModel(primitiveBase, new CrossSectionRepository()); var vm = new PrimitivePropertiesViewModel(primitiveBase, new CrossSectionRepository());
@@ -39,7 +40,8 @@ namespace StructureHelperTests.ViewModelTests
//Arrange //Arrange
ProgramSetting.NatSystem = NatSystems.RU; ProgramSetting.NatSystem = NatSystems.RU;
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40); var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40);
var primitive = new CirclePrimitive() { HeadMaterial = material}; var primitive = new EllipsePrimitive();
primitive.NdmElement.HeadMaterial = material;
var primitiveBase = new CircleViewPrimitive(primitive); var primitiveBase = new CircleViewPrimitive(primitive);
//Act //Act
var vm = new PrimitivePropertiesViewModel(primitiveBase, new CrossSectionRepository()); var vm = new PrimitivePropertiesViewModel(primitiveBase, new CrossSectionRepository());
@@ -53,7 +55,8 @@ namespace StructureHelperTests.ViewModelTests
//Arrange //Arrange
ProgramSetting.NatSystem = NatSystems.RU; ProgramSetting.NatSystem = NatSystems.RU;
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40); var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40);
var primitive = new PointPrimitive(material); var primitive = new PointPrimitive();
primitive.NdmElement.HeadMaterial = material;
var primitiveBase = new PointViewPrimitive(primitive); var primitiveBase = new PointViewPrimitive(primitive);
//Act //Act
var vm = new PrimitivePropertiesViewModel(primitiveBase, new CrossSectionRepository()); var vm = new PrimitivePropertiesViewModel(primitiveBase, new CrossSectionRepository());
@@ -66,7 +69,8 @@ namespace StructureHelperTests.ViewModelTests
//Arrange //Arrange
ProgramSetting.NatSystem = NatSystems.RU; ProgramSetting.NatSystem = NatSystems.RU;
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40); var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40);
var primitive = new RebarPrimitive() { HeadMaterial = material }; var primitive = new RebarPrimitive();
primitive.NdmElement.HeadMaterial = material;
var primitiveBase = new ReinforcementViewPrimitive(primitive); var primitiveBase = new ReinforcementViewPrimitive(primitive);
//Act //Act
var vm = new PrimitivePropertiesViewModel(primitiveBase, new CrossSectionRepository()); var vm = new PrimitivePropertiesViewModel(primitiveBase, new CrossSectionRepository());