コード例 #1
0
ファイル: split.cpp プロジェクト: vkbrad/AndroidOCR
/**********************************************************************
 * split_outline
 *
 * Split between these two edge points.
 **********************************************************************/
void split_outline(EDGEPT *join_point1, EDGEPT *join_point2) { 
  assert(join_point1 != join_point2);

  EDGEPT* temp2 = join_point2->next;
  EDGEPT* temp1 = join_point1->next;
  /* Create two new points */
  EDGEPT* new_point1 = make_edgept(join_point1->pos.x, join_point1->pos.y,
                                   temp1, join_point2);
  EDGEPT* new_point2 = make_edgept(join_point2->pos.x, join_point2->pos.y,
                                   temp2, join_point1);
  // Join_point1 and 2 are now cross-over points, so they must have NULL
  // src_outlines and give their src_outline information their new
  // replacements.
  new_point1->src_outline = join_point1->src_outline;
  new_point1->start_step = join_point1->start_step;
  new_point1->step_count = join_point1->step_count;
  new_point2->src_outline = join_point2->src_outline;
  new_point2->start_step = join_point2->start_step;
  new_point2->step_count = join_point2->step_count;
  join_point1->src_outline = NULL;
  join_point1->start_step = 0;
  join_point1->step_count = 0;
  join_point2->src_outline = NULL;
  join_point2->start_step = 0;
  join_point2->step_count = 0;
  join_point1->MarkChop();
  join_point2->MarkChop();
}
コード例 #2
0
/**********************************************************************
 * split_outline
 *
 * Split between these two edge points. Apply a split and return a
 * pointer to the other side of the split.
 **********************************************************************/
void split_outline(EDGEPT *join_point1, EDGEPT *join_point2) { 
  EDGEPT *join_point1a;
  EDGEPT *temp2;
  EDGEPT *temp1;

  assert (join_point1 != join_point2);

  temp2 = join_point2->next;
  temp1 = join_point1->next;
  /* Create two new points */
  join_point1a = make_edgept (join_point1->pos.x,
    join_point1->pos.y, temp1, join_point2);

  make_edgept (join_point2->pos.x, join_point2->pos.y, temp2, join_point1);
}
コード例 #3
0
ファイル: split.cpp プロジェクト: selgod/ExpenseReportManager
// Makes a split between these two edge points, but does not affect the
// outlines to which they belong.
void SPLIT::SplitOutline() const {
  EDGEPT* temp2 = point2->next;
  EDGEPT* temp1 = point1->next;
  /* Create two new points */
  EDGEPT* new_point1 = make_edgept(point1->pos.x, point1->pos.y, temp1, point2);
  EDGEPT* new_point2 = make_edgept(point2->pos.x, point2->pos.y, temp2, point1);
  // point1 and 2 are now cross-over points, so they must have NULL
  // src_outlines and give their src_outline information their new
  // replacements.
  new_point1->src_outline = point1->src_outline;
  new_point1->start_step = point1->start_step;
  new_point1->step_count = point1->step_count;
  new_point2->src_outline = point2->src_outline;
  new_point2->start_step = point2->start_step;
  new_point2->step_count = point2->step_count;
  point1->src_outline = NULL;
  point1->start_step = 0;
  point1->step_count = 0;
  point2->src_outline = NULL;
  point2->start_step = 0;
  point2->step_count = 0;
}
コード例 #4
0
ファイル: outlines.cpp プロジェクト: 0ximDigital/appsScanner
/**********************************************************************
 * near_point
 *
 * Find the point on a line segment that is closest to a point not on
 * the line segment.  Return that point in near_pt.  Returns whether
 * near_pt was newly created.
 **********************************************************************/
bool Wordrec::near_point(EDGEPT *point,
                         EDGEPT *line_pt_0, EDGEPT *line_pt_1,
                         EDGEPT **near_pt) {
  TPOINT p;

  float slope;
  float intercept;

  float x0 = line_pt_0->pos.x;
  float x1 = line_pt_1->pos.x;
  float y0 = line_pt_0->pos.y;
  float y1 = line_pt_1->pos.y;

  if (x0 == x1) {
                                 /* Handle vertical line */
    p.x = (inT16) x0;
    p.y = point->pos.y;
  }
  else {
    /* Slope and intercept */
    slope = (y0 - y1) / (x0 - x1);
    intercept = y1 - x1 * slope;

    /* Find perpendicular */
    p.x = (inT16) ((point->pos.x + (point->pos.y - intercept) * slope) /
      (slope * slope + 1));
    p.y = (inT16) (slope * p.x + intercept);
  }

  if (is_on_line (p, line_pt_0->pos, line_pt_1->pos) &&
    (!same_point (p, line_pt_0->pos)) && (!same_point (p, line_pt_1->pos))) {
    /* Intersection on line */
    *near_pt = make_edgept(p.x, p.y, line_pt_1, line_pt_0);
    return true;
  } else {                           /* Intersection not on line */
    *near_pt = closest(point, line_pt_0, line_pt_1);
    return false;
  }
}