/// <summary> /// Add primitive plane and material. /// </summary> /// <param name="plane">Plane to add.</param> /// <param name="material"> /// Material to add, may be null if not needed. /// </param> public void Add(PlaneSurface plane, RenderMaterial material) { var material_pointer = (null == material ? IntPtr.Zero : material.ConstPointer()); var pointer = NonConstPointer(); UnsafeNativeMethods.Rdk_CustomMeshes_AddPlane(pointer, plane.ConstPointer(), material_pointer); }
// Methods from PolyFitv3 SolidBuilder // Planes to Planars... integrated method // Planes to Planars... integrated method // RooFit: need to set planes' origin to extrusion's origin public List <Brep> PlanesToPlanars(List <Plane> refinedPlanes, Brep ftExtrusion, double tolerance) { Vector3d diagonal = ftExtrusion.GetBoundingBox(false).Diagonal; // RooFit compatible. Point3d centroid = ComputeCentroid(ftExtrusion); List <Plane> planeList = SetPlaneOriginCloseTo(refinedPlanes, centroid); double length = diagonal.Length; Interval maxInterval = new Interval(-length, length); List <PlaneSurface> surfaceList = new List <PlaneSurface>(); List <Brep> planarList = new List <Brep>(); for (int i = 0; i < planeList.Count; i++) { Plane plane = planeList[i]; // RooFit compatible, set origin // plane.Origin = centroid; PlaneSurface pSurface = new PlaneSurface(plane, maxInterval, maxInterval); surfaceList.Add(pSurface); Brep brep = pSurface.ToBrep(); Brep planar = brep.Trim(ftExtrusion, tolerance)[0]; if (planar != null) { planarList.Add(planar); } } // Plane Operations: Refine Extrated Planes, Generate Wall Planes.. etc. return(planarList); }
internal Vector3d[] GetPointsD() { PlaneSurface ps = new PlaneSurface() { Normal = Normal, Position = Location }; if (!ps.IsOnPlane(AuxPoint)) { return new Vector3d[] { } } ; var dir = AuxPoint - Location; norm = dir.Normalized(); List <Vector3d> pnts = new List <Vector3d>(); var step = Math.PI * 5 / 180f; double sweepAngle = SweepAngle; if (FullEllipse) { sweepAngle = Math.PI * 2; } for (double i = 0; i < sweepAngle; i += step) { pnts.Add(point(i)); } pnts.Add(point(sweepAngle)); return(pnts.ToArray()); } }
private Rhino.Geometry.Surface ToRhinoSurface(Face face) { Object faceGeometry = face.BasicGeometry; // 1. Compute the base surface // Based on https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_NurbsSurface_Create.htm Topologic.NurbsSurface nurbsSurface = faceGeometry as Topologic.NurbsSurface; if (nurbsSurface != null) { return(ToRhinoNurbsSurface(nurbsSurface)); } Topologic.PlanarSurface planarSurface = faceGeometry as Topologic.PlanarSurface; if (planarSurface != null) { //Topologic.NurbsSurface planarSurfaceAsNurbs = planarSurface.ToNurbsSurface(); //return ToRhinoNurbsSurface(planarSurfaceAsNurbs); PlaneSurface planeSurface = ToRhinoPlaneSurface(planarSurface, face); return(planeSurface); //Rhino.Geometry.NurbsSurface planeSurfaceAsNurbsSurface = planeSurface.ToNurbsSurface(); //return planeSurfaceAsNurbsSurface; } throw new Exception("An invalid surface is created."); }
// Constructor with initial values. public SurfaceEnvironmentType(Surface srf, bool wrap) { environment = srf; Wrap = wrap; double width, height; srf.GetSurfaceSize(out width, out height); Width = width; Height = height; Interval widthInterval = new Interval(0, width); Interval heightInterval = new Interval(0, height); Interval u = srf.Domain(0); Interval v = srf.Domain(1); Surface refEnvironment = new PlaneSurface(Plane.WorldXY, widthInterval, heightInterval); refEnvironment.SetDomain(0, u); refEnvironment.SetDomain(1, v); RefEnvironment = refEnvironment; Interval uDom = RefEnvironment.Domain(0); Interval vDom = RefEnvironment.Domain(1); minX = 0; maxX = width; minY = 0; maxY = height; }
public override void OnDone() { if (base.ActiveObject != null) { using (base.Frame.Project.Undo.UndoFrame) { Frame.ActiveView.Canvas.Cursor = "WaitCursor"; GeoObjectList ToAdd = new GeoObjectList(); Model m = base.Frame.ActiveView.Model; PlaneSurface pls = new PlaneSurface(plane); for (int i = 0; i < m.Count; ++i) // durch das ganze Modell laufen { ICurve[] crvs = Intersect(m[i], pls); if (crvs != null) { for (int k = 0; k < crvs.Length; k++) { IGeoObject go = crvs[k] as IGeoObject; go.CopyAttributes(base.ActiveObject); ToAdd.Add(go); } } } m.Add(ToAdd); base.KeepAsLastStyle(ActiveObject); base.ActiveObject = null; base.OnDone(); } } }
private void createPlaneBrep() { Plane plane = new Plane(); if (type == XYZPlanes.YZ) { plane = new Plane(origin, new Rhino.Geometry.Vector3d(1, 0, 0)); } else if (type == XYZPlanes.XZ) { plane = new Plane(origin, new Rhino.Geometry.Vector3d(0, 1, 0)); } else if (type == XYZPlanes.XY) { plane = new Plane(origin, new Rhino.Geometry.Vector3d(0, 0, 1)); } PlaneSurface plane_surface = new PlaneSurface(plane, new Interval(-size, size), new Interval(-size, size)); Brep planeBrep = Brep.CreateFromSurface(plane_surface); if (planeBrep != null) { Guid guid = UtilOld.addRhinoObjectSceneNode(ref mScene, ref planeBrep, ref mesh_m, "plane" + type.ToString(), out planeSN, true); planeObjRef = new Rhino.DocObjects.ObjRef(guid); } }
// OnInspector GUI public override void OnInspectorGUI() { if (GUILayout.Button("Generate")) { TerrainSettings settings = GameObject.FindGameObjectWithTag("GameManager").GetComponentInChildren <TerrainSettings>(); PlaneSurface mySurface = settings.gameObject.GetComponent <PlaneSurface>(); if (mySurface == null) { mySurface = settings.gameObject.AddComponent <PlaneSurface>(); } mySurface.maxHeight = (int)planeSize / 2; mySurface.width = baseWidth; mySurface.length = baseLength; mySurface.planeLength = planeSize; mySurface.tmpNodeObjects = new List <GameObject>(); mySurface.populateNodes(); mySurface.createPlanes(); Debug.Log("Terrain generated."); } }
public override void Intersect(ICurve curve, BoundingRect uvExtent, out GeoPoint[] ips, out GeoPoint2D[] uvOnFaces, out double[] uOnCurve3Ds) { if (curve is IExplicitPCurve3D && firstCurve is Line && secondCurve is Line) { if (Precision.SameDirection(firstCurve.StartDirection, secondCurve.StartDirection, false)) { // a simple plane PlaneSurface pls = new PlaneSurface(firstCurve.StartPoint, firstCurve.EndPoint, secondCurve.StartPoint); // has the same uv system pls.Intersect(curve, uvExtent, out ips, out uvOnFaces, out uOnCurve3Ds); return; } else { if (toUnit.IsNull) { lock (this) { if (toUnit.IsNull) { toUnit = ModOp.Fit(new GeoPoint[] { firstCurve.StartPoint, firstCurve.EndPoint, secondCurve.StartPoint, secondCurve.EndPoint }, new GeoPoint[] { new GeoPoint(0, 0, 0), new GeoPoint(1, 0, 0), new GeoPoint(0, 1, 0), new GeoPoint(1, 1, 1) }, true); } } } ModOp fromUnit = toUnit.GetInverse(); ICurve unitCurve = curve.CloneModified(toUnit); ExplicitPCurve3D explicitCurve = (unitCurve as IExplicitPCurve3D).GetExplicitPCurve3D(); GeoPoint[] hypLineIsp = implicitUnitHyperbolic.Intersect(explicitCurve, out double[] uc); List <GeoPoint2D> luv = new List <GeoPoint2D>(); List <double> lu = new List <double>(); List <GeoPoint> lips = new List <GeoPoint>(); for (int i = 0; i < hypLineIsp.Length; i++) { double u = unitCurve.PositionOf(hypLineIsp[i]); // explicitCurve doesn't necessary have the same u system as curve if (u >= -1e-6 && u <= 1 + 1e-6) { GeoPoint2D uv = new GeoPoint2D(hypLineIsp[i].x, hypLineIsp[i].y); if (BoundingRect.UnitBoundingRect.ContainsEps(uv, -0.001)) { lu.Add(u); luv.Add(uv); lips.Add(fromUnit * hypLineIsp[i]); } } } uvOnFaces = luv.ToArray(); uOnCurve3Ds = lu.ToArray(); ips = lips.ToArray(); #if DEBUG ++hitcount; #endif return; } } base.Intersect(curve, uvExtent, out ips, out uvOnFaces, out uOnCurve3Ds); }
public override GeoPoint2D[] GetLineIntersection(GeoPoint startPoint, GeoVector direction) { if (firstCurve is Line && secondCurve is Line) { if (Precision.SameDirection(firstCurve.StartDirection, secondCurve.StartDirection, false)) { // a simple plane PlaneSurface pls = new PlaneSurface(firstCurve.StartPoint, firstCurve.EndPoint, secondCurve.StartPoint); return(pls.GetLineIntersection(startPoint, direction)); } else { // a standard hyperbolic paraboloid with the form z = x*y as the affine transformation of this paraboloid if (toUnit.IsNull) { lock (this) { if (toUnit.IsNull) { toUnit = ModOp.Fit(new GeoPoint[] { firstCurve.StartPoint, firstCurve.EndPoint, secondCurve.StartPoint, secondCurve.EndPoint }, new GeoPoint[] { new GeoPoint(0, 0, 0), new GeoPoint(1, 0, 0), new GeoPoint(0, 1, 0), new GeoPoint(1, 1, 1) }, true); } } } // ModOp fromUnit = toUnit.GetInverse(); // Polynom hyperbolic = new Polynom(1, "xy", -1, "z"); //Polynom hyperbolic = new Polynom(2, 3); //hyperbolic.Set(1.0, new int[] { 1, 1, 0 }); //hyperbolic.Set(-1.0, new int[] { 0, 0, 1 }); // this is x*y-z==0 //ImplicitPSurface implicitHyperbolic = new ImplicitPSurface(hyperbolic); ExplicitPCurve3D explicitCurve = ExplicitPCurve3D.MakeLine(toUnit * startPoint, toUnit * direction); GeoPoint[] hypLineIsp = implicitUnitHyperbolic.Intersect(explicitCurve, out double[] uc); List <GeoPoint2D> luv = new List <GeoPoint2D>(); for (int i = 0; i < hypLineIsp.Length; i++) { double u = uc[i]; //= explicitCurve.PositionOf(hypLineIsp[i], out double dist); if (u >= -1e-6 && u <= 1 + 1e-6) { GeoPoint2D uv = new GeoPoint2D(hypLineIsp[i].x, hypLineIsp[i].y); if (BoundingRect.UnitBoundingRect.ContainsEps(uv, -0.001)) { luv.Add(uv); } } } #if DEBUG ++hitcount; if (luv.Count == 0) { } #endif return(luv.ToArray()); } } return(base.GetLineIntersection(startPoint, direction)); }
public override void GetGeometryForAnalysis(ref List <GeometryBase> outputGeometry, double waterLevel, Mesh mesh) { var bounds = mesh.GetBoundingBox(false); var waterPlane = new Plane(new Point3d(bounds.Max.X, bounds.Max.Y, waterLevel), new Vector3d(0, 0, 1)); var waterSrf = new PlaneSurface(waterPlane, new Interval(bounds.Min.X, bounds.Max.X), new Interval(bounds.Min.Y, bounds.Max.Y) ); outputGeometry.Add(waterSrf); }
/// <summary> /// 创建未修剪的 Rhino PlaneSurface /// </summary> /// <param name="face"></param> /// <returns></returns> static PlaneSurface ToRhinoPlaneSurface(NXOpen.Face face) { double[] facePt = new double[3]; double[] direction = new double[3]; double[] box = new double[6]; TheUfSession.Modl.AskFaceData(face.Tag, out int type, facePt, direction, box, out double radius, out double radData, out int normDir); Plane plane = new Plane(new Point3d(facePt[0], facePt[1], facePt[2]), new Vector3d(direction[0], direction[1], direction[2])); return(PlaneSurface.CreateThroughBox(plane, new BoundingBox(new Point3d(box[0], box[1], box[2]), new Point3d(box[3], box[4], box[5])))); }
private DbSurface CreateOffsetSurface() { DbSurface unionSurface = null; foreach (var dBObject in TechProcess.ProcessingArea.Select(p => p.ObjectId.QOpenForRead())) { DbSurface surface; switch (dBObject) { case DbSurface sf: surface = sf.Clone() as DbSurface; break; case Region region: surface = new PlaneSurface(); ((PlaneSurface)surface).CreateFromRegion(region); break; default: throw new Exception(ErrorStatus.NotImplementedYet, $"Объект типа {dBObject.GetType()} не может быть обработан (1)"); } if (unionSurface == null) { unionSurface = surface; } else { var res = unionSurface.BooleanUnion(surface); if (res != null) { unionSurface.Dispose(); unionSurface = res; } surface.Dispose(); } } if (Delta == 0) { return(unionSurface); } try { var offsetSurface = DbSurface.CreateOffsetSurface(unionSurface, Delta) as DbSurface; unionSurface.Dispose(); return(offsetSurface); } catch { unionSurface.TransformBy(Matrix3d.Displacement(Vector3d.ZAxis * Delta)); return(unionSurface); } }
public void Test_Surface() { TestContext.WriteLine($"Testing: {nameof(Test_Surface)}"); var p = Plane.WorldXY; var srf = new PlaneSurface(p, new Interval(0, 1), new Interval(0, 2)).ToBrep().Surfaces.First(); var face3D = srf.ToHBFace3D(); var boudary = face3D.Boundary; Assert.AreEqual(boudary[2], new List <decimal> { 1, 2, 0 }); }
public void AddTexturedPlane(RenderMaterial material) { // numeric interval var interval = new Interval(-1.0, 1.0); // create plane var plane = new PlaneSurface(Plane.WorldXY, interval, interval); // add plane to object table var id = _doc.Objects.AddSurface(plane); // Texture the plane TextureExistingGeometry(material, id); }
private Topologic.Face BySurface(Rhino.Geometry.Surface ghSurface) { SumSurface ghSumSurface = ghSurface as SumSurface; if (ghSumSurface != null) { return(BySumSurface(ghSumSurface)); } RevSurface ghRevSurface = ghSurface as RevSurface; if (ghRevSurface != null) { return(ByRevSurface(ghRevSurface)); } PlaneSurface ghPlaneSurface = ghSurface as PlaneSurface; if (ghPlaneSurface != null) { return(ByPlaneSurface(ghPlaneSurface)); } //ClippingPlaneSurface ghClippingPlaneSurface = ghSurface as ClippingPlaneSurface; //if (ghClippingPlaneSurface != null) //{ // return ByClippingPlaneSurface(ghClippingPlaneSurface); //} Extrusion ghExtrusion = ghSurface as Extrusion; if (ghExtrusion != null) { return(ByExtrusion(ghExtrusion)); } Rhino.Geometry.NurbsSurface ghNurbsSurface = ghSurface as Rhino.Geometry.NurbsSurface; if (ghNurbsSurface != null) { return(ByNurbsSurface(ghNurbsSurface)); } //BrepFace ghBrepFace = ghSurface as BrepFace; //if (ghBrepFace != null) //{ // return ByBrepFace(ghBrepFace); //} throw new Exception("This type of surface is not yet supported."); }
private PlaneSurface CreateLevel(double eventHeight) { // TODO: fix this var origin = new Point3d(0, 0, eventHeight); var xExtent = new Point3d(100, 0, eventHeight); var yExtent = new Point3d(0, 100, eventHeight); var plane = new Plane(origin, xExtent, yExtent); var planedSurface = new PlaneSurface(plane, new Interval(0, origin.DistanceTo(xExtent)), new Interval(0, origin.DistanceTo(yExtent)) ); return(planedSurface); }
private Rhino.Geometry.PlaneSurface ToRhinoPlaneSurface(PlanarSurface planarSurface, Face face) { // From Topologic List <double> coefficients = planarSurface.Coefficients; double a = coefficients[0]; double b = coefficients[1]; double c = coefficients[2]; double d = coefficients[3]; Vertex faceCenterOfMass = face.CenterOfMass; Point3d ghFaceCenterOfMass = ToPoint(faceCenterOfMass); Rhino.Geometry.Plane ghPlane = new Rhino.Geometry.Plane(a, b, c, d); double occtXMin = planarSurface.XMin; double occtXMax = planarSurface.XMax; double occtAbsDeltaX = Math.Abs(occtXMax - occtXMin); double occtHalfDeltaX = occtAbsDeltaX / 2.0; double occtYMin = planarSurface.YMin; double occtYMax = planarSurface.YMax; double occtAbsDeltaY = Math.Abs(occtYMax - occtYMin); double occtHalfDeltaY = occtAbsDeltaY / 2.0; double ghXMin = occtXMin; // - occtHalfDeltaX - safetyMarginX; double ghXMax = occtXMax; // - occtHalfDeltaX + safetyMarginX; double ghYMin = occtYMin; // - occtHalfDeltaY - safetyMarginY; double ghYMax = occtYMax; // - occtHalfDeltaY + safetyMarginY; Interval xExtents = new Interval( ghXMin, ghXMax); Interval yExtents = new Interval( ghYMin, ghYMax); PlaneSurface ghPlaneSurface = new PlaneSurface(ghPlane, xExtents, yExtents); Point3d ghCentroid = Rhino.Geometry.AreaMassProperties.Compute(ghPlaneSurface).Centroid; Vector3d ghTranslationVector = ghFaceCenterOfMass - ghCentroid; ghPlaneSurface.Translate(ghTranslationVector); if (!ghPlaneSurface.IsValid) { throw new Exception("A valid surface cannot be created from this Face."); } return(ghPlaneSurface); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { Point3d[] corners; var rc = RhinoGet.GetRectangle(out corners); if (rc != Result.Success) { return(rc); } var plane = new Plane(corners[0], corners[1], corners[2]); var plane_surface = new PlaneSurface( plane, new Interval(0, corners[0].DistanceTo(corners[1])), new Interval(0, corners[1].DistanceTo(corners[2])) ); rc = Result.Cancel; if (plane_surface.IsValid) { var layer_name = doc.Layers.GetUnusedLayerName(); rc = RhinoGet.GetString("Name of layer to create", true, ref layer_name); if (rc == Result.Success && !string.IsNullOrEmpty(layer_name)) { var layer_index = doc.Layers.FindByFullPath(layer_name, -1); if (-1 == layer_index) { layer_index = doc.Layers.Add(layer_name, System.Drawing.Color.Black); } if (layer_index >= 0) { var attribs = doc.CreateDefaultAttributes(); attribs.LayerIndex = layer_index; attribs.Name = layer_name; doc.Objects.AddSurface(plane_surface, attribs); doc.Views.Redraw(); rc = Result.Success; } } } return(rc); }
public static global::Topologic.Face ToTopologic(this global::Rhino.Geometry.Surface surface) { if (surface == null) { return(null); } SumSurface sumSurface = surface as SumSurface; if (sumSurface != null) { return(sumSurface.ToTopologic()); } RevSurface revSurface = surface as RevSurface; if (revSurface != null) { return(revSurface.ToTopologic()); } PlaneSurface planeSurface = surface as PlaneSurface; if (planeSurface != null) { return(planeSurface.ToTopologic()); } Extrusion ghExtrusion = surface as Extrusion; if (ghExtrusion != null) { return(ghExtrusion.ToTopologic()); } global::Rhino.Geometry.NurbsSurface ghNurbsSurface = surface as global::Rhino.Geometry.NurbsSurface; if (ghNurbsSurface != null) { return(ghNurbsSurface.ToTopologic()); } return(null); }
/* * public static List<Line> GetDelaunayEdge(List<Point3d> pts) * { * var nodes = new Node2List(); * foreach (var pt in pts) * { * nodes.Append(new Node2(pt.X, pt.Y)); * } * * var faces = Grasshopper.Kernel.Geometry.Delaunay.Solver.Solve_Faces(nodes, 1); * var delMesh = Grasshopper.Kernel.Geometry.Delaunay.Solver.Solve_Mesh(nodes, 1, ref faces); * * var edgeList = new List<Line>(); * for (int i = 0; i < delMesh.TopologyEdges.Count; i++) * { * edgeList.Add(delMesh.TopologyEdges.EdgeLine(i)); * } * * return edgeList; * } */ public static List <Brep> ConvertPtsToBreps(List <Point3d> pts, int gridSize) { var rtnList = new List <Brep>(); var xInterval = new Interval(-(gridSize / 2), gridSize / 2); var yInterval = new Interval(-(gridSize / 2), gridSize / 2); var breps = new List <Brep>(); foreach (var pt in pts) { var planeXY = new Rhino.Geometry.Plane(pt, Vector3d.ZAxis); var srf = new PlaneSurface(planeXY, xInterval, yInterval); rtnList.Add(srf.ToBrep()); } return(rtnList); }
public static Rhino.Geometry.Surface ToRhino(global::Topologic.Face face) { Object faceGeometry = face.BasicGeometry; // 1. Compute the base surface Based on https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_NurbsSurface_Create.htm global::Topologic.NurbsSurface nurbsSurface = faceGeometry as global::Topologic.NurbsSurface; if (nurbsSurface != null) { return(ToRhino_NurbsSurface(nurbsSurface)); } global::Topologic.PlanarSurface planarSurface = faceGeometry as global::Topologic.PlanarSurface; if (planarSurface != null) { PlaneSurface planeSurface = ToRhino(planarSurface, face); return(planeSurface); } throw new Exception("An invalid surface is created."); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { Point3d[] corners; var rc = Rhino.Input.RhinoGet.GetRectangle(out corners); if (rc != Result.Success) { return(rc); } var plane = new Plane(corners[0], corners[1], corners[2]); var plane_surface = new PlaneSurface(plane, new Interval(0, corners[0].DistanceTo(corners[1])), new Interval(0, corners[1].DistanceTo(corners[2]))); doc.Objects.Add(plane_surface); doc.Views.Redraw(); return(Result.Success); }
public static Result PlanarSurface(RhinoDoc doc) { Point3d[] corners; var rc = Rhino.Input.RhinoGet.GetRectangle(out corners); if (rc != Result.Success) { return(rc); } var plane = new Plane(corners[0], corners[1], corners[2]); var plane_surface = new PlaneSurface(plane, new Interval(0, corners[0].DistanceTo(corners[1])), new Interval(0, corners[1].DistanceTo(corners[2]))); doc.Objects.Add(plane_surface); doc.Views.Redraw(); return(Result.Success); }
private DbSurface CreateOffsetSurface() { DbSurface unionSurface = null; foreach (var dBObject in TechProcess.ProcessingArea.Select(p => p.ObjectId.QOpenForRead())) { DbSurface surface; switch (dBObject) { case DbSurface sf: surface = sf.Clone() as DbSurface; break; case Region region: surface = new PlaneSurface(); ((PlaneSurface)surface).CreateFromRegion(region); break; default: throw new Exception($"Объект типа {dBObject.GetType()} не может быть обработан (1)"); } if (unionSurface == null) { unionSurface = surface; } else { var res = unionSurface.BooleanUnion(surface); if (res != null) { unionSurface.Dispose(); unionSurface = res; } surface.Dispose(); } } var offsetSurface = DbSurface.CreateOffsetSurface(unionSurface, Delta) as DbSurface; unionSurface.Dispose(); return(offsetSurface); }
private ICurve[] Intersect(IGeoObject go, PlaneSurface pls) { Plane plane = pls.Plane; if (go is Solid) { BoundingCube bc = go.GetBoundingCube(); if (bc.Interferes(plane)) { return((go as Solid).GetPlaneIntersection(pls)); } } if (go is Shell) { BoundingCube bc = go.GetBoundingCube(); if (bc.Interferes(plane)) { return((go as Shell).GetPlaneIntersection(pls)); } } if (go is Face) { BoundingCube bc = go.GetBoundingCube(); if (bc.Interferes(plane)) { return((go as Face).GetPlaneIntersection(pls)); } } List <ICurve> res = new List <ICurve>(); if (go is Block) { for (int i = 0; i < go.NumChildren; i++) { res.AddRange(Intersect(go.Child(i), pls)); } } return(res.ToArray()); }
/// <summary> /// Call this method to get a box at the specified index. /// </summary> /// <param name="index"> /// The zero based index of the item in the list. Valid values are greater /// than or equal to 0 and less than Count. /// </param> /// <param name="plane"> /// Will contain the plane at the requested index if the index is in range /// and the primitive at the requested index is a plane. /// </param> /// <returns> /// Return true if the index is in range and the primitive at the requested /// index is a plane otherwise returns false. /// </returns> public bool TryGetPlane(int index, out PlaneSurface plane) { var origin = new Point3d(); var xaxis = new Vector3d(); var yaxis = new Vector3d(); var min_x = 0.0; var max_x = 0.0; var min_y = 0.0; var max_y = 0.0; if (UnsafeNativeMethods.Rdk_CustomMeshes_Plane(ConstPointer(), index, ref origin, ref xaxis, ref yaxis, ref min_x, ref max_x, ref min_y, ref max_y)) { plane = new PlaneSurface(new Plane(origin, xaxis, yaxis), new Interval(min_x, max_x), new Interval(min_y, max_y)); return(true); } plane = new PlaneSurface(new Plane(Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis), new Interval(0.0, 0.0), new Interval(0.0, 0.0)); return(false); }
/// <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) { Plane plane = new Plane(); double length = 0; double width = 0; if (!DA.GetData(0, ref plane)) { return; } if (!DA.GetData(1, ref length)) { return; } if (!DA.GetData(2, ref width)) { return; } Interval i1 = new Interval(0, length); Interval i2 = new Interval(0, width); if (length < 0) { i1 = new Interval(length, 0); } if (width < 0) { i2 = new Interval(width, 0); } PlaneSurface ps = new PlaneSurface(plane, i1, i2); Surface s = (Surface)ps; Point3d[] pts = s.ToBrep().DuplicateVertices(); Curve[] css = s.ToBrep().DuplicateEdgeCurves(); DA.SetData(0, s); DA.SetDataList(1, pts.ToList()); DA.SetDataList(2, css.ToList()); }
public Constr3DFaceExtrude(GeoObjectList selectedObjectsList) : this() { selectedMode = (selectedObjectsList != null); if (selectedMode) { GeoObjectList clonedList = selectedObjectsList.Clone(); GeoObjectList curves = new GeoObjectList(); for (int i = clonedList.Count - 1; i >= 0; --i) { if (clonedList[i] is ICurve) { curves.Add(clonedList[i]); clonedList.Remove(i); } } Plane pln; CompoundShape cs = CompoundShape.CreateFromList(curves, Precision.eps, out pln); if (cs != null && !cs.Empty) { // man konnte ein CompoundShape erzeugen, dann dieses zu Faces machen und verwenden for (int i = 0; i < cs.SimpleShapes.Length; i++) { PlaneSurface ps = new PlaneSurface(pln); Face toAdd = Face.MakeFace(ps, cs.SimpleShapes[i]); toAdd.CopyAttributes(curves[0]); clonedList.Add(toAdd); } this.selectedObjectsList = clonedList; } else { this.selectedObjectsList = selectedObjectsList.Clone(); } ListDefault(this.selectedObjectsList.Count); // setzt alle Listen auf gleiche Länge, Inhalte "null" } ; }
/// <summary> /// Call this method to get a <see cref="Plane"/> primitive for this mesh. If this /// meshes <see cref="PrimitiveType"/> is not a <see cref="Rhino.Render.RenderPrimitiveType.Plane"/> /// then the plane parameter is set to null. /// </summary> /// <param name="plane"> /// Gets set to the plane primitive for this object on success or null on error. /// </param> /// <returns> /// Returns true if <see cref="PrimitiveType"/> is <see cref="Rhino.Render.RenderPrimitiveType.Plane"/> and /// the plane parameter was initialized otherwise returns false. /// </returns> public bool TryGetPlane(out PlaneSurface plane) { var origin = new Point3d(); var xaxis = new Vector3d(); var yaxis = new Vector3d(); var min_x = 0.0; var max_x = 0.0; var min_y = 0.0; var max_y = 0.0; var const_pointer = ConstPointer(); var success = (1 == UnsafeNativeMethods.Rdk_RenderMesh_Plane(const_pointer, ref origin, ref xaxis, ref yaxis, ref min_x, ref max_x, ref min_y, ref max_y)); if (success) { plane = new PlaneSurface(new Plane(origin, xaxis, yaxis), new Interval(min_x, max_x), new Interval(min_y, max_y)); } else { plane = null; } return(success); }