Merge pull request #1 from RedikultsevEvg/Triangulation

Triangulation
This commit is contained in:
RedikultsevEvg
2022-06-23 20:37:23 +05:00
committed by GitHub
42 changed files with 1145 additions and 35 deletions

Binary file not shown.

View File

@@ -128,6 +128,8 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup>
<Folder Include="Logics\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@@ -5,7 +5,12 @@ VisualStudioVersion = 16.0.32002.261
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureHelper", "StructureHelper.csproj", "{BAD27E27-4444-4300-ADF8-E21042C0781D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureHelper", "StructureHelper.csproj", "{BAD27E27-4444-4300-ADF8-E21042C0781D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureHelperTests", ".\StructureHelperTests\StructureHelperTests.csproj", "{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureHelperTests", "StructureHelperTests\StructureHelperTests.csproj", "{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}"
ProjectSection(ProjectDependencies) = postProject
{330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3} = {330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructureHelperLogics", "StructureHelperLogics\StructureHelperLogics.csproj", "{330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -21,6 +26,10 @@ Global
{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Debug|Any CPU.Build.0 = Debug|Any CPU {7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Release|Any CPU.ActiveCfg = Release|Any CPU {7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Release|Any CPU.Build.0 = Release|Any CPU {7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Release|Any CPU.Build.0 = Release|Any CPU
{330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Data.Shapes
{
/// <inheritdoc />
public class Center : ICenter
{
/// <inheritdoc />
public double X { get; set; }
/// <inheritdoc />
public double Y { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Data.Shapes
{
/// <summary>
/// Interface for point of center of some shape
/// Интерфейс для точки центра некоторой формы
/// </summary>
public interface ICenter
{
/// <summary>
/// Coordinate of center of rectangle by local axis X, m
/// Координата центра вдоль локальной оси X, м
/// </summary>
double X { get;}
/// <summary>
/// Coordinate of center of rectangle by local axis Y, m
/// Координата центра вдоль локальной оси Y, м
/// </summary>
double Y { get;}
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Data.Shapes
{
public interface ICenterShape
{
ICenter Center {get;}
IShape Shape { get;}
}
}

View File

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Data.Shapes
{
public interface ICircle : IShape
{
double Diameter { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Data.Shapes
{
public interface IPoint : IShape
{
double Area { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Data.Shapes
{
public interface IRectangle : IShape
{
/// <summary>
/// Width of rectangle, m
/// </summary>
double Width { get; }
/// <summary>
/// Height of rectangle, m
/// </summary>
double Height { get; }
/// <summary>
/// Angle of rotating rectangle, rad
/// </summary>
double Angle { get; }
}
}

View File

@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Data.Shapes
{
public interface IShape
{
}
}

View File

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Data.Shapes
{
public class Point : IPoint
{
public double Area { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Data.Shapes
{
/// <inheritdoc />
public class Rectangle : IRectangle
{
/// <inheritdoc />
public double Width { get; set; }
/// <inheritdoc />
public double Height { get; set; }
/// <inheritdoc />
public double Angle { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Infrastructures.CommonEnums
{
public enum CalcTerms
{
ShortTerm,
LongTerm,
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Infrastructures.CommonEnums
{
public enum LimitStates
{
Collapse = 1,
ServiceAbility = 2,
Special = 3,
}
}

View File

@@ -0,0 +1,17 @@
using StructureHelperLogics.Data.Shapes;
using StructureHelperLogics.NdmCalculations.Materials;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Entities
{
public interface INdmPrimitive
{
ICenter Center { get; set; }
IShape Shape { get; set; }
IPrimitiveMaterial PrimitiveMaterial {get;set;}
double NdmMaxSize { get; set; }
int NdmMinDivision { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using StructureHelperLogics.Data.Shapes;
using StructureHelperLogics.NdmCalculations.Materials;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Entities
{
public class NdmPrimitive : INdmPrimitive
{
public ICenter Center { get; set; }
public IShape Shape { get; set; }
public IPrimitiveMaterial PrimitiveMaterial { get; set; }
public double NdmMaxSize { get; set; }
public int NdmMinDivision { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Materials
{
public interface IPrimitiveMaterial
{
string Id { get;}
MaterialTypes MaterialType { get; }
string ClassName { get; }
double Strength { get; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Materials
{
public enum MaterialTypes
{
Concrete,
Reinforcement,
//Steel,
//CarbonFiber,
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Materials
{
public class PrimitiveMaterial : IPrimitiveMaterial
{
public string Id { get; }
public MaterialTypes MaterialType { get; set; }
public string ClassName { get; set; }
public double Strength { get; set; }
public PrimitiveMaterial()
{
Id = Convert.ToString(Guid.NewGuid());
}
}
}

View File

@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Triangulations
{
interface IPointTiangulationLogic : ITriangulationLogic
{
}
}

View File

@@ -0,0 +1,13 @@
using StructureHelperLogics.Data.Shapes;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Triangulations
{
public interface IPointTriangulationLogicOptions : ITriangulationLogicOptions
{
ICenter Center { get; }
double Area { get; }
}
}

View File

@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Triangulations
{
public interface IRectangleTriangulationLogic : ITriangulationLogic
{
}
}

View File

@@ -0,0 +1,31 @@
using StructureHelperLogics.Data.Shapes;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Triangulations
{
/// <summary>
/// Parameter of triangulation of rectangle part of section
/// Параметры триангуляции прямоугольного участка сечения
/// </summary>
public interface IRectangleTriangulationLogicOptions : ITriangulationLogicOptions
{
/// <summary>
///
/// </summary>
ICenter Center { get; }
/// <summary>
///
/// </summary>
IRectangle Rectangle { get; }
/// <summary>
/// Maximum size (width or height) of ndm part after triangulation
/// </summary>
double NdmMaxSize { get; }
/// <summary>
/// Minimum quantity of division of side of rectangle after triangulation
/// </summary>
int NdmMinDivision { get; }
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.Materials;
namespace StructureHelperLogics.NdmCalculations.Triangulations
{
public interface ITriangulationLogic
{
ITriangulationLogicOptions Options { get; }
IEnumerable<INdm> GetNdmCollection(IMaterial material);
void ValidateOptions(ITriangulationLogicOptions options);
}
}

View File

@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Triangulations
{
public interface ITriangulationLogicOptions
{
}
}

View File

@@ -0,0 +1,13 @@
using StructureHelperLogics.Infrastructures.CommonEnums;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Triangulations
{
public interface ITriangulationOptions
{
LimitStates LimiteState { get; }
CalcTerms CalcTerm { get; }
}
}

View File

@@ -0,0 +1,35 @@
using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Ndms;
using StructureHelperLogics.Data.Shapes;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Triangulations
{
public class PointTriangulationLogic : IPointTiangulationLogic
{
public ITriangulationLogicOptions Options { get; }
public PointTriangulationLogic(IPointTriangulationLogicOptions options)
{
Options = options;
}
public IEnumerable<INdm> GetNdmCollection(IMaterial material)
{
IPointTriangulationLogicOptions options = Options as IPointTriangulationLogicOptions;
ICenter center = options.Center;
double area = options.Area;
List<INdm> ndmCollection = new List<INdm>();
INdm ndm = new Ndm() { CenterX = center.X, CenterY = center.Y, Area = area, Material = material };
ndmCollection.Add(ndm);
return ndmCollection;
}
public void ValidateOptions(ITriangulationLogicOptions options)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,26 @@
using StructureHelperLogics.Data.Shapes;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Triangulations
{
/// <summary>
///
/// </summary>
public class PointTriangulationLogicOptions : IPointTriangulationLogicOptions
{
/// <summary>
///
/// </summary>
public ICenter Center { get; }
public double Area { get; }
public PointTriangulationLogicOptions(ICenter center, double area)
{
Center = center;
Area = area;
}
}
}

View File

@@ -0,0 +1,42 @@
using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Ndms;
using System;
using System.Collections.Generic;
using System.Text;
using LoaderCalculator.Data.Ndms.Transformations;
namespace StructureHelperLogics.NdmCalculations.Triangulations
{
public class RectangleTriangulationLogic : IRectangleTriangulationLogic
{
public ITriangulationLogicOptions Options { get; }
public IEnumerable<INdm> GetNdmCollection(IMaterial material)
{
IRectangleTriangulationLogicOptions rectangleOptions = Options as IRectangleTriangulationLogicOptions;
double width = rectangleOptions.Rectangle.Width;
double height = rectangleOptions.Rectangle.Height;
double ndmMaxSize = rectangleOptions.NdmMaxSize;
int ndmMinDivision = rectangleOptions.NdmMinDivision;
LoaderCalculator.Triangulations.RectangleTriangulationLogicOptions logicOptions = new LoaderCalculator.Triangulations.RectangleTriangulationLogicOptions(width, height, ndmMaxSize, ndmMinDivision);
var logic = LoaderCalculator.Triangulations.Triangulation.GetLogicInstance(logicOptions);
var ndmCollection = logic.GetNdmCollection(new LoaderCalculator.Data.Planes.RectangularPlane { Material = material });
double dX = rectangleOptions.Center.X;
double dY = rectangleOptions.Center.Y;
NdmTransform.Move(ndmCollection, dX, dY);
double angle = rectangleOptions.Rectangle.Angle;
NdmTransform.Rotate(ndmCollection, angle);
return ndmCollection;
}
public void ValidateOptions(ITriangulationLogicOptions options)
{
throw new NotImplementedException();
}
public RectangleTriangulationLogic(ITriangulationLogicOptions options)
{
Options = options;
}
}
}

View File

@@ -0,0 +1,38 @@
using StructureHelperLogics.Data.Shapes;
using StructureHelperLogics.NdmCalculations.Entities;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Triangulations
{
/// <inheritdoc />
public class RectangleTriangulationLogicOptions : IRectangleTriangulationLogicOptions
{
/// <inheritdoc />
public ICenter Center { get; }
/// <inheritdoc />
public IRectangle Rectangle { get; }
/// <inheritdoc />
public double NdmMaxSize { get; }
/// <inheritdoc />
public int NdmMinDivision { get; }
public RectangleTriangulationLogicOptions(ICenter center, IRectangle rectangle, double ndmMaxSize, int ndmMinDivision)
{
Center = center;
Rectangle = rectangle;
NdmMaxSize = ndmMaxSize;
NdmMinDivision = ndmMinDivision;
}
public RectangleTriangulationLogicOptions(INdmPrimitive primitive)
{
if (! (primitive.Shape is IRectangle)) { throw new Exception("Shape type is not valid"); }
Center = primitive.Center;
Rectangle = primitive.Shape as IRectangle;
NdmMaxSize = primitive.NdmMaxSize;
NdmMinDivision = primitive.NdmMinDivision;
}
}
}

View File

@@ -0,0 +1,114 @@
using System;
using System.Collections.Generic;
using System.Text;
using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Materials.MaterialBuilders;
using LoaderCalculator.Data.Ndms;
using StructureHelperLogics.Data.Shapes;
using StructureHelperLogics.NdmCalculations.Entities;
using StructureHelperLogics.NdmCalculations.Materials;
namespace StructureHelperLogics.NdmCalculations.Triangulations
{
public static class Triangulation
{
public static IEnumerable<INdm> GetNdms(IEnumerable<INdmPrimitive> ndmPrimitives, ITriangulationOptions options)
{
List<INdm> ndms = new List<INdm>();
Dictionary<string, IPrimitiveMaterial> primitiveMaterials = GetPrimitiveMaterials(ndmPrimitives);
Dictionary<string, IMaterial> materials = GetMaterials(primitiveMaterials, options);
foreach (var ndmPrimitive in ndmPrimitives)
{
IPrimitiveMaterial primitiveMaterial = ndmPrimitive.PrimitiveMaterial;
IMaterial material;
if (materials.TryGetValue(primitiveMaterial.Id, out material) == false) { throw new Exception("Material dictionary is not valid"); }
IEnumerable<INdm> localNdms = GetNdmsByPrimitive(ndmPrimitive, material);
ndms.AddRange(localNdms);
}
return ndms;
}
private static Dictionary<string, IPrimitiveMaterial> GetPrimitiveMaterials(IEnumerable<INdmPrimitive> ndmPrimitives)
{
Dictionary<string, IPrimitiveMaterial> primitiveMaterials = new Dictionary<string, IPrimitiveMaterial>();
foreach (var ndmPrimitive in ndmPrimitives)
{
IPrimitiveMaterial material = ndmPrimitive.PrimitiveMaterial;
if (!primitiveMaterials.ContainsKey(material.Id)) { primitiveMaterials.Add(material.Id, material); }
}
return primitiveMaterials;
}
private static Dictionary<string, IMaterial> GetMaterials(Dictionary<string, IPrimitiveMaterial> PrimitiveMaterials, ITriangulationOptions options)
{
Dictionary<string, IMaterial> materials = new Dictionary<string, IMaterial>();
IEnumerable<string> keyCollection = PrimitiveMaterials.Keys;
IMaterial material;
foreach (string id in keyCollection)
{
IPrimitiveMaterial primitiveMaterial;
if (PrimitiveMaterials.TryGetValue(id, out primitiveMaterial) == false) { throw new Exception("Material dictionary is not valid"); }
material = GetMaterial(primitiveMaterial, options);
materials.Add(id, material);
}
return materials;
}
private static IEnumerable<INdm> GetNdmsByPrimitive(INdmPrimitive primitive, IMaterial material)
{
List<INdm> ndms = new List<INdm>();
ITriangulationLogicOptions options;
ICenter center = primitive.Center;
IShape shape = primitive.Shape;
if (shape is IRectangle)
{
IRectangle rectangle = shape as IRectangle;
options = new RectangleTriangulationLogicOptions(primitive);
IRectangleTriangulationLogic logic = new RectangleTriangulationLogic(options);
ndms.AddRange(logic.GetNdmCollection(material));
}
else { throw new Exception("Primitive type is not valid"); }
return ndms;
}
public static IMaterial GetMaterial(IPrimitiveMaterial primitiveMaterial, ITriangulationOptions options)
{
IMaterial material;
if (primitiveMaterial.MaterialType == MaterialTypes.Concrete) { material = GetConcreteMaterial(primitiveMaterial, options); }
else if (primitiveMaterial.MaterialType == MaterialTypes.Reinforcement) { material = GetReinforcementMaterial(primitiveMaterial, options); }
else { throw new Exception("Material type is invalid"); }
return material;
}
private static IMaterial GetConcreteMaterial(IPrimitiveMaterial primitiveMaterial, ITriangulationOptions options)
{
IMaterialOptions materialOptions = new ConcreteOptions();
SetMaterialOptions(materialOptions, primitiveMaterial, options);
IMaterialBuilder builder = new ConcreteBuilder(materialOptions);
IBuilderDirector director = new BuilderDirector(builder);
return director.BuildMaterial();
}
private static IMaterial GetReinforcementMaterial(IPrimitiveMaterial primitiveMaterial, ITriangulationOptions options)
{
IMaterialOptions materialOptions = new ReinforcementOptions();
SetMaterialOptions(materialOptions, primitiveMaterial, options);
IMaterialBuilder builder = new ReinforcementBuilder(materialOptions);
IBuilderDirector director = new BuilderDirector(builder);
return director.BuildMaterial();
}
private static void SetMaterialOptions(IMaterialOptions materialOptions, IPrimitiveMaterial primitiveMaterial, ITriangulationOptions options)
{
materialOptions.Strength = primitiveMaterial.Strength;
materialOptions.CodesType = CodesType.EC2_1990;
if (options.LimiteState == Infrastructures.CommonEnums.LimitStates.Collapse) { materialOptions.LimitState = LimitStates.Collapse; }
else if (options.LimiteState == Infrastructures.CommonEnums.LimitStates.ServiceAbility) { materialOptions.LimitState = LimitStates.ServiceAbility; }
else if (options.LimiteState == Infrastructures.CommonEnums.LimitStates.Special) { materialOptions.LimitState = LimitStates.Special; }
else { throw new Exception("LimitStateType is not valid"); }
if (options.CalcTerm == Infrastructures.CommonEnums.CalcTerms.ShortTerm) { materialOptions.IsShortTerm = true; }
else if (options.CalcTerm == Infrastructures.CommonEnums.CalcTerms.LongTerm) { materialOptions.IsShortTerm = false; }
else { throw new Exception("Calculation term is not valid"); }
}
}
}

View File

@@ -0,0 +1,13 @@
using StructureHelperLogics.Infrastructures.CommonEnums;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Triangulations
{
public class TriangulationOptions : ITriangulationOptions
{
public LimitStates LimiteState { get; set; }
public CalcTerms CalcTerm { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Reference Include="LoaderCalculator">
<HintPath>..\..\StructureHelper\Libraries\LoaderCalculator.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,97 @@
using LoaderCalculator;
using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.SourceData;
using LoaderCalculator.Tests.Infrastructures.Logics;
using NUnit.Framework;
using StructureHelperLogics.Data.Shapes;
using StructureHelperLogics.NdmCalculations.Entities;
using StructureHelperLogics.NdmCalculations.Materials;
using StructureHelperLogics.NdmCalculations.Triangulations;
using System.Collections.Generic;
using System.Threading;
namespace StructureHelperTests.FunctionalTests.Ndms.RCSections
{
public class RCSectionTest
{
//Theoretical limit momemt Mx = 43kN*m
[TestCase(0.000113, 0.000494, 10e3, 0d, 0d, 0.00084665917358052976d, 0.0d, 0.00020754144937701132d)]
[TestCase(0.000113, 0.000494, 40e3, 0d, 0d, 0.0033939850380287412d, 0d, 0.00082989880025069202d)]
[TestCase(0.000113, 0.000494, 42e3, 0d, 0d, 0.0056613831873867241d, 0d, 0.0014291081844183839d)]
//Theoretical limit momemt Mx = -187kN*m
[TestCase(0.000113, 0.000494, -50e3, 0d, 0d, -0.0011229555729294297d, 0d, 0.00021353225742956321d)]
[TestCase(0.000113, 0.000494, -180e3, 0d, 0d, -0.0098365950945499738d, 0d, 0.0022035516889170013d)]
[TestCase(0.000113, 0.000494, -183e3, 0d, 0d, -0.021718635290382458d, 0d, 0.0053526701372818789d)]
public void Run_ShouldPass(double topArea, double bottomArea, double mx, double my, double nz, double expectedKx, double expectedKy, double expectedEpsilonZ)
{
//Arrange
double width = 0.4;
double height = 0.6;
var ndmCollection = new List<INdm>();
ndmCollection.AddRange(GetConcreteNdms(width, height));
ndmCollection.AddRange(GetReinforcementNdms(width, height, topArea, bottomArea));
var loaderData = new LoaderOptions
{
Preconditions = new Preconditions
{
ConditionRate = 0.01,
MaxIterationCount = 100,
StartForceMatrix = new ForceMatrix { Mx = mx, My = my, Nz = nz }
},
NdmCollection = ndmCollection
};
var calculator = new Calculator();
//Act
calculator.Run(loaderData, new CancellationToken());
var results = calculator.Result;
//Assert
Assert.NotNull(results);
var strainMatrix = results.StrainMatrix;
Assert.NotNull(strainMatrix);
Assert.AreEqual(expectedKx, strainMatrix.Kx, ExpectedProcessor.GetAccuracyForExpectedValue(expectedKx));
Assert.AreEqual(expectedKy, strainMatrix.Ky, ExpectedProcessor.GetAccuracyForExpectedValue(expectedKy));
Assert.AreEqual(expectedEpsilonZ, strainMatrix.EpsZ, ExpectedProcessor.GetAccuracyForExpectedValue(expectedEpsilonZ));
}
private IEnumerable<INdm> GetConcreteNdms(double width, double height)
{
double strength = 40e6;
ICenter center = new Center() { X = 0, Y = 0 };
IRectangle rectangle = new Rectangle() { Width = width, Height = height, Angle = 0 };
IPrimitiveMaterial material = new PrimitiveMaterial() { MaterialType = MaterialTypes.Concrete, ClassName = "С20", Strength = strength };
ITriangulationOptions options = new TriangulationOptions() { LimiteState = StructureHelperLogics.Infrastructures.CommonEnums.LimitStates.Collapse, CalcTerm = StructureHelperLogics.Infrastructures.CommonEnums.CalcTerms.ShortTerm };
INdmPrimitive primitive = new NdmPrimitive() { Center = center, Shape = rectangle, PrimitiveMaterial = material, NdmMaxSize = 1, NdmMinDivision = 20 };
List<INdmPrimitive> primitives = new List<INdmPrimitive>();
primitives.Add(primitive);
var ndmCollection = Triangulation.GetNdms(primitives, options);
return ndmCollection;
}
private IEnumerable<INdm> GetReinforcementNdms(double width, double height, double topArea, double bottomArea)
{
double gap = 0.05d;
double strength = 4e8;
IShape topReinforcement = new Point() { Area = topArea };
IShape bottomReinforcement = new Point() { Area = bottomArea };
IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial() { MaterialType = MaterialTypes.Reinforcement, ClassName = "S400", Strength = strength };
ITriangulationOptions options = new TriangulationOptions() { LimiteState = StructureHelperLogics.Infrastructures.CommonEnums.LimitStates.Collapse, CalcTerm = StructureHelperLogics.Infrastructures.CommonEnums.CalcTerms.ShortTerm };
IMaterial material = Triangulation.GetMaterial(primitiveMaterial, options);
ICenter centerRT = new Center() { X = width / 2 - gap, Y = height / 2 - gap };
ICenter centerLT = new Center() { X = - (width / 2 - gap), Y = height / 2 - gap };
ICenter centerRB = new Center() { X = width / 2 - gap, Y = - (height / 2 - gap) };
ICenter centerLB = new Center() { X = -(width / 2 - gap), Y = - (height / 2 - gap) };
IPointTriangulationLogicOptions optionsRT = new PointTriangulationLogicOptions(centerRT, topArea);
IPointTriangulationLogicOptions optionsLT = new PointTriangulationLogicOptions(centerLT, topArea);
IPointTriangulationLogicOptions optionsRB = new PointTriangulationLogicOptions(centerRB, bottomArea);
IPointTriangulationLogicOptions optionsLB = new PointTriangulationLogicOptions(centerLB, bottomArea);
var ndmCollection = new List<INdm>();
ndmCollection.AddRange((new PointTriangulationLogic(optionsRT)).GetNdmCollection(material));
ndmCollection.AddRange((new PointTriangulationLogic(optionsLT)).GetNdmCollection(material));
ndmCollection.AddRange((new PointTriangulationLogic(optionsRB)).GetNdmCollection(material));
ndmCollection.AddRange((new PointTriangulationLogic(optionsLB)).GetNdmCollection(material));
return ndmCollection;
}
}
}

View File

@@ -0,0 +1,55 @@
using LoaderCalculator;
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.SourceData;
using LoaderCalculator.Tests.Infrastructures.Logics;
using NUnit.Framework;
using StructureHelperLogics.Data.Shapes;
using StructureHelperLogics.NdmCalculations.Entities;
using StructureHelperLogics.NdmCalculations.Materials;
using StructureHelperLogics.NdmCalculations.Triangulations;
using System.Collections.Generic;
using System.Threading;
namespace StructureHelperTests.FunctionalTests.Ndms.SteelSections
{
public class ReinforcementTest
{
[TestCase(0.3, 0.6, 4e8, 0, 0, 1800000, 0d, 0d, 5e-5d)]
[TestCase(0.3, 0.6, 4e8, 0, 0, -1800000, 0d, 0d, -5e-5d)]
[TestCase(0.3, 0.6, 4e8, 7000000, 0, 0, 0.0065882684745345067d, 0d, 0d)]
[TestCase(0.3, 0.6, 6e8, 10000000, 0, 0, 0.010485801788961743d, 0d, -0.00011114996218404612d)]
public void Run_ShouldPass(double width, double height, double strength, double mx, double my, double nz, double expectedKx, double expectedKy, double expectedEpsilonZ)
{
//Arrange
ICenter center = new Center() { X = 0, Y = 0 };
IRectangle rectangle = new Rectangle() { Width = width, Height = height, Angle = 0 };
IPrimitiveMaterial material = new PrimitiveMaterial() { MaterialType = MaterialTypes.Reinforcement, ClassName = "S400", Strength = strength };
ITriangulationOptions options = new TriangulationOptions() { LimiteState = StructureHelperLogics.Infrastructures.CommonEnums.LimitStates.Collapse, CalcTerm = StructureHelperLogics.Infrastructures.CommonEnums.CalcTerms.ShortTerm };
INdmPrimitive primitive = new NdmPrimitive() { Center = center, Shape = rectangle, PrimitiveMaterial = material, NdmMaxSize = 1, NdmMinDivision = 100 };
List<INdmPrimitive> primitives = new List<INdmPrimitive>();
primitives.Add(primitive);
var ndmCollection = Triangulation.GetNdms(primitives, options);
var loaderData = new LoaderOptions
{
Preconditions = new Preconditions
{
ConditionRate = 0.01,
MaxIterationCount = 100,
StartForceMatrix = new ForceMatrix { Mx = mx, My = my, Nz = nz }
},
NdmCollection = ndmCollection
};
var calculator = new Calculator();
//Act
calculator.Run(loaderData, new CancellationToken());
var results = calculator.Result;
//Assert
Assert.NotNull(results);
var strainMatrix = results.StrainMatrix;
Assert.NotNull(strainMatrix);
Assert.AreEqual(expectedKx, strainMatrix.Kx, ExpectedProcessor.GetAccuracyForExpectedValue(expectedKx));
Assert.AreEqual(expectedKy, strainMatrix.Ky, ExpectedProcessor.GetAccuracyForExpectedValue(expectedKy));
Assert.AreEqual(expectedEpsilonZ, strainMatrix.EpsZ, ExpectedProcessor.GetAccuracyForExpectedValue(expectedEpsilonZ));
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace LoaderCalculator.Tests.Infrastructures.Logics
{
internal static class ExpectedProcessor
{
internal static double GetAccuracyForExpectedValue(double expectedValue, double accuracy = 0.001d)
{
if (expectedValue == 0d) { return 1.0e-15d; }
else return Math.Abs(expectedValue) * accuracy;
}
}
}

View File

@@ -0,0 +1,184 @@
using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Materials.MaterialBuilders;
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.Ndms.Transformations;
using LoaderCalculator.Data.Planes;
using LoaderCalculator.Data.SourceData;
using LoaderCalculator.Infrastructure;
using LoaderCalculator.Tests.Infrastructures.Logics;
using LoaderCalculator.Triangulations;
using Moq;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace LoaderCalculator.Tests.FunctionalTests.SectionTests
{
public class RCSectionTest
{
private IMaterialOptions _reinforcementOptions;
private IMaterialBuilder _reinforcementBuilder;
private IBuilderDirector _reinforcementDirector;
private IMaterialOptions _concreteOptions;
private IMaterialBuilder _concreteBuilder;
private IBuilderDirector _concreteDirector;
[SetUp]
public void Setup()
{
_reinforcementOptions = new ReinforcementOptions();
_reinforcementBuilder = new ReinforcementBuilder(_reinforcementOptions);
_reinforcementDirector = new BuilderDirector(_reinforcementBuilder);
_concreteOptions = new ConcreteOptions();
_concreteBuilder = new ConcreteBuilder(_concreteOptions);
_concreteDirector = new BuilderDirector(_concreteBuilder);
}
//Theoretical limit momemt Mx = 43kN*m
[TestCase(0.000113, 0.000494, 10e3, 0d, 0d, 0.00084665917358052976d, 0.0d, 0.00020754144937701132d)]
[TestCase(0.000113, 0.000494, 40e3, 0d, 0d, 0.0033939850380287412d, 0d, 0.00082989880025069202d)]
[TestCase(0.000113, 0.000494, 42e3, 0d, 0d, 0.0056613831873867241d, 0d, 0.0014291081844183839d)]
//Theoretical limit momemt Mx = -187kN*m
[TestCase(0.000113, 0.000494, -50e3, 0d, 0d, -0.0011229555729294297d, 0d, 0.00021353225742956321d)]
[TestCase(0.000113, 0.000494, -180e3, 0d, 0d, -0.0098365950945499738d, 0d, 0.0022035516889170013d)]
[TestCase(0.000113, 0.000494, -183e3, 0d, 0d, -0.021718635290382458d, 0d, 0.0053526701372818789d)]
public void Run_ShouldPass(double topArea, double bottomArea, double mx, double my, double nz, double expectedKx, double expectedKy, double expectedEpsilonZ)
{
//Arrange
double width = 0.4;
double height = 0.6;
ArrangeMaterial(LimitStates.Collapse, true);
List<INdm> ndmList = new List<INdm>();
ndmList.AddRange(GetConcreteNdms(width, height));
ndmList.AddRange(GetReinforcementNdms(width, height, topArea, bottomArea));
var loaderData = new LoaderOptions
{
Preconditions = new Preconditions
{
ConditionRate = 0.01,
MaxIterationCount = 100,
StartForceMatrix = new ForceMatrix { Mx = mx, My = my, Nz = nz }
},
NdmCollection = ndmList
};
var calculator = new Calculator();
//Act
calculator.Run(loaderData, new CancellationToken());
var results = calculator.Result;
//Assert
Assert.NotNull(results);
var strainMatrix = results.StrainMatrix;
Assert.NotNull(strainMatrix);
Assert.AreEqual(expectedKx, strainMatrix.Kx, ExpectedProcessor.GetAccuracyForExpectedValue(expectedKx));
Assert.AreEqual(expectedKy, strainMatrix.Ky, ExpectedProcessor.GetAccuracyForExpectedValue(expectedKy));
Assert.AreEqual(expectedEpsilonZ, strainMatrix.EpsZ, ExpectedProcessor.GetAccuracyForExpectedValue(expectedEpsilonZ));
}
//Longitudenal prestrain only
[TestCase(0.000494, 0.000494, 0d, 0d, 0d, 0d, 0d, 0d, 0d, 0.0d, 0d)]
[TestCase(0.000494, 0.000494, 0d, 0d, 0d, 0d, 0d, 0.001d, 0d, 0.0d, -4.410e-05d)]
[TestCase(0.000494, 0.000494, 0d, 0d, 0d, 0d, 0d, 0.0015d, 0d, 0.0d, -6.666e-05d)]
[TestCase(0.000494, 0.000494, 0d, 0d, 0d, 0d, 0d, 0.002d, 0d, 0.0d, -8.131e-05d)]
[TestCase(0.000494, 0.000494, 0d, 0d, 0d, 0d, 0d, 0.003d, 0d, 0.0d, -8.131e-05d)]
[TestCase(0.000494, 0.000494, 0d, 0d, 0d, 0d, 0d, -0.001d, 0d, 0.0d, 0.001d)]
[TestCase(0.000494, 0.000494, 0d, 0d, 0d, 0d, 0d, -0.002d, 0d, 0.0d, 0.002d)]
//Curvature prestrain only
[TestCase(0.000494, 0.000494, 0d, 0d, 0d, -1e-5d, 0d, 0d, 5.4638e-6d, 0.0d, 1.069e-06d)]
//Test shows that prestrain and external forces are neglegiate one by another
[TestCase(0.000494, 0.000494, 0d, 0d, 3.952e5d, 0d, 0d, 0.001d, 0d, 0.0d, 0d)]
[TestCase(0.000494, 0.000494, 0d, 0d, 6.873e5d, 0d, 0d, 0.002d, 0d, 0.0d, -1.703e-8d)]
[TestCase(0.000494, 0.000494, 0d, 0d, 6.873e5d, 0d, 0d, 0.003d, 0d, 0.0d, -3.796e-8d)]
public void Run_ShouldPassPrestrain(double topArea, double bottomArea, double mx, double my, double nz, double prestrainKx, double prestrainKy, double prestrainEpsZ, double expectedKx, double expectedKy, double expectedEpsilonZ)
{
//Arrange
double width = 0.4;
double height = 0.6;
ArrangeMaterial(LimitStates.Collapse, true);
List<INdm> ndmList = new List<INdm>();
IStrainMatrix prestrainMatrix = new StrainMatrix() { Kx = prestrainKx, Ky = prestrainKy, EpsZ = prestrainEpsZ };
ndmList.AddRange(GetConcreteNdms(width, height));
var reinforcement = GetReinforcementNdms(width, height, topArea, bottomArea);
NdmTransform.SetPrestrain(reinforcement, prestrainMatrix);
ndmList.AddRange(reinforcement);
var loaderData = new LoaderOptions
{
Preconditions = new Preconditions
{
ConditionRate = 0.001,
MaxIterationCount = 100,
StartForceMatrix = new ForceMatrix { Mx = mx, My = my, Nz = nz }
},
NdmCollection = ndmList
};
var calculator = new Calculator();
//Act
calculator.Run(loaderData, new CancellationToken());
var results = calculator.Result;
//Assert
Assert.NotNull(results);
var strainMatrix = results.StrainMatrix;
Assert.NotNull(strainMatrix);
Assert.AreEqual(expectedKx, strainMatrix.Kx, ExpectedProcessor.GetAccuracyForExpectedValue(expectedKx));
Assert.AreEqual(expectedKy, strainMatrix.Ky, ExpectedProcessor.GetAccuracyForExpectedValue(expectedKy));
Assert.AreEqual(expectedEpsilonZ, strainMatrix.EpsZ, ExpectedProcessor.GetAccuracyForExpectedValue(expectedEpsilonZ));
}
private void ArrangeMaterial(LimitStates limitStates, bool isShortTerm)
{
_reinforcementOptions.InitModulus = 2.0e11;
_reinforcementOptions.LimitState = limitStates;
_reinforcementOptions.IsShortTerm = isShortTerm;
_reinforcementOptions.Strength = 400.0e6;
_concreteOptions.LimitState = limitStates;
_concreteOptions.IsShortTerm = isShortTerm;
_concreteOptions.Strength = 40.0e6;
}
private IEnumerable<INdm> GetConcreteNdms(double width, double heigth)
{
IMaterial _material = _concreteDirector.BuildMaterial();
RectangleTriangulationLogicOptions logicOptions = new RectangleTriangulationLogicOptions(width, heigth, 1, 20);
var logic = Triangulation.GetLogicInstance(logicOptions);
var ndmCollection = logic.GetNdmCollection(new RectangularPlane { Material = _material });
return ndmCollection;
}
private IEnumerable<INdm> GetReinforcementNdms(double width, double heigth, double topArea, double bottomArea)
{
IMaterial _material = _reinforcementDirector.BuildMaterial();
double gap = 0.05;
var ndmCollection = new INdm[]
{
new Ndm
{
Area = topArea,
CenterX = width / 2 - gap,
CenterY = heigth / 2 - gap,
Material = _material
},
new Ndm
{
Area = topArea,
CenterX = -(width / 2 - gap),
CenterY = heigth / 2 - gap,
Material = _material
},
new Ndm
{
Area = bottomArea,
CenterX = width / 2 - gap,
CenterY = -(heigth / 2 - gap),
Material = _material
},
new Ndm
{
Area = bottomArea,
CenterX = -(width / 2 - gap),
CenterY = -(heigth / 2 - gap),
Material = _material
}
};
return ndmCollection;
}
}
}

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" /> <Import Project="..\packages\NUnit3TestAdapter.4.2.1\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.4.2.1\build\net35\NUnit3TestAdapter.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="..\packages\NUnit.3.13.3\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.13.3\build\NUnit.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -39,30 +39,51 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Compile Include="FunctionalTests\Ndms\RCSections\RCSectionTest.cs" />
<HintPath>..\StructureHelper\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath> <Compile Include="FunctionalTests\Ndms\SteelSections\ReinforcementTest.cs" />
</Reference> <Compile Include="Infrastructures\Logics\ExpectedProcessor.cs" />
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Compile Include="LibrariesTests\Ndms\RCSections\RCSectionTest.cs" />
<HintPath>..\StructureHelper\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="TestExampleClass.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UnitTests\Ndms\Triangulations\RectangleTriangulationTest.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Reference Include="Castle.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\packages\Castle.Core.5.0.0\lib\net462\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="LoaderCalculator">
<HintPath>..\Libraries\LoaderCalculator.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Moq, Version=4.18.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.18.1\lib\net462\Moq.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.13.3.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.13.3\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\StructureHelperLogics\StructureHelperLogics.csproj">
<Project>{330bef5b-15be-4d2c-a750-b1ae50fb2be3}</Project>
<Name>StructureHelperLogics</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" /> <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props'))" /> <Error Condition="!Exists('..\packages\NUnit.3.13.3\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.13.3\build\NUnit.props'))" />
<Error Condition="!Exists('..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets'))" /> <Error Condition="!Exists('..\packages\NUnit3TestAdapter.4.2.1\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.4.2.1\build\net35\NUnit3TestAdapter.props'))" />
</Target> </Target>
<Import Project="..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" />
</Project> </Project>

View File

@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StructureHelperTests</RootNamespace>
<AssemblyName>StructureHelperTests</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeCoverage.17.2.0\build\netstandard1.0\Microsoft.CodeCoverage.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeCoverage.17.2.0\build\netstandard1.0\Microsoft.CodeCoverage.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeCoverage.17.2.0\build\netstandard1.0\Microsoft.CodeCoverage.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeCoverage.17.2.0\build\netstandard1.0\Microsoft.CodeCoverage.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.NET.Test.Sdk.17.2.0\build\net45\Microsoft.NET.Test.Sdk.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NET.Test.Sdk.17.2.0\build\net45\Microsoft.NET.Test.Sdk.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NET.Test.Sdk.17.2.0\build\net45\Microsoft.NET.Test.Sdk.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NET.Test.Sdk.17.2.0\build\net45\Microsoft.NET.Test.Sdk.targets'))" />
</Target>
<Import Project="..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\StructureHelper\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" />
<Import Project="..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets')" />
<Import Project="..\packages\Microsoft.CodeCoverage.17.2.0\build\netstandard1.0\Microsoft.CodeCoverage.targets" Condition="Exists('..\packages\Microsoft.CodeCoverage.17.2.0\build\netstandard1.0\Microsoft.CodeCoverage.targets')" />
<Import Project="..\packages\Microsoft.NET.Test.Sdk.17.2.0\build\net45\Microsoft.NET.Test.Sdk.targets" Condition="Exists('..\packages\Microsoft.NET.Test.Sdk.17.2.0\build\net45\Microsoft.NET.Test.Sdk.targets')" />
</Project>

View File

@@ -1,14 +0,0 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace StructureHelperTests
{
[TestClass]
public class TestExampleClass
{
[TestMethod]
public void TestMethod()
{
}
}
}

View File

@@ -0,0 +1,51 @@
using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Materials.MaterialBuilders;
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.Ndms.Transformations;
using LoaderCalculator.Data.Planes;
using LoaderCalculator.Data.SourceData;
using LoaderCalculator.Infrastructure;
using LoaderCalculator.Tests.Infrastructures.Logics;
using LoaderCalculator.Triangulations;
using Moq;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using StructureHelperLogics.NdmCalculations.Triangulations;
using StructureHelperLogics.Data.Shapes;
namespace StructureHelperTests.UnitTests.Ndms.Triangulations
{
public class RectangleTriangulationTest
{
//Участок по центру
[TestCase(0d, 0d, 1.0d, 1.0d, 0d, 0.02d, 1, 50 * 50, -0.49d, -0.49d)]
//Участок со смещением от центра
[TestCase(2d, 2d, 1.0d, 1.0d, 0d, 0.02d, 1, 50 * 50, 1.51d, 1.51d)]
[TestCase(2d, 1d, 1.0d, 1.0d, 0d, 0.02d, 1, 50 * 50, 1.51d, 0.51d)]
//Участок с поворотом на 1 радиан
[TestCase(0d, 0d, 1.0d, 1.0d, 1d, 0.02d, 1, 50 * 50, 0.14757265268048089d, -0.67706891243125777d)]
//Участок со смещением и поворотом на 1 радиан
[TestCase(2d, 2d, 1.0d, 1.0d, 1d, 0.02d, 1, 50 * 50, -0.45476470519903267d, 2.0864776689208147d)]
public void Run_ShouldPass (double centerX, double centerY, double width, double height, double angle, double ndmMaxSize, int ndmMinDivision, int expectedCount, double expectedFirstCenterX, double expectedFirstCenterY)
{
//Arrange
IMaterial material = new Material();
ICenter center = new Center() { X = centerX, Y = centerY };
IRectangle rectangle = new Rectangle() { Width = width, Height = height, Angle = angle };
IRectangleTriangulationLogicOptions options = new StructureHelperLogics.NdmCalculations.Triangulations.RectangleTriangulationLogicOptions(center, rectangle, ndmMaxSize, ndmMinDivision);
IRectangleTriangulationLogic logic = new StructureHelperLogics.NdmCalculations.Triangulations.RectangleTriangulationLogic(options);
//Act
var result = logic.GetNdmCollection(material);
//Assert
Assert.NotNull(result);
Assert.AreEqual(expectedCount, result.Count());
var firstNdm = result.First();
Assert.AreEqual(expectedFirstCenterX, firstNdm.CenterX);
Assert.AreEqual(expectedFirstCenterY, firstNdm.CenterY);
}
}
}

View File

@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="MSTest.TestAdapter" version="2.1.2" targetFramework="net472" /> <package id="Castle.Core" version="5.0.0" targetFramework="net472" />
<package id="MSTest.TestFramework" version="2.1.2" targetFramework="net472" /> <package id="Moq" version="4.18.1" targetFramework="net472" />
<package id="NUnit" version="3.13.3" targetFramework="net472" />
<package id="NUnit3TestAdapter" version="4.2.1" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
</packages> </packages>