当前位置: 首页>>代码示例>>C++>>正文


C++ Formula::top方法代码示例

本文整理汇总了C++中Formula::top方法的典型用法代码示例。如果您正苦于以下问题:C++ Formula::top方法的具体用法?C++ Formula::top怎么用?C++ Formula::top使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Formula的用法示例。


在下文中一共展示了Formula::top方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: findSubformulaeSymbols

void IteratorOpParser::findSubformulaeSymbols(vector<Formula*>& mainSymbols, vector<Formula*>& otherSymbols, unsigned int currentMainIndex,
        vector<Formula*>& underscriptSymbols, vector<Formula*>& overscriptSymbols, long currentRightLimit, long currentLeftLimit) {
    unsigned int& k = currentMainIndex;
    Formula* currentMainSymbol = mainSymbols.at(k);

    if (underscriptSymbols.empty() && overscriptSymbols.empty()) {
        // caso in cui non ci sono underscript e overscript ma (forse) apici e pedici

        long currentMainMidline = currentMainSymbol->center().getY();

        unsigned int j = 0;
        bool beforeCurrentRightLimit = true;
        while (j < otherSymbols.size() && beforeCurrentRightLimit) {
            if (otherSymbols.at(j)->left() >= currentRightLimit) {
                beforeCurrentRightLimit = false;
            } else {
                Formula* oth = otherSymbols.at(j);

                bool crossedByMidline = oth->top() < currentMainMidline && currentMainMidline < oth->bottom();
                if (crossedByMidline) {
                    mainSymbols.insert(mainSymbols.begin() + k + 1, oth);
                    otherSymbols.erase(otherSymbols.begin() + j);
                    currentRightLimit = oth->left();
                }

                j++;
            }
        }

        currentLeftLimit = currentMainSymbol->right();
        underscriptSymbols = FormulaParserUtils::extractSymbolsWithinRange(otherSymbols, currentRightLimit, currentLeftLimit, maxBottomLimit,
                currentMainMidline, true);
        overscriptSymbols = FormulaParserUtils::extractSymbolsWithinRange(otherSymbols, currentRightLimit, currentLeftLimit, currentMainMidline, maxTopLimit,
                true);
    } else {
        // l'underscript e l'overscript, che al momento contengono solo simboli allineati verticalmente col main, vengono estesi

        underscriptSymbols = FormulaParserUtils::extractSymbolsWithinRange(otherSymbols, currentRightLimit, currentLeftLimit, maxBottomLimit,
                currentMainSymbol->bottom() + 1, true);
        overscriptSymbols = FormulaParserUtils::extractSymbolsWithinRange(otherSymbols, currentRightLimit, currentLeftLimit, currentMainSymbol->top() - 1,
                maxTopLimit, true);
    }
}
开发者ID:GiulioGx,项目名称:Marinajo,代码行数:43,代码来源:IteratorOpParser.cpp

示例2: findIteratorOpSymbolIndexes

vector<Formula*>& IteratorOpParser::_parse(vector<Formula*>& formulaToParse) {
    vector<Formula*> mainSymbols, otherSymbols;
    vector<Formula*>& result = *(new vector<Formula*>());

    findMainSymbols(formulaToParse, mainSymbols, otherSymbols, false);

    vector<unsigned int> iteratorOpSymbolIndexes = findIteratorOpSymbolIndexes(mainSymbols);

    unsigned int i = 0;
    for (unsigned int k = 0; k < mainSymbols.size(); k++) {
        Formula* currentMainSymbol = mainSymbols.at(k);

        if (i < iteratorOpSymbolIndexes.size() && iteratorOpSymbolIndexes.at(i) == k) {
            long currentLeftLimit, currentRightLimit;
            computeLimits(mainSymbols, iteratorOpSymbolIndexes, k, i, &currentRightLimit, &currentLeftLimit);

            vector<Formula*>& underscriptSymbols = FormulaParserUtils::extractSymbolsWithinRange(otherSymbols, currentMainSymbol->right(),
                    currentMainSymbol->left(), maxBottomLimit, currentMainSymbol->bottom() + 1, false);
            vector<Formula*>& overscriptSymbols = FormulaParserUtils::extractSymbolsWithinRange(otherSymbols, currentMainSymbol->right(),
                    currentMainSymbol->left(), currentMainSymbol->top(), maxTopLimit, false);
            findSubformulaeSymbols(mainSymbols, otherSymbols, k, underscriptSymbols, overscriptSymbols, currentRightLimit, currentLeftLimit);

            Parser parser;
            Formula* underscript = parser.parse(underscriptSymbols);
            Formula* overscript = parser.parse(overscriptSymbols);

            Formula* newIteratorOp = new IteratorOp(currentMainSymbol, underscript, overscript);
            result.push_back(newIteratorOp);
            i++;
        } else {
            result.push_back(mainSymbols.at(k));
        }
    }

    result.insert(result.end(), otherSymbols.begin(), otherSymbols.end());
    sort(result.begin(), result.end(), Formula::BarHorizontalComparator());

    return result;
}
开发者ID:GiulioGx,项目名称:Marinajo,代码行数:39,代码来源:IteratorOpParser.cpp

示例3: findSubSup

void SubSupParser::findSubSup(Formula** subformulaToSet, Formula* currentOther, vector<Formula*>& allSymbols, vector<Formula*>& mainSymbols,
        vector<Formula*>& otherSymbols, unsigned int currentMainIndex, bool sup_notSub) {
    using namespace FormulaParserUtils;

    unsigned int& i = currentMainIndex;

    Formula* currentMain = mainSymbols.at(currentMainIndex);
    long mainVBar = currentMain->center().getY();
    int currentLeftLimit = currentMain->left();
    int currentRightLimit = (i == mainSymbols.size() - 1) ? maxRightLimit : mainSymbols.at(i + 1)->left() - 1;

    bool subformulaCondition;
    long subsup_bottomLimit, subsup_topLimit, context_bottomLimit, context_topLimit;

    if (sup_notSub) { //apice
        bool higherTop = currentOther->top() + currentOther->height() * SUP_MIN_FRACTION_ABOVE_MAIN < currentMain->top();
        bool higherBar = getWeightedVBar(currentOther) < getWeightedVBar(currentMain) && currentOther->area() <= currentMain->area() * LOW_SUP_MAX_AREA;
        subformulaCondition = higherTop || higherBar;
//		/* un apice deve:
//		 * - avere un bordo superiore "sufficientemente" più in alto del mainSymbol corrente, OPPURE
//		 * - avere un baricentro più alto ed essere "sufficientemente" più piccolo del simbolo principale
//		 * */

        subsup_bottomLimit = mainVBar;
        subsup_topLimit = maxTopLimit;
        context_bottomLimit = maxBottomLimit;
        context_topLimit = mainVBar;
    } else { //pedice
        subformulaCondition = (currentOther->bottom() - currentOther->height() * SUB_MIN_FRACTION_BELOW_MAIN) > currentMain->bottom();
//		// un pedice deve trovarsi "sufficientemente" più in basso del mainSymbol corrente


        subsup_bottomLimit = maxBottomLimit;
        subsup_topLimit = mainVBar;
        context_bottomLimit = mainVBar;
        context_topLimit = maxTopLimit;
    }

    if (!subformulaCondition) {
        /* Non vengono rispettate le condizioni date: l'apice/pedice è stato mal classificato. Viene allora aggiunto ai simboli principali ed eliminato
         * da quelli secondari.
         */

        mainSymbols.insert(mainSymbols.begin() + i + 1, currentOther);
        otherSymbols.erase(otherSymbols.begin());

    } else {
        otherSymbols.erase(otherSymbols.begin());

        vector<Formula*> subsup = extractSymbolsInRange(otherSymbols, currentRightLimit, currentLeftLimit, subsup_bottomLimit, subsup_topLimit);
        subsup.insert(subsup.begin(), currentOther);

        /* Viene passato allSymbols e non otherSymbols perché gli elementi di otherSymbols vengono cancellati una volta classificati (quindi se classifico,
         * ad esempio, un pedice poi quei simboli non saranno più in otherSymbols e non verrebbero più trovati dalla funzione di estrazione, che quindi non
         * fornirebbe il contesto appropriato)
         */
        vector<Formula*> context = extractSymbolsInRange(allSymbols, currentRightLimit, currentLeftLimit, context_bottomLimit, context_topLimit, false);
        fixBadClassification(mainSymbols, otherSymbols, subsup, context, i);

        *subformulaToSet = _parse(subsup, allSymbols);
    }
}
开发者ID:GiulioGx,项目名称:Marinajo,代码行数:62,代码来源:SubSupParser.cpp


注:本文中的Formula::top方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。