tx
2025-04-15 04f9d03e29ce75b4aa0d108a1c2987fe2aaf61f6
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using GCOCC;
using System.IO;
using System.Text;
 
namespace HydrCAD.WinFrmUI.Impeller
{
    public partial class MainViewPage : TabbedMdiXtraForm
    { 
        GCOCC_Point3d ShroundLine1Start;
        GCOCC_Point3d ShroundLine1End;
        GCOCC_Point3d ShroundLine2Control;
        GCOCC_Point3d ShroundLine2End;
        GCOCC_Point3d ShroundLine3End;
        GCOCC_Point3d OutletLineEnd;
        GCOCC_Point3d InletLineStart;
        GCOCC_Point3d HubLine1End;
        GCOCC_Point3d HubLine2Control;
        GCOCC_Point3d HubLine2End;
 
        GCOCC.LineData ShroundLine1;
        GCOCC.LineData ShroundLine2;
        GCOCC.LineData ShroundLine3;
 
        GCOCC.LineData OutletLine;
        GCOCC.LineData InletLine;
 
        GCOCC.LineData HubLine1;
        GCOCC.LineData HubLine2;
        GCOCC.LineData HubLine3;
 
        List<GCOCC.LineData> lines = new List<GCOCC.LineData>();
 
 
 
 
 
        //GCDemo data;
        private void InitOcctDemo()
        {
            //data = new GCDemo();
            ShroundLine1Start = new GCOCC_Point3d(0, 50, 0);
            ShroundLine1End = new GCOCC_Point3d(6.43625613, 50, 0);
            ShroundLine2Control = new GCOCC_Point3d(15.43528266, 53.2753778, 0);
            ShroundLine2End = new GCOCC_Point3d(20.22356467, 61.56892551, 0);
            ShroundLine3End = new GCOCC_Point3d(27, 100, 0);
            OutletLineEnd = new GCOCC_Point3d(45, 100, 0);
            InletLineStart = new GCOCC_Point3d(0, 15, 0);
            HubLine1End = new GCOCC_Point3d(12.57235685, 15, 0);
            HubLine2Control = new GCOCC_Point3d(37.96045984, 25.90758985, 0);
            HubLine2End = new GCOCC_Point3d(47.52439057, 51.83175847, 0);
 
            ShroundLine1 = new GCOCC.LineData(LineType.Straight, new GCOCC_Point3d[] { ShroundLine1Start, ShroundLine1End });
            ShroundLine2 = new GCOCC.LineData(LineType.Arc, new GCOCC_Point3d[] { ShroundLine1End, ShroundLine2Control, ShroundLine2End });
            ShroundLine3 = new GCOCC.LineData(LineType.Straight, new GCOCC_Point3d[] { ShroundLine2End, ShroundLine3End });
 
            OutletLine = new GCOCC.LineData(LineType.Straight, new GCOCC_Point3d[] { ShroundLine3End, OutletLineEnd });
            InletLine = new GCOCC.LineData(LineType.Straight, new GCOCC_Point3d[] { InletLineStart, ShroundLine1Start });
 
            HubLine1 = new GCOCC.LineData(LineType.Straight, new GCOCC_Point3d[] { InletLineStart, HubLine1End });
            HubLine2 = new GCOCC.LineData(LineType.Arc, new GCOCC_Point3d[] { HubLine1End, HubLine2Control, HubLine2End });
            HubLine3 = new GCOCC.LineData(LineType.Straight, new GCOCC_Point3d[] { HubLine2End, OutletLineEnd });
 
 
            //Read(System.IO.Path.Combine(@"D:\WorkData\Pump3D\DPumpHdrV1.0\out", "GridPints.txt"));
 
 
            _occViewer2d = new HydrCAD.WinFrmUI.Viewer.OccBaseViewer();
            _occViewer2d.Dock = DockStyle.Fill;
            _occViewer2d.Name = "OCCViewer2d1";
            this.Controls.Add(_occViewer2d);
        }
 
        /// <summary>
        /// 轴面投影图
        /// </summary>
        public void CreateAxialProjectionDiagram()
        {
            lines.Add(ShroundLine1);
            lines.Add(ShroundLine2);
            lines.Add(ShroundLine3);
            lines.Add(OutletLine);
            lines.Add(InletLine);
            lines.Add(HubLine1);
            lines.Add(HubLine2);
            lines.Add(HubLine3);
            _occViewer2d.View.Draw2dLines(lines.ToArray(), 1);
        }
        List<GCOCC.LineData> _passLines = null;
        /// <summary>
        /// 过流断面
        /// </summary>
        public void CreatCrossSection()
        {
            int flow_num = 10;
 
            _passLines = new List<GCOCC.LineData>();
            List<GCOCC.LineData> shroundLines = new List<GCOCC.LineData> { ShroundLine1, ShroundLine2, ShroundLine3 };
            List<GCOCC.LineData> hubLines = new List<GCOCC.LineData> { HubLine1, HubLine2, HubLine3 };
            var circles = GCOCC_MathMethord.GetMidArcBetweenTwoGroupLinesTest(shroundLines.ToArray(), hubLines.ToArray(), flow_num);
            List<GCOCC.GCOCC_Point2d> starts = new List<GCOCC_Point2d>();
            List<GCOCC.GCOCC_Point2d> mids = new List<GCOCC_Point2d>();
            List<GCOCC.GCOCC_Point2d> ends = new List<GCOCC_Point2d>();
            //var circles = GCOCC_MathMethord.GetMidArcBetweenTwoGroupLines(shroundLines.ToArray(), hubLines.ToArray(), Convert.ToInt32(Numbers.Text));
            foreach (var c in circles)
            {
                GCOCC_Point3d start = new GCOCC_Point3d(c._start.X, c._start.Y, 0);
                GCOCC_Point3d end = new GCOCC_Point3d(c._end.X, c._end.Y, 0);
                GCOCC_Point3d mid = new GCOCC_Point3d(c._mid.X, c._mid.Y, 0);
                starts.Add(new GCOCC_Point2d(c._start.X, c._start.Y));
                mids.Add(new GCOCC_Point2d(c._mid.X, c._mid.Y));
                ends.Add(new GCOCC_Point2d(c._end.X, c._end.Y));
                var isLine = GCOCC_MathMethord.CheckIf3PointsOnALine(start, end, mid);
                GCOCC.LineData l = null;
                if (isLine)
                {
                    l = new GCOCC.LineData(LineType.Straight, new GCOCC_Point3d[] { start, end });
                }
                else
                {
                    l = new GCOCC.LineData(LineType.Arc, new GCOCC_Point3d[] { start, mid, end });
                }
                _passLines.Add(l);
            }
            //View.DrawPoints(starts,"Ps");
            //View.DrawPoints(mids,"Pc");
            //View.DrawPoints(ends,"Ph");
            //View.DrawLines(_passLines, 1);
            _occViewer2d.View.Draw2dLines(_passLines.ToArray(), 1);
        }
        List<GCOCC.LineData> _midFlowCurve = new List<GCOCC.LineData>();
        /// <summary>
        /// 中间流线
        /// </summary>
        public void CreateMiddleFlowCurve()
        {
            if (_passLines == null || _passLines.Count < 3)
                return;
 
            var pts = GCOCC.GCOCC_MathMethord.GetMidPointsFromPassLines(_passLines.ToArray());
            ShroundLine3End = new GCOCC_Point3d(27, 100, 0);
            OutletLineEnd = new GCOCC_Point3d(45, 100, 0);
            pts.Add(new GCOCC_Point2d((ShroundLine3End.X + OutletLineEnd.X) / 2, (ShroundLine3End.Y + OutletLineEnd.Y) / 2));
            List<GCOCC_Point3d> pt3ds = new List<GCOCC_Point3d>();
            foreach (var item in pts)
            {
                GCOCC_Point3d p3d = item.ConvertToPoint3d();
                pt3ds.Add(p3d);
            }
            var midLine = new GCOCC.LineData(LineType.BSpline, pt3ds.ToArray());
            _midFlowCurve.Add(midLine);
            //View.DrawPoints(pts);
            _occViewer2d.View.Draw2dLines(_midFlowCurve.ToArray(), 1);
        }
 
        List<DividedPointData> shroundPoints = new List<DividedPointData>();
        List<DividedPointData> midPoints = new List<DividedPointData>();
        List<DividedPointData> hubPoints = new List<DividedPointData>();
        /// <summary>
        /// 流线分点
        /// </summary>
        public void CreateStreamlineDividingPoint()
        {
            if (_midFlowCurve == null || _midFlowCurve.Count == 0)
                return;
            double Angles = 2.5;
            List<GCOCC.LineData> shroundLines = new List<GCOCC.LineData> { ShroundLine1, ShroundLine2, ShroundLine3 };
            shroundPoints = GCOCC_MathMethord.GetPointsFromStreamLine(shroundLines.ToArray(), Angles);
            shroundPoints.Insert(0, new DividedPointData(new GCOCC_Point2d(ShroundLine3End.X, ShroundLine3End.Y), 0, 0, true, 0, 0));
            List<GCOCC_Point2d> pts = new List<GCOCC_Point2d>();
            shroundPoints.ForEach(x => pts.Add(x.Point));
            _occViewer2d.View.Draw2dPointsWithIndex(pts.ToArray(), null);
 
            List<GCOCC.LineData> hubLines = new List<GCOCC.LineData> { HubLine1, HubLine2, HubLine3 };
            hubPoints = GCOCC_MathMethord.GetPointsFromStreamLine(hubLines.ToArray(), Angles);
            hubPoints.Insert(0, new DividedPointData(new GCOCC_Point2d(OutletLineEnd.X, OutletLineEnd.Y), 0, 0, true, 0, 0));
            List<GCOCC_Point2d> pts2 = new List<GCOCC_Point2d>();
            hubPoints.ForEach(x => pts2.Add(x.Point));
            _occViewer2d.View.Draw2dPointsWithIndex(pts2.ToArray(), null);
 
            midPoints = GCOCC_MathMethord.GetPointsFromStreamLine(_midFlowCurve.ToArray(), Angles);
            midPoints.Insert(0, new DividedPointData(new GCOCC_Point2d(OutletLineEnd.X, OutletLineEnd.Y), 0, 0, true, 0, 0));
            List<GCOCC_Point2d> pts3 = new List<GCOCC_Point2d>();
            midPoints.ForEach(x => pts3.Add(x.Point));
 
            _occViewer2d.View.Draw2dPointsWithIndex(pts3.ToArray(), null);
        }
 
        List<HydrCAD.Model.GridPoint> shroundGridPoints = new List<HydrCAD.Model.GridPoint>();//方格网前盖板流线点集合, 分点坐标 和旋转角度
        List<HydrCAD.Model.GridPoint> hubGridPoints = new List<HydrCAD.Model.GridPoint>();//后盖板
        List<HydrCAD.Model.GridPoint> midGridPoints = new List<HydrCAD.Model.GridPoint>();//中间流线
        List<PointRotateData> shroundRotateDatas = new List<PointRotateData>();//前盖板流线 轴面图坐标 和旋转角度
        List<PointRotateData> hubRotateDatas = new List<PointRotateData>();//后盖板
        List<PointRotateData> midRotateDatas = new List<PointRotateData>();//中间流线
        /// <summary>
        /// 映射方格网
        /// </summary>
        public void CreateMappingGrid()
        {
            if (shroundGridPoints == null || shroundGridPoints.Count == 0)
                return;
 
            List<GCOCC.LineData> shroundLines = new List<GCOCC.LineData> { ShroundLine1, ShroundLine2, ShroundLine3 };
            List<double> shroundGridY = new List<double>();
            shroundGridPoints.ForEach(x => shroundGridY.Add(x.Y));
            var shroundMapPoints = GCOCC_MathMethord.MapGridPointsToStreamLinePoints(shroundLines.ToArray(), shroundPoints, shroundGridY);
            for (int i = 0; i < shroundMapPoints.Count; i++)
            {
                GCOCC_Point3d pt = new GCOCC_Point3d()
                {
                    X = shroundMapPoints[i].X,
                    Y = shroundMapPoints[i].Y,
                    Z = 0
                };
                PointRotateData data = new PointRotateData(pt, 2.5 * i);
                shroundRotateDatas.Add(data);
            }
 
            List<GCOCC.LineData> hubLines = new List<GCOCC.LineData> { HubLine1, HubLine2, HubLine3 };
            List<double> hubGridY = new List<double>();
            hubGridPoints.ForEach(x => hubGridY.Add(x.Y));
            var hubMapPoints = GCOCC_MathMethord.MapGridPointsToStreamLinePoints(hubLines.ToArray(), hubPoints, hubGridY);
            for (int i = 0; i < hubMapPoints.Count; i++)
            {
                GCOCC_Point3d pt = new GCOCC_Point3d()
                {
                    X = hubMapPoints[i].X,
                    Y = hubMapPoints[i].Y,
                    Z = 0
                };
                PointRotateData data = new PointRotateData(pt, 2.5 * i);
                hubRotateDatas.Add(data);
            }
 
            List<double> midGridY = new List<double>();
            midGridPoints.ForEach(x => midGridY.Add(x.Y));
            var midMapPoints = GCOCC_MathMethord.MapGridPointsToStreamLinePoints(_midFlowCurve.ToArray(), midPoints, midGridY);
            for (int i = 0; i < midMapPoints.Count; i++)
            {
                GCOCC_Point3d pt = new GCOCC_Point3d()
                {
                    X = midMapPoints[i].X,
                    Y = midMapPoints[i].Y,
                    Z = 0
                };
                PointRotateData data = new PointRotateData(pt, 2.5 * i);
                midRotateDatas.Add(data);
            }
        }
 
 
        List<GCOCC_Point3d> shroundRotatedPoints;
        List<GCOCC_Point3d> hubRotatedPoints;
        List<GCOCC_Point3d> midRotatedPoints;
        /// <summary>
        /// 叶片设计面造型
        /// </summary>
        public void CreateWorkSheet()
        {
            if (shroundRotateDatas == null || shroundRotateDatas.Count == 0)
                return;
 
            shroundRotatedPoints = GCOCC_MathMethord.RotatePoint(shroundRotateDatas);
            _occViewer2d.View.Draw3dPoints(shroundRotatedPoints.ToArray());
 
            hubRotatedPoints = GCOCC_MathMethord.RotatePoint(hubRotateDatas);
            _occViewer2d.View.Draw3dPoints(hubRotatedPoints.ToArray());
 
            midRotatedPoints = GCOCC_MathMethord.RotatePoint(midRotateDatas);
            _occViewer2d.View.Draw3dPoints(midRotatedPoints.ToArray());
 
            GCOCC.LineData sline = new GCOCC.LineData(LineType.BSpline, shroundRotatedPoints.ToArray());
            GCOCC.LineData hline = new GCOCC.LineData(LineType.BSpline, hubRotatedPoints.ToArray());
            GCOCC.LineData mline = new GCOCC.LineData(LineType.BSpline, midRotatedPoints.ToArray());
 
            //_occViewer2d.View.MakeSurfaceAcrossSplines2(new List<GCOCC.LineData>() { sline, mline, hline }.ToArray());
        }
 
 
 
 
 
    }
}