Beispiel #1
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);
                }
            }
        }
        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);
                }
            }
        }
        public override Value Evaluate(FSharpList <Value> args)
        {
            var particleSystem = (ParticleSystem)((Value.Container)args[0]).Item;

            var result = FSharpList <Value> .Empty;

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

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

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

            return(Value.NewList(result));
        }