コード例 #1
0
        /// <summary>
        /// Creates formula
        /// </summary>
        /// <param name="tree">Operation tree</param>
        /// <param name="level">Formula level</param>
        /// <param name="sizes">Sizes of symbols</param>
        /// <returns>The formula</returns>
        public MathFormula CreateFormula(ObjectFormulaTree tree, byte level, int[] sizes)
        {
            MathFormula form = new MathFormula(level, sizes);

            for (int i = 0; i < 2; i++)
            {
                IFormulaCreatorOperation op = tree[i].Operation as IFormulaCreatorOperation;
                MathFormula f  = op.CreateFormula(tree[i], level, sizes);
                MathFormula fp = null;
                if (op.OperationPriority < OperationPriority)
                {
                    fp = new MathFormula(level, sizes);
                    MathSymbol s = new BracketsSymbol();
                    s.Append(fp);
                    fp.First[0] = f;
                }
                else
                {
                    fp = f;
                }
                form.Add(fp);
                if (i == 0)
                {
                    MathSymbol s = new BinarySymbol(symbol);
                    s.Append(form);
                }
            }
            return(form);
        }
コード例 #2
0
        /// <summary>
        /// Creates formula
        /// </summary>
        /// <param name="operation">Operation of formula creator</param>
        /// <param name="tree">Tree</param>
        /// <param name="level">Level</param>
        /// <param name="sizes">Sizes</param>
        /// <param name="str">Str of binrary</param>
        /// <returns>The formula</returns>
        public static MathFormula CreateFormula(IFormulaCreatorOperation operation, ObjectFormulaTree tree, byte level, int[] sizes, string str)
        {
            MathFormula form = new MathFormula(level, sizes);

            for (int i = 0; i < str.Length + 1; i++)
            {
                IFormulaCreatorOperation op = tree[i].Operation as IFormulaCreatorOperation;
                MathFormula f  = op.CreateFormula(tree[i], level, sizes);
                MathFormula fp = null;
                if (op.OperationPriority < operation.OperationPriority)
                {
                    fp = new MathFormula(level, sizes);
                    MathSymbol s = new BracketsSymbol();
                    s.Append(fp);
                    fp.First[0] = f;
                }
                else
                {
                    fp = f;
                }
                form.Add(fp);
                if (i < str.Length)
                {
                    MathSymbol s = new BinarySymbol(str[i]);
                    s.Append(form);
                }
            }
            return(form);
        }
コード例 #3
0
        /// <summary>
        /// Creates formula
        /// </summary>
        /// <param name="tree">Operation tree</param>
        /// <param name="level">Formula level</param>
        /// <param name="sizes">Sizes of symbols</param>
        /// <returns>The formula</returns>
        public MathFormula CreateFormula(ObjectFormulaTree tree, byte level, int[] sizes)
        {
            MathFormula form            = new MathFormula(level, sizes);
            IFormulaCreatorOperation op = tree[0].Operation as IFormulaCreatorOperation;
            MathFormula f = op.CreateFormula(tree[0], level, sizes);
            MathSymbol  s = new BracketsSymbol();

            s.Append(form);
            form.First[0] = f;
            if (arity > 1)
            {
                IFormulaCreatorOperation opPower = tree[1].Operation as IFormulaCreatorOperation;
                MathFormula p = opPower.CreateFormula(tree[0], level, sizes);
                form.First[1] = p;
            }
            return(form);
        }
コード例 #4
0
        /// <summary>
        /// Creates formula
        /// </summary>
        /// <param name="tree">Operation tree</param>
        /// <param name="level">Formula level</param>
        /// <param name="sizes">Sizes of symbols</param>
        /// <returns>The formula</returns>
        public static MathFormula CreateFormula(ObjectFormulaTree tree, byte level, int[] sizes)
        {
            IFormulaCreatorOperation c = tree.Operation as IFormulaCreatorOperation;

            return(c.CreateFormula(tree, level, sizes));
        }