Ejemplo n.º 1
0
        public override bool CastTo <Q>(ref Q target)
        {
            if (typeof(Q).IsAssignableFrom(typeof(int)))
            {
                object _Index = this.Value.Index;
                target = (Q)_Index;
                return(true);
            }

            if (typeof(Q).IsAssignableFrom(typeof(GH_Integer)))
            {
                object _Index = new GH_Integer(this.Value.Index);
                target = (Q)_Index;
                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(Guid)))
            {
                object _Id = this.Value.Id;
                target = (Q)_Id;
                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(GH_Guid)))
            {
                object _Id = new GH_Guid(this.Value.Id);
                target = (Q)_Id;
                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(GH_String)))
            {
                object _Path = new GH_String(this.Value.FullPath);
                target = (Q)_Path;
                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(string)))
            {
                object _Path = this.Value.FullPath;
                target = (Q)_Path;
                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(Layer)))
            {
                LayerTable LT     = Rhino.RhinoDoc.ActiveDoc.Layers;
                object     _layer = LT.FindIndex(this.Value.Index);
                target = (Q)_layer;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the GH_Structure component out values ready to go
        /// </summary>
        /// <param name="pop"></param>
        /// <param name="BioBranches"></param>
        /// <param name="performanceCount"></param>
        /// <param name="bioBranchID"></param>
        public void SetComponentOut(Population pop, List <BioBranch> BioBranches, int performanceCount, int bioBranchID)
        {
            popCount = pop.chromosomes.Length;

            // Historic pop
            historicNumbers = new GH_Structure <GH_Number>();

            for (int i = 0; i < BioBranches.Count; i++)
            {
                for (int j = 0; j < BioBranches[i].PopTwigs.Count; j++)
                {
                    for (int k = 0; k < BioBranches[i].PopTwigs[j].chromosomes.Length; k++)
                    {
                        List <GH_Number> myList = new List <GH_Number>();
                        for (int c = 0; c < pop.chromosomes[k].GetGenes().Length; c++)
                        {
                            GH_Number myGHNumber = new GH_Number(BioBranches[i].PopTwigs[j].chromosomes[k].GetGenes()[c]);
                            myList.Add(myGHNumber);
                        }

                        GH_Path myPath = new GH_Path(i, j, k);
                        historicNumbers.AppendRange(myList, myPath);
                    }
                }
            }

            // Find the current number of population twigs in the latest biobranch
            int lastBranchTwigCount = BioBranches[bioBranchID].PopTwigs.Count;

            // Now add the current population to the output, using the latest biobranch ID.
            // This is going to be really hard to understand in a month's time.
            for (int k = 0; k < pop.chromosomes.Length; k++)
            {
                List <GH_Number> myList = new List <GH_Number>();
                for (int c = 0; c < pop.chromosomes[k].GetGenes().Length; c++)
                {
                    GH_Number myGHNumber = new GH_Number(pop.chromosomes[k].GetGenes()[c]);
                    myList.Add(myGHNumber);
                }

                GH_Path myPath = new GH_Path(bioBranchID, lastBranchTwigCount, k);
                historicNumbers.AppendRange(myList, myPath);
            }

            // Get the Guids for the sliders and genepools to pass on
            genoGuids = new GH_Structure <GH_Guid>();

            List <GH_Guid> mySliderList   = new List <GH_Guid>();
            List <GH_Guid> myGenepoolList = new List <GH_Guid>();

            // Add the sliders
            for (int i = 0; i < cSliders.Count; i++)
            {
                GH_Guid myGuid = new GH_Guid(cSliders[i].InstanceGuid);
                mySliderList.Add(myGuid);
            }

            // Add the genepools
            for (int i = 0; i < cGenePools.Count; i++)
            {
                GH_Guid myGuid = new GH_Guid(cGenePools[i].InstanceGuid);
                myGenepoolList.Add(myGuid);
            }

            // Add to the GH_Structure
            genoGuids.AppendRange(mySliderList, new GH_Path(0));
            genoGuids.AppendRange(myGenepoolList, new GH_Path(1));


            this.ExpireSolution(true);
        }
Ejemplo n.º 3
0
        /*******************************************/

        public static bool CastToGoo(object value, ref GH_Guid target)
        {
            return(GH_Convert.ToGHGuid(value, GH_Conversion.Both, ref target));
        }