示例#1
0
 public void ImportRelatedForm(RelatedForm rForm)
 {
     if (rForm == null)
     {
         return;
     }
     Clear();
     for (var i = 0; i < rForm.particles.Count; ++i)
     {
         var pi = rForm.particles[i];
         var p  = MakeParticle(pi.pos);
         p.OverrideUID(pi.uid);
     }
     for (var i = 0; i < rForm.springs.Count; ++i)
     {
         var si = rForm.springs[i];
         var s  = MakeSpringByUID(si.a, si.b, si.stiffness);
         s.OverrideUID(si.uid);
     }
     for (var i = 0; i < rForm.angles.Count; ++i)
     {
         var ai = rForm.angles[i];
         var s  = MakeAngleByUID(ai.a, ai.b, ai.m, ai.stiffness);
         s.OverrideUID(ai.uid);
     }
     for (var i = 0; i < rForm.pins.Count; ++i)
     {
         var pi = rForm.pins[i];
         var p  = MakePinByUID(pi.a, pi.pos);
         p.OverrideUID(pi.uid);
     }
 }
示例#2
0
        public RelatedForm ExportRelatedForm()
        {
            var rForm = new RelatedForm();

            rForm.counter = _uidDistributer.current;
            for (var i = 0; i < numOfParticles; ++i)
            {
                var p = GetParticleAt(i);
                rForm.particles.Add(new RelatedForm.ParticleInfo(p.pos, p.uid));
            }
            for (var i = 0; i < numOfSprings; ++i)
            {
                var s = GetSpringAt(i);
                rForm.springs.Add(new RelatedForm.SpringInfo(s.uid, s.a.uid, s.b.uid, s.stiffness));
            }
            for (var i = 0; i < numOfAngles; ++i)
            {
                var a = GetAngleAt(i);
                rForm.angles.Add(new RelatedForm.AngleInfo(a.uid, a.a.uid, a.b.uid, a.m.uid, a.stiffness));
            }
            for (var i = 0; i < numOfPins; ++i)
            {
                var p = GetPinAt(i);
                rForm.pins.Add(new RelatedForm.PinInfo(p.uid, p.a.uid, p.pos));
            }

            return(rForm);
        }