Ejemplo n.º 1
0
    internal MechanismBase[] GetMechanismsForBody(RigidBodyBase body)
    {
        ArrayList list = new ArrayList();

        foreach (MechanismBase mech in Mechanisms)
        {
            BindingMechanismBase bmech = mech as BindingMechanismBase;
            ForceMechanismBase   fmech = mech as ForceMechanismBase;

            if (bmech != null)
            {
                if (bmech.EndpointA.strokeref == body.strokeid ||
                    bmech.EndpointB.strokeref == body.strokeid)
                {
                    list.Add(bmech);
                }
            }
            else if (fmech != null)
            {
                if (fmech.Body.strokeref == body.strokeid)
                {
                    list.Add(fmech);
                }
            }
        }
        return(list.ToArray(typeof(MechanismBase)) as MechanismBase[]);
    }
Ejemplo n.º 2
0
        static bool CompareDocuments(MagicDocument a, MagicDocument b)
        {
            if (a.version != b.version)
            {
                return(false);
            }
            if (a.Bodies.Count != b.Bodies.Count)
            {
                return(false);
            }
            if (a.Mechanisms.Count != b.Mechanisms.Count)
            {
                return(false);
            }
            if (a.xml_Ink != b.xml_Ink)
            {
                return(false);
            }

            for (int i = 0; i < a.Bodies.Count; ++i)
            {
                RigidBodyBase a1 = ((RigidBodyBase)a.Bodies[i]);
                RigidBodyBase b1 = ((RigidBodyBase)b.Bodies[i]);
                if (a1.GetType() != b1.GetType())
                {
                    return(false);
                }
                if (a1.strokeid != b1.strokeid)
                {
                    return(false);
                }
                if (a1.anchored != b1.anchored)
                {
                    return(false);
                }
                if (a1.cfriction != b1.cfriction)
                {
                    return(false);
                }
                if (a1.density != b1.density)
                {
                    return(false);
                }
            }

            for (int i = 0; i < a.Mechanisms.Count; ++i)
            {
                MechanismBase a1 = ((MechanismBase)a.Mechanisms[i]);
                MechanismBase b1 = ((MechanismBase)b.Mechanisms[i]);
                if (a1.GetType() != b1.GetType())
                {
                    return(false);
                }
                if (a1 is ForceMechanismBase)
                {
                    ForceMechanismBase a2 = (ForceMechanismBase)a1;
                    ForceMechanismBase b2 = (ForceMechanismBase)b1;
                    if (a2.Body.strokeref != b2.Body.strokeref)
                    {
                        return(false);
                    }
                    if (a2.Body.attachloc != b2.Body.attachloc)
                    {
                        return(false);
                    }
                    if (a2.vector != b2.vector)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }