diff --git a/App.config b/App.config new file mode 100644 index 0000000..ad911fa --- /dev/null +++ b/App.config @@ -0,0 +1,26 @@ + + + + + +
+ +
+ + + + + + + + + + + + + + + diff --git a/App.xaml b/App.xaml new file mode 100644 index 0000000..286dcea --- /dev/null +++ b/App.xaml @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/App.xaml.cs b/App.xaml.cs new file mode 100644 index 0000000..4021309 --- /dev/null +++ b/App.xaml.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace GroundOrganizer +{ + /// + /// Логика взаимодействия для App.xaml + /// + public partial class App : Application + { + //public static ViewModel vm; + //public App() + //{ + // InitializeComponent(); + // vm = new ViewModel(); + //} + } +} + diff --git a/BL/Bore.cs b/BL/Bore.cs new file mode 100644 index 0000000..eb09696 --- /dev/null +++ b/BL/Bore.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GroundOrganizer +{ + [Serializable] + public class Bore + { + /// + /// Порядковый номер скважины + /// + public int Number { get; set; } + /// + /// Имя скважины + /// + public string Name { get; set; } + /// + /// Х-координата распложения скважины + /// + public double X { get; set; } + /// + /// Y-координата распложения скважины + /// + public double Y { get; set; } + /// + /// Абсолютная отметка устья скважины + /// + public double Z { get; set; } + /// + /// Относительная отметка уровня грунтовых вод + /// + public double? WL { get; set; } + /// + /// Превышение глубины сважины в расчетах осадки + /// + public double DZ { get; set; } + /// + /// Массив грунтовых слоев + /// + public ObservableCollection Layers { get; set; } + + public Bore() + { + Layers = new ObservableCollection(); + } + + public void AddLayer(Layer layer) + { + if (Layers == null) Layers = new ObservableCollection(); + Layers.Add(layer); + } + public void AddLayers(ObservableCollection layers) + { + Layers = layers; + } + public void AddLayers(List layers) + { + if (Layers == null) Layers = new ObservableCollection(); + foreach (var item in layers) Layers.Add(item); + } + + public void DeleteLayers() + { + Layers = new ObservableCollection(); + } + + internal string PropsToString() + { + string s = ";"; + return Number + s + Name + s + X + s + Y + s + Z + s + WL + s + DZ; + } + + internal List PropsToList() + { + return new List { Number, Name, X, Y, Z, WL, DZ }; + } + + internal void StringToProps(string line, char separator = ';') + { + string[] src = line.Split(separator); + try + { + Number = Int32.Parse(src[0]); + Name = src[1]; + X = double.Parse(src[2]); + Y = double.Parse(src[3]); + Z = double.Parse(src[4]); + WL = double.Parse(src[5]); + DZ = double.Parse(src[6]); + } + catch + { + return; + } + } + + internal void ListToProps(List src) + { + try + { + Number = (int)(double)src[0]; + Name = (string)src[1]; + X = (double)src[2]; + Y = (double)src[3]; + Z = (double)src[4]; + WL = (double)src[5]; + DZ = (double)src[6]; + } + catch + { + return; + } + } + } +} diff --git a/BL/DataPair.cs b/BL/DataPair.cs new file mode 100644 index 0000000..7f406e2 --- /dev/null +++ b/BL/DataPair.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GroundOrganizer +{ [Serializable] + public struct DataPair + { + public string Описание { get; set; } + public object Параметр { get; set; } + public UnitsForce ForcesUnits { get; set; } + public UnitsStress StressUnits { get; set; } + public UnitsArea AreasUnits { get; set; } + public UnitsLin LenghtsUnits { get; set; } + } + + [Serializable] + public struct DataPairProps + { + public string Описание { get; set; } + public object Параметр { get; set; } + public UnitsList Ед_изм { get; set; } + } +} diff --git a/BL/DataR.cs b/BL/DataR.cs new file mode 100644 index 0000000..3c4f3a3 --- /dev/null +++ b/BL/DataR.cs @@ -0,0 +1,404 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GroundOrganizer +{ + [Serializable] + public struct DataR + { + public string Bore { get; set; } + public string Base { get; set; } + public double R { get; set; } + public double P { get; set; } + public double PmaxX { get; set; } + public double PmaxY { get; set; } + public double GapX { get; set; } + public double GapY { get; set; } + public double CheckP { get; set; } + public double CheckGap { get; set; } + public double YIIu { get; set; } + public double YII { get; set; } + public double FiII { get; set; } + public double CII { get; set; } + public double Yc1 { get; set; } + public double Yc2 { get; set; } + public double My { get; set; } + public double Mq { get; set; } + public double Mc { get; set; } + public double IL { get; set; } + public double Ys { get; set; } + public double Ke { get; set; } + public double Kz { get; set; } + public double K { get; set; } + public double d1 { get; set; } + public double db { get; set; } + public string Ground { get; set; } + public string GroundType { get; set; } + public List FullData { get; private set; } + public List MediumData { get; private set; } + public List SmallData { get; private set; } + + internal void CreateFullData() + { + FullData = new List(); + DataPair dataPair = new DataPair() { Описание = "Фундамент", Параметр = Base }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Скважина", Параметр = Bore }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Расчетное сопротивление", Параметр = R, AreasUnits = UnitsArea.м, ForcesUnits = UnitsForce.т }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Среднее давление под подошвой", Параметр = P, AreasUnits = UnitsArea.м, ForcesUnits = UnitsForce.т }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Максимальное давление под подошвой в направлении длины фундамента", + Параметр = PmaxX, AreasUnits = UnitsArea.м, ForcesUnits = UnitsForce.т }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Максимальное давление под подошвой в направлении ширины фундамента", + Параметр = PmaxY, AreasUnits = UnitsArea.м, ForcesUnits = UnitsForce.т }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффициент использования расчетного сопротивления", Параметр = CheckP }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Отрыв в направлении длины фундамента", Параметр = GapX}; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Отрыв в направлении ширины фундамента", Параметр = GapY}; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Максимальный отрыв подошвы", Параметр = CheckGap }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Глубина заложения", Параметр = d1, LenghtsUnits = UnitsLin.м }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Глубина подвала", Параметр = db, LenghtsUnits = UnitsLin.м }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Грунт под подошвой", Параметр = Ground }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Объемный вес (осредненный) грунта выше подошвы", Параметр = YIIu, + AreasUnits = UnitsArea.м, ForcesUnits = UnitsForce.т }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Объемный вес (осредненный) грунта ниже подошвы", Параметр = YII, + AreasUnits = UnitsArea.м, ForcesUnits = UnitsForce.т }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Угол внутреннего трения грунта основания (осредненный)", Параметр = FiII }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Удельное сцепление грунта основания (осредненное)", Параметр = CII, + AreasUnits = UnitsArea.м, ForcesUnits = UnitsForce.т }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Показатель текучести грунта основания ", Параметр = IL }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффициент пористости грунта основания ", Параметр = Ke }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Тип грунта основания согласно таблице 5.4", Параметр = GroundType }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффицинт Yc1 согласно таблице 5.4", Параметр = Yc1 }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффицинт Yc2 согласно таблице 5.4", Параметр = Yc2 }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффицинт My согласно таблице 5.5", Параметр = My }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффицинт Mq согласно таблице 5.5", Параметр = Mq }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффицинт Mc согласно таблице 5.5", Параметр = Mc }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффицинт Kz", Параметр = Kz }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффицинт K", Параметр = K }; + FullData.Add(dataPair); + + } + internal void CreateMediumData() + { + MediumData = new List(); + DataPair dataPair = new DataPair() { Описание = "Фундамент", Параметр = Base }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Расчетное сопротивление", Параметр = R, AreasUnits = UnitsArea.м, ForcesUnits = UnitsForce.т }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Среднее давление под подошвой", Параметр = P, AreasUnits = UnitsArea.м, ForcesUnits = UnitsForce.т }; + MediumData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Максимальное давление под подошвой в направлении длины фундамента", + Параметр = PmaxX, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + MediumData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Максимальное давление под подошвой в направлении ширины фундамента", + Параметр = PmaxY, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффициент использования расчетного сопротивления", Параметр = CheckP }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Отрыв в направлении длины фундамента", Параметр = GapX }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Отрыв в направлении ширины фундамента", Параметр = GapY }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Максимальный отрыв подошвы", Параметр = CheckGap }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Глубина заложения", Параметр = d1, LenghtsUnits = UnitsLin.м }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Глубина подвала", Параметр = db, LenghtsUnits = UnitsLin.м }; + MediumData.Add(dataPair); + //dataPair = new DataPair() { Descriptions = "Грунт под подошвой", DataEntity = Ground }; + //MediumData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Объемный вес (осредненный) грунта выше подошвы", + Параметр = YIIu, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + MediumData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Объемный вес (осредненный) грунта ниже подошвы", + Параметр = YII, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Угол внутреннего трения грунта основания (осредненный)", Параметр = FiII }; + MediumData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Удельное сцепление грунта основания (осредненное)", + Параметр = CII, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + MediumData.Add(dataPair); + } + internal void CreateSmallData() + { + SmallData = new List(); + DataPair dataPair = new DataPair() { Описание = "Фундамент", Параметр = Base }; + SmallData.Add(dataPair); + dataPair = new DataPair() { Описание = "Расчетное сопротивление", Параметр = R, AreasUnits = UnitsArea.м, ForcesUnits = UnitsForce.т }; + SmallData.Add(dataPair); + dataPair = new DataPair() { Описание = "Среднее давление под подошвой", Параметр = P, AreasUnits = UnitsArea.м, ForcesUnits = UnitsForce.т }; + SmallData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Максимальное давление под подошвой в направлении длины фундамента", + Параметр = PmaxX, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + SmallData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Максимальное давление под подошвой в направлении ширины фундамента", + Параметр = PmaxY, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + SmallData.Add(dataPair); + dataPair = new DataPair() { Описание = "Отрыв в направлении длины фундамента", Параметр = GapX }; + SmallData.Add(dataPair); + dataPair = new DataPair() { Описание = "Отрыв в направлении ширины фундамента", Параметр = GapY }; + SmallData.Add(dataPair); + dataPair = new DataPair() { Описание = "Максимальный отрыв подошвы", Параметр = CheckGap }; + SmallData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффициент использования расчетного сопротивления", Параметр = CheckP }; + SmallData.Add(dataPair); + } + + internal List FullResults() + { + FullData = new List(); + DataPair dataPair = new DataPair() { Описание = "Фундамент", Параметр = Base }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Скважина", Параметр = Bore }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Расчетное сопротивление", Параметр = R, AreasUnits = UnitsArea.м, ForcesUnits = UnitsForce.т }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Среднее давление под подошвой", Параметр = P, AreasUnits = UnitsArea.м, ForcesUnits = UnitsForce.т }; + FullData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Максимальное давление под подошвой в направлении длины фундамента", + Параметр = PmaxX, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + FullData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Максимальное давление под подошвой в направлении ширины фундамента", + Параметр = PmaxY, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Отрыв в направлении длины фундамента", Параметр = GapX }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Отрыв в направлении ширины фундамента", Параметр = GapY }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Максимальный отрыв подошвы", Параметр = CheckGap }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффициент использования расчетного сопротивления", Параметр = CheckP }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Глубина заложения", Параметр = d1, LenghtsUnits = UnitsLin.м }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Глубина подвала", Параметр = db, LenghtsUnits = UnitsLin.м }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Грунт под подошвой", Параметр = Ground }; + FullData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Объемный вес (осредненный) грунта выше подошвы", + Параметр = YIIu, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + FullData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Объемный вес (осредненный) грунта ниже подошвы", + Параметр = YII, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Угол внутреннего трения грунта основания (осредненный)", Параметр = FiII }; + FullData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Удельное сцепление грунта основания (осредненное)", + Параметр = CII, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Показатель текучести грунта основания ", Параметр = IL }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффициент пористости грунта основания ", Параметр = Ke }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Тип грунта основания согласно таблице 5.4", Параметр = GroundType }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффицинт Yc1 согласно таблице 5.4", Параметр = Yc1 }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффицинт Yc2 согласно таблице 5.4", Параметр = Yc2 }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффицинт My согласно таблице 5.5", Параметр = My }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффицинт Mq согласно таблице 5.5", Параметр = Mq }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффицинт Mc согласно таблице 5.5", Параметр = Mc }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффицинт Kz", Параметр = Kz }; + FullData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффицинт K", Параметр = K }; + FullData.Add(dataPair); + + return FullData; + } + internal List MediumResults() + { + MediumData = new List(); + DataPair dataPair = new DataPair() { Описание = "Фундамент", Параметр = Base }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Расчетное сопротивление", Параметр = R, AreasUnits = UnitsArea.м, ForcesUnits = UnitsForce.т }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Среднее давление под подошвой", Параметр = P, AreasUnits = UnitsArea.м, ForcesUnits = UnitsForce.т }; + MediumData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Максимальное давление под подошвой в направлении длины фундамента", + Параметр = PmaxX, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + MediumData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Максимальное давление под подошвой в направлении ширины фундамента", + Параметр = PmaxY, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Отрыв в направлении длины фундамента", Параметр = GapX }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Отрыв в направлении ширины фундамента", Параметр = GapY }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Максимальный отрыв подошвы", Параметр = CheckGap }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффициент использования расчетного сопротивления", Параметр = CheckP }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Глубина заложения", Параметр = d1, LenghtsUnits = UnitsLin.м }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Глубина подвала", Параметр = db, LenghtsUnits = UnitsLin.м }; + MediumData.Add(dataPair); + //dataPair = new DataPair() { Descriptions = "Грунт под подошвой", DataEntity = Ground }; + //MediumData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Объемный вес (осредненный) грунта выше подошвы", + Параметр = YIIu, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + MediumData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Объемный вес (осредненный) грунта ниже подошвы", + Параметр = YII, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + MediumData.Add(dataPair); + dataPair = new DataPair() { Описание = "Угол внутреннего трения грунта основания (осредненный)", Параметр = FiII }; + MediumData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Удельное сцепление грунта основания (осредненное)", + Параметр = CII, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + MediumData.Add(dataPair); + + return MediumData; + } + internal List SmallResults() + { + SmallData = new List(); + DataPair dataPair = new DataPair() { Описание = "Фундамент", Параметр = Base }; + SmallData.Add(dataPair); + dataPair = new DataPair() { Описание = "Расчетное сопротивление", Параметр = R, AreasUnits = UnitsArea.м, ForcesUnits = UnitsForce.т }; + SmallData.Add(dataPair); + dataPair = new DataPair() { Описание = "Среднее давление под подошвой", Параметр = P, AreasUnits = UnitsArea.м, ForcesUnits = UnitsForce.т }; + SmallData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Максимальное давление под подошвой в направлении длины фундамента", + Параметр = PmaxX, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + SmallData.Add(dataPair); + dataPair = new DataPair() + { + Описание = "Максимальное давление под подошвой в направлении ширины фундамента", + Параметр = PmaxY, + AreasUnits = UnitsArea.м, + ForcesUnits = UnitsForce.т + }; + SmallData.Add(dataPair); + dataPair = new DataPair() { Описание = "Отрыв в направлении длины фундамента", Параметр = GapX }; + SmallData.Add(dataPair); + dataPair = new DataPair() { Описание = "Отрыв в направлении ширины фундамента", Параметр = GapY }; + SmallData.Add(dataPair); + dataPair = new DataPair() { Описание = "Максимальный отрыв подошвы", Параметр = CheckGap }; + SmallData.Add(dataPair); + dataPair = new DataPair() { Описание = "Коэффициент использования расчетного сопротивления", Параметр = CheckP }; + SmallData.Add(dataPair); + + return SmallData; + } + } +} diff --git a/BL/DataS.cs b/BL/DataS.cs new file mode 100644 index 0000000..2ab4c29 --- /dev/null +++ b/BL/DataS.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GroundOrganizer +{ + [Serializable] + public struct DataS + { + public string Bore { get; set; } + public string Base { get; set; } + public double Sp { get; set; } + public double Sr { get; set; } + public double p { get; set; } + public double Hc { get; set; } + public double Hmin { get; set; } + public double YIIu { get; set; } + public List Z { get; set; } + public List Alfa { get; set; } + public List sig_zp { get; set; } + public List sig_zy { get; set; } + public List sig_zg { get; set; } + public List E { get; set; } + public List N { get; set; } + } +} diff --git a/BL/Enums.cs b/BL/Enums.cs new file mode 100644 index 0000000..fb1b307 --- /dev/null +++ b/BL/Enums.cs @@ -0,0 +1,18 @@ +namespace GroundOrganizer +{ + public enum TypeFound { Прямоугольный, Ленточный, Круглый } + public enum PointFound { Центр, Угол} + public enum TypeFlexStructure { Гибкая, Жесткая } + public enum ResKey { eps_b_max, eps_b_min, sig_b_max, sig_b_min, eps_bult, eps_s_max, eps_s_min, sig_s_max, sig_s_min, asel, kf, Mxult, Myult, Nult, Mxcrc, Mycrc, num_itr, rep, info } + public enum SecShape { прямоугольник, круг, кольцо, тавр_с_полками_вверху, тавр_с_полками_внизу, двутавр, короб, пользовательское } + public enum ElementType { стержень, пластина } + public enum CharMat { C, CL, N, NL } + public enum LongForces { кратковременное, длительное } + public enum Vlajnost { Ниже_40, От_40_до_75, Выше_75 } + public enum Orientation { вертикальная, горизонтальная } + public enum ClassBet { B10, B15, B20, B25, B30, B35, B40, B45, B50, B55, B60 } + public enum ClassArm { A240, A400, A500, B500, A600, A800, A1000, Bp500, Bp1200 } + public enum TypeDiagramm { трехлинейная, двухлинейная } + public enum TypeLayer { Au, As1, As2, As3, As4, одиночный, радиальный, линейный, AuAs } + public enum ParamsLayer { AsDs, AsNd, DsNd } +} \ No newline at end of file diff --git a/BL/FoundLoad.cs b/BL/FoundLoad.cs new file mode 100644 index 0000000..e5a9361 --- /dev/null +++ b/BL/FoundLoad.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GroundOrganizer +{ + [Serializable] + public class FoundLoad + { + public double NC { get; set; } + public double MxC { get; set; } + public double MyC { get; set; } + public double QyC { get; set; } + public double QxC { get; set; } + + + public double N { get; set; } + public double Mx { get; set; } + public double My { get; set; } + public double Qy { get; set; } + public double Qx { get; set; } + public double q { get; set; } + + public int Number { get; set; } + + public bool InFoot { get; set; } + + public UnitsForce UnitsF { get; set; } + public UnitsLin UnitsL { get; set; } + + internal string PropsToString() + { + string s = ";"; + return Number + s + N + s + Mx + s + My + s + Qx + s + Qy + s + q; + } + + internal List PropsToList() + { + return new List { Number, N, Mx, My, Qx, Qy, q, InFoot }; + } + + internal void StringToProps(string line, char separator = ';') + { + string[] src = line.Split(separator); + try + { + Number = Int32.Parse(src[0]); + N = double.Parse(src[1]); + Mx = double.Parse(src[2]); + My = double.Parse(src[3]); + Qx = double.Parse(src[4]); + Qy = double.Parse(src[5]); + q = double.Parse(src[6]); + } + catch + { + return; + } + } + + internal void ListToProps(List src) + { + try + { + Number = (int)(double)src[0]; + N = (double)src[1]; + Mx = (double)src[2]; + My = (double)src[3]; + Qx = (double)src[4]; + Qy = (double)src[5]; + q = (double)src[6]; + InFoot = (bool)src[7]; + } + catch + { + return; + } + } + } +} diff --git a/BL/Foundation.cs b/BL/Foundation.cs new file mode 100644 index 0000000..1fe6ade --- /dev/null +++ b/BL/Foundation.cs @@ -0,0 +1,920 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Geo; +using TriangleNet; +using TriangleNet.Geometry; +using TriangleNet.Meshing; +using TriangleNet.Tools; + +namespace GroundOrganizer +{ + [Serializable] + public class Foundation + { + public int Number { get; set; } + public string Name { get; set; } + public TypeFound Type { get; set; } + public bool Basement { get; set; } + public double B { get; set; } + public double L { get; set; } + public double Db { get; set; } + public double D1 { get; set; } + public double H { get; set; } + public double AlfaDeg { get; set; } + public double Hs { get; set; } + public double Hcf { get; set; } + public double Ycf { get; set; } + public double X { get; set; } + public double Y { get; set; } + /// + /// Относительная отметка подошвы фундамента + /// + public double FL { get; set; } + /// + /// Абсолютная отметка планировки в центральной точке фундамента + /// + public double DL { get; set; } + /// + /// Абсолютная отметка естественного рельефа в центральной точке фундамента + /// + public double NL { get; set; } + public ObservableCollection Loads { get; set; } + public UnitsForce UnitsF { get; set; } + public UnitsLin UnitsL { get; set; } + public Quadrangle Contour { get; set; } + + public List FullResults { get; private set; } + public List FullProps { get; private set; } + public List MediumResults { get; private set; } + public List MediumProps { get; private set; } + public List SmallResults{ get; private set; } + public List SmallProps{ get; private set; } + + public Foundation() + { + Loads = new ObservableCollection(); + Type = TypeFound.Прямоугольный; + UnitsF = UnitsForce.т; + UnitsL = UnitsLin.м; + Ycf = 2.2; + FullResults = new List(); + MediumResults = new List(); + SmallResults = new List(); + } + + public Foundation(Quadrangle cntr) + { + if (cntr.Units == UnitsLin.см) + { + Contour.Vertex1 = cntr.Vertex1 * 0.01; + Contour.Vertex2 = cntr.Vertex2 * 0.01; + Contour.Vertex3 = cntr.Vertex3 * 0.01; + Contour.Vertex4 = cntr.Vertex4 * 0.01; + } + if (cntr.Units == UnitsLin.мм) + { + Contour.Vertex1 = cntr.Vertex1 * 0.001; + Contour.Vertex2 = cntr.Vertex2 * 0.001; + Contour.Vertex3 = cntr.Vertex3 * 0.001; + Contour.Vertex4 = cntr.Vertex4 * 0.001; + } + if(cntr.Units == UnitsLin.м) Contour = cntr; + + X = Math.Round(Contour.Centroid.X, 3); + Y = Math.Round(Contour.Centroid.Y, 3); + + IOrderedEnumerable selected = from l in Contour.Segments // определяем каждый объект как + orderby l.Length // упорядочиваем по возрастанию + select l; // выбираем объект + + AlfaDeg = Math.Round(RadToDeg(Math.Acos(selected.First().Directive.Vx / selected.First().Length)), 3); + B = Math.Round(selected.First().Length, 3); + L = Math.Round(selected.Last().Length, 3); + + Loads = new ObservableCollection(); + Type = TypeFound.Прямоугольный; + UnitsF = UnitsForce.т; + UnitsL = UnitsLin.м; + Ycf = 2.2; + FullResults = new List(); + MediumResults = new List(); + SmallResults = new List(); + } + + internal void CreateFullPropsList() + { + FullProps = new List(); + DataPairProps dataPair = new DataPairProps() { Описание = "Номер", Параметр = Number }; + FullProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Марка", Параметр = Name }; + FullProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Ширина", Параметр = B, Ед_изм = UnitsList.м }; + FullProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Длина", Параметр = L, Ед_изм = UnitsList.м }; + FullProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Высота", Параметр = H, Ед_изм = UnitsList.м }; + FullProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Отметка подошвы", Параметр = FL, Ед_изм = UnitsList.м }; + FullProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Глубина заложения", Параметр = D1, Ед_изм = UnitsList.м }; + FullProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Отметка планировки", Параметр = DL }; + FullProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Отметка рельефа", Параметр = NL }; + FullProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Наличие подвала", Параметр = Basement }; + FullProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Глубина подвала", Параметр = Db, Ед_изм = UnitsList.м }; + FullProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "h_s", Параметр = Hs, Ед_изм = UnitsList.м }; + FullProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "h_cf", Параметр = Hcf, Ед_изм = UnitsList.м }; + FullProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Ycf, т/м3", Параметр = Ycf }; + FullProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Х", Параметр = X, Ед_изм = UnitsList.м }; + FullProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Y", Параметр = Y, Ед_изм = UnitsList.м }; + FullProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Поворот", Параметр = AlfaDeg, Ед_изм= UnitsList.градус }; + FullProps.Add(dataPair); + + } + + internal void CreateMediumPropsList() + { + MediumProps = new List(); + DataPairProps dataPair = new DataPairProps() { Описание = "Номер", Параметр = Number }; + MediumProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Марка", Параметр = Name }; + MediumProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Ширина", Параметр = B, Ед_изм = UnitsList.м }; + MediumProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Длина", Параметр = L, Ед_изм = UnitsList.м }; + MediumProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Высота", Параметр = H, Ед_изм = UnitsList.м }; + MediumProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Отметка подошвы", Параметр = FL, Ед_изм = UnitsList.м }; + MediumProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Глубина заложения", Параметр = D1, Ед_изм = UnitsList.м }; + MediumProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Отметка планировки", Параметр = DL }; + MediumProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Отметка рельефа", Параметр = NL }; + MediumProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Наличие подвала", Параметр = Basement }; + MediumProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Глубина подвала", Параметр = Db, Ед_изм = UnitsList.м }; + MediumProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "h_s", Параметр = Hs, Ед_изм = UnitsList.м }; + MediumProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "h_cf", Параметр = Hcf, Ед_изм = UnitsList.м }; + MediumProps.Add(dataPair); + } + + internal void CreateSmallPropsList() + { + SmallProps = new List(); + DataPairProps dataPair = new DataPairProps() { Описание = "Номер", Параметр = Number }; + SmallProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Марка", Параметр = Name }; + SmallProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Ширина b", Параметр = B, Ед_изм = UnitsList.м }; + SmallProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Длина l", Параметр = L, Ед_изм = UnitsList.м }; + SmallProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Высота h", Параметр = H, Ед_изм = UnitsList.м }; + SmallProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Отметка подошвы FL", Параметр = FL, Ед_изм = UnitsList.м }; + SmallProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Глубина заложения d_1", Параметр = D1, Ед_изм = UnitsList.м }; + SmallProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Отметка планировки DL", Параметр = DL, Ед_изм = UnitsList.м }; + SmallProps.Add(dataPair); + dataPair = new DataPairProps() { Описание = "Отметка рельефа NL", Параметр = NL, Ед_изм = UnitsList.м }; + SmallProps.Add(dataPair); + } + + public DataS Sp(Bore bore, FoundLoad load, double kHc = 0.5, PointFound ptFond = PointFound.Центр) + { + DataS res = new DataS(); + List downFS = DownFS(bore); + List n = res.N; + n = new List(); + + foreach (Layer item in downFS) + { + n.Add(Math.Ceiling(item.H / (0.4 * B))); + } + + List layers = new List(); + for (int i = 0; i < n.Count; i++) + { + double z = downFS[i].Up; + double dlt = downFS[i].H / n[i]; + while (downFS[i].Down > z) + { + z += dlt; + Layer lay = downFS[i].Clone(); + lay.Down = z; + lay.H = dlt; + lay.Up = z - dlt; + layers.Add(lay); + } + } + + double FL; + if (Basement) FL = Hs + Hcf + Db; + else FL = D1; + + res.Z = new List() { 0 }; + foreach (Layer item in layers) + { + res.Z.Add(item.Up + 0.5 * item.H - FL); + } + + res.Alfa = TablesInterolator.Table_5_8(res.Z, B, L, Type); + + List upF = UpF(bore); + double roh = 0; + double h = 0; + if (upF.Count > 0) + { + foreach (Layer item in upF) + { + roh += item.H * item.IGE.RoII; + h += item.H; + } + } + res.YIIu = Math.Round(roh / h, 3); + + double sig_zg0 = res.YIIu * FL; + double p = load.N / (B * L) + load.q + 2 * FL; + + res.sig_zy = new List(); + res.sig_zp = new List(); + for (int i = 0; i < res.Z.Count; i++) + { + res.sig_zp.Add((double)res.Alfa[i] * p); + res.sig_zy.Add((double)res.Alfa[i] * sig_zg0); + } + + res.sig_zg = new List { sig_zg0 }; + res.E = new List(); + for (int i = 0; i < layers.Count; i++) + { + res.sig_zg.Add(sig_zg0 + layers[i].IGE.RoII * (res.Z[i + 1] - (layers[i].Up - FL))); + sig_zg0 += layers[i].H * layers[i].IGE.RoII; + res.E.Add(layers[i].IGE.E * 101.972); + } + + sig_zg0 = res.YIIu * FL; + + if (B <= 10) res.Hmin = B / 2; + else if (B > 10 && B <= 60) res.Hmin = 4 + 0.1 * B; + else res.Hmin = 10; + + int j = 0; + for (int i = 0; i < layers.Count; i++) + { + if (res.sig_zp[i] >= kHc * res.sig_zg[i]) + { + res.Hc = res.Z[i]; + } + else + { + j = i; + break; + } + } + + int t = 0; double pt = layers[t].H; + while (pt <= res.Hmin) + { + t++; + pt += layers[t].H; + } + + if (res.Hmin > res.Hc) + { + res.Hc = res.Hmin; + j = t; + } + + if (sig_zg0 >= p) + { + for (int i = 0; i <= j; i++) + { + res.Sp += res.sig_zp[i + 1] * layers[i].H / (5 * res.E[i]); + } + res.Sp *= 0.8; + } + else + { + for (int i = 0; i <= j; i++) + { + res.Sp += (res.sig_zp[i + 1] - res.sig_zy[i + 1]) * layers[i].H / res.E[i] + res.sig_zy[i + 1] * layers[i].H / (5 * res.E[i]); + } + res.Sp *= 0.8; + } + + res.Sp = Math.Round(res.Sp * 100, 1); + res.p = Math.Round(p, 2); + + return res; + } + public DataR P(Bore bore, TypeFlexStructure ts, double ls, double hs, double k = 1) + { + DataR dataR = R(bore, ts, ls, hs, k); + dataR.Base = Name; + dataR.Bore = "Скв." + bore.Name; + + if (Loads == null || Loads.Count == 0) + { + FullResults = dataR.FullResults(); + MediumResults = dataR.MediumResults(); + SmallResults = dataR.SmallResults(); + return dataR; + } + List P = new List(Loads.Count); + List PmaxX = new List(Loads.Count); + List PmaxY = new List(Loads.Count); + List chP = new List(Loads.Count); + List GapX = new List(Loads.Count); + List GapY = new List(Loads.Count); + List chGap = new List(Loads.Count); + foreach (FoundLoad item in Loads) + { + P.Add(item.N / (B * L) + item.q + 2 * D1); + double ex = (Math.Abs(item.Mx) / (item.N + 2 * D1 * L * B)) / L; + double wx = (B * L * L * L) / 6; + double pmaxx; + if (ex <= (1.0 / 6)) {pmaxx= item.N / (B * L) + 2 * D1 + Math.Abs(item.Mx) / wx; PmaxX.Add(pmaxx); GapX.Add(0); ex = 0; } + else + { + double C0x = 0.5 * L - item.Mx / (item.N + 2 * D1 * L * B); + pmaxx = 2 * (item.N + 2 * D1 * L * B) / (3 * B * C0x); + PmaxX.Add(pmaxx); + GapX.Add(ex); + } + double ey = (Math.Abs(item.My) / (item.N + 2 * D1 * L * B)) / B; + double wy = (L * B * B * B) / 6; + double pmaxy; + if (ey <= (1.0 / 6)) {pmaxy= item.N / (B * L) + 2 * D1 + Math.Abs(item.My) / wy; PmaxY.Add(pmaxy); GapY.Add(0); ey = 0; } + else + { + double C0y = 0.5 * B - item.My / (item.N + 2 * D1 * L * B); + pmaxy = 2 * (item.N + 2 * D1 * L * B) / (3 * L * C0y); + PmaxY.Add(pmaxy); + GapY.Add(ey); + } + chGap.Add(Math.Max(ex, ey)); + List chp = new List { (item.N / (B * L) + item.q + 2 * D1) / dataR.R, pmaxx / (1.2 * dataR.R), pmaxy / (1.2 * dataR.R) }; + chP.Add(chp.Max()); + } + dataR.P = Math.Round(P.Max(), 3); + dataR.PmaxX = Math.Round(PmaxX.Max(), 3); + dataR.PmaxY = Math.Round(PmaxY.Max(), 3); + dataR.CheckP = Math.Round(chP.Max(), 3); + dataR.CheckGap = Math.Round(chGap.Max(), 3); + dataR.GapX = Math.Round(GapX.Max(), 3); + dataR.GapY = Math.Round(GapY.Max(), 3); + + FullResults = dataR.FullResults(); + MediumResults = dataR.MediumResults(); + SmallResults = dataR.SmallResults(); + + return dataR; + } + public ObservableCollection P(ObservableCollection bores, TypeFlexStructure ts, double ls, double hs, double k = 1) + { + ObservableCollection res = new ObservableCollection(); + foreach (Bore bore in bores) + { + DataR dataR = R(bore, ts, ls, hs, k); + dataR.Base = Name; + dataR.Bore = "Скв." + bore.Name; + + if (Loads == null || Loads.Count == 0) + { + dataR.CreateFullData(); + dataR.CreateMediumData(); + dataR.CreateSmallData(); + res.Add(dataR); + continue; + } + List P = new List(Loads.Count); + List PmaxX = new List(Loads.Count); + List PmaxY = new List(Loads.Count); + List chP = new List(Loads.Count); + List GapX = new List(Loads.Count); + List GapY = new List(Loads.Count); + List chGap = new List(Loads.Count); + foreach (FoundLoad item in Loads) + { + P.Add(item.N / (B * L) + item.q + 2 * D1); + double ex = (item.Mx / (item.N + 2 * D1 * L * B)) / L; + double wx = (B * L * L * L) / 6; + double pmaxx; + if (ex <= 1 / 6) { pmaxx = item.N / (B * L) + 2 * D1 + Math.Abs(item.Mx) / wx; PmaxX.Add(pmaxx); GapX.Add(0); ex = 0; } + else + { + double C0x = 0.5 * L - item.Mx / (item.N + 2 * D1 * L * B); + pmaxx = 2 * (item.N + 2 * D1 * L * B) / (3 * B * C0x); + PmaxX.Add(pmaxx); + GapX.Add(ex); + } + double ey = (item.My / (item.N + 2 * D1 * L * B)) / B; + double wy = (L * B * B * B) / 6; + double pmaxy; + if (ey <= 1 / 6) { pmaxy = item.N / (B * L) + 2 * D1 + Math.Abs(item.My) / wy; PmaxY.Add(pmaxy); GapY.Add(0); ey = 0; } + else + { + double C0y = 0.5 * B - item.My / (item.N + 2 * D1 * L * B); + pmaxy = 2 * (item.N + 2 * D1 * L * B) / (3 * L * C0y); + PmaxY.Add(pmaxy); + GapY.Add(ey); + } + chGap.Add(Math.Max(ex, ey)); + List chp = new List { (item.N / (B * L) + item.q + 2 * D1) / dataR.R, pmaxx / (1.2 * dataR.R), pmaxy / (1.2 * dataR.R) }; + chP.Add(chp.Max()); + } + dataR.P = Math.Round(P.Max(), 3); + dataR.PmaxX = Math.Round(PmaxX.Max(), 3); + dataR.PmaxY = Math.Round(PmaxY.Max(), 3); + dataR.CheckP = Math.Round(chP.Max(), 3); + dataR.CheckGap = Math.Round(chGap.Max(), 3); + dataR.GapX = Math.Round(GapX.Max(), 3); + dataR.GapY = Math.Round(GapY.Max(), 3); + + dataR.CreateFullData(); + dataR.CreateMediumData(); + dataR.CreateSmallData(); + + res.Add(dataR); + } + + return res; + } + private DataR R(Bore bore, TypeFlexStructure ts, double ls, double hs, double k = 1) + { + DataR res = new DataR(); + List upF = UpF(bore); + List downF = DownF(bore); + double roh = 0; + double h = 0; + if (upF.Count > 0) + { + foreach (Layer item in upF) + { + roh += item.H * item.IGE.RoII; + h += item.H; + } + } + res.YIIu = Math.Round(roh / h, 3); + + double fih = 0; + double ch = 0; + roh = 0; + h = 0; + if (downF.Count > 0) + { + foreach (Layer item in downF) + { + fih += item.H * item.IGE.FiII; + ch += item.H * item.IGE.CII * 100; + roh += item.H * item.IGE.RoII; + h += item.H; + } + } + res.YII = Math.Round(roh / h, 3); + res.FiII = Math.Round(fih / h); + res.CII = Math.Round(ch / h, 3); + res.IL = downF[0].IGE.IL; + res.Ke = downF[0].IGE.Ke; + res.Ys = downF[0].IGE.Ys; + res.Ground = "ИГЭ " + downF[0].IGE.NumIGE + " " + downF[0].IGE.Description; + res.GroundType = downF[0].IGE.GroundType; + res.Yc1 = TablesInterolator.Yc1(res.GroundType); + res.Yc2 = TablesInterolator.Yc2(res.GroundType, ts, ls, hs); + double[] MyMqMc = TablesInterolator.My_Mq_Mc(res.FiII); + res.My = MyMqMc[0]; + res.Mq = MyMqMc[1]; + res.Mc = MyMqMc[2]; + res.K = k; + + if (B < 10) res.Kz = 1; + else res.Kz = 8 / B + 0.2; + + if (Basement) res.d1 = Math.Round(Hs + Hcf * (Ycf / res.YIIu), 3); + else res.d1 = D1; + + if (Basement && Db > 2) res.db = 2; + else if (Basement && Db <= 2) res.db = Db; + else res.db = 0; + + res.R = res.Yc1 * res.Yc2 * (res.My * res.Kz * B * res.YII + res.Mq * res.d1 * res.YIIu + (res.Mq - 1) * res.db * res.YIIu + res.Mc * res.CII) / k; + res.R = Math.Round(res.R, 2); + //res.GroundType = ""; + + return res; + } + private List UpF(Bore bore) + { + List res = new List(); + double d; + if (Basement) d = Hs + Hcf + Db; + else d = D1; + + double FL; + FL = d; + + Bore boreW = BoreW(bore); + if (boreW.Layers.Count == 0) return res; + foreach (Layer item in boreW.Layers) + { + if (item.Up > FL) break; + res.Add(item.Clone()); + } + res[res.Count - 1].Down = FL; + res[res.Count - 1].H = res[res.Count - 1].Down - res[res.Count - 1].Up; + + return res; + } + private List DownF(Bore bore) + { + List res = new List(); + double d, z; + if (Basement) d = Hs + Hcf + Db; + else d = D1; + + if (B < 10) z = 0.5 * B; + else z = 4 + 0.1 * B; + + double FL, ZL; + FL = d; + ZL = d + z; + + Bore boreW = BoreW(bore); + if (boreW.Layers.Count == 0) return res; + foreach (Layer item in boreW.Layers) + { + if (item.Down > FL) res.Add(item.Clone()); + if (item.Down >= ZL) break; + } + res[0].Up = FL; + res[0].H = res[0].Down - res[0].Up; + res[res.Count - 1].Down = ZL; + res[res.Count - 1].H = res[res.Count - 1].Down - res[res.Count - 1].Up; + return res; + } + private List UpW(Bore bore) + { + List res = new List(); + foreach (Layer item in bore.Layers) + { + if (item.Up > bore.WL) break; + res.Add(item.Clone()); + } + if (res.Count > 0) + { + res[res.Count - 1].Down = (double)bore.WL; + res[res.Count - 1].H = res[res.Count - 1].Down - res[res.Count - 1].Up; + } + return res; + } + private List DownW(Bore bore) + { + List layers = new List(bore.Layers.Reverse()); + List res = new List(); + foreach (Layer item in layers) + { + if (item.Down <= bore.WL) break; + if (item.IGE.W) item.IGE.RoII = (item.IGE.Ys - 1) / (1 + item.IGE.Ke); + res.Add(item.Clone()); + } + if (res.Count > 0) + { + res.Reverse(); + res[0].Up = (double)bore.WL; + res[0].H = res[0].Down - res[0].Up; + } + return res; + } + private List DownFS(Bore bore) + { + List res = new List(); + double FL; + + if (Basement) FL = Hs + Hcf + Db; + else FL = D1; + + Bore boreW = BoreW(bore); + if (boreW.Layers.Count == 0) return res; + + foreach (Layer item in boreW.Layers.Reverse()) + { + if (item.Down < FL) break; + res.Add(item.Clone()); + } + + if (res.Count > 0) res.Reverse(); + res[0].Up = FL; + res[0].H = res[0].Down - res[0].Up; + + return res; + } + private Bore BoreW(Bore bore) + { + Bore res = new Bore + { + Name = bore.Name, + Number = bore.Number, + WL = bore.WL, + X = bore.X, + Y = bore.Y, + Z = bore.Z + }; + List downW = DownW(bore); + List layers = new List(UpW(bore)); + if (downW.Count > 0) layers.AddRange(downW); + if (layers.Count > 0) + { + res.Layers = new ObservableCollection(layers); + res.Layers[res.Layers.Count - 1].Down = res.Layers[res.Layers.Count - 1].Down + bore.DZ; + res.Layers[res.Layers.Count - 1].H = res.Layers[res.Layers.Count - 1].H + bore.DZ; + res.Layers[res.Layers.Count - 1].Z = res.Layers[res.Layers.Count - 1].Z - bore.DZ; + return res; + } + else + { + bore.Layers[bore.Layers.Count - 1].Down = bore.Layers[bore.Layers.Count - 1].Down + bore.DZ; + bore.Layers[bore.Layers.Count - 1].H = bore.Layers[bore.Layers.Count - 1].H + bore.DZ; + bore.Layers[bore.Layers.Count - 1].Z = bore.Layers[bore.Layers.Count - 1].Z - bore.DZ; + return bore; + } + } + + internal void CalcDL(Structure str) + { + if (str == null || str.RedPlanning == null || str.RedPlanning.Count == 0) return; + + List vrtxs = new List(); + Vertex vrtx; + int i = 1; + foreach (PlanningVertex item in str.RedPlanning) + { + vrtx = new Vertex(item.X, item.Y, item.Number, 2); + vrtx.Attributes[0] = item.Red; + vrtx.Attributes[1] = item.Black; + vrtxs.Add(vrtx); + i++; + } + + Contour cnt = new Contour(vrtxs); + TriangleNet.Geometry.Polygon polygon = new TriangleNet.Geometry.Polygon(); + polygon.Add(cnt); + GenericMesher mesher = new GenericMesher(); + ConstraintOptions constraint = new ConstraintOptions(); + constraint.Convex = true; + Mesh meshPlanning = (Mesh)mesher.Triangulate(polygon, constraint); + TriangleQuadTree meshTree = new TriangleQuadTree(meshPlanning); + TriangleNet.Topology.Triangle trgl = (TriangleNet.Topology.Triangle)meshTree.Query(X, Y); + if (trgl == null) + { + Dictionary valuePairs = new Dictionary(); + Line2d ln; + foreach (Vertex item in meshPlanning.Vertices) + { + ln = new Line2d(new Point2d(X, Y), new Point2d(item.X, item.Y)); + valuePairs.Add(item, ln.Length); + } + IOrderedEnumerable> selected = from v in valuePairs // определяем каждый объект как + orderby v.Value // упорядочиваем по возрастанию + select v; // выбираем объект + List> lst = selected.ToList(); + foreach (TriangleNet.Topology.Triangle item in meshPlanning.Triangles) + { + if (item.Contains(lst[0].Key) && item.Contains(lst[1].Key)) { trgl = item; break; } + } + } + vrtx = new Vertex(X, Y, Number, 2); + Interpolation.InterpolateAttributes(vrtx, trgl, 1); + DL = Math.Round(vrtx.Attributes[0], 3); + } + + internal void CalcDL(Mesh planningMesh) + { + if (planningMesh == null) return; + + Vertex vrtx; + TriangleQuadTree meshTree = new TriangleQuadTree(planningMesh); + TriangleNet.Topology.Triangle trgl = (TriangleNet.Topology.Triangle)meshTree.Query(X, Y); + if (trgl == null) + { + Dictionary valuePairs = new Dictionary(); + Line2d ln; + foreach (Vertex item in planningMesh.Vertices) + { + ln = new Line2d(new Point2d(X, Y), new Point2d(item.X, item.Y)); + valuePairs.Add(item, ln.Length); + } + IOrderedEnumerable> selected = from v in valuePairs // определяем каждый объект как + orderby v.Value // упорядочиваем по возрастанию + select v; // выбираем объект + List> lst = selected.ToList(); + foreach (TriangleNet.Topology.Triangle item in planningMesh.Triangles) + { + if (item.Contains(lst[0].Key) && item.Contains(lst[1].Key)) { trgl = item; break; } + } + } + vrtx = new Vertex(X, Y, Number, 2); + Interpolation.InterpolateAttributes(vrtx, trgl, 1); + DL = Math.Round(vrtx.Attributes[0], 3); + } + + internal void CalcNL(Mesh blackMesh) + { + if (blackMesh == null) return; + + Vertex vrtx; + TriangleQuadTree meshTree = new TriangleQuadTree(blackMesh); + TriangleNet.Topology.Triangle trgl = (TriangleNet.Topology.Triangle)meshTree.Query(X, Y); + if (trgl == null) + { + Dictionary valuePairs = new Dictionary(); + Line2d ln; + foreach (Vertex item in blackMesh.Vertices) + { + ln = new Line2d(new Point2d(X, Y), new Point2d(item.X, item.Y)); + valuePairs.Add(item, ln.Length); + } + IOrderedEnumerable> selected = from v in valuePairs // определяем каждый объект как + orderby v.Value // упорядочиваем по возрастанию + select v; // выбираем объект + List> lst = selected.ToList(); + foreach (TriangleNet.Topology.Triangle item in blackMesh.Triangles) + { + if (item.Contains(lst[0].Key) && item.Contains(lst[1].Key)) { trgl = item; break; } + } + } + vrtx = new Vertex(X, Y, Number, 2); + Interpolation.InterpolateAttributes(vrtx, trgl, 1); + NL = Math.Round(vrtx.Attributes[0], 3); + } + + internal void DLtoD1(double nullLevel) + { + double dlt = nullLevel - DL; + D1 = Math.Round(-FL - dlt, 3); + } + + internal void D1toDL(double nullLevel) + { + DL = Math.Round(nullLevel + FL + D1, 3); + } + + internal void D1toFL(double nullLevel) + { + double dlt = nullLevel - DL; + FL = Math.Round(-dlt - D1, 3); + } + + internal void FLtoD1(double nullLevel) + { + double dlt = nullLevel + FL; + D1 = Math.Round(DL - dlt, 3); + } + + internal string PropsToString() + { + string s = ";"; + return Number + s + Name + s + (int)Type + s + Basement + s + B + s + L + s + H + s + Db + s + D1 + s + Hs + s + Hcf + s + Ycf + s + X + s + Y + s + FL + + s + DL + s + NL + s + AlfaDeg; + } + + internal List PropsToList() + { + return new List { Number, Name, (int)Type, Basement, B, L, H, Db, D1, Hs, Hcf, Ycf, X, Y, FL, DL, NL, AlfaDeg }; + } + + internal void StringToProps(string line, char separator = ';') + { + string[] src = line.Split(separator); + try + { + Number = Int32.Parse(src[0]); + Name = src[1]; + Type = (TypeFound)Int32.Parse(src[2]); + Basement = bool.Parse(src[3]); + B = double.Parse(src[4]); + L = double.Parse(src[5]); + H = double.Parse(src[6]); + Db = double.Parse(src[7]); + D1 = double.Parse(src[8]); + Hs = double.Parse(src[9]); + Hcf = double.Parse(src[10]); + Ycf = double.Parse(src[11]); + X = double.Parse(src[12]); + Y = double.Parse(src[13]); + FL = double.Parse(src[14]); + DL = double.Parse(src[15]); + NL = double.Parse(src[16]); + AlfaDeg = double.Parse(src[17]); + } + catch + { + return; + } + } + + internal void ListToProps(List src) + { + try + { + Number = (int)(double)src[0]; + Name = (string)src[1]; + Type = (TypeFound)(int)(double)src[2]; + Basement = (bool)src[3]; + B = (double)src[4]; + L = (double)src[5]; + H = (double)src[6]; + Db = (double)src[7]; + D1 = (double)src[8]; + Hs = (double)src[9]; + Hcf = (double)src[10]; + Ycf = (double)src[11]; + X = (double)src[12]; + Y = (double)src[13]; + FL = (double)src[14]; + DL = (double)src[15]; + NL = (double)src[16]; + AlfaDeg = (double)src[17]; + } + catch + { + return; + } + } + + internal void CalcLevels(Mesh planningMesh, Mesh blackMesh) + { + CalcDL(planningMesh); + CalcNL(blackMesh); + } + + public void CopyProps(IEnumerable founds) + { + foreach (Foundation item in founds) + { + if (this.Equals(item)) continue; + item.Name = Name; + item.B = B; + item.L = L; + item.H = H; + item.FL = FL; + item.DL = DL; + item.D1 = D1; + item.Loads = Loads; + } + } + + internal void CalcContour() + { + if (Type == TypeFound.Круглый) return; + Point2d v1 = new Point2d(-0.5 * B, -0.5 * L); + Point2d v2 = new Point2d(-0.5 * B, 0.5 * L); + Point2d v3 = new Point2d(0.5 * B, 0.5 * L); + Point2d v4 = new Point2d(0.5 * B, -0.5 * L); + double alfa = DegToRad(AlfaDeg); + double x = v1.X; double y = v1.Y; + v1.X = x * Math.Cos(alfa) - y * Math.Sin(alfa) + X; + v1.Y = x * Math.Sin(alfa) + y * Math.Cos(alfa) + Y; + x = v2.X; y = v2.Y; + v2.X = x * Math.Cos(alfa) - y * Math.Sin(alfa) + X; + v2.Y = x * Math.Sin(alfa) + y * Math.Cos(alfa) + Y; + x = v3.X; y = v3.Y; + v3.X = x * Math.Cos(alfa) - y * Math.Sin(alfa) + X; + v3.Y = x * Math.Sin(alfa) + y * Math.Cos(alfa) + Y; + x = v4.X; y = v4.Y; + v4.X = x * Math.Cos(alfa) - y * Math.Sin(alfa) + X; + v4.Y = x * Math.Sin(alfa) + y * Math.Cos(alfa) + Y; + + Contour = new Quadrangle(v1, v2, v3, v4); + } + + private double RadToDeg(double radians) + { + return radians * 180 / Math.PI; + } + + private double DegToRad(double degries) + { + return degries * Math.PI / 180; + } + } +} diff --git a/BL/IGE.cs b/BL/IGE.cs new file mode 100644 index 0000000..89f33ec --- /dev/null +++ b/BL/IGE.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GroundOrganizer +{ + [Serializable] + public class IGE + { + private string groundType; + public int Number { get; set; } + /// + /// Номер иженерно-геологического элемента + /// + public string NumIGE { get; set; } + /// + /// Тип грунта согласно таблицы 5.4 СП 22.13330.2011 + /// + public string GroundType { get => groundType; set { groundType = value; ChangeTypeGroundIdx(); } } + /// + /// Плотность грунта для расчетов по 2-й группе предельных сосотояний + /// + public double RoII { get; set; } + /// + /// Угол внутреннего трения грунта в градусах для расчетов по 2-й группе предельных сосотояний + /// + public double FiII { get; set; } + /// + /// Удельное сцепление для расчетов по 2-й группе предельных сосотояний + /// + public double CII { get; set; } + /// + /// Модуль деформации грунта + /// + public double E { get; set; } + /// + /// Удельный вес частиц (минеральной части) грунта + /// + public double Ys { get; set; } + /// + /// Коэффициент пористости + /// + public double Ke { get; set; } + /// + ///Показатель текучести + /// + public double IL { get; set; } + /// + /// Наличие водонасыщения + /// + public bool W { get; set; } + /// + /// Описание слоя грунта + /// + public string Description { get; set; } + + public int GroundTypeIdx { get; private set; } + + /// + /// Типы грунтов согласно таблицы 5.4 СП 22.13330.2011 + /// + private readonly string[] groundTypes = new string[] + { + "Крупнообломочные с песчаным заполнителем и пески кроме мелких и пылеватых", + "Пески мелкие", + "Пески пылеватые маловлажные", + "Пески пылеватые влажные насыщенные водой", + "Пески рыхлые", + "Глинистые, а также крупнообломочные с глинистым заполнителем при IL<=0.25", + "Глинистые, а также крупнообломочные с глинистым заполнителем при 0.25 PropsToList() + { + return new List { Number, NumIGE, Description, RoII, FiII, CII, E, Ys, Ke, IL, W, GroundType, GroundTypeIdx }; + } + + internal void StringToProps(string line, char separator = ';') + { + string[] src = line.Split(separator); + try + { + Number = Int32.Parse(src[0]); + NumIGE = src[1]; + Description = src[2]; + RoII = double.Parse(src[3]); + FiII = double.Parse(src[4]); + CII = double.Parse(src[5]); + E = double.Parse(src[6]); + Ys = double.Parse(src[7]); + Ke = double.Parse(src[8]); + IL = double.Parse(src[9]); + W = bool.Parse(src[10]); + GroundType = src[11]; + } + catch + { + return; + } + } + internal void ListToProps(List src) + { + try + { + Number = (int)(double)src[0]; + NumIGE = (string)src[1]; + Description = (string)src[2]; + RoII = (double)src[3]; + FiII = (double)src[4]; + CII = (double)src[5]; + E = (double)src[6]; + Ys = (double)src[7]; + Ke = (double)src[8]; + IL = (double)src[9]; + W = (bool)src[10]; + GroundType = (string)src[11]; + } + catch + { + return; + } + } + } +} diff --git a/BL/Layer.cs b/BL/Layer.cs new file mode 100644 index 0000000..d9153d0 --- /dev/null +++ b/BL/Layer.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GroundOrganizer +{ + [Serializable] + public class Layer + { + public int Number { get; set; } + + public string NumIGE { get; set; } + public IGE IGE { get; set; } + /// + ///Относительная отметка верхней границы слоя относительно устья скважины + /// + public double Up { get; set; } + /// + ///Относительная отметка нижней границы слоя относительно устья скважины + /// + public double Down { get; set; } + /// + ///Мощность слоя + /// + public double H { get; set; } + /// + ///Абсолютная отметка подошвы слоя + /// + public double Z { get; set; } + /// + /// Описание слоя грунта + /// + public string Description { get; set; } + + public Layer Clone() + { + return new Layer() + { + Number = this.Number, + NumIGE = this.NumIGE, + IGE = this.IGE, + Up = this.Up, + Down = this.Down, + H = this.H, + Z = this.Z, + Description = this.Description + }; + } + + internal string PropsToString() + { + string s = ";"; + return Number + s + NumIGE + s + Down + s + H + s + Z; + } + + internal List PropsToList() + { + return new List { Number, NumIGE, Down, H, Z }; + } + + internal void StringToProps(string line, char separator = ';') + { + string[] src = line.Split(separator); + try + { + Number = Int32.Parse(src[0]); + NumIGE = src[1]; + Down = double.Parse(src[2]); + H = double.Parse(src[3]); + Z = double.Parse(src[4]); + } + catch + { + return; + } + } + + internal void ListToProps(List src) + { + try + { + Number = (int)(double)src[0]; + NumIGE = (string)src[1]; + Down = (double)src[2]; + H = (double)src[3]; + Z = (double)src[4]; + } + catch + { + return; + } + } + } +} diff --git a/BL/PlanningVertex.cs b/BL/PlanningVertex.cs new file mode 100644 index 0000000..4de151b --- /dev/null +++ b/BL/PlanningVertex.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GroundOrganizer +{ + [Serializable] + public class PlanningVertex : Geo.Point3d + { + public int Number { get; set; } + public double Red { get; set; } + public double Black { get; set; } + + internal string PropsToString() + { + string s = ";"; + return Number + s + X + s + Y + s + Red + s + Black; + } + + internal void StringToProps(string line, char separator = ';') + { + string[] src = line.Split(separator); + try + { + Number = Int32.Parse(src[0]); + X = double.Parse(src[1]); + Y = double.Parse(src[2]); + Red = double.Parse(src[3]); + Black = double.Parse(src[4]); + } + catch + { + return; + } + } + } +} diff --git a/BL/PlayGround.cs b/BL/PlayGround.cs new file mode 100644 index 0000000..4c0888a --- /dev/null +++ b/BL/PlayGround.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GroundOrganizer +{ + [Serializable] + public class PlayGround + { + public string Description { get; set; } + public int Number { get; set; } + public string Name { get; set; } + public ObservableCollection IGEs { get; private set; } + public ObservableCollection Bores { get; private set; } + public ObservableCollection Structures { get; private set; } + + public PlayGround() + { + IGEs = new ObservableCollection(); + Bores = new ObservableCollection(); + Structures = new ObservableCollection(); + } + + public void AddIGE(IGE ige) + { + if (IGEs == null) IGEs = new ObservableCollection(); + IGEs.Add(ige); + } + public void AddIGEs(ObservableCollection iges) + { + IGEs = iges; + } + public void AddIGEs(List iges) + { + if (IGEs == null) IGEs = new ObservableCollection(); + foreach (var item in iges) IGEs.Add(item); + } + + public void AddBore(Bore bore) + { + if (Bores == null) Bores = new ObservableCollection(); + Bores.Add(bore); + } + public void AddBores(ObservableCollection bores) + { + Bores = bores; + } + public void AddBores(List bores) + { + if (Bores == null) Bores = new ObservableCollection(); + foreach (var item in bores) Bores.Add(item); + } + + public void DeleteBores() + { + Bores = new ObservableCollection(); + } + + public void DeleteIGEs() + { + IGEs = new ObservableCollection(); + } + + + } +} diff --git a/BL/Structure.cs b/BL/Structure.cs new file mode 100644 index 0000000..7437423 --- /dev/null +++ b/BL/Structure.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GroundOrganizer +{ + [Serializable] + public class Structure + { + public TypeFlexStructure flexStructure { get; set; } + public double L { get; set; } + public double H { get; set; } + public double Null { get; set; } + public int Number { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public ObservableCollection Foundations { get; set; } + public ObservableCollection RedPlanning { get; set; } + public ObservableCollection BlackPlanning { get; set; } + public Structure() + { + Foundations = new ObservableCollection(); + RedPlanning = new ObservableCollection(); + BlackPlanning = new ObservableCollection(); + } + } +} diff --git a/BL/TablesInterolator.cs b/BL/TablesInterolator.cs new file mode 100644 index 0000000..882d9bb --- /dev/null +++ b/BL/TablesInterolator.cs @@ -0,0 +1,415 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Geo; + +namespace GroundOrganizer +{ + public struct My_Mq_Mc + { + public double My; + public double Mq; + public double Mc; + Dictionary table_5_5; + + public My_Mq_Mc(double fi) + { + table_5_5 = new Dictionary + { + {0,new double[]{0,1,3.14}}, + {1,new double[]{0.01,1.06,3.23}}, + {2,new double[]{0.03,1.12,3.32}}, + {3,new double[]{0.04,1.18,3.41}}, + {4,new double[]{0.06,1.25,3.51}}, + {5,new double[]{0.08,1.32,3.61}}, + {6,new double[]{0.1,1.39,3.71}}, + {7,new double[]{0.12,1.47,3.82}}, + {8,new double[]{0.14,1.55,3.93}}, + {9,new double[]{0.16,1.64,4.05}}, + {10,new double[]{0.18,1.73,4.17}}, + {11,new double[]{0.21,1.83,4.29}}, + {12,new double[]{0.23,1.94,4.42}}, + {13,new double[]{0.26,2.05,4.55}}, + {14,new double[]{0.29,2.17,4.69}}, + {15,new double[]{0.32,2.3,4.84}}, + {16,new double[]{0.36,2.43,4.99}}, + {17,new double[]{0.39,2.57,5.15}}, + {18,new double[]{0.43,2.73,5.31}}, + {19,new double[]{0.47,2.89,5.48}}, + {20,new double[]{0.51,3.06,5.66}}, + {21,new double[]{0.56,3.24,5.84}}, + {22,new double[]{0.61,3.44,6.04}}, + {23,new double[]{0.66,3.65,6.24}}, + {24,new double[]{0.72,3.87,6.45}}, + {25,new double[]{0.78,4.11,6.67}}, + {26,new double[]{0.84,4.37,6.9}}, + {27,new double[]{0.91,4.64,7.14}}, + {28,new double[]{0.98,4.93,7.4}}, + {29,new double[]{1.06,5.25,7.67}}, + {30,new double[]{1.15,5.59,7.95}}, + {31,new double[]{1.24,5.95,8.24}}, + {32,new double[]{1.34,6.34,8.55}}, + {33,new double[]{1.44,6.76,8.88}}, + {34,new double[]{1.55,7.22,9.22}}, + {35,new double[]{1.68,7.71,9.58}}, + {36,new double[]{1.81,8.24,9.97}}, + {37,new double[]{1.95,8.81,10.37}}, + {38,new double[]{2.11,9.44,10.8}}, + {39,new double[]{2.28,10.11,11.25}}, + {40,new double[]{2.46,10.85,11.73}}, + {41,new double[]{2.66,11.64,12.24}}, + {42,new double[]{2.88,12.51,12.79}}, + {43,new double[]{3.12,13.46,13.37}}, + {44,new double[]{3.38,14.5,13.98}}, + {45,new double[]{3.66,15.64,14.64}} + }; + My= table_5_5[fi][0]; + Mq = table_5_5[fi][1]; + Mc = table_5_5[fi][2]; + } + } + public class TablesInterolator + { + static readonly Dictionary table_5_5 = new Dictionary + { + {0,new double[]{0,1,3.14}}, + {1,new double[]{0.01,1.06,3.23}}, + {2,new double[]{0.03,1.12,3.32}}, + {3,new double[]{0.04,1.18,3.41}}, + {4,new double[]{0.06,1.25,3.51}}, + {5,new double[]{0.08,1.32,3.61}}, + {6,new double[]{0.1,1.39,3.71}}, + {7,new double[]{0.12,1.47,3.82}}, + {8,new double[]{0.14,1.55,3.93}}, + {9,new double[]{0.16,1.64,4.05}}, + {10,new double[]{0.18,1.73,4.17}}, + {11,new double[]{0.21,1.83,4.29}}, + {12,new double[]{0.23,1.94,4.42}}, + {13,new double[]{0.26,2.05,4.55}}, + {14,new double[]{0.29,2.17,4.69}}, + {15,new double[]{0.32,2.3,4.84}}, + {16,new double[]{0.36,2.43,4.99}}, + {17,new double[]{0.39,2.57,5.15}}, + {18,new double[]{0.43,2.73,5.31}}, + {19,new double[]{0.47,2.89,5.48}}, + {20,new double[]{0.51,3.06,5.66}}, + {21,new double[]{0.56,3.24,5.84}}, + {22,new double[]{0.61,3.44,6.04}}, + {23,new double[]{0.66,3.65,6.24}}, + {24,new double[]{0.72,3.87,6.45}}, + {25,new double[]{0.78,4.11,6.67}}, + {26,new double[]{0.84,4.37,6.9}}, + {27,new double[]{0.91,4.64,7.14}}, + {28,new double[]{0.98,4.93,7.4}}, + {29,new double[]{1.06,5.25,7.67}}, + {30,new double[]{1.15,5.59,7.95}}, + {31,new double[]{1.24,5.95,8.24}}, + {32,new double[]{1.34,6.34,8.55}}, + {33,new double[]{1.44,6.76,8.88}}, + {34,new double[]{1.55,7.22,9.22}}, + {35,new double[]{1.68,7.71,9.58}}, + {36,new double[]{1.81,8.24,9.97}}, + {37,new double[]{1.95,8.81,10.37}}, + {38,new double[]{2.11,9.44,10.8}}, + {39,new double[]{2.28,10.11,11.25}}, + {40,new double[]{2.46,10.85,11.73}}, + {41,new double[]{2.66,11.64,12.24}}, + {42,new double[]{2.88,12.51,12.79}}, + {43,new double[]{3.12,13.46,13.37}}, + {44,new double[]{3.38,14.5,13.98}}, + {45,new double[]{3.66,15.64,14.64}} + }; + static readonly Dictionary table_5_4 = new Dictionary + { + {"Крупнообломочные с песчаным заполнителем и пески кроме мелких и пылеватых", new double[]{1.4, 1.2, 1.4} }, + {"Пески мелкие", new double[]{1.3, 1.1, 1.3} }, + {"Пески пылеватые маловлажные", new double[]{1.25, 1.0, 1.2} }, + {"Пески пылеватые влажные насыщенные водой", new double[]{1.1, 1.0, 1.2} }, + {"Пески рыхлые", new double[]{1.0, 1.0, 1.0} }, + {"Глинистые, а также крупнообломочные с глинистым заполнителем при IL<=0.25", new double[]{1.25, 1.0, 1.1} }, + {"Глинистые, а также крупнообломочные с глинистым заполнителем при 0.25 1.5) return interpolant.Interpolation(L / H); + else if (L / H >= 4) return Yc21; + else return Yc22; + } + + public static double? table_5_8(double z, double b, double l, TypeFound typeFound = TypeFound.Прямоугольный, PointFound ptFound = PointFound.Центр) + { + double nu, ksi; + if (ptFound == PointFound.Центр) ksi = 2 * z / b; + else ksi = z / b; + + if (typeFound == TypeFound.Прямоугольный && l / b < 10) + { + nu = l / b; + return BilinearInterpolation(table_5_8_ksi, table_5_8_nu, table_5_8_R, ksi, nu); + } + if (typeFound == TypeFound.Ленточный || l / b >= 10) + { + return LinearInterpolation(table_5_8_ksi, table_5_8_L, ksi); + } + if (typeFound == TypeFound.Круглый) + { + return LinearInterpolation(table_5_8_ksi, table_5_8_C, ksi); + } + + return null; + } + + public static List Table_5_8(List z, double b, double l, TypeFound typeFound = TypeFound.Прямоугольный, PointFound ptFound = PointFound.Центр) + { + List res = new List(); + double nu, ksi; + + foreach (double item in z) + { + if (ptFound == PointFound.Центр) ksi = 2 * item / b; + else ksi = item / b; + + if (typeFound == TypeFound.Прямоугольный && l / b < 10) + { + nu = l / b; + res.Add(BilinearInterpolation(table_5_8_ksi, table_5_8_nu, table_5_8_R, ksi, nu)); + } + if (typeFound == TypeFound.Ленточный || l / b >= 10) + { + res.Add(LinearInterpolation(table_5_8_ksi, table_5_8_L, ksi)); + } + if (typeFound == TypeFound.Круглый) + { + res.Add(LinearInterpolation(table_5_8_ksi, table_5_8_C, ksi)); + } + } + + return res; + } + + static double? LinearInterpolation(double[] x, double[] y, double xval) + { + double? zval = null; + Line2d interpolant; + int lx = x.Length; + int ly = y.Length; + + if (lx < 2 || ly < 2) return zval; + if (lx != ly) return zval; + + for (int i = 0; i < lx - 1; i++) + { + if (xval >= x[i] && xval < x[i + 1]) + { + interpolant = new Line2d(new Point2d(x[i], y[i]), new Point2d(x[i + 1], y[i + 1])); + return interpolant.Interpolation(xval); + } + + if (xval < x[0]) + { + interpolant = new Line2d(new Point2d(x[0], y[0]), new Point2d(x[1], y[1])); + return interpolant.Interpolation(xval); + } + + if (xval >= x[lx - 1]) + { + interpolant = new Line2d(new Point2d(x[lx - 2], y[lx - 2]), new Point2d(x[lx - 1], y[lx - 1])); + return interpolant.Interpolation(xval); + } + } + + return zval; + } + + static double? BilinearInterpolation(double[] x, double[] y, double[,] z, double xval, double yval) + { + //calculates single point bilinear interpolation + double? zval = null; + Plane interpolant; + int lx = x.Length; + int ly = y.Length; + + if (lx < 2 || ly < 2 || z.Length < 4) return zval; + if (lx !=z.GetLength(0)) return zval; + if (ly !=z.GetLength(1)) return zval; + + for (int i = 0; i < lx - 1; i++) + { + for (int j = 0; j < ly - 1; j++) + { + if (xval >= x[i] && xval < x[i + 1] && yval >= y[j] && yval < y[j + 1]) + { + interpolant = new Plane( + new Point3d(x[i], y[j], z[i, j]), + new Point3d(x[i + 1], y[j], z[i + 1, j]), + new Point3d(x[i], y[j + 1], z[i, j + 1]) + ); + return interpolant.Interpolation(xval, yval); + } + + if (xval >= x[lx-1] && yval >= y[j] && yval < y[j + 1]) + { + interpolant = new Plane( + new Point3d(x[lx - 2], y[j], z[lx - 2, j]), + new Point3d(x[lx - 1], y[j], z[lx - 1, j]), + new Point3d(x[lx - 2], y[j + 1], z[lx - 2, j + 1]) + ); + return interpolant.Interpolation(xval, yval); + } + + if (xval < x[0] && yval >= y[j] && yval < y[j + 1]) + { + interpolant = new Plane( + new Point3d(x[0], y[j], z[0, j]), + new Point3d(x[1], y[j], z[1, j]), + new Point3d(x[0], y[j + 1], z[0, j + 1]) + ); + return interpolant.Interpolation(xval, yval); + } + + if (xval >= x[i] && xval < x[i + 1] && yval >= y[ly-1]) + { + interpolant = new Plane( + new Point3d(x[i], y[ly - 2], z[i, ly - 2]), + new Point3d(x[i + 1], y[ly - 2], z[i + 1, ly - 2]), + new Point3d(x[i], y[ly - 1], z[i, ly - 1]) + ); + return interpolant.Interpolation(xval, yval); + } + + if (xval >= x[i] && xval < x[i + 1] && yval < y[0]) + { + interpolant = new Plane( + new Point3d(x[i], y[0], z[i, 0]), + new Point3d(x[i + 1], y[0], z[i + 1, 0]), + new Point3d(x[i], y[1], z[i, 1]) + ); + return interpolant.Interpolation(xval, yval); + } + + if (xval < x[0] && yval < y[0]) + { + interpolant = new Plane( + new Point3d(x[0], y[0], z[0, 0]), + new Point3d(x[1], y[0], z[1, 0]), + new Point3d(x[0], y[1], z[0, 1]) + ); + return interpolant.Interpolation(xval, yval); + } + + if (xval >= x[lx-1] && yval < y[0]) + { + interpolant = new Plane( + new Point3d(x[lx - 2], y[0], z[lx - 2, 0]), + new Point3d(x[lx - 1], y[0], z[lx - 1, 0]), + new Point3d(x[lx - 2], y[1], z[lx - 2, 1]) + ); + return interpolant.Interpolation(xval, yval); + } + + if (xval < x[0] && yval >= y[ly-1]) + { + interpolant = new Plane( + new Point3d(x[0], y[ly - 2], z[0, ly - 2]), + new Point3d(x[0], y[ly - 1], z[0, ly - 1]), + new Point3d(x[1], y[ly - 1], z[1, ly - 1]) + ); + return interpolant.Interpolation(xval, yval); + } + + if (xval >= x[lx-1] && yval >= y[ly - 1]) + { + interpolant = new Plane( + new Point3d(x[lx - 2], y[ly - 2], z[lx - 2, ly - 2]), + new Point3d(x[lx - 1], y[ly - 2], z[lx - 1, ly - 2]), + new Point3d(x[lx - 2], y[ly - 1], z[lx - 2, ly - 1]) + ); + return interpolant.Interpolation(xval, yval); + } + } + } + return zval; + } + + //double[] BilinearInterpolation(double[] x, double[] y, double[,] z, double[] xvals, double[] yvals) + //{ + // //calculates multiple point bilinear interpolation + // double[] zvals = new double[xvals.Length]; + // for (int i = 0; i < xvals.Length; i++) + // zvals[i] = BilinearInterpolation(x, y, z, xvals[i], yvals[i]); + // return zvals; + //} + } +} diff --git a/BL/ToSerializ.cs b/BL/ToSerializ.cs new file mode 100644 index 0000000..63550f5 --- /dev/null +++ b/BL/ToSerializ.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GroundOrganizer +{ + [Serializable] + internal class ToSerializ + { + public ObservableCollection PlayGroundList { get; set; } + } +} diff --git a/Dictionary.xaml b/Dictionary.xaml new file mode 100644 index 0000000..5113408 --- /dev/null +++ b/Dictionary.xaml @@ -0,0 +1,107 @@ + + + + + Крупнообломочные с песчаным заполнителем и пески кроме мелких и пылеватых + Пески мелкие + Пески пылеватые маловлажные + Пески пылеватые влажные насыщенные водой + Пески рыхлые + Глинистые, а также крупнообломочные с глинистым заполнителем при IL<=0.25 + Глинистые, а также крупнообломочные с глинистым заполнителем при 0.25<IL<=0.5 + Глинистые, а также крупнообломочные с глинистым заполнителем при 0.5<IL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Параметры проекта + Площадки + Сечения + Усилия + Арматура + Бетон + Элементы + Трещиностойкость + Расчет + Вывод результатов + + Тип элементов + + + 25 + \ No newline at end of file diff --git a/Geometry/BoundingBox2d.cs b/Geometry/BoundingBox2d.cs new file mode 100644 index 0000000..33f8d04 --- /dev/null +++ b/Geometry/BoundingBox2d.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Geo +{ + [Serializable] + public class BoundingBox2d + { + Point2d min; + Point2d max; + + public Point2d Min { get => min; private set => min = value; } + public Point2d Max { get => max; private set => max = value; } + + public BoundingBox2d() + { + min = new Point2d(); + max = new Point2d(); + } + + public BoundingBox2d(Point2d minPt, Point2d maxPt) + { + min = minPt; + max = maxPt; + } + + } +} diff --git a/Geometry/IVector.cs b/Geometry/IVector.cs new file mode 100644 index 0000000..e46556b --- /dev/null +++ b/Geometry/IVector.cs @@ -0,0 +1,9 @@ +namespace Geo +{ + public interface IVector + { + int N { get; } + + double[] ToArray(); + } +} \ No newline at end of file diff --git a/Geometry/Line2d.cs b/Geometry/Line2d.cs new file mode 100644 index 0000000..0e9da42 --- /dev/null +++ b/Geometry/Line2d.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Geo +{ + [Serializable] + public class Line2d + { + protected Point3d startPoint; + protected Point3d endPoint; + protected Vector2d directive; + protected Vector2d normal; + + public Point3d StartPoint { get => startPoint; set { startPoint = value; if (EndPoint != null) { directive = endPoint.ToPoint2d() - startPoint.ToPoint2d(); CalcLine(); }; } } + public Point3d EndPoint { get => endPoint; set { endPoint = value; directive = endPoint.ToPoint2d() - startPoint.ToPoint2d(); CalcLine(); } } + public Point3d CenterPoint { get; private set; } + public Vector2d Directive { get => directive; private set => directive = value; } + public Vector2d Normal { get => normal; private set => normal = value; } + public double A { get; private set; } + public double B { get; private set; } + public double C { get; private set; } + public double k { get; private set; } + public double b { get; private set; } + public double Length { get => Directive.Norma; } + public double cosAlfa { get; private set; } + public double cosBeta { get; private set; } + public double p { get; private set; } + + public Line2d() + { + + } + + public Line2d(Point2d startPt, Point2d endPt) + { + startPoint = startPt.ToPoint3d(); endPoint = endPt.ToPoint3d(); + directive = endPoint.ToPoint2d() - startPoint.ToPoint2d(); + CalcLine(); + } + + public Line2d(Point3d startPt, Point3d endPt) + { + startPoint = startPt; + endPoint = endPt; + directive = endPoint.ToPoint2d() - startPoint.ToPoint2d(); + CalcLine(); + } + + protected void CalcLine() + { + A = Directive.Vy; + B = -Directive.Vx; + normal = new Vector2d(A, B); + C = Directive.Vx * StartPoint.Y - Directive.Vy * StartPoint.X; + if (Directive.Vx != 0) { k = Directive.Vy / Directive.Vx; } + else { k = Double.PositiveInfinity; } + if (Directive.Vx != 0) { b = -Directive.Vy / Directive.Vx * StartPoint.X + StartPoint.Y; } + else { b= Double.PositiveInfinity; } + double normC = 1 / Math.Sqrt(A * A + B * B); + if (C < 0) normC *= -1; + cosAlfa = A * normC; + cosBeta = B * normC; + p = C * normC; + double dx = 0.5 * (EndPoint.X - StartPoint.X); + double dy = 0.5 * (EndPoint.Y - StartPoint.Y); + CenterPoint = new Point3d(StartPoint.X + dx, StartPoint.Y + dy, 0); + } + + public double LengthTo(Point2d point) + { + double normC = 1 / Math.Sqrt(A * A + B * B); + if (C < 0) normC *= -1; + cosAlfa = A * normC; + cosBeta = B * normC; + p = C * normC; + return normC * (A * point.X + B * point.Y + C); + } + public double LengthTo(Point3d point) + { + double normC = 1 / Math.Sqrt(A * A + B * B); + if (C < 0) normC *= -1; + cosAlfa = A * normC; + cosBeta = B * normC; + p = C * normC; + return normC * (A * point.X + B * point.Y + C); + } + public double Interpolation(double x) + { + if (B == 0) return double.PositiveInfinity; + else return (-A * x - C) / B; + } + } +} diff --git a/Geometry/Line3d.cs b/Geometry/Line3d.cs new file mode 100644 index 0000000..dd5b612 --- /dev/null +++ b/Geometry/Line3d.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Geo +{ + [Serializable] + public class Line3d + { + Point3d startPoint; + Point3d endPoint; + + public Point3d StartPoint { get => startPoint; set { startPoint = value; Directive = endPoint - startPoint; } } + public Point3d EndPoint { get => endPoint; set { endPoint = value; Directive = endPoint - startPoint; } } + public Vector3d Directive { get; private set; } + public double Length { get => Directive.Norma; } + + public Line3d() + { + + } + + public Line3d(Point2d startPt, Point2d endPt) + { + startPoint = startPt.ToPoint3d(); endPoint = endPt.ToPoint3d(); + Directive = endPoint - startPoint; ; + } + + public Line3d(Point3d startPt, Point3d endPt) + { + startPoint = startPt; endPoint = endPt; + Directive = endPoint - startPoint; ; + } + } +} diff --git a/Geometry/Matrix.cs b/Geometry/Matrix.cs new file mode 100644 index 0000000..a5dff6a --- /dev/null +++ b/Geometry/Matrix.cs @@ -0,0 +1,200 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Geo +{ + [Serializable] + public class Matrix + { + double[,] arr; + int m, n; + public int N + { + get + { + if (n > 0) + return n; + else + return -1; + } + } + public int M + { + get + { + if (m > 0) + return m; + else + return -1; + } + } + public double this[int i, int j] + { + get + { + if (n > 0 && m > 0) + if (i > -1 && j > -1) + return arr[i, j]; + else + Console.WriteLine("Неверный индексы"); + else + Console.WriteLine("Не задана матрица"); + return -1; + } + set + { + if (n > 0 && m > 0) + if (i > -1 && j > -1) + arr[i, j] = value; + else + Console.WriteLine("Неверный индексы"); + else + Console.WriteLine("Не задана матрица"); + } + } + + public Matrix(int N, int M) + { + m = M; + n = N; + arr = new double[N, M]; + } + + public Matrix(Matrix source) + { + m = source.M; + n = source.N; + arr = new double[source.N, source.M]; + arr = (double[,])source.arr.Clone(); + } + + public Matrix(double[,] source) + { + m = source.GetLength(1); + n = source.GetLength(0); + arr = new double[source.GetLength(0), source.GetLength(1)]; + arr = (double[,])source.Clone(); + } + + public double[,] ToArray() + { + return arr; + } + + public Matrix Copy() + { + return new Matrix(this); + } + + public static Matrix operator ^(Matrix A, Matrix B) + { + if (A.M != B.N) { throw new System.ArgumentException("Не совпадают размерности матриц"); } //Нужно только одно соответствие + Matrix C = new Matrix(A.N, B.M); //Столько же строк, сколько в А; столько столбцов, сколько в B + for (int i = 0; i < A.N; ++i) + { + for (int j = 0; j < B.M; ++j) + { + C[i, j] = 0; + for (int k = 0; k < A.M; ++k) + { //ТРЕТИЙ цикл, до A.m=B.n + C[i, j] += A[i, k] * B[k, j]; //Собираем сумму произведений + } + } + } + return C; + } + + public static Matrix operator *(Matrix A, Matrix B) + { + if (((A.n != B.n) || (A.m != B.m)) == true) { throw new System.ArgumentException("Не совпадают размерности матриц"); } + double[,] res = new double[A.n, B.m]; + + for (int i = 0; i < A.n; i++) + { + for (int j = 0; j < B.m; j++) + { + res[i, j] = A[i, j] * B[i, j]; + } + } + return new Matrix(res); + } + + public static Vector operator *(Matrix A, Vector B) + { + if (A.M != B.N) { throw new System.ArgumentException("Не совпадают размерности матриц"); } + double[] res = new double[A.N]; + + for (int i = 0; i < A.N; i++) + { + for (int j = 0; j < B.N; j++) + { + res[i] += A[i, j] * B[j]; + } + } + return new Vector(res); + } + + public static Vector3d operator *(Matrix A, Vector3d B) + { + if (A.n != 3 && A.m != 3) { throw new System.ArgumentException("Не верна размерность матрицы"); } + double[] res = new double[3]; + + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + res[i] += A[i, j] * B[j]; + } + } + return new Vector3d (res); + } + + public static Point3d operator *(Matrix A, Point3d B) + { + if (A.n != 3 && A.m != 3) { throw new System.ArgumentException("Не верна размерность матрицы"); } + double[] res = new double[3]; + + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + res[i] += A[i, j] * B[j]; + } + } + return new Point3d(res); + } + + public static Matrix operator *(Matrix A, double B) + { + double[,] res = new double[A.n, A.m]; + + for (int i = 0; i < A.n; i++) + { + for (int j = 0; j < A.m; j++) + { + res[i, j] = A[i, j] * B; + } + } + + return new Matrix(res); + } + + public static Matrix operator +(Matrix A, Matrix B) + { + if (((A.n != B.n) || (A.m != B.m)) == true) { throw new System.ArgumentException("Не совпадают размерности матриц"); } + double[,] res = new double[A.n, B.m]; + + for (int i = 0; i < A.n; i++) + { + for (int j = 0; j < B.m; j++) + { + res[i, j] = A[i, j] + B[i, j]; + } + } + return new Matrix(res); + } + } +} diff --git a/Geometry/Plane.cs b/Geometry/Plane.cs new file mode 100644 index 0000000..05e39ef --- /dev/null +++ b/Geometry/Plane.cs @@ -0,0 +1,242 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static System.Math; + +namespace Geo +{ + [Serializable] + public class Plane + { + double a; + double b; + double c; + double d; + double gammaRad; + double gammaDeg; + + public double A { get => a; set { a = value; CalcPlane(); } } + public double B { get => b; set { b = value; CalcPlane(); } } + public double C { get => c; set { c = value; CalcPlane(); } } + public double D { get => d; set { d = value; CalcPlane(); } } + public double AlfaRad { get; private set; } + public double BetaRad { get; private set; } + public double GammaRad { get => gammaRad; set { gammaRad = value; RadToDeg(); } } + public double AlfaDeg { get; private set; } + public double BetaDeg { get; private set; } + public double GammaDeg { get => gammaDeg; set { gammaDeg = value; DegToRad(); } } + public Matrix MrAlfa { get; private set; } + public Matrix MrBeta { get; private set; } + public Matrix MrGamma { get; private set; } + public Vector3d X1 { get; private set; } + public Vector3d Y1 { get; private set; } + public Vector3d Z1 { get; private set; } + public Vector3d Normal { get; private set; } + public Matrix Mr { get; private set; } + public Point3d Basis { get; set; } + + public Plane() + { + Basis = new Point3d() { X = 0, Y = 0, Z = 0 }; + + a = 0; + b = 0; + c = 1; + d = 0; + + CalcPlane(); + } + + public Plane(Point3d pt1, Point3d pt2, Point3d pt3) + { + Basis = pt1; + + Vector3d v1 = new Vector3d() + { + Vx = pt2.X - pt1.X, + Vy = pt2.Y - pt1.Y, + Vz = pt2.Z - pt1.Z + }; + + Vector3d v2 = new Vector3d() + { + Vx = pt3.X - pt1.X, + Vy = pt3.Y - pt1.Y, + Vz = pt3.Z - pt1.Z + }; + + a = v1.Vy * v2.Vz - v1.Vz * v2.Vy; + b = v1.Vz * v2.Vx - v1.Vx * v2.Vz; + c = v1.Vx * v2.Vy - v1.Vy * v2.Vx; + d = -a * pt1.X - b * pt1.Y - c * pt1.Z; + + CalcPlane(); + RadToDeg(); + + } + + public Plane(Point3d pt1, Point3d pt2, Point3d pt3, Point3d bpt) + { + Basis = bpt; + + Vector3d v1 = new Vector3d() + { + Vx = pt2.X - pt1.X, + Vy = pt2.Y - pt1.Y, + Vz = pt2.Z - pt1.Z + }; + + Vector3d v2 = new Vector3d() + { + Vx = pt3.X - pt1.X, + Vy = pt3.Y - pt1.Y, + Vz = pt3.Z - pt1.Z + }; + + a = v1.Vy * v2.Vz - v1.Vz * v2.Vy; + b = v1.Vz * v2.Vx - v1.Vx * v2.Vz; + c = v1.Vx * v2.Vy - v1.Vy * v2.Vx; + d = -a * pt1.X - b * pt1.Y - c * pt1.Z; + + CalcPlane(); + RadToDeg(); + + } + + public double Interpolation(double x, double y) + { + if (C == 0) return double.PositiveInfinity; + else return (-A * x - B * y - D) / C; + } + + protected void CreatePlane(Point3d pt1, Point3d pt2, Point3d pt3) + { + Basis = pt1; + + Vector3d v1 = new Vector3d() + { + Vx = pt2.X - pt1.X, + Vy = pt2.Y - pt1.Y, + Vz = pt2.Z - pt1.Z + }; + + Vector3d v2 = new Vector3d() + { + Vx = pt3.X - pt1.X, + Vy = pt3.Y - pt1.Y, + Vz = pt3.Z - pt1.Z + }; + + a = v1.Vy * v2.Vz - v1.Vz * v2.Vy; + b = v1.Vz * v2.Vx - v1.Vx * v2.Vz; + c = v1.Vx * v2.Vy - v1.Vy * v2.Vx; + d = -a * pt1.X - b * pt1.Y - c * pt1.Z; + + CalcPlane(); + RadToDeg(); + } + + protected void CalcPlane() + { + Normal = new Vector3d + { + Vx = a, + Vy = b, + Vz = c + }; + + Intersect(); + CreateMatrix(); + + } + + protected void Intersect() + { + if ((a == 0 & b == 0) == false) + { + Vector3d v3 = new Vector3d { Vx = 0, Vy = 0, Vz = 1 }; + Z1 = new Vector3d(Normal.Unit); + X1 = new Vector3d((v3 ^ Z1).Unit); + Y1 = new Vector3d((Z1 ^ X1).Unit); + + AlfaRad = -Acos(X1.Vx); + BetaRad = -Acos(Z1.Vz); + + //alfaRad = Math.Acos(unitP.Vx); + //betaRad = Math.Acos(unitNormal.Vz); + } + } + + protected void CreateMatrix() + { + Vector3d o = new Vector3d(); + o[0] = -X1.Vx * Basis.X - X1.Vy * Basis.Y - X1.Vz * Basis.Z; + o[1] = -Y1.Vx * Basis.X - Y1.Vy * Basis.Y - Y1.Vz * Basis.Z; + o[2] = -Z1.Vx * Basis.X - Z1.Vy * Basis.Y - Z1.Vz * Basis.Z; + + Mr = new Matrix(4, 4); + + Mr[0, 0] = X1.Vx; Mr[0, 1] = X1.Vy; Mr[0, 2] = X1.Vz; Mr[0, 3] = o.Vx; + Mr[1, 0] = Y1.Vx; Mr[1, 1] = Y1.Vy; Mr[1, 2] = Y1.Vz; Mr[1, 3] = o.Vy; + Mr[2, 0] = Z1.Vx; Mr[2, 1] = Z1.Vy; Mr[2, 2] = Z1.Vz; Mr[2, 3] = o.Vz; + Mr[3, 0] = 0; Mr[3, 1] = 0; Mr[3, 2] = 0; Mr[3, 3] = 1; + + MrAlfa = new Matrix(3, 3); + + MrAlfa[0, 0] = Cos(AlfaRad); MrAlfa[0, 1] = -Sin(AlfaRad); MrAlfa[0, 2] = 0; + MrAlfa[1, 0] = Sin(AlfaRad); MrAlfa[1, 1] = Cos(AlfaRad); MrAlfa[1, 2] = 0; + MrAlfa[2, 0] = 0; MrAlfa[2, 1] = 0; MrAlfa[2, 2] = 0; + + MrBeta = new Matrix(3, 3); + + MrBeta[0, 0] = 1; MrBeta[0, 1] = 0; MrBeta[0, 2] = 0; + MrBeta[1, 0] = 0; MrBeta[1, 1] = Cos(BetaRad); MrBeta[1, 2] = -Sin(BetaRad); + MrBeta[2, 0] = 0; MrBeta[2, 1] = Sin(BetaRad); MrBeta[2, 2] = Cos(BetaRad); + + MrGamma = new Matrix(3, 3); + + MrGamma[0, 0] = Cos(gammaRad); MrGamma[0, 1] = -Sin(gammaRad); MrGamma[0, 2] = 0; + MrGamma[1, 0] = Sin(gammaRad); MrGamma[1, 1] = Cos(gammaRad); MrGamma[1, 2] = 0; + MrGamma[2, 0] = 0; MrGamma[2, 1] = 0; MrGamma[2, 2] = 1; + } + + public Point3d PointInLCS(Point3d pt) + { + double[] d1 = new double[] { 0, 0, 0, 1 }; ; + Vector v1 = new Vector(d1); + v1[0] = pt.X; v1[1] = pt.Y; v1[2] = pt.Z; + + return new Point3d().FromArray((Mr * v1).ToArray()); + } + + protected double[] MultiplyMtxVec(double[,] _Matrix, double[] _Vector) + { + int n = _Vector.Length; + double[] _Result = new double[n]; + + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + _Result[i] += _Matrix[i, j] * _Vector[j]; + } + } + + return _Result; + } + + protected void RadToDeg() + { + AlfaDeg = AlfaRad * 180 / PI; + BetaDeg = BetaRad * 180 / PI; + gammaDeg = gammaRad * 180 / PI; + } + + protected void DegToRad() + { + gammaRad = gammaDeg * 180 / PI; + } + } +} diff --git a/Geometry/Point2d.cs b/Geometry/Point2d.cs new file mode 100644 index 0000000..8d56f6f --- /dev/null +++ b/Geometry/Point2d.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Geo +{ + [Serializable] + public class Point2d + { + double[] arr = new double[2]; + + public double this[int i] { get => arr[i]; set => arr[i] = value; } + public double X { get => arr[0]; set => arr[0] = value; } + public double Y { get => arr[1]; set => arr[1] = value; } + + public Point2d() + { + arr = new double[2]; + } + + public Point2d(double x, double y) + { + arr = new double[2]; + arr[0] = x; arr[1] = y; + } + + public Point2d(Point2d source) + { + arr = new double[2]; + arr = (double[])source.arr.Clone(); + } + + public Point2d(Point3d source) + { + arr = new double[2]; + arr[0]=source.X; arr[1] = source.Y; + } + + public Point2d(double[] source) + { + arr = new double[2]; + if (source.Length >= 2) + { + arr[0] = source[0]; arr[1] = source[1]; + } + } + + public double[] ToArray() + { + return new double[] { X, Y }; + } + + public Vector2d ToVector2d() + { + return new Vector2d { Vx = X, Vy = Y}; + } + + public Vector3d ToVector3d() + { + return new Vector3d { Vx = X, Vy = Y, Vz = 0 }; + } + + public Point3d ToPoint3d() + { + return new Point3d { X = X, Y = Y, Z = 0 }; + } + + public Point2d FromArray(double[] arr) + { + X = arr[0]; Y = arr[1]; + return this; + } + + public double LengthTo(Point2d node) + { + Line2d line = new Line2d(this, node); + return line.Length; + } + + public static Vector2d operator -(Point2d pt1, Point2d pt2) + { + Vector2d res = new Vector2d(); + res[0] = pt1.X - pt2.X; + res[1] = pt1.Y - pt2.Y; + return res; + } + + public static bool operator ==(Point2d p1, Point2d p2) + { + bool check = false; + if (p1.X == p2.X && p1.Y == p2.Y) + { + check = true; + } + return (check); + } + + public static bool operator !=(Point2d p1, Point2d p2) + { + bool check = true; + if (p1.X == p2.X && p1.Y == p2.Y) + { + check = false; + } + return (check); + } + + public override bool Equals(object obj) + { + return base.Equals(obj); + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + } +} diff --git a/Geometry/Point3d.cs b/Geometry/Point3d.cs new file mode 100644 index 0000000..7868d0c --- /dev/null +++ b/Geometry/Point3d.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Geo +{ + [Serializable] + public class Point3d : IVector + { + double[] arr; + //int n = 3; + + public double this[int i] { get => arr[i]; set => arr[i] = value; } + public double X { get => arr[0]; set => arr[0] = value; } + public double Y { get => arr[1]; set => arr[1] = value; } + public double Z { get => arr[2]; set => arr[2] = value; } + + public int N => 3; + + //int N { get => n; } + + public Point3d() + { + arr = new double[3]; + } + + public Point3d(double x, double y, double z) + { + arr = new double[3]; + arr[0] = x; arr[1] = y; arr[2] = z; + } + + public Point3d(double x, double y) + { + arr = new double[3]; + arr[0] = x; arr[1] = y; arr[2] = 0; + } + + public Point3d(Point3d source) + { + arr = new double[3]; + arr = (double[])source.arr.Clone(); + } + + public Point3d(double[] source) + { + arr = new double[3]; + if (source.Length >= 3) { arr[0] = source[0]; arr[1] = source[1]; arr[2] = source[2]; } + else if (source.Length == 2) { arr[0] = source[0]; arr[1] = source[1]; } + else { arr[0] = source[0]; } + } + + public double[] ToArray() + { + return new double[] { X, Y, Z }; + } + + public Vector3d ToVector3d() + { + return new Vector3d { Vx = X, Vy = Y, Vz = Z }; + } + + public Point2d ToPoint2d() + { + return new Point2d { X = X, Y = Y }; + } + + public Point3d FromArray(double[] arr) + { + X = arr[0]; Y = arr[1]; Z = arr[2]; + return this; + } + + public double LengthTo(Point3d node) + { + Line3d line = new Line3d(this, node); + return line.Length; + } + + public double AngleTo(Point3d startPoint, Point3d endPoint) + { + Point3d tempNode = new Point3d(); + + Line3d tempLine1 = new Line3d(this, startPoint); + Line3d tempLine2 = new Line3d(this, endPoint); + double cosTo = Vector3d.CosAngleBetVectors(tempLine1.Directive, tempLine2.Directive); + return RadToDeg(Math.Acos(cosTo)); + } + + public bool NormalDirection(Point3d startNode, Point3d endNode) + { + Line3d tempLine1 = new Line3d(this, startNode); + Line3d tempLine2 = new Line3d(this, endNode); + double norm = (tempLine1.Directive ^ tempLine2.Directive).Vz; + bool res = false; + if (norm > 0) res = true; + return res; + } + + private double RadToDeg(double radians) + { + return radians * 180 / Math.PI; + } + + public static Point3d operator *(Point3d pt, double prime) + { + return new Point3d + { + X = pt.X * prime, + Y = pt.Y * prime, + Z = pt.Z * prime + }; + } + + public static Vector3d operator -(Point3d pt1, Point3d pt2) + { + Vector3d res = new Vector3d(); + res[0] = pt1.X - pt2.X; + res[1] = pt1.Y - pt2.Y; + res[2] = pt1.Z - pt2.Z; + return res; + } + + public static bool operator ==(Point3d p1, Point3d p2) + { + bool check = false; + if (p1.X == p2.X && p1.Y == p2.Y && p1.Z == p2.Z) + { + check = true; + } + return (check); + } + + public static bool operator !=(Point3d p1, Point3d p2) + { + bool check = true; + if (p1.X == p2.X && p1.Y == p2.Y && p1.Z == p2.Z) + { + check = false; + } + return (check); + } + + public override bool Equals(object obj) + { + return base.Equals(obj); + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + } +} diff --git a/Geometry/Polygon.cs b/Geometry/Polygon.cs new file mode 100644 index 0000000..7b4a265 --- /dev/null +++ b/Geometry/Polygon.cs @@ -0,0 +1,663 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Geo +{ + [Serializable] + public class Polygon + { + private double area; + private double ix; + private double iy; + private List vertices = new List(); + + public bool Ckw { get; internal set; } + //public bool? IsSelfItersected { get; private set; } + public double Area { get => Math.Abs(area); } + public double Perimeter { get; internal set; } + public Point3d Centroid { get; internal set; } + public double Ix { get => Math.Abs(ix); } + public double Iy { get => Math.Abs(iy); } + public List Vertices { get => vertices; set { vertices = value; CalcPolygon(); } } + public BoundingBox2d BoundingBox { get; internal set; } + public List Segments { get; internal set; } + + public Polygon() + { + + } + + public Polygon(List vrts) + { + vertices = vrts; + if (vertices[0].X != vertices[vrts.Count - 1].X && vertices[0].Y != vertices[vrts.Count - 1].Y) vertices.Add(vertices[0]); + CalcPolygon(); + } + + public Polygon(List vrts) + { + foreach (Point2d item in vrts) vertices.Add(item.ToPoint3d()); + if (vertices[0].X != vertices[vrts.Count - 1].X && vertices[0].Y != vertices[vrts.Count - 1].Y) vertices.Add(vertices[0]); + CalcPolygon(); + } + + public virtual void AddVertice(Point2d pt) + { + if (vertices.Count == 0) + { + vertices.Add(pt.ToPoint3d()); + return; + } + if (vertices.Count == 1) + { + vertices.Add(pt.ToPoint3d()); + vertices.Add(vertices[0]); + return; + } + if (vertices.Count >= 3) + { + vertices.RemoveAt(vertices.Count - 1); + vertices.Add(pt.ToPoint3d()); + vertices.Add(vertices[0]); + CalcPolygon(); + } + } + + public virtual void AddVertice(Point3d pt) + { + if (vertices.Count == 0) + { + vertices.Add(pt); + return; + } + if (vertices.Count == 1) + { + vertices.Add(pt); + vertices.Add(vertices[0]); + return; + } + if (vertices.Count >= 3) + { + vertices.RemoveAt(vertices.Count - 1); + vertices.Add(pt); + vertices.Add(vertices[0]); + CalcPolygon(); + } + } + + private void CalcBB() + { + double minX = 1000000000; + double minY = 1000000000; + double maxX = -1000000000; + double maxY = -1000000000; + + if (vertices.Count > 0) + { + foreach (Point3d item in vertices) + { + if (item.X < minX) { minX = item.X; } + if (item.Y < minY) { minY = item.Y; } + if (item.X > maxX) { maxX = item.X; } + if (item.Y > maxY) { maxY = item.Y; } + } + + BoundingBox = new BoundingBox2d(new Point2d(minX, minY), new Point2d(maxX, maxY)); + } + } + + private void CalcSegs() + { + if (vertices.Count > 3) + { + Segments = new List(); + for (int i = 0; i < vertices.Count - 1; i++) + { + Segments.Add(new Line2d(vertices[i], vertices[i + 1])); + } + } + } + + protected void CalcI() + { + if (Segments.Count > 2) + { + double tempX = 0; + double tempY = 0; + for (int i = 0; i < Segments.Count; i++) + { + Point3d arrTemp = Segments[i].StartPoint; Point3d arrTemp1 = Segments[i].EndPoint; + tempX += (Math.Pow(arrTemp.X, 2) + arrTemp.X * arrTemp1.X + Math.Pow(arrTemp1.X, 2)) * (arrTemp.X * arrTemp1.Y - arrTemp.Y * arrTemp1.X); + tempY += (Math.Pow(arrTemp.Y, 2) + arrTemp.Y * arrTemp1.Y + Math.Pow(arrTemp1.Y, 2)) * (arrTemp.X * arrTemp1.Y - arrTemp.Y * arrTemp1.X); + } + ix = tempX / 12; + iy = tempY / 12; + } + } + + protected void CalcCentroid() + { + if (Segments.Count > 2) + { + Point3d temp = new Point3d(); + for (int i = 0; i < Segments.Count; i++) + { + Point3d arrTemp = Segments[i].StartPoint; Point3d arrTemp1 = Segments[i].EndPoint; + temp.X += 1 / (6 * area) * (arrTemp.X + arrTemp1.X) * (arrTemp.X * arrTemp1.Y - arrTemp.Y * arrTemp1.X); + temp.Y += 1 / (6 * area) * (arrTemp.Y + arrTemp1.Y) * (arrTemp.X * arrTemp1.Y - arrTemp.Y * arrTemp1.X); + } + Centroid = temp; + } + } + + protected void CalcArea() + { + double temp = 0; + if (Segments.Count > 2) + { + for (int i = 0; i < Segments.Count; i++) + { + Point3d arrTemp = Segments[i].StartPoint; Point3d arrTemp1 = Segments[i].EndPoint; + temp += 0.5 * (arrTemp.X * arrTemp1.Y - arrTemp1.X * arrTemp.Y); + } + area = temp; + } + } + + protected void CalcPerimeter() + { + if (Segments.Count > 2) + { + Perimeter = 0; + foreach (Line2d item in Segments) + { + Perimeter += item.Length; + } + } + } + + protected void CalcCkw() + { + if (area < 0) Ckw = true; + else Ckw = false; + } + + /// + /// Вычисление свойств полигона + /// + public void CalcPolygon() + { + if (Vertices.Count > 3) + { + if ((Vertices[0].X != Vertices[vertices.Count - 1].X && Vertices[0].Y != Vertices[Vertices.Count - 1].Y)|| + (Vertices[0].X == Vertices[vertices.Count - 1].X && Vertices[0].Y != Vertices[Vertices.Count - 1].Y)|| + (Vertices[0].X != Vertices[vertices.Count - 1].X && Vertices[0].Y == Vertices[Vertices.Count - 1].Y)) + Vertices.Add(Vertices[0]); + } + CalcBB(); + CalcSegs(); + CalcPerimeter(); + CalcArea(); + CalcCkw(); + CalcCentroid(); + CalcI(); + } + + /// + /// Замена вершины полигона + /// + /// индекс заменяемой вершины + /// объект заменяющей вершины + public bool ReplaceVertice( int oldVertIdx, Point3d newVert) + { + try + { + Vertices[oldVertIdx] = newVert; + if (oldVertIdx == 0 || oldVertIdx == Vertices.Count - 1) { Vertices[0] = newVert; Vertices[Vertices.Count - 1] = newVert; } + CalcPolygon(); + return true; + } + catch + { + return false; + } + } + + public void Triangulation(double shag, out List innerNodes, out List triangles) + { + innerNodes = new List(); + triangles = new List(); + List polygons = new List(); + int n = Tesselation(shag); + Polygon front = new Polygon(Vertices); + //int p = 1; + do + { + if (polygons.Count != 0) { front = polygons[0]; polygons.RemoveAt(0); } + for (int j = 0; j < 1000; j++) + { + AngleIn3Point minAngle; + front.MinAngleDeg(out minAngle); + while (minAngle.AngleDeg == 0 && front.Vertices.Count > 3) + { + if(minAngle.VerticeIdx == 0) + { + front.Vertices.RemoveRange(Vertices.Count - 2, 2); + front.Vertices.RemoveAt(0); + } + else front.Vertices.RemoveRange(minAngle.PreviousIdx, 2); + front.CalcPolygon(); + front.MinAngleDeg(out minAngle); + } + + if (Math.Round(minAngle.AngleDeg) < 90) + { + triangles.Add(new Triangle(front.Vertices[minAngle.PreviousIdx], front.Vertices[minAngle.VerticeIdx], front.Vertices[minAngle.NextIdx])); + front.Vertices.RemoveAt(minAngle.VerticeIdx); + if (minAngle.VerticeIdx == 0 && front.Vertices.Count > 3) front.Vertices.RemoveAt(front.Vertices.Count - 1); + front.CalcPolygon(); + } + + else if (Math.Round(minAngle.AngleDeg) == 90 /*&& Math.Round(minAngle.AngleDeg) <= 140*/) + { + Line2d lin = new Line2d(front.Vertices[minAngle.VerticeIdx], front.Vertices[minAngle.PreviousIdx]); + Point3d temp = front.Vertices[minAngle.VerticeIdx]; + Point3d g = new Point3d(front.Vertices[minAngle.NextIdx].X + lin.Directive.Vx, front.Vertices[minAngle.NextIdx].Y + lin.Directive.Vy, 0); + Point3d gNode = new Point3d { X = g.X, Y = g.Y, Z = g.Z/*, Number = n*/ }; + bool ch = false; + int k = -1; + for (int i = 0; i < front.Vertices.Count - 1; i++) + { + //if (i == minAngle.VerticeIdx) continue; + double d = g.LengthTo(front.Vertices[i]); + if (Math.Round(g.X, 2) == Math.Round(front.Vertices[i].X, 2) && Math.Round(g.Y, 2) == Math.Round(front.Vertices[i].Y, 2)) + { ch = true; k = i; break; } + } + + Triangle t1, t2; + + if (ch) + { + t1 = new Triangle(front.Vertices[minAngle.VerticeIdx], front.Vertices[minAngle.NextIdx], front.Vertices[k]); + t2 = new Triangle(front.Vertices[minAngle.PreviousIdx], front.Vertices[minAngle.VerticeIdx], front.Vertices[k]); + } + else + { + t1 = new Triangle(front.Vertices[minAngle.VerticeIdx], front.Vertices[minAngle.NextIdx], gNode); + t2 = new Triangle(front.Vertices[minAngle.PreviousIdx], front.Vertices[minAngle.VerticeIdx], gNode); + } + + front.ReplaceVertice(minAngle.VerticeIdx, gNode); + + if (front.SelfItersectCheck()) + { + front.ReplaceVertice(minAngle.VerticeIdx, temp); + double dist = 100000000; + k = -1; + for (int i = 0; i < front.Vertices.Count - 1; i++) + { + if (i == minAngle.NextIdx || i == minAngle.PreviousIdx || i == minAngle.VerticeIdx) continue; + double d = front.Vertices[minAngle.VerticeIdx].LengthTo(front.Vertices[i]); + if (d < dist) { dist = d; k = i; } + } + Polygon sub; + front.Bisection(k, minAngle.VerticeIdx, out sub); + polygons.Add(sub); + } + else + { + if (!ch) { innerNodes.Add(gNode); n++; } + triangles.Add(t1); triangles.Add(t2); + } + + } + + else + { + Line2d linPrev = new Line2d(front.Vertices[minAngle.VerticeIdx], front.Vertices[minAngle.PreviousIdx]); + Line2d linNext = new Line2d(front.Vertices[minAngle.VerticeIdx], front.Vertices[minAngle.NextIdx]); + double vx = (linPrev.Directive.Unit[0] + linNext.Directive.Unit[0]) * 0.5; + double vy = (linPrev.Directive.Unit[1] + linNext.Directive.Unit[1]) * 0.5; + //double lengthBis = (linPrev.Length + linNext.Length) * 0.5; + double x = front.Vertices[minAngle.VerticeIdx].X + vx * shag; + double y = front.Vertices[minAngle.VerticeIdx].Y + vy * shag; + Point3d temp = front.Vertices[minAngle.VerticeIdx]; + Point3d g = new Point3d(x, y, 0); + Line2d linBis = new Line2d(front.Vertices[minAngle.VerticeIdx], g); + x = front.Vertices[minAngle.VerticeIdx].X + linBis.Directive.Unit[0] * shag; + y = front.Vertices[minAngle.VerticeIdx].Y + linBis.Directive.Unit[1] * shag; + g = new Point3d(x, y, 0); + Point3d gNode = new Point3d() { X = g.X, Y = g.Y, Z = g.Z/*, Number = n*/ }; + Triangle t1, t2; + t1 = new Triangle(front.Vertices[minAngle.VerticeIdx], front.Vertices[minAngle.NextIdx], gNode); + t2 = new Triangle(front.Vertices[minAngle.PreviousIdx], front.Vertices[minAngle.VerticeIdx], gNode); + front.ReplaceVertice(minAngle.VerticeIdx, gNode); + //if (p == 1) { Shpunt.AcCreator.CreateContour(front); p++; } + + if (front.SelfItersectCheck()) + { + front.ReplaceVertice(minAngle.VerticeIdx, temp); + double dist = 100000000; + int k = -1; + for (int i = 0; i < front.Vertices.Count - 1; i++) + { + if (i == minAngle.NextIdx || i == minAngle.PreviousIdx || i == minAngle.VerticeIdx) continue; + double d = front.Vertices[minAngle.VerticeIdx].LengthTo(front.Vertices[i]); + if (d < dist) { dist = d; k = i; } + } + Polygon sub; + front.Bisection(k, minAngle.VerticeIdx, out sub); + polygons.Add(sub); + } + else + { + triangles.Add(t1); + triangles.Add(t2); + innerNodes.Add(gNode); + } + n++; + } + if (front.Vertices.Count < 4) break; + } + } while (polygons.Count != 0); + } + + /// + /// Тесселяция полигона с заданным шагом + /// + /// Величина шага тесселяции + public int Tesselation(double shag) + { + List nodes = new List(); + int n = 1; + int nD = 0; + foreach (Line2d seg in Segments) + { + Point3d start = seg.StartPoint; + Point3d end = seg.EndPoint; + nD = (int)Math.Round(seg.Length / shag); + if (nD > 1) + { + double delta = seg.Length / nD; + double deltaX = (end.X - start.X) / nD; + double deltaY = (end.Y - start.Y) / nD; + double deltaZ = (end.Z - start.Z) / nD; + for (int j = 0; j < nD; j++) + { + Point3d pt = new Point3d(start.X + j * deltaX, start.Y + j * deltaY, start.Z + j * deltaZ); + //FEA.Node nd = new FEA.Node(pt) { Number = n }; + nodes.Add(pt); + n++; + } + } + else + { + Point3d pt = new Point3d(start.X, start.Y, start.Z); + //FEA.Node nd = new FEA.Node(pt) { Number = n }; + nodes.Add(pt); + n++; + } + } + Vertices = nodes; + if (!Ckw) { Vertices.Reverse(); CalcPolygon(); } + return n; + } + + /// + /// Деление полигона через указание 2-х точек деления + /// + /// Индекс первой точки деления(секущей) + /// Индекс второй точки деления(базовой) + /// Возвращаемый отсеченный полигон + public void Bisection(int sectPointIdx,int basePointIdx, out Polygon newPolygon) + { + newPolygon = new Polygon(); + List tmp = new List(); + if (basePointIdx > sectPointIdx) + { + for (int i = sectPointIdx; i <= basePointIdx; i++) + { + newPolygon.AddVertice(Vertices[i]); + } + newPolygon.CalcPolygon(); + Vertices.RemoveRange(sectPointIdx + 1, basePointIdx - sectPointIdx - 1); + CalcPolygon(); + } + else + { + for (int i = basePointIdx; i <= sectPointIdx; i++) + { + newPolygon.AddVertice(Vertices[i]); + } + newPolygon.CalcPolygon(); + Vertices.RemoveRange(basePointIdx + 1, sectPointIdx - basePointIdx - 1); + CalcPolygon(); + } + } + + /// + /// Проверка полигона на самопересечение (возвращает булево значение, если true - полигон самопересекающийся) + /// + public bool SelfItersectCheck() + { + bool IsSelfItersected = false; + if (Segments.Count < 4) return IsSelfItersected; + for (int i = 0; i < Segments.Count; i++) + { + for (int j = 0; j < Segments.Count; j++) + { + if (i == j) continue; + double a1 = Segments[i].A; + double a2 = Segments[j].A; + double b1 = Segments[i].B; + double b2 = Segments[j].B; + double c1 = Segments[i].C; + double c2 = Segments[j].C; + double p1 = (b2 - b1 * a2 / a1); + if (p1 == 0) continue; + double y = (a2 * c1 / a1 - c2) / p1; + double x = (-b1 * y - c1) / a1; + Point3d ptItersect = new Point3d(x, y, 0); + Line2d linTmp1 = new Line2d(Segments[i].CenterPoint, ptItersect); + Line2d linTmp2 = new Line2d(Segments[j].CenterPoint, ptItersect); + double l1 = Math.Round(linTmp1.Length, 2); + double l11 = Math.Round(Segments[i].Length / 2, 2); + double l2 = Math.Round(linTmp2.Length, 2); + double l22 = Math.Round(Segments[j].Length / 2, 2); + if (Math.Round(linTmp1.Length, 2) < Math.Round(Segments[i].Length / 2, 2) && + Math.Round(linTmp2.Length, 2) < Math.Round(Segments[j].Length / 2, 2)) + { + IsSelfItersected = true; + return IsSelfItersected; + } + } + } + return IsSelfItersected; + } + /// + /// Вычисление минимального угла полигона в градусах + /// + /// + public double MinAngleDeg() + { + double minAngle = 360; + double angleTmp; + bool type; + for (int i = 0; i < Vertices.Count - 1; i++) + { + if (i == 0) + { + angleTmp = Vertices[0].AngleTo(Vertices[Vertices.Count - 2], Vertices[1]); + if (angleTmp is double.NaN) angleTmp = 180; + type = Vertices[0].NormalDirection(Vertices[Vertices.Count - 2], Vertices[1]); + if (!type && angleTmp != 0) angleTmp = 360 - angleTmp; + if (!type && angleTmp == 0) angleTmp = 0; + if (angleTmp < minAngle) minAngle = angleTmp; + } + else + { + angleTmp = Vertices[i].AngleTo(Vertices[i - 1], Vertices[i + 1]); + if (angleTmp is double.NaN) angleTmp = 180; + type = Vertices[i].NormalDirection(Vertices[i - 1], Vertices[i + 1]); + if (!type && angleTmp != 0) angleTmp = 360 - angleTmp; + if (!type && angleTmp == 0) angleTmp = 0; + if (angleTmp < minAngle) minAngle = angleTmp; + } + } + return minAngle; + } + /// + /// Вычисление минимального угла полигона в градусах (возвращает массив индексов 3-х точек на которых был найден угол) + /// + /// Возвращаемое значение минимального угла в градусах + public int[] MinAngleDeg(out double minAngle) + { + minAngle = 0; + if (Vertices.Count < 3) return null; + int[] res = new int[3]; + minAngle = 360; + double angleTmp; + bool type; + for (int i = 0; i < Vertices.Count - 1; i++) + { + if (i == 0) + { + angleTmp = Vertices[0].AngleTo(Vertices[Vertices.Count - 2], Vertices[i + 1]); + if (angleTmp is double.NaN) angleTmp = 180; + type = Vertices[i].NormalDirection(Vertices[Vertices.Count - 2], Vertices[i + 1]); + if (!type && angleTmp != 0) angleTmp = 360 - angleTmp; + if (!type && angleTmp == 0) angleTmp = 0; + if (angleTmp < minAngle) + { + res[0] = Vertices.Count - 2; + res[1] = 0; + res[2] = 1; + minAngle = angleTmp; + } + } + else + { + angleTmp = Vertices[i].AngleTo(Vertices[i - 1], Vertices[i + 1]); + if (angleTmp is double.NaN) angleTmp = 180; + type = Vertices[i].NormalDirection(Vertices[i - 1], Vertices[i + 1]); + if (!type && angleTmp != 0) angleTmp = 360 - angleTmp; + if (!type && angleTmp == 0) angleTmp = 0; + if (angleTmp < minAngle) + { + res[0] = i - 1; + res[1] = i; + res[2] = i + 1; + minAngle = angleTmp; + } + } + } + return res; + } + + /// + /// Вычисление минимального угла полигона в градусах + /// + /// Возвращаемое значение в виде объекта со свойствами индексов трех точек образуюших угол и значения угла в градусах + public void MinAngleDeg(out AngleIn3Point result) + { + result = new AngleIn3Point(); + result.AngleDeg = 0; + if (Vertices.Count < 3) return; + result.AngleDeg = 360; + double angleTmp; + bool type; + for (int i = 0; i < Vertices.Count - 1; i++) + { + if (i == 0) + { + angleTmp = Vertices[0].AngleTo(Vertices[Vertices.Count - 2], Vertices[i + 1]); + if (angleTmp is double.NaN) angleTmp = 180; + type = Vertices[i].NormalDirection(Vertices[Vertices.Count - 2], Vertices[i + 1]); + if (!type && angleTmp != 0) angleTmp = 360 - angleTmp; + if (!type && angleTmp == 0) angleTmp = 0; + if (angleTmp < result.AngleDeg) + { + result.PreviousIdx = Vertices.Count - 2; + result.VerticeIdx = 0; + result.NextIdx = 1; + result.AngleDeg = angleTmp; + } + } + else + { + angleTmp = Vertices[i].AngleTo(Vertices[i - 1], Vertices[i + 1]); + if (angleTmp is double.NaN) angleTmp = 180; + type = Vertices[i].NormalDirection(Vertices[i - 1], Vertices[i + 1]); + if (!type && angleTmp != 0) angleTmp = 360 - angleTmp; + if (!type && angleTmp == 0) angleTmp = 0; + if (angleTmp < result.AngleDeg) + { + result.PreviousIdx = i - 1; + result.VerticeIdx = i; + result.NextIdx = i + 1; + result.AngleDeg = angleTmp; + } + } + } + } + /// + /// Вычисление максимального угла полигона в градусах + /// + /// + public double MaxAngleDeg() + { + double minAngle = 0; + double angleTmp; + bool type; + for (int i = 0; i < Vertices.Count - 1; i++) + { + if (i == 0) + { + angleTmp = Vertices[0].AngleTo(Vertices[Vertices.Count - 2], Vertices[i + 1]); + if (angleTmp is double.NaN) angleTmp = 180; + type = Vertices[i].NormalDirection(Vertices[Vertices.Count - 2], Vertices[i + 1]); + if (!type && angleTmp != 0) angleTmp = 360 - angleTmp; + if (!type && angleTmp == 0) angleTmp = 0; + if (angleTmp > minAngle) minAngle = angleTmp; + } + else + { + angleTmp = Vertices[i].AngleTo(Vertices[i - 1], Vertices[i + 1]); + if (angleTmp is double.NaN) angleTmp = 180; + type = Vertices[i].NormalDirection(Vertices[i - 1], Vertices[i + 1]); + if (!type && angleTmp != 0) angleTmp = 360 - angleTmp; + if (!type && angleTmp == 0) angleTmp = 0; + if (angleTmp > minAngle) minAngle = angleTmp; + } + } + + return minAngle; + } + } + /// + /// Объект-структура со свойствами индексов трех точек образуюших угол и значения угла в градусах + /// + public struct AngleIn3Point + { + /// + /// Индекс предыдущей вершины + /// + public int PreviousIdx { get; set; } + /// + /// Индех следующей вершины + /// + public int NextIdx { get; set; } + /// + /// Индекс вершины, на которой найден угол + /// + public int VerticeIdx { get; set; } + /// + /// Значение найденного угла в градусах + /// + public double AngleDeg { get; set; } + + } +} diff --git a/Geometry/Quadrangle.cs b/Geometry/Quadrangle.cs new file mode 100644 index 0000000..6b80dc9 --- /dev/null +++ b/Geometry/Quadrangle.cs @@ -0,0 +1,147 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Geo +{ + [Serializable] + public class Quadrangle : Polygon + { + private Point3d vertex1 = new Point3d(); + private Point3d vertex2 = new Point3d(); + private Point3d vertex3 = new Point3d(); + private Point3d vertex4 = new Point3d(); + + public Point3d Vertex1 { get => vertex1; set { vertex1 = value; Vertices[0] = vertex1; CalcQuadrangle(); } } + public Point3d Vertex2 { get => vertex2; set { vertex2 = value; Vertices[1] = vertex2; CalcQuadrangle(); } } + public Point3d Vertex3 { get => vertex3; set { vertex3 = value; Vertices[2] = vertex3; CalcQuadrangle(); } } + public Point3d Vertex4 { get => vertex4; set { vertex4 = value; Vertices[3] = vertex4; CalcQuadrangle(); } } + public double MaxAngleDeg { get; private set; } + public bool IsValid { get; private set; } + public UnitsLin Units { get; set; } + + public Quadrangle(Triangle trg1, Triangle trg2) + { + List vrt = new List(); + List dgn = new List(); + vrt.Add(trg1.Vertex1); + vrt.Add(trg1.Vertex2); + vrt.Add(trg1.Vertex3); + vrt.Add(trg2.Vertex1); + vrt.Add(trg2.Vertex2); + vrt.Add(trg2.Vertex3); + for (int i = 0; i < vrt.Count; i++) + { + for (int j = 0; j < vrt.Count; j++) + { + if (i == j) continue; + if (Math.Round(vrt[i].X, 2) == Math.Round(vrt[j].X,2) && Math.Round(vrt[i].Y,2) == Math.Round(vrt[j].Y,2)) + { + dgn.Add(vrt[i]); + vrt.RemoveAt(j); + break; + } + } + } + + if (vrt.Count == 4) + { + if (vrt[0].Equals(dgn[0]) && vrt[1].Equals(dgn[1])) + { + vertex1 = vrt[0]; + AddVertice(Vertex1); + vertex2 = vrt[2]; + AddVertice(Vertex2); + vertex3 = vrt[1]; + AddVertice(Vertex3); + vertex4 = vrt[3]; + AddVertice(Vertex4); + } + if (vrt[1].Equals(dgn[0]) && vrt[2].Equals(dgn[1])) + { + vertex1 = vrt[0]; + AddVertice(Vertex1); + vertex2 = vrt[2]; + AddVertice(Vertex2); + vertex3 = vrt[3]; + AddVertice(Vertex3); + vertex4 = vrt[1]; + AddVertice(Vertex4); + } + if (vrt[0].Equals(dgn[0]) && vrt[2].Equals(dgn[1])) + { + vertex1 = vrt[0]; + AddVertice(Vertex1); + vertex2 = vrt[1]; + AddVertice(Vertex2); + vertex3 = vrt[2]; + AddVertice(Vertex3); + vertex4 = vrt[3]; + AddVertice(Vertex4); + } + if (vrt[1].Equals(dgn[0]) && vrt[3].Equals(dgn[1])) + { + vertex1 = vrt[0]; + AddVertice(Vertex1); + vertex2 = vrt[1]; + AddVertice(Vertex2); + vertex3 = vrt[2]; + AddVertice(Vertex3); + vertex4 = vrt[3]; + AddVertice(Vertex4); + } + IsValid = true; + CalcQuadrangle(); + } + else + { + IsValid = false; + Vertices.Add(new Point3d()); + Vertices.Add(new Point3d()); + Vertices.Add(new Point3d()); + Vertices.Add(new Point3d()); + } + } + + public Quadrangle(Point3d node1, Point3d node2, Point3d node3, Point3d node4) + { + vertex1 = node1; + AddVertice(node1); + vertex2 = node2; + AddVertice(node2); + vertex3 = node3; + AddVertice(node3); + vertex4 = node4; + AddVertice(node4); + CalcQuadrangle(); + IsValid = true; + } + + public Quadrangle(Point2d node1, Point2d node2, Point2d node3, Point2d node4) + { + vertex1 = node1.ToPoint3d(); + AddVertice(node1); + vertex2 = node2.ToPoint3d(); + AddVertice(node2); + vertex3 = node3.ToPoint3d(); + AddVertice(node3); + vertex4 = node4.ToPoint3d(); + AddVertice(node4); + CalcQuadrangle(); + IsValid = true; + } + + public void CalcQuadrangle() + { + double ang1, ang2, ang3, ang4; + ang1 = vertex1.AngleTo(vertex4, vertex2); + ang2 = vertex2.AngleTo(vertex1, vertex3); + ang3 = vertex3.AngleTo(vertex2, vertex4); + ang4 = vertex4.AngleTo(vertex3, vertex1); + MaxAngleDeg = Math.Max(Math.Max(Math.Max(ang1, ang2), ang3), ang4); + CalcPolygon(); + } + } +} diff --git a/Geometry/Triangle.cs b/Geometry/Triangle.cs new file mode 100644 index 0000000..933e285 --- /dev/null +++ b/Geometry/Triangle.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Geo +{ + [Serializable] + public class Triangle : Polygon + { + private Point3d vertex1; + private Point3d vertex2; + private Point3d vertex3; + + public Point3d Vertex1 { get => vertex1; set { vertex1 = value; Vertices[0] = vertex1; CalcTriangle(); } } + public Point3d Vertex2 { get => vertex2; set { vertex2 = value; Vertices[1] = vertex2; CalcTriangle(); } } + public Point3d Vertex3 { get => vertex3; set { vertex3 = value; Vertices[2] = vertex3; CalcTriangle(); } } + public double MaxAngleDeg { get; private set; } + + public Triangle(Point3d node1, Point3d node2, Point3d node3) + { + vertex1 = node1; + AddVertice(vertex1); + vertex2 = node2; + AddVertice(vertex2); + vertex3 = node3; + AddVertice(vertex3); + CalcTriangle(); + } + + public Triangle(Point2d node1, Point2d node2, Point2d node3) + { + vertex1 = node1.ToPoint3d(); + AddVertice(vertex1); + vertex2 = node2.ToPoint3d(); + AddVertice(vertex2); + vertex3 = node3.ToPoint3d(); + AddVertice(vertex3); + CalcTriangle(); + } + + public void CalcTriangle() + { + //Edge1 = new Line3d(vertex1, vertex2); + //Edge2 = new Line3d(vertex2, vertex3); + //Edge3 = new Line3d(vertex3, vertex1); + //Centroid = new Point3d((vertex1.X + vertex2.X + vertex3.X) / 3, (vertex1.Y + vertex2.Y + vertex3.Y) / 3, (vertex1.Z + vertex2.Z + vertex3.Z) / 3); + //Point3d minPt, maxPt; + //minPt = new Point3d( + // Math.Min(Math.Min(vertex1.X, vertex2.X), vertex3.X), + // Math.Min(Math.Min(vertex1.Y, vertex2.Y), vertex3.Y), + // Math.Min(Math.Min(vertex1.Z, vertex2.Z), vertex3.Z)); + //maxPt = new Point3d( + // Math.Max(Math.Max(vertex1.X, vertex2.X), vertex3.X), + // Math.Max(Math.Max(vertex1.Y, vertex2.Y), vertex3.Y), + // Math.Max(Math.Max(vertex1.Z, vertex2.Z), vertex3.Z)); + //BoundingBox = new BoundingBox2d(minPt.ToPoint2d(), maxPt.ToPoint2d()); + double ang1, ang2, ang3; + ang1 = vertex1.AngleTo(vertex3, vertex2); + ang2 = vertex2.AngleTo(vertex1, vertex3); + ang3 = vertex3.AngleTo(vertex2, vertex1); + MaxAngleDeg = Math.Max(Math.Max(ang1, ang2), ang3); + CalcPolygon(); + } + } +} diff --git a/Geometry/UnitsEnums.cs b/Geometry/UnitsEnums.cs new file mode 100644 index 0000000..83c47e4 --- /dev/null +++ b/Geometry/UnitsEnums.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +public enum UnitsLin { м = 1, см = 2, мм = 3, _ = 0 } +public enum UnitsArea { м = 1, см = 2, мм = 3, _ = 0 } +public enum UnitsForce { т = 1, кН = 3, Н = 4, кг = 2, _ = 0 } +public enum UnitsStress { т = 1, кН = 2, Н = 3, МПа = 4, кПа = 5, _ = 0 } +public enum UnitsList { _, м, см, мм, т, кг, Н, кН, кПа, МПа, градус, rad } diff --git a/Geometry/Vector.cs b/Geometry/Vector.cs new file mode 100644 index 0000000..e290c87 --- /dev/null +++ b/Geometry/Vector.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Geo +{ + [Serializable] + public class Vector : IVector + { + double[] arr; + int n; + + public int N { get => n; } + public double this[int i] { get => arr[i]; set => arr[i] = value; } + + public Vector(int N) + { + n = N; + arr = new double[N]; + } + + public Vector(Vector source) + { + n = source.N; + arr = new double[source.N]; + arr = (double[])source.arr.Clone(); + } + + public Vector(Vector3d source) + { + n = 3; + arr = new double[n]; + arr[0] = source.Vx; + arr[1] = source.Vy; + arr[2] = source.Vz; + } + + public Vector(double[] source) + { + n = source.Length; + arr = new double[source.Length]; + arr = (double[])source.Clone(); + } + + public double[] ToArray() + { + return arr; + } + + public Vector3d ToVector3d() + { + return new Vector3d { Vx = arr[0], Vy = arr[1], Vz = arr[2] }; + } + } +} diff --git a/Geometry/Vector2d.cs b/Geometry/Vector2d.cs new file mode 100644 index 0000000..e32b749 --- /dev/null +++ b/Geometry/Vector2d.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static System.Math; + +namespace Geo +{ + [Serializable] + public class Vector2d + { + double[] arr = new double[2]; + + public double this[int i] { get => arr[i]; set => arr[i] = value; } + public double Vx { get => arr[0]; set => arr[0] = value; } + public double Vy { get => arr[1]; set => arr[1] = value; } + public double Norma { get => Sqrt(Pow(Vx, 2) + Pow(Vy, 2)); } + public double[] Unit { get => new double[] { Vx / Norma, Vy / Norma }; } + + public Vector2d() + { + arr = new double[3]; + } + + public Vector2d(double v1, double v2) + { + arr = new double[2]; + arr[0] = v1; arr[1] = v2; + } + + public Vector2d(Vector2d source) + { + arr = new double[3]; + arr = (double[])source.arr.Clone(); + } + + public Vector2d(Point2d source) + { + arr = new double[2]; + arr[0] = source.X; arr[1] = source.Y; + } + + public Vector2d(Vector source) + { + arr = new double[2]; + if (source.N >= 2) + { + arr[0] = source[0]; arr[1] = source[1]; + } + } + + public Vector2d(double[] source) + { + arr = new double[2]; + if (source.Length >= 2) + { + arr[0] = source[0]; arr[1] = source[1]; + } + } + + public static double CosAngleBetVectors(Vector2d v1, Vector2d v2) + { + return (v1.Vx * v2.Vx + v1.Vy * v2.Vy) / (Sqrt(v1.Vx * v1.Vx + v1.Vy * v1.Vy) * Sqrt(v2.Vx * v2.Vx + v2.Vy * v2.Vy)); + } + + public double[] ToArray() + { + return arr; + } + + public Vector ToVector() + { + return new Vector(arr); + } + + public static Vector3d operator ^(Vector2d v1, Vector2d v2) + { + Vector3d tempV1 = new Vector3d(v1); Vector3d tempV2 = new Vector3d(v2); + return new Vector3d + { + Vx = tempV1.Vy * tempV2.Vz - tempV1.Vz * tempV2.Vy, + Vy = tempV1.Vz * tempV2.Vx - tempV1.Vx * tempV2.Vz, + Vz = tempV1.Vx * tempV2.Vy - tempV1.Vy * tempV2.Vx + }; + } + + public static Vector2d operator *(Vector2d v1, Vector2d v2) + { + return new Vector2d + { + Vx = v1.Vx * v2.Vx, + Vy = v1.Vy * v2.Vy + }; + } + } +} diff --git a/Geometry/Vector3d.cs b/Geometry/Vector3d.cs new file mode 100644 index 0000000..3a7aac8 --- /dev/null +++ b/Geometry/Vector3d.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static System.Math; + +namespace Geo +{ + [Serializable] + public class Vector3d : IVector + { + double[] arr; + int n = 3; + + public double this[int i] { get => arr[i]; set => arr[i] = value; } + public double Vx { get => arr[0]; set => arr[0] = value; } + public double Vy { get => arr[1]; set => arr[1] = value; } + public double Vz { get => arr[2]; set => arr[2] = value; } + public double Norma { get => Sqrt(Pow(Vx, 2) + Pow(Vy, 2) + Pow(Vz, 2)); } + public double[] Unit { get => new double[] { Vx / Norma, Vy / Norma, Vz / Norma }; } + public int N { get => n; } + + public Vector3d() + { + arr = new double[3]; + } + + public Vector3d(Vector3d source) + { + arr = new double[3]; + arr = (double[])source.arr.Clone(); + } + + public Vector3d(Point3d source) + { + arr = new double[3]; + arr[0] = source.X; arr[1] = source.Y; arr[2] = source.Z; + } + + public Vector3d(Vector source) + { + arr = new double[3]; + if (source.N >= 3) + { + arr[0] = source[0]; arr[1] = source[1]; arr[2] = source[2]; + } + } + + public Vector3d(Vector2d source) + { + arr = new double[3]; + arr[0] = source.Vx; + arr[1] = source.Vy; + arr[2] = 0; + } + + public Vector3d(double[] source) + { + arr = new double[3]; + if (source.Length >= 3) + { + arr[0] = source[0]; arr[1] = source[1]; arr[2] = source[2]; + } + } + + public static double CosAngleBetVectors(Vector3d v1, Vector3d v2) + { + return (v1.Vx * v2.Vx + v1.Vy * v2.Vy + v1.Vz * v2.Vz) / (Sqrt(v1.Vx* v1.Vx + v1.Vy* v1.Vy+ v1.Vz * v1.Vz) * Sqrt(v2.Vx * v2.Vx + v2.Vy * v2.Vy + v2.Vz * v2.Vz)); + } + + public double[] ToArray() + { + return arr; + } + + public Vector2d ToVector2d() + { + return new Vector2d() { Vx = Vx, Vy = Vy }; + } + + public Vector ToVector() + { + return new Vector(arr); + } + + public static Vector3d operator ^(Vector3d v1, Vector3d v2) + { + return new Vector3d + { + Vx = v1.Vy * v2.Vz - v1.Vz * v2.Vy, + Vy = v1.Vz * v2.Vx - v1.Vx * v2.Vz, + Vz = v1.Vx * v2.Vy - v1.Vy * v2.Vx + }; + } + + public static Vector3d operator *(Vector3d v1, Vector3d v2) + { + return new Vector3d + { + Vx = v1.Vx * v2.Vx, + Vy = v1.Vy * v2.Vy, + Vz = v1.Vz * v2.Vz + }; + } + } +} diff --git a/Grapfics/CanvasDrafter.cs b/Grapfics/CanvasDrafter.cs new file mode 100644 index 0000000..464a3cd --- /dev/null +++ b/Grapfics/CanvasDrafter.cs @@ -0,0 +1,231 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Shapes; +using AForge.Math.Geometry; +using AForge; +using netDxf.Entities; +using Point = System.Windows.Point; + +namespace GroundOrganizer +{ + public partial class CanvasDrafter + { + //const double WXMIN = -300; + //const double WXMAX = 300; + //const double WYMIN = -300; + //const double WYMAX = 300; + const double DMARGIN = 0; + + static Matrix WtoDMatrix; + static Matrix DtoWMatrix; + + static public void DrawPolygonsFromDxfLwPolyline(IEnumerable dxfEntitys,Canvas canvas, double h) + { + double dxmin = DMARGIN; + double dymin = DMARGIN; + double dymax = h - DMARGIN; + + double wxmin; + double wxmax; + double wymin; + double wymax; + + List dxfVertices = new List(); + foreach (LwPolyline item in dxfEntitys) + { + dxfVertices.AddRange(item.Vertexes); + } + + IOrderedEnumerable selected = from x in dxfVertices // определяем каждый объект как x + orderby x.Position.X // упорядочиваем по возрастанию + select x; // выбираем объект + wxmin = selected.First().Position.X; + wxmax = selected.Last().Position.X; + + selected = from y in dxfVertices orderby y.Position.Y select y; + + wymin = selected.First().Position.Y; + wymax = selected.Last().Position.Y; + + double w = (wxmax - wxmin) / (wymax - wymin)*h; + double dxmax = w - DMARGIN; + + PrepareTransformations(wxmin, wxmax, wymin, wymax, dxmin, dxmax, dymax, dymin); + + Canvas da = canvas; + da.Width = w; + da.Height = h; + + Polygon contour; + foreach (LwPolyline item in dxfEntitys) + { + dxfVertices = item.Vertexes; + Point pt; + contour = new Polygon + { + Points = new PointCollection(), + Stroke = Brushes.Black, + StrokeThickness = 2, + Fill = Brushes.White + }; + foreach (LwPolylineVertex v in dxfVertices) + { + pt = WtoDMatrix.Transform(new Point(v.Position.X, v.Position.Y)); + contour.Points.Add(pt); + } + da.Children.Add(contour); + //da.Children.Add(new Rectangle() { Width = 80, Height = 80,Stroke=Brushes.Black,StrokeThickness=1,Fill=Brushes.White }); + } + } + + static public void DrawFoundations(ObservableCollection founds, Canvas canvas, double h) + { + double dxmin = DMARGIN; + double dymin = DMARGIN; + double dymax = h - DMARGIN; + + double wxmin; + double wxmax; + double wymin; + double wymax; + + List Vertices = new List(); + foreach (Foundation item in founds) + { + if (item.Contour != null) Vertices.AddRange(item.Contour.Vertices); + } + + if (Vertices.Count < 4) return; + IOrderedEnumerable selected = from x in Vertices // определяем каждый объект как x + orderby x.X // упорядочиваем по возрастанию + select x; // выбираем объект + + wxmin = selected.First().X; + wxmax = selected.Last().X; + + selected = from y in Vertices orderby y.Y select y; + + wymin = selected.First().Y; + wymax = selected.Last().Y; + + double w = (wxmax - wxmin) / (wymax - wymin) * h; + double dxmax = w - DMARGIN; + + PrepareTransformations(wxmin, wxmax, wymin, wymax, dxmin, dxmax, dymax, dymin); + + Canvas da = canvas; + da.Width = w; + da.Height = h; + + Polygon contour; + foreach (Foundation item in founds) + { + if (item.Contour == null) continue; + ToolTip toolTip = new ToolTip(); + StackPanel toolTipPanel = new StackPanel(); + DataGrid props = new DataGrid() { ItemsSource = item.SmallProps, FontSize = 11 }; + //DataGrid results = new DataGrid() { ItemsSource = item.SmallResults}; + toolTipPanel.Children.Add(props); + //toolTipPanel.Children.Add(results); + toolTip.Content = toolTipPanel; + Vertices = item.Contour.Vertices; + Point pt; + contour = new Polygon + { + Points = new PointCollection(), + Stroke = Brushes.Black, + StrokeThickness = 2, + Fill = Brushes.White + }; + ToolTipService.SetToolTip(contour, toolTip); + ToolTipService.SetShowDuration(contour, int.MaxValue); + + foreach (Geo.Point3d v in Vertices) + { + pt = WtoDMatrix.Transform(new Point(v.X, v.Y)); + contour.Points.Add(pt); + } + da.Children.Add(contour); + + //da.Children.Add(new Rectangle() { Width = 80, Height = 80,Stroke=Brushes.Black,StrokeThickness=1,Fill=Brushes.White }); + } + } + static public void DrawFoundationsNumbers(ObservableCollection founds, Canvas canvas) + { + double dxmin = DMARGIN; + double dymin = DMARGIN; + double dymax = canvas.ActualHeight - DMARGIN; + double dxmax = canvas.ActualWidth - DMARGIN; + + double wxmin; + double wxmax; + double wymin; + double wymax; + + List Vertices = new List(); + foreach (Foundation item in founds) + { + if (item.Contour != null) Vertices.AddRange(item.Contour.Vertices); + } + + if (Vertices.Count < 4) return; + IOrderedEnumerable selected = from x in Vertices // определяем каждый объект как x + orderby x.X // упорядочиваем по возрастанию + select x; // выбираем объект + + wxmin = selected.First().X; + wxmax = selected.Last().X; + + selected = from y in Vertices orderby y.Y select y; + + wymin = selected.First().Y; + wymax = selected.Last().Y; + + PrepareTransformations(wxmin, wxmax, wymin, wymax, dxmin, dxmax, dymax, dymin); + + Canvas da = canvas; + + Label label; + foreach (Foundation item in founds) + { + Point pt = WtoDMatrix.Transform(new Point(item.X, item.Y)); + label = new Label + { + Content = item.Number.ToString(), + VerticalContentAlignment = VerticalAlignment.Center, + HorizontalContentAlignment = HorizontalAlignment.Center + }; + Canvas.SetTop(label, pt.Y); + Canvas.SetLeft(label, pt.X); + da.Children.Add(label); + + //da.Children.Add(new Rectangle() { Width = 80, Height = 80,Stroke=Brushes.Black,StrokeThickness=1,Fill=Brushes.White }); + } + } + + static void PrepareTransformations(double wxmin, double wxmax, double wymin, double wymax, double dxmin, double dxmax, double dymin, double dymax) + { + // Make WtoD. + WtoDMatrix = Matrix.Identity; + WtoDMatrix.Translate(-wxmin, -wymin); + + double xscale = (dxmax - dxmin) / (wxmax - wxmin); + double yscale = (dymax - dymin) / (wymax - wymin); + WtoDMatrix.Scale(xscale, yscale); + + WtoDMatrix.Translate(dxmin, dymin); + + // Make DtoW. + DtoWMatrix = WtoDMatrix; + DtoWMatrix.Invert(); + } + + + } +} diff --git a/Grapfics/RenderVisualService.cs b/Grapfics/RenderVisualService.cs new file mode 100644 index 0000000..fd66f15 --- /dev/null +++ b/Grapfics/RenderVisualService.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Media; +using System.Windows.Media.Imaging; + +namespace GroundOrganizer +{ + public static class RenderVisualService + { + private const double defaultDpi = 96.0; + + public static ImageSource RenderToPNGImageSource(Visual targetControl) + { + var renderTargetBitmap = GetRenderTargetBitmapFromControl(targetControl); + + var encoder = new PngBitmapEncoder(); + encoder.Frames.Add(BitmapFrame.Create(renderTargetBitmap)); + + var result = new BitmapImage(); + + using (var memoryStream = new MemoryStream()) + { + encoder.Save(memoryStream); + memoryStream.Seek(0, SeekOrigin.Begin); + + result.BeginInit(); + result.CacheOption = BitmapCacheOption.OnLoad; + result.StreamSource = memoryStream; + result.EndInit(); + } + + return result; + } + + public static void RenderToPNGFile(Visual targetControl, string filename) + { + var renderTargetBitmap = GetRenderTargetBitmapFromControl(targetControl); + + var encoder = new PngBitmapEncoder(); + encoder.Frames.Add(BitmapFrame.Create(renderTargetBitmap)); + + var result = new BitmapImage(); + + try + { + using (var fileStream = new FileStream(filename, FileMode.Create)) + { + encoder.Save(fileStream); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"There was an error saving the file: {ex.Message}"); + } + } + + private static BitmapSource GetRenderTargetBitmapFromControl(Visual targetControl, double dpi = defaultDpi) + { + if (targetControl == null) return null; + + var bounds = VisualTreeHelper.GetDescendantBounds(targetControl); + var renderTargetBitmap = new RenderTargetBitmap((int)(bounds.Width * dpi / 96.0), + (int)(bounds.Height * dpi / 96.0), + dpi, + dpi, + PixelFormats.Pbgra32); + + var drawingVisual = new DrawingVisual(); + + using (var drawingContext = drawingVisual.RenderOpen()) + { + var visualBrush = new VisualBrush(targetControl); + drawingContext.DrawRectangle(visualBrush, null, new Rect(new Point(), bounds.Size)); + } + + renderTargetBitmap.Render(drawingVisual); + return renderTargetBitmap; + } + } +} diff --git a/GroundOrganizer.csproj b/GroundOrganizer.csproj new file mode 100644 index 0000000..8f3573a --- /dev/null +++ b/GroundOrganizer.csproj @@ -0,0 +1,312 @@ + + + + + Debug + AnyCPU + {82435CCA-41F6-4074-8C93-A3DCDF9BA0E5} + WinExe + GroundOrganizer + GroundOrganizer + v4.7.2 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + Resources\business-color_books_icon-icons.com_53474.ico + + + + ..\packages\AForge.2.2.5\lib\AForge.dll + + + ..\packages\AForge.Math.2.2.5\lib\AForge.Math.dll + + + ..\packages\EPPlus.4.5.3.2\lib\net40\EPPlus.dll + + + ..\packages\netDXF.2.2.0.1\lib\net45\netDxf.dll + + + + + + + + + + + + + + + 4.0 + + + ..\..\..\..\OneDrive\Documents\C#\triangle\sourceCode\sourceCode\Triangle.NET\Triangle\bin\Debug\Triangle.dll + + + + + + + + MSBuild:Compile + Designer + + + + + FoundPropWindow.xaml + + + + + + + + + MainPage.xaml + + + TestWindow.xaml + + + + + + CanwasWindow.xaml + + + + ImageWindow.xaml + + + + AlertWindow.xaml + + + + + + + + + + + + + + + + + + + + + FoundationsPage.xaml + + + StructuresPage.xaml + + + + + + + + + + BoresPage.xaml + + + ResultsPage.xaml + + + IGEsPage.xaml + + + PlayGroundsPage.xaml + + + + + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + + + + MainWindow.xaml + Code + + + Designer + MSBuild:Compile + + + + + + 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/GroundOrganizer.sln b/GroundOrganizer.sln new file mode 100644 index 0000000..06ad610 --- /dev/null +++ b/GroundOrganizer.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35303.130 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GroundOrganizer", "GroundOrganizer.csproj", "{82435CCA-41F6-4074-8C93-A3DCDF9BA0E5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {82435CCA-41F6-4074-8C93-A3DCDF9BA0E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {82435CCA-41F6-4074-8C93-A3DCDF9BA0E5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {82435CCA-41F6-4074-8C93-A3DCDF9BA0E5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {82435CCA-41F6-4074-8C93-A3DCDF9BA0E5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {94A84522-F2BC-4F49-9D2C-711A3AAAD4BA} + EndGlobalSection +EndGlobal diff --git a/Images/Bookmark-add-icon32.png b/Images/Bookmark-add-icon32.png new file mode 100644 index 0000000..84ecc4e Binary files /dev/null and b/Images/Bookmark-add-icon32.png differ diff --git a/Images/Help-and-Support-icon32.png b/Images/Help-and-Support-icon32.png new file mode 100644 index 0000000..05d9ea1 Binary files /dev/null and b/Images/Help-and-Support-icon32.png differ diff --git a/Images/Save-icon32.png b/Images/Save-icon32.png new file mode 100644 index 0000000..b514374 Binary files /dev/null and b/Images/Save-icon32.png differ diff --git a/Images/Save_as-80_icon-icons.com32.png b/Images/Save_as-80_icon-icons.com32.png new file mode 100644 index 0000000..a430f9d Binary files /dev/null and b/Images/Save_as-80_icon-icons.com32.png differ diff --git a/Images/ShemaLoads.png b/Images/ShemaLoads.png new file mode 100644 index 0000000..b5907e2 Binary files /dev/null and b/Images/ShemaLoads.png differ diff --git a/Images/XLSX_export-32.png b/Images/XLSX_export-32.png new file mode 100644 index 0000000..cb50665 Binary files /dev/null and b/Images/XLSX_export-32.png differ diff --git a/Images/XLSX_import-32.png b/Images/XLSX_import-32.png new file mode 100644 index 0000000..95e4ade Binary files /dev/null and b/Images/XLSX_import-32.png differ diff --git a/Images/database-accept-icon.png b/Images/database-accept-icon.png new file mode 100644 index 0000000..8b23336 Binary files /dev/null and b/Images/database-accept-icon.png differ diff --git a/Images/drawing1_32.png b/Images/drawing1_32.png new file mode 100644 index 0000000..c3f6cec Binary files /dev/null and b/Images/drawing1_32.png differ diff --git a/Images/drawing32.png b/Images/drawing32.png new file mode 100644 index 0000000..c4a2875 Binary files /dev/null and b/Images/drawing32.png differ diff --git a/Images/icons8-export-csv-32.png b/Images/icons8-export-csv-32.png new file mode 100644 index 0000000..d251da2 Binary files /dev/null and b/Images/icons8-export-csv-32.png differ diff --git a/Images/icons8-import-csv-32.png b/Images/icons8-import-csv-32.png new file mode 100644 index 0000000..3a1c8a4 Binary files /dev/null and b/Images/icons8-import-csv-32.png differ diff --git a/Images/icons8-mesh-32 (1).png b/Images/icons8-mesh-32 (1).png new file mode 100644 index 0000000..9541b12 Binary files /dev/null and b/Images/icons8-mesh-32 (1).png differ diff --git a/Images/icons8-mesh-32.png b/Images/icons8-mesh-32.png new file mode 100644 index 0000000..ad9e40f Binary files /dev/null and b/Images/icons8-mesh-32.png differ diff --git a/Images/icons8-mesh-80_ed1.png b/Images/icons8-mesh-80_ed1.png new file mode 100644 index 0000000..f54f559 Binary files /dev/null and b/Images/icons8-mesh-80_ed1.png differ diff --git a/Images/icons8-spiderweb-32.png b/Images/icons8-spiderweb-32.png new file mode 100644 index 0000000..f8a3be3 Binary files /dev/null and b/Images/icons8-spiderweb-32.png differ diff --git a/Images/interfaceDXF.png b/Images/interfaceDXF.png new file mode 100644 index 0000000..2f22535 Binary files /dev/null and b/Images/interfaceDXF.png differ diff --git a/Images/table_1061_32.png b/Images/table_1061_32.png new file mode 100644 index 0000000..8569283 Binary files /dev/null and b/Images/table_1061_32.png differ diff --git a/Images/text-list-numbers-icon32.png b/Images/text-list-numbers-icon32.png new file mode 100644 index 0000000..c6df687 Binary files /dev/null and b/Images/text-list-numbers-icon32.png differ diff --git a/MainWindow.xaml b/MainWindow.xaml new file mode 100644 index 0000000..03378bc --- /dev/null +++ b/MainWindow.xaml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs new file mode 100644 index 0000000..dfee2f9 --- /dev/null +++ b/MainWindow.xaml.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Runtime.Serialization.Formatters.Binary; +using System.IO; +using System.Collections.ObjectModel; +using System.Windows.Controls.Ribbon; + +namespace GroundOrganizer +{ + /// + /// Логика взаимодействия для MainWindow.xaml + /// + public partial class MainWindow : Window + { + ViewModel vm; + public MainWindow() + { + InitializeComponent(); + vm = DataContext as ViewModel; + Top = 75; + Left = 75; + double ws = SystemParameters.PrimaryScreenWidth; + double hs = SystemParameters.PrimaryScreenHeight; + MaxWidth = ws - Left - 5; + MaxHeight = hs - Top - 40; + //this.SizeToContent = SizeToContent.Height; + Loaded += MainWindow_Loaded; + + } + + private void MainWindow_Loaded(object sender, RoutedEventArgs e) + { + if (File.Exists(Properties.Settings.Default.BasePath) == true) + { + // создаем объект BinaryFormatter + BinaryFormatter formatter = new BinaryFormatter(); + using (FileStream fs = new FileStream(Properties.Settings.Default.BasePath, FileMode.OpenOrCreate)) + { + ViewModel vm = (ViewModel)DataContext; + //ToSerializ ser = (ToSerializ)formatter.Deserialize(fs); + vm.ListPlayGround = formatter.Deserialize(fs) as ObservableCollection; + DataContext = vm; + } + } + } + + private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e) + { + vm.ReadDB(); + } + + //private void MainRibbon_SelectionChanged(object sender, SelectionChangedEventArgs e) + //{ + // if(contentFrame!=null) contentFrame.Content = null; + // if (HomeTab.IsSelected && contentFrame != null) contentFrame.Content = new MainPage(); + //} + } +} diff --git a/Pages/BoresPage.xaml b/Pages/BoresPage.xaml new file mode 100644 index 0000000..a57ddea --- /dev/null +++ b/Pages/BoresPage.xaml @@ -0,0 +1,300 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pages/IGEsPage.xaml.cs b/Pages/IGEsPage.xaml.cs new file mode 100644 index 0000000..287381b --- /dev/null +++ b/Pages/IGEsPage.xaml.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace GroundOrganizer +{ + /// + /// Логика взаимодействия для IGEsPage.xaml + /// + public partial class IGEsPage : Page + { + private ViewModel vm; + public IGEsPage() + { + InitializeComponent(); + vm = App.Current.MainWindow.DataContext as ViewModel; + DataContext = vm; + } + + private void ToCSV_Click(object sender, RoutedEventArgs e) + { + vm.SaveIGEsInCsv(); + } + + private void FromCSV_Click(object sender, RoutedEventArgs e) + { + vm.ReadIGEsFromCsv(); + } + } +} diff --git a/Pages/MainPage.xaml b/Pages/MainPage.xaml new file mode 100644 index 0000000..4a1375c --- /dev/null +++ b/Pages/MainPage.xaml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pages/MainPage.xaml.cs b/Pages/MainPage.xaml.cs new file mode 100644 index 0000000..9127835 --- /dev/null +++ b/Pages/MainPage.xaml.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace GroundOrganizer +{ + /// + /// Логика взаимодействия для MainPage.xaml + /// + public partial class MainPage : Page + { + public MainPage() + { + InitializeComponent(); + DataContext = App.Current.MainWindow.DataContext; + } + } +} diff --git a/Pages/PlayGroundsPage.xaml b/Pages/PlayGroundsPage.xaml new file mode 100644 index 0000000..361d5a5 --- /dev/null +++ b/Pages/PlayGroundsPage.xaml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pages/PlayGroundsPage.xaml.cs b/Pages/PlayGroundsPage.xaml.cs new file mode 100644 index 0000000..b34d2fd --- /dev/null +++ b/Pages/PlayGroundsPage.xaml.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace GroundOrganizer +{ + /// + /// Логика взаимодействия для PlayGroundsPage.xaml + /// + public partial class PlayGroundsPage : Page + { + private ViewModel vm; + public PlayGroundsPage() + { + InitializeComponent(); + DataContext = App.Current.MainWindow.DataContext; + vm = DataContext as ViewModel; + } + } +} diff --git a/Pages/ResultsPage.cs b/Pages/ResultsPage.cs new file mode 100644 index 0000000..a49cbc3 --- /dev/null +++ b/Pages/ResultsPage.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace GroundOrganizer +{ + /// + /// Логика взаимодействия для CalculationsPage.xaml + /// + public partial class ResultsPage : Page + { + ViewModel vm; + public ResultsPage() + { + InitializeComponent(); + DataContext = App.Current.MainWindow.DataContext; + vm = DataContext as ViewModel; + } + } +} diff --git a/Pages/ResultsPage.xaml b/Pages/ResultsPage.xaml new file mode 100644 index 0000000..be239b0 --- /dev/null +++ b/Pages/ResultsPage.xaml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + diff --git a/Pages/StructuresPage.xaml b/Pages/StructuresPage.xaml new file mode 100644 index 0000000..ddf7bc8 --- /dev/null +++ b/Pages/StructuresPage.xaml @@ -0,0 +1,350 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pages/StructuresPage.xaml.cs b/Pages/StructuresPage.xaml.cs new file mode 100644 index 0000000..59f5400 --- /dev/null +++ b/Pages/StructuresPage.xaml.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace GroundOrganizer +{ + /// + /// Логика взаимодействия для StructuresPage.xaml + /// + public partial class StructuresPage : Page + { + private ViewModel vm; + public StructuresPage() + { + InitializeComponent(); + DataContext = App.Current.MainWindow.DataContext; + vm = DataContext as ViewModel; + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8e7085f --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// Общие сведения об этой сборке предоставляются следующим набором +// набор атрибутов. Измените значения этих атрибутов, чтобы изменить сведения, +// связанные со сборкой. +[assembly: AssemblyTitle("GroundOrganizer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("GroundOrganizer")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// из модели COM, установите атрибут ComVisible для этого типа в значение true. +[assembly: ComVisible(false)] + +//Чтобы начать создание локализуемых приложений, задайте +//CultureYouAreCodingWith в файле .csproj +//в . Например, при использовании английского (США) +//в своих исходных файлах установите в en-US. Затем отмените преобразование в комментарий +//атрибута NeutralResourceLanguage ниже. Обновите "en-US" в +//строка внизу для обеспечения соответствия настройки UICulture в файле проекта. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //где расположены словари ресурсов по конкретным тематикам + //(используется, если ресурс не найден на странице, + // или в словарях ресурсов приложения) + ResourceDictionaryLocation.SourceAssembly //где расположен словарь универсальных ресурсов + //(используется, если ресурс не найден на странице, + // в приложении или в каких-либо словарях ресурсов для конкретной темы) +)] + + +// Сведения о версии для сборки включают четыре следующих значения: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Номер редакции +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..712bed2 --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,140 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace GroundOrganizer.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.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() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GroundOrganizer.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Icon, аналогичного (Значок). + /// + internal static System.Drawing.Icon business_color_books_icon_icons_com_53474 { + get { + object obj = ResourceManager.GetObject("business_color_books_icon_icons_com_53474", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Byte[]. + /// + internal static byte[] IGE { + get { + object obj = ResourceManager.GetObject("IGE", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ShemaFound { + get { + object obj = ResourceManager.GetObject("ShemaFound", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ShemaLoads { + get { + object obj = ResourceManager.GetObject("ShemaLoads", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Ищет локализованную строку, похожую на 0;0;1;3.14 + ///1;0.01;1.06;3.23 + ///2;0.03;1.12;3.32 + ///3;0.04;1.18;3.41 + ///4;0.06;1.25;3.51 + ///5;0.08;1.32;3.61 + ///6;0.1;1.39;3.71 + ///7;0.12;1.47;3.82 + ///8;0.14;1.55;3.93 + ///9;0.16;1.64;4.05 + ///10;0.18;1.73;4.17 + ///11;0.21;1.83;4.29 + ///12;0.23;1.94;4.42 + ///13;0.26;2.05;4.55 + ///14;0.29;2.17;4.69 + ///15;0.32;2.3;4.84 + ///16;0.36;2.43;4.99 + ///17;0.39;2.57;5.15 + ///18;0.43;2.73;5.31 + ///19;0.47;2.89;5.48 + ///20;0.51;3.06;5.66 + ///21;0.56;3.24;5.84 + ///22;0.61;3.44;6.04 + ///23;0.66;3.65;6.24 + ///24;0.72;3.87;6.45 + ///25;0.78;4.11;6.67 + ///26;0.84;4.37;6.9 + ///27;0.91;4.64;7.14 + /// [остаток строки не уместился]";. + /// + internal static string tabl_5_5 { + get { + return ResourceManager.GetString("tabl_5_5", resourceCulture); + } + } + } +} diff --git a/Properties/Resources.resx b/Properties/Resources.resx new file mode 100644 index 0000000..9c1decf --- /dev/null +++ b/Properties/Resources.resx @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\business-color_books_icon-icons.com_53474.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\tabl_5_5.csv;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + + ..\Resources\ShemaFound.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ShemaLoads.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ИГЭ.xlsx;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs new file mode 100644 index 0000000..4f409d0 --- /dev/null +++ b/Properties/Settings.Designer.cs @@ -0,0 +1,38 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace GroundOrganizer.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.1.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; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string BasePath { + get { + return ((string)(this["BasePath"])); + } + set { + this["BasePath"] = value; + } + } + } +} diff --git a/Properties/Settings.settings b/Properties/Settings.settings new file mode 100644 index 0000000..f81cf61 --- /dev/null +++ b/Properties/Settings.settings @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Resources/ShemaFound.png b/Resources/ShemaFound.png new file mode 100644 index 0000000..89fa095 Binary files /dev/null and b/Resources/ShemaFound.png differ diff --git a/Resources/ShemaLoads.png b/Resources/ShemaLoads.png new file mode 100644 index 0000000..2b20786 Binary files /dev/null and b/Resources/ShemaLoads.png differ diff --git a/Resources/business-color_books_icon-icons.com_53474.ico b/Resources/business-color_books_icon-icons.com_53474.ico new file mode 100644 index 0000000..152f802 Binary files /dev/null and b/Resources/business-color_books_icon-icons.com_53474.ico differ diff --git a/Resources/tabl_5_5.csv b/Resources/tabl_5_5.csv new file mode 100644 index 0000000..136a814 --- /dev/null +++ b/Resources/tabl_5_5.csv @@ -0,0 +1,46 @@ +0;0;1;3.14 +1;0.01;1.06;3.23 +2;0.03;1.12;3.32 +3;0.04;1.18;3.41 +4;0.06;1.25;3.51 +5;0.08;1.32;3.61 +6;0.1;1.39;3.71 +7;0.12;1.47;3.82 +8;0.14;1.55;3.93 +9;0.16;1.64;4.05 +10;0.18;1.73;4.17 +11;0.21;1.83;4.29 +12;0.23;1.94;4.42 +13;0.26;2.05;4.55 +14;0.29;2.17;4.69 +15;0.32;2.3;4.84 +16;0.36;2.43;4.99 +17;0.39;2.57;5.15 +18;0.43;2.73;5.31 +19;0.47;2.89;5.48 +20;0.51;3.06;5.66 +21;0.56;3.24;5.84 +22;0.61;3.44;6.04 +23;0.66;3.65;6.24 +24;0.72;3.87;6.45 +25;0.78;4.11;6.67 +26;0.84;4.37;6.9 +27;0.91;4.64;7.14 +28;0.98;4.93;7.4 +29;1.06;5.25;7.67 +30;1.15;5.59;7.95 +31;1.24;5.95;8.24 +32;1.34;6.34;8.55 +33;1.44;6.76;8.88 +34;1.55;7.22;9.22 +35;1.68;7.71;9.58 +36;1.81;8.24;9.97 +37;1.95;8.81;10.37 +38;2.11;9.44;10.8 +39;2.28;10.11;11.25 +40;2.46;10.85;11.73 +41;2.66;11.64;12.24 +42;2.88;12.51;12.79 +43;3.12;13.46;13.37 +44;3.38;14.5;13.98 +45;3.66;15.64;14.64 diff --git a/Resources/Аннотация 2019-06-14 145047.png b/Resources/Аннотация 2019-06-14 145047.png new file mode 100644 index 0000000..c402ed7 Binary files /dev/null and b/Resources/Аннотация 2019-06-14 145047.png differ diff --git a/Resources/ИГЭ.xlsx b/Resources/ИГЭ.xlsx new file mode 100644 index 0000000..00b06f3 Binary files /dev/null and b/Resources/ИГЭ.xlsx differ diff --git a/Settings.cs b/Settings.cs new file mode 100644 index 0000000..2b3a565 --- /dev/null +++ b/Settings.cs @@ -0,0 +1,28 @@ +namespace GroundOrganizer.Properties { + + + // Этот класс позволяет обрабатывать определенные события в классе параметров: + // Событие SettingChanging возникает перед изменением значения параметра. + // Событие PropertyChanged возникает после изменения значения параметра. + // Событие SettingsLoaded возникает после загрузки значений параметров. + // Событие SettingsSaving возникает перед сохранением значений параметров. + internal sealed partial class Settings { + + public Settings() { + // // Для добавления обработчиков событий для сохранения и изменения параметров раскомментируйте приведенные ниже строки: + // + // this.SettingChanging += this.SettingChangingEventHandler; + // + // this.SettingsSaving += this.SettingsSavingEventHandler; + // + } + + private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { + // Добавьте здесь код для обработки события SettingChangingEvent. + } + + private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { + // Добавьте здесь код для обработки события SettingsSaving. + } + } +} diff --git a/TestWindow.xaml b/TestWindow.xaml new file mode 100644 index 0000000..40aaa43 --- /dev/null +++ b/TestWindow.xaml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TestWindow.xaml.cs b/TestWindow.xaml.cs new file mode 100644 index 0000000..f8315b5 --- /dev/null +++ b/TestWindow.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Ribbon; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace GroundOrganizer +{ + /// + /// Логика взаимодействия для TestWindow.xaml + /// + public partial class TestWindow : RibbonWindow + { + public TestWindow() + { + InitializeComponent(); + } + } +} diff --git a/VM/BoresVM.cs b/VM/BoresVM.cs new file mode 100644 index 0000000..2061e52 --- /dev/null +++ b/VM/BoresVM.cs @@ -0,0 +1,208 @@ +using Microsoft.Win32; +using OfficeOpenXml; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TriangleNet.Geometry; +using TriangleNet.Meshing; + +namespace GroundOrganizer +{ + public partial class ViewModel : INotifyPropertyChanged + { + private RelayCommand addBore; + private RelayCommand renumBore; + private RelayCommand updateBore; + private RelayCommand createBoresMesh; + private RelayCommand importBoresFromXLSX; + private RelayCommand exportBoresToXLSX; + + int numBore = 1; + string nameBore; + private string boresNote; + Bore selectedBore; + ObservableCollection listBore = new ObservableCollection(); + public string BoresNote { get => boresNote; set { boresNote = value; OnPropertyChanged(); } } + + public Bore SelectedBore { get => selectedBore; set { selectedBore = value; OnPropertyChanged(); ChangeSelectedBore(); } } + + public string NameBore { get => nameBore; set { nameBore = value; OnPropertyChanged(); } } + + public ObservableCollection ListBore { get => listBore; set { listBore = value; OnPropertyChanged(); } } + public TriangleNet.Mesh MeshBores { get; private set; } + + + public RelayCommand AddBore + { + get { return addBore ?? (addBore = new RelayCommand(obj => { AddBoreToList(); })); } + } + + public RelayCommand UpdateBores + { + get { return updateBore ?? (updateBore = new RelayCommand(obj => { UpdateBoreInList(); })); } + } + + public RelayCommand RenumBores + { + get { return renumBore ?? (renumBore = new RelayCommand(obj => { RenumberingBoreInList(); })); } + } + + public RelayCommand CreateBoresMesh + { + get { return createBoresMesh ?? (createBoresMesh = new RelayCommand(obj => { CreateMeshBores(); })); } + } + + public RelayCommand ExportBoresToXLSX + { + get { return exportBoresToXLSX ?? (exportBoresToXLSX = new RelayCommand(obj => { SaveBoresInXlsx(); })); } + } + + public RelayCommand ImportBoresFromXLSX + { + get { return importBoresFromXLSX ?? (importBoresFromXLSX = new RelayCommand(obj => { ReadBoresFromXlsx(); })); } + } + + //Чтение таблицы набора скважин из файла *.xlsx + internal void ReadBoresFromXlsx() + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.DefaultExt = "*.xlsx"; + ofd.Filter = "Файл Excel (*.xlsx)|*.xlsx"; + ofd.Title = "Заполнение таблицы"; + ofd.ShowDialog(); + + if (ofd.FileName == null || ofd.FileName == "") return; + + //ListIGE.Clear(); + + using (var p = new ExcelPackage(new FileInfo(ofd.FileName))) + { + //A workbook must have at least on cell, so lets add one... + var ws = p.Workbook.Worksheets["Скважины"]; + + object[,] content = ws.Cells.Value as object[,]; + List source; Bore item; + for (int i = 1; i < content.GetLength(0); i++) + { + source = new List(); + for (int j = 0; j < content.GetLength(1); j++) + { + source.Add(content[i, j]); + } + item = new Bore(); item.ListToProps(source); + ListBore.Add(item); + } + } + } + + //Сохранение таблицы набора ИГЭ в файл *.csv + internal void SaveBoresInXlsx() + { + SaveFileDialog sfd = new SaveFileDialog(); + sfd.DefaultExt = "*.xlsx"; + sfd.Filter = "Файл Excel (*.xlsx)|*.xlsx"; + sfd.Title = "Сохранение таблицы"; + //sfd.AddExtension = true; + sfd.OverwritePrompt = false; + sfd.ShowDialog(); + + if (sfd.FileName == null || sfd.FileName == "") return; + + string path = "ИГЭ.xlsx"; + FileInfo fileInf = new FileInfo(path); + if (fileInf.Exists != true) + { + using (FileStream fstream = new FileStream("ИГЭ.xlsx", FileMode.OpenOrCreate)) + { + byte[] array = Properties.Resources.IGE; + fstream.Write(array, 0, array.Length); + } + } + List content = new List(); + foreach (Bore item in listBore) + { + content.Add(item.PropsToList().ToArray()); + } + + using (var p = new ExcelPackage(new FileInfo(sfd.FileName))) + { + try + { + var ws = p.Workbook.Worksheets["Скважины"]; + + //To set values in the spreadsheet use the Cells indexer. + ws.Cells["A2"].LoadFromArrays(content); + + //Save the new workbook. We haven't specified the filename so use the Save as method. + p.SaveAs(new FileInfo(sfd.FileName)); + } + catch + { + ExcelPackage p1 = new ExcelPackage(new FileInfo("ИГЭ.xlsx")); + ExcelWorksheet ws1 = p1.Workbook.Worksheets["Скважины"]; + p.Workbook.Worksheets.Add("Скважины", ws1); + ExcelWorksheet ws = p.Workbook.Worksheets["Скважины"]; + + //Save the new workbook. We haven't specified the filename so use the Save as method. + ws.Cells["A2"].LoadFromArrays(content); + ws.Select(); + p.SaveAs(new FileInfo(sfd.FileName)); + } + } + } + + private void CreateMeshBores() + { + if (listBore == null || listBore.Count == 0) return; + + Polygon polygon = new Polygon(); + Vertex vrtx; + int i = 1; + foreach (Bore item in listBore) + { + vrtx = new Vertex(item.X, item.Y, item.Number, 2); + polygon.Add(vrtx); + i++; + } + + ConstraintOptions constraint = new ConstraintOptions() { Convex = true }; + MeshBores = (TriangleNet.Mesh)polygon.Triangulate(constraint); + Alert("Триангуляционная сеть скважин создана"); + } + + void AddBoreToList() + { + ListBore.Add(new Bore() { Number = numBore }); numBore++; + //CreateListNumberTypeBet(); + //NameBore = listBore[0].Name; + } + void RenumberingBoreInList() + { + int j = 1; + foreach (Bore item in ListBore) + { + item.Number = j; + j++; + } + numBore = j; + ListBore = new ObservableCollection(ListBore); + } + void UpdateBoreInList() + { + ListBore = new ObservableCollection(ListBore); + SaveDB(); + } + + void ChangeSelectedBore() + { + if (listBore.Count == 0 || selectedBore == null) return; + NameBore = selectedBore.Name; + ListLayer = selectedBore.Layers; + } + } +} diff --git a/VM/CalculationsVM.cs b/VM/CalculationsVM.cs new file mode 100644 index 0000000..ab8d11b --- /dev/null +++ b/VM/CalculationsVM.cs @@ -0,0 +1,175 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Interop; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using Microsoft.Win32; +using netDxf; +using netDxf.Entities; + +namespace GroundOrganizer +{ + public partial class ViewModel : INotifyPropertyChanged + { + private RelayCommand calcFoundsContours; + private RelayCommand calcRinBore; + private RelayCommand calcRinBores; + private RelayCommand calcRinCoords; + private RelayCommand calcSpInBore; + private RelayCommand calcSpInBores; + + private ObservableCollection resR; + private ObservableCollection resS; + private List resSdata; + private List resRdata; + private DataR resRselected; + private List listTypeFounds; + + public DataR ResRselected { get => resRselected; set { resRselected = value; OnPropertyChanged(); ChangeSelectedResults(); } } + public ObservableCollection ResR { get => resR; set { resR = value; OnPropertyChanged(); } } + public ObservableCollection ResS { get => resS; set { resS = value; OnPropertyChanged(); } } + public List ResRdata { get => resRdata; set { resRdata = value; OnPropertyChanged(); } } + public List ResSdata { get => resSdata; set { resSdata = value; OnPropertyChanged(); } } + + public RelayCommand CalcFoundsContours + { + get { return calcFoundsContours ?? (calcFoundsContours = new RelayCommand(obj => { CalculateContoursFounds(); })); } + } + + public RelayCommand CalcRinBore + { + get { return calcRinBore ?? (calcRinBore = new RelayCommand(obj => { CalculateRinBore(); })); } + } + + public RelayCommand CalcRinBores + { + get { return calcRinBores ?? (calcRinBores = new RelayCommand(obj => { CalculateRinBores(); })); } + } + + public RelayCommand CalcRinCoords + { + get { return calcRinCoords ?? (calcRinCoords = new RelayCommand(obj => { CalculateRinCoords(); })); } + } + + public RelayCommand CalcSpInBore + { + get { return calcSpInBore ?? (calcSpInBore = new RelayCommand(obj => { CalculateSpInBore(); })); } + } + + public RelayCommand CalcSpInBores + { + get { return calcSpInBores ?? (calcSpInBores = new RelayCommand(obj => { CalculateSpInBores(); })); } + } + + private void CalculateContoursFounds() + { + if (listFoundation == null || listFoundation.Count == 0) return; + + foreach (Foundation item in listFoundation) item.CalcContour(); + ListFoundation = new ObservableCollection(listFoundation); + } + + void ChangeSelectedResults() + { + if (resR == null || resR.Count == 0) return; + ResRdata = resRselected.SmallData; + } + + void CalculateSpInBore() + { + if (selectedBore == null) { Alert("Не выбрана расчетная скважина"); return; } + if (selectedFoundation == null) { Alert("Не выбран фундамент для расчета"); return; } + if (selectedFoundLoad == null) { Alert("Не выбрана расчетная нагрузка"); return; } + if (resS == null) ResS = new ObservableCollection(); + ResS.Clear(); + DataS s = selectedFoundation.Sp(selectedBore, selectedFoundLoad); + s.Bore = "Скв. " + nameBore; + s.Base = nameFoundation; + ResS.Add(s); + ResultsPage resPage = new ResultsPage(); + MW.ResulsFrame.Content = resPage; + resPage.ResultsDataGrid.ItemsSource = ResS; + MW.MainTabControl.SelectedIndex = 5; + //FoundationsPage foundPage = (FoundationsPage)MW.FoundationsFrame.Content; + //resPage.resultExpander.IsExpanded = true; + } + + void CalculateSpInBores() + { + if (listBore == null) { Alert("Площадка не содержит ни одной скважины"); return; } + if (selectedFoundation == null) { Alert("Не выбран фундамент для расчета"); return; } + if (selectedFoundLoad == null) { Alert("Не выбрана расчетная нагрузка"); return; } + if (resS == null) ResS = new ObservableCollection(); + ResS.Clear(); + foreach (Bore item in listBore) + { + DataS s = selectedFoundation.Sp(item, selectedFoundLoad); + s.Bore = "Скв. " + item.Name; + s.Base = nameFoundation; + ResS.Add(s); + } + ResultsPage resPage = new ResultsPage(); + MW.ResulsFrame.Content = resPage; + resPage.ResultsDataGrid.ItemsSource = ResS; + MW.MainTabControl.SelectedIndex = 5; + //FoundationsPage foundPage = (FoundationsPage)MW.FoundationsFrame.Content; + //foundPage.ResultsDataGrid.ItemsSource = ResS; + //foundPage.resultExpander.IsExpanded = true; + + } + + void CalculateRinBore() + { + if (selectedBore == null) { Alert("Не выбрана расчетная скважина"); return; } + if (selectedFoundation == null) { Alert("Не выбран фундамент для расчета"); return; } + if (resR == null) ResR = new ObservableCollection(); + ResR.Clear(); + DataR r = selectedFoundation.P(selectedBore, selectedStructure.flexStructure, selectedStructure.L, selectedStructure.H); + ResR.Add(r); + ResultsPage resPage = new ResultsPage(); + MW.ResulsFrame.Content = resPage; + //resPage.ResultsDataGrid.ItemsSource = ResR; + //resPage.DetailedResultsDataGrid.ItemsSource = ResRdata; + MW.MainTabControl.SelectedIndex = 5; + //FoundationsPage foundPage = (FoundationsPage)MW.FoundationsFrame.Content; + //foundPage.ResultsDataGrid.ItemsSource = ResR; + //foundPage.resultExpander.IsExpanded = true; + } + + private void CalculateRinBores() + { + if (listBore == null) { Alert("Площадка не содержит ни одной скважины"); return; } + if (selectedFoundation == null) { Alert("Не выбран фундамент для расчета"); return; } + ResR = selectedFoundation.P(ListBore, selectedStructure.flexStructure, selectedStructure.L, selectedStructure.H); + ResultsPage resPage = new ResultsPage(); + MW.ResulsFrame.Content = resPage; + //resPage.ResultsDataGrid.ItemsSource = ResR; + //resPage.DetailedResultsDataGrid.ItemsSource = ResRdata; + MW.MainTabControl.SelectedIndex = 5; + //FoundationsPage foundPage = (FoundationsPage)MW.FoundationsFrame.Content; + //foundPage.ResultsDataGrid.ItemsSource = ResR; + //foundPage.resultExpander.IsExpanded = true; + } + + private void CalculateRinCoords() + { + if (selectedBore == null) return; + if (resR == null) ResR = new ObservableCollection(); + ResR.Clear(); + DataR r = SelectedFoundation.P(selectedBore, selectedStructure.flexStructure, selectedStructure.L, selectedStructure.H); + r.Bore = "По координатам"; + r.Base = nameFoundation; + ResR.Add(r); + //FoundationsPage foundPage = (FoundationsPage)MW.FoundationsFrame.Content; + //foundPage.ResultsDataGrid.ItemsSource = ResR; + //foundPage.resultExpander.IsExpanded = true; + } + } +} diff --git a/VM/DrawingVM.cs b/VM/DrawingVM.cs new file mode 100644 index 0000000..d7d3aaf --- /dev/null +++ b/VM/DrawingVM.cs @@ -0,0 +1,81 @@ +using netDxf; +using netDxf.Entities; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Interop; +using System.Windows.Media.Imaging; + +namespace GroundOrganizer +{ + public partial class ViewModel : INotifyPropertyChanged + { + + private RelayCommand drowFoundations; + private RelayCommand showFoundProps; + + CanwasWindow cw; + + public RelayCommand DrowFoundations + { + get { return drowFoundations ?? (drowFoundations = new RelayCommand(obj => { DrowFounds(); })); } + } + + public RelayCommand ShowFoundProps + { + get { return showFoundProps ?? (showFoundProps = new RelayCommand(obj => { ShowFoundPropsWindow(); })); } + } + + internal void ShowFoundPropsWindow() + { + if (listFoundation.Count == 0) return; + if (listFoundation == null) return; + + FoundPropWindow fpw = new FoundPropWindow(); + fpw.Owner = MW; + fpw.DataContext = MW.DataContext; + fpw.Top = 75; + fpw.Left = 75; + fpw.ShowDialog(); + } + + internal void DrowFounds() + { + if (listFoundation.Count == 0) return; + if (listFoundation == null) return; + + CalculateContoursFounds(); + CreateSmallPropsFounds(); + int t = 75; + int l = 75; + double ws = SystemParameters.PrimaryScreenWidth; + double hs = SystemParameters.PrimaryScreenHeight; + cw = new CanwasWindow(); + cw.Top = t; + cw.Left = l; + cw.MaxHeight= hs - t - 37; + cw.MaxWidth= ws - l - 5; + cw.CanvasScrollViewer.MaxWidth = cw.MaxWidth; + cw.CanvasScrollViewer.MaxHeight = cw.MaxHeight-60; + cw.Owner = MW; + CanvasDrafter.DrawFoundations(listFoundation, cw.drawArea, cw.MaxHeight - 120); + cw.drawArea.MinHeight = cw.drawArea.Height; + cw.drawArea.MinWidth = cw.drawArea.Width; + cw.EventMouseEnter(); + cw.Show(); + } + + internal void DrowFoundsNums() + { + if (cw == null || cw.IsActive == false) return; + CanvasDrafter.DrawFoundationsNumbers(listFoundation, cw.drawArea); + } + } +} diff --git a/VM/FoundLoadsVM.cs b/VM/FoundLoadsVM.cs new file mode 100644 index 0000000..02ca0da --- /dev/null +++ b/VM/FoundLoadsVM.cs @@ -0,0 +1,188 @@ +using Microsoft.Win32; +using OfficeOpenXml; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GroundOrganizer +{ + public partial class ViewModel : INotifyPropertyChanged + { + private RelayCommand addFoundLoad; + private RelayCommand updateFoundLoad; + private RelayCommand renumFoundLoad; + private RelayCommand exportFoundLoadsToCSV; + private RelayCommand importFoundLoadsFromCSV; + + int numFoundLoad = 1; + string nameFoundLoad; + FoundLoad selectedFoundLoad; + ObservableCollection listFoundLoad = new ObservableCollection(); + + public ObservableCollection ListFoundLoad { get => listFoundLoad; set { listFoundLoad = value; OnPropertyChanged(); } } + + + public RelayCommand AddFoundLoad + { + get { return addFoundLoad ?? (addFoundLoad = new RelayCommand(obj => { AddFoundLoadToList(); })); } + } + + public RelayCommand UpdateFoundLoads + { + get { return updateFoundLoad ?? (updateFoundLoad = new RelayCommand(obj => { UpdateFoundLoadInList(); })); } + } + + public RelayCommand RenumFoundLoads + { + get { return renumFoundLoad ?? (renumFoundLoad = new RelayCommand(obj => { RenumberingFoundLoadInList(); })); } + } + + public RelayCommand ExportFoundLoadsToCSV + { + get { return exportFoundLoadsToCSV ?? (exportFoundLoadsToCSV = new RelayCommand(obj => { SaveLoadsInXlsx(); })); } + } + + public RelayCommand ImportFoundLoadsFromCSV + { + get { return importFoundLoadsFromCSV ?? (importFoundLoadsFromCSV = new RelayCommand(obj => { ReadLoadsFromXlsx(); })); } + } + public FoundLoad SelectedFoundLoad { get => selectedFoundLoad; set { selectedFoundLoad = value; OnPropertyChanged(); ChangeSelectedFoundLoad(); } } + + public string NameFoundLoad { get => nameFoundLoad; set { nameFoundLoad = value; OnPropertyChanged(); } } + + void AddFoundLoadToList() + { + ListFoundLoad.Add(new FoundLoad() { Number = numFoundLoad }); numFoundLoad++; + //CreateListNumberTypeBet(); + //NameFoundLoad = listFoundLoad[0].Name; + } + void RenumberingFoundLoadInList() + { + int j = 1; + foreach (FoundLoad item in ListFoundLoad) + { + item.Number = j; + j++; + } + numFoundLoad = j; + ListFoundLoad = new ObservableCollection(ListFoundLoad); + SaveDB(); + } + internal void UpdateFoundLoadInList() + { + ListFoundLoad = new ObservableCollection(ListFoundLoad); + SaveDB(); + } + + void ChangeSelectedFoundLoad() + { + if (listFoundLoad.Count == 0 || selectedFoundLoad == null) return; + NameFoundLoad = SelectedFoundLoad.Number.ToString(); + } + + //Сохранение таблицы нагрузок в файл *.xlsx + internal void SaveLoadsInXlsx() + { + SaveFileDialog sfd = new SaveFileDialog(); + sfd.DefaultExt = "*.xlsx"; + sfd.Filter = "Файл Excel (*.xlsx)|*.xlsx"; + sfd.Title = "Сохранение таблицы"; + //sfd.AddExtension = true; + sfd.OverwritePrompt = true; + sfd.ShowDialog(); + + if (sfd.FileName == null || sfd.FileName == "") return; + + try + { + string path = "ИГЭ.xlsx"; + FileInfo fileInf = new FileInfo(path); + if (fileInf.Exists != true) + { + using (FileStream fstream = new FileStream("ИГЭ.xlsx", FileMode.OpenOrCreate)) + { + byte[] array = Properties.Resources.IGE; + fstream.Write(array, 0, array.Length); + } + } + + + using (var p = new ExcelPackage(new FileInfo(sfd.FileName))) + { + for (int i = 0; i < listFoundation.Count; i++) + { + List content = new List(); + foreach (FoundLoad fli in listFoundation[i].Loads) + { + content.Add(fli.PropsToList().ToArray()); + } + ExcelPackage p1 = new ExcelPackage(new FileInfo("ИГЭ.xlsx")); + //A workbook must have at least on cell, so lets add one... + var ws = p1.Workbook.Worksheets["Нагрузки"]; + p.Workbook.Worksheets.Add((i + 1).ToString(), ws); + var wsi = p.Workbook.Worksheets[i + 1]; + //To set values in the spreadsheet use the Cells indexer. + wsi.Cells["D1"].Value = listFoundation[i].Number; + wsi.Cells["F1"].Value = listFoundation[i].Name; + wsi.Cells["A3"].LoadFromArrays(content); + } + + //Save the new workbook. We haven't specified the filename so use the Save as method. + p.SaveAs(new FileInfo(sfd.FileName)); + } + } + catch (Exception e) + { + Alert(e.Message); + } + } + + //Чтение нагрузок из файла *.xlsx + internal void ReadLoadsFromXlsx() + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.DefaultExt = "*.xlsx"; + ofd.Filter = "Файл Excel (*.xlsx)|*.xlsx"; + ofd.Title = "Заполнение таблиц"; + ofd.ShowDialog(); + + if (ofd.FileName == null || ofd.FileName == "") return; + + //ListFoundLoad.Clear(); + try + { + using (var p = new ExcelPackage(new FileInfo(ofd.FileName))) + { + int k = 0; + foreach (ExcelWorksheet wsi in p.Workbook.Worksheets) + { + listFoundation[k].Loads = new ObservableCollection(); + + object[,] content = wsi.Cells.Value as object[,]; + List source; FoundLoad item; + for (int i = 2; i < content.GetLength(0); i++) + { + source = new List(); + for (int j = 0; j < content.GetLength(1); j++) + { + source.Add(content[i, j]); + } + item = new FoundLoad(); item.ListToProps(source); + listFoundation[k].Loads.Add(item); + } + k++; + } + } + } + catch (Exception e) + { + Alert(e.Message); + } + } + } +} diff --git a/VM/FoundationsVM.cs b/VM/FoundationsVM.cs new file mode 100644 index 0000000..38e9a4c --- /dev/null +++ b/VM/FoundationsVM.cs @@ -0,0 +1,401 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Interop; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using Geo; +using Microsoft.Win32; +using netDxf; +using netDxf.Entities; +using OfficeOpenXml; + +namespace GroundOrganizer +{ + public partial class ViewModel : INotifyPropertyChanged + { + private RelayCommand addFoundation; + private RelayCommand updateFoundation; + private RelayCommand renumFoundation; + private RelayCommand importFoundationsFromDXF; + private RelayCommand replaceD1Found; + private RelayCommand replaceDLFound; + private RelayCommand replaceFLFound; + private RelayCommand replaceDLFoundfromNULL; + private RelayCommand calculateDLFound; + private RelayCommand calculateLevelsFounds; + private RelayCommand exportFoundationsToCSV; + private RelayCommand importFoundationsFromCSV; + + private double d1; + private double dL; + private double fL; + + int numFoundation = 1; + string nameFoundation; + Foundation selectedFoundation; + ObservableCollection listFoundation = new ObservableCollection(); + List bufferFoundations = new List(); + + public double D1 { get => d1; set { d1 = value; OnPropertyChanged(); /*ChangeD1();*/ } } + public double DL { get => dL; set { dL = value; OnPropertyChanged(); /*ChangeDL();*/ } } + public double FL { get => fL; set { fL = value; OnPropertyChanged(); /*ChangeFL();*/ } } + + + public ObservableCollection ListFoundation { get => listFoundation; set { listFoundation = value; OnPropertyChanged(); } } + public Foundation SelectedFoundation { get => selectedFoundation; set { selectedFoundation = value; OnPropertyChanged(); ChangeSelectedFoundation(); } } + public string NameFoundation { get => nameFoundation; set { nameFoundation = value; OnPropertyChanged(); ChangeMark(); } } + public List ListTypeFounds { get => listTypeFounds; set { listTypeFounds = value; OnPropertyChanged(); } } + public List BufferFoundations { get => bufferFoundations; set => bufferFoundations = value; } + + #region Команды + + public RelayCommand AddFoundation + { + get { return addFoundation ?? (addFoundation = new RelayCommand(obj => { AddFoundationToList(); })); } + } + + public RelayCommand UpdateFoundations + { + get { return updateFoundation ?? (updateFoundation = new RelayCommand(obj => { UpdateFoundationInList(); })); } + } + + public RelayCommand RenumFoundations + { + get { return renumFoundation ?? (renumFoundation = new RelayCommand(obj => { RenumberingFoundationInList(); })); } + } + + public RelayCommand ImportFoundationsFromDXF + { + get { return importFoundationsFromDXF ?? (importFoundationsFromDXF = new RelayCommand(obj => { ReadFondationsFromDXF(); })); } + } + + public RelayCommand ReplaceD1Found + { + get { return replaceD1Found ?? (replaceD1Found = new RelayCommand(obj => { ChangeD1(); })); } + } + + public RelayCommand ReplaceDLFound + { + get { return replaceDLFound ?? (replaceDLFound = new RelayCommand(obj => { ChangeDL(); })); } + } + + public RelayCommand ReplaceFLFound + { + get { return replaceFLFound ?? (replaceFLFound = new RelayCommand(obj => { ChangeFL(); })); } + } + + + public RelayCommand ReplaceDLFoundfromNULL + { + get { return replaceDLFoundfromNULL ?? (replaceDLFoundfromNULL = new RelayCommand(obj => { ChangeDLfromNULL(); })); } + } + + public RelayCommand CalculateDLFound + { + get { return calculateDLFound ?? (calculateDLFound = new RelayCommand(obj => { CalcDLFound(); })); } + } + + public RelayCommand CalculateLevelsFounds + { + get { return calculateLevelsFounds ?? (calculateLevelsFounds = new RelayCommand(obj => { CalcDLFoundsAll(); CalcNLFoundsAll(); })); } + } + + public RelayCommand ExportFoundationsToCSV + { + get { return exportFoundationsToCSV ?? (exportFoundationsToCSV = new RelayCommand(obj => { SaveFoundationsInCsv(); })); } + } + + public RelayCommand ImportFoundationsFromCSV + { + get { return importFoundationsFromCSV ?? (importFoundationsFromCSV = new RelayCommand(obj => { ReadFoundationsFromCsv(); })); } + } + + #endregion + + void AddFoundationToList() + { + ListFoundation.Add(new Foundation() { Number = numFoundation }); numFoundation++; + //CreateListNumberTypeBet(); + //NameFoundation = listFoundation[0].Name; + } + void RenumberingFoundationInList() + { + int j = 1; + foreach (Foundation item in ListFoundation) + { + item.Number = j; + j++; + } + numFoundation = j; + ListFoundation = new ObservableCollection(ListFoundation); + } + internal void UpdateFoundationInList() + { + ListFoundation = new ObservableCollection(ListFoundation); + SaveDB(); + } + + void ChangeSelectedFoundation() + { + if (listFoundation.Count == 0 || selectedFoundation == null) return; + NameFoundation = selectedFoundation.Name; + ListFoundLoad = selectedFoundation.Loads; + D1 = selectedFoundation.D1; + FL = selectedFoundation.FL; + DL = selectedFoundation.DL; + } + + void CreateListTypeFoundations() + { + if (listFoundation == null || listPlayGround == null) return; + ListTypeFounds = new List { TypeFound.Прямоугольный, TypeFound.Круглый, TypeFound.Ленточный }; + try + { + FoundationsPage foundationsPage = (FoundationsPage)MW.FoundationsFrame.Content; + foundationsPage.typeFondsListCbxCol.ItemsSource = ListTypeFounds; + } + catch (Exception) + { + return; + } + } + private void ReadFondationsFromDXF() + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.DefaultExt = "*.dxf"; + ofd.Filter = "Чертеж (*.dxf)|*.dxf"; + ofd.Title = "Импорт чертежа"; + ofd.ShowDialog(); + + if (ofd.FileName == null || ofd.FileName == "") return; + + DxfDocument dxfDocument = DxfDocument.Load(ofd.FileName); + IEnumerable dxfLwPolylines = dxfDocument.LwPolylines; + IEnumerable dxfLwPolylinesVertexes = null; + Foundation fnd; + Quadrangle countFound; int i = 0; + Point2d[] ptColl = new Point2d[4]; + foreach (LwPolyline item in dxfLwPolylines) + { + if (item.Layer.Name == "Foundations") + { + dxfLwPolylinesVertexes = item.Vertexes; + int j = 0; + foreach (LwPolylineVertex itemVrtx in dxfLwPolylinesVertexes) + { + ptColl[j] = new Point2d(itemVrtx.Position.X * 0.001, itemVrtx.Position.Y * 0.001); + j++; if (j == 4) break; + } + countFound = new Quadrangle(ptColl[0], ptColl[1], ptColl[2], ptColl[3]); + countFound.Units = UnitsLin.м; + fnd = new Foundation(countFound) { Number = i + 1 }; + ListFoundation.Add(fnd); + i++; + } + } + + if (dxfLwPolylinesVertexes == null) return; + } + + //Сохранение таблицы фундаментов в файл *.csv + internal void SaveFoundationsInCsv() + { + SaveFileDialog sfd = new SaveFileDialog(); + sfd.DefaultExt = "*.xlsx"; + sfd.Filter = "Файл Excel (*.xlsx)|*.xlsx"; + sfd.Title = "Сохранение таблицы"; + //sfd.AddExtension = true; + sfd.OverwritePrompt = false; + sfd.ShowDialog(); + + if (sfd.FileName == null || sfd.FileName == "") return; + + string path = "ИГЭ.xlsx"; + FileInfo fileInf = new FileInfo(path); + if (fileInf.Exists != true) + { + using (FileStream fstream = new FileStream("ИГЭ.xlsx", FileMode.OpenOrCreate)) + { + byte[] array = Properties.Resources.IGE; + fstream.Write(array, 0, array.Length); + } + } + List content = new List(); + foreach (Foundation item in listFoundation) + { + content.Add(item.PropsToList().ToArray()); + } + + using (var p = new ExcelPackage(new FileInfo(sfd.FileName))) + { + try + { + //A workbook must have at least on cell, so lets add one... + var ws = p.Workbook.Worksheets["Фундаменты"]; + + //To set values in the spreadsheet use the Cells indexer. + ws.Cells["A2"].LoadFromArrays(content); + + //Save the new workbook. We haven't specified the filename so use the Save as method. + p.SaveAs(new FileInfo(sfd.FileName)); + } + catch + { + ExcelPackage p1 = new ExcelPackage(new FileInfo("ИГЭ.xlsx")); + ExcelWorksheet ws1 = p1.Workbook.Worksheets["Фундаменты"]; + p.Workbook.Worksheets.Add("Фундаменты", ws1); + + //A workbook must have at least on cell, so lets add one... + var ws = p.Workbook.Worksheets["Фундаменты"]; + + //To set values in the spreadsheet use the Cells indexer. + ws.Cells["A2"].LoadFromArrays(content); + ws.Select(); + //Save the new workbook. We haven't specified the filename so use the Save as method. + p.SaveAs(new FileInfo(sfd.FileName)); + } + } + } + + //Чтение таблицы фундаментов из файла *.xlsx + internal void ReadFoundationsFromCsv() + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.DefaultExt = "*.xlsx"; + ofd.Filter = "Файл Excel (*.xlsx)|*.xlsx"; + ofd.Title = "Заполнение таблицы"; + ofd.ShowDialog(); + + if (ofd.FileName == null || ofd.FileName == "") return; + + //ListIGE.Clear(); + + try + { + using (var p = new ExcelPackage(new FileInfo(ofd.FileName))) + { + //A workbook must have at least on cell, so lets add one... + var ws = p.Workbook.Worksheets["Фундаменты"]; + + object[,] content = ws.Cells.Value as object[,]; + List source; Foundation item; + for (int i = 1; i < content.GetLength(0); i++) + { + source = new List(); + for (int j = 0; j < content.GetLength(1); j++) + { + source.Add(content[i, j]); + } + item = new Foundation(); item.ListToProps(source); + ListFoundation.Add(item); + } + } + } + catch (Exception e) + { + Alert(e.Message); + } + } + + private void ChangeMark() + { + if (selectedFoundation == null) return; + SelectedFoundation.Name = nameFoundation; + } + + void ChangeD1() + { + if (selectedFoundation == null || selectedStructure == null) return; + SelectedFoundation.D1 = d1; + SelectedFoundation.D1toFL(selectedStructure.Null); + DL = selectedFoundation.DL; + //FL = selectedFoundation.FL; + } + + void ChangeDL() + { + if (selectedFoundation == null || selectedStructure == null) return; + SelectedFoundation.DL = dL; + SelectedFoundation.DLtoD1(selectedStructure.Null); + D1 = selectedFoundation.D1; + //FL = selectedFoundation.FL; + } + + void ChangeFL() + { + if (selectedFoundation == null || selectedStructure == null) return; + SelectedFoundation.FL = fL; + SelectedFoundation.FLtoD1(selectedStructure.Null); + D1 = selectedFoundation.D1; + //DL = selectedFoundation.DL; + } + + private void ChangeDLfromNULL() + { + if (selectedFoundation == null || selectedStructure == null) return; + SelectedFoundation.DL = selectedStructure.Null; + DL = SelectedFoundation.DL; + SelectedFoundation.DLtoD1(selectedStructure.Null); + D1 = selectedFoundation.D1; + } + + private void CalcDLFound() + { + if (selectedFoundation == null || selectedStructure == null) return; + if (MeshRedPlanning == null) CreateRedMesh(); + selectedFoundation.CalcDL(MeshRedPlanning); + DL = SelectedFoundation.DL; + SelectedFoundation.DLtoD1(selectedStructure.Null); + D1 = selectedFoundation.D1; + } + + internal void CalcDLFoundsAll() + { + if (listFoundation == null || listFoundation.Count == 0) return; + if (MeshRedPlanning == null) CreateRedMesh(); + if (MeshRedPlanning == null) + { + Alert("Сооружение не содержит планировочных отметок"); + return; + } + + foreach (Foundation item in ListFoundation) + { + item.CalcDL(MeshRedPlanning); + item.DLtoD1(selectedStructure.Null); + } + + Alert("Уровни планировки для всех фундаментов \nвычислены по триангуляционной сети"); + } + + internal void CalcNLFoundsAll() + { + if (listFoundation == null || listFoundation.Count == 0) return; + if (MeshBlackPlanning == null) CreateBlackMesh(); + if (MeshBlackPlanning == null) + { + Alert("Сооружение не содержит планировочных отметок"); + return; + } + foreach (Foundation item in ListFoundation) + { + item.CalcNL(MeshBlackPlanning); + } + + Alert("Отметки естественного рельефа для всех фундаментов \nвычислены по триангуляционной сети"); + } + + internal void CreateSmallPropsFounds() + { + foreach (Foundation item in ListFoundation) item.CreateSmallPropsList(); + } + } +} diff --git a/VM/HelpsVM.cs b/VM/HelpsVM.cs new file mode 100644 index 0000000..84c944f --- /dev/null +++ b/VM/HelpsVM.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Interop; +using System.Windows.Media.Imaging; + +namespace GroundOrganizer +{ + public partial class ViewModel : INotifyPropertyChanged + { + + private RelayCommand helpFoundation; + private RelayCommand helpLoads; + public RelayCommand HelpFoundation + { + get { return helpFoundation ?? (helpFoundation = new RelayCommand(obj => { HelpFoundAlert(); })); } + } + public RelayCommand HelpLoads + { + get { return helpLoads ?? (helpLoads = new RelayCommand(obj => { HelpLoadsAlert(); })); } + } + + void HelpFoundAlert() + { + Alert(Properties.Resources.ShemaFound, 500); + if (MW.OwnedWindows.Count > 0) + { + foreach (Window item in MW.OwnedWindows) item.Close(); + Alert(Properties.Resources.ShemaFound, 500); + } + } + + void HelpLoadsAlert() + { + Alert(@"\Images\ShemaLoads.png", 200); + if (MW.OwnedWindows.Count > 0) + { + foreach (Window item in MW.OwnedWindows) item.Close(); + Alert(@"\Images\ShemaLoads.png", 200); + } + } + + void Alert(string alert) + { + AlertWindow aw = new AlertWindow(); + aw.Owner = MW; + aw.alertLabel.Content = alert; + //aw.WindowStyle = WindowStyle.None; + aw.ShowDialog(); + } + void Alert(string alert, string title) + { + AlertWindow aw = new AlertWindow(); + aw.Owner = MW; + aw.alertLabel.Content = alert; + aw.Title = title; + aw.ShowDialog(); + } + void Alert(Bitmap resource, int h = 250) + { + ImageWindow aw = new ImageWindow(); + //BitmapImage b =new BitmapImage(new Uri("pack://application:,,,/Resources/ShemaFound.png")); + Bitmap br = resource; + BitmapSource b = Imaging.CreateBitmapSourceFromHBitmap(br.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); + aw.alertImage.Source = b; + aw.alertImage.Height = h; + aw.Owner = MW; + aw.WindowStartupLocation = WindowStartupLocation.Manual; + aw.Top = MW.Top; + aw.Left = MW.Left + MW.Width; + aw.Show(); + } + + void Alert(string filepath, int h = 250) + { + Uri uri = new Uri(filepath, UriKind.RelativeOrAbsolute); + BitmapImage b = new BitmapImage(uri); + ImageWindow aw = new ImageWindow(); + aw.alertImage.Source = b; + aw.alertImage.Height = h; + aw.Owner = MW; + aw.WindowStartupLocation = WindowStartupLocation.Manual; + aw.Top = MW.Top; + aw.Left = MW.Left + MW.Width; + aw.Show(); + } + } +} diff --git a/VM/IGEsVM.cs b/VM/IGEsVM.cs new file mode 100644 index 0000000..50dcbac --- /dev/null +++ b/VM/IGEsVM.cs @@ -0,0 +1,278 @@ +using Microsoft.Win32; +using OfficeOpenXml; +using OfficeOpenXml.Style; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.Serialization.Formatters.Binary; +using System.Text; +using System.Threading.Tasks; + +namespace GroundOrganizer +{ + public partial class ViewModel : INotifyPropertyChanged + { + int numIGE = 1; + ObservableCollection listIGE = new ObservableCollection(); + + public ObservableCollection ListIGE { get => listIGE; set { listIGE = value; OnPropertyChanged(); } } + + private RelayCommand addIGE; + public RelayCommand AddIGE + { + get { return addIGE ?? (addIGE = new RelayCommand(obj => { AddIGEToList(); })); } + } + + private RelayCommand updateIGE; + public RelayCommand UpdateIGEs + { + get { return updateIGE ?? (updateIGE = new RelayCommand(obj => { UpdateIGEInList(); })); } + } + + private RelayCommand renumIGE; + public RelayCommand RenumIGEs + { + get { return renumIGE ?? (renumIGE = new RelayCommand(obj => { RenumberingIGEInList(); })); } + } + + private RelayCommand exportIGEtoCSV; + public RelayCommand ExportIGEtoCSV + { + get { return exportIGEtoCSV ?? (exportIGEtoCSV = new RelayCommand(obj => { SaveIGEsInCsv(); })); } + } + + private RelayCommand importIGEfromCSV; + public RelayCommand ImportIGEfromCSV + { + get { return importIGEfromCSV ?? (importIGEfromCSV = new RelayCommand(obj => { ReadIGEsFromCsv(); })); } + } + + private RelayCommand saveIGEsTable; + public RelayCommand SaveIGEsTable + { + get { return saveIGEsTable ?? (saveIGEsTable = new RelayCommand(obj => { SaveIGEs(); })); } + } + + private IEnumerable listNumIGEs; + public IEnumerable ListNumIGEs { get => listNumIGEs; set { listNumIGEs = value; OnPropertyChanged(); } } + + void AddIGEToList() + { + ListIGE.Add(new IGE() { Number = numIGE }); numIGE++; + CreateListNumIGEs(); + //CreateListNumberTypeBet(); + //NameIGE = listIGE[0].Name; + } + void RenumberingIGEInList() + { + int j = 1; + foreach (IGE item in ListIGE) + { + item.Number = j; + j++; + } + numIGE = j; + ListIGE = new ObservableCollection(ListIGE); + CreateListNumIGEs(); + } + void UpdateIGEInList() + { + ListIGE = new ObservableCollection(ListIGE); + SaveDB(); + } + + void CreateListNumIGEs() + { + if (listIGE == null || listPlayGround == null) return; + ListNumIGEs = from bet in listIGE select bet.NumIGE; + try + { + BoresPage boresPage = (BoresPage)MW.BoresFrame.Content; + boresPage.IGEsListCbxCol.ItemsSource = listNumIGEs; + } + catch { return; } + } + + //Сохранение таблицы набора ИГЭ в файл *.csv + internal void SaveIGEsInCsv() + { + SaveFileDialog sfd = new SaveFileDialog(); + sfd.DefaultExt = "*.xlsx"; + sfd.Filter = "Файл Excel (*.xlsx)|*.xlsx"; + sfd.Title = "Сохранение таблицы"; + //sfd.AddExtension = true; + sfd.OverwritePrompt = false; + sfd.ShowDialog(); + + if (sfd.FileName == null || sfd.FileName == "") return; + + string path = "ИГЭ.xlsx"; + FileInfo fileInf = new FileInfo(path); + if (fileInf.Exists != true) + { + using (FileStream fstream = new FileStream("ИГЭ.xlsx", FileMode.OpenOrCreate)) + { + byte[] array = Properties.Resources.IGE; + fstream.Write(array, 0, array.Length); + } + } + List content = new List(); + foreach (IGE item in listIGE) + { + content.Add(item.PropsToList().ToArray()); + } + + using (var p = new ExcelPackage(new FileInfo(sfd.FileName))) + { + try + { + var ws = p.Workbook.Worksheets["ИГЭ"]; + + //To set values in the spreadsheet use the Cells indexer. + ws.Cells["A2"].LoadFromArrays(content); + + //Save the new workbook. We haven't specified the filename so use the Save as method. + p.SaveAs(new FileInfo(sfd.FileName)); + } + catch + { + ExcelPackage p1 = new ExcelPackage(new FileInfo("ИГЭ.xlsx")); + ExcelWorksheet ws1 = p1.Workbook.Worksheets["ИГЭ"]; + p.Workbook.Worksheets.Add("ИГЭ", ws1); + ExcelWorksheet ws = p.Workbook.Worksheets["ИГЭ"]; + + //Save the new workbook. We haven't specified the filename so use the Save as method. + ws.Cells["A2"].LoadFromArrays(content); + ws.Select(); + p.SaveAs(new FileInfo(sfd.FileName)); + } + } + + //try + //{ + // using (StreamWriter sw = new StreamWriter(sfd.FileName, false, System.Text.Encoding.Default)) + // { + // foreach (IGE item in listIGE) + // { + // sw.WriteLine(item.PropsToString()); + // } + // } + //} + //catch (Exception e) + //{ + // Alert(e.Message); + //} + } + + //Чтение таблицы набора ИГЭ из файла *.csv + internal void ReadIGEsFromCsv() + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.DefaultExt = "*.xlsx"; + ofd.Filter = "Файл Excel (*.xlsx)|*.xlsx"; + ofd.Title = "Заполнение таблицы"; + ofd.ShowDialog(); + + if (ofd.FileName == null || ofd.FileName == "") return; + + //ListIGE.Clear(); + + using (var p = new ExcelPackage(new FileInfo(ofd.FileName))) + { + //A workbook must have at least on cell, so lets add one... + var ws = p.Workbook.Worksheets["ИГЭ"]; + + object[,] content = ws.Cells.Value as object[,]; + List source; IGE item; + for (int i = 1; i < content.GetLength(0); i++) + { + source = new List(); + for (int j = 0; j < content.GetLength(1); j++) + { + source.Add(content[i, j]); + } + item = new IGE(); item.ListToProps(source); + ListIGE.Add(item); + } + } + + //OpenFileDialog ofd = new OpenFileDialog(); + //ofd.DefaultExt = "*.*"; + //ofd.Filter = "Текстовый файл (*.csv)|*.csv|Все файлы (*.*)|*.*"; + //ofd.Title = "Заполнение таблицы"; + //ofd.ShowDialog(); + + //if (ofd.FileName == null || ofd.FileName == "") return; + + //ListIGE.Clear(); + //try + //{ + // using (StreamReader sr = new StreamReader(ofd.FileName, System.Text.Encoding.Default)) + // { + // string line; + // IGE ige; + // while ((line = sr.ReadLine()) != null) + // { + // ige = new IGE(); + // ige.StringToProps(line); + // ListIGE.Add(ige); + // } + // } + //} + //catch (Exception e) + //{ + // Alert(e.Message); + //} + } + + internal void SaveIGEs() + { + SaveFileDialog sfd = new SaveFileDialog(); + sfd.DefaultExt = "*.igedb"; + sfd.Filter = "Таблица ИГЭ (*.igedb)|*.igedb"; + sfd.Title = "Сохранение таблицы"; + //sfd.AddExtension = true; + sfd.OverwritePrompt = true; + sfd.ShowDialog(); + + if (sfd.FileName == null || sfd.FileName == "") return; + + BinaryFormatter formatter = new BinaryFormatter(); + // получаем поток, куда будем записывать сериализованный объект + using (FileStream fs = new FileStream(sfd.FileName, FileMode.OpenOrCreate)) + { + formatter.Serialize(fs, ListIGE); + } + //Alert("Введенные данные успешно сохранены"); + } + + internal void ReadIGEs() + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.DefaultExt = "*.igedb"; + ofd.Filter = "Таблица ИГЭ (*.igedb)|*.igedb"; + ofd.Title = "Открытие таблицы"; + ofd.ShowDialog(); + + if (ofd.FileName == null || ofd.FileName == "") return; + + if (File.Exists(ofd.FileName) == true) + { + // создаем объект BinaryFormatter + BinaryFormatter formatter = new BinaryFormatter(); + + using (FileStream fs = new FileStream(ofd.FileName, FileMode.OpenOrCreate)) + { + List tmp = new List(ListIGE); + tmp.AddRange(formatter.Deserialize(fs) as ObservableCollection); + ListIGE = new ObservableCollection(tmp); + } + } + } + } +} diff --git a/VM/LayersVM.cs b/VM/LayersVM.cs new file mode 100644 index 0000000..6b73cca --- /dev/null +++ b/VM/LayersVM.cs @@ -0,0 +1,244 @@ +using Microsoft.Win32; +using OfficeOpenXml; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GroundOrganizer +{ + public partial class ViewModel : INotifyPropertyChanged + { + private RelayCommand addLayer; + private RelayCommand updateLayer; + private RelayCommand renumLayer; + private RelayCommand recalcLayerH; + private RelayCommand recalcLayerDown; + private RelayCommand exportLayersToXLSX; + private RelayCommand importLayersFromXLSX; + + int numLayer = 1; + ObservableCollection listLayer = new ObservableCollection(); + + public ObservableCollection ListLayer { get => listLayer; set { listLayer = value; OnPropertyChanged(); } } + + public RelayCommand AddLayer + { + get { return addLayer ?? (addLayer = new RelayCommand(obj => { AddLayerToList(); })); } + } + + public RelayCommand UpdateLayers + { + get { return updateLayer ?? (updateLayer = new RelayCommand(obj => { UpdateLayerInList(); })); } + } + + public RelayCommand RenumLayers + { + get { return renumLayer ?? (renumLayer = new RelayCommand(obj => { RenumberingLayerInList(); })); } + } + + public RelayCommand RecalcLayerH + { + get { return recalcLayerH ?? (recalcLayerH = new RelayCommand(obj => { RecalcInLayersH(); })); } + } + + public RelayCommand RecalcLayerDown + { + get { return recalcLayerDown ?? (recalcLayerDown = new RelayCommand(obj => { RecalcInLayersDown(); })); } + } + + public RelayCommand ExportLayersToXLSX + { + get { return exportLayersToXLSX ?? (exportLayersToXLSX = new RelayCommand(obj => { SaveLayersInXlsx(); })); } + } + + public RelayCommand ImportLayersFromXLSX + { + get { return importLayersFromXLSX ?? (importLayersFromXLSX = new RelayCommand(obj => { ReadLayersFromXlsx(); })); } + } + + void AddLayerToList() + { + ListLayer.Add(new Layer() { Number = numLayer }); numLayer++; + //CreateListNumberTypeBet(); + //NameLayer = listLayer[0].Name; + } + void RenumberingLayerInList() + { + int j = 1; + foreach (Layer item in listLayer) + { + item.Number = j; + j++; + } + numLayer = j; + ListLayer = new ObservableCollection(listLayer); + } + void UpdateLayerInList() + { + foreach (Layer lay in listLayer) + { + foreach (IGE ige in listIGE) + { + if (lay.NumIGE==ige.NumIGE) + { + lay.IGE = ige.Clone(); + lay.Description = ige.Description; + break; + } + } + } + ListLayer = new ObservableCollection(listLayer); + selectedBore.Layers = listLayer; + SaveDB(); + } + + void RecalcInLayersH() + { + if (listLayer == null) return; + if (listLayer.Count == 0) return; + if (selectedBore == null) return; + + UpdateLayerInList(); + + double down = 0; + double up = 0; + double z = selectedBore.Z; + foreach (Layer item in listLayer) + { + z -= item.H; + down += item.H; + item.Down = down; + item.Z = z; + item.Up = up; + up += item.H; + } + ListLayer = new ObservableCollection(listLayer); + } + + void RecalcInLayersDown() + { + if (listLayer == null) return; + if (listLayer.Count == 0) return; + if (selectedBore == null) return; + + UpdateLayerInList(); + + double up = 0; + double z = selectedBore.Z; + foreach (Layer item in listLayer) + { + item.Up = up; + item.H = item.Down - item.Up; + z -= item.H; + item.Z = z; + up += item.H; + } + ListLayer = new ObservableCollection(listLayer); + } + + //Сохранение таблиц наборов слоев в файл *.xlsx + internal void SaveLayersInXlsx() + { + SaveFileDialog sfd = new SaveFileDialog(); + sfd.DefaultExt = "*.xlsx"; + sfd.Filter = "Файл Excel (*.xlsx)|*.xlsx"; + sfd.Title = "Сохранение таблицы"; + //sfd.AddExtension = true; + sfd.OverwritePrompt = true; + sfd.ShowDialog(); + + if (sfd.FileName == null || sfd.FileName == "") return; + + try + { + string path = "ИГЭ.xlsx"; + FileInfo fileInf = new FileInfo(path); + if (fileInf.Exists != true) + { + using (FileStream fstream = new FileStream("ИГЭ.xlsx", FileMode.OpenOrCreate)) + { + byte[] array = Properties.Resources.IGE; + fstream.Write(array, 0, array.Length); + } + } + + using (var p = new ExcelPackage(new FileInfo(sfd.FileName))) + { + for (int i = 0; i < listBore.Count; i++) + { + List content = new List(); + foreach (Layer fli in listBore[i].Layers) + { + content.Add(fli.PropsToList().ToArray()); + } + ExcelPackage p1 = new ExcelPackage(new FileInfo("ИГЭ.xlsx")); + //A workbook must have at least on cell, so lets add one... + var ws = p1.Workbook.Worksheets["Слои"]; + p.Workbook.Worksheets.Add((i + 1).ToString(), ws); + var wsi = p.Workbook.Worksheets[i + 1]; + //To set values in the spreadsheet use the Cells indexer. + wsi.Cells["D1"].Value = listBore[i].Name; + wsi.Cells["A3"].LoadFromArrays(content); + } + + //Save the new workbook. We haven't specified the filename so use the Save as method. + p.SaveAs(new FileInfo(sfd.FileName)); + } + } + catch (Exception e) + { + Alert(e.Message); + } + } + + //Чтение наборов слоев из файла *.xlsx + internal void ReadLayersFromXlsx() + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.DefaultExt = "*.xlsx"; + ofd.Filter = "Файл Excel (*.xlsx)|*.xlsx"; + ofd.Title = "Заполнение таблиц"; + ofd.ShowDialog(); + + if (ofd.FileName == null || ofd.FileName == "") return; + + //ListFoundLoad.Clear(); + try + { + using (var p = new ExcelPackage(new FileInfo(ofd.FileName))) + { + int k = 0; + foreach (ExcelWorksheet wsi in p.Workbook.Worksheets) + { + listBore[k].Layers = new ObservableCollection(); + + object[,] content = wsi.Cells.Value as object[,]; + List source; Layer item; + for (int i = 2; i < content.GetLength(0); i++) + { + source = new List(); + for (int j = 0; j < content.GetLength(1); j++) + { + source.Add(content[i, j]); + } + item = new Layer(); item.ListToProps(source); + listBore[k].Layers.Add(item); + SelectedBore = listBore[k]; + UpdateLayerInList(); + } + k++; + } + } + } + catch (Exception e) + { + Alert(e.Message); + } + } + } +} diff --git a/VM/PlanningVM.cs b/VM/PlanningVM.cs new file mode 100644 index 0000000..d5db65b --- /dev/null +++ b/VM/PlanningVM.cs @@ -0,0 +1,363 @@ +using Microsoft.Win32; +using netDxf; +using netDxf.Entities; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Runtime.Serialization.Formatters.Binary; +using System.Text; +using System.Threading.Tasks; +using TriangleNet; +using TriangleNet.Geometry; +using TriangleNet.Meshing; +using TriangleNet.Tools; + +namespace GroundOrganizer +{ + public partial class ViewModel : INotifyPropertyChanged + { + private RelayCommand addRedVertex; + private RelayCommand addBlackVertex; + private RelayCommand updateRedPlanning; + private RelayCommand updateBlackPlanning; + private RelayCommand renumRedVertexes; + private RelayCommand renumBlackVertexes; + private RelayCommand importPlanningsFromDXF; + private RelayCommand importRedPlanningFromCSV; + private RelayCommand importBlackPlanningFromCSV; + private RelayCommand exportRedPlanningToCSV; + private RelayCommand exportBlackPlanningToCSV; + private RelayCommand createRedPlanningMesh; + private RelayCommand createBlackPlanningMesh; + + int numVertex = 1; + PlanningVertex selectedRedVertex; + PlanningVertex selectedBlackVertex; + ObservableCollection redPlanning = new ObservableCollection(); + ObservableCollection blackPlanning = new ObservableCollection(); + + public ObservableCollection RedPlanning { get => redPlanning; set { redPlanning = value; OnPropertyChanged(); } } + public ObservableCollection BlackPlanning { get => blackPlanning; set { blackPlanning = value; OnPropertyChanged(); } } + public PlanningVertex SelectedRedVertex { get => selectedRedVertex; set { selectedRedVertex = value; OnPropertyChanged(); } } + public PlanningVertex SelectedBlackVertex { get => selectedBlackVertex; set { selectedBlackVertex = value; OnPropertyChanged(); } } + public TriangleNet.Mesh MeshRedPlanning { get; private set; } + public TriangleNet.Mesh MeshBlackPlanning { get; private set; } + + + public RelayCommand AddRedVertex + { + get { return addRedVertex ?? (addRedVertex = new RelayCommand(obj => { AddRedVertexToList(); })); } + } + + public RelayCommand UpdateRedPlanning + { + get { return updateRedPlanning ?? (updateRedPlanning = new RelayCommand(obj => { UpdateRedVertexesInList(); })); } + } + + public RelayCommand RenumRedVertexes + { + get { return renumRedVertexes ?? (renumRedVertexes = new RelayCommand(obj => { RenumberingRedVertexesInList(); })); } + } + + public RelayCommand AddBlackVertex + { + get { return addBlackVertex ?? (addBlackVertex = new RelayCommand(obj => { AddBlackVertexToList(); })); } + } + + public RelayCommand UpdateBlackPlanning + { + get { return updateBlackPlanning ?? (updateBlackPlanning = new RelayCommand(obj => { UpdateBlackVertexesInList(); })); } + } + + public RelayCommand RenumBlackVertexes + { + get { return renumBlackVertexes ?? (renumBlackVertexes = new RelayCommand(obj => { RenumberingBlackVertexesInList(); })); } + } + + public RelayCommand ImportPlanningsFromDXF + { + get { return importPlanningsFromDXF ?? (importPlanningsFromDXF = new RelayCommand(obj => { ReadPlanningsDXF(); })); } + } + + public RelayCommand ImportRedPlanningFromCSV + { + get { return importRedPlanningFromCSV ?? (importRedPlanningFromCSV = new RelayCommand(obj => { ReadRedPlanningCSV(); })); } + } + + public RelayCommand ExportRedPlanningToCSV + { + get { return exportRedPlanningToCSV ?? (exportRedPlanningToCSV = new RelayCommand(obj => { SaveRedPlanningInCsv(); })); } + } + + + public RelayCommand ImportBlackPlanningFromCSV + { + get { return importBlackPlanningFromCSV ?? (importBlackPlanningFromCSV = new RelayCommand(obj => { ReadBlackPlanningCSV(); })); } + } + + public RelayCommand ExportBlackPlanningToCSV + { + get { return exportBlackPlanningToCSV ?? (exportBlackPlanningToCSV = new RelayCommand(obj => { SaveBlackPlanningInCsv(); })); } + } + + public RelayCommand CreateRedPlanningMesh + { + get { return createRedPlanningMesh ?? (createRedPlanningMesh = new RelayCommand(obj => { CreateRedMesh(); })); } + } + + public RelayCommand CreateBlackPlanningMesh + { + get { return createBlackPlanningMesh ?? (createBlackPlanningMesh = new RelayCommand(obj => { CreateBlackMesh(); })); } + } + + private void ReadRedPlanningCSV() + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.DefaultExt = "*.*"; + ofd.Filter = "Текстовый файл (*.csv)|*.csv|Все файлы (*.*)|*.*"; + ofd.Title = "Заполнение таблицы"; + ofd.ShowDialog(); + + if (ofd.FileName == null || ofd.FileName == "") return; + + RedPlanning.Clear(); + try + { + using (StreamReader sr = new StreamReader(ofd.FileName, System.Text.Encoding.Default)) + { + string line; + PlanningVertex vert; + while ((line = sr.ReadLine()) != null) + { + vert = new PlanningVertex(); + vert.StringToProps(line); + RedPlanning.Add(vert); + } + } + } + catch (Exception e) + { + Alert(e.Message); + } + } + + internal void SaveRedPlanningInCsv() + { + SaveFileDialog sfd = new SaveFileDialog(); + sfd.DefaultExt = "*.csv"; + sfd.Filter = "Текстовый файл (*.csv)|*.csv"; + sfd.Title = "Сохранение таблицы"; + //sfd.AddExtension = true; + sfd.OverwritePrompt = true; + sfd.ShowDialog(); + + if (sfd.FileName == null || sfd.FileName == "") return; + + try + { + using (StreamWriter sw = new StreamWriter(sfd.FileName, false, System.Text.Encoding.Default)) + { + foreach (PlanningVertex item in RedPlanning) + { + sw.WriteLine(item.PropsToString()); + } + } + } + catch (Exception e) + { + Alert(e.Message); + } + } + + private void ReadBlackPlanningCSV() + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.DefaultExt = "*.*"; + ofd.Filter = "Текстовый файл (*.csv)|*.csv|Все файлы (*.*)|*.*"; + ofd.Title = "Заполнение таблицы"; + ofd.ShowDialog(); + + if (ofd.FileName == null || ofd.FileName == "") return; + + BlackPlanning.Clear(); + try + { + using (StreamReader sr = new StreamReader(ofd.FileName, System.Text.Encoding.Default)) + { + string line; + PlanningVertex vert; + while ((line = sr.ReadLine()) != null) + { + vert = new PlanningVertex(); + vert.StringToProps(line); + BlackPlanning.Add(vert); + } + } + } + catch (Exception e) + { + Alert(e.Message); + } + } + + internal void SaveBlackPlanningInCsv() + { + SaveFileDialog sfd = new SaveFileDialog(); + sfd.DefaultExt = "*.csv"; + sfd.Filter = "Текстовый файл (*.csv)|*.csv"; + sfd.Title = "Сохранение таблицы"; + //sfd.AddExtension = true; + sfd.OverwritePrompt = true; + sfd.ShowDialog(); + + if (sfd.FileName == null || sfd.FileName == "") return; + + try + { + using (StreamWriter sw = new StreamWriter(sfd.FileName, false, System.Text.Encoding.Default)) + { + foreach (PlanningVertex item in BlackPlanning) + { + sw.WriteLine(item.PropsToString()); + } + } + } + catch (Exception e) + { + Alert(e.Message); + } + } + + private void ReadPlanningsDXF() + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.DefaultExt = "*.dxf"; + ofd.Filter = "Чертеж (*.dxf)|*.dxf"; + ofd.Title = "Импорт чертежа"; + ofd.ShowDialog(); + + if (ofd.FileName == null || ofd.FileName == "") return; + if (selectedStructure == null) return; + RedPlanning.Clear(); BlackPlanning.Clear(); + DxfDocument dxfDocument = DxfDocument.Load(ofd.FileName); + IEnumerable dxfTexts = dxfDocument.Texts; + PlanningVertex vert; int j = 1; int k = 1; + foreach (Text item in dxfTexts) + { + if (item.Layer.Name == "Red") + { + vert = new PlanningVertex + { + X = Math.Round(item.Position.X * 0.001, 3), + Y = Math.Round(item.Position.Y * 0.001, 3), + Number = j, + Red = double.Parse(item.Value) + }; + RedPlanning.Add(vert); + j++; + } + else if (item.Layer.Name == "Black") + { + vert = new PlanningVertex + { + X = Math.Round(item.Position.X * 0.001, 3), + Y = Math.Round(item.Position.Y * 0.001, 3), + Number = k, + Black = double.Parse(item.Value) + }; + BlackPlanning.Add(vert); + k++; + } + } + } + + void AddRedVertexToList() + { + RedPlanning.Add(new PlanningVertex() { Number = numVertex }); numVertex++; + //NameStructure = listStructure[0].Name; + } + void RenumberingRedVertexesInList() + { + int j = 1; + foreach (PlanningVertex item in RedPlanning) + { + item.Number = j; + j++; + } + numVertex = j; + RedPlanning = new ObservableCollection(RedPlanning); + } + void UpdateRedVertexesInList() + { + RedPlanning = new ObservableCollection(RedPlanning); + SaveDB(); + } + + void AddBlackVertexToList() + { + BlackPlanning.Add(new PlanningVertex() { Number = numVertex }); numVertex++; + //NameStructure = listStructure[0].Name; + } + void RenumberingBlackVertexesInList() + { + int j = 1; + foreach (PlanningVertex item in BlackPlanning) + { + item.Number = j; + j++; + } + numVertex = j; + BlackPlanning = new ObservableCollection(BlackPlanning); + } + void UpdateBlackVertexesInList() + { + BlackPlanning = new ObservableCollection(BlackPlanning); + SaveDB(); + } + + internal void CreateRedMesh() + { + if (selectedStructure == null || selectedStructure.RedPlanning == null || selectedStructure.RedPlanning.Count == 0) return; + + Polygon polygon = new Polygon(); + Vertex vrtx; + int i = 1; + foreach (PlanningVertex item in selectedStructure.RedPlanning) + { + vrtx = new Vertex(item.X, item.Y, item.Number, 1); + vrtx.Attributes[0] = item.Red; + polygon.Add(vrtx); + i++; + } + GenericMesher mesher = new GenericMesher(); + ConstraintOptions constraint = new ConstraintOptions(); + constraint.Convex = true; + MeshRedPlanning = (TriangleNet.Mesh)mesher.Triangulate(polygon, constraint); + Alert("\"Красная\" триангуляционная сеть создана"); + } + + internal void CreateBlackMesh() + { + if (selectedStructure == null || selectedStructure.BlackPlanning == null || selectedStructure.BlackPlanning.Count == 0) return; + + Polygon polygon = new Polygon(); + Vertex vrtx; + int i = 1; + foreach (PlanningVertex item in selectedStructure.BlackPlanning) + { + vrtx = new Vertex(item.X, item.Y, item.Number, 1); + vrtx.Attributes[0] = item.Black; + polygon.Add(vrtx); + i++; + } + GenericMesher mesher = new GenericMesher(); + ConstraintOptions constraint = new ConstraintOptions(); + constraint.Convex = true; + MeshBlackPlanning = (TriangleNet.Mesh)mesher.Triangulate(polygon, constraint); + Alert("\"Черная\" триангуляционная сеть создана"); + } + } +} diff --git a/VM/PlayGroundVM.cs b/VM/PlayGroundVM.cs new file mode 100644 index 0000000..1731d39 --- /dev/null +++ b/VM/PlayGroundVM.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GroundOrganizer +{ + public partial class ViewModel : INotifyPropertyChanged + { + int numPG = 1; + PlayGround selectedPlayGround; + string namePlayGround; + ObservableCollection listPlayGround = new ObservableCollection(); + + public ObservableCollection ListPlayGround { get => listPlayGround; set { listPlayGround = value; OnPropertyChanged(); } } + public string NamePlayGround { get => namePlayGround; set { namePlayGround = value; OnPropertyChanged(); } } + public PlayGround SelectedPlayGround { get => selectedPlayGround; set { selectedPlayGround = value; OnPropertyChanged(); ChangeSelectedPlayGround(); } } + + private RelayCommand addPlayGround; + public RelayCommand AddPlayGround + { + get { return addPlayGround ?? (addPlayGround = new RelayCommand(obj => { AddPlayGroundToList(); })); } + } + + private RelayCommand updatePlayGround; + public RelayCommand UpdatePlayGrounds + { + get { return updatePlayGround ?? (updatePlayGround = new RelayCommand(obj => { UpdatePlayGroundInList(); })); } + } + + private RelayCommand renumPlayGround; + public RelayCommand RenumPlayGrounds + { + get { return renumPlayGround ?? (renumPlayGround = new RelayCommand(obj => { RenumberingPlayGroundInList(); })); } + } + + void AddPlayGroundToList() + { + ListPlayGround.Add(new PlayGround() { Number = numPG }); numPG++; + //CreateListNumberTypeBet(); + //NamePlayGround = listPlayGround[0].Name; + } + void RenumberingPlayGroundInList() + { + int j = 1; + foreach (PlayGround item in ListPlayGround) + { + item.Number = j; + j++; + } + numPG = j; + ListPlayGround = new ObservableCollection(ListPlayGround); + } + void UpdatePlayGroundInList() + { + ListPlayGround = new ObservableCollection(ListPlayGround); + SaveDB(); + } + + //void ChangeSelClassBet() + //{ + // //if (selectedBet==null) return; + // CreateListNumberTypeBet(); + //} + + //void CreateListNumberTypeBet() + //{ + // //listNumberTypeArm = new List(); + // ListNumberTypeBet = from bet in listBet select bet.Id; + //} + + void ChangeSelectedPlayGround() + { + if (listPlayGround.Count == 0 || selectedPlayGround == null) return; + NamePlayGround = SelectedPlayGround.Name; + ListIGE = selectedPlayGround.IGEs; + ListBore = selectedPlayGround.Bores; + ListStructure = selectedPlayGround.Structures; + CreateListNumIGEs(); + CreateListShemas(); + CreateListTypeFoundations(); + } + } +} diff --git a/VM/RelayCommand.cs b/VM/RelayCommand.cs new file mode 100644 index 0000000..b888336 --- /dev/null +++ b/VM/RelayCommand.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace GroundOrganizer +{ + public class RelayCommand : ICommand + { + private Action execute; + private Func canExecute; + + public event EventHandler CanExecuteChanged + { + add { CommandManager.RequerySuggested += value; } + remove { CommandManager.RequerySuggested -= value; } + } + + public RelayCommand(Action execute, Func canExecute = null) + { + this.execute = execute; + this.canExecute = canExecute; + } + + public bool CanExecute(object parameter) + { + return this.canExecute == null || this.canExecute(parameter); + } + + public void Execute(object parameter) + { + this.execute(parameter); + } + } +} + diff --git a/VM/StructuresVM.cs b/VM/StructuresVM.cs new file mode 100644 index 0000000..dc63a70 --- /dev/null +++ b/VM/StructuresVM.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GroundOrganizer +{ + public partial class ViewModel : INotifyPropertyChanged + { + int numStructure = 1; + string nameStructure; + private string structureNote; + Structure selectedStructure; + ObservableCollection listStructure = new ObservableCollection(); + + public ObservableCollection ListStructure { get => listStructure; set { listStructure = value; OnPropertyChanged(); } } + + private IEnumerable listShemas; + public IEnumerable ListShemas { get => listShemas; set { listShemas = value; OnPropertyChanged(); } } + public string StructureNote { get => structureNote; set { structureNote = value; OnPropertyChanged(); } } + + private RelayCommand addStructure; + public RelayCommand AddStructure + { + get { return addStructure ?? (addStructure = new RelayCommand(obj => { AddStructureToList(); })); } + } + + private RelayCommand updateStructure; + public RelayCommand UpdateStructures + { + get { return updateStructure ?? (updateStructure = new RelayCommand(obj => { UpdateStructureInList(); })); } + } + + private RelayCommand renumStructure; + + public RelayCommand RenumStructures + { + get { return renumStructure ?? (renumStructure = new RelayCommand(obj => { RenumberingStructureInList(); })); } + } + + public Structure SelectedStructure { get => selectedStructure; set { selectedStructure = value; OnPropertyChanged(); ChangeSelectedStructure(); } } + + public string NameStructure { get => nameStructure; set { nameStructure = value; OnPropertyChanged(); } } + + void AddStructureToList() + { + ListStructure.Add(new Structure() { Number = numStructure }); numStructure++; + //NameStructure = listStructure[0].Name; + } + void RenumberingStructureInList() + { + int j = 1; + foreach (Structure item in ListStructure) + { + item.Number = j; + j++; + } + numStructure = j; + ListStructure = new ObservableCollection(ListStructure); + } + void UpdateStructureInList() + { + ListStructure = new ObservableCollection(ListStructure); + SaveDB(); + } + + void ChangeSelectedStructure() + { + if (listStructure.Count == 0 || selectedStructure == null) return; + NameStructure = selectedStructure.Name; + ListFoundation = selectedStructure.Foundations; + RedPlanning = selectedStructure.RedPlanning; + BlackPlanning = selectedStructure.BlackPlanning; + if (redPlanning == null) RedPlanning = new ObservableCollection(); + if (blackPlanning == null) BlackPlanning = new ObservableCollection(); + } + + void CreateListShemas() + { + if (listStructure == null || listPlayGround == null) return; + ListShemas = new List() { TypeFlexStructure.Гибкая, TypeFlexStructure.Жесткая }; + try + { + StructuresPage structuresPage = (StructuresPage)MW.StructuresFrame.Content; + structuresPage.flexListCbxCol.ItemsSource = listShemas; + } + catch + { + return; + } + } + } +} diff --git a/VM/UnitsViewModel .cs b/VM/UnitsViewModel .cs new file mode 100644 index 0000000..45dea90 --- /dev/null +++ b/VM/UnitsViewModel .cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace GroundOrganizer +{ + public partial class ViewModel : INotifyPropertyChanged + { + UnitsLin[] unitsL = { UnitsLin.м, UnitsLin.см, UnitsLin.мм }; + UnitsArea[] unitsA = { UnitsArea.м, UnitsArea.см, UnitsArea.мм }; + UnitsForce[] unitsF = { UnitsForce.т, UnitsForce.кН, UnitsForce.Н }; + UnitsStress[] unitsS = { UnitsStress.т, UnitsStress.кН, UnitsStress.Н, UnitsStress.МПа, UnitsStress.кПа }; + UnitsLin unitsLId = UnitsLin.м; + UnitsLin unitsSectId = UnitsLin.см; + UnitsLin unitsDarmId = UnitsLin.мм; + UnitsArea unitsAarmId = UnitsArea.см; + UnitsArea unitsAMatId = UnitsArea._; + UnitsLin unitsLForcId = UnitsLin.м; + UnitsArea unitsAStressId = UnitsArea._; + UnitsLin unitsCrackId = UnitsLin.мм; + UnitsStress unitsSMatId = UnitsStress.МПа; + UnitsStress unitsSStressId = UnitsStress.МПа; + UnitsForce unitsFForceId = UnitsForce.кН; + internal double scaleDimLength = 1; + internal double scaleDimSect = 0.01; + internal double scaleDimDarm = 0.001; + internal double scaleDimAarm = 0.0001; + internal double scaleDimLfrc = 1; + internal double scaleDimFfrc = 1; + internal double scaleDimStress = 0.001; + internal double scaleDimMat = 0.001; + internal double scaleDimCrack = 0.001; + + public UnitsLin[] UnitsL { get => unitsL; set => unitsL = value; } + public UnitsArea[] UnitsA { get => unitsA; set => unitsA = value; } + public UnitsForce[] UnitsF { get => unitsF; set => unitsF = value; } + public UnitsStress[] UnitsS { get => unitsS; set => unitsS = value; } + + public UnitsLin UnitsLId { get => unitsLId; set { unitsLId = value; OnPropertyChanged(); ChangeUnits(); } } + public UnitsLin UnitsSectId { get => unitsSectId; set { unitsSectId = value; OnPropertyChanged(); ChangeUnits(); } } + public UnitsLin UnitsDarmId { get => unitsDarmId; set { unitsDarmId = value; OnPropertyChanged(); ChangeUnits(); } } + public UnitsArea UnitsAarmId { get => unitsAarmId; set { unitsAarmId = value; OnPropertyChanged(); ChangeUnits(); } } + public UnitsArea UnitsAMatId { get => unitsAMatId; set { unitsAMatId = value; OnPropertyChanged(); ChangeUnits(); } } + public UnitsLin UnitsLForcId { get => unitsLForcId; set { unitsLForcId = value; OnPropertyChanged(); ChangeUnits(); } } + public UnitsArea UnitsAStressId { get => unitsAStressId; set { unitsAStressId = value; OnPropertyChanged(); ChangeUnits(); } } + public UnitsLin UnitsCrackId { get => unitsCrackId; set { unitsCrackId = value; OnPropertyChanged(); ChangeUnits(); } } + public UnitsForce UnitsFForceId { get => unitsFForceId; set { unitsFForceId = value; OnPropertyChanged(); ChangeUnits(); } } + public UnitsStress UnitsSMatId { get => unitsSMatId; set { unitsSMatId = value; OnPropertyChanged(); ChangeUnits(); + if (value == UnitsStress.МПа || value == UnitsStress.кПа) UnitsAMatId = UnitsArea._; } } + public UnitsStress UnitsSStressId { get => unitsSStressId; set { unitsSStressId = value; OnPropertyChanged(); ChangeUnits(); + if (value == UnitsStress.МПа || value == UnitsStress.кПа) UnitsAStressId = UnitsArea._; } } + + + void ChangeUnits() + { + scaleDimAarm = ScaleAUnits(unitsAarmId); + scaleDimCrack = ScaleLUnits(unitsCrackId); + scaleDimDarm = ScaleLUnits(unitsDarmId); + scaleDimFfrc = ScaleFUnits(unitsFForceId); + scaleDimLength = ScaleLUnits(unitsLId); + scaleDimLfrc = ScaleLUnits(unitsLForcId); + scaleDimSect = ScaleLUnits(unitsSectId); + scaleDimMat = ScaleSUnits(unitsSMatId,unitsAMatId); + scaleDimStress = ScaleSUnits(unitsSStressId, unitsAStressId); + //Bfloat = B / scaleDimSect; + //Hfloat = H / scaleDimSect; + //Dfloat = D / scaleDimSect; + //D1float = D1 / scaleDimSect; + } + + void ChangeValues() + { + //B = bfloat * scaleDimSect; + //H = hfloat * scaleDimSect; + //D = dfloat * scaleDimSect; + //D1 = d1float * scaleDimSect; + } + + double ScaleLUnits(UnitsLin unit) + { + double res = 1; + switch (unit) + { + case UnitsLin.мм: res = 1E-3; break; + case UnitsLin.см: res = 1E-2; break; + } + return res; + } + + double ScaleAUnits(UnitsArea unit) + { + double res = 1; + switch (unit) + { + case UnitsArea.мм: res = 1E-6; break; + case UnitsArea.см: res = 1E-4; break; + } + return res; + } + + double ScaleFUnits(UnitsForce unit) + { + double res = 1; + switch (unit) + { + case UnitsForce.Н: res = 1E+3; break; + case UnitsForce.т: res = 0.10194; break; + } + return res; + } + + double ScaleSUnits(UnitsStress unitS, UnitsArea unitA) + { + double res = 1; + if (unitS == UnitsStress.кН && unitA == UnitsArea.см) res = 1E-4; + if (unitS == UnitsStress.кН && unitA == UnitsArea.мм) res = 1E-6; + if (unitS == UnitsStress.Н && unitA == UnitsArea.м) res = 1E+3; + if (unitS == UnitsStress.Н && unitA == UnitsArea.см) res = 0.1; + if (unitS == UnitsStress.Н && unitA == UnitsArea.мм) res = 1E-3; + if (unitS == UnitsStress.т && unitA == UnitsArea.м) res = 0.10194; + if (unitS == UnitsStress.т && unitA == UnitsArea.см) res = 1E-5; + if (unitS == UnitsStress.т && unitA == UnitsArea.мм) res = 1.01937E-7; + if (unitS == UnitsStress.МПа) res = 1E-3; + return res; + } + } +} diff --git a/VM/ViewModel.cs b/VM/ViewModel.cs new file mode 100644 index 0000000..4ab3af0 --- /dev/null +++ b/VM/ViewModel.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.Serialization.Formatters.Binary; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Interop; +using System.Windows.Media.Imaging; + +namespace GroundOrganizer +{ + public partial class ViewModel : INotifyPropertyChanged + { + string title; + ToSerializ ser = new ToSerializ(); + MainWindow MW; + //MainPage MP; + private string basePath; + + public string BasePath { get => basePath; set { basePath = value; OnPropertyChanged(); } } + + public ViewModel() + { + title = "GroundOrganizer"; + MW = App.Current.MainWindow as MainWindow; + //MW.contentFrame.Content = MP; + MW.Title = title; + BasePath = Properties.Settings.Default.BasePath; + StructureNote = "к числу зданий и сооружений с жесткой конструктивной схемой относятся:" + + "\n- здания панельные, блочные и кирпичные, в которых междуэтажные" + + "\nперекрытия опираются по всему контуру на поперечные и продольные" + + "\nстены или только на поперечные несущие стены при малом их шаге;" + + "\n- сооружения типа башен, силосных корпусов, дымовых труб, домен и др."; + BoresNote = "* положительное значение отметки уровня грунтовых вод относительно устья скважины"; + + } + + private RelayCommand openGroundBase; + public RelayCommand OpenGroundBase + { + get { return openGroundBase ?? (openGroundBase = new RelayCommand(obj => { ReadDB(); })); } + } + + public string Title { get => title; set => title = value; } + + string GetGroundBaseFile() + { + Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog(); + ofd.DefaultExt = "*.*"; + ofd.Filter = "База данных инженерно-геологических площадок (*.grndb)|*.grndb|Все файлы (*.*)|*.*"; + ofd.Title = "Выбор файла с базой данных инженерно-геологических площадок"; + ofd.ShowDialog(); + return ofd.FileName; + } + + internal void SaveDB() + { + //ser = new ToSerializ { PlayGroundList = ListPlayGround }; + // создаем объект BinaryFormatter + BinaryFormatter formatter = new BinaryFormatter(); + // получаем поток, куда будем записывать сериализованный объект + using (FileStream fs = new FileStream(Properties.Settings.Default.BasePath, FileMode.OpenOrCreate)) + { + formatter.Serialize(fs, ListPlayGround); + } + //Alert("Введенные данные успешно сохранены"); + } + + internal void ReadDB() + { + Properties.Settings.Default.BasePath = GetGroundBaseFile(); + Properties.Settings.Default.Save(); + BasePath = Properties.Settings.Default.BasePath; + if (File.Exists(Properties.Settings.Default.BasePath) == true) + { + // создаем объект BinaryFormatter + BinaryFormatter formatter = new BinaryFormatter(); + + using (FileStream fs = new FileStream(Properties.Settings.Default.BasePath, FileMode.OpenOrCreate)) + { + //ToSerializ ser = (ToSerializ)formatter.Deserialize(fs); + ListPlayGround = formatter.Deserialize(fs) as ObservableCollection; + } + } + + } + + public event PropertyChangedEventHandler PropertyChanged; + public void OnPropertyChanged([CallerMemberName]string prop = "") + { + if (PropertyChanged != null) + PropertyChanged(this, new PropertyChangedEventArgs(prop)); + } + } +} diff --git a/Windows/AlertWindow.xaml b/Windows/AlertWindow.xaml new file mode 100644 index 0000000..01fb967 --- /dev/null +++ b/Windows/AlertWindow.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +