//CONSTRUCTOR
        public Design(RadicalComponent component)
        {
            //Access the component
            this.MyComponent = component;

            this.Variables   = new List <IVariable>();
            this.Geometries  = new List <IDesignGeometry>();
            this.Constraints = new List <Constraint>();

            // ADD VARIABLES
            //Sliders
            foreach (IGH_Param param in MyComponent.Params.Input[2].Sources)
            {
                SliderVariable s = new SliderVariable(param);
                if (s.CurrentValue == 0)
                {
                    if (s.Max >= 0.001)
                    {
                        s.UpdateValue(0.001);
                    }
                    else
                    {
                        s.UpdateValue(-0.001);
                    }
                }
                this.Variables.Add(new SliderVariable(param));
            }
            Grasshopper.Instances.ActiveCanvas.Document.NewSolution(false, Grasshopper.Kernel.GH_SolutionMode.Silent);

            //Surfaces
            for (int i = 0; i < MyComponent.Params.Input[3].Sources.Count; i++)
            {
                IGH_Param    param = MyComponent.Params.Input[3].Sources[i];
                NurbsSurface surf  = MyComponent.SrfVariables[i];
                Geometries.Add(new DesignSurface(param, surf));
            }
            //Curves
            for (int i = 0; i < MyComponent.Params.Input[4].Sources.Count; i++)
            {
                IGH_Param  param = MyComponent.Params.Input[4].Sources[i];
                NurbsCurve curv  = MyComponent.CrvVariables[i];
                this.Geometries.Add(new DesignCurve(param, curv));
            }

            // Add geometries to variables list
            // not the cleanest way to do it, review code structure
            if (Geometries.Any())
            {
                this.Variables.AddRange(Geometries.Select(x => x.Variables).SelectMany(x => x).ToList());
            }

            // ADD CONSTRAINTS
            for (int i = 0; i < component.Constraints.Count; i++)
            {
                this.Constraints.Add(new Constraint(MyComponent, Constraint.ConstraintType.morethan, i));
            }

            MyComponent.numVars = this.Variables.Where(var => var.IsActive).Count();
        }
Beispiel #2
0
 public bool HasAnyPoint()
 {
     if (Points != null)
     {
         return(Points.Length > 0);
     }
     else if (Geometries != null)
     {
         return(Geometries.Any(g => g.HasAnyPoint()));
     }
     else
     {
         return(false);
     }
 }