//Butt valley public Brep[] ValleyButt(Point3d p2, Vector3d v12, Vector3d v23, double maxLength, int orientation) { Brep[] output = new Brep[2]; output[0] = new Brep(); output[1] = new Brep(); Vector3d vv = Vector3d.CrossProduct(v12, v23); if (vv.Z * orientation > 0) { Vector3d perp12 = Vector3d.CrossProduct(v12, Vector3d.ZAxis * orientation); perp12.Unitize(); Vector3d move12 = perp12 + Vector3d.ZAxis; move12 *= maxLength; Vector3d perp23 = Vector3d.CrossProduct(v23, Vector3d.ZAxis * orientation); perp23.Unitize(); Vector3d move23 = perp23 + Vector3d.ZAxis; move23 *= maxLength; Line l12 = new Line(p2 + move12, v12); Line l23 = new Line(p2 + move23, v23); Point3d pmid = p2 + (move23 + move12) / 2; double a, b; if (Rhino.Geometry.Intersect.Intersection.LineLine(l12, l23, out a, out b, 0.01, false)) { pmid = l12.PointAt(a); } var sweep = new Rhino.Geometry.SweepTwoRail(); sweep.AngleToleranceRadians = RhinoDoc.ActiveDoc.ModelAngleToleranceRadians; sweep.ClosedSweep = false; sweep.SweepTolerance = RhinoDoc.ActiveDoc.ModelAbsoluteTolerance; Brep[] sideBreps = sweep.PerformSweep(new LineCurve(p2 + move12, p2), new LineCurve(pmid, p2), new LineCurve(p2 + move12, pmid)); if (sideBreps.Length > 0) { output[0] = sideBreps[0]; } sideBreps = sweep.PerformSweep(new LineCurve(pmid, p2), new LineCurve(p2 + move23, p2), new LineCurve(pmid, p2 + move23)); if (sideBreps.Length > 0) { output[1] = sideBreps[0]; } } return(output); }
//Square Valley public Brep ValleySquare(Point3d p2, Vector3d v12, Vector3d v23, double maxLength, int orientation) { Brep output = new Brep(); Vector3d vv = Vector3d.CrossProduct(v12, v23); if (vv.Z * orientation > 0) { Vector3d perp12 = Vector3d.CrossProduct(v12, Vector3d.ZAxis * orientation); perp12.Unitize(); Vector3d move12 = perp12 + Vector3d.ZAxis; move12 *= maxLength; Vector3d perp23 = Vector3d.CrossProduct(v23, Vector3d.ZAxis * orientation); perp23.Unitize(); Vector3d move23 = perp23 + Vector3d.ZAxis; move23 *= maxLength; var sweep = new Rhino.Geometry.SweepTwoRail(); sweep.AngleToleranceRadians = RhinoDoc.ActiveDoc.ModelAngleToleranceRadians; sweep.ClosedSweep = false; sweep.SweepTolerance = RhinoDoc.ActiveDoc.ModelAbsoluteTolerance; Brep[] sideBreps = sweep.PerformSweep(new LineCurve(p2 + move12, p2), new LineCurve(p2 + move23, p2), new LineCurve(p2 + move12, p2 + move23)); if (sideBreps.Length > 0) { output = sideBreps[0]; } } return(output); }