TopoShape CreateShape() { GPntList v3list = new GPntList(); double[,] startpiont = new double[1, 3] { { 0, 0, 10 } }; //起点 double length = 10; //波长 double width = 4; //波峰减去波谷差值 int nums = 5; //支点个数 double[,] list = GetVerticalCurveList(startpiont, length, width, nums); for (int i = 0; i < list.GetLength(0); i++) { GPnt P0 = new GPnt(list[i, 0], list[i, 1], list[i, 2]);//直井井室入口 起点 v3list.Add(P0); } GVec aa = new GVec(); aa.SetXYZ(v3list[1].XYZ()); GVec bb = new GVec(); bb.SetXYZ(v3list[0].XYZ()); GDir dir = new GDir(); dir.SetXYZ(aa.Subtracted(bb).XYZ()); TopoShape section = SketchBuilder.MakeCircle(v3list[0], 0.1, dir); TopoShape line9 = SketchBuilder.MakeBSpline(v3list); return(FeatureTool.Sweep(section, line9, EnumGeomFillTrihedron.CorrectedFrenet)); }
public override void Run(RenderControl render) { var sketch = SketchBuilder.MakeEllipse(GP.Origin(), 5, 3, GP.DX(), GP.DZ()); // 1. Sweep { GPntList points = new GPntList { GP.Origin(), new GPnt(20, 10, 30), new GPnt(50, 50, 50), }; var path = SketchBuilder.MakeBSpline(points); render.ShowShape(path, Vector3.Green); var feature = FeatureTool.Sweep(sketch, path, EnumGeomFillTrihedron.ConstantNormal); render.ShowShape(feature, Vector3.Blue); } // 2. Revol { var feature = FeatureTool.Revol(sketch, new GAx1(new GPnt(-20, 0, 0), GP.DY()), 90); render.ShowShape(feature, Vector3.Green); } // 3. Loft { var baseWire = SketchBuilder.MakeRectangle(new GAx2(new GPnt(50, -50, 0), GP.DZ()), 20, 20, 5, false); var topWire = SketchBuilder.MakeCircle(new GPnt(60, -40, 40), 5, GP.DZ()); var loft = FeatureTool.Loft(baseWire, topWire, true); render.ShowShape(loft, Vector3.Red); } }
public override void Run(RenderControl render) { GPntList points = new GPntList(); string fileName = GetResourcePath("data/CableViewInfo.txt"); using (StreamReader reader = File.OpenText(fileName)) { while (!reader.EndOfStream) { var line = reader.ReadLine(); var items = line.Split(','); if (items.Length < 3) { continue; } double x = double.Parse(items[0]); double y = double.Parse(items[1]); double z = double.Parse(items[2]); points.Add(new GPnt(x, y, z)); } } var path = SketchBuilder.MakeBSpline(points); render.ShowShape(path, ColorTable.Red); var curve = new ParametricCurve(path); var rt = curve.D1(curve.FirstParameter()); var position = rt.GetPoint(); var dir = new GDir(rt.GetVectors()[0]); var sketch = SketchBuilder.MakeCircle(position, 1, dir); var pipe = FeatureTool.Sweep(sketch, path, EnumGeomFillTrihedron.ConstantNormal); if (pipe != null) { render.ShowShape(pipe, new Vector3(0.8f)); } }
public override void Run(RenderControl render) { double dS = 19.0; //弹簧螺距mm double dR = 11.25; //1/2弹簧中径mm double dr1 = 0.9; //内层钢丝半径mm double dr2 = 0.9; //外层钢丝半径mm double dr = dr1 + dr2; //钢丝轴心分布半径mm double da1 = 0.29; //弹簧螺旋角rad double dw0 = 1; //卷簧轴转速rad/s double dw1 = 5; //拧索轴转速rad/s int nOutterCount = 5; //外层钢丝股数 { // create the intter path GPntList pts = new GPntList(); for (double t = 0; t < 10; t += 0.1) { pts.Add(getIntterMultiSpingCoord(t, dS, dR, dw0)); } var path = SketchBuilder.MakeBSpline(pts); // Get the sketch position and direction var curve = new ParametricCurve(path); var rt = curve.D1(curve.FirstParameter()); var position = rt.GetPoint(); var dir = new GDir(rt.GetVectors()[0]); var sketch = SketchBuilder.MakeCircle(position, dr1, dir); // Create pipe var pipe = FeatureTool.Sweep(sketch, path, EnumGeomFillTrihedron.CorrectedFrenet); render.ShowShape(pipe, new Vector3(0.8f)); } Vector3[] colors = new Vector3[] { new Vector3(1.0f, 0, 0), new Vector3(1, 1, 0), new Vector3(0.5f, 1, 0), new Vector3(0, 1, 64 / 255.0f), new Vector3(0, 1, 1) }; // create the outter path for (int i = 0; i < nOutterCount; i++) { GPntList pts = new GPntList(); for (double t = 0; t < 10; t += 0.1) { pts.Add(getOutterMultiSpingCoord(t, dS, dR, dr, da1, dw0, dw1, i * 2 * Math.PI / nOutterCount)); } var path = SketchBuilder.MakeBSpline(pts); // Get the sketch position and direction var curve = new ParametricCurve(path); var rt = curve.D1(curve.FirstParameter()); var position = rt.GetPoint(); var dir = new GDir(rt.GetVectors()[0]); var sketch = SketchBuilder.MakeCircle(position, dr2, dir); // Create pipe var pipe = FeatureTool.Sweep(sketch, path, EnumGeomFillTrihedron.CorrectedFrenet); render.ShowShape(pipe, colors[i]); } }