Добавлены сервисы CalculationService, PrimitiveService, Common-сборка с типами

Необходимо реализовать в дальнейшем GetInnerPoints в PrimitiveService
This commit is contained in:
NickAppLab
2022-07-26 03:53:57 +05:00
parent 47dc9617c3
commit d9cb4fe3b8
41 changed files with 426 additions and 89 deletions

View File

@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup> </startup>
</configuration> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -1,4 +1,7 @@
using System.Windows; using System.Windows;
using Autofac;
using StructureHelper.Services;
using StructureHelper.Windows.MainWindow;
namespace StructureHelper namespace StructureHelper
{ {
@@ -7,5 +10,24 @@ namespace StructureHelper
/// </summary> /// </summary>
public partial class App : Application public partial class App : Application
{ {
public static IContainer Container { get; private set; }
protected override void OnStartup(StartupEventArgs e)
{
var builder = new ContainerBuilder();
builder.RegisterType<PrimitiveRepository>().As<IPrimitiveRepository>();
builder.RegisterType<PrimitiveService>().As<IPrimitiveService>();
builder.RegisterType<MainModel>().AsSelf();
builder.RegisterType<MainViewModel>().AsSelf();
builder.RegisterType<MainView>().AsSelf();
Container = builder.Build();
using (var scope = Container.BeginLifetimeScope())
{
var window = scope.Resolve<MainView>();
window.ShowDialog();
}
}
} }
} }

View File

@@ -1,9 +1,9 @@
using System; using System;
using StructureHelper.Infrastructure.Enums; using StructureHelper.Infrastructure.Enums;
using StructureHelper.Windows.MainWindow; using StructureHelper.Windows.MainWindow;
using StructureHelperLogics.Data.Shapes; using StructureHelperCommon.Models.Entities;
using StructureHelperLogics.NdmCalculations.Entities; using StructureHelperCommon.Models.Materials;
using StructureHelperLogics.NdmCalculations.Materials; using StructureHelperCommon.Models.Shapes;
namespace StructureHelper.Infrastructure.UI.DataContexts namespace StructureHelper.Infrastructure.UI.DataContexts
{ {
@@ -36,10 +36,10 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
double centerY = 0; double centerY = 0;
double area = 0; double area = 0;
string materialName = "s400"; string materialName = "s400";
ICenter center = new Center() { X = centerX, Y = centerY }; ICenter center = new Center { X = centerX, Y = centerY };
IShape shape = new StructureHelperLogics.Data.Shapes.Point() { Area = area }; IShape shape = new StructureHelperCommon.Models.Shapes.Point { Area = area };
IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial() { MaterialType = GetMaterialTypes(), ClassName = materialName, Strength = strength }; ; IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial { MaterialType = GetMaterialTypes(), ClassName = materialName, Strength = strength }; ;
INdmPrimitive ndmPrimitive = new NdmPrimitive() { Center = center, Shape = shape, PrimitiveMaterial = primitiveMaterial }; INdmPrimitive ndmPrimitive = new NdmPrimitive { Center = center, Shape = shape, PrimitiveMaterial = primitiveMaterial };
return ndmPrimitive; return ndmPrimitive;
} }
} }

View File

@@ -4,8 +4,8 @@ using System.Windows.Media;
using StructureHelper.Infrastructure.Enums; using StructureHelper.Infrastructure.Enums;
using StructureHelper.Models.Materials; using StructureHelper.Models.Materials;
using StructureHelper.Windows.MainWindow; using StructureHelper.Windows.MainWindow;
using StructureHelperLogics.NdmCalculations.Entities; using StructureHelperCommon.Models.Entities;
using StructureHelperLogics.NdmCalculations.Materials; using StructureHelperCommon.Models.Materials;
namespace StructureHelper.Infrastructure.UI.DataContexts namespace StructureHelper.Infrastructure.UI.DataContexts
{ {

View File

@@ -1,8 +1,8 @@
using StructureHelper.Infrastructure.Enums; using StructureHelper.Infrastructure.Enums;
using StructureHelper.Windows.MainWindow; using StructureHelper.Windows.MainWindow;
using StructureHelperLogics.Data.Shapes; using StructureHelperCommon.Models.Entities;
using StructureHelperLogics.NdmCalculations.Entities; using StructureHelperCommon.Models.Materials;
using StructureHelperLogics.NdmCalculations.Materials; using StructureHelperCommon.Models.Shapes;
namespace StructureHelper.Infrastructure.UI.DataContexts namespace StructureHelper.Infrastructure.UI.DataContexts
{ {
@@ -25,7 +25,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
ICenter center = new Center() { X = centerX, Y = centerY }; ICenter center = new Center() { X = centerX, Y = centerY };
double height = 0; double height = 0;
double width = 0; double width = 0;
IShape shape = new StructureHelperLogics.Data.Shapes.Rectangle() { Height = height, Width = width, Angle = 0 }; IShape shape = new StructureHelperCommon.Models.Shapes.Rectangle() { Height = height, Width = width, Angle = 0 };
IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial() { MaterialType = GetMaterialTypes(), ClassName = materialName, Strength = strength }; ; IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial() { MaterialType = GetMaterialTypes(), ClassName = materialName, Strength = strength }; ;
INdmPrimitive ndmPrimitive = new NdmPrimitive() { Center = center, Shape = shape, PrimitiveMaterial = primitiveMaterial }; INdmPrimitive ndmPrimitive = new NdmPrimitive() { Center = center, Shape = shape, PrimitiveMaterial = primitiveMaterial };
return ndmPrimitive; return ndmPrimitive;

View File

@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelperCommon.Models.NdmPrimitives;
using StructureHelperCommon.Models.Shapes;
using Point = StructureHelper.Infrastructure.UI.DataContexts.Point;
using Rectangle = StructureHelper.Infrastructure.UI.DataContexts.Rectangle;
namespace StructureHelper.Services
{
public interface IPrimitiveRepository
{
void Add(PrimitiveBase primitive);
void Delete(PrimitiveBase primitive);
IEnumerable<Point> GetPoints();
IEnumerable<Rectangle> GetRectangles();
}
class PrimitiveRepository : IPrimitiveRepository
{
List<Point> points = new List<Point>();
List<Rectangle> rectangles = new List<Rectangle>();
public void Add(PrimitiveBase primitive)
{
switch (primitive)
{
case Point point:
points.Add(point);
break;
case Rectangle rectangle:
rectangles.Add(rectangle);
break;
}
}
public void Delete(PrimitiveBase primitive)
{
switch (primitive)
{
case Point point:
points.Remove(point);
break;
case Rectangle rectangle:
rectangles.Remove(rectangle);
break;
}
}
public IEnumerable<Point> GetPoints() => points;
public IEnumerable<Rectangle> GetRectangles() => rectangles;
}
public class PrimitiveService : IPrimitiveService
{
IPrimitiveRepository primitiveRepository;
public PrimitiveService(IPrimitiveRepository primitiveRepository)
{
this.primitiveRepository = primitiveRepository;
}
public PointPrimitive[] GetInnerPoints(RectanglePrimitive rectanglePrimitive)
{
return new[] { new PointPrimitive(new Center(), new StructureHelperCommon.Models.Shapes.Point()) };
}
}
public interface IPrimitiveService
{
PointPrimitive[] GetInnerPoints(RectanglePrimitive rectanglePrimitive);
}
}

View File

@@ -8,12 +8,13 @@
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<RootNamespace>StructureHelper</RootNamespace> <RootNamespace>StructureHelper</RootNamespace>
<AssemblyName>StructureHelper</AssemblyName> <AssemblyName>StructureHelper</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -35,6 +36,16 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Autofac, Version=6.4.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
<HintPath>packages\Autofac.6.4.0\lib\netstandard2.0\Autofac.dll</HintPath>
</Reference>
<Reference Include="LoaderCalculator, Version=1.5.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Libraries\LoaderCalculator.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Bcl.AsyncInterfaces.1.1.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Expression.Interactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="Microsoft.Expression.Interactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\Microsoft.Expression.Interactions.dll</HintPath> <HintPath>packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\Microsoft.Expression.Interactions.dll</HintPath>
</Reference> </Reference>
@@ -42,7 +53,26 @@
<HintPath>packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Diagnostics.DiagnosticSource.4.7.1\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<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.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\System.Windows.Interactivity.dll</HintPath> <HintPath>packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\System.Windows.Interactivity.dll</HintPath>
@@ -69,6 +99,7 @@
<Compile Include="Infrastructure\UI\UserControls\PrimitivePopup.xaml.cs"> <Compile Include="Infrastructure\UI\UserControls\PrimitivePopup.xaml.cs">
<DependentUpon>PrimitivePopup.xaml</DependentUpon> <DependentUpon>PrimitivePopup.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Services\PrimitiveService.cs" />
<Compile Include="Windows\AddMaterialWindow\AddMaterialView.xaml.cs"> <Compile Include="Windows\AddMaterialWindow\AddMaterialView.xaml.cs">
<DependentUpon>AddMaterialView.xaml</DependentUpon> <DependentUpon>AddMaterialView.xaml</DependentUpon>
</Compile> </Compile>
@@ -158,9 +189,9 @@
<Folder Include="Logics\" /> <Folder Include="Logics\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="StructureHelperLogics\StructureHelperLogics.csproj"> <ProjectReference Include="StructureHelperCommon\StructureHelperCommon.csproj">
<Project>{330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}</Project> <Project>{5dfec3fd-9677-47bb-9e88-eb71828b5913}</Project>
<Name>StructureHelperLogics</Name> <Name>StructureHelperCommon</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 # Visual Studio Version 17
VisualStudioVersion = 16.0.32002.261 VisualStudioVersion = 17.2.32630.192
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
@@ -12,6 +12,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureHelperTests", "Str
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructureHelperLogics", "StructureHelperLogics\StructureHelperLogics.csproj", "{330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructureHelperLogics", "StructureHelperLogics\StructureHelperLogics.csproj", "{330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureHelperCommon", "StructureHelperCommon\StructureHelperCommon.csproj", "{5DFEC3FD-9677-47BB-9E88-EB71828B5913}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -30,6 +32,10 @@ Global
{330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}.Debug|Any CPU.Build.0 = 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.ActiveCfg = Release|Any CPU
{330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}.Release|Any CPU.Build.0 = Release|Any CPU {330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}.Release|Any CPU.Build.0 = Release|Any CPU
{5DFEC3FD-9677-47BB-9E88-EB71828B5913}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5DFEC3FD-9677-47BB-9E88-EB71828B5913}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DFEC3FD-9677-47BB-9E88-EB71828B5913}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5DFEC3FD-9677-47BB-9E88-EB71828B5913}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -1,7 +1,7 @@
using StructureHelperLogics.Data.Shapes; using StructureHelperCommon.Models.Materials;
using StructureHelperLogics.NdmCalculations.Materials; using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.NdmCalculations.Entities namespace StructureHelperCommon.Models.Entities
{ {
public interface INdmPrimitive public interface INdmPrimitive
{ {

View File

@@ -1,7 +1,7 @@
using StructureHelperLogics.Data.Shapes; using StructureHelperCommon.Models.Materials;
using StructureHelperLogics.NdmCalculations.Materials; using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.NdmCalculations.Entities namespace StructureHelperCommon.Models.Entities
{ {
public class NdmPrimitive : INdmPrimitive public class NdmPrimitive : INdmPrimitive
{ {

View File

@@ -1,4 +1,4 @@
namespace StructureHelperLogics.NdmCalculations.Materials namespace StructureHelperCommon.Models.Materials
{ {
public interface IPrimitiveMaterial public interface IPrimitiveMaterial
{ {

View File

@@ -1,4 +1,4 @@
namespace StructureHelperLogics.NdmCalculations.Materials namespace StructureHelperCommon.Models.Materials
{ {
public enum MaterialTypes public enum MaterialTypes
{ {

View File

@@ -1,6 +1,6 @@
using System; using System;
namespace StructureHelperLogics.NdmCalculations.Materials namespace StructureHelperCommon.Models.Materials
{ {
public class PrimitiveMaterial : IPrimitiveMaterial public class PrimitiveMaterial : IPrimitiveMaterial
{ {

View File

@@ -0,0 +1,10 @@
using StructureHelperCommon.Models.Entities;
using StructureHelperCommon.Models.Shapes;
namespace StructureHelperCommon.Models.NdmPrimitives
{
public interface IPrimitive : ICenterShape
{
INdmPrimitive GetNdmPrimitive();
}
}

View File

@@ -1,8 +1,8 @@
using StructureHelperLogics.Data.Shapes; using StructureHelperCommon.Models.Entities;
using StructureHelperLogics.NdmCalculations.Entities; using StructureHelperCommon.Models.Materials;
using StructureHelperLogics.NdmCalculations.Materials; using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.Models.NdmPrimitives namespace StructureHelperCommon.Models.NdmPrimitives
{ {
public class PointPrimitive : PrimitiveBase<IPoint>, IPoint public class PointPrimitive : PrimitiveBase<IPoint>, IPoint
{ {

View File

@@ -1,7 +1,7 @@
using StructureHelperLogics.Data.Shapes; using StructureHelperCommon.Models.Entities;
using StructureHelperLogics.NdmCalculations.Entities; using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.Models.NdmPrimitives namespace StructureHelperCommon.Models.NdmPrimitives
{ {
public abstract class PrimitiveBase<T> : IPrimitive where T : IShape public abstract class PrimitiveBase<T> : IPrimitive where T : IShape
{ {
@@ -11,7 +11,7 @@ namespace StructureHelperLogics.Models.NdmPrimitives
public ICenter Center => _center; public ICenter Center => _center;
public IShape Shape => _shape; public IShape Shape => _shape;
public PrimitiveBase(ICenter center, T shape) protected PrimitiveBase(ICenter center, T shape)
{ {
_center = center; _center = center;
_shape = shape; _shape = shape;

View File

@@ -1,8 +1,8 @@
using StructureHelperLogics.Data.Shapes; using StructureHelperCommon.Models.Entities;
using StructureHelperLogics.NdmCalculations.Entities; using StructureHelperCommon.Models.Materials;
using StructureHelperLogics.NdmCalculations.Materials; using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.Models.NdmPrimitives namespace StructureHelperCommon.Models.NdmPrimitives
{ {
public class RectanglePrimitive : PrimitiveBase<IRectangle>, IRectangle public class RectanglePrimitive : PrimitiveBase<IRectangle>, IRectangle
{ {

View File

@@ -1,4 +1,4 @@
namespace StructureHelperLogics.Data.Shapes namespace StructureHelperCommon.Models.Shapes
{ {
/// <inheritdoc /> /// <inheritdoc />
public class Center : ICenter public class Center : ICenter

View File

@@ -1,4 +1,4 @@
namespace StructureHelperLogics.Data.Shapes namespace StructureHelperCommon.Models.Shapes
{ {
/// <summary> /// <summary>
/// Interface for point of center of some shape /// Interface for point of center of some shape

View File

@@ -1,4 +1,4 @@
namespace StructureHelperLogics.Data.Shapes namespace StructureHelperCommon.Models.Shapes
{ {
public interface ICenterShape public interface ICenterShape
{ {

View File

@@ -1,4 +1,4 @@
namespace StructureHelperLogics.Data.Shapes namespace StructureHelperCommon.Models.Shapes
{ {
public interface ICircle : IShape public interface ICircle : IShape
{ {

View File

@@ -1,4 +1,4 @@
namespace StructureHelperLogics.Data.Shapes namespace StructureHelperCommon.Models.Shapes
{ {
public interface IPoint : IShape public interface IPoint : IShape
{ {

View File

@@ -1,4 +1,4 @@
namespace StructureHelperLogics.Data.Shapes namespace StructureHelperCommon.Models.Shapes
{ {
public interface IRectangle : IShape public interface IRectangle : IShape
{ {

View File

@@ -0,0 +1,6 @@
namespace StructureHelperCommon.Models.Shapes
{
public interface IShape
{
}
}

View File

@@ -1,4 +1,4 @@
namespace StructureHelperLogics.Data.Shapes namespace StructureHelperCommon.Models.Shapes
{ {
public class Point : IPoint public class Point : IPoint
{ {

View File

@@ -1,4 +1,4 @@
namespace StructureHelperLogics.Data.Shapes namespace StructureHelperCommon.Models.Shapes
{ {
/// <inheritdoc /> /// <inheritdoc />
public class Rectangle : IRectangle public class Rectangle : IRectangle

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанные со сборкой.
[assembly: AssemblyTitle("StructureHelperCommon")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StructureHelperCommon")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// COM, задайте атрибуту ComVisible значение TRUE для этого типа.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("5dfec3fd-9677-47bb-9e88-eb71828b5913")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5DFEC3FD-9677-47BB-9E88-EB71828B5913}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StructureHelperCommon</RootNamespace>
<AssemblyName>StructureHelperCommon</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</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>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Models\Entities\INdmPrimitive.cs" />
<Compile Include="Models\Entities\NdmPrimitive.cs" />
<Compile Include="Models\Materials\IPrimitiveMaterial.cs" />
<Compile Include="Models\Materials\MaterialTypes.cs" />
<Compile Include="Models\Materials\PrimitiveMaterial.cs" />
<Compile Include="Models\NdmPrimitives\IPrimitive.cs" />
<Compile Include="Models\NdmPrimitives\PointPrimitive.cs" />
<Compile Include="Models\NdmPrimitives\PrimitiveBase.cs" />
<Compile Include="Models\NdmPrimitives\RectanglePrimitive.cs" />
<Compile Include="Models\Shapes\Center.cs" />
<Compile Include="Models\Shapes\ICenter.cs" />
<Compile Include="Models\Shapes\ICenterShape.cs" />
<Compile Include="Models\Shapes\ICircle.cs" />
<Compile Include="Models\Shapes\IPoint.cs" />
<Compile Include="Models\Shapes\IRectangle.cs" />
<Compile Include="Models\Shapes\IShape.cs" />
<Compile Include="Models\Shapes\Point.cs" />
<Compile Include="Models\Shapes\Rectangle.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -1,6 +0,0 @@
namespace StructureHelperLogics.Data.Shapes
{
public interface IShape
{
}
}

View File

@@ -1,10 +0,0 @@
using StructureHelperLogics.Data.Shapes;
using StructureHelperLogics.NdmCalculations.Entities;
namespace StructureHelperLogics.Models.NdmPrimitives
{
public interface IPrimitive : ICenterShape
{
INdmPrimitive GetNdmPrimitive();
}
}

View File

@@ -1,4 +1,4 @@
using StructureHelperLogics.Data.Shapes; using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.NdmCalculations.Triangulations namespace StructureHelperLogics.NdmCalculations.Triangulations
{ {

View File

@@ -1,4 +1,4 @@
using StructureHelperLogics.Data.Shapes; using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.NdmCalculations.Triangulations namespace StructureHelperLogics.NdmCalculations.Triangulations
{ {

View File

@@ -1,8 +1,8 @@
using LoaderCalculator.Data.Materials; using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Ndms; using LoaderCalculator.Data.Ndms;
using StructureHelperLogics.Data.Shapes;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.NdmCalculations.Triangulations namespace StructureHelperLogics.NdmCalculations.Triangulations
{ {

View File

@@ -1,4 +1,4 @@
using StructureHelperLogics.Data.Shapes; using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.NdmCalculations.Triangulations namespace StructureHelperLogics.NdmCalculations.Triangulations
{ {

View File

@@ -1,6 +1,6 @@
using StructureHelperLogics.Data.Shapes; using System;
using StructureHelperLogics.NdmCalculations.Entities; using StructureHelperCommon.Models.Entities;
using System; using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.NdmCalculations.Triangulations namespace StructureHelperLogics.NdmCalculations.Triangulations
{ {

View File

@@ -3,9 +3,9 @@ using System.Collections.Generic;
using LoaderCalculator.Data.Materials; using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Materials.MaterialBuilders; using LoaderCalculator.Data.Materials.MaterialBuilders;
using LoaderCalculator.Data.Ndms; using LoaderCalculator.Data.Ndms;
using StructureHelperLogics.Data.Shapes; using StructureHelperCommon.Models.Entities;
using StructureHelperLogics.NdmCalculations.Entities; using StructureHelperCommon.Models.Materials;
using StructureHelperLogics.NdmCalculations.Materials; using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.NdmCalculations.Triangulations namespace StructureHelperLogics.NdmCalculations.Triangulations
{ {

View File

@@ -0,0 +1,67 @@
using Autofac;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using LoaderCalculator;
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.SourceData;
using StructureHelper;
using StructureHelper.Services;
using StructureHelperCommon.Models.Entities;
using StructureHelperCommon.Models.NdmPrimitives;
using StructureHelperLogics.NdmCalculations.Triangulations;
using StructureHelperLogics.Infrastructures.CommonEnums;
namespace StructureHelperLogics.Services
{
public class CalculationService
{
public IStrainMatrix GetPrimitiveStrainMatrix(double topArea, double bottomArea, RectanglePrimitive concreteRectangle, double mx, double my, double nz)
{
var ndmPrimitives = new List<INdmPrimitive>();
//Добавляем прямоугольник бетонного сечения
ndmPrimitives.Add(concreteRectangle.GetNdmPrimitive());
using (var scope = App.Container.BeginLifetimeScope())
{
var primitiveService = scope.Resolve<PrimitiveService>();
//Добавляем точки внутри прямоугольника
ndmPrimitives.AddRange(primitiveService.GetInnerPoints(concreteRectangle).Select(x=>x.GetNdmPrimitive()));
}
//Коллекция для хранения элементарных участков
var ndmCollection = new List<INdm>();
//Настройки триангуляции, пока опции могут быть только такие
ITriangulationOptions options = new TriangulationOptions
{
LimiteState = LimitStates.Collapse,
CalcTerm = CalcTerms.ShortTerm
};
//Формируем коллекцию элементарных участков для расчета в библитеке (т.е. выполняем триангуляцию)
ndmCollection.AddRange(Triangulation.GetNdms(ndmPrimitives, options));
var calculator = new Calculator();
var calculationData = new LoaderOptions
{
Preconditions = new Preconditions
{
ConditionRate = 0.01,
MaxIterationCount = 100,
StartForceMatrix = new ForceMatrix
{
Mx = mx,
My = my,
Nz = nz
}
},
NdmCollection = ndmCollection
};
calculator.Run(calculationData, new CancellationToken());
var results = calculator.Result;
return results.StrainMatrix;
}
}
}

View File

@@ -4,6 +4,15 @@
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StructureHelper.csproj" />
<ProjectReference Include="..\StructureHelperCommon\StructureHelperCommon.csproj" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="LoaderCalculator"> <Reference Include="LoaderCalculator">
<HintPath>..\..\StructureHelper\Libraries\LoaderCalculator.dll</HintPath> <HintPath>..\..\StructureHelper\Libraries\LoaderCalculator.dll</HintPath>

View File

@@ -1,13 +1,17 @@
using System.Windows; using System.Windows;
using StructureHelper.Services;
namespace StructureHelper.Windows.MainWindow namespace StructureHelper.Windows.MainWindow
{ {
public partial class MainView : Window public partial class MainView : Window
{ {
public MainView() public IPrimitiveRepository PrimitiveRepository { get; }
public IPrimitiveService PrimitiveService { get; }
public MainView(IPrimitiveRepository primitiveRepository, IPrimitiveService primitiveService, MainViewModel viewModel)
{ {
var model = new MainModel(); PrimitiveRepository = primitiveRepository;
var viewModel = new MainViewModel(model, this); PrimitiveService = primitiveService;
DataContext = viewModel; DataContext = viewModel;
InitializeComponent(); InitializeComponent();
} }

View File

@@ -6,14 +6,16 @@ using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.Extensions; using StructureHelper.Infrastructure.Extensions;
using StructureHelper.Infrastructure.UI.DataContexts; using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.MaterialCatalogWindow; using StructureHelper.MaterialCatalogWindow;
using StructureHelper.Services;
using StructureHelper.Windows.ColorPickerWindow; using StructureHelper.Windows.ColorPickerWindow;
namespace StructureHelper.Windows.MainWindow namespace StructureHelper.Windows.MainWindow
{ {
public class MainViewModel : ViewModelBase public class MainViewModel : ViewModelBase
{ {
private MainModel rectanglesModel; private IPrimitiveService PrimitiveService { get; }
private MainView rectanglesView; private IPrimitiveRepository PrimitiveRepository { get; }
private MainModel Model { get; }
public ObservableCollection<PrimitiveBase> Primitives { get; set; } public ObservableCollection<PrimitiveBase> Primitives { get; set; }
public ICommand AddRectangle { get; } public ICommand AddRectangle { get; }
@@ -178,13 +180,12 @@ namespace StructureHelper.Windows.MainWindow
public ICommand SetPopupCanBeClosedFalse { get; } public ICommand SetPopupCanBeClosedFalse { get; }
private double delta = 0.5; private double delta = 0.5;
public MainViewModel(MainModel model, IPrimitiveService primitiveService, IPrimitiveRepository primitiveRepository)
public MainViewModel() { }
public MainViewModel(MainModel rectanglesModel, MainView rectanglesView)
{ {
this.rectanglesModel = rectanglesModel; PrimitiveService = primitiveService;
this.rectanglesView = rectanglesView; PrimitiveRepository = primitiveRepository;
Model = model;
CanvasWidth = 1500; CanvasWidth = 1500;
CanvasHeight = 1000; CanvasHeight = 1000;
@@ -304,17 +305,21 @@ namespace StructureHelper.Windows.MainWindow
}); });
Primitives = new ObservableCollection<PrimitiveBase>(); Primitives = new ObservableCollection<PrimitiveBase>();
AddRectangle = new RelayCommand(o => AddRectangle = new RelayCommand(o =>
{ {
var rectangle = new Rectangle(60, 40, YX1, XY1, this); var rectangle = new Rectangle(60, 40, YX1, XY1, this);
Primitives.Add(rectangle); Primitives.Add(rectangle);
PrimitivesCount = Primitives.Count; PrimitivesCount = Primitives.Count;
PrimitiveRepository.Add(rectangle);
}); });
AddEllipse = new RelayCommand(o => AddEllipse = new RelayCommand(o =>
{ {
var point = new Point(2000, YX1, XY1, this); var point = new Point(2000, YX1, XY1, this);
Primitives.Add(point); Primitives.Add(point);
PrimitivesCount = Primitives.Count; PrimitivesCount = Primitives.Count;
PrimitiveRepository.Add(point);
}); });
SetPopupCanBeClosedTrue = new RelayCommand(o => SetPopupCanBeClosedTrue = new RelayCommand(o =>
@@ -329,4 +334,4 @@ namespace StructureHelper.Windows.MainWindow
}); });
} }
} }
} }

View File

@@ -1,5 +1,13 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Autofac" version="6.4.0" targetFramework="net472" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="1.1.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net472" /> <package id="Newtonsoft.Json" version="12.0.1" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Diagnostics.DiagnosticSource" version="4.7.1" targetFramework="net472" />
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net472" />
<package id="System.Windows.Interactivity.WPF" version="2.0.20525" targetFramework="net472" /> <package id="System.Windows.Interactivity.WPF" version="2.0.20525" targetFramework="net472" />
</packages> </packages>