From 79a82220c45fc3c56036137363babba5f0007550 Mon Sep 17 00:00:00 2001 From: Nikita Romanenko Date: Sun, 9 Dec 2018 14:07:23 +0300 Subject: [PATCH] Pores proj first commit --- Pores.sln | 25 ++++ Pores/App.config | 6 + Pores/App.xaml | 9 ++ Pores/App.xaml.cs | 17 +++ .../Controllers/ModelGenerationController.cs | 25 ++++ Pores/Interfaces/IPoresLocalization.cs | 10 ++ Pores/MainWindow.xaml | 15 +++ Pores/MainWindow.xaml.cs | 31 +++++ Pores/Models/Coordinate.cs | 16 +++ .../Localizations/NormalLocalization.cs | 58 +++++++++ Pores/Models/Material.cs | 10 ++ Pores/Models/Pore.cs | 8 ++ Pores/Pores.csproj | 108 ++++++++++++++++ Pores/Properties/AssemblyInfo.cs | 55 ++++++++ Pores/Properties/Resources.Designer.cs | 71 +++++++++++ Pores/Properties/Resources.resx | 117 ++++++++++++++++++ Pores/Properties/Settings.Designer.cs | 30 +++++ Pores/Properties/Settings.settings | 7 ++ 18 files changed, 618 insertions(+) create mode 100644 Pores.sln create mode 100644 Pores/App.config create mode 100644 Pores/App.xaml create mode 100644 Pores/App.xaml.cs create mode 100644 Pores/Controllers/ModelGenerationController.cs create mode 100644 Pores/Interfaces/IPoresLocalization.cs create mode 100644 Pores/MainWindow.xaml create mode 100644 Pores/MainWindow.xaml.cs create mode 100644 Pores/Models/Coordinate.cs create mode 100644 Pores/Models/Localizations/NormalLocalization.cs create mode 100644 Pores/Models/Material.cs create mode 100644 Pores/Models/Pore.cs create mode 100644 Pores/Pores.csproj create mode 100644 Pores/Properties/AssemblyInfo.cs create mode 100644 Pores/Properties/Resources.Designer.cs create mode 100644 Pores/Properties/Resources.resx create mode 100644 Pores/Properties/Settings.Designer.cs create mode 100644 Pores/Properties/Settings.settings diff --git a/Pores.sln b/Pores.sln new file mode 100644 index 0000000..a088a47 --- /dev/null +++ b/Pores.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pores", "Pores\Pores.csproj", "{12EAD304-2155-4F18-8373-3EEA60798B8D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {12EAD304-2155-4F18-8373-3EEA60798B8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {12EAD304-2155-4F18-8373-3EEA60798B8D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {12EAD304-2155-4F18-8373-3EEA60798B8D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {12EAD304-2155-4F18-8373-3EEA60798B8D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {740ACE1D-F83D-4181-9888-B3EA705A5E70} + EndGlobalSection +EndGlobal diff --git a/Pores/App.config b/Pores/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/Pores/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Pores/App.xaml b/Pores/App.xaml new file mode 100644 index 0000000..5d7dd87 --- /dev/null +++ b/Pores/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/Pores/App.xaml.cs b/Pores/App.xaml.cs new file mode 100644 index 0000000..f8e65c4 --- /dev/null +++ b/Pores/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace Pores +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/Pores/Controllers/ModelGenerationController.cs b/Pores/Controllers/ModelGenerationController.cs new file mode 100644 index 0000000..700cdd0 --- /dev/null +++ b/Pores/Controllers/ModelGenerationController.cs @@ -0,0 +1,25 @@ +using Pores.Interfaces; +using Pores.Models; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; + +namespace Pores.Controllers +{ + public class ModelGenerationController + { + public IPoreLocalization PoresLocalization { get; set; } + public Material MaterialInstance { get; set; } + public IList PoreCoordinates { get; set; } + + public ModelGenerationController(IPoreLocalization poresLocalization) + { + PoresLocalization = poresLocalization; + } + + public void GeneratePores() + { + PoreCoordinates = PoresLocalization.GetLocalization(); + } + } +} diff --git a/Pores/Interfaces/IPoresLocalization.cs b/Pores/Interfaces/IPoresLocalization.cs new file mode 100644 index 0000000..44b8444 --- /dev/null +++ b/Pores/Interfaces/IPoresLocalization.cs @@ -0,0 +1,10 @@ +using Pores.Models; +using System.Collections.Generic; + +namespace Pores.Interfaces +{ + public interface IPoreLocalization + { + IList GetLocalization(); + } +} diff --git a/Pores/MainWindow.xaml b/Pores/MainWindow.xaml new file mode 100644 index 0000000..d9309e3 --- /dev/null +++ b/Pores/MainWindow.xaml @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/Pores/MainWindow.xaml.cs b/Pores/MainWindow.xaml.cs new file mode 100644 index 0000000..be046b9 --- /dev/null +++ b/Pores/MainWindow.xaml.cs @@ -0,0 +1,31 @@ +using Pores.Controllers; +using Pores.Interfaces; +using Pores.Models; +using Pores.Models.Localizations; +using System.Windows; + +namespace Pores +{ + public partial class MainWindow : Window + { + public MainWindow() + { + + // -> DataContext = ?; + InitializeComponent(); + + Material material = new Material() + { + Height = 10, + Width = 10, + Depth = 10, + }; + + IPoreLocalization localization = new NormalLocalization(material, 100); + + ModelGenerationController genController = + new ModelGenerationController(localization); + genController.GeneratePores(); + } + } +} diff --git a/Pores/Models/Coordinate.cs b/Pores/Models/Coordinate.cs new file mode 100644 index 0000000..c6ad906 --- /dev/null +++ b/Pores/Models/Coordinate.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; + +namespace Pores.Models +{ + public class Coordinate + { + public double X { get; set; } + public double Y { get; set; } + public double Z { get; set; } + + public List ToList() + { + return new List() { X, Y, Z }; + } + } +} diff --git a/Pores/Models/Localizations/NormalLocalization.cs b/Pores/Models/Localizations/NormalLocalization.cs new file mode 100644 index 0000000..fa90551 --- /dev/null +++ b/Pores/Models/Localizations/NormalLocalization.cs @@ -0,0 +1,58 @@ +using System; +using Pores.Interfaces; +using System.Collections.ObjectModel; +using System.Collections.Generic; + +namespace Pores.Models.Localizations +{ + public class NormalLocalization : IPoreLocalization + { + private double mu, sigma; + private double maxR; + private Material Material { get; } + public int NumberOfPores { get; } + + public double GaussFunction (double x, double sigma, double mu) + { + double part1 = 1.0/ (sigma * Math.Sqrt(2 * 3.14)); + double part2 = Math.Exp(-Math.Pow(x - mu, 2) / (2.0 * Math.Pow(sigma, 2))); + return part1 * part2; + } + + public double GaussFunctionByHeight (Coordinate c) + { + return GaussFunction(c.Z, sigma, mu); + } + + public IList GetLocalization() + { + var result = new ObservableCollection(); + for (int i = 0; i <= NumberOfPores; i++) + for (int j = 0; j <= NumberOfPores; j++) + for (int k = 0; k <= NumberOfPores; k++) + { + var r = new Random(); + var c = new Coordinate() + { + X = (double) i / NumberOfPores * Material.Width, + Y = (double) j / NumberOfPores * Material.Depth, + Z = (double) k / NumberOfPores * Material.Height, + }; + var randomDouble = r.NextDouble(); + var gaussResult = GaussFunctionByHeight(c); + if (randomDouble < gaussResult) + result.Add(new Pore() { GetCoordinate = c, Radius = maxR }); + } + return result; + } + + public NormalLocalization(Material material, int numberOfPores) + { + Material = material; + NumberOfPores = numberOfPores; + sigma = 4; + mu = material.Height - material.Height / 4; + maxR = Math.Sqrt((NumberOfPores / Math.Pow(NumberOfPores, 3)) / 3.14); + } + } +} diff --git a/Pores/Models/Material.cs b/Pores/Models/Material.cs new file mode 100644 index 0000000..9164cc3 --- /dev/null +++ b/Pores/Models/Material.cs @@ -0,0 +1,10 @@ +namespace Pores.Models +{ + public class Material + { + public Coordinate GetCoordinate { get; set; } + public double Height { get; set; } + public double Width { get; set; } + public double Depth { get; set; } + } +} diff --git a/Pores/Models/Pore.cs b/Pores/Models/Pore.cs new file mode 100644 index 0000000..ca53dde --- /dev/null +++ b/Pores/Models/Pore.cs @@ -0,0 +1,8 @@ +namespace Pores.Models +{ + public class Pore + { + public Coordinate GetCoordinate { get; set; } + public double Radius { get; set; } + } +} diff --git a/Pores/Pores.csproj b/Pores/Pores.csproj new file mode 100644 index 0000000..b590c75 --- /dev/null +++ b/Pores/Pores.csproj @@ -0,0 +1,108 @@ + + + + + Debug + AnyCPU + {12EAD304-2155-4F18-8373-3EEA60798B8D} + WinExe + Pores + Pores + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + + + + + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + \ No newline at end of file diff --git a/Pores/Properties/AssemblyInfo.cs b/Pores/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..20b2997 --- /dev/null +++ b/Pores/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Pores")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Pores")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Pores/Properties/Resources.Designer.cs b/Pores/Properties/Resources.Designer.cs new file mode 100644 index 0000000..cb05baf --- /dev/null +++ b/Pores/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Pores.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Pores.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Pores/Properties/Resources.resx b/Pores/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Pores/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Pores/Properties/Settings.Designer.cs b/Pores/Properties/Settings.Designer.cs new file mode 100644 index 0000000..cb6249d --- /dev/null +++ b/Pores/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Pores.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Pores/Properties/Settings.settings b/Pores/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/Pores/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file