protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { double v = -1.0; DA.GetData(1, ref v); if (!FriedChiken.isInitialized) { Rhino.Geometry.Curve c = null; if (!DA.GetData(0, ref c)) { return; } if (c.IsPolyline()) { Rhino.Geometry.Polyline pl = null; if (c.TryGetPolyline(out pl)) { nNewNodes = pl.Count(); nElements = nNewNodes - 1; newNodes.Clear(); newNodes.AddRange(pl); lGeometry.Clear(); cV = new constrainVolumeObject(v); mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes]; for (int i = 0; i < nNewNodes; i++) { particles[i] = new mikity.NumericalMethodHelper.particle(newNodes[i][0], newNodes[i][1], newNodes[i][2]); } pS = new GH_particleSystem(particles); List <mikity.NumericalMethodHelper.elements.isoparametricElement> e = new List <mikity.NumericalMethodHelper.elements.isoparametricElement>(); for (int i = 0; i < nElements; i++) { e.Add(new mikity.NumericalMethodHelper.elements.isoparametricElement(i, i + 1)); } for (int i = 0; i < e.Count; i++) { cV.addElement(e[i]); } pS.Value.addObject(cV); lGeometry.Clear(); for (int i = 0; i < pS.Value.__N; i++) { lGeometry.Add(particles[i][0], particles[i][1], particles[i][2]); } } } else { AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Only polyline is accepted"); return; } } else { if (cV != null && v > 0) { cV.refVolume = v / nElements; } } this.DVPW = GetDVPW(lGeometry); pS.DVPW = GetDVPW(lGeometry2); pS.UPGR = GetUPGR(lGeometry2); pS.BKGT = GetBKGT(lGeometry2); this.BKGT = GetBKGT(lGeometry); DA.SetData(0, pS); DA.SetDataList(1, newNodes); }
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); }