//THIS FUNCTION IS TEMPORARY. The function generates a box or a sweep. This determined by the linearity of the curve. public Brep MakeBrep() { Brep Geometri = new Brep(); double[] parameter = { 0.0, 2.2 }; Plane tempPlane = new Plane(elemLine.PointAtStart, elemLine.TangentAtStart); Ali.rotationVectorToPoint(elemLine.PointAtStart); Vector3d alignvector = Ali.Rotation; //Getting rotation angle double angle = Rhino.Geometry.Vector3d.VectorAngle(tempPlane.XAxis, alignvector, tempPlane); tempPlane.Rotate(angle, tempPlane.Normal, tempPlane.Origin); tempPlane.Translate(tempPlane.XAxis * Ali.OffsetY); tempPlane.Translate(tempPlane.YAxis * Ali.OffsetZ); Interval iz = new Interval(); Interval iy = new Interval(); Interval ix = new Interval(); double HalfWidth = rectSec.Width / 2; double HalfHeight = rectSec.Height / 2; iz = new Interval(-HalfHeight, HalfHeight); iy = new Interval(-HalfWidth, HalfWidth); ix = new Interval(0, elemLine.GetLength()); if (elemLine.IsLinear()) { Box boxen = new Box(tempPlane, iy, iz, ix); Geometri = boxen.ToBrep(); } else { SweepOneRail tempsweep = new SweepOneRail(); Rectangle3d rect = new Rectangle3d(tempPlane, iy, iz); rect.ToPolyline(); var sweep = tempsweep.PerformSweep(elemLine, rect.ToNurbsCurve()); Geometri = sweep[0]; } return(Geometri); }
public static Brep [] Sweep(this Curve centreCrv, double thickness) { Vector3d tan = centreCrv.TangentAtStart; Vector3d projTan = new Vector3d(tan.X, tan.Y, 0); Vector3d norm = Engine.Geometry.Compute.CrossProduct(projTan / projTan.Length, Vector3d.ZAxis); Line crossSection = new Line(centreCrv.PointAtStart - norm * thickness / 2, norm * thickness); Rhino.Geometry.SweepOneRail sweepOne = new SweepOneRail(); Brep[] b = sweepOne.PerformSweep(centreCrv, crossSection.ToNurbsCurve()); return(b); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Curve railCurve = null; double radius = 0; int segments = 0; double angle = 0; if (!DA.GetData(0, ref railCurve)) { return; } if (!DA.GetData(1, ref radius)) { return; } if (!DA.GetData(2, ref segments)) { return; } if (!DA.GetData(3, ref angle)) { return; } /////////////////////////////////////////////////// Curve x = railCurve; double y = radius; int n = segments; Vector3d vc = x.TangentAtStart; Plane pl = new Plane(x.PointAtStart, vc); Polyline ply = ViperClass.CreatePolyline(pl, y, n); ply.Transform(Transform.Rotation(angle, pl.ZAxis, pl.Origin)); NurbsCurve nc = ply.ToNurbsCurve(); SweepOneRail swp = new SweepOneRail(); Brep[] bs = swp.PerformSweep(x, nc); DA.SetDataList(0, bs); }