示例#1
0
    /// <summary>
    /// This procedure contains the user code. Input parameters are provided as regular arguments,
    /// Output parameters as ref arguments. You don't have to assign output parameters,
    /// they will have a default value.
    /// </summary>
    private void RunScript(bool reset, bool go, int mode, List <Point3d> P, List <Vector3d> V, double nR, double coS, double alS, double seS, double seR, ref object Ap, ref object Av)
    {
        // <Custom code>
        GH_Point[]  ptsOut;
        GH_Vector[] vecOut;

        if (reset || AgSys == null)
        {
            AgSys = new AgentSystem(P, V);
        }

        if (go)
        {
            AgSys.NeighborhoodRadius = nR;
            AgSys.CohesionStrength   = coS;
            AgSys.AlignmentStrength  = alS;
            AgSys.SeparationStrength = seS;
            AgSys.SeparationRadius   = seR;

            /*
             * if(condition)
             * {}
             * else
             * {}
             */
            if (AgSys.Agents.Count < 600)
            {
                AgSys.Update();
            }
            else
            {
                switch (mode)
                {
                case 0:
                    AgSys.UpdateParallel();
                    break;

                case 1:
                    AgSys.UpdateRTree();
                    break;
                }
            }

            Component.ExpireSolution(true);
        }

        AgSys.GetPtsVecs(out ptsOut, out vecOut);
        Ap = ptsOut;
        Av = vecOut;

        // </Custom code>
    }
    /// <summary>
    /// This procedure contains the user code. Input parameters are provided as regular arguments,
    /// Output parameters as ref arguments. You don't have to assign output parameters,
    /// they will have a default value.
    /// </summary>
    private void RunScript(bool reset, bool go, List <Point3d> P, List <Vector3d> V, double nR, double coS, double alS, double seS, double seR, ref object Ap, ref object Av, ref object At)
    {
        // <Custom code>

        #region initialization
        // initialization
        if (reset || AgSys == null)
        {
            AgSys = new AgentSystem(P, V);
        }
        #endregion

        // update
        if (go)
        {
            // parameters update
            AgSys.NeighborhoodRadius = nR;
            AgSys.CohesionStrength   = coS;
            AgSys.AlignmentStrength  = alS;
            AgSys.SeparationStrength = seS;
            AgSys.SeparationRadius   = seR;


            // system update
            //AgSys.Update();
            AgSys.UpdateRTree();
            // update solution
            Component.ExpireSolution(true);
        }

        // output
        GH_Point[]  ptOut;
        GH_Vector[] velOut;


        AgSys.GetPtsVecs(out ptOut, out velOut);

        Ap = ptOut;
        Av = velOut;
        At = AgSys.GetAgentsTrails();


        // </Custom code>
    }