protected override void SolveInstance(IGH_DataAccess DA) { ghGrid = new GH_Grid(); if (!DA.GetData(0, ref ghGrid)) { return; } if (GridHasChanged()) { hasValidControls = false; point = new IvyCore.Parametric.Point(ghGrid.Value); // cache a DeepCopy ghGridCache = ghGrid.DeepCopy(); this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Grid Has Changed. Reset Controls via Menu."); this.Message = "Select Controls in Menu"; } // If controls are valid, then compute the point if (hasValidControls) { UpdatePoint(DA); DA.SetDataList(1, point.Coord); DA.SetData(2, point.CellIndex()); } else { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Grid Has Changed. Reset Controls via Menu."); this.Message = "Select Controls in Menu"; } DA.SetData(0, ghGrid.Value.Info()); }
/// <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) { var vertices = new List <GH_Point>(); var faces = new GH_Structure <GH_Integer>(); var thickness = new List <GH_Number>(); DA.GetDataList(0, vertices); DA.GetDataTree(1, out faces); DA.GetDataList(2, thickness); var properties = new List <AbaqusShellElementProperty>(); double E = 5e9; double d = 1.0; for (int i = 0; i < faces.Branches.Count; i++) { double e = thickness[i].Value; var prop = new AbaqusShellElementProperty(e, E, d, 0); properties.Add(prop); } var shell = new Shell(ToList(vertices), ToList(faces), properties); var X3D = new double[2][] { new double[3] { 0, 1, 3 }, new double[3] { 0, 1, 3 } }; var grid3D = new Grid(X3D); var p = new IvyCore.Parametric.Point(grid3D, new double[2] { 1, 1 }); DA.SetData(0, p.CellIndex() + ""); // DA.SetData(1, grid3D.Info()); // var s = 3; }
protected override void SolveInstance(IGH_DataAccess DA) { var ghGrid = new GH_Grid(); var list = new List <double>(); if (!DA.GetData(0, ref ghGrid)) { return; } if (!DA.GetDataList(1, list)) { return; } point = new IvyCore.Parametric.Point(ghGrid.Value, list.ToArray()); DA.SetDataList(0, point.Coord); DA.SetData(1, point.CellIndex()); }
protected override void SolveInstance(IGH_DataAccess DA) { var ghGrid = new GH_Grid(); var list = new List <double>(); if (!DA.GetData(0, ref ghGrid)) { return; } if (!DA.GetDataList(1, list)) { return; } point = new IvyCore.Parametric.Point(ghGrid.Value, list.ToArray()); var cellIndex = point.CellIndex(); var LERP = ghGrid.Value.Cells[cellIndex].GetInterpolant(point); DA.SetDataList(0, point.Coord); DA.SetDataList(1, point.Normalized()); DA.SetData(2, cellIndex); DA.SetData(3, new GH_Interpolant(LERP)); }
/// <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) { var X2D = new double[2][] { new double[2] { 0, 1 }, new double[2] { 0, 1 } }; X2D = new double[2][] { new double[3] { 0, 0.25, 1 }, new double[3] { 0, 0.5, 1 } }; //var Z2D = new double[9] { 1, 1, 1, 1, 1, 1, 1, 1, 1 }; var Z2D = new double[9] { 1, 2, 3, 4, 2, -3, 1, 2, 3 }; //var Z2D = new double[4] { 1, 2, 3, 4 }; //Z2D = new double[6] { 1, 2, 3, 1, 2, 3 }; Z = Z2D; grid = new Grid(X2D); gp = new IvyCore.Parametric.Point(grid); Zpts = this.ConstructFieldView(grid, Z); var p = new Point3d(); DA.GetData(0, ref p); int n = Math.Min(gp.Dim, 3); for (int i = 0; i < n; i++) { gp[i] = p[i]; } int cellIndex = gp.CellIndex(); var cell = gp.Grid.Cells[cellIndex]; Interpolant interp = cell.GetInterpolant(gp); double zlerp = interp.Lerp(Z); //for (int i = 0; i < LERP.Length; i++) //{ // int index = cell.VerticesIndex[i]; // zlerp += LERP[i] * Z[index]; //} var cellPts = new Point3d[5]; double[] node; node = grid.Nodes[cell.VerticesIndex[0]].Coord; cellPts[0] = new Point3d(node[0], node[1], 0); node = grid.Nodes[cell.VerticesIndex[1]].Coord; cellPts[1] = new Point3d(node[0], node[1], 0); node = grid.Nodes[cell.VerticesIndex[3]].Coord; cellPts[2] = new Point3d(node[0], node[1], 0); node = grid.Nodes[cell.VerticesIndex[2]].Coord; cellPts[3] = new Point3d(node[0], node[1], 0); cellPts[4] = cellPts[0]; var contour = new PolylineCurve(cellPts); p.Z = zlerp; DA.SetData(0, p); DA.SetDataList(1, Zpts); DA.SetData(2, contour); DA.SetData(3, grid.Info()); }