예제 #1
0
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            double v = -1.0;

            DA.GetData(2, ref v);
            if (!FriedChiken.isInitialized)
            {
                GH_Point[] pointList = new GH_Point[2];
                DA.GetData(0, ref pointList[0]);
                DA.GetData(1, ref pointList[1]);
                cV = new constrainVolumeObject(v);
                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);
                cV.addElement(new isoparametricElement(0, 1));
                pS.Value.addObject(cV);
                lGeometry.Clear();
                lGeometry2.Clear();
                lGeometry.Add(particles[0][0], particles[0][1], particles[0][2]);
                lGeometry.Add(particles[1][0], particles[1][1], particles[1][2]);
                lGeometry2.Add(particles[0][0], particles[0][1], particles[0][2]);
                lGeometry2.Add(particles[1][0], particles[1][1], particles[1][2]);

                this.DVPW = GetDVPW(lGeometry);
                this.BKGT = GetBKGT(lGeometry);
                pS.DVPW   = GetDVPW(lGeometry2);
                pS.UPGR   = GetUPGR(lGeometry2);
                pS.BKGT   = GetBKGT(lGeometry2);
            }
            else
            {
                if (cV != null)
                {
                    if (v > 0)
                    {
                        cV.refVolume = v;
                    }
                }
            }

            DA.SetData(0, pS);
        }
예제 #2
0
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            double v = -1.0;

            DA.GetData(3, ref v);
            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]);
                cV = new constrainVolumeObject(v);
                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];
                    }
                }
                el = MathUtil.isoparametricElements(nEdgeNodes);
                int nElements = el.Length;
                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(el[i]));
                }
                for (int i = 0; i < e.Count; i++)
                {
                    cV.addElement(e[i]);
                }
                pS.Value.addObject(cV);
                lGeometry.Clear();
                for (int i = 0; i < nNewNodes; i++)
                {
                    lGeometry.Add(pS.Value.particles[i, 0], pS.Value.particles[i, 1], pS.Value.particles[i, 2]);
                }
                this.DVPW = GetDVPW(lGeometry);
                this.BKGT = GetBKGT(lGeometry);
                pS.DVPW   = GetDVPW(lGeometry2);
                pS.UPGR   = GetUPGR(lGeometry2);
                pS.BKGT   = GetBKGT(lGeometry2);
            }
            else
            {
                if (cV != null)
                {
                    if (v > 0)
                    {
                        cV.refVolume = v;
                    }
                }
            }
            DA.SetData(0, pS);
        }
예제 #3
0
        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);
        }