Beispiel #1
0
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            bool toggle = false;

            if (!DA.GetData(1, ref toggle))
            {
                return;
            }
            if (!DA.GetData(2, ref rs))
            {
                return;
            }
            if (toggle == false)
            {
                newFunction = new GH_function();
                if (!DA.GetData(0, ref newFunction))
                {
                    return;
                }
                t       = 0;
                numNode = 12 * (newFunction.uMax) * (newFunction.vMax);
                int maxNumMember = 20 * (newFunction.uMax) * (newFunction.vMax);
                x                        = new double[numNode, 3];
                originalX                = new double[numNode, 3];
                force                    = new double[numNode, 3];
                velocity                 = new double[numNode, 3];
                nodeType                 = new int[numNode];
                numberOfMembersAtNode    = new int[numNode];
                maxNumberOfMembersAtNode = new int[numNode];
                numberFarEndsBoundary    = new int[numNode];
                thisEnd                  = new int[maxNumMember];
                thatEnd                  = new int[maxNumMember];
                MemberType               = new int[maxNumMember];

                lP = initNodes(newFunction, numNode);
                lL = initMembers(newFunction, numNode);
            }
            else
            {
                calculation();
                visualization();
                t++;
            }
            DA.SetDataList(0, lP);
            DA.SetDataList(1, lL);
        }
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            List <GH_vectorINT>           el = new List <GH_vectorINT>();
            List <Rhino.Geometry.Point3d> pl = new List <Rhino.Geometry.Point3d>();

            Rhino.Geometry.Mesh m = null;
            if (!DA.GetData(0, ref m))
            {
                return;
            }
            pl.AddRange(m.Vertices.ToPoint3dArray());
            for (int i = 0; i < m.Faces.Count; i++)
            {
                if (m.Faces[i].IsQuad)
                {
                    int[] f = new int[4] {
                        m.Faces[i].A, m.Faces[i].B, m.Faces[i].D, m.Faces[i].C
                    };
                    el.Add(new GH_vectorINT(f));
                }
            }
            DA.SetDataList(0, pl);
            DA.SetDataList(1, el);
        }
        /// <summary>
        /// You will need to override this method to solve the component.
        /// </summary>
        /// <param name="DA">Grasshopper's DataAccess interface</param>
        protected override void SolveInstance(GH.Kernel.IGH_DataAccess DA)
        {
            // Retrieve the data and pass it to the designer component
            Point3d point   = new Point3d(0, 0, 0);
            double  span    = 10.0;
            double  height  = 1.0;
            int     n       = 1;
            double  spacing = 1.0;

            if (DA.GetData <Point3d>(1, ref point))
            {
                ((DesignerWithVisualOutputExample)this.Designer).basePoint = new SOPoint3d(
                    point.X,
                    point.Y,
                    point.Z);
            }
            if (DA.GetData <double>(2, ref span))
            {
                ((DesignerWithVisualOutputExample)this.Designer).Span = span;
            }
            if (DA.GetData <double>(3, ref height))
            {
                ((DesignerWithVisualOutputExample)this.Designer).Height = height;
            }
            if (DA.GetData <int>(4, ref n))
            {
                ((DesignerWithVisualOutputExample)this.Designer).NumberOfFrames = n;
            }
            if (DA.GetData <double>(5, ref spacing))
            {
                ((DesignerWithVisualOutputExample)this.Designer).Spacing = spacing;
            }

            /// Note that you will need to call the SolveInstance method of the base class to process the default parameters and connect them to the framework.
            base.SolveInstance(DA);

            DesignerWithVisualOutputExample dsn = (DesignerWithVisualOutputExample)this.Designer;

            List <Line> lines = new List <Line>();

            for (int i = 0; i < dsn.NumberOfFrames; i++)
            {
                lines.Add(new Line(dsn.Points2[i].X, dsn.Points2[i].Y, dsn.Points2[i].Z, dsn.Points4[i].X, dsn.Points4[i].Y, dsn.Points4[i].Z));
                lines.Add(new Line(dsn.Points1[i].X, dsn.Points1[i].Y, dsn.Points1[i].Z, dsn.Points2[i].X, dsn.Points2[i].Y, dsn.Points2[i].Z));
                lines.Add(new Line(dsn.Points3[i].X, dsn.Points3[i].Y, dsn.Points3[i].Z, dsn.Points4[i].X, dsn.Points4[i].Y, dsn.Points4[i].Z));
            }
            DA.SetDataList(1, lines);
        }
Beispiel #4
0
        /// <summary>
        /// This function will be called (successively) from within the
        /// ComputeData method of this component
        /// </summary>
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess data)
        {
            Rhino.Geometry.Point3d center = Rhino.Geometry.Point3d.Origin;
            double length = 1.0;

            if (!data.GetData(m_center_index, ref center))
            {
                return;
            }
            if (!data.GetData(m_length_index, ref length))
            {
                return;
            }
            if (!center.IsValid || length <= 0.0)
            {
                return;
            }

            Rhino.Geometry.Vector3d  dir          = center - Rhino.Geometry.Point3d.Origin;
            Rhino.Geometry.Plane     plane        = Rhino.Geometry.Plane.WorldXY;
            Rhino.Geometry.Transform xf_translate = Rhino.Geometry.Transform.Translation(dir);
            Rhino.Geometry.Transform xf_scale     = Rhino.Geometry.Transform.Scale(plane, length, length, length);
            Rhino.Geometry.Transform xf           = xf_translate * xf_scale;
            if (!xf.IsValid)
            {
                return;
            }

            PlatonicsCommon.PlatonicBase geom = Geometry();
            if (null == geom)
            {
                return;
            }

            Rhino.Geometry.Brep[] faces = geom.Faces();
            if (null != faces && 0 < faces.Length)
            {
                foreach (Brep t in faces)
                {
                    t.Transform(xf);
                }
                data.SetDataList(m_faces_index, faces);
            }

            Rhino.Geometry.Curve[] edges = geom.Edges();
            if (null != edges && 0 < edges.Length)
            {
                foreach (Curve t in edges)
                {
                    t.Transform(xf);
                }
                data.SetDataList(m_edges_index, edges);
            }

            Rhino.Geometry.Point3d[] vertices = geom.Vertices();
            if (null != vertices && 0 < vertices.Length)
            {
                for (int i = 0; i < vertices.Length; i++)
                {
                    vertices[i].Transform(xf);
                }
                data.SetDataList(m_vertices_index, vertices);
            }
        }
Beispiel #5
0
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            List <GH_hill> listHill = new List <GH_hill>();
            int            uMax = 0, vMax = 0;
            double         size = 0.0;

            if (!DA.GetDataList(0, listHill))
            {
                return;
            }
            if (!DA.GetData(1, ref size))
            {
                return;
            }
            if (!DA.GetData(2, ref uMax))
            {
                return;
            }
            if (!DA.GetData(3, ref vMax))
            {
                return;
            }
            double ContourInterval = 0.01 * listHill[0].Value.h;
            double seaLevel        = 30.0 * ContourInterval;

            double c      = size / uMax;
            double otherc = size / vMax;

            if (c > otherc)
            {
                c = otherc;
            }
            double maxX = c * uMax / 2d;
            double maxY = c * vMax / 2d;

            GH_function newFunction = new GH_function();

            newFunction.Value      = new function();
            newFunction.Value.Func = new _function((xValue, yValue) => {
                res f          = new res();
                double z       = -seaLevel;
                double zDiff_X = 0;
                double zDiff_Y = 0;
                double dx      = 0;
                double dy      = 0;
                for (int hill = 0; hill < listHill.Count; hill++)
                {
                    dx = xValue - listHill[hill].Value.x;
                    dy = yValue - listHill[hill].Value.y;
                    double expThingy = listHill[hill].Value.h * Math.Exp(-(dx * dx + dy * dy) / (listHill[hill].Value.size * listHill[hill].Value.size));
                    z       += expThingy;
                    zDiff_X -= dx * expThingy / (listHill[hill].Value.size * listHill[hill].Value.size);
                    zDiff_Y -= dy * expThingy / (listHill[hill].Value.size * listHill[hill].Value.size);
                }
                f.z      = z;
                f.zDiffX = zDiff_X;
                f.zDiffY = zDiff_Y;

                return(f);
            });
            Rhino.Geometry.PointCloud pc = new Rhino.Geometry.PointCloud();

            for (int i = 0; i <= uMax * 4; i++)
            {
                for (int j = 0; j <= vMax * 4; j++)
                {
                    double x = -maxX + (c / 4d) * i;
                    double y = -maxY + (c / 4d) * j;
                    pc.Add(new Rhino.Geometry.Point3d(x, y, newFunction.Value.Func(x, y).z));
                }
            }
            Rhino.Geometry.Plane        plane     = new Rhino.Geometry.Plane(new Rhino.Geometry.Point3d(0, 0, 0), new Rhino.Geometry.Vector3d(1.0, 0, 0), new Rhino.Geometry.Vector3d(0.0, 1.0, 0));
            Rhino.Geometry.PlaneSurface planeSurf = new Rhino.Geometry.PlaneSurface(plane, new Rhino.Geometry.Interval(-size / 2d * 1.2d, size / 2d * 1.2d), new Rhino.Geometry.Interval(-size / 2d * 1.2d, size / 2d * 1.2d));
            DA.SetDataList(0, pc.GetPoints().ToList());
            DA.SetData(1, planeSurf);
            newFunction.size            = size;
            newFunction.uMax            = uMax;
            newFunction.vMax            = vMax;
            newFunction.maxX            = maxX;
            newFunction.maxY            = maxY;
            newFunction.c               = c;
            newFunction.seaLevel        = seaLevel;
            newFunction.ContourInterval = ContourInterval;
            newFunction.a               = c * (Math.Sqrt(7.0) - 1.0) / 6.0;
            newFunction.bsin            = c / 4.0;
            newFunction.bcos            = c * (4.0 - Math.Sqrt(7.0)) / 12.0;
            DA.SetData(2, newFunction);
        }
        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);


                        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]);
                        }
                        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));
                        }
                        lCV.Clear();
                        pS = new GH_particleSystem(particles);
                        for (int i = 0; i < e.Count; i++)
                        {
                            lCV.Add(new constrainVolumeObject(v / nElements));
                            lCV[i].addElement(e[i]);
                            pS.Value.addObject(lCV[i]);
                        }

                        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);
                        pS.DVPW   = GetDVPW(lGeometry2);
                        pS.UPGR   = GetUPGR(lGeometry2);
                        pS.BKGT   = GetBKGT(lGeometry2);
                        this.BKGT = GetBKGT(lGeometry);
                    }
                }
                else
                {
                    AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Only polyline is accepted");
                    return;
                }
            }
            else
            {
                if (lCV != null && v > 0)
                {
                    for (int i = 0; i < lCV.Count; i++)
                    {
                        lCV[i].refVolume = v / nElements;
                    }
                }
            }
            DA.SetData(0, pS);
            DA.SetDataList(1, newNodes);
        }
Beispiel #7
0
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            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))
                    {
                        int nNewNodes = pl.Count();
                        int nElements = nNewNodes - 1;
                        newNodes.Clear();
                        newNodes.AddRange(pl);
                        GH_material mat = null;
                        GH_gravity  gvt = null;
                        if (!DA.GetData(1, ref mat))
                        {
                            return;
                        }
                        if (!DA.GetData(2, ref gvt))
                        {
                            return;
                        }


                        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]);
                        }

                        eM = new generalSpring();
                        pS = new GH_particleSystem(particles);
                        for (int i = 0; i < nElements; i++)
                        {
                            mikity.NumericalMethodHelper.elements.isoparametricElement e = new NumericalMethodHelper.elements.isoparametricElement(i, i + 1);
                            eM.addElement(e);
                        }
                        eM.setMaterial(mat.Value, gvt.Value);
                        pS.Value.addObject(eM);
                        lGeometry  = new Rhino.Geometry.Polyline();
                        lGeometry2 = new Rhino.Geometry.Polyline();

                        for (int i = 0; i < pS.Value.__N; i++)
                        {
                            lGeometry.Add(particles[i][0], particles[i][1], particles[i][2]);
                        }

                        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);
                    }
                }
                else
                {
                    AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Only polyline is accepted");
                    return;
                }
            }
        }
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            if (!FriedChiken.isInitialized)
            {
                Rhino.Geometry.Mesh m = null;
                if (!DA.GetData(0, ref m))
                {
                    return;
                }
                lGeometry  = m.DuplicateMesh();
                lGeometry2 = m.DuplicateMesh();
                newNodes.Clear();
                newNodes.AddRange(m.Vertices.ToPoint3dArray());
                int nNewNodes = newNodes.Count;
                el = new List <int[]>();
                for (int i = 0; i < m.Faces.Count; i++)
                {
                    if (m.Faces[i].IsQuad)
                    {
                        int[] f = new int[4] {
                            m.Faces[i].A, m.Faces[i].B, m.Faces[i].D, m.Faces[i].C
                        };
                        el.Add(f);
                    }
                    if (m.Faces[i].IsTriangle)
                    {
                        int[] f = new int[3] {
                            m.Faces[i].A, m.Faces[i].B, m.Faces[i].C
                        };
                        el.Add(f);
                    }
                }
                bool isJoin = false;
                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]);
                }

                eM = new generalSpring();
                pS = new GH_particleSystem(particles);
                if (!DA.GetData(3, ref isJoin))
                {
                    return;
                }
                if (isJoin)
                {
                    pS.simplify(el);
                }
                lGeometry.Faces.Clear();
                lGeometry2.Faces.Clear();
                for (int i = 0; i < el.Count; i++)
                {
                    if (el[i].Length == 4)
                    {
                        mikity.NumericalMethodHelper.elements.isoparametricElement e = new NumericalMethodHelper.elements.isoparametricElement(el[i]);
                        eM.addElement(e);
                        lGeometry.Faces.AddFace(e.el[0], e.el[1], e.el[3], e.el[2]);
                        lGeometry2.Faces.AddFace(e.el[0], e.el[1], e.el[3], e.el[2]);
                    }
                    else if (el[i].Length == 3)
                    {
                        mikity.NumericalMethodHelper.elements.simplexElement e = new NumericalMethodHelper.elements.simplexElement(el[i]);
                        eM.addElement(e);
                        lGeometry.Faces.AddFace(e.el[0], e.el[1], e.el[2]);
                        lGeometry2.Faces.AddFace(e.el[0], e.el[1], e.el[2]);
                    }
                }
                pS.Value.addObject(eM);
                this.DVPW = GetDVPW(lGeometry);
                this.BKGT = GetBKGT(lGeometry);
                pS.DVPW   = GetDVPW(lGeometry2);
                pS.UPGR   = GetUPGR(lGeometry2);
                pS.BKGT   = GetBKGT(lGeometry2);
                DA.SetData(0, pS);
                DA.SetDataList(1, newNodes);
                GH_material mat = null;
                GH_gravity  gvt = null;
                if (!DA.GetData(1, ref mat))
                {
                    return;
                }
                if (!DA.GetData(2, ref gvt))
                {
                    return;
                }
                eM.setMaterial(mat.Value, gvt.Value);
            }
        }
Beispiel #9
0
        /// <summary>
        /// This function will be called (successively) from within the
        /// ComputeData method of this component
        /// </summary>
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess data)
        {
            var center = Rhino.Geometry.Point3d.Origin;
            var length = 1.0;

            if (!data.GetData(0, ref center))
            {
                return;
            }
            if (!data.GetData(1, ref length))
            {
                return;
            }
            if (!center.IsValid || length <= 0.0)
            {
                return;
            }

            var dir          = center - Point3d.Origin;
            var plane        = Plane.WorldXY;
            var xf_translate = Transform.Translation(dir);
            var xf_scale     = Transform.Scale(plane, length, length, length);
            var xf           = xf_translate * xf_scale;

            if (!xf.IsValid)
            {
                return;
            }

            var geom = Geometry();

            if (null == geom)
            {
                return;
            }

            var faces = geom.Faces();

            if (null != faces && 0 < faces.Length)
            {
                foreach (var face in faces)
                {
                    face.Transform(xf);
                }
                data.SetDataList(0, faces);
            }

            var edges = geom.Edges();

            if (null != edges && 0 < edges.Length)
            {
                foreach (var edge in edges)
                {
                    edge.Transform(xf);
                }
                data.SetDataList(1, edges);
            }

            var vertices = geom.Vertices();

            if (null != vertices && 0 < vertices.Length)
            {
                for (var i = 0; i < vertices.Length; i++)
                {
                    vertices[i].Transform(xf);
                }
                data.SetDataList(2, vertices);
            }
        }
Beispiel #10
0
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            if (!FriedChiken.isInitialized)
            {
                Rhino.Geometry.Surface s = null;
                if (!DA.GetData(0, ref s))
                {
                    return;
                }
                Rhino.Geometry.Interval uDomain = s.Domain(0);
                Rhino.Geometry.Interval vDomain = s.Domain(1);
                int[] nEdgeNodes = new int[_dim];
                DA.GetData(1, ref nEdgeNodes[0]);
                DA.GetData(2, ref nEdgeNodes[1]);
                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;
                    }
                }
                Rhino.Geometry.Mesh m = new Rhino.Geometry.Mesh();
                //メッシュノード構築
                newNodes.Clear();
                for (int i = 0; i < nEdgeNodes[1]; i++)
                {
                    for (int j = 0; j < nEdgeNodes[0]; j++)
                    {
                        newNodes.Add(s.PointAt(uDomain.T0 + (uDomain.T1 - uDomain.T0) / (nEdgeNodes[0] - 1) * j, vDomain.T0 + (vDomain.T1 - vDomain.T0) / (nEdgeNodes[1] - 1) * i));
                    }
                }
                m.Vertices.AddVertices(newNodes);
                int nNewNodes = newNodes.Count;

                GH_material mat = null;
                GH_gravity  gvt = null;
                if (!DA.GetData(3, ref mat))
                {
                    return;
                }
                if (!DA.GetData(4, ref gvt))
                {
                    return;
                }

                el = MathUtil.isoparametricElements(nEdgeNodes);
                int nElements = el.Length;
                //メッシュ構築
                for (int i = 0; i < nElements; i++)
                {
                    m.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]);
                }
                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]);
                }

                eM = new generalSpring();
                pS = new GH_particleSystem(particles);
                for (int i = 0; i < nElements; i++)
                {
                    if (_subdv == subdivide.quad)
                    {
                        eM.addElement(new mikity.NumericalMethodHelper.elements.isoparametricElement(el[i]));
                    }
                    if (_subdv == subdivide.triA)
                    {
                        eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] {
                            el[i][0], el[i][1], el[i][3]
                        }));
                        eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] {
                            el[i][0], el[i][3], el[i][2]
                        }));
                    }
                    if (_subdv == subdivide.triB)
                    {
                        int S = i % (nEdgeNodes[0] - 1);
                        int T = (i - S) / (nEdgeNodes[0] - 1);
                        if (T % 2 == 1)
                        {
                            S++;
                        }
                        if (S % 2 == 0)
                        {
                            eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] {
                                el[i][0], el[i][1], el[i][3]
                            }));
                            eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] {
                                el[i][0], el[i][3], el[i][2]
                            }));
                        }
                        else
                        {
                            eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] {
                                el[i][0], el[i][1], el[i][2]
                            }));
                            eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] {
                                el[i][2], el[i][1], el[i][3]
                            }));
                        }
                    }
                    if (_subdv == subdivide.triC)
                    {
                        int S = i % (nEdgeNodes[0] - 1);
                        if (S % 2 == 0)
                        {
                            eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] {
                                el[i][0], el[i][1], el[i][3]
                            }));
                            eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] {
                                el[i][0], el[i][3], el[i][2]
                            }));
                        }
                        else
                        {
                            eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] {
                                el[i][0], el[i][1], el[i][2]
                            }));
                            eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] {
                                el[i][2], el[i][1], el[i][3]
                            }));
                        }
                    }
                }
                if (_subdv == subdivide.quad)
                {
                    nElements *= 1;
                }
                else
                {
                    nElements *= 2;
                }
                lGeometry  = new Rhino.Geometry.Mesh();
                lGeometry2 = new Rhino.Geometry.Mesh();
                lGeometry.Vertices.Clear();
                lGeometry.Faces.Clear();
                lGeometry2.Faces.Clear();
                for (int i = 0; i < pS.Value.__N; i++)
                {
                    lGeometry.Vertices.Add(particles[i][0], particles[i][1], particles[i][2]);
                }
                for (int i = 0; i < nElements; i++)
                {
                    if (_subdv == subdivide.quad)
                    {
                        lGeometry.Faces.AddFace(eM.elemList[i].el[0], eM.elemList[i].el[1], eM.elemList[i].el[3], eM.elemList[i].el[2]);
                    }
                    else
                    {
                        lGeometry.Faces.AddFace(eM.elemList[i].el[0], eM.elemList[i].el[1], eM.elemList[i].el[2]);
                    }
                }
                for (int i = 0; i < nElements; i++)
                {
                    if (_subdv == subdivide.quad)
                    {
                        lGeometry2.Faces.AddFace(eM.elemList[i].el[0], eM.elemList[i].el[1], eM.elemList[i].el[3], eM.elemList[i].el[2]);
                    }
                    else
                    {
                        lGeometry2.Faces.AddFace(eM.elemList[i].el[0], eM.elemList[i].el[1], eM.elemList[i].el[2]);
                    }
                }

                eM.setMaterial(mat.Value, gvt.Value);
                pS.Value.addObject(eM);
                this.DVPW = GetDVPW(lGeometry);
                this.BKGT = GetBKGT(lGeometry);
                pS.DVPW   = GetDVPW(lGeometry2);
                pS.UPGR   = GetUPGR(lGeometry2);
                pS.BKGT   = GetBKGT(lGeometry2);

                DA.SetData(0, pS);
                DA.SetDataList(1, newNodes);
            }
        }
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            if (!FriedChiken.isInitialized)
            {
                Rhino.Geometry.Curve c = null;
                if (!DA.GetData(0, ref c))
                {
                    return;
                }

                Rhino.Geometry.Interval uDomain = c.Domain;
                int[] nEdgeNodes = new int[_dim];
                DA.GetData(1, ref nEdgeNodes[0]);
                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;
                    }
                }
                lGeometry.Clear();
                //メッシュノード構築
                newNodes.Clear();
                for (int j = 0; j < nEdgeNodes[0]; j++)
                {
                    newNodes.Add(c.PointAt(uDomain.T0 + (uDomain.T1 - uDomain.T0) / (nEdgeNodes[0] - 1) * j));
                }
                int nNewNodes = newNodes.Count;

                GH_material mat = null;
                GH_gravity  gvt = null;
                if (!DA.GetData(2, ref mat))
                {
                    return;
                }
                if (!DA.GetData(3, ref gvt))
                {
                    return;
                }

                el = MathUtil.isoparametricElements(nEdgeNodes);
                int nElements = el.Length;


                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]);
                }

                eM = new generalSpring();
                pS = new GH_particleSystem(particles);
                for (int i = 0; i < el.Length; i++)
                {
                    mikity.NumericalMethodHelper.elements.isoparametricElement e = new NumericalMethodHelper.elements.isoparametricElement(el[i]);
                    eM.addElement(e);
                }
                eM.setMaterial(mat.Value, gvt.Value);


                for (int i = 0; i < pS.Value.__N; i++)
                {
                    lGeometry.Add(particles[i][0], particles[i][1], particles[i][2]);
                }

                this.DVPW = GetDVPW(lGeometry);
                pS.DVPW   = GetDVPW(lGeometry2);
                pS.UPGR   = GetUPGR(lGeometry2);
                pS.BKGT   = GetBKGT(lGeometry2);

                pS.Value.addObject(eM);

                DA.SetData(0, pS);
                DA.SetDataList(1, newNodes);
            }
        }
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            if (!FriedChiken.isInitialized)
            {
                Rhino.Geometry.Mesh m = null;
                if (!DA.GetData(0, ref m))
                {
                    return;
                }
                lGeometry.Clear();
                lGeometry2.Clear();
                var ms = mikity.GeometryProcessing.MeshStructure.CreateFrom(m);

                var edges    = ms.edges();
                var boundary = new Rhino.Geometry.Polyline();
                newNodes.Clear();
                newNodes.AddRange(m.Vertices.ToPoint3dArray());
                int nNewNodes = newNodes.Count;
                el = new List <int[]>();
                foreach (var e in edges)
                {
                    if (!e.isNaked)
                    {
                        el.Add(new int[2] {
                            e.P.N, e.next.P.N
                        });
                    }
                }
                var s = ms.boundaryStart.hf_begin;
                do
                {
                    var P = m.Vertices[s.P.N];
                    boundary.Add(new Rhino.Geometry.Point3d(P.X, P.Y, P.Z));
                    s = s.next.P.hf_begin;
                } while (s.P != ms.boundaryStart);

                boundary.Add(new Rhino.Geometry.Point3d(boundary[0]));
                var  boundary2 = new Rhino.Geometry.PolylineCurve(boundary);
                bool isJoin    = false;
                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]);
                }

                eM = new generalSpring();
                pS = new GH_particleSystem(particles);
                if (!DA.GetData(3, ref isJoin))
                {
                    return;
                }
                if (isJoin)
                {
                    pS.simplify(el);
                }
                foreach (var e in el)
                {
                    var ee = new mikity.NumericalMethodHelper.elements.simplexElement(e);
                    eM.addElement(ee);
                    lGeometry.Add(new Rhino.Geometry.Line(pS.Value.particles[e[0], 0], pS.Value.particles[e[0], 1], pS.Value.particles[e[0], 2], pS.Value.particles[e[1], 0], pS.Value.particles[e[1], 1], pS.Value.particles[e[1], 2]));
                }
                pS.Value.addObject(eM);
                this.DVPW = GetDVPW(lGeometry);
                this.BKGT = GetBKGT(lGeometry);
                pS.DVPW   = GetDVPW(lGeometry2);
                pS.UPGR   = GetUPGR(lGeometry2);
                pS.BKGT   = GetBKGT(lGeometry2);
                DA.SetData(0, pS);
                DA.SetDataList(1, newNodes);
                DA.SetData(2, boundary);
                GH_material mat = null;
                GH_gravity  gvt = null;
                if (!DA.GetData(1, ref mat))
                {
                    return;
                }
                if (!DA.GetData(2, ref gvt))
                {
                    return;
                }
                eM.setMaterial(mat.Value, gvt.Value);
            }
        }