Add VisualAnalysisDTO
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
51
DataAccess/DTOs/Converters/ProjectToDTOConvertStrategy.cs
Normal file
51
DataAccess/DTOs/Converters/ProjectToDTOConvertStrategy.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,6 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; set; }
|
||||
[JsonProperty("Center")]
|
||||
public IPoint2D Center { get; set; }
|
||||
[JsonProperty("HeadMaterial")]
|
||||
public IHeadMaterial? HeadMaterial { get; set; }
|
||||
[JsonProperty("Triangulate")]
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace DataAccess.DTOs
|
||||
public bool IsActual { get; set; }
|
||||
|
||||
[JsonProperty("VisualAnalyses")]
|
||||
public List<IVisualAnalysis> VisualAnalyses { get; private set; }
|
||||
public List<IVisualAnalysis> VisualAnalyses { get; private set; } = new();
|
||||
|
||||
[JsonIgnore]
|
||||
public string FileName { get; set; }
|
||||
@@ -31,5 +31,10 @@ namespace DataAccess.DTOs
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public ProjectDTO() : this (Guid.NewGuid())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
29
DataAccess/DTOs/VisualAnalysisDTO.cs
Normal file
29
DataAccess/DTOs/VisualAnalysisDTO.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,15 @@ namespace DataAccess.Infrastructures
|
||||
refDictinary = new Dictionary<(Guid id, Type type), ISaveable>();
|
||||
FileVersionDTO versionDTO = GetVersionDTO();
|
||||
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
|
||||
{
|
||||
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
|
||||
};
|
||||
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,
|
||||
ReferenceDictionary = refDictinary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
var versionDTO = dictionaryConvertStrategy.ConvertTo(version as FileVersion);
|
||||
var versionDTO = dictionaryConvertStrategy.Convert(version);
|
||||
return versionDTO;
|
||||
}
|
||||
|
||||
@@ -85,8 +111,9 @@ namespace DataAccess.Infrastructures
|
||||
{
|
||||
Converters = new List<JsonConverter>
|
||||
{
|
||||
new FileVersionDTOJsonConverter(logger), // Add the specific converter
|
||||
// Add other converters if needed
|
||||
new FileVersionDTOJsonConverter(logger), // Add the specific converter
|
||||
new ProjectDTOJsonConverter(logger)
|
||||
},
|
||||
Formatting = Formatting.Indented,
|
||||
PreserveReferencesHandling = PreserveReferencesHandling.All,
|
||||
|
||||
18
DataAccess/JsonConverters/ProjectDTOJsonConverter.cs
Normal file
18
DataAccess/JsonConverters/ProjectDTOJsonConverter.cs
Normal 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
17
DataAccess/JsonConverters/VisualAnalysisDTOJsonConverter.cs
Normal file
17
DataAccess/JsonConverters/VisualAnalysisDTOJsonConverter.cs
Normal 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,16 +12,16 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
{
|
||||
public class CircleViewPrimitive : PrimitiveBase, IHasCenter
|
||||
{
|
||||
ICirclePrimitive primitive;
|
||||
IEllipsePrimitive primitive;
|
||||
public double Diameter
|
||||
{
|
||||
get
|
||||
{
|
||||
return primitive.Diameter;
|
||||
return primitive.DiameterByX;
|
||||
}
|
||||
set
|
||||
{
|
||||
primitive.Diameter = value;
|
||||
primitive.DiameterByX = value;
|
||||
RefreshPlacement();
|
||||
}
|
||||
}
|
||||
@@ -31,13 +31,13 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
|
||||
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;
|
||||
DivisionViewModel = new HasDivisionViewModel(circle);
|
||||
DivisionViewModel = new HasDivisionViewModel(circle.DivisionSize);
|
||||
}
|
||||
|
||||
public override INdmPrimitive GetNdmPrimitive()
|
||||
|
||||
@@ -60,49 +60,49 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
}
|
||||
public bool Triangulate
|
||||
{
|
||||
get => primitive.Triangulate;
|
||||
get => primitive.NdmElement.Triangulate;
|
||||
set
|
||||
{
|
||||
primitive.Triangulate = value;
|
||||
primitive.NdmElement.Triangulate = value;
|
||||
OnPropertyChanged(nameof(Triangulate));
|
||||
}
|
||||
}
|
||||
public double InvertedCenterY => - CenterY;
|
||||
public double PrestrainKx
|
||||
{ get => primitive.UsersPrestrain.Mx;
|
||||
{ get => primitive.NdmElement.UsersPrestrain.Mx;
|
||||
set
|
||||
{
|
||||
primitive.UsersPrestrain.Mx = value;
|
||||
primitive.NdmElement.UsersPrestrain.Mx = value;
|
||||
OnPropertyChanged(nameof(PrestrainKx));
|
||||
}
|
||||
}
|
||||
public double PrestrainKy
|
||||
{ get => primitive.UsersPrestrain.My;
|
||||
{ get => primitive.NdmElement.UsersPrestrain.My;
|
||||
set
|
||||
{
|
||||
primitive.UsersPrestrain.My = value;
|
||||
primitive.NdmElement.UsersPrestrain.My = value;
|
||||
OnPropertyChanged(nameof(PrestrainKy));
|
||||
}
|
||||
}
|
||||
public double PrestrainEpsZ
|
||||
{ get => primitive.UsersPrestrain.Nz;
|
||||
{ get => primitive.NdmElement.UsersPrestrain.Nz;
|
||||
set
|
||||
{
|
||||
primitive.UsersPrestrain.Nz = value;
|
||||
primitive.NdmElement.UsersPrestrain.Nz = value;
|
||||
OnPropertyChanged(nameof(PrestrainEpsZ));
|
||||
}
|
||||
}
|
||||
|
||||
public double AutoPrestrainKx => primitive.AutoPrestrain.Mx;
|
||||
public double AutoPrestrainKy => primitive.AutoPrestrain.My;
|
||||
public double AutoPrestrainEpsZ => primitive.AutoPrestrain.Nz;
|
||||
public double AutoPrestrainKx => primitive.NdmElement.AutoPrestrain.Mx;
|
||||
public double AutoPrestrainKy => primitive.NdmElement.AutoPrestrain.My;
|
||||
public double AutoPrestrainEpsZ => primitive.NdmElement.AutoPrestrain.Nz;
|
||||
|
||||
public IHeadMaterial HeadMaterial
|
||||
{
|
||||
get => primitive.HeadMaterial;
|
||||
get => primitive.NdmElement.HeadMaterial;
|
||||
set
|
||||
{
|
||||
primitive.HeadMaterial = value;
|
||||
primitive.NdmElement.HeadMaterial = value;
|
||||
OnPropertyChanged(nameof(HeadMaterial));
|
||||
OnPropertyChanged(nameof(Color));
|
||||
}
|
||||
@@ -121,7 +121,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
public Color Color
|
||||
{
|
||||
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
|
||||
{
|
||||
SetMaterialColor = false;
|
||||
|
||||
@@ -30,9 +30,9 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
var rect = primitive as IRectanglePrimitive;
|
||||
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);
|
||||
}
|
||||
else if (primitive is IPointPrimitive & primitive is not RebarPrimitive)
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
public RectangleViewPrimitive(IRectanglePrimitive _primitive) : base(_primitive)
|
||||
{
|
||||
primitive = _primitive;
|
||||
DivisionViewModel = new HasDivisionViewModel(primitive);
|
||||
DivisionViewModel = new HasDivisionViewModel(primitive.DivisionSize);
|
||||
}
|
||||
public override void Refresh()
|
||||
{
|
||||
|
||||
@@ -139,9 +139,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
||||
{
|
||||
var limitState = tuple.DesignForceTuple.LimitState;
|
||||
var calcTerm = tuple.DesignForceTuple.CalcTerm;
|
||||
var material = valuePoint.ndmPrimitive.HeadMaterial.GetLoaderMaterial(limitState, calcTerm);
|
||||
var userPrestrain = valuePoint.ndmPrimitive.UsersPrestrain;
|
||||
var autoPrestrain = valuePoint.ndmPrimitive.AutoPrestrain;
|
||||
var material = valuePoint.ndmPrimitive.NdmElement.HeadMaterial.GetLoaderMaterial(limitState, calcTerm);
|
||||
var userPrestrain = valuePoint.ndmPrimitive.NdmElement.UsersPrestrain;
|
||||
var autoPrestrain = valuePoint.ndmPrimitive.NdmElement.AutoPrestrain;
|
||||
var ndm = new Ndm()
|
||||
{
|
||||
Area = valuePoint.areaPoint.Area,
|
||||
|
||||
@@ -338,7 +338,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
||||
{
|
||||
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>();
|
||||
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));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
@@ -7,6 +8,7 @@ namespace StructureHelper.Windows.MainWindow.Analyses
|
||||
{
|
||||
public class VisualAnalysis : IVisualAnalysis
|
||||
{
|
||||
private IUpdateStrategy<IVisualAnalysis> updateStrategy = new VisualAnalysisUpdateStrategy();
|
||||
public Guid Id { get; }
|
||||
public IAnalysis Analysis { get; set; }
|
||||
|
||||
@@ -44,5 +46,12 @@ namespace StructureHelper.Windows.MainWindow.Analyses
|
||||
var window = new CrossSectionView(crossSection);
|
||||
window.ShowDialog();
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var newAnalysis = Analysis.Clone() as IAnalysis;
|
||||
VisualAnalysis newItem = new(newAnalysis);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace StructureHelper.Windows.ViewModels.Materials
|
||||
if (parent is IHasPrimitives)
|
||||
{
|
||||
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();
|
||||
if (primitivesCount > 0)
|
||||
{
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace StructureHelper.Windows.ViewModels.Materials
|
||||
public override void DeleteMethod(object parameter)
|
||||
{
|
||||
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();
|
||||
if (primitivesCount > 0)
|
||||
{
|
||||
|
||||
@@ -10,9 +10,9 @@ using System.Windows.Controls;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
{
|
||||
public class HasDivisionViewModel : ViewModelBase, IHasDivisionSize
|
||||
public class HasDivisionViewModel : ViewModelBase, IDivisionSize
|
||||
{
|
||||
private IHasDivisionSize primitive;
|
||||
private IDivisionSize primitive;
|
||||
|
||||
public double NdmMaxSize
|
||||
{
|
||||
@@ -42,7 +42,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
}
|
||||
}
|
||||
|
||||
public HasDivisionViewModel(IHasDivisionSize primitive)
|
||||
public HasDivisionViewModel(IDivisionSize primitive)
|
||||
{
|
||||
this.primitive = primitive;
|
||||
}
|
||||
|
||||
@@ -98,9 +98,9 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
}
|
||||
else if (primitiveType == PrimitiveType.Circle)
|
||||
{
|
||||
var primitive = new CirclePrimitive
|
||||
var primitive = new EllipsePrimitive
|
||||
{
|
||||
Diameter = 0.5d
|
||||
DiameterByX = 0.5d
|
||||
};
|
||||
ndmPrimitive = primitive;
|
||||
viewPrimitive = new CircleViewPrimitive(primitive);
|
||||
@@ -251,9 +251,9 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -305,7 +305,7 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
|
||||
HostPrimitives = new ObservableCollection<PrimitiveBase>();
|
||||
foreach (var item in sectionRepository.Primitives)
|
||||
{
|
||||
if (item is RectanglePrimitive || item is CirclePrimitive)
|
||||
if (item is RectanglePrimitive || item is EllipsePrimitive)
|
||||
{
|
||||
CheckHost(primitive, item);
|
||||
HostPrimitives.Add(PrimitiveOperations.ConvertNdmPrimitiveToPrimitiveBase(item));
|
||||
@@ -320,7 +320,8 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
|
||||
{
|
||||
var host = item as IHasDivisionSize;
|
||||
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)
|
||||
{
|
||||
var dialogResult = MessageBox.Show($"Primitive {reinforcement.Name} is inside primitive {item.Name}",
|
||||
|
||||
@@ -27,5 +27,7 @@
|
||||
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 CalculationError => "#0019: Error of calculation";
|
||||
public static string SourceObject => "#0020: Source object";
|
||||
public static string TargetObject => "#0021: Target object";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
public IConvertStrategy<T,V> ConvertStrategy { get; set; }
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public T ConvertFrom(V source)
|
||||
public T Convert(V source)
|
||||
{
|
||||
ICheckInputData();
|
||||
T val;
|
||||
@@ -31,32 +31,12 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
}
|
||||
else
|
||||
{
|
||||
val = ConvertStrategy.ConvertFrom(source);
|
||||
val = ConvertStrategy.Convert(source);
|
||||
ReferenceDictionary.Add(key, val);
|
||||
TraceLogger?.AddMessage($"New value of {typeof(T)} (Id = {val.Id}) was added to dictionary", TraceLogStatuses.Debug);
|
||||
}
|
||||
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()
|
||||
{
|
||||
if(ReferenceDictionary is null)
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
where T :ISaveable
|
||||
where V :ISaveable
|
||||
{
|
||||
Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
IShiftTraceLogger TraceLogger { get; set; }
|
||||
V ConvertTo(T source);
|
||||
T ConvertFrom(V source);
|
||||
T Convert(V source);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Analyses
|
||||
{
|
||||
public class Version : IVersion
|
||||
public class DateVersion : IDateVersion
|
||||
{
|
||||
public DateTime DateTime { get; set; }
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Analyses
|
||||
{
|
||||
public interface IAnalysis : ISaveable
|
||||
public interface IAnalysis : ISaveable, ICloneable
|
||||
{
|
||||
string Name { get; set; }
|
||||
string Tags { get; set; }
|
||||
|
||||
@@ -7,9 +7,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Analyses
|
||||
{
|
||||
public interface IVersion
|
||||
public interface IDateVersion
|
||||
{
|
||||
DateTime DateTime { get; }
|
||||
DateTime DateTime { get; set; }
|
||||
ISaveable Item { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ namespace StructureHelperCommon.Models.Analyses
|
||||
public interface IVersionProcessor : ISaveable
|
||||
{
|
||||
void AddVersion(ISaveable newItem);
|
||||
List<IVersion> Versions { get; }
|
||||
IVersion GetCurrentVersion();
|
||||
List<IDateVersion> Versions { get; }
|
||||
IDateVersion GetCurrentVersion();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Analyses
|
||||
{
|
||||
public interface IVisualAnalysis : ISaveable
|
||||
public interface IVisualAnalysis : ISaveable, ICloneable
|
||||
{
|
||||
IAnalysis Analysis {get;set;}
|
||||
void Run();
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace StructureHelperCommon.Models.Analyses
|
||||
{
|
||||
public class VersionProcessor : IVersionProcessor
|
||||
{
|
||||
public List<IVersion> Versions { get; }
|
||||
public List<IDateVersion> Versions { 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);
|
||||
}
|
||||
|
||||
public void AddVersion(ISaveable newItem)
|
||||
{
|
||||
var version = new Version()
|
||||
var version = new DateVersion()
|
||||
{
|
||||
DateTime = DateTime.Now,
|
||||
Item = newItem
|
||||
@@ -40,7 +40,7 @@ namespace StructureHelperCommon.Models.Analyses
|
||||
}
|
||||
|
||||
|
||||
public IVersion GetCurrentVersion()
|
||||
public IDateVersion GetCurrentVersion()
|
||||
{
|
||||
return Versions[^1];
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,8 @@ namespace StructureHelperCommon.Models.Projects
|
||||
{
|
||||
public void Update(IFileVersion targetObject, IFileVersion sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; };
|
||||
targetObject.VersionNumber = sourceObject.VersionNumber;
|
||||
targetObject.SubVersionNumber = sourceObject.SubVersionNumber;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -17,6 +19,8 @@ namespace StructureHelperCommon.Models.Shapes
|
||||
/// <inheritdoc />
|
||||
public void Update(IPoint2D targetObject, IPoint2D sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject, ErrorStrings.SourceObject);
|
||||
CheckObject.IsNull(targetObject, ErrorStrings.TargetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.X = sourceObject.X;
|
||||
targetObject.Y = sourceObject.Y;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -11,6 +12,8 @@ namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
public void Update(IRectangleShape targetObject, IRectangleShape sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Width = sourceObject.Width;
|
||||
targetObject.Height = sourceObject.Height;
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperLogics.Models.Analyses;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogic.Models.Analyses
|
||||
{
|
||||
public class CrossSectionNdmAnalysis : IAnalysis
|
||||
{
|
||||
private CrossSectionNdmAnalysisUpdateStrategy updateStrategy = new();
|
||||
public Guid Id { get; private set; }
|
||||
public string Name { get; set; }
|
||||
public string Tags { get; set; }
|
||||
@@ -21,7 +18,7 @@ namespace StructureHelperLogic.Models.Analyses
|
||||
VersionProcessor = versionProcessor;
|
||||
}
|
||||
|
||||
public CrossSectionNdmAnalysis() : this(new Guid(), new VersionProcessor())
|
||||
public CrossSectionNdmAnalysis() : this(Guid.NewGuid(), new VersionProcessor())
|
||||
{
|
||||
CrossSection crossSection = new CrossSection();
|
||||
VersionProcessor.AddVersion(crossSection);
|
||||
@@ -29,7 +26,9 @@ namespace StructureHelperLogic.Models.Analyses
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
CrossSectionNdmAnalysis newAnalysis = new();
|
||||
updateStrategy.Update(newAnalysis, this);
|
||||
return newAnalysis;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
|
||||
public class CircleGeometryLogic : IRCGeometryLogic
|
||||
{
|
||||
ICircleTemplate template;
|
||||
CirclePrimitive concreteBlock;
|
||||
EllipsePrimitive concreteBlock;
|
||||
|
||||
public IEnumerable<IHeadMaterial> HeadMaterials { get; set; }
|
||||
|
||||
@@ -35,7 +35,8 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
|
||||
var diameter = template.Shape.Diameter;
|
||||
var concreteMaterial = HeadMaterials.ToList()[0];
|
||||
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);
|
||||
return primitives;
|
||||
}
|
||||
@@ -56,11 +57,11 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
|
||||
{
|
||||
Area = barArea,
|
||||
Name = "Left bottom point",
|
||||
HeadMaterial = reinforcementMaterial,
|
||||
HostPrimitive=concreteBlock };
|
||||
point.Center.X = x;
|
||||
point.Center.Y = y;
|
||||
primitives.Add(point);
|
||||
point.NdmElement.HeadMaterial = reinforcementMaterial;
|
||||
}
|
||||
return primitives;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,8 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
|
||||
private IEnumerable<INdmPrimitive> GetConcretePrimitives()
|
||||
{
|
||||
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);
|
||||
return primitives;
|
||||
}
|
||||
@@ -63,9 +64,10 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
|
||||
{
|
||||
Area = area1,
|
||||
Name = "Left bottom rebar",
|
||||
HeadMaterial = reinforcement,
|
||||
|
||||
HostPrimitive=concreteBlock
|
||||
};
|
||||
point.NdmElement.HeadMaterial = reinforcement;
|
||||
point.Center.X = xs[0];
|
||||
point.Center.Y = ys[0];
|
||||
primitives.Add(point);
|
||||
@@ -73,9 +75,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
|
||||
{
|
||||
Area = area1,
|
||||
Name = "Right bottom rebar",
|
||||
HeadMaterial = reinforcement,
|
||||
HostPrimitive = concreteBlock
|
||||
};
|
||||
point.NdmElement.HeadMaterial = reinforcement;
|
||||
point.Center.X = xs[1];
|
||||
point.Center.Y = ys[0];
|
||||
primitives.Add(point);
|
||||
@@ -83,9 +85,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
|
||||
{
|
||||
Area = area2,
|
||||
Name = "Left top rebar",
|
||||
HeadMaterial = reinforcement,
|
||||
HostPrimitive = concreteBlock
|
||||
};
|
||||
point.NdmElement.HeadMaterial = reinforcement;
|
||||
point.Center.X = xs[0];
|
||||
point.Center.Y = ys[1];
|
||||
primitives.Add(point);
|
||||
@@ -93,9 +95,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
|
||||
{
|
||||
Area = area2,
|
||||
Name = "Right top rebar",
|
||||
HeadMaterial = reinforcement,
|
||||
HostPrimitive = concreteBlock
|
||||
};
|
||||
point.NdmElement.HeadMaterial = reinforcement;
|
||||
point.Center.X = xs[1];
|
||||
point.Center.Y = ys[1];
|
||||
primitives.Add(point);
|
||||
@@ -115,11 +117,23 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
|
||||
double dist = (xs[1] - xs[0]) / count;
|
||||
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.Y = ys[0];
|
||||
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.Y = ys[1];
|
||||
primitives.Add(point);
|
||||
@@ -135,9 +149,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
|
||||
{
|
||||
Area = area1,
|
||||
Name = $"Left point {i}",
|
||||
HeadMaterial = reinforcement,
|
||||
HostPrimitive = concreteBlock
|
||||
};
|
||||
point.NdmElement.HeadMaterial = reinforcement;
|
||||
point.Center.X = xs[0];
|
||||
point.Center.Y = ys[0] + dist * i;
|
||||
primitives.Add(point);
|
||||
@@ -145,9 +159,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
|
||||
{
|
||||
Area = area1,
|
||||
Name = $"Right point {i}",
|
||||
HeadMaterial = reinforcement,
|
||||
HostPrimitive = concreteBlock
|
||||
};
|
||||
point.NdmElement.HeadMaterial = reinforcement;
|
||||
point.Center.X = xs[1];
|
||||
point.Center.Y = ys[0] + dist * i;
|
||||
primitives.Add(point);
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.RC
|
||||
inputData.CrossSectionArea = ndmPrimitive.Area;
|
||||
var diameter = Math.Sqrt(ndmPrimitive.Area / Math.PI) * 2d;
|
||||
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");
|
||||
}
|
||||
@@ -52,7 +52,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.RC
|
||||
if (primitive.HostPrimitive is not null)
|
||||
{
|
||||
var host = primitive.HostPrimitive;
|
||||
var hostMaterial = host.HeadMaterial.HelperMaterial;
|
||||
var hostMaterial = host
|
||||
.NdmElement
|
||||
.HeadMaterial
|
||||
.HelperMaterial;
|
||||
if (hostMaterial is 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)
|
||||
{
|
||||
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;
|
||||
return strength;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
RebarPrimitive rebarCopy = null;
|
||||
|
||||
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);
|
||||
crackableNdmsLoc = triangulationLogicLoc.GetNdmCollection();
|
||||
crackedNdmsLoc = triangulationLogicLoc.GetCrackedNdmCollection();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -9,46 +9,54 @@ using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
|
||||
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/>
|
||||
public Guid Id { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public string Name { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public IPoint2D Center { get; private set; }
|
||||
public IHeadMaterial? HeadMaterial { get; set; }
|
||||
public StrainTuple UsersPrestrain { get; }
|
||||
public StrainTuple AutoPrestrain { get; }
|
||||
public IVisualProperty VisualProperty { get; }
|
||||
public double Diameter { get; set; }
|
||||
public double NdmMaxSize { get; set; }
|
||||
public int NdmMinDivision { get; set; }
|
||||
public bool ClearUnderlying { get; set; }
|
||||
public bool Triangulate { get; set; }
|
||||
public IPoint2D Center { get; set; } = new Point2D();
|
||||
/// <inheritdoc/>
|
||||
public IVisualProperty VisualProperty { get; } = new VisualProperty { Opacity = 0.8d };
|
||||
/// <inheritdoc/>
|
||||
public double DiameterByX
|
||||
{
|
||||
get
|
||||
{
|
||||
return rectangleShape.Width;
|
||||
}
|
||||
set
|
||||
{
|
||||
rectangleShape.Width = value;
|
||||
rectangleShape.Height = value;
|
||||
}
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public double DiameterByY { get => rectangleShape.Height; set => rectangleShape.Height = value; }
|
||||
/// <inheritdoc/>
|
||||
public ICrossSection? CrossSection { get; set; }
|
||||
/// <inheritdoc/>
|
||||
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;
|
||||
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/>
|
||||
public object Clone()
|
||||
{
|
||||
var primitive = new CirclePrimitive();
|
||||
var primitive = new EllipsePrimitive();
|
||||
updateStrategy.Update(primitive, this);
|
||||
return primitive;
|
||||
}
|
||||
@@ -70,7 +78,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
var dX = Center.X - point.X;
|
||||
var dY = Center.Y - point.Y;
|
||||
var distance = Math.Sqrt(dX * dX + dY * dY);
|
||||
if (distance > Diameter / 2) { return false; }
|
||||
if (distance > DiameterByX / 2) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -88,28 +96,28 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
newPoint = new NamedAreaPoint
|
||||
{
|
||||
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
|
||||
};
|
||||
points.Add(newPoint);
|
||||
newPoint = new NamedAreaPoint
|
||||
{
|
||||
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
|
||||
};
|
||||
points.Add(newPoint);
|
||||
newPoint = new NamedAreaPoint
|
||||
{
|
||||
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
|
||||
};
|
||||
points.Add(newPoint);
|
||||
newPoint = new NamedAreaPoint
|
||||
{
|
||||
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
|
||||
};
|
||||
points.Add(newPoint);
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public interface ICirclePrimitive : INdmPrimitive, IHasDivisionSize, ICircleShape
|
||||
public interface IEllipsePrimitive : INdmPrimitive, IHasDivisionSize
|
||||
{
|
||||
double DiameterByX { get; set; }
|
||||
double DiameterByY { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -8,23 +7,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
/// <summary>
|
||||
/// Include parameters of triangulation for shapes
|
||||
/// </summary>
|
||||
public interface IHasDivisionSize
|
||||
{
|
||||
/// <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; }
|
||||
///<inheritdoc/>
|
||||
IDivisionSize DivisionSize { get; }
|
||||
/// <summary>
|
||||
/// Shows if point is located inside shape
|
||||
/// </summary>
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public interface ILinePrimitive : IHasDivisionSize, ILineShape
|
||||
public interface ILinePrimitive : IDivisionSize, ILineShape
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,6 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public interface INdmElement : ISaveable, ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// Base point of primitive
|
||||
/// </summary>
|
||||
IPoint2D Center { get; }
|
||||
/// <summary>
|
||||
/// Material of primitive
|
||||
/// </summary>
|
||||
|
||||
@@ -17,38 +17,22 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
/// <summary>
|
||||
/// Geometrical primitive which generates ndm elemtntary part
|
||||
/// </summary>
|
||||
public interface INdmPrimitive : ISaveable, ICloneable
|
||||
public interface INdmPrimitive : ISaveable, IHasCenter2D, ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of primitive
|
||||
/// </summary>
|
||||
string? Name { get; set; }
|
||||
INdmElement NdmElement { get;}
|
||||
IShape Shape { get; }
|
||||
/// <summary>
|
||||
/// Base point of primitive
|
||||
/// Base properties of primitive
|
||||
/// </summary>
|
||||
IPoint2D Center { get; }
|
||||
INdmElement NdmElement { get;}
|
||||
/// <summary>
|
||||
/// Host cross-section for primitive
|
||||
/// </summary>
|
||||
ICrossSection? CrossSection { get; set; }
|
||||
/// <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
|
||||
/// </summary>
|
||||
IVisualProperty VisualProperty {get; }
|
||||
|
||||
@@ -23,11 +23,14 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Name = sourceObject.Name;
|
||||
if (sourceObject.HeadMaterial != null) targetObject.HeadMaterial = sourceObject.HeadMaterial;
|
||||
targetObject.Triangulate = sourceObject.Triangulate;
|
||||
if (sourceObject.NdmElement.HeadMaterial != null)
|
||||
{
|
||||
targetObject.NdmElement.HeadMaterial = sourceObject.NdmElement.HeadMaterial;
|
||||
}
|
||||
targetObject.NdmElement.Triangulate = sourceObject.NdmElement.Triangulate;
|
||||
point2DUpdateStrategy.Update(targetObject.Center, sourceObject.Center);
|
||||
visualPropsUpdateStrategy.Update(targetObject.VisualProperty, sourceObject.VisualProperty);
|
||||
tupleUpdateStrategy.Update(targetObject.UsersPrestrain, sourceObject.UsersPrestrain);
|
||||
tupleUpdateStrategy.Update(targetObject.NdmElement.UsersPrestrain, sourceObject.NdmElement.UsersPrestrain);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
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;
|
||||
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,9 @@ using System.Threading.Tasks;
|
||||
|
||||
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; }
|
||||
targetObject.NdmMaxSize = sourceObject.NdmMaxSize;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,21 +5,16 @@ using StructureHelperCommon.Services;
|
||||
|
||||
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;
|
||||
|
||||
public INdmElementUpdateStrategy(IUpdateStrategy<IPoint2D> point2DUpdateStrategy,
|
||||
IUpdateStrategy<IForceTuple> tupleUpdateStrategy)
|
||||
public NdmElementUpdateStrategy(IUpdateStrategy<IForceTuple> tupleUpdateStrategy)
|
||||
{
|
||||
this.point2DUpdateStrategy = point2DUpdateStrategy;
|
||||
this.tupleUpdateStrategy = tupleUpdateStrategy;
|
||||
}
|
||||
|
||||
public INdmElementUpdateStrategy() : this (
|
||||
new Point2DUpdateStrategy(),
|
||||
new ForceTupleUpdateStrategy())
|
||||
public NdmElementUpdateStrategy() : this (new ForceTupleUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
@@ -29,8 +24,6 @@ namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
|
||||
{
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
|
||||
point2DUpdateStrategy.Update(targetObject.Center, sourceObject.Center);
|
||||
if (sourceObject.HeadMaterial != null)
|
||||
{
|
||||
targetObject.HeadMaterial = sourceObject.HeadMaterial;
|
||||
@@ -21,11 +21,11 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
}
|
||||
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
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,9 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
/// <inheritdoc/>
|
||||
public Guid Id { get; }
|
||||
/// <inheritdoc/>
|
||||
public IPoint2D Center { get; } = new Point2D();
|
||||
/// <inheritdoc/>
|
||||
public IHeadMaterial? HeadMaterial { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public bool Triangulate { get; set; }
|
||||
public bool Triangulate { get; set; } = true;
|
||||
/// <inheritdoc/>
|
||||
public StrainTuple UsersPrestrain { get; } = new();
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -14,34 +14,26 @@ namespace StructureHelperLogics.Models.Primitives
|
||||
static readonly PointUpdateStrategy updateStrategy = new();
|
||||
public Guid Id { get; }
|
||||
public string? Name { get; set; }
|
||||
public IPoint2D Center { get; private 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 IPoint2D Center { get; set; }
|
||||
public double Area { get; set; }
|
||||
|
||||
public IVisualProperty VisualProperty { get; }
|
||||
public bool Triangulate { get; set; }
|
||||
public IVisualProperty VisualProperty { get; } = new VisualProperty();
|
||||
|
||||
public ICrossSection? CrossSection { get; set; }
|
||||
|
||||
public INdmElement NdmElement { get; } = new NdmElement();
|
||||
|
||||
public IShape Shape => throw new NotImplementedException();
|
||||
|
||||
public PointPrimitive(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
Name = "New Point";
|
||||
Area = 0.0005d;
|
||||
Center = new Point2D();
|
||||
VisualProperty = new VisualProperty();
|
||||
UsersPrestrain = new StrainTuple();
|
||||
AutoPrestrain = new StrainTuple();
|
||||
Triangulate = true;
|
||||
}
|
||||
public PointPrimitive() : this (Guid.NewGuid())
|
||||
{}
|
||||
public PointPrimitive(IHeadMaterial material) : this() { HeadMaterial = material; }
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
|
||||
@@ -27,17 +27,9 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
/// <inheritdoc/>
|
||||
public string Name { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public IPoint2D Center { get; private set; }
|
||||
public IPoint2D Center { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public IHeadMaterial? HeadMaterial { get; set; }
|
||||
/// <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; }
|
||||
public IVisualProperty VisualProperty { get; private set; } = new VisualProperty();
|
||||
/// <inheritdoc/>
|
||||
public Guid Id { get; set; }
|
||||
/// <inheritdoc/>
|
||||
@@ -49,16 +41,14 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
|
||||
public INdmElement NdmElement { get; } = new NdmElement();
|
||||
|
||||
public IShape Shape => throw new NotImplementedException();
|
||||
|
||||
public RebarPrimitive(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
Name = "New Reinforcement";
|
||||
Area = 0.0005d;
|
||||
Center = new Point2D();
|
||||
VisualProperty = new VisualProperty();
|
||||
UsersPrestrain = new StrainTuple();
|
||||
AutoPrestrain = new StrainTuple();
|
||||
Triangulate = true;
|
||||
}
|
||||
public RebarPrimitive() : this(Guid.NewGuid())
|
||||
{
|
||||
|
||||
@@ -11,46 +11,34 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public class RectanglePrimitive : IRectanglePrimitive
|
||||
{
|
||||
readonly RectangleUpdateStrategy updateStrategy = new();
|
||||
private readonly RectanglePrimitiveUpdateStrategy updateStrategy = new();
|
||||
private readonly RectangleShape rectangleShape = new();
|
||||
public Guid Id { get;}
|
||||
public string Name { get; set; }
|
||||
public IHeadMaterial? HeadMaterial { get; set; }
|
||||
public StrainTuple UsersPrestrain { get; private set; }
|
||||
public StrainTuple AutoPrestrain { get; private set; }
|
||||
public double NdmMaxSize { get; set; }
|
||||
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 double Width { get => rectangleShape.Width; set => rectangleShape.Width = value; }
|
||||
public double Height { get => rectangleShape.Height; set => rectangleShape.Height = value; }
|
||||
public double Angle { get => rectangleShape.Angle; set => rectangleShape.Angle = value; }
|
||||
public IVisualProperty VisualProperty { get; } = new VisualProperty() { Opacity = 0.8d };
|
||||
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 IDivisionSize DivisionSize { get; } = new DivisionSize();
|
||||
|
||||
public IShape Shape => rectangleShape;
|
||||
|
||||
public RectanglePrimitive(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
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(IHeadMaterial material) : this() { HeadMaterial = material; }
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var primitive = new RectanglePrimitive();
|
||||
|
||||
@@ -25,14 +25,15 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
public ITriangulationOptions triangulationOptions { get; set; }
|
||||
public IHeadMaterial HeadMaterial { get; set; }
|
||||
|
||||
public CircleTriangulationLogicOptions(ICirclePrimitive primitive)
|
||||
public CircleTriangulationLogicOptions(IEllipsePrimitive primitive)
|
||||
{
|
||||
Center = primitive.Center.Clone() as Point2D;
|
||||
Circle = primitive;
|
||||
NdmMaxSize = primitive.NdmMaxSize;
|
||||
NdmMinDivision = primitive.NdmMinDivision;
|
||||
HeadMaterial = primitive.HeadMaterial;
|
||||
Prestrain = ForceTupleService.SumTuples(primitive.UsersPrestrain, primitive.AutoPrestrain) as StrainTuple;
|
||||
//to do change to ellipse
|
||||
Circle = new CircleShape() { Diameter = primitive.DiameterByX };
|
||||
NdmMaxSize = primitive.DivisionSize.NdmMaxSize;
|
||||
NdmMinDivision = primitive.DivisionSize.NdmMinDivision;
|
||||
HeadMaterial = primitive.NdmElement.HeadMaterial;
|
||||
Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
Center = primitive.Center.Clone() as Point2D;
|
||||
Area = primitive.Area;
|
||||
HeadMaterial = primitive.HeadMaterial;
|
||||
Prestrain = ForceTupleService.SumTuples(primitive.UsersPrestrain, primitive.AutoPrestrain) as StrainTuple;
|
||||
HeadMaterial = primitive.NdmElement.HeadMaterial;
|
||||
Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,11 +55,12 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
var hostPrimitive = options.HostPrimitive;
|
||||
var material = hostPrimitive
|
||||
.NdmElement
|
||||
.HeadMaterial
|
||||
.GetLoaderMaterial(options.triangulationOptions.LimiteState, options.triangulationOptions.CalcTerm);
|
||||
|
||||
var prestrain = ForceTupleService.SumTuples(hostPrimitive.UsersPrestrain,
|
||||
hostPrimitive.AutoPrestrain)
|
||||
var prestrain = ForceTupleService.SumTuples(hostPrimitive.NdmElement.UsersPrestrain,
|
||||
hostPrimitive.NdmElement.AutoPrestrain)
|
||||
as StrainTuple;
|
||||
|
||||
var concreteNdm = new Ndm
|
||||
|
||||
@@ -30,9 +30,9 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
Center = primitive.Center.Clone() as Point2D;
|
||||
Area = primitive.Area;
|
||||
HeadMaterial = primitive.HeadMaterial;
|
||||
HeadMaterial = primitive.NdmElement.HeadMaterial;
|
||||
HostPrimitive = primitive.HostPrimitive;
|
||||
Prestrain = ForceTupleService.SumTuples(primitive.UsersPrestrain, primitive.AutoPrestrain) as StrainTuple;
|
||||
Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
Center = new Point2D() {X = primitive.Center.X, Y = primitive.Center.Y };
|
||||
Rectangle = primitive;
|
||||
NdmMaxSize = primitive.NdmMaxSize;
|
||||
NdmMinDivision = primitive.NdmMinDivision;
|
||||
HeadMaterial = primitive.HeadMaterial;
|
||||
Prestrain = ForceTupleService.SumTuples(primitive.UsersPrestrain, primitive.AutoPrestrain) as StrainTuple;
|
||||
NdmMaxSize = primitive.DivisionSize.NdmMaxSize;
|
||||
NdmMinDivision = primitive.DivisionSize.NdmMinDivision;
|
||||
HeadMaterial = primitive.NdmElement.HeadMaterial;
|
||||
Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
Dictionary<Guid, IHeadMaterial> headMaterials = new Dictionary<Guid, IHeadMaterial>();
|
||||
foreach (var ndmPrimitive in ndmPrimitives)
|
||||
{
|
||||
IHeadMaterial material = ndmPrimitive.HeadMaterial;
|
||||
IHeadMaterial material = ndmPrimitive.NdmElement.HeadMaterial;
|
||||
if (!headMaterials.ContainsKey(material.Id)) { headMaterials.Add(material.Id, material); }
|
||||
}
|
||||
return headMaterials;
|
||||
|
||||
@@ -25,7 +25,9 @@ namespace StructureHelperLogics.Services.NdmPrimitives
|
||||
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
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");
|
||||
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
@@ -33,8 +35,8 @@ namespace StructureHelperLogics.Services.NdmPrimitives
|
||||
}
|
||||
foreach (var item in Primitives)
|
||||
{
|
||||
if (item.Triangulate == true &
|
||||
item.HeadMaterial is null)
|
||||
if (item.NdmElement.Triangulate == true &
|
||||
item.NdmElement.HeadMaterial is null)
|
||||
{
|
||||
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Primitive: {item.Name} can't be triangulated since material is null");
|
||||
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
|
||||
@@ -9,10 +9,22 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Services.NdmPrimitives
|
||||
{
|
||||
/// <summary>
|
||||
/// Implement logic of triangulation of primitives which have parameters of division
|
||||
/// </summary>
|
||||
public interface IMeshHasDivisionLogic : ILogic
|
||||
{
|
||||
List<INdm> NdmCollection { get; set; }
|
||||
IHasDivisionSize Primitive { get; set; }
|
||||
/// <summary>
|
||||
/// 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
|
||||
CheckPrimitive();
|
||||
List<INdm> ndmCollection = new();
|
||||
if (Primitive.HeadMaterial.HelperMaterial is ICrackedMaterial)
|
||||
if (Primitive.NdmElement.HeadMaterial.HelperMaterial is ICrackedMaterial)
|
||||
{
|
||||
ProcessICracked(ndmCollection);
|
||||
}
|
||||
@@ -74,13 +74,13 @@ namespace StructureHelperLogics.Services.NdmPrimitives
|
||||
|
||||
private void SetNewMaterial(INdmPrimitive? newPrimititve)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Process material {newPrimititve.HeadMaterial.Name} has started");
|
||||
var newHeadMaterial = newPrimititve.HeadMaterial.Clone() as IHeadMaterial;
|
||||
TraceLogger?.AddMessage($"Process material {newPrimititve.NdmElement.HeadMaterial.Name} has started");
|
||||
var newHeadMaterial = newPrimititve.NdmElement.HeadMaterial.Clone() as IHeadMaterial;
|
||||
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;
|
||||
newHeadMaterial.HelperMaterial = newMaterial as IHelperMaterial;
|
||||
newPrimititve.HeadMaterial = newHeadMaterial;
|
||||
newPrimititve.NdmElement.HeadMaterial = newHeadMaterial;
|
||||
}
|
||||
|
||||
private List<INdm> GetNdms(INdmPrimitive primitive)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
@@ -12,30 +14,55 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Services.NdmPrimitives
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public class MeshHasDivisionLogic : IMeshHasDivisionLogic
|
||||
{
|
||||
public List<INdm> NdmCollection { get; set; }
|
||||
public IHasDivisionSize Primitive { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public List<INdm>? NdmCollection { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public IHasDivisionSize? Primitive { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public void MeshHasDivision()
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
|
||||
CheckInputData();
|
||||
if (Primitive is IHasDivisionSize hasDivision)
|
||||
{
|
||||
if (hasDivision.ClearUnderlying == true)
|
||||
if (hasDivision.DivisionSize.ClearUnderlying == true)
|
||||
{
|
||||
TraceLogger?.AddMessage("Removing of background part has started", TraceLogStatuses.Service);
|
||||
NdmCollection
|
||||
.RemoveAll(x =>
|
||||
hasDivision
|
||||
.IsPointInside(new Point2D()
|
||||
{
|
||||
X = x.CenterX,
|
||||
Y = x.CenterY
|
||||
}) == true);
|
||||
NdmCollection.RemoveAll(x => IsCenterInside(x, hasDivision) == true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsCenterInside(INdm x, IHasDivisionSize hasDivision)
|
||||
{
|
||||
Point2D point = new Point2D()
|
||||
{
|
||||
X = x.CenterX,
|
||||
Y = x.CenterY
|
||||
};
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
|
||||
divisionLogic.Primitive = hasDivision;
|
||||
divisionLogic.MeshHasDivision();
|
||||
}
|
||||
if (primitive.Triangulate == true)
|
||||
if (primitive.NdmElement.Triangulate == true)
|
||||
{
|
||||
meshLogic.Primitive = primitive;
|
||||
var ndms = meshLogic.MeshPrimitive();
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT
|
||||
//Act
|
||||
foreach (var item in ndmPrimitives)
|
||||
{
|
||||
ForceTupleService.CopyProperties(source, item.AutoPrestrain);
|
||||
ForceTupleService.CopyProperties(source, item.NdmElement.AutoPrestrain);
|
||||
}
|
||||
calculator.Run();
|
||||
var result2 = calculator.Result as IForcesResults;
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace StructureHelperTests.UnitTests.Ndms
|
||||
|
||||
_mockRebarPrimitive.Setup(x => x.HostPrimitive).Returns(mockHostPrimitive.Object);
|
||||
_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);
|
||||
|
||||
// Act
|
||||
|
||||
@@ -56,7 +56,7 @@ public class CheckTupleCalculatorInputDataTests
|
||||
// Arrange
|
||||
_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
|
||||
};
|
||||
|
||||
@@ -74,7 +74,7 @@ public class CheckTupleCalculatorInputDataTests
|
||||
// Arrange
|
||||
_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
|
||||
};
|
||||
|
||||
|
||||
@@ -66,14 +66,23 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
|
||||
//Arrange
|
||||
ProgramSetting.NatSystem = NatSystems.RU;
|
||||
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.Y = centerY;
|
||||
mainBlock.VisualProperty.ZIndex = 0;
|
||||
var opening = new RectanglePrimitive()
|
||||
{ Width = 0.3d, Height = 0.2d,
|
||||
HeadMaterial = material, Triangulate = triangOpening,
|
||||
ClearUnderlying = true};
|
||||
{
|
||||
Width = 0.3d,
|
||||
Height = 0.2d
|
||||
};
|
||||
opening.DivisionSize.ClearUnderlying = true;
|
||||
opening.NdmElement.HeadMaterial = material;
|
||||
opening.NdmElement.Triangulate = triangOpening;
|
||||
opening.VisualProperty.ZIndex = 1;
|
||||
var primitives = new List<INdmPrimitive>() { mainBlock, opening };
|
||||
//Act
|
||||
@@ -100,19 +109,28 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
|
||||
//Arrange
|
||||
ProgramSetting.NatSystem = NatSystems.RU;
|
||||
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.Y = centerY;
|
||||
mainBlock.VisualProperty.ZIndex = 0;
|
||||
var opening = new CirclePrimitive()
|
||||
var opening = new EllipsePrimitive()
|
||||
{
|
||||
Diameter = 0.3d,
|
||||
HeadMaterial = material,
|
||||
Triangulate = triangOpening,
|
||||
ClearUnderlying = true
|
||||
DiameterByX = 0.3d
|
||||
};
|
||||
opening.DivisionSize.ClearUnderlying = true;
|
||||
opening.NdmElement.HeadMaterial = material;
|
||||
opening.NdmElement.Triangulate = triangOpening;
|
||||
opening.VisualProperty.ZIndex = 1;
|
||||
var primitives = new List<INdmPrimitive>() { mainBlock, opening };
|
||||
var primitives = new List<INdmPrimitive>()
|
||||
{
|
||||
mainBlock,
|
||||
opening
|
||||
};
|
||||
//Act
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
@@ -137,18 +155,19 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
|
||||
//Arrange
|
||||
ProgramSetting.NatSystem = NatSystems.RU;
|
||||
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.Y = centerY;
|
||||
mainBlock.VisualProperty.ZIndex = 0;
|
||||
var opening = new RectanglePrimitive()
|
||||
{
|
||||
Width = 0.3d,
|
||||
Height = 0.2d,
|
||||
HeadMaterial = material,
|
||||
Triangulate = triangOpening,
|
||||
ClearUnderlying = true
|
||||
Height = 0.2d
|
||||
};
|
||||
opening.DivisionSize.ClearUnderlying = true;
|
||||
opening.NdmElement.HeadMaterial = material;
|
||||
opening.NdmElement.Triangulate = triangOpening;
|
||||
opening.VisualProperty.ZIndex = 1;
|
||||
var primitives = new List<INdmPrimitive>() { mainBlock, opening };
|
||||
//Act
|
||||
|
||||
@@ -26,7 +26,8 @@ namespace StructureHelperTests.ViewModelTests
|
||||
{
|
||||
//Arrange
|
||||
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40);
|
||||
var primitive = new RectanglePrimitive(material);
|
||||
var primitive = new RectanglePrimitive();
|
||||
primitive.NdmElement.HeadMaterial = material;
|
||||
var primitiveBase = new RectangleViewPrimitive(primitive);
|
||||
//Act
|
||||
var vm = new PrimitivePropertiesViewModel(primitiveBase, new CrossSectionRepository());
|
||||
@@ -39,7 +40,8 @@ namespace StructureHelperTests.ViewModelTests
|
||||
//Arrange
|
||||
ProgramSetting.NatSystem = NatSystems.RU;
|
||||
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);
|
||||
//Act
|
||||
var vm = new PrimitivePropertiesViewModel(primitiveBase, new CrossSectionRepository());
|
||||
@@ -53,7 +55,8 @@ namespace StructureHelperTests.ViewModelTests
|
||||
//Arrange
|
||||
ProgramSetting.NatSystem = NatSystems.RU;
|
||||
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40);
|
||||
var primitive = new PointPrimitive(material);
|
||||
var primitive = new PointPrimitive();
|
||||
primitive.NdmElement.HeadMaterial = material;
|
||||
var primitiveBase = new PointViewPrimitive(primitive);
|
||||
//Act
|
||||
var vm = new PrimitivePropertiesViewModel(primitiveBase, new CrossSectionRepository());
|
||||
@@ -66,7 +69,8 @@ namespace StructureHelperTests.ViewModelTests
|
||||
//Arrange
|
||||
ProgramSetting.NatSystem = NatSystems.RU;
|
||||
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);
|
||||
//Act
|
||||
var vm = new PrimitivePropertiesViewModel(primitiveBase, new CrossSectionRepository());
|
||||
|
||||
Reference in New Issue
Block a user