Пример #1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var points          = new List <GH_Point>();
            var vectors         = new List <GH_Vector>();
            var surface         = new GH_Surface();
            var dynamicsWrapped = new List <GH_ObjectWrapper>();

            if (DA.GetDataList(0, points) && points == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid point list. Operation canceled.");
                return;
            }

            if (DA.GetDataList(1, vectors) && vectors == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid vector list. Operation canceled.");
                return;
            }

            // if vec field is empty, create parallel list of 0 vectors
            if (vectors.Count == 0)
            {
                for (int i = 0; i < points.Count; i++)
                {
                    vectors.Add(new GH_Vector());
                }
            }

            if (DA.GetDataList(2, dynamicsWrapped) && dynamicsWrapped == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid dynamics list. Operation canceled.");
                return;
            }

            if (DA.GetData(3, ref surface) && surface == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid surface. Operation canceled.");
                return;
            }

            var dynamics = new List <IDynamic>();

            foreach (var d in dynamicsWrapped)
            {
                dynamics.Add(d.Value as IDynamic);
            }
            Algos.SortDynamicsByPriority(dynamics);

            Algos.ClearDynamics(dynamics);

            foreach (var d in dynamics)
            {
                Algos.ProcessDynamics(d, points, vectors, surface);
            }

            Algos.RealignAccelerationVectors(dynamics, vectors);

            DA.SetDataList(0, points);
            DA.SetDataList(1, vectors);
        }
Пример #2
0
        private void UpdateWithDynamics(List <IDynamic> dynamics, DynamicSettings settings)
        {
            var points  = new List <GH_Point>(particles.Count);
            var vectors = new List <GH_Vector>(particles.Count);

            for (int i = 0; i < particles.Count; i++)
            {
                points.Add(particles[i].Current.Point);
                vectors.Add(new GH_Vector());
            }

            foreach (var d in dynamics)
            {
                // we need a new list of vectors each way through, which we add seperately to an end result
                // otherwise acceleration can apply across dynamics in unintended ways
                var tempVectors = new List <GH_Vector>(particles.Count);
                for (int i = 0; i < particles.Count; i++)
                {
                    tempVectors.Add(new GH_Vector());
                }

                // post processes use the cumulative vector list
                // pre processes use the temporary empty vector list
                if (d.PostProcess)
                {
                    // vectors is modified inline so we don't need to update as below
                    Algos.ProcessDynamics(d, points, vectors, settings.surface);
                }
                else
                {
                    Algos.ProcessDynamics(d, points, tempVectors, settings.surface);

                    for (int i = 0; i < particles.Count; i++)
                    {
                        vectors[i].Value += tempVectors[i].Value;
                    }
                }
            }

            Algos.RealignAccelerationVectors(dynamics, vectors);

            for (int i = 0; i < points.Count; i++)
            {
                points[i].Value += vectors[i].Value;

                // update particles from resultant p/v's above
                particles[i].Current.Point  = points[i];
                particles[i].Current.Vector = vectors[i];
            }
        }
Пример #3
0
        public void Process(List <GH_Point> points, List <GH_Vector> vectors, GH_Surface surface)
        {
            var dynamicsWrapped = Param["D"] as List <GH_ObjectWrapper>;

            var dynamics = new List <IDynamic>();

            foreach (var d in dynamicsWrapped)
            {
                dynamics.Add(d.Value as IDynamic);
            }
            Algos.SortDynamicsByPriority(dynamics);

            foreach (var d in dynamics)
            {
                Algos.ProcessDynamics(d, points, vectors, surface);
            }
        }