tangxu
2024-11-04 ebd031e3bed6c1cfddce8fc9b98f7f9e95fb9e32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace DPumpHydr.WinFrmUI.Volute.ViewModel
{
    /// <summary>
    /// 单个端面参数
    /// </summary>
    public class SectionShapePara
    {
        public int Index { get; set; }//断面序号  第8断面就是8 第一断面就是1
        public double Gama_Left { get; set; }//角度1 
        public double Gama_Right { get; set; }//角度2
        public double H { get; set; }//高度
        public double R_out { get; set; }//外围的半径 UG中R4
        public double R_Left { get; set; }//角度1边对应的圆角半径 UG中R1
        public double R_Right { get; set; }//角度2边对应的圆角半径 UG中R2
        public double SectionArea { get; set; }//面积:由occ计算
        public double BaseWidth { get; set; }//底部宽度 就是B3
        public double BaseCircleRadius { get; set; }//底部圆半径 就是D3/2
        public eSectionShapeType ShapeType { get; set; }
 
 
 
        public string DeriveArgument(ViewModel.SectionBundleInfo sectionBaseInfo)
        {
            var jsonArray = new StringBuilder("[\n");
            //for (int i = 1; i < sectionBaseInfo.GaMa1.Count - 1; i++)
            //{
            //    Initialparameters(i, sectionBaseInfo);
            //    jsonArray.Append("    {\n");
            //    jsonArray.AppendFormat("        \"Index\":{0},\n", this.Index);
            //    jsonArray.AppendFormat("        \"Gama_Left\":{0:F2},\n", this.Gama_Left);
            //    jsonArray.AppendFormat("        \"Gama_Right\":{0:F2},\n", this.Gama_Right);
            //    jsonArray.AppendFormat("        \"H\":{0:F2},\n", this.H);
            //    jsonArray.AppendFormat("        \"R_out\":{0:F2},\n", this.R_out);
            //    jsonArray.AppendFormat("        \"R_Left\":{0:F2},\n", this.R_Left);
            //    jsonArray.AppendFormat("        \"R_Right\":{0:F2},\n", this.R_Right);
            //    jsonArray.AppendFormat("        \"SectionArea\":{0:F2},\n", this.SectionArea);
            //    jsonArray.AppendFormat("        \"BaseWidth\":{0:F2},\n", this.BaseWidth);
            //    jsonArray.AppendFormat("        \"BaseCircleRadius\":{0:F2}\n", this.BaseCircleRadius);
            //    jsonArray.Append("    },\n"); // 结束对象
            //}
            //jsonArray.Length -= 2;
            //jsonArray.Append("\n");
            //jsonArray.Append("]"); // 结束数组
            return jsonArray.ToString();
        }
 
        //public static void WriteToFile(string json, string filePath)
        //{
        //    File.WriteAllText(filePath, json);
        //}
 
        /// <summary>
        /// 根据面积计算高度
        /// </summary>
        public double CalcHeightByArea(eSectionShapeType SectionType)
        {
            double a = (Math.Tan(Gama_Left * Math.PI / 180) + Math.Tan(Gama_Right * Math.PI / 180)) / 2;
            double b = BaseWidth;
            double c = (90 + Gama_Right) / 360 * Math.PI * R_Left * R_Left + (90 + Gama_Left) / 360 * Math.PI * R_Right * R_Right
                - R_Left * R_Left * Math.Tan((45 + Gama_Right / 2) * Math.PI / 180) - R_Right * R_Right * Math.Tan((45 + Gama_Left / 2) * Math.PI / 180) - SectionArea;
            double delta = b * b - 4 * a * c;
            if (delta < 0) return -1;
            if (SectionType == eSectionShapeType.矩形)//矩形
            {
                return -c / b;
            }
            else
            {
                if (delta < 0) return -1;
                return (-b + Math.Sqrt(delta)) / (2 * a);
            }
        }
 
 
 
        /// <summary>
        /// 验证是否合理
        /// </summary>
        /// <param name="sectionShapePara"></param>
        /// <param name="index"></param>、
        public bool Verify(out string error)
        {
            error = "";
            bool isverify = true;
            if ((this.H - this.R_Left) * Math.Tan(this.Gama_Left)+(this.H - this.R_Right) * Math.Tan(this.R_Right)+this.BaseWidth >= this.R_Right + this.R_Left)
            {
                error = "输入的直径非法!";
                isverify = false;
            }
            if(this.Gama_Left > 45 || this.Gama_Right > 45)
            {
                error = "输入的角度非法!";
                isverify = false;
            }
            return isverify;
        }
        //private double DecreaseR = 0.5;
        //public bool  CalculateR(HdrBaseInfo BaseInfo, SectionBaseInfo sectionBaseInfo, GeomBaseInfo geomBaseInfo, bool isFirst)
        //{
        //    if (!isFirst)
        //    {
        //        R_Left = R_Left - DecreaseR;
        //        R_Right = R_Right - DecreaseR;
 
        //        if (R_Left > (H - 1))
        //            R_Left = Math.Round(H * 0.85 - 1,0);
        //        if (R_Right > (H - 1))
        //            R_Right = Math.Round(H * 0.85 - 1,0);
 
        //        if (R_Left < 2)
        //            R_Left = 2;
        //        if (R_Right < 2)
        //            R_Right = 2;
        //    }
        //    else//是第一次计算
        //    {
 
        //        //赋值:R1 R2 R3 R4 
        //        if (sectionBaseInfo.ShapeType ==  eSectionShapeType.对称) //type=0:对称梯形
        //            R_Left = Math.Round(BaseWidth * 0.55 + 0.5  - 4,0);
        //        else if (sectionBaseInfo.ShapeType == eSectionShapeType.不对称)//type=1:不对称梯形
        //            R_Left = Math.Round(BaseWidth * 0.55 + 0.5  - 4,0);
        //        else if (sectionBaseInfo.ShapeType == eSectionShapeType.矩形)//type=2:矩形
        //            R_Left = Math.Round(BaseWidth * 0.4 + 0.5  - 2,0);
 
 
        //        if (BaseInfo.IsSXB)
        //            R_Left = Math.Round(R_Left / 2,0);
        //        //if (DesignMode == YSSnxOpen::DesignMode::AssPawuQnshQw1)
        //        //{
        //        //    R_Left = int(R_Left * 0.7);
        //        //}
        //        double m_R3 = 0;
        //        double t = 0;
        //        if (BaseWidth <= 35)
        //            m_R3 = 5;
        //        else if (BaseWidth <= 60 && BaseWidth > 35)
        //        {
        //            t = Math.Round(BaseWidth * 0.6, 0) - Math.Round(BaseWidth * 0.6 / 10.0, 0) * 10;
        //            if (t <= 2)
        //                m_R3 = Math.Round(BaseWidth * 0.6 / 10.0, 0) * 10;
        //            else if (t > 2 && t <= 7)
        //                m_R3 = Math.Round(BaseWidth * 0.6 / 10.0, 0) * 10 + 5;
        //            else if (t > 7)
        //                m_R3 = Math.Round(BaseWidth * 0.6 / 10.0, 0) * 10 + 10;
        //        }
        //        else if (BaseWidth > 60 && BaseWidth <= 90)
        //        {
        //            t = Math.Round(BaseWidth * 0.9, 0) - Math.Round(BaseWidth * 0.9 / 10.0, 0) * 10;
        //            if (t <= 2)
        //                m_R3 = Math.Round(BaseWidth * 0.9 / 10.0, 0) * 10;
        //            else if (t > 2 && t <= 7)
        //                m_R3 = Math.Round(BaseWidth * 0.9 / 10.0, 0) * 10 + 5;
        //            else if (t > 7)
        //                m_R3 = Math.Round(BaseWidth * 0.9 / 10.0, 0) * 10 + 10;
        //        }
        //        else if (BaseWidth > 90)
        //        {
        //            t = Math.Round(BaseWidth * 0.3, 0) - Math.Round(BaseWidth * 0.3 / 10.0, 0) * 10;
        //            if (t <= 2)
        //                m_R3 = Math.Round(BaseWidth * 0.3 / 10.0, 0) * 10;
        //            else if (t > 2 && t <= 7)
        //                m_R3 = Math.Round(BaseWidth * 0.3 / 10.0, 0) * 10 + 5;
        //            else if (t > 7)
        //                m_R3 = Math.Round(BaseWidth * 0.3 / 10.0, 0) * 10 + 10;
        //        }
 
        //        R_Right = R_Left;
        //        R_out = 1000.0;
 
        //        //截面R1 和 R4的减少角度 DecreaseR
        //        if (BaseWidth < 15)
        //        {
        //            DecreaseR = 0.5;
        //        }
        //        else if (BaseWidth >= 15 && BaseWidth < 25)
        //        {
        //            DecreaseR = 1;
        //        }
        //        else if (BaseWidth >= 25 && BaseWidth < 45)
        //        {
        //            DecreaseR = 1.5;
        //        }
        //        else if (BaseWidth >= 45)
        //        {
        //            DecreaseR = 2;
        //        }
 
        //        if (BaseInfo.IsSXB)
        //            DecreaseR = 1;
        //    }
 
        //    return true;
        //}
    }
}