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 lines = new List(); //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); } /// /// 轴面投影图 /// 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 _passLines = null; /// /// 过流断面 /// public void CreatCrossSection() { int flow_num = 10; _passLines = new List(); List shroundLines = new List { ShroundLine1, ShroundLine2, ShroundLine3 }; List hubLines = new List { HubLine1, HubLine2, HubLine3 }; var circles = GCOCC_MathMethord.GetMidArcBetweenTwoGroupLinesTest(shroundLines.ToArray(), hubLines.ToArray(), flow_num); List starts = new List(); List mids = new List(); List ends = new List(); //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 _midFlowCurve = new List(); /// /// 中间流线 /// 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 pt3ds = new List(); 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 shroundPoints = new List(); List midPoints = new List(); List hubPoints = new List(); /// /// 流线分点 /// public void CreateStreamlineDividingPoint() { if (_midFlowCurve == null || _midFlowCurve.Count == 0) return; double Angles = 2.5; List shroundLines = new List { 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 pts = new List(); shroundPoints.ForEach(x => pts.Add(x.Point)); _occViewer2d.View.Draw2dPointsWithIndex(pts.ToArray(), null); List hubLines = new List { 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 pts2 = new List(); 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 pts3 = new List(); midPoints.ForEach(x => pts3.Add(x.Point)); _occViewer2d.View.Draw2dPointsWithIndex(pts3.ToArray(), null); } List shroundGridPoints = new List();//方格网前盖板流线点集合, 分点坐标 和旋转角度 List hubGridPoints = new List();//后盖板 List midGridPoints = new List();//中间流线 List shroundRotateDatas = new List();//前盖板流线 轴面图坐标 和旋转角度 List hubRotateDatas = new List();//后盖板 List midRotateDatas = new List();//中间流线 /// /// 映射方格网 /// public void CreateMappingGrid() { if (shroundGridPoints == null || shroundGridPoints.Count == 0) return; List shroundLines = new List { ShroundLine1, ShroundLine2, ShroundLine3 }; List shroundGridY = new List(); 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 hubLines = new List { HubLine1, HubLine2, HubLine3 }; List hubGridY = new List(); 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 midGridY = new List(); 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 shroundRotatedPoints; List hubRotatedPoints; List midRotatedPoints; /// /// 叶片设计面造型 /// 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() { sline, mline, hline }.ToArray()); } } }