void StemDetection::findStems()
{
	cerr << "...Finding stems..." << endl;
	int nRows = vBoard.size(), nCols = vBoard[0].size();
	for (int j = 0; j < nCols; j++)
	{
		for (int i = 0, len = 0, start = 0; i <= nRows; i++)
		{
			if (i == nRows || vBoard[i][j] == WHITE)
			{
				if (len >= 2 * staffSpaceHeight)
				{
					Stem stem;
					for (int k = start; k < i; k++)
						stem.AddPixel(Point2i(k, j));
					if (isStem(stem))
						stems.push_back(stem);
				}
				len = 0;
				start = i + 1;
				continue;
			}
			else
				len++;
		}
	}
	mergeStems();
	filterStems();
}
Пример #2
0
/**
 * Resolve the "stem.[a,b,c]=" to the equivalent stem.a.b.c= form,
 * with all of the indices taken as constants
 *
 * @param tailElements
 *                 The array of arguments.  the first argument is the
 *                 assigned value.  All additional arguments are the
 *                 tail pieces.
 * @param argCount The count of arguments.
 *
 * @return Returns nothing.
 */
RexxObject *StemClass::bracketEqual(RexxObject **tailElements, size_t argCount)
{

    // no value to set?  This is an error
    if (argCount == 0)
    {
        reportException(Error_Incorrect_method_noarg, IntegerOne);
    }
    RexxObject *newValue = requiredArgument(tailElements[0], ARG_ONE);

    // if the argument count is 1, we're just setting the default value
    if (argCount == 1)
    {
        // stem value as default?  don't allow this as it leads to recursion loops
        if (isStem(newValue))
        {
            reportException(Error_Execution_nostem);
        }

        setField(value, newValue);
        // this clears out all of our elements and gets marked as having an
        // explicit value.
        tails.clear();
        dropped = false;
        return OREF_NULL;
    }

    // create a searchable tail from the array elements
    // and set the variable value
    CompoundVariableTail resolved_tail((RexxInternalObject **)(tailElements + 1), argCount - 1);
    CompoundTableElement *variable = getCompoundVariable(resolved_tail);
    variable->set(newValue);
    return OREF_NULL;
}
Пример #3
0
/**
 * Forward all request requests to the target value.  We
 * handle some of these directly, the rest are passed on
 * to the default value.
 *
 * @param makeclass The name of the class for the request.
 *
 * @return The appropriate result for the request.
 */
RexxObject *StemClass::request(RexxString *makeclass)
{
    ProtectedObject result;
    makeclass = stringArgument(makeclass, ARG_ONE)->upper();
    // take care of any ARRAY requests, the rest go to the default value
    if (makeclass->strCompare("ARRAY"))
    {
        // if we have a real stem object (not a subclass), handle directly,
        // otherwise send to the subclass.
        if (isStem(this))
        {
            return makeArray();
        }
        else
        {
            sendMessage(GlobalNames::MAKEARRAY, result);
            return result;
        }
    }
    // let the default value handle everything else
    value->sendMessage(GlobalNames::REQUEST, makeclass, result);
    return result;
}