private void CreateSpringsFromCurves(IEnumerable <Value> curves, IEnumerable <Value> points)
        {
            //create all the fixed points first
            foreach (var pt in points)
            {
                var xyz = (XYZ)((Value.Container)pt).Item;
                ParticleSystem.makeParticle(_m, xyz, true);
            }

            //create all the springs, checking for existing particles
            foreach (var crv in curves)
            {
                var curve = (Curve)((Value.Container)crv).Item;
                XYZ start = curve.get_EndPoint(0);
                XYZ end   = curve.get_EndPoint(1);

                //find an existing particle to use
                Particle a = ParticleSystem.getParticleByXYZ(start);
                Particle b = ParticleSystem.getParticleByXYZ(end);

                //if not, create a particle
                if (a == null)
                {
                    a = ParticleSystem.makeParticle(_m, start, false);
                }
                if (b == null)
                {
                    b = ParticleSystem.makeParticle(_m, end, false);
                }

                if (_useRl)
                {
                    ParticleSystem.makeSpring(a, b, _r, _s, _d);
                }
                else
                {
                    double restLength = start.DistanceTo(end) * _rlf;
                    ParticleSystem.makeSpring(a, b, restLength, _s, _d);
                }
            }
        }
Example #2
0
        private void CreateSpringsFromCurves(IEnumerable <Curve> curves, IEnumerable <XYZ> points)
        {
            //create all the fixed points first
            foreach (var pt in points)
            {
                ParticleSystem.makeParticle(m, pt, true);
            }

            //create all the springs, checking for existing particles
            foreach (var curve in curves)
            {
                XYZ start = curve.get_EndPoint(0);
                XYZ end   = curve.get_EndPoint(1);

                //find an existing particle to use
                Particle a = ParticleSystem.getParticleByXYZ(start);
                Particle b = ParticleSystem.getParticleByXYZ(end);

                //if not, create a particle
                if (a == null)
                {
                    a = ParticleSystem.makeParticle(m, start, false);
                }
                if (b == null)
                {
                    b = ParticleSystem.makeParticle(m, end, false);
                }

                if (useRl)
                {
                    ParticleSystem.makeSpring(a, b, r, s, d);
                }
                else
                {
                    double restLength = start.DistanceTo(end) * rlf;
                    ParticleSystem.makeSpring(a, b, restLength, s, d);
                }
            }
        }