protected override void SolveInstance(IGH_DataAccess DA) { GsaGravityLoad gravityLoad = new GsaGravityLoad(); //Load case int lc = 1; GH_Integer gh_lc = new GH_Integer(); if (DA.GetData(0, ref gh_lc)) { GH_Convert.ToInt32(gh_lc, out lc, GH_Conversion.Both); } gravityLoad.GravityLoad.Case = lc; //element/beam list string beamList = "all"; GH_String gh_bl = new GH_String(); if (DA.GetData(1, ref gh_bl)) { GH_Convert.ToString(gh_bl, out beamList, GH_Conversion.Both); } gravityLoad.GravityLoad.Elements = beamList; // 2 Name string name = ""; GH_String gh_name = new GH_String(); if (DA.GetData(2, ref gh_name)) { if (GH_Convert.ToString(gh_name, out name, GH_Conversion.Both)) { gravityLoad.GravityLoad.Name = name; } } //factor Vector3 factor = new Vector3(); Vector3d vect = new Vector3d(0, 0, -1); GH_Vector gh_factor = new GH_Vector(); if (DA.GetData(3, ref gh_factor)) { GH_Convert.ToVector3d(gh_factor, ref vect, GH_Conversion.Both); } factor.X = vect.X; factor.Y = vect.Y; factor.Z = vect.Z; gravityLoad.GravityLoad.Factor = factor; GsaLoad gsaLoad = new GsaLoad(gravityLoad); DA.SetData(0, new GsaLoadGoo(gsaLoad)); }
protected override void SolveInstance(IGH_DataAccess DA) { ///input parameters GH_Structure <GH_Vector> Tree = new GH_Structure <GH_Vector>(); bool s = false; /// initialise parameters List <int> X_i = new List <int>(); List <int> Y_i = new List <int>(); List <int> Z_i = new List <int>(); GH_Path pth = null; Vector3d vector3D = new Vector3d(); DataTree <int> indices = new DataTree <int>(); ///import if (!DA.GetDataTree("Vectors", out Tree)) { return; } if (!DA.GetData("Strict", ref s)) { return; } /// 0. error catching /// 1. decompose datatree /// 2. convert GH_GOO structure to rhinocommon Vector3D /// 3. querry list /// 4. create new datatree /// 5. output data // most occuring value in a list //int test = 0; double t_h = 0.1; //List<int> lijst = new List<int>(); //for (int k=0;k<W_i.Count;k++) //{ // test = X_i // .Where(v => Math.Abs(v - X_i[k]) <= t_h) // .Count(); // lijst.Add(test); //} //frequency = lijst; // efficient sum //int test = 0; double t_h = 0.1; List <Point3d> P1 = new List <Point3d>(); List <Point3d> P2 = new List <Point3d>(); List <Point3d> result = new List <Point3d>(); //List<Double> x = new List<Double>(); /// 1. decompose datatree for (int i = 0; i < Tree.PathCount; i++) { /// 2. convert GH_GOO structure to rhinocommon Vector3D pth = Tree.get_Path(i); var branch = Tree.Branches[i]; List <Vector3d> V = new List <Vector3d>(); foreach (GH_Vector thisGHVector in branch) { GH_Convert.ToVector3d(thisGHVector, ref vector3D, 0); V.Add(vector3D); } /// 3. querry list if (s == false) { X_i = V .Select((v, index) => index) .Where(index => Math.Abs(V[index].X) >= Math.Abs(V[index].Y) && Math.Abs(V[index].X) >= Math.Abs(V[index].Z)) .ToList(); Y_i = V .Select((v, index) => index) .Where(index => Math.Abs(V[index].Y) >= Math.Abs(V[index].X) && Math.Abs(V[index].Y) >= Math.Abs(V[index].Z)) .ToList(); Z_i = V .Select((v, index) => index) .Where(index => Math.Abs(V[index].Z) >= Math.Abs(V[index].X) && Math.Abs(V[index].Z) >= Math.Abs(V[index].Y)) .ToList(); } else { var a = 1 / Math.Sqrt(3); X_i = V .Select((v, index) => index) .Where(index => Math.Abs(V[index].X) >= a) .ToList(); Y_i = V .Select((v, index) => index) .Where(index => Math.Abs(V[index].Y) >= a) .ToList(); Z_i = V .Select((v, index) => index) .Where(index => Math.Abs(V[index].Z) >= a) .ToList(); } /// 4. create new datatree var path = pth.Indices.ToList(); path.Add(0); var p = new GH_Path(path.ToArray()); indices.AddRange(X_i, p); path = pth.Indices.ToList(); path.Add(1); p = new GH_Path(path.ToArray()); indices.AddRange(Y_i, p); path = pth.Indices.ToList(); path.Add(2); p = new GH_Path(path.ToArray()); indices.AddRange(Z_i, p); } /// 5. DA.SetDataTree(0, indices); }