Nikita Romanenko
6 years ago
15 changed files with 178 additions and 85 deletions
@ -0,0 +1,53 @@ |
|||||
|
using Autofac; |
||||
|
using Pores.Controllers; |
||||
|
using Pores.Interfaces; |
||||
|
using Pores.Models; |
||||
|
using Pores.Models.Localizations; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Collections.ObjectModel; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Pores |
||||
|
{ |
||||
|
public class Bootstrap |
||||
|
{ |
||||
|
public IContainer CompileContainer() |
||||
|
{ |
||||
|
ContainerBuilder build = new ContainerBuilder(); |
||||
|
|
||||
|
build |
||||
|
.Register(c => new Material()) |
||||
|
.As<Material>() |
||||
|
.SingleInstance(); |
||||
|
|
||||
|
build |
||||
|
.Register(c => new ObservableCollection<IPoreLocalization>() { new NormalLocalization(c.Resolve<Material>()) }) |
||||
|
.As<IEnumerable<IPoreLocalization>>() |
||||
|
.SingleInstance(); |
||||
|
|
||||
|
build |
||||
|
.RegisterType<PoreGenerator>() |
||||
|
.As<IPoreGenerator>() |
||||
|
.SingleInstance(); |
||||
|
|
||||
|
build |
||||
|
.RegisterType<BatchGenerator>() |
||||
|
.AsSelf(); |
||||
|
|
||||
|
build |
||||
|
.RegisterType<PoresToFileSaver>() |
||||
|
.AsSelf(); |
||||
|
|
||||
|
build |
||||
|
.RegisterType<MainWindowViewModel>() |
||||
|
.AsSelf() |
||||
|
.SingleInstance(); |
||||
|
|
||||
|
|
||||
|
return build.Build(); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -1,24 +0,0 @@ |
|||||
using Pores.Helpers; |
|
||||
using Pores.Interfaces; |
|
||||
using Pores.Models; |
|
||||
using System.Collections.Generic; |
|
||||
|
|
||||
namespace Pores.Controllers |
|
||||
{ |
|
||||
public class ModelGenerationController : PropertyChangedClass |
|
||||
{ |
|
||||
public IPoreLocalization PoresLocalization { get; set; } |
|
||||
public Material MaterialInstance { get; set; } |
|
||||
public IList<Pore> PoreCoordinates { get; set; } |
|
||||
|
|
||||
public ModelGenerationController(IPoreLocalization poresLocalization) |
|
||||
{ |
|
||||
PoresLocalization = poresLocalization; |
|
||||
} |
|
||||
|
|
||||
public void GeneratePores() |
|
||||
{ |
|
||||
PoreCoordinates = PoresLocalization.GetLocalization(); |
|
||||
} |
|
||||
} |
|
||||
} |
|
@ -0,0 +1,24 @@ |
|||||
|
using Pores.Helpers; |
||||
|
using Pores.Interfaces; |
||||
|
using Pores.Models; |
||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Pores.Controllers |
||||
|
{ |
||||
|
public class PoreGenerator : PropertyChangedClass, IPoreGenerator |
||||
|
{ |
||||
|
public IPoreLocalization PoresLocalization { get; set; } |
||||
|
public Material CurrentMaterial { get; set; } |
||||
|
public IList<Pore> Pores { get; set; } |
||||
|
|
||||
|
public PoreGenerator(Material currentMaterial) |
||||
|
{ |
||||
|
CurrentMaterial = currentMaterial; |
||||
|
} |
||||
|
|
||||
|
public void Generate(IPoreLocalization localization) |
||||
|
{ |
||||
|
Pores = localization.GetLocalization(); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
using Pores.Models; |
||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Pores.Interfaces |
||||
|
{ |
||||
|
public interface IPoreGenerator |
||||
|
{ |
||||
|
IList<Pore> Pores { get; set; } |
||||
|
void Generate(IPoreLocalization localization); |
||||
|
} |
||||
|
} |
@ -1,56 +1,69 @@ |
|||||
using Pores.Controllers; |
using Pores.Controllers; |
||||
using Pores.Interfaces; |
using Pores.Interfaces; |
||||
using Pores.Models; |
using Pores.Models; |
||||
using Pores.Models.Localizations; |
|
||||
using Pores.Helpers; |
using Pores.Helpers; |
||||
using System.Windows.Input; |
using System.Windows.Input; |
||||
using System.Collections.ObjectModel; |
using System.Collections.Generic; |
||||
|
using System; |
||||
|
|
||||
namespace Pores |
namespace Pores |
||||
{ |
{ |
||||
public class MainWindowViewModel : PropertyChangedClass |
public class MainWindowViewModel : PropertyChangedClass |
||||
{ |
{ |
||||
public Material Material { get; set; } = new Material(); |
public Material CurrentMaterial { get; set; } |
||||
|
public IEnumerable<IPoreLocalization> Localizations { get; set; } |
||||
|
|
||||
public IPoreLocalization SelectedLocalization { get; set; } |
public IPoreLocalization SelectedLocalization { get; set; } |
||||
public ModelGenerationController GenController { get; set; } |
public IPoreGenerator PoreGeneratorInstance { get; set; } |
||||
public ObservableCollection<IPoreLocalization> Localizations { get; set; } |
public BatchGenerator BatchGenerator { get; } |
||||
public PoresToFileSaver saveController = new PoresToFileSaver("output.log"); |
|
||||
|
private PoresToFileSaver PoreSaver; |
||||
|
|
||||
public int NumberOfPores { get; set; } |
public int NumberOfPores { get; set; } |
||||
public ICommand GeneratePoresCommand { get; set; } |
public ICommand GeneratePoresCommand { get; set; } |
||||
public ICommand SaveToFileCommand { get; set; } |
public ICommand SaveToFileCommand { get; set; } |
||||
public ICommand GenAndSaveBatchCommand { get; set; } |
public ICommand GenAndSaveBatchCommand { get; set; } |
||||
|
|
||||
public double BatchWidth { get; set; } |
public BatchPoint BatchPoint { get; set; } = new BatchPoint(); |
||||
public double BatchDepth { get; set; } |
|
||||
public Point3D BatchCenter { get; set; } = new Point3D(); |
|
||||
|
|
||||
public MainWindowViewModel() |
public MainWindowViewModel( |
||||
|
Material material, |
||||
|
IEnumerable<IPoreLocalization> localizations, |
||||
|
IPoreGenerator poreGenerator, |
||||
|
PoresToFileSaver poreSaver, |
||||
|
BatchGenerator batchGenerator) |
||||
{ |
{ |
||||
Localizations = new ObservableCollection<IPoreLocalization> |
CurrentMaterial = material; |
||||
{ |
Localizations = localizations; |
||||
new NormalLocalization(Material), |
PoreGeneratorInstance = poreGenerator; |
||||
}; |
PoreSaver = poreSaver; |
||||
|
BatchGenerator = batchGenerator; |
||||
GeneratePoresCommand = new RelayCommand(StartGeneration, () => SelectedLocalization != null); |
GeneratePoresCommand = new RelayCommand(StartGeneration, () => SelectedLocalization != null); |
||||
SaveToFileCommand = new RelayCommand(Save, () => GenController?.PoreCoordinates?.Count > 0); |
SaveToFileCommand = new RelayCommand(Save, () => PoreGeneratorInstance?.Pores?.Count > 0); |
||||
GenAndSaveBatchCommand = new RelayCommand(CreateBatch, () => GenController?.PoreCoordinates?.Count > 0); |
GenAndSaveBatchCommand = new RelayCommand(CreateBatch, () => PoreGeneratorInstance?.Pores?.Count > 0); |
||||
} |
} |
||||
|
|
||||
public void StartGeneration() |
public void StartGeneration() |
||||
{ |
{ |
||||
GenController = new ModelGenerationController(SelectedLocalization); |
PoreGeneratorInstance.Generate(SelectedLocalization); |
||||
GenController.GeneratePores(); |
|
||||
} |
} |
||||
|
|
||||
public void Save() |
public void Save() |
||||
{ |
{ |
||||
saveController.Save(GenController.PoreCoordinates); |
PoreSaver.FileName = string.Format( |
||||
|
"model_w{0}_d{1}_h{2}_n{3}_{4}.mdl", |
||||
|
CurrentMaterial.Width, |
||||
|
CurrentMaterial.Depth, |
||||
|
CurrentMaterial.Height, |
||||
|
CurrentMaterial.NumberOfPores, |
||||
|
DateTime.Now.ToString("yyyyMMdd_HHmmss")); |
||||
|
|
||||
|
PoreSaver.Save(PoreGeneratorInstance.Pores); |
||||
} |
} |
||||
|
|
||||
public void CreateBatch() |
public void CreateBatch() |
||||
{ |
{ |
||||
var batchGenerator = new BatchGenerator(Material, GenController.PoreCoordinates); |
BatchGenerator.GenerateBatch(BatchPoint, PoreGeneratorInstance.Pores); |
||||
batchGenerator.GenerateBatch(BatchCenter, BatchWidth, BatchDepth); |
|
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
@ -0,0 +1,11 @@ |
|||||
|
using Pores.Helpers; |
||||
|
|
||||
|
namespace Pores.Models |
||||
|
{ |
||||
|
public class BatchPoint : PropertyChangedClass |
||||
|
{ |
||||
|
public Point3D Center { get; set; } = new Point3D(); |
||||
|
public double Width { get; set; } |
||||
|
public double Depth { get; set; } |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue