using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DPumpHydr.WinFrmUI.Volute.ViewModel { public class OutflowParas { public OutflowParas() { } public OutflowParas(OutflowParas rhs) { this.ShapeStyle = rhs.ShapeStyle; this.LinkStyle = rhs.LinkStyle; this.Offset = rhs.Offset; this.Heigh = rhs.Heigh; this.Dia = rhs.Dia; this.Tangent_Top_Right = rhs.Tangent_Top_Right; this.Tangent_Btm_Right = rhs.Tangent_Btm_Right; this.Tangent_Top_Left = rhs.Tangent_Top_Left; this.Tangent_Btm_Left = rhs.Tangent_Btm_Left; this.H1 = rhs.H1; this.H2 = rhs.H2; this.R1 = rhs.R1; this.R2 = rhs.R2; this.Septalradius = rhs.Septalradius; } public ViewModel.eOutflowShapeStyle ShapeStyle { get; set; } = ViewModel.eOutflowShapeStyle.未知; public ViewModel.eOutflowLinkStyle LinkStyle { get; set; } = ViewModel.eOutflowLinkStyle.曲线; public double Offset { get; set; } //图片中的A = 0.0; public double Heigh { get; set; } //图片中的L = 420.0; public double Dia { get; set; } //图片中的D4 = 80.0; public double Tangent_Top_Right { get; set; } = 1.0; //切线缩放量 = m_dTopValue; public double Tangent_Btm_Right { get; set; } = 1.0; //切线缩放量 = m_dBtmValue; public double Tangent_Top_Left { get; set; } = 1.0; //切线缩放量 = m_dTopValue; public double Tangent_Btm_Left { get; set; } = 1.0; //切线缩放量 = m_dBtmValue; public double R1 { get; set; }//圆弧连接时的R1 public double R2 { get; set; }//圆弧连接时的R2 public double H1 { get; set; } //图片中的H1 = 10; public double H2 { get; set; } //图片中的H2 = 10; public double Septalradius { get; set; } //隔舌半径r public double CalR2( ViewModel.HdrBaseInfo hdrBaseInfo, ViewModel.GeomBaseInfo geomBaseInfo, ViewModel.SectionBundleInfo sectionBundleInfo) { double r2 = 0; double scale2 = ((this.Heigh / 100) >= (sectionBundleInfo.H[6] / 75)) ? (this.Heigh / 100) : (sectionBundleInfo.H[6] / 75); PointD pt02 = new PointD(300, 100); if (scale2 <= 0.05) scale2 = 0.05; if ((scale2 > 0.05) && (scale2 <= 0.1)) scale2 = 0.1; if ((scale2 > 0.1) && (scale2 <= 0.2)) scale2 = 0.2; if ((scale2 > 0.2) && (scale2 <= 0.25)) scale2 = 0.25; if ((scale2 > 0.25) && (scale2 <= 0.4)) scale2 = 0.4; if ((scale2 > 0.4) && (scale2 <= 0.5)) scale2 = 0.5; if ((scale2 > 0.5) && (scale2 <= 1.0)) scale2 = 1; if ((scale2 > 1.0) && (scale2 <= 1.5)) scale2 = 1.5; if ((scale2 > 1.5) && (scale2 <= 2.0)) scale2 = 2.0; if ((scale2 > 2.0) && (scale2 <= 2.5)) scale2 = 2.5; if ((scale2 > 2.5) && (scale2 <= 3)) scale2 = 3; if ((scale2 > 3) && (scale2 <= 4)) scale2 = 4; if ((scale2 > 4) && (scale2 <= 5)) scale2 = 5; if ((scale2 > 5) && (scale2 <= 6)) scale2 = 6; if ((scale2 > 6) && (scale2 <= 7)) scale2 = 7; if ((scale2 > 7) && (scale2 <= 8)) scale2 = 8; if ((scale2 > 8) && (scale2 <= 9)) scale2 = 9; if ((scale2 > 9) && (scale2 <= 10)) scale2 = 10; if ((scale2 > 10) && (scale2 <= 15)) scale2 = 15; if ((scale2 > 15) && (scale2 <= 20)) scale2 = 20; if ((scale2 > 20) && (scale2 <= 25)) scale2 = 25; if ((scale2 > 25) && (scale2 <= 30)) scale2 = 30; if ((scale2 > 35) && (scale2 <= 40)) scale2 = 40; PointD pth12 = GeometryHelper.AdsPolar(pt02, GeometryHelper.DegreesToRadians(90), this.Heigh / scale2); pth12 = GeometryHelper.AdsPolar(pth12, GeometryHelper.DegreesToRadians(0), this.Offset / scale2); PointD pth6 = GeometryHelper.AdsPolar(pt02, GeometryHelper.DegreesToRadians(-90), (geomBaseInfo.D3 / 2 + sectionBundleInfo.H[6]) / scale2); PointD pth7 = GeometryHelper.AdsPolar(pt02, GeometryHelper.DegreesToRadians(-45), (geomBaseInfo.D3 / 2 + sectionBundleInfo.H[7]) / scale2); PointD pth8 = GeometryHelper.AdsPolar(pt02, GeometryHelper.DegreesToRadians(0), (geomBaseInfo.D3 / 2 + sectionBundleInfo.H[8]) / scale2); PointD pt1 = GeometryHelper.AdsPolar(pth6, GeometryHelper.DegreesToRadians(0), 0); PointD pt2 = GeometryHelper.AdsPolar(pth7, GeometryHelper.DegreesToRadians(0), 0); PointD pt3 = GeometryHelper.AdsPolar(pth8, GeometryHelper.DegreesToRadians(0), 0); double a1 = 2 * (pt1.X - pt2.X); double b1 = 2 * (pt1.Y - pt2.Y); double c1 = pt1.X * pt1.X - pt2.X * pt2.X + pt1.Y * pt1.Y - pt2.Y * pt2.Y; double A1 = 2 * (pt3.X - pt2.X); double B1 = 2 * (pt3.Y - pt2.Y); double C1 = pt3.X * pt3.X - pt2.X * pt2.X + pt3.Y * pt3.Y - pt2.Y * pt2.Y; double ptc4_Y = (A1 * c1 - a1 * C1) / (A1 * b1 - a1 * B1); double ptc4_X = (c1 - b1 * ptc4_Y) / a1; double rr4 = Math.Sqrt((pt2.X - ptc4_X) * (pt2.X - ptc4_X) + (pt2.Y - ptc4_Y) * (pt2.Y - ptc4_Y)); // 计算 R2 pt1 = GeometryHelper.AdsPolar(pth12, GeometryHelper.DegreesToRadians(0), this.Dia / 2 / scale2); a1 = 2 * (rr4 + ptc4_X - pt1.X); b1 = (ptc4_Y - pt1.Y) * (ptc4_Y - pt1.Y) - rr4 * rr4 + (ptc4_X - pt1.X) * (ptc4_X - pt1.X); r2 = (b1 / a1) * scale2; r2 = Math.Round(r2, 2); return r2; } } public static class GeometryHelper { // 将角度从度转换为弧度 public static double DegreesToRadians(double degrees) { return degrees * Math.PI / 180.0; } // 计算极坐标点 public static PointD AdsPolar(PointD startPoint, double angleInRadians, double distance) { double newX = startPoint.X + distance * Math.Cos(angleInRadians); double newY = startPoint.Y + distance * Math.Sin(angleInRadians); return new PointD(newX, newY); } } public struct PointD { public double X { get; set; } public double Y { get; set; } public PointD(double x, double y) { X = x; Y = y; } public override string ToString() { return $"({X}, {Y})"; } } public class OutflowParasCalcReponse { public bool IsSuccess { get; set; } public double SectArea9 { get; set; } //9 截面面积 public double SectArea10 { get; set; } //10 截面面积 } }