public void DrawViewportWires(IGH_PreviewArgs args) { IGH_StructureEnumerator data = this.VolatileData.AllData(true); Color c = args.WireColour; if (Attributes.Selected) { c = args.WireColour_Selected; } foreach (IMesh m in data) { if (!m.ElementTypes.Contains(-1)) { args.Display.DrawMeshWires(m.RenderMesh, c); } else { int[] hf; Point3d[] pts; foreach (IElement e in m.Elements) { if (e.TopologicDimension == 2) { pts = IRhinoGeometry.GetPointsFromElements(e.Vertices, m); args.Display.DrawPolyline(pts, c); } else { if (!m.IsMultidimensionalMesh) { for (int i = 1; i <= e.HalfFacetsCount; i++) { if (e.IsNakedSiblingHalfFacet(i)) { e.GetHalfFacet(i, out hf); pts = IRhinoGeometry.GetPointsFromElements(hf, m); args.Display.DrawPolyline(pts, c); } } } else { if (e.IsBoundaryElement()) { for (int i = 1; i <= e.HalfFacetsCount; i++) { e.GetHalfFacet(i, out hf); pts = IRhinoGeometry.GetPointsFromElements(hf, m); args.Display.DrawPolyline(pts, c); } } } } } } } }
/// <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) { IMesh iM = new IMesh(); DA.GetData(0, ref iM); Mesh mesh = IRhinoGeometry.TryGetRhinoMesh(iM); DA.SetData(0, mesh); }
/// <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) { IMesh mesh = null; DA.GetData(0, ref mesh); List <Polyline> faces = IRhinoGeometry.GetAllFacesAsPolylines(mesh); DA.SetDataList(0, faces); }
public void DrawViewportWires(GH_PreviewWireArgs args) { if (RenderMesh == null) { return; } // Check high order elements (visualization is not supported with rhino mesh) if (!_elementTypes.Contains(-1) && !_elementTypes.Contains(17) && !_elementTypes.Contains(18) && !_elementTypes.Contains(19) && !_elementTypes.Contains(9) && !_elementTypes.Contains(16) && !_elementTypes.Contains(11)) { args.Pipeline.DrawMeshWires(RenderMesh, args.Color); } else { int[] hf; Point3d[] pts; foreach (IElement e in Elements) { if (e.TopologicDimension == 2) { pts = IRhinoGeometry.GetPointsFromElements(e.Vertices, this); args.Pipeline.DrawPolyline(pts, args.Color); } else { if (!IsMultidimensionalMesh) { for (int i = 1; i <= e.HalfFacetsCount; i++) { if (e.IsNakedSiblingHalfFacet(i)) { e.GetHalfFacet(i, out hf); pts = IRhinoGeometry.GetPointsFromElements(hf, this); args.Pipeline.DrawPolyline(pts, args.Color); } } } else { if (e.IsBoundaryElement()) { for (int i = 1; i <= e.HalfFacetsCount; i++) { e.GetHalfFacet(i, out hf); pts = IRhinoGeometry.GetPointsFromElements(hf, this); args.Pipeline.DrawPolyline(pts, args.Color); } } } } } } }
/// <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) { IMesh mesh = new IMesh(); int eKey = -1; DA.GetData(0, ref mesh); DA.GetData(1, ref eKey); IElement e = mesh.GetElementWithKey(eKey); Brep brep = IRhinoGeometry.GetBrepFromElement(mesh, eKey); DA.SetData(0, e); DA.SetData(1, brep); }
/// <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) { IMesh mesh = null; DA.GetData(0, ref mesh); int eCount = mesh.ElementsCount; if (eCount > 1e4 && _massivePreview == false) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "A large number of elements was detected. Enable 'Massive Display' for continuing but this might slow down the entire preview process."); } else { List <Surface> surfaces = IRhinoGeometry.Get2DElementsAsSurfaces(mesh); DA.SetDataList(0, surfaces); } }
public static void EmbedConstraints(List <IConstraint> constraints, int dim = 2, int tag = -1) { if (constraints == null || constraints == default || constraints.Count == 0) { return; } Tuple <int, int>[] dimTags; IModel.GetEntities(out dimTags, dim); if (tag == -1) { var mainTags = dimTags.Select(keyPair => keyPair.Item2).ToArray(); if (mainTags.Length == 1) { tag = mainTags[0]; } else if (mainTags.Length > 1 && dim == 2) { tag = IBuilder.AddSurfaceLoop(mainTags); } } int count = constraints.Count; if (count > 0) { List <int> ptsTags = new List <int>(); List <int> crvTags = new List <int>(); List <int> srfTags = new List <int>(); PointCloud ptsCloud = new PointCloud(); IConstraint data; double t = 0.0001; Curve crv; for (int i = 0; i < count; i++) { data = constraints[i]; switch (data.Dim) { case 0: Point3d p = (Point3d)data.RhinoGeometry; int idx = EvaluatePoint(ptsCloud, p, t); if (idx == -1) { ptsTags.Add(IBuilder.AddPoint(p.X, p.Y, p.Z, data.Size)); ptsCloud.Add(p); } break; case 1: crv = (Curve)data.RhinoGeometry; crvTags.AddRange(CreateUnderlyingLinesFromCurveDividedByLength(crv, data.Size, data.CurveDivisionLength)); break; case 2: crv = (Curve)data.RhinoGeometry; crvTags.AddRange(CreateUnderlyingLinesFromCurveDividedByCount(crv, data.Size, data.NodesCountPerCurve)); break; case 3: Brep b = (Brep)data.RhinoGeometry; List <Point3d> patch; Curve[] crvArr; IRhinoGeometry.GetBrepFaceMeshingData(b, 0, 20, out crvArr, out patch); srfTags.Add(CreateUnderlyingSurfaceFromCurve(crvArr[0], data.Size, patch, false)); break; } } IBuilder.Synchronize(); if (tag != -1) { if (ptsTags.Count > 0) { IMeshingKernel.IBuilder.Embed(0, ptsTags.ToArray(), dim, tag); } if (crvTags.Count > 0) { IMeshingKernel.IBuilder.Embed(1, crvTags.ToArray(), dim, tag); } if (dim == 3) { if (srfTags.Count > 0) { IMeshingKernel.IBuilder.Embed(2, srfTags.ToArray(), dim, tag); } } } } }
public override void DrawViewportMeshes(IGH_PreviewArgs args) { base.DrawViewportMeshes(args); IRhinoGeometry.DrawElementsID(args, entitiesID, drawID); }
public void UpdateGraphics() { _renderMesh = IRhinoGeometry.TryGetRhinoMesh(this); }