protected override void SolveInstance(IGH_DataAccess DA) { Mesh mesh = new Mesh(); Mesh mesh_ = new Mesh(); DA.GetData(0, ref mesh); double scale = 1; DA.GetData(1, ref scale); //int t = 0; //DA.GetData(2, ref t); Polyline[][] pairplines = null; var m = mesh.ProjectPairsMesh(scale, ref pairplines); foreach (var mm in m) { mm.Clean(); mesh_.Append(mm); } this.PreparePreview(mesh_, DA.Iteration); DA.SetDataList(0, m); DA.SetDataTree(1, GrasshopperUtil.JaggedArraysToTree(pairplines, 0)); }
protected override void SolveInstance(IGH_DataAccess DA) { Mesh mesh = new Mesh(); DA.GetData(0, ref mesh); int iteration = DA.Iteration; uint[][] fId = mesh.GetFacesInNGons(); Polyline[][] fPolylines = mesh.GetFacePolylinesInNgons(fId); List <Polyline> display = new List <Polyline>(); foreach (var d in fPolylines) { foreach (var dd in d) { if (dd != null && dd.IsValid) { display.Add(dd); } } } this.PreparePreview(mesh, DA.Iteration, display, false, null); var dtPlines = GrasshopperUtil.JaggedArraysToTree(fPolylines, iteration); DA.SetDataTree(0, dtPlines); DA.SetDataTree(1, GrasshopperUtil.JaggedArraysToTree(fId, iteration)); }
protected override void SolveInstance(IGH_DataAccess DA) { Mesh mesh = new Mesh(); DA.GetData(0, ref mesh); int iteration = DA.Iteration; uint[][] v = mesh.GetNGonsBoundaries(); int[][] tv = mesh.GetNGonsTopoBoundaries(); var pt = mesh.GetNGonsBoundariesPoint3F(v); List <Point3d> points = new List <Point3d>(); List <Line[]> lineArray = new List <Line[]>(); foreach (var p in pt) { Point3d center = new Point3d(); foreach (var pp in p) { center += pp; points.Add(pp); } center /= p.Length; Point3d[] p_Copy = new Point3d[p.Length]; int i = 0; foreach (var pp in p) { Point3d pp_Copy = pp; pp_Copy.Transform(Rhino.Geometry.Transform.Scale(center, 0.95)); p_Copy[i++] = pp_Copy; } lineArray.Add(p_Copy.ToLineArray(true)); } this.PreparePreview(mesh, iteration, null, false, points, null, 255, 0, 0, lineArray); DA.SetDataTree(0, GrasshopperUtil.JaggedArraysToTree(pt, iteration)); // DA.SetDataTree(0, Util.JaggedArraysToTree(MeshUtil.GetNGonsTopoBoundariesPoint3F(mesh, tv), iteration)); DA.SetDataTree(1, GrasshopperUtil.JaggedArraysToTree(v, iteration)); DA.SetDataTree(2, GrasshopperUtil.JaggedArraysToTree(tv, iteration)); }
protected override void SolveInstance(IGH_DataAccess DA) { Mesh mesh = new Mesh(); DA.GetData(0, ref mesh); int iteration = DA.Iteration; HashSet <int> allNGonTvAll = mesh.GetAllNGonsTopoVertices(); int[][] nGonTV = mesh.GetNGonsTopoBoundaries(); HashSet <int> allNGonEAll = mesh.GetAllNGonEdges(nGonTV); int[][] connectedE = mesh.GetConnectedNGonEdgesToNGonTopologyVertices(allNGonTvAll, allNGonEAll); Line[][] connectedLines = mesh.GetConnectedNGonLinesToNGonTopologyVertices(connectedE); DA.SetDataTree(0, GrasshopperUtil.JaggedArraysToTree(connectedLines, iteration)); DA.SetDataTree(1, GrasshopperUtil.JaggedArraysToTree(connectedE, iteration)); }
protected override void SolveInstance(IGH_DataAccess DA) { Mesh mesh = new Mesh(); DA.GetData(0, ref mesh); double dist = 0.5; DA.GetData(1, ref dist); var o = mesh.OffsetNgon(dist); Polyline[] polylines = mesh.OffsetNgonAndMerge(dist); this.PreparePreview(mesh, DA.Iteration, polylines.ToList(), false); DA.SetDataTree(0, GrasshopperUtil.JaggedArraysToTree(o.Item1, 0)); DA.SetDataList(1, o.Item2); DA.SetDataList(2, polylines); }
protected override void SolveInstance(IGH_DataAccess DA) { Mesh mesh = new Mesh(); DA.GetData(0, ref mesh); bool flag = true; DA.GetData(1, ref flag); int iteration = DA.Iteration; HashSet <int> tvAll = mesh.GetAllNGonsTopoVertices(); int[][] NGons = mesh.GetNGonsConnectedToNGonTopologyVertices(tvAll, flag); bool[] nakedNGonVertices = mesh.GetNakedNGonTopologyPointStatus(tvAll); DA.SetDataTree(0, GrasshopperUtil.JaggedArraysToTree(NGons, iteration)); DA.SetDataList(1, nakedNGonVertices); }
protected override void SolveInstance(IGH_DataAccess DA) { Mesh mesh = new Mesh(); DA.GetData(0, ref mesh); double size = 10; DA.GetData(1, ref size); double textScale = 0.75; DA.GetData(2, ref textScale); int iteration = DA.Iteration; bbox.Union(mesh.GetBoundingBox(false)); int[][] tv = mesh.GetNGonsTopoBoundaries(); int[][] fe = mesh.GetNGonFacesEdges(tv); var l = mesh.GetNGonFacesEdgesLines(fe); DataTree <int> dt2 = new DataTree <int>(); HashSet <int> allE = mesh.GetAllNGonEdges(tv); int[] allEArray = allE.ToArray(); int[][] ef = mesh.GetNgonsConnectedToNGonsEdges(allE, true); for (int i = 0; i < mesh.Ngons.Count; i++) { for (int j = 0; j < fe[i].Length; j++) { int elocal = Array.IndexOf(allEArray, fe[i][j]); int neiF = (ef[elocal][0] == i) ? ef[elocal][1] : ef[elocal][0]; dt2.Add(neiF, new Grasshopper.Kernel.Data.GH_Path(i, DA.Iteration)); } } List <Line> ld = new List <Line>(); foreach (var ll in l) { ld.AddRange(ll); } //this.PreparePreview(mesh, DA.Iteration, null, false,null,ld); Plane[] planes = mesh.GetNgonPlanes(); for (int i = 0; i < planes.Length; i++) { if (faces) { this.texts.Add(new Rhino.Display.Text3d("F" + i.ToString(), planes[i], size)); } } for (int i = 0; i < planes.Length; i++) { for (int j = 0; j < fe[i].Length; j++) { Point3d p = l[i][j].PointAt(0.5); p.Transform(Rhino.Geometry.Transform.Scale(planes[i].Origin, textScale)); Plane edgePlane = new Plane(p, l[i][j].Direction, Vector3d.CrossProduct(planes[i].ZAxis, l[i][j].Direction)); if (edgesE) { this.texts.Add(new Rhino.Display.Text3d("E" + fe[i][j].ToString(), edgePlane, size * 0.75)); } if (edgesF) { this.texts.Add(new Rhino.Display.Text3d("F" + dt2.Branch(i)[j].ToString(), edgePlane, size * 0.75)); } } } DA.SetDataTree(0, GrasshopperUtil.JaggedArraysToTree(l, iteration)); DA.SetDataTree(1, GrasshopperUtil.JaggedArraysToTree(fe, iteration)); DA.SetDataTree(2, dt2); }
protected override void SolveInstance(IGH_DataAccess DA) { //Input Mesh mesh = new Mesh(); DA.GetData(0, ref mesh); int iteration = DA.Iteration; GH_Structure <GH_Integer> pairs = new GH_Structure <GH_Integer>(); DA.GetDataTree(1, out pairs); double scale = 0.9; DA.GetData(2, ref scale); //Solution int[][] p = new int[pairs.PathCount][]; //Grasshopper datatree to int[] {a,b} for (int i = 0; i < pairs.PathCount; i++) { p[i] = (new int[] { pairs[i][0].Value, pairs[i][1].Value }); } var edges = mesh.FindMeshEdgeByNGonPair(p); //Offset all lines by dist int[][] NGFaceEdgesID = edges.Item4; Line[][] NGFacesEdges = new Line[edges.Item4.Length][]; //Get face centers Point3d[] centers = mesh.GetNGonCenters(); for (int i = 0; i < edges.Item4.Length; i++) { NGFacesEdges[i] = new Line[edges.Item4[i].Length]; for (int j = 0; j < edges.Item4[i].Length; j++) { Line l = mesh.TopologyEdges.EdgeLine(NGFaceEdgesID[i][j]); l.Transform(Rhino.Geometry.Transform.Scale(centers[i], scale)); NGFacesEdges[i][j] = l; if (edges.Item6.ContainsKey(NGFaceEdgesID[i][j])) { edges.Item5[NGFaceEdgesID[i][j]].Add(l.From); edges.Item5[NGFaceEdgesID[i][j]].Add(l.To); } } } //Draw line between face centers //pairs gives a and b face //item1 gives flag //item3 gives edges id //Create dictionary with KEY - edge id VALUE - flag //Then dictionary with KEY - edge id VALUE - end points Polyline[] plines = new Polyline[edges.Item6.Count]; int id = 0; foreach (var i in edges.Item5) { plines[id] = new Polyline(new Point3d[] { i.Value[0], i.Value[1], i.Value[3], i.Value[2], i.Value[0] }); id++; } //Output DA.SetDataList(0, edges.Item2); DA.SetDataList(1, edges.Item3); DA.SetDataList(2, edges.Item1); DA.SetDataTree(3, GrasshopperUtil.JaggedArraysToTree(NGFacesEdges, 0)); DA.SetDataList(4, plines); }