/// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var divisions = new List <int>();
            var domains   = new List <GH_Interval>();

            //get Data
            DA.GetDataList(0, divisions);
            DA.GetDataList(1, domains);

            foreach (var item in domains)
            {
                if (item.Value.Min < 0 || item.Value.Max == 0)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Domain should within or equal (min:0 TO max:total)");
                    return;
                }
            }

            foreach (var item in divisions)
            {
                if (item < 0)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Divisions should be larger or equal 0");
                    return;
                }
            }

            if (RuntimeMessageLevel != GH_RuntimeMessageLevel.Error)
            {
                var selections = new IteratorSelection(divisions, domains);

                //set Data
                DA.SetData(0, selections);
            }
        }
예제 #2
0
        private void checkSelections(IteratorSelection Selections, List <ColibriParam> ColibriParam, long totalCount)
        {
            var takeNumbers = new List <int>();
            var userDomains = new List <GH_Interval>();


            if (Selections.IsDefinedInSel)
            {
                takeNumbers = Selections.UserTakes;
                userDomains = Selections.UserDomains;
                //check take numbers for each parameters
                if (takeNumbers.Any() && takeNumbers.Count != ColibriParam.Count)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "The number of connected sliders must be equal to the number of items in the Steps input list.\n But Colibri will run without Division settings.");
                }


                //Check domains if any of their max is out of range (the min is checked in Selection component)
                if (userDomains.Any())
                {
                    foreach (var item in userDomains)
                    {
                        if (item.Value.Max > totalCount - 1)
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Domains' max number should be smaller than the total number " + totalCount + ".\n Colibri has fixed it for you.");
                        }
                    }
                }
            }
        }
예제 #3
0
        private string updateComponentMsg(List <ColibriParam> ColibriParams, IteratorSelection Selections)
        {
            if (ColibriParams.IsNullOrEmpty())
            {
                return(null);
            }

            //this will check and add take_numbers and domains
            Selections.MatchSelectionFrom(ColibriParams);
            this._totalCount    = Selections.TotalCounts;
            this._selectedCount = Selections.SelectedCounts;
            string messages = "";

            //Check selections
            checkSelections(Selections, ColibriParams, _totalCount);

            messages = "ITERATION NUMBER \nTotal: " + _totalCount;

            if (Selections.IsDefinedInSel)
            {
                messages += "\nSelected: " + _selectedCount;
                messages += "\n";
                messages += Selections.ToString(true);
            }


            return(messages);
        }
예제 #4
0
        private List <List <int> > selectedIterations(IteratorSelection Selections, List <List <int> > allIterations)
        {
            int  count         = 0;
            bool ifInSelection = true;
            var  selectedIterationPositions = new List <List <int> >();

            foreach (var item in allIterations)
            {
                ifInSelection = ifInSelectionDomains(Selections, count);
                if (ifInSelection)
                {
                    selectedIterationPositions.Add(allIterations[count]);
                }
                count++;
            }

            return(selectedIterationPositions);
        }
예제 #5
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var  userSelections = new IteratorSelection();
            bool remoteFly      = false;
            int  selectionIndex = this.Params.IndexOfInputParam(this._selectionName);

            DA.GetData(selectionIndex, ref userSelections);

            if (this._remoteFly)
            {
                DA.GetData(selectionIndex + 1, ref remoteFly);

                //set remoteCtrl
                DA.SetData(selectionIndex + 1, _running);
            }



            var FlyID = new List <object>();

            //flyParam only exists when flying
            if (!_running && _flyParam == null)
            {
                _filteredSources = gatherSources();
                checkAllInputParamNames(_filteredSources);

                this._selections = new IteratorSelection(userSelections.UserTakes, userSelections.UserDomains);
                this.Message     = updateComponentMsg(_filteredSources, this._selections);

                if (remoteFly)
                {
                    this.OnMouseDownEvent(this);
                }
            }

            //Get current value
            foreach (var item in _filteredSources)
            {
                DA.SetData(item.AtIteratorPosition, item.CurrentValue());
                FlyID.Add(item.ToString(true));
            }

            DA.SetDataList(selectionIndex, FlyID);
        }
예제 #6
0
        public IteratorFlyParam(List <ColibriParam> sourceParams, IteratorSelection selections, string studyFolder, OverrideMode overrideFolderMode)
        {
            this._inputParams        = sourceParams;
            this._selections         = selections == null? new IteratorSelection(): selections;
            this._overrideFolderMode = overrideFolderMode;
            //this._studyFoler = studyFolder;

            this._totalCounts           = ColibriBase.CalTotalCounts(this._inputParams);
            this._selectedCounts        = _selections.SelectedCounts > 0 ? _selections.SelectedCounts : _totalCounts;
            this._allPositions          = ColibriBase.AllParamsPositions(this._inputParams);
            this._allSelectedPositions  = _selections.ParamsSelectedPositions == null? this._allPositions : _selections.ParamsSelectedPositions;
            this._currentPositionsIndex = Enumerable.Repeat(0, _inputParams.Count()).ToList();
            Count = 0;

            createWatchFile(studyFolder);

            //get studied Fly ID from folder
            if (this._overrideFolderMode == OverrideMode.FinishTheRest)
            {
                this._studiedFlyID = getStudiedFlyID(studyFolder);
            }
        }
예제 #7
0
        private bool ifInSelectionDomains(IteratorSelection Selections, int CurrentCount)
        {
            //Selections undefined, so all is in seleciton
            if (!Selections.IsDefinedInSel)
            {
                return(true);
            }

            var  currentCount   = (double)CurrentCount;
            bool isInSelection  = true;
            int  includedCounts = 0;

            if (Selections.Domains.Any())
            {
                foreach (var domain in Selections.Domains)
                {
                    includedCounts += domain.Value.IncludesParameter(currentCount) == true ? 1 : 0;
                }
            }

            isInSelection = includedCounts == 0 ? false : true;
            return(isInSelection);
        }