public void Brep_Intersection() { // Arrange var radius = 4.0; var brep = Brep.CreateFromSphere(new Sphere(new Point3d(), radius)); var cuttingPlane = Plane.WorldXY; // Act Rhino.Geometry.Intersect.Intersection.BrepPlane(brep, cuttingPlane, 0.001, out var curves, out var points); // Assert Assert.AreEqual(1, curves.Length, "Wrong curve count"); Assert.AreEqual(2 * Math.PI * radius, curves[0].GetLength(), "Wrong curve length"); }
public Brep ToBrep() { return(Brep.CreateFromSphere(this)); }
protected override void SolveInstance(IGH_DataAccess DA) { // input parameter definition List <Curve> polylines = new List <Curve>(); DA.GetDataList(0, polylines); List <int> syntax = new List <int>(); DA.GetDataList(1, syntax); List <string> hooking = new List <string>(); DA.GetDataList(2, hooking); List <Point3d> anchorpts = new List <Point3d>(); DA.GetDataList(3, anchorpts); // neue liste die in for schleife benutzt wird machen List <Vector3d> anchorvecs = new List <Vector3d>(); DA.GetDataList(4, anchorvecs); List <Vector3d> nanchorvecs = new List <Vector3d>(); // normed anchorvecs foreach (Vector3d anchorvec in anchorvecs) { Vector3d nanchorvec = anchorvec / anchorvec.Length; // calc of normed anchorvec -> list: nanchorvecs nanchorvecs.Add(nanchorvec); } double anchorparam = 0; DA.GetData(5, ref anchorparam); double washerparam = 0; DA.GetData(6, ref washerparam); double sphereparam = 0; DA.GetData(7, ref sphereparam); Boolean leftrot = new Boolean(); DA.GetData(8, ref leftrot); // input parameter definition // output and code parameter definition : global variables List <Point3d> checkpts = new List <Point3d>(); List <Point3d> pathpts = new List <Point3d>(); List <Vector3d> orivecs = new List <Vector3d>(); List <Vector3d> tanvecs = new List <Vector3d>(); List <double> time = new List <double>(); List <Sphere> spheres = new List <Sphere>(); List <Curve> curves = new List <Curve>(); double fiberlength = 0; int neg = 0; int h = 0; Point3d endpt = new Point3d(); Point3d startpt = new Point3d(); Point3d ipt2 = new Point3d(); Vector3d vec2 = new Vector3d(); Vector3d veca2 = new Vector3d(); Curve polyline1 = polylines[0]; List <Arc> arc = new List <Arc>(); Brep sph2 = new Brep(); // output and code parameter definition // code: first anchor separately calculated Point3d anchorpt0 = anchorpts[syntax[0]]; Point3d anchorpt1 = anchorpts[syntax[1]]; Vector3d vec0 = anchorpt1 - anchorpt0; Vector3d nlinevec0 = vec0 / vec0.Length; // norm Vector3d nanchorvec0 = nanchorvecs[syntax[0]]; Vector3d crossvec0 = Vector3d.CrossProduct(nanchorvec0, nlinevec0); // right hand system Point3d arcminpt0 = new Point3d(anchorpt0 - crossvec0 * washerparam); Point3d arcmaxpt0 = new Point3d(anchorpt0 + crossvec0 * washerparam); // first hooking if (leftrot == true) { startpt = arcmaxpt0; endpt = arcminpt0; } else { startpt = arcminpt0; endpt = arcmaxpt0; } checkpts.Add(endpt); Arc arc0 = new Arc(startpt, -nlinevec0, endpt); arc.Add(arc0); // Path by Syntax for (int i = 1; i < syntax.Count - 1; i++) { anchorpt0 = anchorpts[syntax[i - 1]]; // hooking position can differ from anchor mid point anchorpt1 = anchorpts[syntax[i]]; Point3d pt0 = anchorpt0; Point3d pt1 = anchorpt1; Sphere sphere0 = new Sphere(anchorpt0, sphereparam); Brep sph0 = Brep.CreateFromSphere(sphere0); Sphere sphere1 = new Sphere(anchorpt1, sphereparam); Brep sph1 = Brep.CreateFromSphere(sphere1); Curve polyline0 = polylines[i - 1]; polyline1 = polylines[i]; Intersection.CurveBrep(polyline0, sph0, 0, out Curve[] curve1, out Point3d[] ipt);
public Brep RhinoSphere() { //return new Sphere(centrePoint, radius); return(Brep.CreateFromSphere(new Sphere(centrePoint, radius))); }