예제 #1
0
void SegmentFactory::finishRun(bool *lastBool,
                               bool *nextBool,
                               SegmentVector &lastSegment,
                               SegmentVector &currSegment,
                               int x,
                               int yStart,
                               int yStop,
                               int height,
                               const DocumentModelSegments &modelSegments,
                               int* madeLines)
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "SegmentFactory::finishRun"
                               << " column=" << x
                               << " rows=" << yStart << "-" << yStop
                               << " runsOnLeft=" << adjacentRuns (nextBool, yStart, yStop, height)
                               << " runsOnRight=" << adjacentSegments (lastSegment, yStart, yStop, height);

  // When looking at adjacent columns, include pixels that touch diagonally since
  // those may also diagonally touch nearby runs in the same column (which would indicate
  // a branch)

  // Count runs that touch on the left
  if (adjacentRuns(lastBool, yStart, yStop, height) > 1) {
    return;
  }

  // Count runs that touch on the right
  if (adjacentRuns(nextBool, yStart, yStop, height) > 1) {
    return;
  }

  Segment *seg;
  if (adjacentSegments(lastSegment, yStart, yStop, height) == 0) {

    // This is the start of a new segment
    seg = new Segment(m_scene,
                      (int) (0.5 + (yStart + yStop) / 2.0),
                      m_isGnuplot);
    ENGAUGE_CHECK_PTR (seg);

  } else {

    // This is the continuation of an existing segment
    seg = adjacentSegment(lastSegment, yStart, yStop, height);

    ++(*madeLines);
    ENGAUGE_CHECK_PTR(seg);
    seg->appendColumn(x, (int) (0.5 + (yStart + yStop) / 2.0), modelSegments);
  }

  for (int y = yStart; y <= yStop; y++) {

    ENGAUGE_ASSERT (y < height);
    currSegment [y] = seg;
  }
}
예제 #2
0
void Segments::finishRun(bool* lastBool, bool* nextBool,
                         Segment** lastSegment, Segment** currSegment,
                         int x, int yStart, int yStop, int height, SegmentSettings set, int* madeLines)
{
    // when looking at adjacent columns, include pixels that touch diagonally since
    // those may also diagonally touch nearby runs in the same column (which would indicate
    // a branch)
    DigitDebug::scanning(QString("column ") + QString::number(x) +
                         QString(", rows ") + QString::number(yStart) + QString(" to ") + QString::number(yStop) +
                         QString(", runs on left ") + QString::number(adjacentRuns(nextBool, yStart, yStop, height)) +
                         QString(", runs on right ") + QString::number(adjacentSegments(lastSegment, yStart, yStop, height)));

    // count runs that touch on the left
    if (adjacentRuns(lastBool, yStart, yStop, height) > 1)
        return;
    // count runs that touch on the right
    if (adjacentRuns(nextBool, yStart, yStop, height) > 1)
        return;

    Segment* seg;
    if (adjacentSegments(lastSegment, yStart, yStop, height) == 0)
    {
        // this is the start of a new segment
        seg = new Segment(canvas, (int) (0.5 + (yStart + yStop) / 2.0));
        CHECK_PTR_ENGAUGE(seg);

        segments.append(seg);
    }
    else
    {
        // this is the continuation of an existing segment
        seg = adjacentSegment(lastSegment, yStart, yStop, height);

        ++(*madeLines);
        ASSERT_ENGAUGE(seg != 0);
        seg->appendColumn(x, (int) (0.5 + (yStart + yStop) / 2.0), set);
    }

    for (int y = yStart; y <= yStop; y++)
        currSegment [y] = seg;
}