protected override void SolveInstance(IGH_DataAccess DA) { Mesh m = new Mesh(); DA.GetData(0, ref m); int i = 0; DA.GetData(1, ref i); int iterations = 0; DA.GetData(2, ref iterations); if (m.IsValid) { List <List <int> > nakedVertices = m.GetNakedVerticesID(iterations); List <Polyline> nakedPolylines = m.GetNakedPolylines(nakedVertices); Mesh mesh = m.DuplicateMesh(); if (nakedVertices.Count != 0) { int check = mesh.Ngons.AddNgon(MeshNgon.Create(nakedVertices[i.Wrap(nakedVertices.Count)], Enumerable.Range(0, m.Faces.Count).ToList())); PreparePreview(mesh, DA.Iteration, nakedPolylines); DA.SetData(0, mesh); DA.SetDataTree(1, GrasshopperUtil.IE2(nakedVertices, DA.Iteration)); DA.SetDataTree(2, GrasshopperUtil.IE(nakedPolylines, DA.Iteration)); } else { DA.SetData(0, m); DA.SetDataTree(1, new Grasshopper.DataTree <int>()); DA.SetDataTree(2, new Grasshopper.DataTree <Polyline>()); } } else { DA.SetData(0, m); DA.SetDataTree(1, new Grasshopper.DataTree <int>()); DA.SetDataTree(2, new Grasshopper.DataTree <Polyline>()); } }
protected override void SolveInstance(IGH_DataAccess DA) { Mesh m = new Mesh(); DA.GetData(0, ref m); double dist = DA.Fetch <double>("Offset"); bool flip = DA.Fetch <bool>("Flip"); if (dist != 0) { m = m.FaceFaceOffset(dist); //Rhino.RhinoDoc.ActiveDoc.Objects.AddMesh(m); } Mesh M = NGonsCore.MeshCreate.MeshFromPolylines(m.GetFacePolylinesArray(), 0.01); if (flip) { M.Flip(true, true, true); } DA.SetData(4, M); try { MeshProps mp = M._Planes(); DA.SetData(0, mp); DA.SetDataTree(1, GrasshopperUtil.IE(mp.fPl, -1)); DA.SetDataTree(2, GrasshopperUtil.IE2(mp.fePl)); // DA.SetDataTree(3, GrasshopperUtil.IE2(mp.fePl90)); DA.SetDataTree(3, GrasshopperUtil.IE(mp.ePl)); //DA.SetDataTree(5, GrasshopperUtil.IE(mp.ePl90)); } catch (Exception e) { Rhino.RhinoApp.WriteLine(e.ToString()); } }