protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { if (!FriedChiken.isInitialized) { List <GH_Point> pointList = new List <GH_Point>(); DA.GetDataList(0, pointList); bool x = true, y = true, z = true; if (!DA.GetData(1, ref x)) { return; } if (!DA.GetData(2, ref y)) { return; } if (!DA.GetData(3, ref z)) { return; } bool isGroup = true; if (!DA.GetData(4, ref isGroup)) { return; } _nNodes = pointList.Count; mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[_nNodes]; for (int i = 0; i < _nNodes; i++) { particles[i] = new particle(pointList[i].Value.X, pointList[i].Value.Y, pointList[i].Value.Z); } pS = new GH_particleSystem(particles); node[] lNodes = new node[_nNodes]; for (int i = 0; i < _nNodes; i++) { lNodes[i] = new node(i); lNodes[i].copyFrom(pS.Value.particles); } if (isGroup) { fixedNodes fN = new fixedNodes(x, y, z); for (int i = 0; i < _nNodes; i++) { fN.addNode(lNodes[i]); } pS.Value.addObject(fN); } else { for (int i = 0; i < _nNodes; i++) { fixedNodes fN = new fixedNodes(x, y, z); fN.addNode(lNodes[i]); pS.Value.addObject(fN); } } lGeometry = new Rhino.Geometry.Point3d[_nNodes]; lGeometry2 = new Rhino.Geometry.Point3d[_nNodes]; for (int i = 0; i < _nNodes; i++) { lGeometry[i] = new Rhino.Geometry.Point3d(particles[i][0], particles[i][1], particles[i][2]); } this.DVPW = GetDVPW(lGeometry); this.BKGT = GetBKGT(lGeometry); pS.DVPW = GetDVPW(lGeometry2); pS.UPGR = GetUPGR(lGeometry2); pS.BKGT = GetBKGT(lGeometry2); } DA.SetData(0, pS); }
protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { if (!FriedChiken.isInitialized) { GH_Point[] pointList = new GH_Point[2]; List <GH_Point> tmpPointList = new List <GH_Point>(); GH_Curve c = new GH_Curve(); int[] nEdgeNodes = new int[_dim]; DA.GetData(0, ref c); DA.GetData(1, ref nEdgeNodes[0]); bool x = true, y = true, z = true; if (!DA.GetData(2, ref x)) { return; } if (!DA.GetData(3, ref y)) { return; } if (!DA.GetData(4, ref z)) { return; } for (int i = 0; i < _dim; i++) { if (nEdgeNodes[i] < 2) { AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Integers must be greater than or equal to 2"); return; } } //点群生成 int nNewNodes = nEdgeNodes[0]; nElements = nNewNodes - 1; mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes]; for (int i = 0; i < nNewNodes; i++) { Rhino.Geometry.Point3d p = c.Value.PointAt(c.Value.Domain.T0 + (c.Value.Domain.T1 - c.Value.Domain.T0) / nElements * i); particles[i] = new particle(p.X, p.Y, p.Z); } pS = new GH_particleSystem(particles); node[] lNodes = new node[nNewNodes]; for (int i = 0; i < nNewNodes; i++) { lNodes[i] = new node(i); lNodes[i].copyFrom(pS.Value.particles); } fixedNodes fN = new fixedNodes(x, y, z); for (int i = 0; i < nNewNodes; i++) { fN.addNode(lNodes[i]); } pS.Value.addObject(fN); lGeometry = new Rhino.Geometry.Point3d[nNewNodes]; for (int i = 0; i < nNewNodes; i++) { lGeometry[i] = new Rhino.Geometry.Point3d(particles[i][0], particles[i][1], particles[i][2]); } } DA.SetData(0, pS); }
protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { if (!FriedChiken.isInitialized) { GH_Point[] pointList = new GH_Point[2]; List <GH_Point> tmpPointList = new List <GH_Point>(); int[] nEdgeNodes = new int[_dim]; DA.GetData(0, ref pointList[0]); DA.GetData(1, ref pointList[1]); DA.GetData(2, ref nEdgeNodes[0]); bool x = true, y = true, z = true; if (!DA.GetData(3, ref x)) { return; } if (!DA.GetData(4, ref y)) { return; } if (!DA.GetData(5, ref z)) { return; } for (int i = 0; i < _dim; i++) { if (nEdgeNodes[i] < 2) { AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Integers must be greater than or equal to 2"); return; } } //点群生成 double[,] wt = mikity.MathUtil.bicubic(_dim, nEdgeNodes); int nNewNodes = wt.GetLength(0); mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes]; for (int i = 0; i < nNewNodes; i++) { particles[i] = new particle(0, 0, 0); for (int j = 0; j < _nNodes; j++) { particles[i][0] += pointList[j].Value.X * wt[i, j]; particles[i][1] += pointList[j].Value.Y * wt[i, j]; particles[i][2] += pointList[j].Value.Z * wt[i, j]; } } pS = new GH_particleSystem(particles); node[] lNodes = new node[nNewNodes]; for (int i = 0; i < nNewNodes; i++) { lNodes[i] = new node(i); lNodes[i].copyFrom(pS.Value.particles); } fixedNodes fN = new fixedNodes(x, y, z); for (int i = 0; i < nNewNodes; i++) { fN.addNode(lNodes[i]); } pS.Value.addObject(fN); lGeometry = new Rhino.Geometry.Point3d[nNewNodes]; for (int i = 0; i < nNewNodes; i++) { lGeometry[i] = new Rhino.Geometry.Point3d(particles[i][0], particles[i][1], particles[i][2]); } } DA.SetData(0, pS); }
protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { if (!FriedChiken.isInitialized) { List <GH_Point> pointList1 = new List <GH_Point>(); List <GH_Point> pointList2 = new List <GH_Point>(); if (!DA.GetDataList(0, pointList1)) { return; } if (!DA.GetDataList(1, pointList2)) { return; } if (pointList1.Count != pointList2.Count) { AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "The first and second lists must have the same elements"); return; } int __n = pointList1.Count; int nU = 0; if (!DA.GetData(2, ref nU)) { return; } List <GH_Point[]> pointLists = new List <GH_Point[]>(); for (int i = 0; i < __n; i++) { pointLists.Add(new GH_Point[nU]); } bool x = true, y = true, z = true; if (!DA.GetData(3, ref x)) { return; } if (!DA.GetData(4, ref y)) { return; } if (!DA.GetData(5, ref z)) { return; } bool isGroup = true; if (!DA.GetData(6, ref isGroup)) { return; } //点群生成 double[,] wt = mikity.MathUtil.bicubic(1, new int[1] { nU }); int nNewNodes = wt.GetLength(0); mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes * __n]; for (int j = 0; j < __n; j++) { for (int i = 0; i < nNewNodes; i++) { particles[i + j * nNewNodes] = new particle(0, 0, 0); particles[i + j * nNewNodes][0] += pointList1[j].Value.X * wt[i, 0]; particles[i + j * nNewNodes][1] += pointList1[j].Value.Y * wt[i, 0]; particles[i + j * nNewNodes][2] += pointList1[j].Value.Z * wt[i, 0]; particles[i + j * nNewNodes][0] += pointList2[j].Value.X * wt[i, 1]; particles[i + j * nNewNodes][1] += pointList2[j].Value.Y * wt[i, 1]; particles[i + j * nNewNodes][2] += pointList2[j].Value.Z * wt[i, 1]; } } pS = new GH_particleSystem(particles); node[] lNodes = new node[__n * nNewNodes]; for (int i = 0; i < __n * nNewNodes; i++) { lNodes[i] = new node(i); lNodes[i].copyFrom(pS.Value.particles); } if (isGroup) { fixedNodes fN = new fixedNodes(x, y, z); for (int i = 0; i < __n * nNewNodes; i++) { fN.addNode(lNodes[i]); } pS.Value.addObject(fN); } else { for (int i = 0; i < __n; i++) { fixedNodes fN = new fixedNodes(x, y, z); for (int j = 0; j < nNewNodes; j++) { fN.addNode(lNodes[j + nNewNodes * i]); } pS.Value.addObject(fN); } } if (isGroup) { } else { } lGeometry.Clear(); lGeometry2.Clear(); for (int i = 0; i < __n * nNewNodes; i++) { lGeometry.Add(new Rhino.Geometry.Point3d(particles[i][0], particles[i][1], particles[i][2])); } this.DVPW = GetDVPW(lGeometry); this.BKGT = GetBKGT(lGeometry); pS.DVPW = GetDVPW(lGeometry2); pS.UPGR = GetUPGR(lGeometry2); pS.BKGT = GetBKGT(lGeometry2); } DA.SetData(0, pS); }