public DataTree <Plane> GetNexorPlanes() { DataTree <Plane> dt = new DataTree <Plane>(); foreach (var n in this._nexors) { if (n.isNexor != 0) { var path = new Grasshopper.Kernel.Data.GH_Path(n.idNested[0], n.idNested[1]); dt.AddRange(n.foPl, path); dt.Add(n.ePl, path); dt.Add(n.fcPl_foPl, path); dt.AddRange(n.fcPl, path); dt.Add(n.ePl90Offset, path); dt.Add(n.endPl0, path); dt.Add(n.endPl1, path); } } return(dt); }
private void RunScript(List <System.Object> iWindingObjects, double iVecAmp, Curve iAxis, List <Curve> iSyntaxCurves, bool iBackSyntax, ref object oWindingObjects, ref object iTravelPlanes, ref object iAllPlanes) { // <Custom code> DataTree <Plane> allPlanes = new DataTree <Plane>(); DataTree <Plane> travelPlanes = new DataTree <Plane>(); GH_Path pth = new GH_Path(0); List <WindingClass> windingObjects = new List <WindingClass>(); for (var index = 0; index < iWindingObjects.Count - 1; index++) { pth = new GH_Path(index); WindingClass wC = (WindingClass)iWindingObjects[index]; wC.travelPath = CreateTravelPath(wC, (WindingClass)iWindingObjects[index + 1], iSyntaxCurves[index], iAxis, iVecAmp, iBackSyntax); travelPlanes.AddRange(wC.travelPath, pth); allPlanes.AddRange(wC.windingPath, pth); allPlanes.AddRange(wC.travelPath, pth); //allPlanes.AddRange(wC.transitionPath); windingObjects.Add(wC); } // Deal with last winding plane since it dosn't have two neighbors WindingClass lastItem = (WindingClass)iWindingObjects[iWindingObjects.Count - 1]; allPlanes.AddRange(lastItem.windingPath, pth); windingObjects.Add((WindingClass)windingObjects.Last()); oWindingObjects = windingObjects; iTravelPlanes = travelPlanes; iAllPlanes = allPlanes; // </Custom code> }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { List <Building> buildings = new List <Building>(); Plane plane = new Plane(); Curve boundary = new PolylineCurve(); int number = 0; if ((!DA.GetDataList(0, buildings))) { return; } if (!DA.GetData(1, ref plane)) { return; } if (!DA.GetData(2, ref boundary)) { return; } if (!DA.GetData(3, ref number)) { return; } Move move = new Move(buildings, plane, boundary, number); List <Curve> sunRegulation = new List <Curve>(); List <Curve> residence = new List <Curve>(); List <Curve> spaceRegulation = new List <Curve>(); List <Point3d> points = new List <Point3d>(); for (int i = 0; i < buildings.Count; i++) { var building = buildings[i]; sunRegulation.Add(building.SunRegulation); residence.Add(building.Residence); spaceRegulation.Add(building.SpaceRegulation); points.Add(building.Point); } DataTree <Curve> dataTree = new DataTree <Curve>(); dataTree.AddRange(residence, new GH_Path(0)); dataTree.AddRange(spaceRegulation, new GH_Path(1)); dataTree.AddRange(sunRegulation, new GH_Path(2)); DA.SetDataList(0, points); DA.SetDataTree(1, dataTree); }
protected override void SolveInstance(IGH_DataAccess da) { var list = new List <object>(); var members = new List <object>(); da.GetDataList(_listIn, list); da.GetDataList(_membersIn, members); var dict = new Dictionary <object, (List <int>, int)>(); for (var i = 0; i < list.Count; i++) { var currentItem = list[i]; if (dict.ContainsKey(currentItem)) { var rec = dict[currentItem]; dict[currentItem] = (rec.Item1.Concat(new List <int> { i }).ToList(), rec.Item2 + 1); } else { dict[currentItem] = (new List <int> { i }, 1); } } var indices = new DataTree <int>(); var count = new DataTree <int>(); for (var i = 0; i < members.Count; i++) { var path = new GH_Path(i); var member = members[i]; if (dict.ContainsKey(member)) { indices.AddRange(dict[member].Item1, path); count.Add(dict[member].Item2); } else { indices.AddRange(new int[] {}, path); count.Add(0, path); } } da.SetDataTree(_indicesOut, indices); da.SetDataTree(_countOut, count); }
/// <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) { GH_Structure <IGH_Goo> tree; List <int> indexes = new List <int>(); if (!DA.GetDataTree(0, out tree)) { return; } if (!DA.GetDataList(1, indexes)) { return; } DataTree <object> outTree = new DataTree <object>(); for (int i = 0; i < tree.Branches.Count; i++) { if (!indexes.Contains(i)) { var path = tree.Paths[i]; outTree.AddRange(tree.Branches[i], path); } } DA.SetDataTree(0, outTree); }
protected override void SolveInstance(IGH_DataAccess DA) { var connectionType = new ConnectionType(); DA.GetData(0, ref connectionType); var connection = connectionType.Value; var d = connection.graph; if (d == null) { return; } var edgeTree = new DataTree <string>(); var pathIndex = 0; foreach (var edge in d.edges) { var nodeIdsOfEdge = new List <string>(); foreach (var nodeId in edge) { nodeIdsOfEdge.Add(nodeId); } edgeTree.AddRange(nodeIdsOfEdge, new Grasshopper.Kernel.Data.GH_Path(pathIndex)); pathIndex++; } DA.SetDataTree(0, edgeTree); }
protected override void SetOutputs(IGH_DataAccess da) { outTree = new DataTree<Point3d>(); GH_Path trunk = new GH_Path(0); // {0} GH_Path branch = new GH_Path(); // {}\ GH_Path limb = new GH_Path(); for (int i = 0; i < particles.Count; i++) { IQuelea particle = particles[i]; branch = trunk.AppendElement(i); DataTree<Point3d> particlePositionHistoryTree = particle.Position3DHistory.ToTree(); for (int j = 0; j < particlePositionHistoryTree.BranchCount; j++) { limb = branch.AppendElement(j); //for (int k = particlePositionHistoryTree.Branch(j).Count - 1; k >= 0; k--) //{ // outTree.Add(particlePositionHistoryTree.Branch(j)[k], limb); //} outTree.AddRange(particlePositionHistoryTree.Branch(j), limb); } } da.SetDataTree(nextOutputIndex++, outTree); }
/// <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) { IssueCollection issues = new IssueCollection(); List <DateTime> timestamps = new List <DateTime>(); DA.GetDataList <Issue>(0, issues); DateTime timestamp = DateTime.Now; DataTree <Issue> results = new DataTree <Issue>(); List <int> counts = new List <int>(); DA.GetDataList(1, timestamps); for (int i = 0; i < timestamps.Count; i++) { timestamp = timestamps[i]; IssueCollection issues_as_of = issues.AsOf(timestamp); GH_Path path = new GH_Path(i); results.AddRange(issues_as_of, path); counts.Add(issues_as_of.Count); } DA.SetDataList(0, counts); DA.SetDataTree(1, results); }
public static DataTree <int> Color(List <int> V, List <int> E0, List <int> E1, int numberOfColors = 2) { var graph = new Advanced.Algorithms.DataStructures.Graph.AdjacencyList.Graph <int>(); for (int i = 0; i < V.Count; i++) { graph.AddVertex(V[i]); } for (int i = 0; i < E0.Count; i++) { if (!graph.HasEdge(E0[i], E1[i])) { graph.AddEdge(E0[i], E1[i]); } } MColorer <int, string> algorithm = new MColorer <int, string>(); MColorResult <int, string> result = algorithm.Color(graph, Letters(numberOfColors)); DataTree <int> dtResult = new DataTree <int>(); if (result.Partitions != null) { int counter = 0; foreach (KeyValuePair <string, List <int> > p in result.Partitions) { dtResult.AddRange(p.Value, new GH_Path(counter++)); } } return(dtResult); }
protected override void SolveInstance(IGH_DataAccess DA) { try { List <Point3d> pts = new List <Point3d>(); DA.GetDataList(0, pts); DataTree <Line> links = new DataTree <Line>(); DataTree <int> indices = new DataTree <int>(); for (int i = 0; i < pts.Count; i++) { Point3d p0 = pts[i]; for (int j = i + 1; j < pts.Count; j++) { Point3d p1 = pts[j]; double d = p0.DistanceTo(p1); bool linkus = true; for (int k = 0; k < pts.Count; k++) { if (k != i && k != j) { Point3d p2 = pts[k]; if (p2.DistanceTo(p0) < d && p2.DistanceTo(p1) < d) { linkus = false; break; } } } if (linkus) { links.Add(new Line(p0, p1), new GH_Path(i)); links.Add(new Line(p1, p0), new GH_Path(j)); indices.Add(j, new GH_Path(i)); indices.Add(i, new GH_Path(j)); } } } //for(int i = 0;i < pts.Count;i++){ System.Threading.Tasks.Parallel.For(0, pts.Count, i => { GH_Path path = new GH_Path(i); if (!links.PathExists(path)) {//Add nulls links.AddRange(new List <Line>() { }, path); indices.AddRange(new List <int>() { }, path); } }); DA.SetDataTree(0, links); DA.SetDataTree(1, indices); } catch (Exception e) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.ToString()); } }
/// <summary> /// This procedure contains the user code. Input parameters are provided as regular arguments, /// Output parameters as ref arguments. You don't have to assign output parameters, /// they will have a default value. /// </summary> private void RunScript(bool reset, bool go, List <Plane> Pl, double sR, List <Polyline> body, ref object iter, ref object Bodies, ref object Planes, ref object TipPoints) { // <Custom code> // . . . . . . . . . . . . . . . . . . . . . . . . return on null data if (Pl == null || body == null) { return; } // variables for data extraction DataTree <Polyline> outBodies = new DataTree <Polyline>(); GH_Plane[] outPlanes = new GH_Plane[Pl.Count]; List <GH_Point> tipPoints = new List <GH_Point>(); // . . . . . . . . . . . . . . . . . . . . . . . . initialize system if (reset || ABS == null) { ABS = new AgentBodySimulation(Pl, body, sR); iterationsCount = 0; Status = ""; } //Print("{0}", ABS.Agents[0].Neighbours.Count); //Print(Status); if (go) { // update parameters //ABS.searchRadius = sR; ABS.Update(); iterationsCount++; Component.ExpireSolution(true); } // . . . . . . . . . . . . . . . . . . . . . . . . extract geometries and data // necessary only in case of parallelization //for (int i = 0; i < ABS.Agents.Length; i++) // outBodies.EnsurePath(new GH_Path(i)); for (int i = 0; i < ABS.Agents.Length; i++) { outBodies.AddRange(ABS.Agents[i].ExtractBody(), new GH_Path(i)); outPlanes[i] = new GH_Plane(ABS.Agents[i].agentPlane); for (int j = 0; j < ABS.Agents[i].body.Tips.Count; j++) { tipPoints.Add(new GH_Point(ABS.Agents[i].body.Tips[j].pos)); } } iter = iterationsCount; Bodies = outBodies; Planes = outPlanes; TipPoints = tipPoints; // </Custom code> }
void clusterize(int cb, int sb, ref DataTree <int> Td, ref DataTree <int> cl, ref List <int> tP) { // current branch path GH_Path cp = new GH_Path(cb); if (cb == sb) // when cb==sb create a new branch in cl { // // create new cluster // GH_Path clp = new GH_Path(cl.BranchCount); //new cluster path cl.Add(cb, clp); // add Td branch index as first element // add all branch indexes cl.AddRange(Td.Branches[cb]); // call clusterize for each of them for (int i = 0; i < Td.Branches[cb].Count; i++) { clusterize(Td[cp, i], cb, ref Td, ref cl, ref tP); } tP.RemoveAt(tP.IndexOf(cb)); // // call new cluster if there are still available indexes // if (tP.Count > 0) { clusterize(tP[0], tP[0], ref Td, ref cl, ref tP); } } else { // // add elements to existing cluster // // scan elements of current branch for (int i = 0; i < Td.Branches[cb].Count; i++) { // if elements in current branch (cb) of Td are different // from sending branch index (sb): if (Td[cp, i] != sb) { // if elements are not yet in cluster, add them // and call clusterize on them if (!cl.Branches[cl.BranchCount - 1].Contains(Td[cp, i])) { cl.Add(Td[cp, i], new GH_Path(cl.BranchCount - 1)); clusterize(Td[cp, i], cb, ref Td, ref cl, ref tP); } } else if (tP.Contains(cb)) { tP.RemoveAt(tP.IndexOf(cb)); //remove branch index from list } } } }
public static Tuple <Point3d[], List <string>, List <int>, List <int>, List <int>, DataTree <int> > GetGraphData(List <Line> lines) { NGonsCore.Graphs.UndirectedGraph g = LinesToUndirectedGrap(lines); DataTree <int> dataTreeA = new DataTree <int>(); List <String> vertices = g.GetVertices(); for (int i = 0; i < vertices.Count; i++) { dataTreeA.AddRange(g.GetNeighbours(vertices[i]), new Grasshopper.Kernel.Data.GH_Path(i)); } DataTree <int> dataTreeB = new DataTree <int>(); List <NGonsCore.Graphs.Edge> edges = g.GetEdges(); List <int> u = new List <int>(); List <int> v = new List <int>(); List <int> w = new List <int>(); for (int i = 0; i < edges.Count; i++) { u.Add(edges[i].u); v.Add(edges[i].v); w.Add(1); dataTreeB.Add(edges[i].u, new Grasshopper.Kernel.Data.GH_Path(i)); dataTreeB.Add(edges[i].v, new Grasshopper.Kernel.Data.GH_Path(i)); } PointCloud pointCloud = ((PointCloud)g.GetAttribute()); return(new Tuple <Point3d[], List <string>, List <int>, List <int>, List <int>, DataTree <int> >(pointCloud.GetPoints(), g.GetVertices(), u, v, w, dataTreeA)); }
protected override void SolveInstance(IGH_DataAccess DA) { Mesh m = new Mesh(); DA.GetData(0, ref m); double d = 1; DA.GetData(1, ref d); Polyline[] polylinesOriginal = m.GetPolylines(); Polyline[] polylines = m.PlanarOffset(d); //Polyline[] polylines = m.PlanarBisectorOffset(d); DataTree <Polyline> dt = new DataTree <Polyline>(); for (int i = 0; i < polylines.Length; i++) { dt.AddRange(new[] { polylinesOriginal[i], polylines[i] }, new Grasshopper.Kernel.Data.GH_Path(i)); } this.PreparePreview(m, DA.Iteration, dt.AllData(), false); DA.SetDataTree(0, dt); }
public static DataTree <Curve> SectionBrep(this Brep M, Plane P, double D, double tolerance = 0.01) { //GetBoundingBox Box box = Box.Unset; BoundingBox bbox = M.GetBoundingBox(P, out box); int n = (int)Math.Ceiling(box.Z.Length / D); //Store Planes var plns = new List <Plane>(); //Output cuts DataTree <Curve> cuts = new DataTree <Curve>(); //Mesh Plane intersction double docTol = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance; for (int i = 0; i < n; i++) { Plane plane = new Plane(box.PointAt(0, 0, 0) + P.ZAxis * i * D + P.ZAxis * tolerance, P.XAxis, P.YAxis); plns.Add(plane); Curve[] crvs; Point3d[] pts; Rhino.Geometry.Intersect.Intersection.BrepPlane(M, plane, docTol, out crvs, out pts); if (crvs != null) { cuts.AddRange(crvs, new GH_Path(i)); } } return(cuts); }
private object GetTreeFromParameter(IGH_DataAccess DA, int index, bool addIntoGhDoc) { GH_Structure <IGH_Goo> structure; DA.GetDataTree(index, out structure); IGH_TypeHint typeHint = ((Param_ScriptVariable)_component.Params.Input[index]).TypeHint; var tree = new DataTree <object>(); for (int i = 0; i < structure.PathCount; i++) { GH_Path path = structure.get_Path(i); List <IGH_Goo> list = structure.Branches[i]; List <object> data = new List <object>(); for (int j = 0; j < list.Count; j++) { object cast = this.TypeCast(list[j], typeHint); DocumentSingle(ref cast, addIntoGhDoc); data.Add(cast); } tree.AddRange(data, path); } return(tree); }
protected override void SetOutputs(IGH_DataAccess da) { outTree = new DataTree <Point3d>(); GH_Path trunk = new GH_Path(0); // {0} GH_Path branch = new GH_Path(); // {}\ GH_Path limb = new GH_Path(); for (int i = 0; i < particles.Count; i++) { IQuelea particle = particles[i]; branch = trunk.AppendElement(i); DataTree <Point3d> particlePositionHistoryTree = particle.Position3DHistory.ToTree(); for (int j = 0; j < particlePositionHistoryTree.BranchCount; j++) { limb = branch.AppendElement(j); //for (int k = particlePositionHistoryTree.Branch(j).Count - 1; k >= 0; k--) //{ // outTree.Add(particlePositionHistoryTree.Branch(j)[k], limb); //} outTree.AddRange(particlePositionHistoryTree.Branch(j), limb); } } da.SetDataTree(nextOutputIndex++, outTree); }
public void BranchWork(List <Point3d> pointList, int branchIndex, Point3d centroid) { mainDict = new SortedDictionary <Vector2d, smPoint>(); Vector2d indexTemp; for (int i = 0; i < pointList.Count; i++) { indexTemp = new Vector2d(pointList[i].X, pointList[i].Y); smPoint pt; if (mainDict.TryGetValue(indexTemp, out pt)) { continue; } else { mainDict.Add(indexTemp, new smPoint(pointList[i])); } } var cent = centroid; //centroids.Add(cent); var holdPts = mainDict.Values.OrderBy(s => s.pt.DistanceTo(cent)).Select(s => s.pt).ToList(); List <Point3d> ptStore = new List <Point3d>(); ptStore.AddRange(holdPts); origPt.Add(ptStore.Count); int sCount = 0; List <Point3d> branchPts; while (ptStore.Count > 0) { branchPts = TraverseDict(ptStore[0], mainDict); if (branchPts != null && branchPts.Count > 0) { if (branchPts.Count > 200) { outTree.AddRange(branchPts, new GH_Path(branchIndex, sCount)); } for (int j = 0; j < branchPts.Count; j++) { ptStore.Remove(branchPts[j]); } tempPt.Add(ptStore.Count); sCount++; } else { ptStore.Remove(ptStore[0]); } } }
/// <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) { List <object> list = new List <object>(); List <Interval> domain = new List <Interval>(); if (!DA.GetDataList(0, list)) { return; } if (!DA.GetDataList(1, domain)) { return; } List <object> x = list; List <Interval> y = domain; DataTree <object> objs = new DataTree <object>(); List <object> rest = new List <object>(); List <int> used = new List <int>(); int index = 0; for (int i = 0; i < y.Count; i++) { bool flag = false; Interval inter = y[i]; if (inter.IsIncreasing == false) { flag = true; } inter.MakeIncreasing(); int mem1 = Convert.ToInt32(inter.T0); int mem2 = Convert.ToInt32(inter.T1); List <object> obj = new List <object>(); for (int j = mem1; j <= mem2; j++) { obj.Add(x[j]); used.Add(j); } if (flag)////如果给定区间是降序排列,那么反转列表 { obj.Reverse(); } objs.AddRange(obj, new GH_Path(0, DA.Iteration, index)); index++; } List <int> used2 = used.Distinct().ToList(); used2.Sort(); for (int i = 0; i < x.Count; i++) { if (used2.Contains(i)) { continue; } rest.Add(x[i]); } DA.SetDataTree(0, objs); DA.SetDataList(1, rest); }
/// <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) { List <string> _buildingFiles = new List <string>(); List <string> _buildingBinaryFiles = new List <string>(); int _val_ = 0; bool runIt_ = false; DA.GetDataList(0, _buildingFiles); DA.GetDataList(1, _buildingBinaryFiles); DA.GetData(2, ref _val_); DA.GetData(3, ref runIt_); // Unwrap variables List <FacadeVariable> variables = BuildingFacadeOutputMapping(); if (runIt_) { DataTree <string> fileNameTree = new DataTree <string>(); DataTree <FacadeVariable> variableTree = new DataTree <FacadeVariable>(); DataTree <double> dataTree = new DataTree <double>(); // Warning! if (_val_ >= variables.Count) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Variable is out of range, check description of the input."); return; } for (int i = 0; i < _buildingFiles.Count; i++) { GHD.GH_Path pth = new GHD.GH_Path(i); try { string edxName = Path.GetFileNameWithoutExtension(_buildingFiles[i]); string edtName = Path.GetFileNameWithoutExtension(_buildingBinaryFiles[i]); if (edxName == edtName) { List <double> results = BuildingOutput.ParseBinBuilding(_buildingFiles[i], _buildingBinaryFiles[i], (int)variables[_val_], Direction); fileNameTree.Add(Path.GetFileName(_buildingFiles[i]), pth); variableTree.Add(variables[_val_], pth); dataTree.AddRange(results, pth); } } catch { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Something is wrong in output dynamic folder.\nPlease, make sure EDT length is equals to EDX length."); continue; } } DA.SetDataTree(0, fileNameTree); DA.SetDataTree(1, variableTree); DA.SetDataTree(2, dataTree); } }
DataTree <GH_Integer> ToDataTree(int[][] vals) { DataTree <GH_Integer> vTree = new DataTree <GH_Integer>(); for (int i = 0; i < vals.Length; i++) { vTree.AddRange(vals[i].Select(x => new GH_Integer(x)), new GH_Path(i)); } return(vTree); }
public DataTree <Plane> GetJointPlanes() { DataTree <Plane> dt = new DataTree <Plane>(); for (int i = 0; i < _pipes.Count; i++) { dt.AddRange(_pipes[i].jointPlanes, new Grasshopper.Kernel.Data.GH_Path(i)); } return(dt); }
public DataTree <Polyline> GetMeshProjections() { DataTree <Polyline> dt = new DataTree <Polyline>(); for (int i = 0; i < _pipes.Count; i++) { dt.AddRange(_pipes[i].meshProjections, new Grasshopper.Kernel.Data.GH_Path(i)); } return(dt); }
/// <summary> /// Converts nested list of lines into data tree (for scripting components inside gh) /// </summary> /// <param name="conversionData">the nested list to convert</param> /// <returns>The data structure</returns> public static DataTree <Line> ConvertToGHDataTree(List <List <Line> > conversionData) { DataTree <Line> ghTree = new DataTree <Line>(); for (int i = 0; i < conversionData.Count; i++) { ghTree.AddRange(conversionData[i], new GH_Path(i)); } return(ghTree); }
public DataTree <Line> GetDrillingLines() { DataTree <Line> dt = new DataTree <Line>(); for (int i = 0; i < _pipes.Count; i++) { dt.AddRange(_pipes[i].drillingHoles, new Grasshopper.Kernel.Data.GH_Path(i)); } return(dt); }
public DataTree <int> GetNeiboursID() { DataTree <int> dt = new DataTree <int>(); for (int i = 0; i < _pipes.Count; i++) { dt.AddRange(_pipes[i].neiID, new Grasshopper.Kernel.Data.GH_Path(i)); } return(dt); }
public DataTree <Brep> GetBrepsCuts() { DataTree <Brep> dt = new DataTree <Brep>(); for (int i = 0; i < this._pipes.Count; i++) { dt.AddRange(this._pipes[i].brepCuts, new Grasshopper.Kernel.Data.GH_Path(i)); } return(dt); }
public DataTree <GH_Integer> ToDataTree(int[][] array) { DataTree <GH_Integer> dt = new DataTree <GH_Integer>(); for (int i = 0; i < array.Length; i++) { dt.AddRange(array[i].Select(x => new GH_Integer(x)), new GH_Path(i)); } return(dt); }
static DataTree <T> ListOfListsToTree <T>(List <List <T> > listofLists) { DataTree <T> tree = new DataTree <T>(); for (int i = 0; i < listofLists.Count; i++) { tree.AddRange(listofLists[i], new GH_Path(i)); } return(tree); }
public DataTree <Polyline> GetBoundingBoxCuts() { DataTree <Polyline> dt = new DataTree <Polyline>(); for (int i = 0; i < _pipes.Count; i++) { dt.AddRange(_pipes[i].boundingBoxCuts, new Grasshopper.Kernel.Data.GH_Path(i)); } return(dt); }
protected override void SolveInstance(IGH_DataAccess DA) { List <GH_Curve> curves = new List <GH_Curve>(); if (!DA.GetDataList <GH_Curve>(0, curves)) { return; } bool flip = true; DA.GetData(1, ref flip); double inflate = 100.0; DA.GetData(2, ref inflate); double RotateX = 45.0; DA.GetData(3, ref RotateX); double RotateY = 160.0; DA.GetData(4, ref RotateY); int maxLength = 0; DA.GetData(5, ref maxLength); bool flag = true; DA.GetData(6, ref flag); int loops = 0; DA.GetData(7, ref loops); //Get direction Line line = Direction(flip, inflate, curves, RotateX, RotateY); //Create Graph CreateGraph(); //Perform walk List <List <string> > pathList = ShortestWalkStripper(_g, line, maxLength, 1, flag, loops); //Output DataTree <string> output = new DataTree <string>(); for (int i = 0; i < pathList.Count; i++) { output.AddRange(pathList[i], new GH_Path(i)); } DA.SetDataTree(0, output); DA.SetData(1, line); DA.SetData(2, oddWalks); }
private Mesh local_tet(Plane pl, double xBase, double yBase, double zBase) { List<Point3d> list = new List<Point3d> { pl.PointAt(-xBase, yBase, -zBase), pl.PointAt(xBase, yBase, -zBase), pl.PointAt(xBase, -yBase, -zBase), pl.PointAt(-xBase, -yBase, -zBase), pl.PointAt(-xBase, yBase, zBase), pl.PointAt(xBase, yBase, zBase), pl.PointAt(xBase, -yBase, zBase), pl.PointAt(-xBase, -yBase, zBase) }; List<double> list2 = new List<double>(); foreach (Point3d pointd in list) { double item = this.calculate_field(pointd); list2.Add(item); } DataTree<Point3d> tree = new DataTree<Point3d>(); Point3d[] data = new Point3d[] { list[0], list[2], list[3], list[7] }; tree.AddRange(data, new GH_Path(0)); data = new Point3d[] { list[0], list[2], list[6], list[7] }; tree.AddRange(data, new GH_Path(1)); data = new Point3d[] { list[0], list[4], list[6], list[7] }; tree.AddRange(data, new GH_Path(2)); data = new Point3d[] { list[0], list[6], list[1], list[2] }; tree.AddRange(data, new GH_Path(3)); data = new Point3d[] { list[0], list[6], list[1], list[4] }; tree.AddRange(data, new GH_Path(4)); data = new Point3d[] { list[5], list[6], list[1], list[4] }; tree.AddRange(data, new GH_Path(5)); DataTree<double> tree2 = new DataTree<double>(); tree2.AddRange(new double[] { list2[0], list2[2], list2[3], list2[7] }, new GH_Path(0)); tree2.AddRange(new double[] { list2[0], list2[2], list2[6], list2[7] }, new GH_Path(1)); tree2.AddRange(new double[] { list2[0], list2[4], list2[6], list2[7] }, new GH_Path(2)); tree2.AddRange(new double[] { list2[0], list2[6], list2[1], list2[2] }, new GH_Path(3)); tree2.AddRange(new double[] { list2[0], list2[6], list2[1], list2[4] }, new GH_Path(4)); tree2.AddRange(new double[] { list2[5], list2[6], list2[1], list2[4] }, new GH_Path(5)); Mesh mesh = new Mesh(); foreach (GH_Path path in tree2.Paths) { List<Point3d> list3 = tree.Branch(path); List<double> list4 = tree2.Branch(path); int num2 = 0; if (list4[0] < this.use_iso) { num2 |= 1; } if (list4[1] < this.use_iso) { num2 |= 2; } if (list4[2] < this.use_iso) { num2 |= 4; } if (list4[3] < this.use_iso) { num2 |= 8; } Mesh other = new Mesh(); switch (num2) { case 1: case 14: other.Vertices.Add(this.interp_vertex(list3[0], list3[1], list4[0], list4[1])); other.Vertices.Add(this.interp_vertex(list3[0], list3[2], list4[0], list4[2])); other.Vertices.Add(this.interp_vertex(list3[0], list3[3], list4[0], list4[3])); other.Faces.AddFace(0, 1, 2); break; case 2: case 13: other.Vertices.Add(this.interp_vertex(list3[1], list3[0], list4[1], list4[0])); other.Vertices.Add(this.interp_vertex(list3[1], list3[3], list4[1], list4[3])); other.Vertices.Add(this.interp_vertex(list3[1], list3[2], list4[1], list4[2])); other.Faces.AddFace(0, 1, 2); break; case 3: case 12: other.Vertices.Add(this.interp_vertex(list3[0], list3[3], list4[0], list4[3])); other.Vertices.Add(this.interp_vertex(list3[0], list3[2], list4[0], list4[2])); other.Vertices.Add(this.interp_vertex(list3[1], list3[3], list4[1], list4[3])); other.Faces.AddFace(0, 1, 2); other.Vertices.Add(this.interp_vertex(list3[1], list3[2], list4[1], list4[2])); other.Faces.AddFace(2, 3, 1); break; case 4: case 11: other.Vertices.Add(this.interp_vertex(list3[2], list3[0], list4[2], list4[0])); other.Vertices.Add(this.interp_vertex(list3[2], list3[1], list4[2], list4[1])); other.Vertices.Add(this.interp_vertex(list3[2], list3[3], list4[2], list4[3])); other.Faces.AddFace(0, 1, 2); break; case 5: case 10: other.Vertices.Add(this.interp_vertex(list3[0], list3[1], list4[0], list4[1])); other.Vertices.Add(this.interp_vertex(list3[2], list3[3], list4[2], list4[3])); other.Vertices.Add(this.interp_vertex(list3[0], list3[3], list4[0], list4[3])); other.Faces.AddFace(0, 1, 2); other.Vertices.Add(this.interp_vertex(list3[1], list3[2], list4[1], list4[2])); other.Faces.AddFace(0, 3, 1); break; case 6: case 9: other.Vertices.Add(this.interp_vertex(list3[0], list3[1], list4[0], list4[1])); other.Vertices.Add(this.interp_vertex(list3[1], list3[3], list4[1], list4[3])); other.Vertices.Add(this.interp_vertex(list3[2], list3[3], list4[2], list4[3])); other.Faces.AddFace(0, 1, 2); other.Vertices.Add(this.interp_vertex(list3[0], list3[2], list4[0], list4[2])); other.Faces.AddFace(0, 3, 2); break; case 7: case 8: other.Vertices.Add(this.interp_vertex(list3[3], list3[0], list4[3], list4[0])); other.Vertices.Add(this.interp_vertex(list3[3], list3[2], list4[3], list4[2])); other.Vertices.Add(this.interp_vertex(list3[3], list3[1], list4[3], list4[1])); other.Faces.AddFace(0, 1, 2); break; } mesh.Append(other); } mesh.Vertices.CombineIdentical(true, true); return mesh; }