Пример #1
0
        public override Value Evaluate(FSharpList <Value> args)
        {
            ParticleSystem particleSystem = (ParticleSystem)((Value.Container)args[0]).Item;

            var result = FSharpList <Value> .Empty;

            ParticleSpring s;
            Particle       springEnd1;
            Particle       springEnd2;
            XYZ            springXYZ1;
            XYZ            springXYZ2;
            Line           springLine;

            //create a geometry curve from each spring
            for (int i = 0; i < particleSystem.numberOfSprings(); i++)
            {
                s          = particleSystem.getSpring(i);
                springEnd1 = s.getOneEnd();
                springEnd2 = s.getTheOtherEnd();

                springXYZ1 = springEnd1.getPosition();
                springXYZ2 = springEnd2.getPosition();
                springLine = dynRevitSettings.Doc.Application.Application.Create.NewLineBound(springXYZ1, springXYZ2);

                result = FSharpList <Value> .Cons(Value.NewContainer(springLine), result);
            }

            return(Value.NewList(result));
        }
Пример #2
0
        public void Draw()
        {
            if (RenderDescription == null)
            {
                RenderDescription = new RenderDescription();
            }

            if (ParticleSystem == null)
            {
                return;
            }

            for (int i = 0; i < ParticleSystem.numberOfParticles(); i++)
            {
                Particle p   = ParticleSystem.getParticle(i);
                XYZ      pos = p.getPosition();
                if (i < RenderDescription.points.Count())
                {
                    RenderDescription.points[i] = new Point3D(pos.X, pos.Y, pos.Z);
                }
                else
                {
                    var pt = new Point3D(pos.X, pos.Y, pos.Z);
                    RenderDescription.points.Add(pt);
                }
            }

            for (int i = 0; i < ParticleSystem.numberOfSprings(); i++)
            {
                ParticleSpring ps   = ParticleSystem.getSpring(i);
                XYZ            pos1 = ps.getOneEnd().getPosition();
                XYZ            pos2 = ps.getTheOtherEnd().getPosition();

                if (i * 2 + 1 < RenderDescription.lines.Count())
                {
                    RenderDescription.lines[i * 2]     = new Point3D(pos1.X, pos1.Y, pos1.Z);
                    RenderDescription.lines[i * 2 + 1] = new Point3D(pos2.X, pos2.Y, pos2.Z);
                }
                else
                {
                    var pt1 = new Point3D(pos1.X, pos1.Y, pos1.Z);
                    var pt2 = new Point3D(pos2.X, pos2.Y, pos2.Z);

                    RenderDescription.lines.Add(pt1);
                    RenderDescription.lines.Add(pt2);
                }
            }
        }
Пример #3
0
        public void Draw()
        {
            if (this.RenderDescription == null)
            {
                this.RenderDescription = new Nodes.RenderDescription();
            }

            if (particleSystem == null)
            {
                return;
            }

            for (int i = 0; i < particleSystem.numberOfParticles(); i++)
            {
                Particle p   = particleSystem.getParticle(i);
                XYZ      pos = p.getPosition();
                if (i < this.RenderDescription.points.Count())
                {
                    this.RenderDescription.points[i] = new Point3D(pos.X, pos.Y, pos.Z);
                }
                else
                {
                    Point3D pt = new System.Windows.Media.Media3D.Point3D(pos.X, pos.Y, pos.Z);
                    this.RenderDescription.points.Add(pt);
                }
            }

            for (int i = 0; i < particleSystem.numberOfSprings(); i++)
            {
                ParticleSpring ps   = particleSystem.getSpring(i);
                XYZ            pos1 = ps.getOneEnd().getPosition();
                XYZ            pos2 = ps.getTheOtherEnd().getPosition();

                if (i * 2 + 1 < this.RenderDescription.lines.Count())
                {
                    this.RenderDescription.lines[i * 2]     = new Point3D(pos1.X, pos1.Y, pos1.Z);
                    this.RenderDescription.lines[i * 2 + 1] = new Point3D(pos2.X, pos2.Y, pos2.Z);
                }
                else
                {
                    Point3D pt1 = new System.Windows.Media.Media3D.Point3D(pos1.X, pos1.Y, pos1.Z);
                    Point3D pt2 = new System.Windows.Media.Media3D.Point3D(pos2.X, pos2.Y, pos2.Z);

                    this.RenderDescription.lines.Add(pt1);
                    this.RenderDescription.lines.Add(pt2);
                }
            }
        }
Пример #4
0
 private void UpdateSystem()
 {
     //update the spring values
     for (int j = 0; j < ParticleSystem.numberOfSprings(); j++)
     {
         ParticleSpring spring = ParticleSystem.getSpring(j);
         spring.setDamping(_d);
         if (!_useRl)
         {
             spring.setRestLength(_r);
         }
         spring.setSpringConstant(_s);
     }
     for (int j = 0; j < ParticleSystem.numberOfParticles(); j++)
     {
         Particle p = ParticleSystem.getParticle(j);
         p.setMass(_m);
     }
 }