Add triangulation of polygon
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives.Logics;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class NdmElementFromDTOConvertStrategy : ConvertStrategy<INdmElement, INdmElement>
|
||||
{
|
||||
private IUpdateStrategy<INdmElement> updateStrategy;
|
||||
private IUpdateStrategy<IForceTuple> forceUpdateStrategy = new ForceTupleUpdateStrategy();
|
||||
private NdmElement newItem;
|
||||
|
||||
public NdmElementFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override INdmElement GetNewItem(INdmElement source)
|
||||
{
|
||||
if (source is not NdmElementDTO sourceDTO)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source));
|
||||
}
|
||||
newItem = new NdmElement(sourceDTO.Id);
|
||||
updateStrategy = new NdmElementUpdateStrategy() { UpdateChildren = false};
|
||||
updateStrategy.Update(newItem, sourceDTO);
|
||||
forceUpdateStrategy.Update(newItem.UsersPrestrain, source.UsersPrestrain);
|
||||
//newItem.UsersPrestrain.Id = source.UsersPrestrain.Id;
|
||||
//forceUpdateStrategy.Update(newItem.AutoPrestrain, source.AutoPrestrain);
|
||||
//(newItem.AutoPrestrain as ForceTupleDTO).Id = source.AutoPrestrain.Id;
|
||||
NewItem = newItem;
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,16 +54,20 @@ namespace DataAccess.DTOs
|
||||
updateStrategy.Update(newItem, source);
|
||||
headMaterialConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
headMaterialConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<HeadMaterialDTO, IHeadMaterial>(this, headMaterialConvertStrategy);
|
||||
var headMaterialLogic = new DictionaryConvertStrategy<HeadMaterialDTO, IHeadMaterial>(this, headMaterialConvertStrategy);
|
||||
if (source.HeadMaterial != null)
|
||||
{
|
||||
var headMaterial = convertLogic.Convert(source.HeadMaterial);
|
||||
var headMaterial = headMaterialLogic.Convert(source.HeadMaterial);
|
||||
newItem.HeadMaterial = headMaterial;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newItem.HeadMaterial = null;
|
||||
}
|
||||
forceUpdateStrategy.Update(newItem.UsersPrestrain, source.UsersPrestrain);
|
||||
(newItem.UsersPrestrain as ForceTupleDTO).Id = source.UsersPrestrain.Id;
|
||||
forceUpdateStrategy.Update(newItem.AutoPrestrain, source.AutoPrestrain);
|
||||
(newItem.AutoPrestrain as ForceTupleDTO).Id = source.AutoPrestrain.Id;
|
||||
//forceUpdateStrategy.Update(newItem.AutoPrestrain, source.AutoPrestrain);
|
||||
//(newItem.AutoPrestrain as ForceTupleDTO).Id = source.AutoPrestrain.Id;
|
||||
return newItem;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +45,12 @@ namespace DataAccess.DTOs
|
||||
|
||||
public override INdmPrimitive GetNewItem(INdmPrimitive source)
|
||||
{
|
||||
GetMaterial(source.NdmElement.HeadMaterial);
|
||||
INdmPrimitive newItem = GetNewPrimitive(source);
|
||||
newItem.NdmElement.HeadMaterial = headMaterial;
|
||||
if (source.NdmElement.HeadMaterial != null)
|
||||
{
|
||||
GetMaterial(source.NdmElement.HeadMaterial);
|
||||
newItem.NdmElement.HeadMaterial = headMaterial;
|
||||
}
|
||||
return newItem;
|
||||
}
|
||||
|
||||
@@ -69,11 +72,23 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
return GetRectangle(rectangle);
|
||||
}
|
||||
if (source is ShapeNdmPrimitiveDTO shape)
|
||||
{
|
||||
return GetShape(shape);
|
||||
}
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
||||
TraceLogger.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
|
||||
private INdmPrimitive GetShape(ShapeNdmPrimitiveDTO shape)
|
||||
{
|
||||
TraceLogger?.AddMessage($"{PrimitiveIs} shape ndm primitive");
|
||||
ShapeNdmPrimitiveFromDTOConvertStrategy convertStrategy = new(this);
|
||||
IShapeNdmPrimitive shapeNdmPrimitive = convertStrategy.Convert(shape);
|
||||
return shapeNdmPrimitive;
|
||||
}
|
||||
|
||||
private void GetMaterial(IHeadMaterial source)
|
||||
{
|
||||
HeadMaterialFromDTOConvertStrategy convertStrategy = new()
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ShapeNdmPrimitiveFromDTOConvertStrategy : ConvertStrategy<IShapeNdmPrimitive, IShapeNdmPrimitive>
|
||||
{
|
||||
IUpdateStrategy<IShapeNdmPrimitive> updateStrategy;
|
||||
private IConvertStrategy<IShape, IShape> shapeConvertStrategy;
|
||||
private IConvertStrategy<INdmElement, INdmElement> ndmElementConvertStrategy;
|
||||
private IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy;
|
||||
private IConvertStrategy<IVisualProperty, VisualPropertyDTO> visualPropsConvertStrategy;
|
||||
private IConvertStrategy<IDivisionSize, IDivisionSize> divisionConvertStrategy;
|
||||
|
||||
private ShapeNdmPrimitive newItem;
|
||||
|
||||
public ShapeNdmPrimitiveFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
updateStrategy = new ShapeNdmPrimitiveUpdateStrategy() { UpdateChildren = false };
|
||||
shapeConvertStrategy = new ShapeFromDTOConvertStrategy(this);
|
||||
ndmElementConvertStrategy = new NdmElementFromDTOConvertStrategy(this);
|
||||
pointConvertStrategy = new Point2DFromDTOConvertStrategy(this);
|
||||
visualPropsConvertStrategy = new VisualPropertyFromDTOConvertStrategy(this);
|
||||
divisionConvertStrategy = new DivisionSizeFromDTOConvertStrategy(this);
|
||||
}
|
||||
|
||||
public override IShapeNdmPrimitive GetNewItem(IShapeNdmPrimitive source)
|
||||
{
|
||||
ChildClass = this;
|
||||
if (source is not ShapeNdmPrimitiveDTO sourceDTO)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source) + ": source shape is not DTO object");
|
||||
}
|
||||
newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, sourceDTO);
|
||||
updateChildProperties(sourceDTO);
|
||||
NewItem = newItem;
|
||||
return NewItem;
|
||||
}
|
||||
private void updateChildProperties(ShapeNdmPrimitiveDTO source)
|
||||
{
|
||||
newItem.SetShape(shapeConvertStrategy.Convert(source.Shape));
|
||||
newItem.NdmElement = ndmElementConvertStrategy.Convert(source.NdmElement);
|
||||
newItem.Center = pointConvertStrategy.Convert(source.Center as Point2DDTO);
|
||||
newItem.VisualProperty = visualPropsConvertStrategy.Convert(source.VisualProperty as VisualPropertyDTO);
|
||||
newItem.DivisionSize = divisionConvertStrategy.Convert(source.DivisionSize);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user